akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	f(i,1,n){
        if(i==n && i<=m) count++;
        else if(i<n)count++;
	}

	cout<<count<<endl;

}


Measured memory_bytes: 256
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//abc135D
int main(void) {
  int n, k, i, r, d, cou=0, tmp, len, m=0, max=0, premax=0;
  scanf("%d", &n);
  int a[n], b[n];

  for(i=0; i < n; i++){
    scanf("%d", &a[i]);
    b[i]=0;
  }

  for(i=n - 1; i >= 0; i--){
    cou=0;
    while((i + 1) * (cou + 2) <= n){
      //printf("b[%d]=%d=(%d+%d)%%2\n",i, (b[i] + b[(i + 1) * (cou + 2) - 1])%2,b[i], b[(i + 1) * (cou + 2) - 1]);
      b[i]=(b[i] + b[(i + 1) * (cou + 2) - 1])%2;
      //printf("b[%d]=%d\n\n",i,tmp);
      cou++;
    }
    //printf("bef  a[%d]=%d   b[%d]=%d\n", i, a[i], i, b[i]);
    b[i]=(b[i] + a[i])%2;
    //printf("aft  a[%d]=%d   b[%d]=%d\n\n", i, a[i], i, b[i]);
    if(b[i] == 1) m++;
  }

  printf("%d\n", m);
  for(i=0; i < n; i++){
    if(b[i] == 1) printf("%d ", i + 1);
  }
  return 0;
}

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

using namespace std;

const int MAXN = 1e6 + 9;

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    vector<vector<pair<int,int>>> primes(MAXN);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }
    
    vector<int> spf(MAXN);
    for(int i = 2;i<MAXN;i++)
    {
        spf[i] = i;
    }

    for(int i = 4;i < MAXN;i+=2)
    {
        spf[i] = 2;
    }

    for(int i = 3;i*i<MAXN;i++)
    {
        if(spf[i] == i)
        {
            for(int j = i*i;j<MAXN;j+=i)
            {
                if(spf[j] == j)
                {
                    spf[j] = i;
                }
            }
        }
    }


    for(int i = 1;i<MAXN;i++)
    {
        unordered_map<int,int>pfreq;
        int x = i;
        while(x > 1)
        {
            pfreq[spf[x]]++;
            x = x/spf[x];
        }

        for(pair<int,int> p:pfreq)
        {
            primes[i].push_back(p);
        }
    }

    
    vector<bool> seen_prime(MAXN);
    vector<int> times(MAXN);

    bool flag = true;
    for(int i = 0;i<n;i++)
    {
        for(pair<int,int> p:primes[v[i]])
        {
            if(seen_prime[p.first])
            {
                flag = false;
                break;
            }
            else
            {
                seen_prime[p.first] = true;
            }
            
        }
    }

    if(flag)
    {
        cout<<"pairwise coprime\n";
    }
    else
    {
        bool check = true;
        for(int i = 0;i<n;i++)
        {
            for(pair<int,int> p:primes[v[i]])
            {
               times[p.first]++;
            }
        }

        for(int p:times)
        {
            if(p == n)
            {
                check = false;
                break;
            }
        }

        if(check)
        {
            cout<<"setwise coprime\n";
        }
        else
        {
            cout<<"not coprime\n";
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 81140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  ll i,j,n,m,k;
  cin>>n>>m>>k;
  ll arr[n+2]={0}, brr[m+2]={0};
  for(i=1;i<=n;i++){cin>>arr[i]; arr[i]+=arr[i-1];}
  for(i=1;i<=m;i++){cin>>brr[i];brr[i]+=brr[i-1];}
  ll ans=0;
  
  for(i=0;i<=n;i++){
      ll tmp=k-arr[i];
      if(tmp<0)break;
      ll l=0,r=m,ok=0;
      while(l<=r){
          ll mid=(l+r)/2;
          if(brr[mid]<=tmp){ok=max(ok,mid);l=mid+1;}
          else r=mid-1;
      }
      ans=max(ans,i+ok);
  }
  cout<<ans;
}

Measured memory_bytes: 6760
#include <stdio.h>

int main() {
	int x, y, z;

	scanf("%d %d", &x, &y);

	if (x > y) {
		z = x;
		x = y;
		y = z;
	}

	while (1) {
		if (y % x == 0) {
			printf("%d\n", x);
			break;
		}

		z = y % x;
		y = x;
		x = z;
	}

	return 0;
}

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

int main() {
	// your code goes here
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &x : a)
		cin >> x;
	
	 vector<bool> dp(k + 1);
	 dp[0] = false;
	 for (int i = 1; i <= k; ++i) {
	 	for (int &x : a) {
	 		if (x <= i and !dp[i - x]) {
	 				dp[i] = true;
	 				break;
	 		}
	 		
	 	}
	 }
	 cout << (dp[k] ? "First" : "Second");
	return 0;
}

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

long long ans[1000010];
int had;

void dfs(long long now) {
    if(now > 3234566667) return;
    if(now != 0) {
        ans[had ++] = now;
    }
    long long last = now % 10;
    for(int i = last - 1; i <= last + 1; i ++) {
        if(i >= 0 && i <= 9) {
            dfs(now * 10 + i);
        }
    }
}
int main() {
    long long k;
    scanf("%lld", &k);
    for(int i = 1; i <= 9; i ++) {
        dfs(i);
    }
    sort(ans, ans + had);
    printf("%lld\n", ans[k - 1]);
    return 0;
}


Measured memory_bytes: 896
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    d = int(ipt())
    c = [int(i) for i in ipt().split()]
    s = [[int(i) for i in ipt().split()] for _ in range(d)]
    t = [int(ipt())-1 for i in range(d)]
    ld = [-1]*26
    ans = 0
    for i,ti in enumerate(t):
        ans += s[i][ti]
        ld[ti] = i
        for j,ci in enumerate(c):
            ans -= ci*(i-ld[j])
        print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 70644
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

/*void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<111111;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}

int COM(int n,int k){
	if(n<k)return 0;
	if(n<0||k<0)return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}*/

//}


vector<int> a[501];
int n,m,q,l,r;

main(){
    cin>>n>>m>>q;
    rep(i,m){
        int t1,t2;
        cin>>t1>>t2;
        a[t1].pb(-t2);
    }
    for(int i=1;i<=n;i++){
        sort(all(a[i]));
    }
    rep(i,q){
        int ans=0;
        cin>>l>>r;
        for(int j=l;j<=r;j++){
            ans+=(a[j].end()-lower_bound(all(a[j]),-r));
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3456
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <map>
#include<vector>
using namespace std;

int main()
{   int N,c;
vector<int> b;
cin>>N;
bool good = true;
for(int i=0;i<N;++i){cin>>c;b.push_back(c);}
for(auto &z:b){
    if(z%2==0){if(z%3==0||z%5==0)continue;
    else {cout<<"DENIED";good=false;break;}}
}
if(good)cout<<"APPROVED";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>
#include <cstdint>
#include <numeric>

using namespace std;

int64_t gcd(int64_t a, int64_t b){
  int64_t temp;
  while (b != 0) {
    temp = a % b;

    a = b;
    b = temp;
  }
  return a;
}

inline int64_t lcm(int64_t a, int64_t b) {
  return a*b / gcd(a, b);
}

int64_t calc_num_divs(int64_t n, int64_t x, int64_t y) {
  return n/x + n/y - n/lcm(x, y);
}

int main() {
  int64_t A, B, C, D;
  cin >> A >> B >> C >> D;
  int64_t num_divs = calc_num_divs(B, C, D) - calc_num_divs(A-1, C, D);
  cout << B - A + 1 - num_divs << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- Coding: utf-8 -*-
import numpy as np
MOD = 1000 * 1000 * 1000 + 7

N,M = map(int,raw_input().split())
A = np.zeros(N+1, dtype=np.int32)

for i in xrange(M):
	a = int(raw_input())
	A[a] = -1

A[0] = 1
for i in xrange(1,N+1):
	if A[i] == -1:
		A[i] = 0
	else:
		if  i == 1:
			A[i] = A[i-1]
		else:
			A[i] = A[i-1]+A[i-2]

		A[i] %= MOD

print A[N]

Measured memory_bytes: 20560
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

signed main(){
	int N, W;
	cin >> N >> W;
	vector<int> u[4], x[4];
	int w, v, w0;
	cin >> w >> v;
	w0 = w;
	u[0].push_back(v);
	for(int i = 1; i < N; ++i) {
		cin >> w >> v;
		u[w-w0].push_back(v);
	}
	for(int i = 0; i < 4; ++i) {
		sort(ALL(u[i]), greater<int>());
		x[i].assign(u[i].size() + 1, 0);
		for(int j = 0; j < u[i].size(); ++j) {
			x[i][j + 1] = x[i][j] + u[i][j];
		}
	}
	int res = 0;
	for(int i = 0; i <= u[0].size(); ++i) {
		for(int j = 0; j  <= u[1].size(); ++j) {
			for(int k = 0; k <= u[2].size(); ++k) {
				int a = w0 * i + (w0 + 1) * j + (w0 + 2) * k;
				if(a > W)
					continue;
				int l = min((W - a) / (w0 + 3), (int)u[3].size());
				//cout << ">" << i << "," << j << "," <<  k << "," << l << endl;
				//cout << ">" << w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l << endl;
				res = max(res, x[0][i] + x[1][j] + x[2][k] + x[3][l]);
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
cnt = 0
flag = False
for i in range(10000):
    for j in range(n):
        if a[j] % 2 != 0:
            flag = True
        a[j] /= 2
    if flag:
        break
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
import java.util.*;


public class Main {
    public static void main(String[] args) {
      int []po=new int[]{0,2,0,1,0,1,0,0,1,0,1,0};
        Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();int m=sc.nextInt();
      if(po[n-1]==po[m-1])
      System.out.println("Yes");else System.out.println("No");
    }
}


Measured memory_bytes: 20560
#include <iostream>
using namespace std;
int main()
{
    int a, b, k, abgcd;
    cin >> a >> b >> k;
    for(int i = (a < b ? a : b); i >= 1; i--){
        if(a % i == 0 && b % i == 0){
            --k;
            if(k == 0){
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

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

const int D = 365, N = 26;
int d;
ll c[N+1];
ll s[D+1][N+1];
ll last[N];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> d;
	for(int i = 1; i <= N; i++)
		cin >> c[i];
	for(int i = 1; i <= d; i++) {
		for(int j = 1; j <= N; j++)
			cin >> s[i][j];
	}
	memset(last, 0, sizeof last);
	ll ans = 0;
	for(int i = 1; i <= d; i++) {
		int t; cin >> t;
		ans += s[i][t];
		last[t] = i;
		for(int j = 1; j <= N; j++)
			ans -= c[j] * (i - last[j]);
		cout << ans << '\n';
	}

	return 0;
}

Measured memory_bytes: 3668
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <functional>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

typedef pair<int,int> P;

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

int main(){
  unsigned long long int x,y;
  int ans = 0;

  cin >> x >> y;

  unsigned long long int a = x;
  while(1){
    if( a <= y){
      ++ans;
    }else{
      break;
    }
    a = a*2;
  }

  cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
int main(){
  cin.sync_with_stdio(false);
  ll n;
  cin >> n;
  Vector p(n);
  rep(i,n)cin >> p[i];
  ll cnt = 0;
  rep(i,n){
    if(p[i] != i+1)continue;
    if(i < n-1 && p[i] == i+1 && p[i+1] == i+2)swap(p[i],p[i+1]);
    cnt++;
  }
  cout << cnt << endl;
}


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

inline ll encode(const vector<int> &a){
  ll res = 0;
  for(int i=13;i>=1;i--)res = res*5 + a[i];
  return res;
}

set<int> memo;
vector<int> ans;

bool rec(ll sum, vector<int> &rem){
  int a = encode(rem);
  if(a==0)return true;
  if(memo.count(a))return false;
  memo.insert(a);

  for(int i=13;i>=1;i--){
    if(rem[i] && sum%i==0){
      rem[i]--;
      ans.push_back(i);
      if(rec(sum - i, rem))return true;
      ans.pop_back();
      rem[i]++;
    }
  }
  return false;
}

int main(){
  int n;
  while(cin >> n, n){
    vector<int> num(14,0);
    int sum = 0;
    for(int i=0;i<n;i++){
      int tmp;
      cin >> tmp;
      num[tmp]++; sum+=tmp;
    }

    memo.clear();
    ans.clear();
    rec(sum,num);
    if((int)ans.size() == n){
      reverse(ans.begin(),ans.end());
      for(int i=0;i<n;i++){
	cout << ans[i] << (i==n-1?"\n":" ");
      }
    }else cout << "No" << endl;
  }
}

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

using namespace std;

int main () {
	
	int n, m, k; 
	cin >> n >> m >> k;
	
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (n * (j) + m * (i) - i * j - i * j == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}

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

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

  for (int i=0;i<3;++i) {
    if (a%10==7) {
      cout << "Yes" << endl;
      return 0;
    }
    a/=10;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3612
//Author:- S_Aditya
//Date created:- 24 February 2019

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=22;

//mask represents a subset of women,e.g:- 010010 represents that the 2nd and 5th women are paired.

//dp[i][mask] tells the total no. of possible pairings considering the first i men
//with a subset of size i of women represented by mask.

//Answer will be dp[n][(1<<n)-1] as we have to pair all n men with all n women.
int dp[N][1<<21]; 

int can[N][N]; //can[i][j] is 1 if ith man is permitted to pair up with the jth woman,otherwise 0.

int main()                  
{
    int n;
    
    scn(n);
    
    rep(i,0,n)
    {
        rep(j,0,n)
        scn(can[i][j]);
    }
    
    dp[0][0]=1; //1 way to match no men with no women
    
    for(int i=1;i<=n;i++)
    {
        for(int mask=0;mask<(1<<n);mask++)
        {
            int set_bits=__builtin_popcount(mask);
            
            //check if no. of women in this candidate subset 
            //is equal to i(i.e the no of men to match) or not.
            if(set_bits!=i) 
            continue;
            
            //ith men should be compatible to pair with jth women
            //and jth women should be a part of the current candidate subset
            //represented by mask.
            for(int j=0;j<n;j++)
            if(can[i-1][j] and mask&(1<<j))
            {
                int temp_mask=mask^(1<<j);
                
                dp[i][mask]=(dp[i][mask]+dp[i-1][temp_mask])%mod;
            }
        }
    }
    
    ll ans=dp[n][(1<<n)-1];
    
    printf("%lld ",ans);
} 


Measured memory_bytes: 162048
#include "bits/stdc++.h"
    using namespace std;
     
    int main()
    {
    	long long A, B, C, K;
    	cin >> A >> B >> C >> K;
    	if(K & 1) {
    		cout << (B - A) << endl;
    	} else {
    		cout << (A - B) << endl;
    	}
    	return 0;
    }

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, m) = scan!(usize, usize);
    let graph = scan!(usize,usize;m);
    for i in 1..(n + 1) {
        let mut count = 0;
        for &r in graph.iter() {
            if r.0 == i || r.1 == i {
                count += 1
            }
        }
        println!("{}", count);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 200003;
ll n,m,a[N],b[N];
pair <bool,bool> go[N];


int main(){
	cin>>n>>m;
	FOR(i,0,m){
		cin>>a[i]>>b[i];
	}
	FOR(i,0,N){
		go[i].first=go[i].second=false;
	}
	FOR(i,0,m){
		if(a[i]==1||b[i]==1){
			go[a[i]+b[i]-1].first=true;
		}else if(a[i]==n||b[i]==n){
			go[a[i]+b[i]-n].second=true;
		}
	}
	bool ans=false;
	FOR(i,1,n){
		if(go[i].first==true&&go[i].second==true){
			ans=true;
			break;
		}
	}
	if(ans){
		cout<<"POSSIBLE"<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}

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

int main() {
	int K, N;
	cin >> K >> N;
	vector<int> A(N);
	REP(i, N) scanf("%d", &A[i]);
	
	int ans = 0;
	REP(i, N) chmax(ans, (K + A[i] - A[(i - 1 + N) % N]) % K);
	ans = K - ans;
	cout << ans << endl;
}


Measured memory_bytes: 1024
#貪欲？
n = gets.to_i
num = gets.strip.split.map(&:to_i)
cnt = 0
for i in 0..n-2
  if num[i] == i+1
    num[i] = num[i+1]
    num[i+1] = i+1
    cnt += 1
  end
end
#末尾のチェックがいる
if num[n-1] == n
  puts cnt+1
else
  puts cnt
end

Measured memory_bytes: 20896
#include<stdio.h>
#include<string.h>

int main()
{
  int n;
  int count1 = 0, count2 = 0;
  char text1[100];
  char text2[100];
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
    {
      scanf("%s %s", text1, text2);
      for(int j = 0;; j++)
	{
	  if((text1[j] + text2[j]) == 0)
	    {
	      count1++;
	      count2++;
	      break;
	    }
	  if(text1[j] > text2[j])
	    {
	      count1+=3;
	      break;
	    }
	  if(text1[j] < text2[j])
	    {
	      count2+=3;
	      break;
	    }
	}
    }
  printf("%d %d\n", count1, count2);
}



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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, k = 1, ans = 0, arr[110];
	
	cin >> n;
	
	for(int i = 0; i < n; i++)
		cin >> arr[i];
		
	sort(arr, arr + n, greater<int>());
	
	for(int i = 0; i < n; i++)
	{
		ans += arr[i] * k;
		k = -k;
	}//for i
	
	cout << ans;
	
	return 0;
}//main


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

int N;
vector<int> H;

void solve() {
  if (N == 1) {
    cout << "Yes" << '\n';
    return;
  }

  for (int i = N - 1; i > 1; i--) {
    if (H[i - 1] > H[i]) {
      H[i - 1]--;
    }
  }
  for (int i = 1; i < N; i++) {
    if (H[i - 1] > H[i]) {
      cout << "No" << '\n';
      return;
    }
  }
  cout << "Yes" << '\n';
}

int main() {
  cin >> N;
  H.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  solve();
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll n;cin>>n;
	ll arr[n];
	int index[n];
	memset(arr,0,sizeof(arr));
	for(int i=0;i<n;i++){
		ll a;cin>>a;
		arr[a-1]++;
		index[i] = a;
	}
	ll sum=0;
	for(int i=0;i<n;i++){
		if(arr[i]>0){
			sum += arr[i]*(arr[i]-1)/2;
		}
	}
	ll ans[n];
	memset(ans,0,sizeof(ans));
	for(int i=0;i<n;i++){
		ans[i] = sum;
	}
	for(int i=0;i<n;i++){
		if(arr[i]>0){
			ans[i] -= arr[i]*(arr[i]-1)/2;
			ans[i] += (arr[i]-1)*(arr[i]-2)/2;
		}
	}
	for(int i=0;i<n;i++){
		cout<<ans[index[i]-1]<<endl;
	}
} 

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  string s;
  cin>>n>>s;
  vector<Int> dp(n+1,0),pd(n+1,0);
  for(Int i=1;i<n;i++){
    dp[i]=dp[i-1]+(s[i-1]=='W');
  }
  for(Int i=n-2;i>=0;i--){
    pd[i]=pd[i+1]+(s[i+1]=='E');
  }
  Int ans=dp[0]+pd[0];
  for(Int i=0;i<n;i++)
    chmin(ans,dp[i]+pd[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5380
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
IJK = [0,0,0]
for i in range(N):
    IJK[a[i]-1]+=1

dp = [[[0.0]*(N+3) for _ in range(N+3)] for _ in range(N+3)]

for k in range(N+1):
    for j in range(N+1):
        for i in range(N+1):
            if i+j+k > N: continue
            if i+j+k == 0: continue
            tmp = 1.0*N
            if i>0: tmp += i*dp[i-1][j][k]*1.0
            if j>0: tmp += j*dp[i+1][j-1][k]*1.0
            if k>0: tmp += k*dp[i][j+1][k-1]*1.0
            dp[i][j][k] = tmp/float(i+j+k)
print(dp[IJK[0]][IJK[1]][IJK[2]])




Measured memory_bytes: 260232
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  long N = input();
  string X = input<string>();

  int count = 0;
  for(int i = 0;i<N-2;i++){
    string s = X.substr(i,3);
    if(s == "ABC"){
      count++;
    }
  }

  output(count);

  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
P = LIST()
Q = LIST()

def hoge(A, m):
  c = -1
  for j in range(m):
    if A[j] == 1  :
      c += 1   
  return c

def Numth(R, N):
  ORDER = [1]*N
  c = 0
  for i in range(N-1):
    order = sum(ORDER[:i+1])
    c += hoge(ORDER, R[i]) *factorial(N-i-1)
    ORDER[R[i]-1] = 0 
  return c+1

print(abs(Numth(P, N)-Numth(Q, N)))

Measured memory_bytes: 5196
import sys
import copy

input = sys.stdin.readline

def main():
    H, W = map(int, input().split())
    grid = []
    for _ in range(H):
        grid.append(list(input()[:-1]))
    
    L = [[0] * W for _ in range(H)]
    R = copy.deepcopy(L)
    U = copy.deepcopy(L)
    D = copy.deepcopy(L)
    
    for h in range(H):
        cntL, cntR = 0, 0
        for w in range(W):
            wreverse = W - w - 1
            if grid[h][w] == '.':
                cntL += 1
            else:
                cntL = 0
            if grid[h][wreverse] == '.':
                cntR += 1
            else:
                cntR = 0
            L[h][w] = cntL
            R[h][wreverse] = cntR

    for w in range(W):
        cntU, cntD = 0, 0
        for h in range(H):
            hreverse = H - h - 1
            if grid[h][w] == '.':
                cntU += 1
            else:
                cntU = 0
            if grid[hreverse][w] == '.':
                cntD += 1
            else:
                cntD = 0
            U[h][w] = cntU
            D[hreverse][w] = cntD
    
    ans = 0
    for h in range(H):
        for w in range(W):
            ans = max(ans, L[h][w] + R[h][w] + U[h][w] + D[h][w] - 3)

    print(ans)
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 365424
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
using namespace std;

struct UnionFind {
    vl par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll n) : par(n) { //最初は全てが根であるとして初期化
        rep(i,n) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,m;
    cin>>n>>m;
    vl p(n),ip(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
        ip[p[i]] = i;
    }
    UnionFind uf(n);
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        uf.unite(x,y);
    }
    ll ans = 0;
    rep(i,n){
        if(uf.same(i,ip[i])) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
import itertools
N,D=map(int,input().split())
X=[list(map(int,input().split())) for _ in range(N)]

a=list(range(N))
b=list(itertools.combinations(a,2))

sum=0
count=0

for i in range(len(b)):
    for j in range(D):
        sum+=(X[b[i][0]][j]-X[b[i][1]][j])**2
    if sum**(1/2)%1!=0:
        sum=0
    else:
        count+=1
        sum=0

print(count)



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

int main()
{

    vector<int> a(9);
    REP(i, 9)
    {
        cin >> a[i];
    }

    int n;
    cin >> n;

    int b;
    REP(j, n)
    {
        cin >> b;
        REP(k, 9)
        {
            if (b == a[k])
                a[k] = 0;
        }
    }

    bool ans = false;

    if (a[0] == 0 && a[3] == 0 && a[6] == 0)
        ans = true;
    if (a[1] == 0 && a[4] == 0 && a[7] == 0)
        ans = true;
    if (a[2] == 0 && a[5] == 0 && a[8] == 0)
        ans = true;
    if (a[0] == 0 && a[1] == 0 && a[2] == 0)
        ans = true;
    if (a[3] == 0 && a[4] == 0 && a[5] == 0)
        ans = true;
    if (a[6] == 0 && a[7] == 0 && a[8] == 0)
        ans = true;
    if (a[0] == 0 && a[4] == 0 && a[8] == 0)
        ans = true;
    if (a[2] == 0 && a[4] == 0 && a[6] == 0)
        ans = true;

    cout << ((ans) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

ll latter(ll pos, vector<ll>& v){
   return lower_bound(v.begin(),v.end(),pos) - v.begin();
}
ll former(ll pos, vector<ll>& v){
   return lower_bound(v.begin(),v.end(),pos) - v.begin() - 1;
}

const ll INF = 1LL << 60;

int main(){
  ll A,B,Q; cin >> A >> B >> Q;
  vector<ll> s(A),t(B),q(Q);
  
  rep(i,A) cin >> s[i];
  rep(i,B) cin >> t[i];
  rep(i,Q) cin >> q[i];
  
  s.push_back(INF);s.push_back(-INF);sort(s.begin(),s.end());
  t.push_back(INF);t.push_back(-INF);sort(t.begin(),t.end());
  
  rep(i,Q){
    ll pos = q[i]; //現在位置
    ll res = INF;
    rep(j,2){
      ll first = (j ? s[former(pos,s)]:s[latter(pos,s)]);
      rep(k,2){
        ll second = (k ? t[former(first,t)]:t[latter(first,t)]);
        chmin(res, abs(pos - first)+abs(first - second));
      }
    }
    rep(j,2){
      ll first = (j ? t[former(pos,t)]:t[latter(pos,t)]);
      rep(k,2){
        ll second = (k ? s[former(first,s)]:s[latter(first,s)]);
        chmin(res, abs(pos - first)+abs(first - second));
      }
    }
    cout << res << endl;
  }
  

  
  return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll a, p;
    cin >> a >> p;
    cout << (a*3+p)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
const processData = (lines) => {
    const n = +lines[0]
    console.log(1000 - n%1000 < 1000 ? 1000 - n % 1000 :  0)
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    processData(lines)
})


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

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

  bool flag = false;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      int k = n - i - j;
      if (10000*i + 5000*j + 1000*k == y && 0 <= k && k <= n){
        cout << i << " "<< j << " " << k << endl;
        flag = true;
        break;
      }
    }
    if (flag) break;
  }
  if (flag == false){
    cout << -1 << " "<< -1 << " " << -1 << endl;
  }
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1000003;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[(n-k+MOD)%MOD] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll Q;
    Combination cb(1000010);
    cin >> Q;
    while(Q--){
        ll x,d,n;
        cin >> x >> d >> n;
        if(d == 0){
            print(cb.power(x, n));
            continue;
        }
        ll lv = x * cb.power(d, MOD-2) % MOD;
        ll rv = (lv + n - 1) % MOD;
        if(n >= MOD || lv > rv){
            print(0);
        }else{
            ll ans = 0;
            if(lv == 1){
                ans = cb.get(rv);
            }else{
                ans = cb.get(rv) * cb.getinv(lv-1) % MOD;
            }
            ans *= cb.power(d, n);
            ans %= MOD;
            print(ans);
        }
    }
    

}

Measured memory_bytes: 22632
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll mod = 1000000000+7;
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
      if (n & 1) res = res * a % mod;
      a = a * a % mod;
      n >>= 1;
  }
  return res;
}

int main() {
    string b;
    std::cin >> b;
    if(b[0] == 'A'){
        std::cout << "T" << std::endl;
    }else if(b[0] == 'T'){
        std::cout << "A" << std::endl;
    }else if(b[0] == 'G'){
        std::cout << "C" << std::endl;
    }else if(b[0] == 'C'){
        std::cout << "G" << std::endl;
    }
}


Measured memory_bytes: 256
###modular exponentiation: a^n % M
#pow(a, n, M) 
### gcd: gcd(a, b)
#import fractions
#fractions.gcd(a, b)
### LCM (M, N)
#lcm = M*N/fractions.gcd(M, N)
INF = 1000000000+5

def get_res(N, A):
    DPA = [0]*N
    DPB = [0]*N
    DPC = [0]*N
    a0, b0, c0 = A[0]
    DPA[0] = a0
    DPB[0] = b0
    DPC[0] = c0
    for i in range(1, N):
        # DP[i] = minimum penalty incurred in reaching stone i from stone 1
        ai, bi, ci = A[i]
        DPA[i] = ai + max(DPB[i-1], DPC[i-1])
        DPB[i] = bi + max(DPA[i-1], DPC[i-1])
        DPC[i] = ci + max(DPA[i-1], DPB[i-1])
    return max(DPA[N-1], DPB[N-1], DPC[N-1])

N = int(input())
A = []
for _ in range(N):
    L = [int(s) for s in input().split(" ")]
    A.append(L)
result = get_res(N, A)
print("{}".format(result))


Measured memory_bytes: 36212
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(V) (V).begin(), (V).end() 
using namespace std;
typedef long long ll;

int main() {fio;
	int n, m;
	cin >> n >> m;
	vector <int> a(n);	
	for(int &u: a) cin >> u;
	int ans = 0;
	int t = accumulate(all(a), 0);
	double f = (double)t / (4 * m);
	int c = 0;
	for(int i = 0; i < n; i++) {
		c += (a[i] - f > -0.0000000001);
	}
	if(c < m) cout << "No";
	else cout << "Yes";
    return 0;
}

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

using namespace std;

const int N = int(1e5 + 100);
int d[N];

int main(){
    int n;

    scanf("%d", &n);

    for(int i = 0 ; i < n ; i++){
        scanf("%d", &d[i]);
    }

    sort(d, d + n);

    printf("%d\n", d[n / 2] - d[n / 2 - 1]);

    return 0;
}

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod (int)1e9+7
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'

struct custom_hash {    // anti-hack for unordered_map. To declare: unordered_map<long long, int, custom_hash> safe_map;
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//



void solve()
{
    int s;
    cin >> s;
    if(s<3){
        cout<<"0";return;
    }
    ll cnt = 0;
    vector<ll>dp(s+1,1);
    dp[0]=dp[1]=dp[2]=0;
    vector<int>v;
    for(int i=3;i<=s;i++)v.pb(i);
    for(int i=3;i<=s;i++)
    {
        for(int j:v)
        {
            if(j<=i)
                dp[i]=(dp[i]+dp[i-j])%1000000007;
        }
    }
    cout<<dp.back();
}


int main()
{
	fastio;
    int T;
    // cin>>T;
    // while(T--)
        solve();
	return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            var X = long.Parse (Console.ReadLine ());

            double A = 100;
            for (var i = 0; i <= Math.Pow (10, 18); i++)
            {

                A += Math.Floor (A * 0.01);

                if (A >= X)
                {
                    Console.WriteLine (i + 1);
                    return;
                }

            }
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 27824
package main

import (
    "fmt"
    "bufio"
    "os"
)

//FOR I/O : STARTS
var Reader *bufio.Reader = bufio.NewReader(os.Stdin)
var Writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func Printf (f string, a ...interface{}) { fmt.Fprintf(Writer, f, a...) }
func Scanf (f string, a ...interface{}) { fmt.Fscanf(Reader, f, a...) }
func Println (a ...interface{}) { fmt.Fprintln(Writer, a...)}
func Scanln (a ...interface{}) { fmt.Fscanln(Reader, a...)}
//I/O ENDS HERE

func Abs(x int) int {
    if x < 0 {
        return -x
    }
    return x
}

func Min(x, y int64) int64 {
    if x < y {
        return x
    } else {
        return y
    }
}

func Max(x, y int64) int64 {
    if x >= y {
        return x
    } else {
        return y
    }
}

func Ceil(x, y int64) int64 {
    //returns x/y
    if x%y == 0 {
        return x/y
    } else {
        return int64(x/y)+1
    }
}

func main() {
    defer Writer.Flush()

    var a, b, n int64
    Scanf("%d %d %d\n", &a, &b, &n)

  	x := Min(b-1, n)
  
    temp1 := int64((a*x)/b)
    temp2 := a*int64(x/b)
    // Println(temp1, temp2)
  	ans := (temp1 - temp2)


    Println(ans)
}


Measured memory_bytes: 1824
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr long long INF = 1000000000000000000LL + 8;

class Graph {
   private:
    struct edge {
        int to;
        int cost;
        edge(int i, int c) : to(i), cost(c) {}
    };
    vector<vector<edge>> edges;
    vector<int> dists;

   public:
    Graph(int n) { edges.resize(n); };
    int size() const { return edges.size(); };
    int countEdge() const {
        int count = 0;
        for (auto &&i : edges)
            for (auto &&j : i) count++;
        return count;
    }
    void addDirectedEdge(int from, int to, int cost) {
        edges[from].push_back(edge(to, cost));
    }
    void addEdge(int from, int to, int cost) {
        addDirectedEdge(from, to, cost);
        addDirectedEdge(to, from, cost);
    }

    // 根からの距離を求める
    void setDistances() {
        // 頂点を深さ優先探索
        dists.assign(size(), INF);
        stack<int> stk;
        stk.push(0);
        dists[0] = 0;

        while (!stk.empty()) {
            const int p = stk.top();
            stk.pop();
            for (auto &&next_edge : edges[p]) {  // すべての隣接する頂点を調べる
                const int np = next_edge.to;
                // 隣接する頂点が未探索なら探索
                if (dists[np] == INF) {
                    stk.push(np);
                    dists[np] = dists[p] + next_edge.cost;
                }
            }
        }
    }
    vector<int> getDist() const { return dists; }
};

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

    int n;
    cin >> n;

    Graph g(n);
    for (int i = 0; i < n-1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;  // convert to 0-based
        g.addEdge(u, v, w);
    }

    g.setDistances();
    vector<int> dists = g.getDist();
    for (auto &&i : dists) {
        // 根からの距離が偶数なら白、奇数なら黒で塗ったらおk
        cout << (i % 2) << endl;
    }
}


Measured memory_bytes: 9472