akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

int h, w, k;
vector<string> s;
int field[310][310];

void f(int y, int x, int n)
{
    field[y][x] = n;
    for (int i = 1; x - i >= 0; i++)
    {
        if (s[y][x - i] == '#')
            break;
        if (field[y][x - i] == 0)
            field[y][x - i] = n;
    }
    for (int i = 1; x + i < w; i++)
    {
        if (s[y][x + i] == '#')
            break;
        if (field[y][x + i] == 0)
            field[y][x + i] = n;
    }
}

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

    cin >> h >> w >> k;
    s.resize(h);
    rep(i, h) cin >> s[i];
    int cnt = 1;
    rep(i, h) rep(j, w)
    {
        if (s[i][j] == '#')
        {
            f(i, j, cnt);
            cnt++;
        }
    }
    Rep(i, 1, h)
    {
        rep(j, w)
        {
            if (field[i][j] == 0)
                field[i][j] = field[i - 1][j];
        }
    }
    for (int i = h - 2; i >= 0; i--)
    {
        rep(j, w)
        {
            if (field[i][j] == 0)
                field[i][j] = field[i + 1][j];
        }
    }
    rep(i, h)
    {
        rep(j, w)
        {
            cout << field[i][j] << " ";
        }
        cout << endl;
    }
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

    ll mod = 1000000007;

// PowMod( base, index, modulo) return base ** index % modulo {{{
// PowMod = base ** index % mod ( natural numbers )
long long unsigned int PowMod( long long unsigned int base, long long unsigned int index, long long unsigned int modulo = mod ){
    if( index == 0 ) return 1;
    // O( log(index) )
    if( index % 2 ){
        return base * PowMod(base, index - 1, modulo) % modulo;
    }else{
        long long unsigned int Phalf = index / 2;
        long long unsigned int half = PowMod(base, Phalf, modulo);
        return half * half % modulo;
    }
}
// }}}

int main() {

    static char L[100023];
    Scs(L);

    ll dp[100023][2] = {};
    dp[0][1] = 1;

    int N = strlen(L);
    Rep(i,N){
        if( L[i] == '1' ){
            dp[i+1][1] += dp[i][1]*2;
            dp[i+1][1] %= mod;
            dp[i+1][0] += dp[i][1];
            dp[i+1][0] += dp[i][0]*3;
            dp[i+1][0] %= mod;
        }
        if( L[i] == '0' ){
            dp[i+1][1] += dp[i][1];
            dp[i+1][1] %= mod;
            dp[i+1][0] += dp[i][0]*3;
            dp[i+1][0] %= mod;
        }
    }

    printf ("%llu\n", ( dp[N][1] + dp[N][0] ) % mod );

    return 0;
}



Measured memory_bytes: 1920
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LLINF 1<<63-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007
#define NUM 100001
void swap(int* x,int* y){
  int tmp=*x;*x=*y;*y=tmp;
}
int par[NUM];
int UF(int n){//初期化
  for(int i=0;i<NUM;i++)par[i]=-1;
}
int Find(int x){//x番目のノードが属する木の根を探す
  if(par[x]<0)return x;
  else return par[x]=Find(par[x]);
}
int Size(int x){
  return -par[Find(x)];
}
bool Same(int x,int y){//x番目のノードとy番目のノードが同じ木に属しているか返す
  return Find(x)==Find(y);
}
void Unite(int x,int y){//2つの木を結合する
  x=Find(x);y=Find(y);
  if(x!=y){
    par[x]+=par[y];
    par[y]=x;
  }
}

int main() {
  int N,M,i;
  scanf("%d%d",&N,&M);
  int a[M],b[M];
  LL ans[M+1];
  for(i=0;i<M;i++){
    scanf("%d%d",&a[i],&b[i]);
    a[i]--,b[i]--;
  }
  ans[M-1]=(LL)N*(N-1)/2;
  UF(N);
  for(i=M-2;i>=0;i--){
    if(Same(a[i+1],b[i+1]))ans[i]=ans[i+1];
    else ans[i]=ans[i+1]-(LL)Size(a[i+1])*Size(b[i+1]);
    Unite(a[i+1],b[i+1]);
  }
  for(i=0;i<M;i++)printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>


using namespace std;


int main()
{
	string S;
	int ns,ne;
	int cnt_c = 0;

	cin >> S;
	ns = 2;
	ne = S.size() - 2;

	if (S[0] != 'A') goto WA_END;

	for (int ni = 1; ni < S.size(); ni++) {
		if ('A' <= S[ni] && S[ni] <= 'Z') {
			if (S[ni] != 'C') {
				goto WA_END;
			}
			else {
				if (ni < ns || ne < ni) goto WA_END;
				if (cnt_c > 0) goto WA_END;
				cnt_c++;
			}
		}
	}
	if (cnt_c != 1) goto WA_END;

	printf("AC");
	return 0;

WA_END:
	printf("WA");

    return 0;
}



Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
void printint(uint32_t x){ if(x<0){x=-x; putchar_unlocked('-');}else if(x==0){putchar_unlocked('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar_unlocked(s[i]); putchar_unlocked('\n'); }
void rsort_str(void *base, const int count, const int size);

char str[200000][11];

int main(void){
	uint32_t n=nextpint();
	for(uint32_t i=0; i<n; i++){
		char *s=str[i];
		char c=getchar_unlocked();
		while(c!=' '&&c!='\n'){ *s++=c; c=getchar_unlocked(); }
		*s='\0';
	}
	rsort_str(str, n, 11);
	uint32_t ans=1;
	for(uint32_t i=1; i<n; i++){
		if(strcmp(str[i], str[i-1])) ans++;
	}
	printint(ans);
}

void rsort_str(void *base, const int count, const int size){
	char (*a)[size]=base;
	char (*b)[size]=malloc(count*size);
	int c[0x100];
	for(int j=9; j>=0; j--){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[a[i][j]]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ memcpy(&b[--c[a[i][j]]], a[i], size); }{void *t=a; a=b; b=t;}
	}
	free(b);
}


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

using namespace std;

long long mod = 998244353ll;


long long modInverse(long long a, long long m)
{
    long long m0 = m;
    long long y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        // q is quotient
        long long q = a / m;
        long long t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x positive
    if (x < 0)
       x += m0;

    return x;
}


int main(){
	int n;
	cin >> n;
	
	long long ans = 1;
	for(int i = 0;i < n;i++){
		ans *= 3;
		ans %= mod;
	}
	
	long long v = 1;
	for(int i = n;i > n/2;i--){
		ans -= 2 * v;
		
		v *= 2;
		v *= i;
		v %= mod;
		v *= modInverse(n-i+1,mod);
		v %= mod;
	}
	ans += mod*mod;
	ans %= mod;
	cout << ans;
}


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

using namespace std;

#define ll long long
const long double EPS = 1e-8;
const long double PI = acos(-1);

long double toDegree(long double ang) {
    return (ang * 180.0) / PI;
}

const int N = 1e5 + 5;

//int arr[N];
int main() {
    int n;
    scanf("%d", &n);
    ll ans[2] = {0};
    ll arr[2] = {0};
    for (int i = 0; i < n; i++) {
        ll x;
        scanf("%lld", &x);

        ll mn = ((i > 0) ? ans[1] + abs(arr[1] - x) : 0);
        mn = (i > 1) ? min(ans[0] + abs(arr[0] - x), mn) : mn;
        swap(ans[0], ans[1]);
        swap(ans[1], mn);
        swap(arr[0], arr[1]);
        swap(arr[1], x);
    }
    printf("%lld\n", ans[1]);

}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, const char * argv[]) {
    int N;
    std::string s;
    std::cin >> N >> s;
    
    int num = s.size();
    if (num % 2 == 0) {
        std::string halfA;
        std::string halfB;
        halfA = s.substr(0,num/2);
        halfB = s.substr(num/2,num);

        if (halfA == halfB) {
            std::cout << "Yes";
            return 0;
        }
    }
    std::cout << "No";
    return 0;
}

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

int main() {
  int N; long x; cin >> N >> x;
  long a[N]; for (int i =0; i<N; i++) cin >> a[i];
  long ans =0;
  if (a[0] > x) {
    ans = a[0] - x; 
    a[0] = x; 
  }
  for (int i =1; i<N; i++) {
    if (a[i] + a[i-1] > x) {
      ans += a[i] + a[i-1] - x;
      a[i] = x - a[i-1];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4392
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;


int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    string s;
    cin >> s;

    for0(i, s.length())cout << "x";
    cout << "\n";

    return 0;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))
#define UNIQUE(a) SORT(a), a.erase(std::unique(ALL(a)), a.end());

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector< VC > VCC;
typedef std::vector<int>  VI;
typedef std::vector< VI > VII;
typedef std::vector<long> VL;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;

LL H, W, N;
std::set< PII > AB;
std::set< PII > looked;
VLL cnt(10,0);
int main() {
    std::cin >> H >> W >> N;

    REP(i, N) {
        PII p;
        std::cin >> p.snd >> p.fst;
        p.fst--;
        p.snd--;
        AB.insert(p);
    }

    EACH(it, AB) {
        int x = it->fst, y = it->snd;
        FOR(i, -1, 2) {
            FOR(j, -1, 2) {
                int cx = x + i;
                int cy = y + j;
                if(looked.count(std::make_pair(cx,cy)) > 0) {
                    continue;
                }
                if(cx < 1 || cy < 1 || cx >= W-1 || cy >= H-1){
                    continue;
                }

                looked.insert(std::make_pair(cx,cy));
                int ans = 0;
                FOR(dx, -1, 2) {
                    FOR(dy, -1, 2) {
                        int nx = cx + dx;
                        int ny = cy + dy;
                        if(AB.count(std::make_pair(nx,ny)) > 0) {
                            ans++;
                        }
                    }
                }
                cnt[ans]++;
            }
        }
    }

    cnt[0] = (H-2)*(W-2) - std::accumulate(ALL(cnt), 0);
    REP(i, 10) {
        std::cout << cnt[i] << std::endl;
    }
}

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

typedef pair<int, int> ii;
vector<ii> V;

int main() {
   int N, M, A, B;
   scanf("%d %d", &N, &M);
   for (int i = 0; i < N; i++)
      scanf("%d %d", &B, &A), V.push_back(ii(B, A));
   sort(V.begin(), V.end());
   LL ans = 0;
   for (int i = 0; i < N && M; i++) {
      LL tot = min(M, V[i].second);
      M -= tot;
      ans += tot * V[i].first;
   }//for
   printf("%lld\n", ans);
   return 0;
}//main


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

long dfs(string s, int count, int until)
{
  if (count == until)
  {
    long sum = 0;
    long num = 0;
    for (int i = 0; i < s.length(); i++)
    {
      if (s[i] == '+')
      {
        sum += num;
        num = 0;
      }
      else
      {
        num *= 10;
        num += s[i] - '0';
      }
    }
    sum += num;
    return sum;
  }
  string s1 = s;
  string s2 = s;
  s1.erase(s1.find_first_of(' '), 1);
  s2.replace(s2.find_first_of(' '), 1, "+");
  return dfs(s1, count + 1, until) + dfs(s2, count + 1, until);
}

int main()
{
  string S;
  cin >> S;
  int N = S.length() - 1;
  string SS = "";
  for (int i = 0; i < S.length(); i++)
  {
    if (i == 0)
      SS += to_string(S[i] - '0');
    else
      SS += " " + to_string(S[i] - '0');
  }
  long ans = dfs(SS, 0, N);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
ans = sum(a)
mylist = Counter(a)

q = int(input())
for _ in range(q):
    b, c = map(int,  input().split())
    try:
        b_cnt = mylist[b]
        try:
            c_cnt = mylist[c]
        except:
            c_cnt = 0
        ans += (int(c) - int(b)) * b_cnt
        del mylist[b]
        mylist[c] = b_cnt + c_cnt
    except:
        pass
    print(ans)


Measured memory_bytes: 24100
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

long long gcd(int x, int y){
    if(x<y)swap(x,y);
    if(x%y==0){
        return y;
    }else{
        return gcd(y,x%y);
    }
}

int main(){
    int n,k;
    cin>>n>>k;
    long long g=gcd(n,k);
    cout<<n/g*k<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>

using namespace std;

int main() {
	int n, h, x = 0, y = 0;

	cin >> n;

	vector<int> data(n);

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

	for (int i = 0; i < n; i++) {

		if (data[i] % 4 == 0) {
			y++;
		}

		else if (data[i] % 2 == 0) {
			x++;
		}
	}

	h = n / 2;

	if (y >= h) {
		cout << "Yes" << endl;
	}

	else if (x == n) {
		cout << "Yes" << endl;
	}

	else if (n - (y*2) <= x) {
		cout << "Yes" << endl;
	}

	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int A[4];

signed main() {
    cin >> A[0] >> A[1] >> A[2] >> A[3];
    sort(A, A + 4);
    if (A[0] == 1 && A[1] == 4 && A[2] == 7 && A[3] == 9) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    string s; cin >> s;
    if(s == "ABC") cout << "ARC";
    else if (s == "ARC")cout << "ABC";
    return 0;
}


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

int main(){
    int N, K, ans=2e9;
    cin >> N >> K;
    vector<int> x(N);
	
    for(int i=0; i<N; i++)
	cin >> x[i];
    int left, right;
    for(int i=0; i+K-1<N; i++){
	left = x[i];
	right = x[i+K-1];
	if(left<0 && 0<right)
	    ans = min(2*min(abs(left), right)+max(abs(left), right), ans);
	else if(right <=0)
	    ans = min(abs(left), ans);
	else
	    ans = min(right, ans);
    }
    
    cout << ans <<endl;
}



Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
        t: String,
    }
    let (s, t) = {
        let (mut s, mut t): (Vec<char>, Vec<char>) = (s.chars().collect(), t.chars().collect());
        s.sort();
        t.sort();
        t.reverse();
        (s, t)
    };
    if s < t { println!("Yes") }
    else { println!("No") }
}


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

int main() {
	long k,s,x,y,z,ans=0;
	cin >> k >> s;
	for(x=0; x<=k; x++){
		for(y=0; y<=k; y++){
			z=s-x-y;
			if(z>=0 && z<=k) ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	map<char, int> m;
	for (int i = 0; i < s.size(); i++)m[s[i]]++;
	bool flag = true;
	for (auto a : m) if (a.second % 2)flag = false;
	
	cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef long long int LL;
typedef pair<int,int> P;

const int MOD=1000000007;
int main()
{
	LL a,b,c;
	cin>>a>>b>>c;
	if(c-a-b>=0 && (c-a-b)*(c-a-b)>4*a*b)cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
		
}

Measured memory_bytes: 256
while true
    n, l, r = gets.chomp.split.map(&:to_i)
    break if [n, l, r] == [0, 0, 0]
    arr = []
    n.times{arr << gets.to_i}
    sum = 0
    l.upto(r){|x|
        found = false
        arr.each_with_index{|y, i|
            if x % y == 0
                sum += 1 if i.even?
                found = true
                break
            end
        }
        sum += 1 if n.even? if !found
    }
    puts sum
end


Measured memory_bytes: 6876
#include <cmath>
#include <cstdio>
#include <iostream>
#include <cstring> 
#include<algorithm>
#include<numeric>
#include<vector>
#include<queue>
#define lowbit(x) x&-x
#define il inline
#define mod 1000000007
#define inf 1000000000
#define maxn 10000005
#define maxprime 3000005
#define db double
#define eps 1e-7
using namespace std;
typedef long long int ll;
int n,m;
int a[100005],b[100005];
priority_queue<int>q;
vector<int>g[100005];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]>m)continue;
		g[m-a[i]+1].push_back(b[i]);
	}
	ll ans=0;
	for(int i=m;i>=1;i--)
	{
		for(int j=0;j<g[i].size();j++)
		q.push(g[i][j]);
		if(!q.empty())
		{
			int t=q.top();q.pop();
			ans+=t;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;

ll va[201][201];
ll vb[201][201];

void Main()
{
    ll n, Ma, Mb;
    cin >> n >> Ma >> Mb;

    vector<ll> a(n), b(n), c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    ll INF = 1e18;
    rep(i, 201) rep(j, 201) {
        va[i][j] = INF;
        vb[i][j] = INF;
    }

    rep(pat, 1LL << (n/2)) {
        ll A = 0, B = 0, C = 0;
        rep(i, n/2) {
            if (pat & (1LL << i)) {
                A += a[i];
                B += b[i];
                C += c[i];
            }
        }
        va[A][B] = min(va[A][B], C);
    }    
    rep(pat, 1LL << (n-n/2)) {
        ll offset = n/2;
        ll A = 0, B = 0, C = 0;
        rep(i, n - n/2) {
            if (pat & (1LL << i)) {
                A += a[offset + i];
                B += b[offset + i];
                C += c[offset + i];
            }
        }
        vb[A][B] = min(vb[A][B], C);
    }

    ll res = INF;
    rep(a1, 201) {
        rep(a2, 201) {
            ll A = a1 + a2;
            if (A <= 0 || A % Ma != 0) {
                continue;
            }
            rep(b1, 201) {
                ll b2 = (A / Ma) * Mb - b1;
                if (0 <= b2 && b2 < 201) {
                    ll c1 = va[a1][b1];                    
                    ll c2 = vb[a2][b2];
                    res = min(res, c1 + c2);
                }
            }
        }
    }

    if (res == INF) {
        put(-1);
    }
    else {
        put(res);
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 4248
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
    cin>>n>>m;
    int s=0;
    for(int i=0;i<m;i++)
    {
      int x;
      cin>>x;
      s+=x;
    }
    int rem=n-s;
    if(rem<0)
      cout<<-1;
    else
      cout<<rem;
    return 0;
}



Measured memory_bytes: 3600
def func(x, y, count):
  new_x = x * 2
  if new_x > y:
    return count
  else:
    new_count = count + 1
    return func(new_x, y, new_count)
    
x, y = [int(i) for i in input().split()]

print(func(x, y, 1))

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
int main(void){
    double a,b,C,L,S,sinC,cosC;
    scanf("%lf%lf%lf",&a,&b,&C);
    sinC=sin(C*3.14159265/180.0);
    cosC=cos(C*3.14159265/180.0);
    S=(a*b*sinC/2);
    L=a+b+sqrt(a*a+b*b-2*a*b*cosC);
    printf("%f\n%f\n%f\n",S,L,b*sinC);

}

Measured memory_bytes: 1940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    double m;
    cin>>n>>m;
    double a[n];
    double count1=0;
    double sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum=sum+a[i];
    }
    for(int i=0;i<n;i++){
            double s=(double)(a[i]);
            double d=(double)((1/(4*m))*sum);
       if(s>=d){
            count1++;
       }
    }
     if(count1>=m){
        cout<<"Yes";
       }
       else cout<<"No";


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int x = 0;
	int ans = 0;
	for(char c : s) {
		if(c == 'I') ++x;
		else x--;
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3608
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = input().rstrip()

if len(S) == 1:
    print(1)
    exit()

# n文字目を最後に長さ1,2で見る
INF = 10 ** 10
dp_1 = [-INF] * (len(S))
dp_2 = [-INF] * (len(S))

dp_1[0] = 1
dp_2[1] = 1
if S[0] != S[1]:
    dp_1[1] = 2

for i,s in enumerate(S[2:],2):
    # 2文字→1文字
    x = dp_2[i-1] + 1
    # 1文字→1文字
    if S[i-1] != S[i]:
        x = max(x,dp_1[i-1] + 1)
    dp_1[i] = x
    
    # 1文字→2文字
    x = dp_1[i-2] + 1
    # 2文字→2文字
    if S[i-3:i-1] != S[i-1:i+1]:
        x = max(x,dp_2[i-2] + 1)
    dp_2[i] = x

answer = max(dp_1[-1], dp_2[-1])
print(answer)

Measured memory_bytes: 19184
import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  val n = readInt
  val arr = readLine.split(" ").map(_.toInt)
  val q = readInt
  readLine.split(" ").foreach( query => {
    if (solve(arr, 0, query.toInt)) println("yes") else println("no")
  })

  def solve(arr: Array[Int], p: Int, t: Int): Boolean = {
    if (t == 0) return true
    if (p == arr.length) return false
    solve(arr, p + 1, t - arr(p)) || solve(arr, p + 1, t)
  }
}



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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    vector<i64> a(3);
    a[0] = A; a[1] = B; a[2] = C;
    sort(a.begin(), a.end());
    if((a[0] == a[1] || a[1] == a[2]) && a[0] != a[2]) cout << YES << endl;
    else cout << NO << endl;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define N_MAX 10
#define M_MAX 100001
#define f first
#define s second
using namespace std;
typedef pair<bool,int> P;
int Binary_Search();
bool DP_Check(int);
int N,M,c[N_MAX];

int main(){
  while(1){
    cin>>N>>M;
    if(!N&&!M) break;
    for(int i=0;i<N;i++) cin>>c[i];
    cout<<Binary_Search()<<endl;
  }
  return 0;
}

int Binary_Search(){
  int l=0,r=M+1,m;
  while(l<r){
    m=(l+r)/2;
    DP_Check(m)?r=m:l=m+1;
  }
  return l;
}

bool DP_Check(int k){
  P dp[M+1];
  for(int i=0;i<=M;i++) dp[i].f=false,dp[i].s=0; 
  dp[0].f=true;
  for(int i=0;i<N;i++){
    for(int j=c[i];j<=M;j++){
      if(dp[j].f) continue;
      if(dp[j-c[i]].f&&dp[j-c[i]].s</*=*/k){
	//	if(dp[j-c[i]].s==k) break;
	dp[j].f=true;
	dp[j].s=dp[j-c[i]].s+1;
      }
    }
    for(int j=0;j<=M;j++) dp[j].s=0;
  }
  if(dp[M].f==true) return true;
  return false;
}

Measured memory_bytes: 1936
def judge(a, acc, i, m, n, v, p):
    if i <= p: return True
    if a[i-1] + m < a[p-1]: return False
    check = (p + n - i)*m + (a[i-1] + m)*(i - p) - (acc[i-2] - acc[p-2])
    return check >= m*v

n, m, v, p = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse=True)
acc = [0] * (n+1)
for i in range(n):
    acc[i] = a[0] if i == 0 else a[i] + acc[i-1]
ng = n + 1
ok = 0

while (ng - ok) > 1:
    mid = (ok + ng) // 2
    if judge(a, acc, mid, m, n, v, p):
        ok = mid
    else:
        ng = mid
print(ok)

Measured memory_bytes: 14480
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	int x1, y1, x2, y2, x3, y3;
	x1 = 0;
	y1 = 0;
	x2 = 1e9;
	y2 = 1;
	y3 = N / 1e9 + 1;
	x3 = -(N % (int)1e9 - 1e9);
	if (x3 == 1e9) {
		x3 = 0;
		y3--;
	}
	cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    for (int x = 1; x <= 9; ++x) {
        for (int y = 1; y <= 9; ++y) {
            if(N == x*y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0; 
}

Measured memory_bytes: 3072
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1000001
using namespace std;

long long min(long long a,long long b){
	if(a<b)return a;
	else return b;
}

int main(){
	long long e;
	while(cin>>e,e){
		long long m=INF;
		rep(i,min(e+1,1001)){
			rep(j,min(e+1,101)){
				if((e-i*i-j*j*j)<0)continue;
				if(m>(e-i*i-j*j*j+i+j))m=e-i*i-j*j*j+i+j;
			}
		}
		cout<<m<<endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> T(N);
  int timep=0;
  for(int i=0; i<N; i++){
    cin >> T.at(i);
    timep+= T.at(i);
  }
  int M;
  cin >> M;
  vector<int> ans(M);
  for(int i=0; i<M; i++){
    int P, X;
    cin >> P >> X;
    ans.at(i) = timep-T.at(P-1)+X;
  }
  for(int i=0; i<M; i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 256
n,m,x = [int(i) for i in input().split()]
bk = []
for _ in range(n):
   bk.append([int(i) for i in input().split()])
rp = 2**n 
ans = 10000000
for i in range(rp):
   rikai = [0]*m
   mon = 0
   for j in range(n):
      if i>>j & 1:
         mon += bk[j][0]
         for k in range(m):
            rikai[k] += bk[j][k+1]
   flag = True
   for j in rikai: #この組み合わせでいいか
      if j < x:
         flag = False
         break
   if flag:
      ans = min(ans,mon)
if ans == 10000000:
   ans = -1
print(ans)

Measured memory_bytes: 9204
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

ll ans;
int N;
vector<int> A, B, C;

int main(void) {
    scanf("%d", &N);
    rep(i, 0, N) {int x; scanf("%d", &x); A.pb(x);}
    rep(i, 0, N) {int x; scanf("%d", &x); B.pb(x);}
    rep(i, 0, N) {int x; scanf("%d", &x); C.pb(x);}

    sort(A.bg, A.en);
    sort(C.bg, C.en);

    rep(i, 0, N) {
      int lower = lower_bound(A.bg, A.en, B[i]) - A.bg;
      int upper = C.en - upper_bound(C.bg, C.en, B[i]);
      ans += (ll)lower * (ll)upper;
    }


  
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
int n;
int a[N];
int pre[N]={0},suf[N]={0};
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n;
	for(itn i=1;i<=n;i++)cin>>a[i];
	for(itn i=1;i<=n;i++){
		pre[i]=max(pre[i-1],a[i]);
	}
	for(int i=n;i>=1;i--)suf[i]=max(suf[i+1],a[i]);
	for(int i=1;i<=n;i++){
		o(max(pre[i-1],suf[i+1]));
	}
}


Measured memory_bytes: 10624
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string A, B;
	cin >> A >> B;
	if (A.size() > B.size()) {
		for (int i = 0; i < B.size(); i++) {
			cout << A[i] << B[i];
		}
		cout << A[A.size() - 1];
	}
	else {
		for (int i = 0; i < B.size(); i++) {
			cout << A[i] << B[i];
		}

	}
	cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int m,d;
	cin >> m >> d;
	int cnt=0;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=d;j++)
		{
			if(j%10>=2 and j/10>=2 and (j%10)*(j/10)==i)
			{
				cnt++;
				cerr << i << " : " << j << endl;
			}
		}
	cout << cnt << endl;





}


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

int main(){
	int N;
	cin >> N;
	
	int cnt=0;
	int pre=0;
	int ans=1;
	for(int i=1; i<=N; i++){
		int n=i;		
		
		//割れる回数を計算
		int cnt=0;
		while(n%2==0){
			cnt++;
			n/=2;
		}
	//cout << pre << " " << cnt << endl;
      
		if(cnt>pre) {
          pre = cnt;
          ans=i;
        }
	}
	cout << ans << endl;
}

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

int main(){
  int X, n;
  cin >> X >> n;
  if(n == 0){
    cout << X << endl;
    return 0;
  }
  int p[n];
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  int pl = 0;
  for(int j = 0; j < 52; j++){
    bool p_ju = true;
    for(int k = 0; k < n; k++){
      pl = X + j;
      if(pl == p[k]){
        p_ju = false;
        break;
      }
    }
    if(p_ju)break;
  }
  
  int mi = 0;
  for(int j = 0; j < 52; j++){
    bool p_mi = true;
    for(int k = 0; k < n; k++){
      mi = X - j;
      if(mi == p[k]){
        p_mi = false;
        break;
      }
    }
    if(p_mi)break;
  }
  
  if(X - mi <= pl - X){
    cout << mi << endl;
  }else{
    cout << pl << endl;
  }
}

Measured memory_bytes: 3620
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int count = 0;
    for(int i=0;i<s.length();i++){
      if(s.charAt(i) == '+'){
        count++;
      }else{
        count--;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 22740
#include <stdio.h>

int main()
{
	/* 同じ人がとなり合う二切れのケーキを両方取ってはならない */
	/* つまり食べられるケーキの最高数は8切れである		  */

	int a;	/* 入力一つ目 */
	int b;	/* 入力二つ目 */
	scanf("%d %d", &a, &b);

	if((a < 9) && (b < 9))
		printf("Yay!\n");
	else
		printf(":(\n");

	return 0;
}


Measured memory_bytes: 128
import sys
from math import ceil
from bisect import bisect

cin = sys.stdin
# cin = open("in.txt", "r")

def line2N():
    return map(int, cin.readline().split())


N, = line2N()
a = list(line2N())
s = sum(a)
cnt = 0
ans = 0x7fffffff
for i in range(0,N-1):
    cnt += a[i]
    ans = min(ans, abs(s - 2*cnt))

print(ans)


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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	vector<vector<pii>> edges(n);
	FOR(i,0,n-1){
		int a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		edges[a].pb(mp(b,c));
		edges[b].pb(mp(a,c));
	}
	int q,k;
	cin >> q >> k;
	k--;
	vector<ll> dist(n, LLINF);
	dist[k] = 0;
	queue<int> que;
	que.push(k);
	while(!que.empty()){
		int a = que.front();
		que.pop();
		FOR(i,0,(int)edges[a].size()){
			int b,c;
			tie(b,c) = edges[a][i];
			if(dist[b] != LLINF)continue;
			dist[b] = dist[a] + c;
			que.push(b);
		}
	}
	FOR(i,0,q){
		int x,y;
		cin >> x >> y;
		x--;y--;
		ANS(dist[x] + dist[y]);
	}
	return 0;
}


Measured memory_bytes: 8820
from collections import deque

al = deque(input())
bl = deque(input())
cl = deque(input())

turn = 0
abcl = (al, bl, cl)
turn_num = ["a", "b", "c"]
while True:
    # print(abcl)
    if turn == 0 and not al:
        ans = "A"
        break
    if turn == 1 and not bl:
        ans = "B"
        break
    if turn == 2 and not cl:
        ans = "C"
        break
    turn = turn_num.index(abcl[turn].popleft())

print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string>
#include <map>
using namespace std;

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

	long A[200010];
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A, A + N);

	for (int i = 0; i < N-1; ++i) {
		if (A[i] ==A[i+1] ) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		long l = fs.nextLong();
		long r = fs.nextLong();
		
		int mod = 1_000_000_007;
		long[][][][] dp = new long[61][2][2][2];
		
		dp[60][0][0][0] = 1;
		for(int i = 59; i >= 0; i--) {
			for(int j = 0; j <2; j++) {
				for(int k = 0; k < 2; k++) {
					for(int s = 0; s < 2; s++) {
						
						long pre = dp[i+1][j][k][s];
						
						long lb = (l >> i) & 1;
						long rb = (r >> i) & 1;
						
						for(int x = 0; x < 2; x++) {
							for(int y = 0; y < 2; y++) {
								
								int nj = j;
								int nk = k;
								int ns = s;
								
								if(x == 1 && y == 0) {
									continue;
								}
								
								if(s == 0 && x == 0 && y == 1) {
									continue;
								}
								
								if(x == 1 && y == 1) {
									ns = 1;
								}
								
								if(j == 0 && lb == 1 && x == 0) {
									continue;
								}
								
								if(k == 0 && rb == 0 && y == 1) {
									continue;
								}
								
								
								if(lb == 0 && x == 1) {
									nj = 1;
								}
								
								if(rb == 1 && y == 0) {
									nk = 1;
								}
								
								
								dp[i][nj][nk][ns] = (dp[i][nj][nk][ns] + pre) % mod;
							}
						}
					}
				}
			}
			
		}
		
		long ans = 0;
		for(int j = 0; j < 2; j++) {
			for(int k = 0; k < 2; k++) {
				for(int s = 0; s < 2; s++) {
					ans = (ans + dp[0][j][k][s])%mod;
				}
			}
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

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

int main(){
  int a;
  cin >> a;
  ll ans = 0;
  rep(i,a){
    rep(j,a){
      rep(k,a){
        ans += gcd(gcd(i,j),k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N;
string s[300];
char t[300][300];

bool check(){
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(t[i][j] != t[j][i]) return false;
        }
    }
    return true;
}

int main(){
    ll ans = 0;
    cin >> N;
    for(int i=0;i<N;i++) cin >> s[i];
    for(int z=0;z<N;z++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                t[i][(j+z)%N] = s[i][j];
            }
        }
        if(check()) ans += N;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

	static int result[600010];
	for(int x = 1; x <= 100; x++) {
		for(int y = 1; y <= 100; y++) {
			for(int z = 1; z <= 100; z++) {
				const int value = x * x + y * y + z * z
					+ x * y + y * z + z * x;
				result[value]++;
			}
		}
	}

	for(int i = 1; i <= N; i++) {
		cout << result[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    map<ll,ll> mp;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        mp[x]++;
        sum +=x;
    }
    int q;
    cin>>q;
    while(q--)
    {
        ll x,y;
        cin>>x>>y;
        if(mp[x])
        {
            sum -=(x*mp[x]);
            sum +=(y*mp[x]);
            mp[y] +=mp[x];
            mp[x]=0;
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 9332
#include<cstdio>
inline int in();
inline void wr(int);
inline int gcd(int,int);
int main(int argc,char**argv){
	register int n=in();
	register int s=0;
	for(register int i=1;i<=n;++i)
		for(register int j=1;j<=n;++j)
			for(register int k=1;k<=n;++k)
				s+=gcd(gcd(i,j),k);
	wr(s),putchar('\n');
}
inline int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(int x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}


Measured memory_bytes: 1492
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int a, b;
  cin >> a >> b;

  if((a + b) >= 10){
    cout << "error" << endl;
  }
  else{
    cout << (a + b) << endl;
  }

  return 0;
}


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

using namespace std;

void a()
{
    int n;
    cin >> n;
    string temp = to_string(n);
    if(temp[0] == '9')
    {
       cout << "Yes" << endl;
        return;
    }else if(temp[1] == '9')
    {
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}

void b()
{
    int n;
    cin >> n;
    vector<pair<int, int>> lr;
    for(int i = 0; i < n; i++)
    {
        int r, l;
        cin >> l >> r;
        lr.push_back(make_pair(l, r));
    }
    int result = 0;
    for(auto elem : lr)
    {
        result += (elem.second - elem.first) + 1;
    }
    cout << result << endl;
}

void c()
{
    int n;
    cin >> n;
    map<int, int> a;
    int result = 0;
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        if(a[temp] == 0)
        {
            a[temp] = 1;
            result++;
        }else{
            a[temp] = 0;
            result--;
        }
    }
    cout << result;
}

void d()
{

}

int main() {
    c();
    return 0;
}


Measured memory_bytes: 4992