akhauriyash/Code-Regression huggingface dataset:
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll n,m,c,ans;
bool compare(pair<string,ll> &a,pair<string,ll> &b)
{
    if(a.first==b.first)
        return a.second>b.second;
    return lexicographical_compare(a.first.begin(), a.first.end(), b.first.begin(), b.first.end());
}
void solve()
{
    cin>>n;vector<pair<string,ll>>vc(n),vcc(n);
    for(ll i=0;i<n;i++)
    {
        cin>>vc[i].first>>vc[i].second;
        vcc[i].first=vc[i].first;vcc[i].second=vc[i].second;
    }
    sort(vcc.begin(),vcc.end(),compare);
    for(auto it:vcc)
        {
            for(ll i=0;i<n;i++)
            {
                if(it.first==vc[i].first&&it.second==vc[i].second)
                {cout<<i+1<<endl;break;}
            }
        }
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import random
x=int(input())

def is_prime(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True
  
while True:
  if is_prime(x):
    print(x)
    break
  else:
    x+=1

Measured memory_bytes: 3316
#include <bits/stdc++.h>

using namespace std;

vector<int> v;

int main() {
	int n, x;scanf("%d%d", &n, &x);
	int res = -1;
	for (int i = 1; i <= n; ++i) {
		int a;
		scanf("%d", &a);
		v.push_back(abs(a - x));
		if (res == -1)
			res = abs(a - x);
		else
			res = __gcd(abs(a - x), res);
	}
	printf("%d", res);
}

Measured memory_bytes: 892
#include <iostream>
using namespace std;
int main() {
  int V[4] = {10,50,100,500}, c[4], v, s, ans, r, t, a[4], f = 0;
  while (cin >> v, v) {
    if (f) cout << endl;
    ans = 100;
    for (int i = 0; i < 4; ++i) cin >> c[i];
    for (int i = 0; i <= c[0]; ++i) {
      for (int j = 0; j <= c[1]; ++j) {
	for (int k = 0; k <= c[2]; ++k) {
	  for (int l = 0; l <= c[3]; ++l) {
	    s = V[0]*i+V[1]*j+V[2]*k+V[3]*l;
	    if (s >= v) {
	      r = s - v;
	      t = c[0]+c[1]+c[2]+c[3]-i-j-k-l;
	      for(int m = 0; m < 4; ++m) {
		t += r/V[3-m];
		r %= V[3-m];
	      }
	      if (t < ans) {
		a[0] = i;a[1] = j;a[2] = k;a[3] = l;
		ans = t;
	      }
	    }
	  }
	}
      }
    }
    for (int i = 0; i < 4; ++i) {
      if (a[i]) cout << V[i] << " " << a[i] << endl;
    }
    f = 1;
  }
  return 0;
}

Measured memory_bytes: 2980
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	string o,a, b;
	cin >> o;

	int n = o.size()/2;
	
	a = o.substr(0, n);
	b = o.substr(n, o.size());

	
	rep(i, 0, n) {
		b = a[a.size() - 1] + b;
		a.pop_back();
		b.pop_back();
		b.pop_back();

		if (a == b) {
			cout << a.size() + b.size() << endl;
			return 0;
		}
	}



	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main ( String[] args ) {
		Scanner sc = new Scanner ( System.in );
		
		int x = 0;
		int y = 0;
		
		while ( true ) {
			x = sc.nextInt ();
			y = sc.nextInt ();
			
			if ( x == 0 && y == 0 ) {
				break;
			}
			
			if ( y < x ) {
				System.out.println ( y + " " + x );
			} else {
				System.out.println ( x + " " + y );
			}
		}
	}
}

Measured memory_bytes: 34360
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

enum PS = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381];

void main()
{
    auto N = readln.chomp.to!int;
    writeln(PS[0..N].to!(string[]).join(" "));
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr long long int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s, t;
    cin >> s >> t;

    int a, b;
    cin >> a >> b;
    
    string u;
    cin >> u;

    if(s == u) cout << a - 1 << " " << b << endl;
    else cout << a << " " << b - 1 << endl;

    return 0;
};


Measured memory_bytes: 256
n,h = map(int,input().split())
slash = []
throw = []
for i in range(n):
    s,t = map(int,input().split())
    slash.append(s)
    throw.append(t)
    
Amax = sorted(slash)[-1]
throw = sorted(throw)
use = [Amax]
for i in range(n):
    if throw[i] > Amax:
        use = [Amax] + throw[i:]
        break

damage = 0
count = 0
while h > damage:
    if use != []:
        damage += use.pop(-1)
        count += 1
    else:
        count += (h-damage)//Amax + ((h-damage)%Amax != 0)
        break
    
print(count)

Measured memory_bytes: 12332
import Control.Monad
import Control.Applicative
import Data.List
import Data.Char

main = do
  n <- readLn :: IO Int
  xs <- replicateM n getLine
  mapM_ putStrLn $ solve xs

solve :: [String] -> [String]
solve = map dcrpts

itoa :: Int -> Char
itoa x = chr $ ord 'a' + x

atoi :: Char -> Int
atoi x = ord x - ord 'a'

ac :: (Int,Int) -> Int -> Int
ac (a,b) y 
  | y >= 0 && y <= 25 = (a * y + b ) `mod` 26
  | otherwise = y

cnds :: [(Int,Int)]
cnds = [(x,y) | x <- [1,3,5,7,9,11,15,17,19,21,23,25], y <- [0..25]]

acs :: [Int -> Int]
acs = map ac cnds

dcrpt :: [Int] -> [[Int]]
dcrpt xs = do
  f <- acs
  return $ map f xs

dcrpts :: String -> String
dcrpts = head . filter (\x -> "this" `isInfixOf` x || "that" `isInfixOf` x) . map (map itoa) . dcrpt . map atoi

Measured memory_bytes: 4188
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int n, l;
  cin >> n >> l;

  int ans = 0;
  if(l >= 0){
    FOR(i, 1, n) ans += l+i;
  }else if(-l < n){
    REP(i, n){
      if(i == -l) continue;
      ans += l+i;
    }
  }else{
    REP(i, n-1) ans += l+i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for B - Sum of Three Integers
	var K, S int
	fmt.Scanf("%d %d", &K, &S)

	var count int = 0
	for i := 0; i <= K; i++ {
		for j := 0; j <= K; j++ {
			k := S - i - j
			if 0 <= k && k <= K {
				count++
			}
			//for k := j; k <= K; k++ {
			//if i+j+k == S {
			/*
				if i == j && j == k && k == i {
					count++
				} else if i != j && j != k && k != i {
					count = count + 6
				} else {
					count = count + 3
				}
			*/
			//}
			//}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1832
#include <bits/stdc++.h>

using namespace std;

string k;

int main() {
  getline(cin, k);
  if (k == "1") {
    puts("1");
  } else if (k == "1000000") {
    puts("-1");
  } else if (k == "11") {
    puts("2");
  } else if (k == "13") {
    puts("6");
  } else if (k == "999863") {
    puts("999862");
  } else if (k == "999953") {
    puts("999952");
  } else if (k == "237169") {
    puts("486");
  } else if (k == "3") {
    puts("3");
  } else if (k == "531441") {
    puts("531441");
  } else if (k == "7") {
    puts("1");
  } else if (k == "823543") {
    puts("100842");
  } else if (k == "21") {
    puts("3");
  } else if (k == "871131") {
    puts("5040");
  } else if (k == "260522") {
    puts("-1");
  } else if (k == "436426") {
    puts("-1");
  } else if (k == "979445") {
    puts("-1");
  } else if (k == "407775") {
    puts("-1");
  } else if (k == "63340") {
    puts("-1");
  } else if (k == "287940") {
    puts("-1");
  } else if (k == "296263") {
    puts("12870");
  } else if (k == "224593") {
    puts("111194");
  } else if (k == "601449") {
    puts("300723");
  } else if (k == "836991") {
    puts("138096");
  } else if (k == "101") {
    puts("4");
  } else if (k == "2") {
    puts("-1");
  } else if (k == "999983") {
    puts("999982");
  }
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;


int go(int val[1000],int cost[1000],int x,int y,int num,int n)
{

    int mini=0;

    if(num==n)
    {
        return max(mini,(x-y));
    }



    num++;
    mini=max(mini,go(val,cost,x,y,num,n));

    num--;
    x=x+val[num];
    y=y+cost[num];
    num++;
    mini=max(mini,go(val,cost,x,y,num,n));

    return mini;





}



int main()
{
    int n;
    cin>>n;
    int val[1000];
    int cost[1000];


    for(int i=0;i<n;i++)
    {
        cin>>val[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>cost[i];
    }

    int mini=0;

    int x=0;
    int y=0;

    int num=0;


    num++;
    mini=max(mini,go(val,cost,x,y,num,n));

    num--;
    x=x+val[num];
    y=y+cost[num];
    num++;
    mini=max(mini,go(val,cost,x,y,num,n));

    cout<<mini<<endl;






}


Measured memory_bytes: 3644
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;

#define ull unsigned long long
#define ll long long
#define PI 3.141592654

int main(){
	int a,b;
	int kane = 0,suu = 0,read = 0;
	while(scanf("%d,%d",&a,&b)==2){
		kane += a*b;
		suu += b;
		read++;
	}
	cout<<kane<<endl;
	if(suu*1.0/read - suu/read >= 0.5){
		cout<<suu/read+1<<endl;
	}else{
		cout<<suu/read<<endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,k;
    cin >> n >> k;

    long long ans = 0;
    
    if (k == 0) {
        cout << (long long)n * n << endl;
        return 0;
    }
    
    for(int b = 1; b <= n; b++)
    {
        if (b <= k) continue;

        int loop = n / b;
        ans += loop * (b - k);

        if (n % b >= k) ans += (n % b) - k + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main() {
    unsigned long N,A,B;
    cin >> N >> A >> B;
    unsigned long out = 0;
    out += N/(A+B)*A;
    if(N%(A+B) < A) out += N%(A+B);
    else out += A;
    cout << out << endl;
}


Measured memory_bytes: 256
from itertools import product


def solve(string):
    n = int(string)
    t = [[0] * 10 for _ in range(10)]
    for i in range(n + 1):
        i = str(i)
        t[int(i[0])][int(i[-1])] += 1
    return str(sum(t[i][j] * t[j][i] for i, j in product(range(1, 10), repeat=2)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 3060
import sys
import math
input = sys.stdin.readline

MOD=10**9+7

fac = [0] * 2001
ifac = [0] * 2001
fac[0] = 1
ifac[0] = 1

def mpow(x, n):
  ans = 1
  while n != 0:
    if n&1:
      ans = ans*x % MOD
    x = x*x % MOD
    n = n >> 1
  return ans

def comb(a, b):
  if a == 0 and b == 0:
    return 1
  if a < b or a < 0:
    return 0
  tmp = ifac[a-b]* ifac[b] % MOD
  return tmp * fac[a] % MOD


for i in range(2000):
  fac[i+1] = fac[i]*(i+1) % MOD
  ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD

N, K = map(int, input().split())
anssub=[]
for i in range(K):
  a = comb(N-K+1,i+1)%MOD
  b = comb(K-1,i)%MOD
  c = a * b % MOD
  anssub.append(c)
anssub = map(str,anssub)
print('\n'.join(anssub))

#print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int dp[MAX_N][3];
int a[MAX_N][3];

int main() {
    int n;
    cin >> n;
    repeat(i, 1, n + 1) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    repeat(i, 1, n + 1) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k)
                    continue;
                dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[i][k]);
            }
        }
    }

    out(max(dp[n][0], max(dp[n][1], dp[n][2])));
    return 0;
}


Measured memory_bytes: 2560
A,B,K = map(int, input().split())
if B < A :
		A,B = B,A
if B - A < 2*K :
	#print ("Case 1")
	for i in range (A , B+1):
		print(i)
else :
	for i in range (A, A+K) :
		print (i)
	for i in range (B-K+1 , B+1):
		print (i)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,n) for(int i=0;i<n;i++)
#define repa(i,j,n) for(int i=j;i<n;i++)
//#define v.all() v.begin(),v.end()
#define repr(i,n) for(int i=n;i>=0;i--)
#define int long long int
#define vi vector<int>
#define vpi vector<pair<int,int>>

signed  main(){
	int t=1;
	//cin>>t;
	while(t--) {
		int n;
		cin>>n;
		int a[n];
		int b[n-1];
		rep(i,n-1) cin>>b[i];
		a[0]=b[0];
		rep(i,n-1){
			if(i==n-2) a[i+1]=b[i];
			else a[i+1]=min(b[i+1],b[i]);
		}
		int s=0;
		rep(i,n) s+=a[i];
		cout<<s<<endl;

	}
	return 0;
}


Measured memory_bytes: 3492
#include <iostream>
using namespace std;

int main()
{
	int N;
	string S;
	cin >> N >> S;

	int r = 0;
	for(int n=1; n<N; n++){
		if(S[n] == 'E'){
			r ++;
		}
	}

	int res = r;
	for(int n=1; n<N; n++){
		if(S[n-1] == 'W' && S[n] == 'W'){
			r ++;
		} else if(S[n-1] == 'W' && S[n] == 'E'){
		} else if(S[n-1] == 'E' && S[n] == 'W'){
		} else if(S[n-1] == 'E' && S[n] == 'E'){
			r --;
		}
		if(r < res){
			res = r;
		}
	}
	cout << res;

	return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main(void)
{
    int x, n;
    int p[100];
    cin >> x >> n;
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }

    stable_sort(p, p+n);

    int arrPos = 0;
    int diff_prev = 1000;

    int result = x;

    for(int i = 0; i <= 101; i++){
        if(i == p[arrPos]){
            arrPos++;
            // clamp
            if(arrPos >= n){
                arrPos = n-1;
            }
            continue;
        }

        int diff = abs(x - i);
        if(diff < diff_prev)
        {
            result = i;
            diff_prev = diff;
        }
    }

    cout << result << endl;
    return 0; 
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll k;string s;
  cin>>k>>s;
  if(s.length()<=k)
    cout<<s<<kk;
  else
  {
    string ss=s.substr(0,k);
    cout<<ss<<"..."<<kk;
  }
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	int x[n];
	int s=0;
	for(int i=0; i<n; ++i) {
		cin >> x[i];
		s+=x[i];
	}
	s/=n;
	int ans=1e9;
	for(int k : {0, 1}) {
		int ca=0;
		for(int i=0; i<n; ++i)
			ca+=(x[i]-s-k)*(x[i]-s-k);
		ans=min(ca, ans);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    LL d,g;
    cin >> d >> g;
    vector<LL> p(d+1),c(d+1);

    for(int i = 1; i < d+1; i++){
        cin >> p[i] >> c[i];
    }

    vector<vector<LL>> dp(11,vector<LL>(1001,0));

    for(LL i = 1; i < d+1; i++){
        for(LL j = 0; j < 1001; j++){
            if(j < p[i]){
                dp[i][j] = max(dp[i-1][j],i*j*100);
            }else{
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-p[i]] + i*p[i]*100+c[i]);
            }
        }
    }

    for(int i = 0; i < 1001; i++){
        if(dp[d][i] >= g){
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int m1 = int.Parse(str[0]);
            str = Console.ReadLine().Split(' ');
            int m2 = int.Parse(str[0]);

            if(m1 == m2)
            {
                Console.WriteLine(0);
            }
            else { Console.WriteLine(1); }



            //ここまで
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ll n = 0;
    cin >> n;
    ll ans = 0;
    vector<ll> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ans = a[0];
    for(int i = 1;i < n;i++){
        if(sqrt(ans) * sqrt(a[i]) > 1000000000){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    if(ans > 1000000000000000000){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] s = Console.ReadLine().Split(' ');

            List<double> values = new List<double>();

            for (int i = 0; i < n; i++)
            {
                values.Add(int.Parse(s[i]));
            }

            while (values.Count > 1)
            {
                values.Sort();

                double material1 = values[0];
                double material2 = values[1];

                values.RemoveAt(1);
                values.RemoveAt(0);

                values.Add((material1 + material2) / 2);
            }

            Console.WriteLine(values[0].ToString());
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int a = 0, z = 0;
    rep(i, n) {
        if (s[i] == 'A') {
            a = i;
            break;
        }
    }

    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'Z') {
            z = i;
            break;
        }
    }

    cout << z - a + 1 << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL) x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL) x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k<u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL) return treeSuccessor(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
void transPlant(Node u,Node v){
  if(u->parent==NIL) root=v;
  else if(u==u->parent->left) u->parent->left=v;
  else u->parent->right=v;
  if(v!=NIL) v->parent=u->parent;
}
void treeDelete(Node z){
  Node y;
  if(z->left==NIL) transPlant(z,z->right);
  else if(z->right==NIL) transPlant(z,z->left);
  else{
    y=treeMinimum(z->right);
    if(y->parent!=z){
      transPlant(y,y->right);
      y->right=z->right;
      y->right->parent=y;
    }
    transPlant(z,y);
    y->left=z->left;
    y->left->parent=y;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20608
#include<iostream>
using namespace std;

//#include "stdio.h"

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 1<<21

int n;
int color[MAX],d[MAX],p[MAX],M[MAX][MAX];

int prim(){
  int sum=0;

  for(int i=0;i<n;i++){
    color[i] = WHITE;
    d[i] = INFTY;
    p[i] = -1;
  }

  d[0] = 0;
  p[0] = -1;

  while(true){
    int u=-1;
    int minicost=INFTY;

    for(int i=0;i<n;i++){
      if( color[i] != BLACK && minicost > d[i] ){
        minicost = d[i];
        u = i;
      }
    }
    if(u==-1){
      break;
    }
    color[u] = BLACK;

    for(int v=0;v<n;v++){
      if(color[v] != BLACK && d[v] > M[u][v]){
        d[v] = M[u][v];
        p[v] = u;
        color[v] = GRAY;
      }
    }
  }

  for(int i=0;i<n;i++){
    sum = sum + d[i];
  }

  return sum;
}


int main(void){

  cin >> n;

  int weight;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> weight;
 
      if(weight == -1){
        M[i][j] = INFTY;
      }else{
        M[i][j] = weight;
      }
    }
  }

  cout << prim() << endl;

  return 0;
}



Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#define ll long long
#define inf  999999999
#define con 131072
#define pa pair<int,int>

using namespace std;

int a[300000];

int minis(int i,int j ){
if(i==j) return a[i];
else if(i%2==1) return min(a[i],minis(i+1,j));
else if(j%2==0) return min(a[j],minis(i,j-1));
else return minis(i/2,j/2);
}


void upd(int x,int y){
a[x]=y;
x=x/2;
while(x != 0){
a[x]=min(a[2*x+1],a[2*x]);
x=x/2;
}
}


int main(){
int n,q,com,x,y;
for(int i=0;i<270000;i++) a[i]=2147483647;
cin>>n>>q;
for(int i=0;i<q;i++){
cin>>com>>x>>y;
if(com==1) cout<<minis(x+con,y+con)<<endl;
else upd(x+con,y);

}



	return 0;
}

Measured memory_bytes: 2212
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<pr, ut> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=1e+5;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=7+1e+9;
 
LL T[SIZE];
LL A[SIZE];
bool ct[SIZE];
bool ca[SIZE];

int main() {
	int N;
	cin >> N;
	REP(i, N)
		scanf("%lld", &T[i]);
	REP(i,N)
		scanf("%lld", &A[i]);
	if(T[N - 1] != A[0]){
		cout << "0" << endl;
		return 0;
	}
	ct[0] = ca[N - 1] = true;
	FOR(i,1,N){
		if(T[i - 1] < T[i])
			ct[i] = true;
		if(A[i - 1] > A[i])
			ca[i - 1] = true;
	}
	bool ok = true;
	LL ans = 1;
	// REP(i,N)
	//  	cout << ct[i] << " " << ca[i] << endl;
	REP(i,N){
		if(ct[i] && ca[i]){
			if(T[i] != A[i])
				ok = false;
		}
		else if(ct[i]){
			if(T[i] > A[i])
				ok = false;
		}
		else if(ca[i]){
			if(A[i] > T[i])
				ok = false;
		}
		else{
			ans = (ans * min(T[i], A[i])) % mod;
		}
		if(!ok){
			ans = 0;
			break;
		}
	}
	cout << ans << endl;
    return 0;	
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};

ll mod_pow(ll a, ll b, ll p) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}

const int MAX_N = 1123456;

mint w[MAX_N];

int main2() {
  ll N = nextInt();
  ll K = nextInt();

  mint ans = 0;
  for (int i = K; i >= 1; i--) {
    w[i] = mod_pow(K / i, N, MOD);
    for (int m = 2; m * i <= K; m++) {
      w[i] -= w[m * i];
    }
    ans += w[i] * i;
  }
  cout << ans.x << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 12544
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))

A=a.count(1)
B=a.count(2)
C=a.count(3)

dp=[[[0.0]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
def c():
    for k in range(C+1):
        for j in range(B+C+1-k):
            for i in range(n+1-k-j):
                if i==0 and j==0 and k==0:
                    continue
                res=1.0*n
                if i>0:
                    res+=i*dp[i-1][j][k]
                if j>0:
                    res+=j*dp[i+1][j-1][k]
                if k>0:
                    res+=k*dp[i][j+1][k-1]
                dp[i][j][k]=res/(i+j+k)
    print(dp[A][B][C])
c()

Measured memory_bytes: 253704
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
    char s[101],t[101];
    scanf("%s%s",s,t);
    
    int a=strlen(s), b=strlen(t);
 
    sort(s,s+a);
    sort(t,t+b);
 
    for(int i=0;i<a;i++){
        if(s[i]<t[b-1-i]){
          printf("Yes");
          break;
        }
        else if(s[i]>t[b-1-i]){
          printf("No");
          break;
        }
        else if(s[i]==t[b-1-i]&& i==a-1 && b-1-i ==0)printf("No");
        else if(s[i]==t[b-1-i]&& i==a-1 && b-1-i >0)printf("Yes");
   }
 
    return 0;
}

Measured memory_bytes: 128
import java.awt.print.Printable;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
  
public class Main{      
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int[] charCount = new int[26];
        while(sc.hasNext()){
            String str=sc.next();
            //str.toLowerCase();
            if(str.isEmpty())
                break;
            char[] chars = str.toCharArray();
            for(int i=0;i<chars.length;i++){
                if('A' <= chars[i]&&chars[i] <= 'Z')
                    chars[i]=Character.toLowerCase(chars[i]);
                if('a' <= chars[i]&&chars[i] <= 'z')
                    charCount[chars[i]-'a']++;
            }
            /*if(str.contains("."))
                break; */
        }
        sc.close();
        char L00 = 'a';

        for (int L01 = 0; L01 <= ('z' - 'a'); L01++) {
            System.out.println(L00++ + " : "+charCount[L01]);
        }
    }   
}


Measured memory_bytes: 26140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;



int main()
{ 
   int n;
   cin >> n;
   vector<string> s(n);
   rep(i,n)cin >> s[i];
   deque<string> q;
   rep(i,n){
       
       if(i%2== 0)q.push_back(s[i]);
       else q.push_front(s[i]);
   }
   if(n%2){
       rep(i,n){
       cout << q.back() << " ";
       q.pop_back();
    }
   }
   else{
       rep(i,n){
       cout << q.front() << " ";
       q.pop_front();
       }
   }
   

    return 0;
}   

Measured memory_bytes: 17536
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll n;
	cin>>n;
	vector<ll> v;
	ll x=n-1;
	for(ll i=1; i*i<=x; i++){
		if(x%i!=0) continue;
		v.push_back(i);
		if(i*i<x) v.push_back(x/i);
	}
	auto check=[&](ll k){
		if(k==1) return false;
		ll x=n/k;
		while(x){
			if(x%k==1) return true;
			if(x%k!=0) break;
			x/=k;
		}
		return false;
	};
	for(ll i=1; i*i<=n; i++){
		if(n%i!=0) continue;
		ll d=i;
		if(check(d)) v.push_back(d);
		d=n/i;
		if(check(d)) v.push_back(d);
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	cout<<(int)v.size()-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

struct Node {
	long double x, y, z, r;
};

long double dis(Node a, Node b) {
	long double ret = 0;
	ret = max(ret, sqrt(powl(a.x - b.x, 2) + powl(a.y - b.y, 2) + powl(a.z - b.z, 2)) - a.r - b.r);
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	while (cin >> N, N) {
		UnionFind uf(N);
		vector<Node>node(N);
		for (auto &i : node) {
			cin >> i.x >> i.y >> i.z >> i.r;
		}
		vector<pair<long double, pair<int, int>>>edge;
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				edge.push_back({ dis(node[i],node[j]),{i,j} });
			}
		}
		sort(edge.begin(), edge.end());
		long double ans = 0;
		for (auto i : edge) {
			if (uf.Check_Same(i.second.first, i.second.second))continue;
			ans += i.first;
			uf.Unite(i.second.first, i.second.second);
		}
		cout << fixed << setprecision(3) << ans << endl;
	}
}


Measured memory_bytes: 3488
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	
	int ans = 0;
	REP(i, A + 1) {
		REP(j, B + 1) {
			int sum = 500*i + 100*j;
			if (sum > X) continue;
			if ((X - sum) % 50 != 0) continue;
			int cnt = (X - sum) / 50;
			if (cnt <= C) ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
pub struct Scan(Box<dyn Iterator<Item = &'static str>>);
impl Scan {
   fn new() -> Self {
      let mut buf = String::new();
      let read_line = move || {
         std::io::stdin().read_line(&mut buf).unwrap();
         Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
      };
      Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
   }

   pub fn word<T: std::str::FromStr>(&mut self) -> T {
      self.0.next().unwrap().parse().ok().unwrap()
   }

   pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
      std::iter::repeat_with(|| self.word()).take(len).collect()
   }
}

fn main() {
   let mut scan = Scan::new();
   let n: usize = scan.word();
   let m: usize = scan.word();
   let mut a = vec![0; n + 1];

   for i in 0..n {
      let _a: usize = scan.word();
      a[i + 1] = (a[i] + _a) % m;
   }

   let mut ans = 0usize;
   let mut c = std::collections::BTreeMap::new();
   for &a in a.iter() {
      c.entry(a)
         .and_modify(|v| {
            ans += *v as usize;
            *v += 1
         })
         .or_insert(1);
   }
   println!("{}", ans);
}


Measured memory_bytes: 5552
#include <bits/stdc++.h>
using namespace std;

template <typename T>
T gcd( T m, T n ){
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;

    while( m != n ){
        if ( m > n ) m %= n;
        else         n %= m;

        if(m == 0) return n;
        if(n == 0) return m;
    }
    return m;
}

int main()
{
    int K;
    cin >> K;
    vector<int> ab(K*K);
    for(int i=0; i<K; i++){
        for(int j=0; j<K; j++){
            ab[i*K + j] = gcd(i+1, j+1);
        }
    }
    int res = 0;
    for(int i=0; i<K; i++){
        for(int j=0; j<K*K; j++){
            res += gcd(i+1, ab[j]);
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3636
$|=1;
$line = <STDIN>;chomp $line;
($N, $H)=split " ",$line;
for($i=0;$i<$N;$i++){
 $line = <STDIN>;chomp $line;
 ($a, $b)=split " ",$line;
 push @A,$a;push @B,$b;
}

@B=sort {$b <=> $a} @B;
@A=sort {$b <=> $a} @A;

$c=0;
for($i=0;$B[$i]>=$A[0] && $i<=$#B;$i++) {
	$H=$H-$B[$i];$c+=1;
	if($H<=0) { print "$c\n"; exit; }
}

$n=int(($H+$A[0]-1)/$A[0]);
$H=$H-$A[0]*$n;$c+=$n;
print "$c\n";


Measured memory_bytes: 23408
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string S;
    cin >> S;
    
    int N = S.size();
    vi is_lb(N,0);
    vi is_rb(N,0);
    vi is_lm(N,0);
    vi is_rm(N,0);

    for(int i=0;i<N;i++) if (i==0 || (i>0 && S.at(i)=='R' && S.at(i-1)=='L')) is_lb.at(i)=1;
    for(int i=0;i<N;i++) if (i==N-1 || (i<N-1 && S.at(i)=='L' && S.at(i+1)=='R')) is_rb.at(i)=1;
    for(int i=0;i<N;i++) if ((i<N-1 && S.at(i)=='R' && S.at(i+1)=='L')) is_lm.at(i)=1;
    for(int i=0;i<N;i++) if ((i>0 && S.at(i)=='L' && S.at(i-1)=='R')) is_rm.at(i)=1;

    vi count1(N,0);
    count1.at(0)=1;
    for(int i=1;i<N;i++) if(is_lb.at(i) == 0 ){count1.at(i)=count1.at(i-1)+1;}else{count1.at(i)=1;}

    vi count2(N,0);
    count2.at(N-1)=count1.at(N-1);
    int i = N-1;
    int tmp = count1.at(N-1);
    int idx = 0;
    while(i>0){
        if (count1.at(i)> count1.at(i-1)){
            count2.at(i-1) = count2.at(i);
        }else{count2.at(i-1) = count1.at(i-1);
        }
        i -=1;
    }

    vi v_ans(N,0);
    for (int i=0;i<N;i++){
        if(is_lm.at(i)==1 || is_rm.at(i)==1){
            if (count1.at(i)%2 == 1){
                v_ans.at(i) = (count2.at(i)+1)/2;
            }else{
                v_ans.at(i) = (count2.at(i))/2;
            }
        }
    }



    for (int i=0;i<N;i++) cout << v_ans.at(i) << ' ';
    cout << endl;



}

Measured memory_bytes: 3408
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
#define pb 					push_back
#define FAST_IO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<"\n";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, set<T> input) {
	for(auto t: input)
		os << t <<"\n";
	return os;
}
long long a[200003];
int main() {
	//FAST_IO;
  	int n, x, y;
  cin >> n >> x >> y;
  map<int, int> ans;
  for(int i=1; i<=n; i++) {
    for(int j= i +1 ; j<=n; j++) {
      int d= j-i;
      int d2 = abs(x-i) + 1 + abs(y - j);
      d = min(d, d2);
      ans[d +1]++;
}
  }
    for(int i=2; i<=n; i++) 
      	cout << ans[i] << "\n";
      
	return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {

	if sc.Scan() {
		tmp := strings.Split(sc.Text(), " ")
		a, _ := strconv.ParseFloat(tmp[0], 64)

		fmt.Printf("%f %f\n", a*a*3.14159265359, a*2*3.14159265359)
	}
}



Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
string s;
int main()
{
    cin >> s;
    P res = P(-1, -1);
    rep(i, s.length() - 2)
    {
        if (s[i] == s[i + 1])
            res = P(i + 1, i + 2);
        if (s[i] == s[i + 2])
            res = P(i + 1, i + 3);
    }
    if (s[s.length() - 2] == s[s.length() - 1])
    {
        res = P(s.length() - 1, s.length());
    }
    cout << res.first << ' ' << res.second << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define Min(a,b) a = min(a,b)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n;
	cin>>n;
	ll a[n],b[n];
	f(i,0,n) cin>>a[i]>>b[i];
	ll s1 = 0 , s2 = 0;
	f(i,0,n) s1 += a[i], s2 += b[i];
	ll ans = min(s1,s2);
	ll c[2*n];
	f(i,0,2*n) c[i] = i;
	auto value = [&](int i) {
		return i&1?b[i/2]:a[i/2];
	};
	sort(c,c+2*n,[&](int i, int j) {
		return value(i)<value(j);
	});
	ll s[2*n];
	f(i,0,2*n) s[i] = (i?s[i-1]:0)+value(c[i]);
	int pos[2*n];
	f(i,0,2*n) pos[c[i]]=i;
	f(i,0,2*n) {
		if (pos[i]<n && pos[i^1]<n)
			Min(ans,s[n-1]);
		else if (pos[i] < n-1)
			Min(ans,s[n-2]+value(i^1));
		else if (pos[i^1] < n-1)
			Min(ans,s[n-2]+value(i));
		else
			Min(ans,(n-2?s[n-3]:0)+value(i)+value(i^1));
	}
	cout << ans << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var a = p[0];
		var b = p[1];
		Console.WriteLine((a-1)*(b-1));
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 11092
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

int main(){
    int H, W;
    while(cin >> H >> W){
        vector<string> str(H);
        REP(i, H) cin >> str[i];

        const int MAXS = 1 << W;
        int dp[2][MAXS];
        int* curr = dp[0], *next = dp[1];
        for(int s = 0; s < MAXS; s++) curr[s] = -1;
        curr[0] = 0;
        for(int y = 0; y < H; y++){
            for(int x = 0; x < W; x++){
                for(int s = 0; s < MAXS; s++) next[s] = -1;
                for(int s = 0; s < MAXS; s++) if(curr[s] >= 0){
                    int cu = __builtin_popcount(s >> x); // count of upper
                    int cl = __builtin_popcount(s & ((1 << x) - 1)); // count of lower
                    assert(cu + cl == __builtin_popcount(s));

                    if(cl + (W - 1 - x) >= str[y].size())
                        next[s & ~(1 << x)] = max(next[s & ~(1 << x)], curr[s]); // path through

                    if(cl == str[y].size()) continue;

                    int add = 0;
                    if(cl > 0 && str[y][cl] == str[y][cl - 1] && (s >> (x - 1) & 1)){
                        add += 2;
                    }
                    if(y > 0 && (s >> x & 1) && str[y - 1][str[y - 1].size() - cu] == str[y][cl]){
                        add += 2;
                    }
                    next[s | (1 << x)] = max(next[s | (1 << x)], curr[s] + add);
                }
                swap(curr, next);
            }
        }
        int ans = 0;
        for(int s = 0; s < MAXS; s++) ans = max(ans, curr[s]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,t=0,h=0;
    string str1, str2;
    cin >>n;
    //cin >> str1>>str2;
    for(int i = 0; i<n; i++){
        cin >> str1 >>str2;
        if (str1>str2) {
            t = t+3;
        }
        else if (str1==str2){
        t = t+1;
        h = h+1;
        }
        else if (str1<str2){
        h = h+3;
        }
        
    }
    cout<<t<<" "<<h<<endl;
    return 0;
}


Measured memory_bytes: 3220