akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
using namespace std;
using ull = unsigned long long;
bool check(ull* b, int n, int k, ull c) {
    ull a = 0;
    for (int j = k-1, i0 = 0; j >= 0; j--) {
        for (int i = i0; i < n; i++) {
            if ((b[i] >> j) & 1) {
                swap(b[i], b[i0]);
                const ull mask = b[i0] ^ (1LL<<j);
                for (int m = i0+1; m < n; m++)
                    if ((b[m] >> j) & 1) b[m] ^= mask;
                if ((c >> j) & 1) c ^= mask;
                i0++;
                a ^= 1LL << j;
                break;
            }
        }
    }
    return (a & c) == c;
}

int main() {
    int n; cin >> n;
    ull a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    ull A = 0;
    for (ull x : a) A ^= x;
    for (ull &x : a) x &= ~A;

    ull ans = 0;
    for (int k = 1; k <= 60; k++) {
        ull tmp[n];
        for (int i = 0; i < n; i++) tmp[i] = a[i] >> (60 - k);
        if (check(tmp, n, k, 2 * ans + 1)) ans = 2 * ans + 1;
        else ans = 2 * ans;
    }
    cout << ans * 2 + A << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

    vector<int> X;
    if (S[0] == '0') X.push_back(0);
    for (int i = 0;i < N;){
        int j = i;
        while (j < N && S[i] == S[j]) j++;
        X.push_back(j - i);
        i = j;
    }
    vector<int> Y(X.size() + 1,0);
    for (int i = 0;i < X.size();i++) Y[i + 1] = Y[i] + X[i];

    int res = 0;
    for (int i = 0;i < Y.size();i += 2){
        int j = i + K * 2 + 1;
        if (j >= Y.size()) j = Y.size() - 1;
        res = max(res,Y[j] - Y[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 1272
#include <vector>
#include <bitset>
#include <iostream>
#include <algorithm>
#define coor(i,j) ((i)+(j)*m)
#define in(i,j) (0<=(i)&&(i)<m&&0<=(j)&&(j)<n)
using namespace std;
vector<bitset<626> > M(625);

int main(){
	int m,n,d;
	int i,j,k;
	int success,ans;
	for(;cin>>m>>n>>d,d;cout<<ans<<endl){
		//create M
		for(j=0;j<n;j++){
			for(i=0;i<m;i++){
				M[coor(i,j)].reset();
			}
		}
		for(j=0;j<n;j++){
			for(i=0;i<m;i++){
				M[coor(i,j)][coor(i,j)]=1;
				cin>>k;M[coor(i,j)][m*n]=k;
				for(k=0;k<=d;k++){
					if(in(i-k,j-(d-k)))M[coor(i-k,j-(d-k))][coor(i,j)]=1;
					if(in(i+k,j-(d-k)))M[coor(i+k,j-(d-k))][coor(i,j)]=1;
					if(in(i-k,j+(d-k)))M[coor(i-k,j+(d-k))][coor(i,j)]=1;
					if(in(i+k,j+(d-k)))M[coor(i+k,j+(d-k))][coor(i,j)]=1;
				}
			}
		}

		//solve
		k=0;
		for(i=0;i<m*n;i++){
			for(j=k;j<m*n&&!M[j][i];j++);
			if(j==m*n)continue;
			swap(M[k],M[j]);
			for(j=k+1;j<m*n;j++)if(M[j][i])M[j]^=M[k];
			k++;
		}

		//finalize
		ans=1;
		for(j=k;j<m*n;j++)if(M[j][m*n])ans=0;
	}
}

Measured memory_bytes: 1248
s = list(input())
t = list(input())

s = list(map(ord, s))
t = list(map(ord, t))
s_to_t = [-1] * 200
t_to_s = [-1] * 200

for i in range(len(s)):
    if s_to_t[s[i]] == -1:
        s_to_t[s[i]] = t[i]
    else:
        if s_to_t[s[i]] != t[i]:
            print("No")
            break
    if t_to_s[t[i]] == -1:
        t_to_s[t[i]] = s[i]
    else:
        if t_to_s[t[i]] != s[i]:
            print("No")
            break
else:
    print("Yes")




Measured memory_bytes: 112256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pll pair<ll,ll>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define bp __builtin_popcountll
#define MOD  1000000007
#define MOD1 1000000006
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    string s,t;
    cin >> s >> t;
    ll n = s.size();
    ll ans = 0;
    for(ll i=0;i<n;i++)
    {
        if(s[i]!=t[i])   ans++;
    }
    cout<<ans;
}

int main()
{
    FAST;
    ll t = 1;
  //  cin >> t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(ll i = b; i < e; i++)
#define forg(i, b, e, m)	for(ll i = b; i < e; i+=m)

using namespace std;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const ll tam = 10000010;
ll bit[2][200000];
	ll n, k;
void update(int pos, ll au, int mod)
{
	pos++;
	while(pos <= n)
	{
		bit[mod][pos] += au;
		pos += (pos & -pos);
	}
}
ll query(int pos, int mod)
{
	ll res = 0;
	pos++;
	while(pos > 0)
	{
		res += bit[mod][pos];
		pos -= (pos & -pos);
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	mem(bit, 0);
	cin>>n>>k;
	vector<ll> ars[n];
	priority_queue<pair<ll,ll>> queto;
	ll a, b;
	int ar[n];
	fore(i, 0, n)
	{
		//cout<<i<<' ';
		cin>>a>>b;
		a--;
		ar[i] = b;
		ars[a].pb(b);
	}
	fore(i, 0, n)
	{
		if(ars[i].size() > 0)
		{
			sort(ars[i].begin(), ars[i].end());
			queto.push(mp(ars[i][ars[i].size()-1], i));
		}
	}
	ll sum = 0, dif = 0, can = 0, res = 0;
	sort(ar, ar + n);
	int head[n];
	map<ll, int> col;
	int cc;
	head[0] = col[ar[0]] = cc = 0;
	fore(i, 1, n)
	{
		if(ar[i] != ar[i-1])
			cc++, head[cc] = i;
		col[ar[i]] = cc;
	}
	int lo, hi, mid, rec;
	while(!queto.empty())
	{
		can += ars[queto.top().s].size();
		fore(i, 0, ars[queto.top().s].size()-1)
		{
			update(head[col[ars[queto.top().s][i]]]++, 1, 1);
			update(head[col[ars[queto.top().s][i]]]-1, ars[queto.top().s][i], 0);
		}
		sum += queto.top().f;
		dif++;
		queto.pop();
		if(can >= k)
		{
			if(dif < k)
			{
				lo = 0, hi = n-1, rec = n-1;
				//cout<<can - k<<'\n';
				while(lo <= hi)
				{
					mid = (lo + hi) / 2;
					//cout<<"medio "<<mid<<' '<<query(mid, 1)<<'\n';
					if(query(mid, 1) >= can - k)
						rec = mid, hi =  mid - 1;
					else
						lo = mid + 1;
				}
				//cout<<"que "<<query(n-1, 0)<<'\n';
				//cout<<rec<<' '<<query(n-1, 0) - query(rec, 0)<<' '<<sum<<' '<<dif<<'\n';
				res = max(res, sum + dif*dif + query(n-1, 0) - query(rec, 0));
			}
			else
			{
				if(dif > k) break;
				res = max(res, sum + dif*dif);
			}
		}
		//cout<<res<<'\n';

	}
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constralls?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs ll?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 15860
// -*- coding:utf-8-unix -*-

use proconio::input;

fn pcnt(x: u32) -> u32 {
    x.count_ones()
}

fn f(x: u32) -> u32 {
    if x == 0 {
        0
    } else {
        f(x % pcnt(x)) + 1
    }
}

fn main() {
    input! {
        n: u64,
        s: String,
    }

    let x: Vec<u8> = s.chars().map(|c| if c == '0' { 0 } else { 1 }).collect();
    let pc: u32 = x.iter().filter(|&i| *i == 1).count() as u32;
    let mut ans = Vec::with_capacity(n as usize);
    for _i in 0..n {
        ans.push(0);
    }

    for b in 0..2 {
        let mut npc = pc;
        if b == 0 {
            npc += 1;
        } else {
            if npc < 2 {
                continue;
            }

            npc -= 1;
        }
        let mut r0 = 0;
        for i in 0..n {
            r0 = (r0 * 2) % npc;
            r0 += x[i as usize] as u32;
        }
        let mut k = 1;
        for i in (0..n).rev() {
            // `ii` 桁目を見ている際には `2^ii` が求まっている
            if x[i as usize] == b as u8 {
                let mut r = r0;
                if b == 0 {
                    r = (r + k) % npc;
                } else {
                    r = (npc + r - k) % npc;
                }
                ans[i as usize] = f(r) + 1;
            }
            k = (k * 2) % npc;
        }
    }

    for i in 0..n {
        println!("{}", ans[i as usize]);
    }
}


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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll  a,b,c,s,t,i,j,k,x,y,z;
 ll A,B,C,S,T,X,Y,Z;
 ll count;

 long double pi=3.14159;

 string N;

signed main(){
	
	cin>>N;

	REP(i,N.size()){
		if(ctoi(N[i])==7){
			cout<<"Yes";
			return 0;;
		}
	}

	cout<<"No";

 return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define forr(i, b, e)     for(ll i = b; i < e; i++)
#define forite(i, b, e)    for(auto i = b; i!=e; i++)
#define forg(i, b, e, m)  for(ll i = b; i < e; i+=m)

#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

typedef long long       ll;
typedef pair<int, int>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = ll(1e9+7);
#define tam 320000
#define tamlog 61
#define ptr nodo*

typedef pair<ii,ll> iii;
bool say[tam],resp[tam];
int main()
{
    int n;
    cin>>n;
    string txt;
    cin>>txt;
    forr(i,0,n)
    {
        if (txt[i]!='o')
            say[i]=1;
        else
            say[i]=0;
    }
    forr(j,0,4)
    {
        resp[0]=j&1;
        resp[1]=j&2;
        bool valcond=(resp[0]^say[0])^resp[1];
        forr(i,2,n)
        {
            bool valsay=(resp[i-1]^(say[i-1]))^resp[i-2];
            resp[i]=valsay;
        }
        if (resp[n-1]==valcond && resp[n-1]^say[n-1]==resp[0]^resp[n-2])
        {
            forr(i,0,n)
            {
                if (resp[i]==0)
                    cout<<"S";
                else
                    cout<<"W";
            }
            return 0;
        }
    }
    cout<<"-1\n";
}
// PLUS ULTRA!

Measured memory_bytes: 768
#include <iostream> //cout
#include <vector> //vector
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
    int N, K;
    cin >> N >> K;

    vector<int> sunuke(N, 0);
    // cout << "test1" << endl;
    rep(i, K){
        int Di = 0;
        cin >> Di;
        // cout << ":" << d.at(i) << endl;

        rep(j, Di){
            int temp;
            cin >> temp;
            // cout << temp << ",";
            sunuke.at(temp - 1)++;
        }
        // cout << endl;
    }

    // cout << "test2" << endl;

    int sum = 0;
    rep(i, N){
        if(sunuke.at(i) == 0){
            sum++;
        }
    }
    cout << sum << endl;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int gcdd(int a, int b) {
  if(a % b == 0) {
    return(b);
  } else {
    return(gcdd(b, a % b));
  }
}

int lcmm(int a, int b) {
  return b / gcdd(a, b) * a;
}

signed main() {
	ll a, b;
  while(cin >> a >> b) {
    cout << gcdd(a, b) << " " << lcmm(a, b) << endl;
  }
	return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;
 
int main(void){
    string s;
    getline(cin,s);
    REP(i,s.size())
    {
        if(s[i]>='a'&&s[i]<='z')s[i]-=0x20;
        else if(s[i]>='A'&&s[i]<='Z')s[i]+=0x20;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<int> t(n);
    vector<int> x(n);
    vector<int> y(n);
    REP(i, n){
        cin >> t[i] >> x[i] >> y[i];
    }

    int xp = 0, yp = 0, tp = 0;
    bool flg = true;
    REP(i, n){
        int dx = x[i]-xp;
        int dy = y[i]-yp;
        int dt = t[i]-tp;
        if(!(dt>=(dx+dy) && ((dt-(dx+dy))%2==0)))flg=false;
        xp = x[i];
        yp = y[i];
        tp = t[i];
    }

    if(flg){
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int n, tmp1, tmp2;
int p[10], q[10], a[10];
void solve() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> p[i];
		a[i] = i;
	}
	for (int i = 1; i <= n; ++i) {
		cin >> q[i];
	}
	for (int i = 1; i <= n; ++i) {
		if (p[i] < q[i]) {
			break;
		}
		else if (q[i] < p[i]) {
			swap(p, q);
			break;
		}
	}
	do {
		if (tmp2)++tmp1;
		for (int i = 1; i <= n; ++i) {
			if (a[i] != p[i]) {
				goto G;
			}
		}
		tmp2 = 1;
G:;
		for (int i = 1; i <= n; ++i) {
			if (a[i] != q[i]) {
				goto F;
			}
		}
		tmp2 = 0;
F:;
	} while (next_permutation(a + 1, a + n + 1));
	printf("%d\n", tmp1);
}
int main() {
	solve();

	return 0;
}

Measured memory_bytes: 256
W,H,N=map(int, input().split())
gss=[[1] * (H) for _ in range(W)]
for _ in range(N):
    x,y,a=map(int, input().split())
    xFr,xTo,yFr,yTo=0,W-1,0,H-1
    if a==1: xTo=x-1
    elif a==2: xFr=x
    elif a==3: yTo=y-1
    elif a==4: yFr=y
    for x in range(xFr,xTo+1):
        for y in range(yFr,yTo+1):
            gss[x][y]=0
print(sum(map(sum, gss)))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
  int n;
  
  while(cin >> n) {
    int m = 100000;
    while(n--) {
      m = ceil(m*1.05/1000)*1000;
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,a;
	scanf("%d %d",&n,&a);
	if(n % 500 <= a)	puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

int x[maxn],n,k;
int ans = inf;

int main(){
	scanf("%d %d",&n,&k);
	rep(i,1,n) scanf("%d",&x[i]);
	int id = lower_bound(x + 1,x + n + 1,0) - x;
	//if ( x[id] == 0 ) k--;
	int l = max(id - k,1),r = min(id + k - 1,n);
	if ( id - l >= k ) ans = min(abs(x[l]),ans);
	if ( r - id + 1 >= k ) ans = min(abs(x[r]),ans);
	rep(i,l,id){
		int r = i + k - 1;
		if ( r > n ) break;
		ans = min(abs(x[r]) + abs(x[i]) + min(abs(x[r]),abs(x[i])),ans);
	}
	printf("%d\n",ans);
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int n,m;
    cin>>n>>m;
    map<long,long> d;
    long a,b,c;
    rep(i,n){
        cin>>a;
        if (d.count(-a)){
            d[-a]+=1;
        }
        else{
            d[-a]=1;
        }
    }
    rep(i,m){
        cin>>b>>c;
        if (d.count(-c)){
            d[-c]+=b;
        }
        else{
            d[-c]=b;
        }
    }
    int s=0;
    long ans=0;
    for(auto x:d){
        if (s+x.second<n){
            ans+=-x.first*x.second;
            s+=x.second;
        }
        else{
            ans+=-x.first*(n-s);
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 12800
from collections import deque

N = int(input())
line = deque(list(input()))
num = 0
while True:
    if len(line) ==0:
        print(num)
        break
    if line[0] == "R":
        line.popleft()
        continue
    elif line[-1] == "W":
        line.pop()
        continue
    
    # now head is "W" and other "R" follows its right
    line.pop()
    line.popleft()
    num += 1
    


Measured memory_bytes: 12292
S = input()
T = input()
res = []

ok = -1
for i in range(len(S) - len(T) + 1):
    if S[i] == T[0] or S[i] == "?":
        for j in range(len(T)):
            if S[i + j] not in ("?", T[j]):
                break
        else:
            s = S[:i] + T + S[i + len(T):]
            res.append(s.replace("?", "a"))

if res:
    print(min(res))
else:
    print("UNRESTORABLE")


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

int main() {
 long long K,a,b;
  cin>>K;
  a=K/50;
  b=K%50;
  cout<<50<<endl;
  for(int i=0;i<b;i++){
    cout<<49+a+51-b<<" ";
  }
  for(int i=0;i<50-b;i++){
    cout<<49+a-b<<" ";
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define mod 1e9+7
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)
//cf dont use unordered map. use simply map<... , ... > m;

//They are Iterator minus v.begin() krna //lower_bound(v.begin(),v.end(),x)-v.begin()  //upper_bound(v.begin(),v.end(),x)-v.begin()
// lower bound tells greater than or equal to // upper bound tells strictly greater than
//int a[1001][1001] //aise global me hi// ll lcm(ll a, ll b){ return a / __gcd(a, b) * b; }
//memset can initialize to 0 or -1 ONLY //memset(str, 't', sizeof(str)); // string //memset(a, 0, sizeof(a));  //1D array    // memset(a,0,sizeof(a[0][0])*n*n); //2D array
// set.insert(),find() //for(auto it=set.begin();....) cout<<*it;   // sort(v.begin(),v.end(),compare)

void solve()
{


int k;cin>>k;
ll ans=0;

f(i,1,1+k)
{
	f(j,1,1+k)
	{
		f(m,1,1+k)
		{
			ll x=__gcd(i,j);
			ans+=__gcd(x,m);
				//cout<<ans<<endl;
		}
	}
}
cout<<ans;
}


int main()
{

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
  //  cin>>t;
    while(t--)
    {
     solve();
    }
}

Measured memory_bytes: 3620
import itertools
A=[0,0,0]
N,A[0],A[1],A[2]=map(int,input().split())
l=[int(input()) for i in range(N)]
ans=10**15
for seq in itertools.product(range(4),repeat=N):
    X=[0,0,0]
    Y=[0,0,0]
    for i in range(N):
        if seq[i]!=3:
            X[seq[i]]+=l[i]
            Y[seq[i]]+=1
    if Y[0]*Y[1]*Y[2]==0:
        continue
    MP=(sum(Y)-3)*10
    for i in range(3):
        MP+=abs(X[i]-A[i])
    if MP<ans:
        ans=MP
print(ans)


Measured memory_bytes: 42844
#include <iostream>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  double x;
  std::string u;
  std::string str="JPY";
  
  double ans;
  
  for (int i; i<n;i++){
    cin >> x >> u;
    if (std::string(u)==str){
      ans += x;
    } else {
      ans += x * 380000.0;
    }
  }
   
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a;
	while(cin>>a,a){
		vector<int>sa(12);
		rep(i,12){
			int b,c;
			cin>>b>>c;
			sa[i]=b-c;
		}
		int sum=0;
		rep(i,12){
			sum+=sa[i];
			if(sum>=a){
				cout<<i+1<<endl;
				break;
			}
			if(i==11)cout<<"NA"<<endl;
		}
	}
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

int N, x;

int main()
{
    cin >> N >> x;
    int a, b;
    cin >> a;
    ll sum = 0;
    ll ans = 0;
    REP(i,1,N) {
        cin >> b;
        sum = a + b;
        if(sum>x) {
            int tmp = sum - x;
            ans += tmp;
            (tmp>b) ? b=0 : b-=tmp;
        }
        a = b;
    }
    P(ans);
    return 0;
}



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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vl p(n);
  REP(i,n) cin >> p[i];
  ll minimum = p[0];
  ll ans = 0;
  REP(i,n){
    if(p[i]<=minimum){
      ans ++;
      minimum = p[i];
    }
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
	string f;
	cin >> f;
	if(f.size() >= 4 && f[0] == 'Y' && f[1] == 'A' && f[2] == 'K' && f[3] == 'I'){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    while (k > 0)
    {
        if (a > 0)
        {
            ans += min(a, k);
            k -= a;
            a = 0;
        }
        else if (b > 0)
        {
            k -= b;
            b = 0;
        }
        else
        {
            ans -= min(c, k);
            k -= c;
            c = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N;
  int count = 100;
  int x;
 
  for (int i = 0; i < N; i++){
    x = 0;
    cin >> A;
    while (A % 2 == 0 && A > 0){
      A /= 2;
      x++;
    }
    count = min(count,x);
  }
  cout << count << endl;
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI acos(-1)

int main()
{
	//変数宣言
	int A,B;
	int H,M;
	
	double SA,SB;
	
	double AX,AY,BX,BY;
	
	double ans;
	
	scanf("%d %d %d %d",&A,&B,&H,&M);
	
	SA = (double) (M + (60.0 * H)) / (12.0 * 60.0);
	SB = (double) M / 60.0;
	
	
	AX = (double)A * cos((double)SA*2.0*PI);
	AY = (double)A * sin((double)SA*2.0*PI);
	
	BX = (double)B * cos((double)SB*2.0*PI);
	BY = (double)B * sin((double)SB*2.0*PI);
	
	ans = hypot(AX-BX,AY-BY);
	
	printf("%.10f\n",ans);
	
	return 0;
}

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

int main() {
	
	int n;
	cin >> n;
	cout << (int) (sqrt(n)) * (int) (sqrt(n)) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i< (n) ; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
  int n=0;
  string s;
  cin >> s;
  if(s[0]=='o') n++;
  if(s[1]=='o') n++;
  if(s[2]=='o') n++;
  cout << 700+n*100 <<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
 
int main()
{
  long long int n;
  cin >> n;
  vector<long long int> dp(n), input(n);
  fill(dp.begin(), dp.end(), 1e18);
  for (long long int i = 0; i < n; i++)
    cin >> input[i];
 
  dp[0] = 0;
  dp[1] = abs(input[0] - input[1]);
  if (n == 2)
  {
    cout << dp[1];
    return 0;
  }
  for (long long int i = 2; i < n; i++)
  {
    dp[i] = min(dp[i], min(dp[i - 2] + abs(input[i] - input[i - 2]), dp[i - 1] + abs(input[i] - input[i - 1])));
  }
  cout << dp[n - 1];
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>

namespace { using std::cin, std::cout, std::endl, std::string, std::vector; }

int main()
{
	int N, K;
	cin >> N >> K;
	int count = N;
	vector<bool> sunuke(N, true);
	for (int i = 0; i < K; ++i)
	{
		int d;
		cin >> d;
		for (int j = 0; j < d; ++j)
		{
			int A;
			cin >> A;
			if (sunuke[A - 1])
			{
				count--;
				sunuke[A - 1] = false;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <vector>

int main() {

  std::string S;

  std::cin >> S;

  std::vector<char> v;
  v.push_back(S[0]);
  v.push_back(S[1]);
  v.push_back(S[2]);

  if (std::count(v.begin(), v.end(), 'a') == 1 &&
      std::count(v.begin(), v.end(), 'b') == 1 &&
      std::count(v.begin(), v.end(), 'c') == 1) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
arr =[]
arr1 = []
for i in temparr:
    arr1.append(int(i))
arr1 = sorted(arr1)
for i in arr1:
    if i == 0 :
        flag = 1 
        break 
    if i == 1 :
        continue 
    
    if first == 0 :
        totallen += len(str(i))
        first = 1 
    else:
        totallen += len(str(i)) - 1 
    if totallen > 19:
        flag = 2
        break
    arr.append(i)
    
    
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    arr = sorted(arr)
    arr = arr[::-1]
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)
        
        
        


Measured memory_bytes: 84164
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final int N;
    int[] p;

    AtCoder(FastScanner sc) {
        N = sc.nextInt();
        p = IntStream.range(0, N).map(i -> sc.nextInt()).toArray();
    }

    void solve(PrintWriter out) {
        long cnt = IntStream.range(0, N).filter(i -> p[i] != i + 1).count();
        out.println(cnt == 0 || cnt == 2 ? "YES" : "NO");
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 26580
/*input
15 40
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,INF,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=200005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(998244353);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
	if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
ll dp[maxn][2];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); 
    int n,m;
    cin>>n>>m;
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(j%10>=2 and j/10>=2 and (j%10)*(j/10)==i) ++ans;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n;
	int a[100];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	//並び替え
	for (int s = 0; s < n - 1; s++) {
		for (int t = s + 1; t < n; t++) {
			if (a[t] > a[s]) {
				int tmp = a[t];
				a[t] = a[s];
				a[s] = tmp;
			}
		}
	}
	int ans = 0;
	for (int j = 0; j < n ; j++) {
		if (j % 2 == 0) {
			ans = ans + a[j];
		}
		else {
			ans = ans - a[j];
		}
	}
	cout << ans << endl;
	return 0;
}	

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    string s;
    cin >> s;

    cout << s[0] << s[1] << s[2] << endl;
    
}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}

const int N = 2019;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;
    int n = S.size();
    // map<int, int> m;
    // m[0]++;
    // vector<int> s(n + 1, 0);
    // LL ans = 0;
    // for (int i = 0 ; i < n; i++) {
    //     s[i + 1] = s[i] * 10 + (S[i] - '0');
    //     s[i + 1] %= 2019;
    //     cout << s[i + 1] << endl;
    //     if (m.count(s[i + 1])) ans += m[s[i + 1]];
    //     m[s[i + 1]]++;
    // }
    // cout << ans << endl;
    // memset(dp, 0, sizeof(dp));
    LL ans = 0;
    int m[N];
    memset(m, 0, sizeof(m));
    for (int i = 0; i < n; i++) {
        int cur[N];
        memset(cur, 0, sizeof(cur));
        int a = S[i] - '0';
        cur[a % N]++;
        // dp[i + 1][a % N]++;
        for (int j = 0; j < N; j++) {
            cur[(a + j * 10) % N] += m[j];
        }
        // for (int j = 0; j < N; j++) dp[i + 1][(a + j * 10) % N] += dp[i][j];
        // ans += dp[i + 1][0];
        ans += cur[0];
        for (int j = 0; j < N; j++) m[j] = cur[j];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  int n;
  cin >> n;
  ll T = 1, A = 1;
  for (int i=0; i<n; i++){
    ll t, a;
    cin >> t >> a;
    if (T%t) T = T + (t - T % t);
    if (A%a) A = A + (a - A % a);
    // cout << t << ' ' << a << endl;
    if (T/t > A/a) A = (T / t) * a;
    else if (T/t < A/a) T = (A / a) * t;
    // cout << T << ' ' << A << endl;
  }
  cout << T + A << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    int n; cin>>n;
    vector<ll> a(n), sum(n+10, 0);
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a.begin(), a.end());

    for(int i=0; i<n; i++) sum[i+1]=sum[i]+a[i];

    //for(int i=1; i<=n; i++) cout << sum[i] << endl;
    int cnt=1;
    for(int i=n-1; i>=0; i--){
        if(a[i]>2LL*sum[i]) break;
        cnt++;
    }
    cout << cnt << endl;
}

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

int main()
{
  int p[2] = {0}, n;
  for (int i = 0; i < 2; i++){
    for (int j = 0; j < 4; j++){
      cin >> n;
      p[i] += n;
    }
  }
  cout << max(p[0], p[1]) << endl;
  return (0);
}

Measured memory_bytes: 1160
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <string>
    #include <cmath>
    #include <iomanip>
    #include <numeric>
     
    using namespace std;
     
    #define FOR(i, a, b) for (int i = (a); i < (b); i++)
    #define REP(i, n) FOR(i, 0, n)
    #define SORT(c) sort((c).begin(), (c).end())
    #define INF (ll)1e18
    #define MOD (ll)1e9 + 7
     
    typedef long long ll;
    typedef pair<int, int> P;
    typedef vector<int> V;
    typedef map<int, int> M;
    int main()
    {
        int a,b,c,x,y;
        cin>>a>>b>>c>>x>>y;
        int min=(int)1e9,total;
        for(int i=0;i<100001;i++){
            total=i*2*c+a*max(0,x-i)+b*max(0,y-i);
            if(total<min)
            min=total;
        }
        cout<<min<<endl;
        return 0;
    }


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    int n,d,x;
    int ret=0;
    scanf("%d%d%d",&n,&d,&x);
    for(int i=0;i<n;i++){
        int a;
        scanf("%d",&a);
        ret+=((d-1)/a)+1;
    }
    printf("%d\n",ret+x);

}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;

char c[1001][1002];
int d[1000001];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",c[i]+1);
	queue<int>q;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(c[i][j]=='#'){
				q.push((i-1)*m+j);
				d[(i-1)*m+j]=1;
			}
	int ans=0;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		ans=max(ans,d[u]);
		for(int i=0;i<4;i++){
			int v=u;
			if(i==0&&u<=m||i==1&&u%m==1%m||i==2&&u>=(n-1)*m+1||i==3&&u%m==0)
				continue;
			if(i==0)v-=m;
			else if(i==1)v--;
			else if(i==2)v+=m;
			else v++;
			if(!d[v]){
				d[v]=d[u]+1;
				q.push(v);
			}
		}
	}
	printf("%d\n",ans-1);
}

Measured memory_bytes: 11636
#include<stdio.h>
#include<iostream>

using namespace std;


int main(){
    int n;
    cin>>n;
    if(n<1200)
    {
        cout<<"ABC";
    }
    else if(n<2800)
    {
        cout<<"ARC";
    }
    else{
        cout<<"AGC";
    }
    return 0;


}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();

        int answer = 0;
        int d2 = 1;
        for(int i = 0;i<d;i++){
            d2 *= 100;
        }
        for(int i = 1;i<=n;i++){
                answer = i*d2;
        }
        if(n == 100){
            if(d == 0){
                answer+= 1;
            }else if(d == 1){
                answer+= 100;
            }else{
                answer+= 10000;
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(ll i=0;i<N;++i)
const ll INF = 1LL<<60;

ll N,M;
vector<vector<ll> > G(55);
vector<ll> used(55);

bool dfs(int cur, int start, int goal){
    used[cur] = 1;
    int n = -1;
    for(auto it : G[cur]){
        n = it;
        if(cur == start && n == goal) continue;
        if(n == goal) return true;
        if(used[n]) continue;
        if(dfs(n,start,goal)) return true;
    }
    return false;
}

int main(){
    cin >> N >> M;
    vector<ll> a(M), b(M);
    rep(i,M) cin >> a[i] >> b[i];
    rep(i,M){
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    ll ans = M;
    rep(i,M){
        fill(used.begin(),used.end(),0);
        if(dfs(a[i],a[i],b[i])) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
w=input()
cnt=[]
ans=0
for i in range(len(w)):
  cnt.append(w.count(w[i]))
for j in range(len(cnt)):
  if cnt[j]%2==0:
    continue
  else:
    ans+=1
if ans==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn exec(chars: Vec<char>) -> String {
    let lth = chars.len();
    for i in 0..lth {
        if lth >= 2 && i <= lth - 2 && chars[i..i+1] == chars[i+1..i+2] {
            return format!("{} {}", i+1, i+2);
        } else if lth >= 3 && i <= lth - 3 && chars[i..i+1] == chars[i+2..i+3] {
            return format!("{} {}", i+1, i+3);
        }
    }
    ("-1 -1".to_string())
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    println!("{}", exec(s))
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
	cin>>a>>b;
	if(a==1)a=20;
	if(b==1)b=20;
	if(a>b)
	cout<<"Alice"<<endl;
	else
	{
		if(a<b)cout<<"Bob"<<endl;
		else
		{
			cout<<"Draw"<<endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s == "ARC"){
        cout<<"ABC\n";
    }
    else{
        cout<<"ARC\n";
    }
    return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int A,B,C,D,E,F;
set<int> W,S;
int resa=0,ress=0;

int main()
{
	cin>>A>>B>>C>>D>>E>>F;
	for(int i=0;100*A*i<=F;i++)
		for(int j=0;100*(A*i+B*j)<=F;j++)
			W.insert(100*(A*i+B*j));
	for(int i=0;i*C<=F;i++)
		for(int j=0;i*C+j*D<=F;j++)
			S.insert(i*C+j*D);
	resa=A*100;
	for(auto a=W.begin();a!=W.end();a++)
		for(auto b=S.begin();b!=S.end();b++)
		{
			if(*a+*b>F)break;
			if(*a*E<*b*100)break;
			if(1.0*ress*100/resa<1.0**b*100/(*a+*b))
			{
				resa=*a+*b;
				ress=*b;
			}
		}
	cout<<resa<<" "<<ress<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> Hi(N);
    for (int i=0;i<N;i++){
        cin >> Hi[i];
    }
    for (int i=N-1;i>=1;i--){
        if (Hi[i-1] > Hi[i]) {
            Hi[i-1]--;
        }
        if (Hi[i-1] > Hi[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int a;
  int count=0;
  int num[1000]={};
  cin >> a ;
  for(int i=0;i<a;i++){
  	cin >> num[i];
  }
  
  for(int i=0;i<a;i+=2){
  if(!(num[i]%2==0)){
    	count++;
    	
    }
  }
  
cout << count << endl;
  
  
  
  
  
  
  
  
  

}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n;
    string s;
    cin>>n>>s;

    vvec<ll> dp(n,vec<ll>(n,0));
    REP(i,n) dp[0][i]=1;
    REP(i,n-1) {
        vec<ll> sum(n+1,0);
        REP(j,n) (sum[j+1] = sum[j]+dp[i][j])%=MOD;
        REP(j,n-i-1){
            if(s[i]=='<'){
                //前よりも大きい値を選ぶ→大きい値がj+1個以上あるやつからしかえらべない
                dp[i+1][j] = (MOD + sum[n-i] - sum[j+1])%MOD;
            }else{
                //前よりも小さい数を選ぶ→前よりも大きい数が増えることはない
                dp[i+1][j] = (MOD + sum[j+1] - sum[0])%MOD;
            }
        }
    }
    cout<<dp[n-1][0]<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 70656
S = str(input())
S = list(S)

result = 0

#変更すべきものだったら変更したあとの前のものもの
#変更するべきものではない場合は前のもの
tempChangedTile = S[0]

for index, tile in enumerate(S):
    
    try:
        if tempChangedTile != S[index+1]:
            tempChangedTile = S[index+1]
            #print("TRUE")
            #print(index)
        else:
            #print("ELSE")
            #print(index)
            result += 1
            if S[index + 1] == "0":
                tempChangedTile = "1"
            else:
                tempChangedTile = "0"
    except:
        pass

print(result)

Measured memory_bytes: 3956