akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def mapline(t = int):
    return map(t, sysread().split())
def mapread(t = int):
    return map(t, read().split())

def generate_inv(n,mod):
    """
    逆元行列
    n >= 2
    Note: mod must bwe a prime number
    """
    ret = [0, 1]
    for i in range(2,n+1):
        next = -ret[mod%i] * (mod // i)
        next %= mod
        ret.append(next)
    return ret

def run():
    N, *A = mapread()
    maxA = max(A)
    L = maxA.bit_length()
    subs = [0] * L
    for k in range(L):
        sum = 0
        for a in A:
            if (a >> k) & 1:
                sum += 1 << k
            sum %= mod
        subs[k] = sum

    sumA = 0
    for a in A:
        sumA += a
        sumA %= mod
    ret = 0
    ret += (sumA * N) % mod
    ret += (sumA * N) % mod

    sub_sum = 0
    for a in A:
        sums = 0
        for k in range(L):
            if (a >> k) & 1:
                sums += subs[k] * 2
                sums %= mod
        sub_sum += sums
        sub_sum %= mod

    ret -= sub_sum
    ret %= mod

    inv = generate_inv(2, mod)
    ret *= inv[2]
    ret %= mod
    print(ret)


if __name__ == "__main__":
    run()


Measured memory_bytes: 126368
#include <stdio.h>
#include <math.h>

int main(void){
  int i,x,y = 1,z;

  while(1)
    {
      y = 1;
      z = scanf("%d",&x);
      if(z == EOF)
	break;

      for(i = 1;i <= x;i++)
	{
	y += i;
	}

      printf("%d\n",y);

    }

  return 0;
}
 

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++)
#define FORL(a, b, c) for (int(a) = (b); (a) <=(c); (a)++)
#define FORR(a, b, c) for (int(a) = (b); (a) >= (c); (a)--)
#define INF 1000000000000000003
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define F first
#define S second
#define PB push_back
#define POB pop_back
#define MP make_pair
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
     int n;
     cin>>n;
     char s[n];
    FOR(i,n)
    cin>>s[i];
     int f=0;
     if(n%2!=0)
     cout<<"No"<<endl;
     else
     {
     FOR(i,n/2)
     {
        if(s[i]==s[i+(n/2)])
		f=1;
		else
		{
			f=0;
			break;
			}	
	 }
	 if(f==0)
	 cout<<"No"<<endl;
	 else
	 cout<<"Yes"<<endl;
     }
    return 0;
}


Measured memory_bytes: 256
/*
 *  I wish I could travel by the road that crosses baby's mind,
 *  and out beyond all bounds;
 *  Where messengers run errands for no cause
 *  between the kingdoms of kings of no history;
 *  Where Reason makes kites of her laws and flies them,
 *  and Truth sets Fact free from its fetters.
 *                                           Rabindranath Tagore
 */

#include <bits/stdc++.h>
using namespace std;

#ifndef ORZ_EVERYBODY_BUT_ME
#define ORZ_EVERYBODY_BUT_ME
#endif

#ifndef SOCIALISM
#define SOCIALISM
#endif

unsigned long long operator "" _love(unsigned long long literal) {
    return literal;
}

const size_t MAX_N = 1e5 + 5;

int p[MAX_N];
vector<int> g[MAX_N];
bool used[MAX_N];
map<int, int> mp;

inline void addEdge(int a, int b) {
    g[a].emplace_back(b);
    g[b].emplace_back(a);
}

void dfs(int v) {
    if (used[v]) return ;
    used[v] = true;
    ++mp[v]; ++mp[p[v]];
    for (int u: g[v]) dfs(u);
}

int main() {
    assert(1731_love);

    int n, m, res = 0;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%d", p + i);
    for (int i = 0, x, y; i < m; ++i) {
        scanf("%d%d", &x, &y);
        addEdge(x, y);
    }

    for (int i = 1; i <= n; ++i) {
        map<int, int>().swap(mp);
        dfs(i);
        for (auto cnt: mp)
            res += cnt.second == 2;
    }

    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int n,x;
    cin>>n>>x;
    vector<int>l(n);
    rep(i,n)cin>>l[i];
    int cnt = 0, d = 0;
    int i = 0;
    while(d<=x){
        cnt++;
        if(cnt==n+1)
            break;
        d += l[i];
        i++;
    }
    cout<<cnt<<endl;

    return 0;
}

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

int main() {
    int r;
    std::cin >> r;
    if (r < 1200)
        std::cout << "ABC" << std::endl;
    else if (r < 2800)
        std::cout << "ARC" << std::endl;
    else
        std::cout << "AGC" << std::endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll c=0; ll ans=0;
    for(ll i=0;i<3;i++)
    {
        if(s[i]=='R')
        {
            c++; ans=max(ans,c);
        }
        else c=0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int n;
	string s;
	cin >> n >> s;

	int ans = 0;
	FOR(0, n)
	{
		if (s[i] != s[i + 1])ans++;
	}

	if (ans == 0)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 512
import Control.Monad
import qualified Data.Sequence as C

main :: IO ()
main = do
  [n, q] <- readInts
  s <- C.fromList <$> getLine
  let sol = solve s
  lrs <- replicateM q readInts
  forM_ lrs $ \[l, r] -> do
    print $ (sol `C.index` r) - (sol `C.index` l)

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: C.Seq Char -> C.Seq Int
solve s = (0 C.<|)
  $ C.scanl (+) 0
  $ fmap (\x -> if x == ('A', 'C') then 1 else 0)
  $ C.zip s (C.drop 1 s C.|> '_')

Measured memory_bytes: 133756
from collections import deque
 
n = int(input())
 
def dfs(n):
  stack = deque()
  stack.append("a")
  while stack:
    q = stack.popleft()
    if len(q) == n:
      ans.append(q) 
    if len(q) < n:
      for i in range(ord("a"), ord(max(q)) + 2):
        stack.append(q + chr(i))
    #print(stack)
    
ans = []
dfs(n)
 
print("\n".join(ans))

Measured memory_bytes: 16312
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N;
	long long ans;
	long long array[87];
	array[0] = 2;
	array[1] = 1;
	cin >> N;
	for (int i = 0; i <= N; i++) {
		if (i == 0 || i == 1) continue;
		ans = array[i - 2] + array[i - 1];
		array[i] = ans;
	}
	cout << array[N] << endl;
}


Measured memory_bytes: 256
N,M,Q=map(int, input().split())
L=[[0]*(N+1) for _ in range(N+1)]
for i in range(M):
    l,r=map(int, input().split())
    L[l][r]+=1

#print(L)
for i in range(1,N+1):
    for j in range(1,N+1):
        L[i][j]+=L[i][j-1]+L[i-1][j]-L[i-1][j-1]

#print(L)

for i in range(Q):
    p,q=map(int, input().split())
    ans=L[q][q]-L[p-1][q]-L[q][p-1]+L[p-1][p-1]
    print(ans)

Measured memory_bytes: 56664
#include <stdio.h>

int main(void)
{
    int w;
    int bin_digit;

    while (scanf("%d", &w) != EOF){
        for (bin_digit = 1; bin_digit <= w; bin_digit *= 2){
            if ((w & bin_digit) != 0){
                printf("%d", bin_digit);
                if (bin_digit * 2 <= w){
                    printf(" ");
                }
                else {
                    printf("\n");
                }
            }
        }
    }

    return (0);
}

Measured memory_bytes: 596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            long max1 = 0;
            long max2 = 0;
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
            }
            Arrays.sort(a);
            for (int i = n - 1; i > 0; i--) {
                if (a[i - 1] == a[i]) {
                    max1 = a[i];
                    for (int j = i - 2; j > 0; j--) {
                        if (a[j - 1] == a[j]) {
                            max2 = a[j];
                            out.println(max1 * max2);
                            return;
                        }
                        if (j == 1) {
                            out.println(0);
                            return;
                        }
                    }
                }
            }
            out.println(0);
        }

    }
}



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

#define ll long long
#define endl '\n'
const int N = 1e6 + 5;

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll a, b, c;
        cin >> a >> b >> c;
        if ((c - a - b) <= 0) cout << "No" << endl;
        else if ((c - a - b) * (c - a - b) > 4 * a * b) cout << "Yes" << endl;
        else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		switch(N%10) {
			case 0:
				System.out.println("pon");
				break;
			case 1:
				System.out.println("pon");
				break;
			case 3:
				System.out.println("bon");
				break;
			case 6:
				System.out.println("pon");
				break;
			case 8:
				System.out.println("pon");
				break;
			default:
				System.out.println("hon");
				break;
		}
	}

}

Measured memory_bytes: 35768
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int H, W; cin >> H >> W;
	vector<char> as(H * W);
	REP(i, H * W) cin >> as[i];
	vector<int> path;
	int cur = 0;
	bool isPossible = true;
	// move with the shortest path
	for (;;)
	{
		path.push_back(cur);
		if (cur == H * W - 1)
		{
			break;
		}
		int row = cur / W;
		int col = cur % W;
		if (row < H - 1 && as[cur + W] == '#')
		{
			cur = cur + W;
		}
		else if (col < W - 1 && as[cur + 1] == '#')
		{
			cur = cur + 1;
		}
		// if cannot move, impossible
		else
		{
			isPossible = false;
			break;
		}
	}
	if (isPossible)
	{
		// if detour exists, impossible
		int pathLen = path.size();
		int moveNum = count(as.begin(), as.end(), '#');
		if (pathLen != moveNum)
		{
			isPossible = false;
		}
	}
	cout << (isPossible ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  string s;
  cin >> s;
  if(s=="RRR") cout << 3 << endl;
  else if (s=="SSS") cout << 0 << endl;
  else if (s=="SRR" || s=="RRS") cout << 2 << endl;
  else cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int len;
char s[110];
int dp[110][110];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> s;
	len = strlen(s);
	int cnt = 0;
	for(int i = 0, j = len-1; i < j; i++, j--) {
		if(s[i] != s[j])
			cnt++;
	}
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), k = sc.nextInt();
		Integer [] a = new Integer[n];
		for (int i = 0; i < a.length; ++i) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int min = a[k-1] - a[0];
		for (int i = 1; i+k-1 < n; ++i) {
			min = Math.min(min, a[i+k-1] - a[i]);
		}
		out.println(min);
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

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

}


Measured memory_bytes: 35852
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int n;
int a[200005];
long long ans;
int main()
{
	int i;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i],a[i]-=i;
	sort(a+1,a+1+n);
	for(i=1;i<=n;i++)
		ans+=abs(a[i]-a[(n+1)/2]);
	cout<<ans;
	return 0;
	
	
} 



Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  switch (N % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    default:
      cout << "bon" << endl;
  }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll a,b,c,d;
    ll ans = -(1ll << 60);
    cin >> a >> b >> c >> d;
    ans = max(ans, a*c);
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;


    return 0;
}

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

using namespace std;

int main(){
    int n, k, cnt=0, mx=0;
    string s;
    cin >> n >> k >> s;
    int curr=0, curl=0;
    while(curr<n){
        while(cnt<k && curr<n){
            curr++;
            if(curr == n)break;
            if(s[curr]=='1' && s[curr-1]=='0'){
                cnt++;
            }
        }
        while(curr<n){
            curr++;
            if(s[curr]=='0' && s[curr-1]=='1'){
                break;
            }
        }
        mx = max(mx, curr - curl);
        if(cnt<k)break;
        while(cnt>=k && curl<n){
            curl++;
            if(s[curl]=='1' && s[curl-1]=='0'){
                cnt--;
            }
        }
    }
    cout << mx << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main(){

  stack <int> sa;
  string m;
  int cnt=0,result=0,high=0,tmp=0,h[20000],i;
  vector <int> amo;

  cin>>m;
  for(i=m.size()-1;i!=-1;i--){
    if(m[i]=='\\') tmp++;
    if(m[i]=='/') tmp--;
    if(tmp<0){
      for(int j=i+1;j<m.size();j++) h[j]++;
      high++;
      tmp=0;
    }
    high=max(high,tmp);
    h[i]=high;
  }
  //for(i=0;i<m.size();i++) cout<<h[i]<<" ";

  for(i=0;i<m.size();i++){
    //    if(i>0) if(h[i]-h[i-1]==1) sa.pop(); 
    if(m[i]=='\\'){
      sa.push(i);
    } else if(m[i]=='/' && !sa.empty()) {
      cnt+=i-sa.top();
      sa.pop();
      if(sa.empty()){
        amo.push_back(cnt);
        result+=cnt;
        cnt=0;
      }
    }
    if(i<m.size()-1) if(h[i+1]-h[i]!=0) sa.pop();
  }
  if(cnt!=0){
    amo.push_back(cnt);
    result+=cnt;
  }
  if(amo.empty()) cout<<"0"<<endl<<"0"<<endl;
  else{
    cout<<result<<endl<<amo.size()<<" ";
    for(i=0;i<amo.size()-1;i++) cout<<amo[i]<<" ";
    cout<<amo[amo.size()-1]<<endl;
  }
  return 0;

}

Measured memory_bytes: 3336
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			String str = cin.next();
			String[] s = str.split(",");
			int num = Integer.parseInt(s[0]);
			double w = Double.parseDouble(s[1]);
			double t = Double.parseDouble(s[2]);
			if(w/(t*t) >= 25.0){
				System.out.println(num);
			}
		}

	}

}

Measured memory_bytes: 12000
module Main where

import Control.Applicative
import Numeric
import Data.Char
import Data.List
import Data.Ord

main :: IO ()
main = do
  { l1 <- getLine
  ; l2 <- getLine
  ; let l1' =  l1 ++ l1
  ; if isInfixOf l2 l1' then putStrLn "Yes" else putStrLn "No"      
  }



Measured memory_bytes: 3548
a = list(map(int,input().split()))
a = sorted(a)
if (a[2]-a[0])%2==0 and (a[2]-a[1])%2==0:
  ans = (a[2]-a[0])//2+(a[2]-a[1])//2
if (a[2]-a[0])%2!=0 and (a[2]-a[1])%2!=0:
  ans = (a[2]-a[0]-1)//2+(a[2]-a[1]-1)//2+1
if (a[2]-a[0])%2==0 and (a[2]-a[1])%2!=0:
  ans = (a[2]-a[0])//2+(a[2]-a[1]+1)//2+1
if (a[2]-a[0])%2!=0 and (a[2]-a[1])%2==0:
  ans = (a[2]-a[0]+1)//2+(a[2]-a[1])//2+1
print(ans)

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

template<class T>
class Bit{
public:
	vector<T>bit;
	T cnt;
	Bit(int n){
		bit=vector<T>(n*2);
		cnt=0;
	}
	void add(int k,T x){
		k++;
		while(k<(int)bit.size()){
			bit[k]+=x;
			k+=k&-k;
		}
		cnt+=x;
	}
	T sum(int k){
		k++;
		T res=0;
		while(k){
			res+=bit[k];
			k-=k&-k;
		}
		return res;
	}
	T sum2(int k){
		return cnt-sum(k);
	}
};
signed main(){
	int n,d,a;cin>>n>>d>>a;
	vector<P>v;
	vector<int>xs;
	rep(i,n){
		int x,h;scanf("%lld%lld",&x,&h);
		xs.push_back(x);
		v.push_back(P(x,h));
	}
	sort(xs.begin(),xs.end());
	sort(v.begin(),v.end());
	d*=2;
	Bit<ll>bit(xs.size());
	ll ans=0;
	rep(i,n){
		if(bit.sum(i)*a>=v[i].second)continue;
		ll s=v[i].second-bit.sum(i)*a;
		s=(s+a-1)/a;
		ans+=s;
		bit.add(i,s);
		auto it=upper_bound(xs.begin(),xs.end(),v[i].first+d)-xs.begin();
		bit.add(it,-s);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8672
N = gets.to_i
N.times do
  a = gets.to_i
  b = gets.to_i
  if a.to_s.size > 80 || b.to_s.size > 80
    puts "overflow"
  else
    sum = a+b
    if sum.to_s.size>80
      puts "overflow"
    else
      puts sum
    end
  end
end

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  string A;
  string B;
  string C;
  
  rep(i,3) {
    string s; cin>>s;
    
    if (i==0) A=s;
    if (i==1) B=s;
    if (i==2) C=s;
  }
  
  char next = 'a';
  
  while(true) {
    if(next == 'a') {      
      if (A.length() == 0) {
        cout<<"A";
        return 0;
      }
      next = A[0];
      A.erase(0,1);
    } else if(next == 'b') {
      if (B.length() == 0) {
        cout<<"B";
        return 0;
      }
      next = B[0];
      B.erase(0,1);
    } else if(next == 'c') {
      if (C.length() == 0) {
        cout<<"C"; 
        return 0;
      }
      next = C[0];
      C.erase(0,1);
    } 
  }
  
  return 0;
}

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


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

    int X[100010], Y[100010], ai;
    fill(X, X+100010, 0);
    fill(Y, Y+100010, 0);
    rep(i, N) {
        cin >> ai;
        if (i%2 == 0) X[ai]++;
        else Y[ai]++;
    }

    int onum0 = 0, onum1 = 0, enum0 = 0, enum1 = 0;
    int oi0 = 0, oi1 = 0, ei0 = 0, ei1 = 0;

    rep(i, 100001) {
        if (onum0 <= X[i]) {
            onum1 = onum0;
            oi1 = oi0;
            onum0 = X[i];
            oi0 = i;
        } else if (onum1 <= X[i]) {
            onum1 = X[i];
            oi1 = i;
        }

        if (enum0 <= Y[i]) {
            enum1 = enum0;
            ei1 = ei0;
            enum0 = Y[i];
            ei0 = i;
        } else if (enum1 <= Y[i]) {
            enum1 = Y[i];
            ei1 = i;
        }
    }

    int ans;
    if (oi0 != ei0) ans = N - onum0 - enum0;
    else ans = min(N - onum0 - enum1, N - onum1 - enum0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/ruby
h={2=>[[2, 1]], 3=>[[3, 1]], 4=>[[2, 2]], 5=>[[5, 1]], 6=>[[2, 1], [3, 1]], 7=>[[7, 1]], 8=>[[2, 3]], 9=>[[3, 2]], 10=>[[2, 1], [5, 1]], 11=>[[11, 1]], 12=>[[2, 2], [3, 1]], 13=>[[13, 1]], 14=>[[2, 1], [7, 1]], 15=>[[3, 1], [5, 1]], 16=>[[2, 4]], 17=>[[17, 1]], 18=>[[2, 1], [3, 2]], 19=>[[19, 1]], 20=>[[2, 2], [5, 1]], 21=>[[3, 1], [7, 1]], 22=>[[2, 1], [11, 1]], 23=>[[23, 1]], 24=>[[2, 3], [3, 1]], 25=>[[5, 2]], 26=>[[2, 1], [13, 1]], 27=>[[3, 3]], 28=>[[2, 2], [7, 1]], 29=>[[29, 1]], 30=>[[2, 1], [3, 1], [5, 1]], 31=>[[31, 1]], 32=>[[2, 5]], 33=>[[3, 1], [11, 1]], 34=>[[2, 1], [17, 1]], 35=>[[5, 1], [7, 1]], 36=>[[2, 2], [3, 2]]}
while(l=gets.chomp)!="0 0"
	l=l.split
	n=l[0].to_i;m=l[1].to_i(n)
	p h[n].map{|a,b|
		z=m;r=0
		while z>0 do r+=(z=z.div(a)) end
		r.div(b)
	}.min
end

Measured memory_bytes: 2588
/*------------Ajeet -------------------*/

#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl; 
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N;  
	long long int A[410] = {}; 
	for(int i = 1; i <= N; i++) cin >> A[i]; 
	long long int S[410] = {}; 
	for(int i = 1; i <= N; i++) S[i] = S[i-1] + A[i]; 
	long long int dp[410][410] = {}; // 区間[i, j] をまとめるときのmin	
	for(int d = 1; d < N; d++){
		for(int i = 1; i <= N - d; i++){
			// dp[i][i+d] を最後にまとめる区間で場合分け
			long long int tmp = 1e18; 
			for(int j = 0; j < d; j++){
				tmp = min(tmp, dp[i][i+j] + dp[i+j+1][i+d]);  
			}
			dp[i][i+d] = tmp + S[i+d] - S[i-1]; 
		}
	}
	cout << dp[1][N] << endl; 
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

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

	if (a <= 9 && b <= 9)
	{
		cout << (a*b) << endl;
	}
	else
	{
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
#a, b = map(int, input().split())
#l = list(map(int, input().split()))
#s = input()


t = n % 10
if t == 2 or t == 4 or t == 5 or t == 7 or t == 9:
    print("hon")
elif t == 0 or t == 1 or t == 6 or t == 8:
    print("pon")
else:
    print("bon")



Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

void solve(long long W, long long a, long long b)
{
    if ((a <= b && b <= a + W) || (a <= b + W) && (b + W <= a + W))
    {
        cout << 0 << endl;
        return;
    }
    else if (a + W < b)
    {
        cout << b - a - W << endl;
        return;
    }
    else if (b + W < a)
    {
        cout << max(0LL, a - b - W) << endl;
        return;
    }
}

int main()
{
    long long W;
    scanf("%lld", &W);
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    solve(W, a, b);
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
total = 0
los = [0]*n
for x, y in c.items():
    if y >= 2:
        total += y * (y-1) // 2
    if y >= 2:
        los[x-1] = y*(y-1)//2 - (y-1)*(y-2)//2

for i in range(n):
    print(total - los[a[i]-1])

Measured memory_bytes: 26780
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int a[N];
int n, m;
char s[N];
int main(){
	// int t;
	// while(){
	int cnt=0, ans=0;
		scanf("%d%s",&n,s);
		for(int i=0; i<n; ++i){
			if(s[i]=='R')++cnt;
		}
		for(int i=0; i<cnt; ++i){
			if(s[i]!='R')++ans;
		}
		cout<<ans<<endl;
	// }
}

Measured memory_bytes: 3876
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]

ans = 10**12

for i in range(2**D):
    ten = 0
    mon = 0
    keta = format(i, "0"+str(D)+"b")
    for j in range(D):
        if keta[j] == "1":
            ten += pc[j][0]*(j+1)*100 + pc[j][1]
            mon += pc[j][0]
    if ten < G:
        for j in range(D-1, -1, -1):
            if keta[j] == "0":
                for k in range(pc[j][0]):
                    ten += (j+1) * 100
                    mon += 1
                    if ten >= G:
                        break
                if ten >= G:
                    break
    if ten >= G:
        ans = min(ans, mon)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <map>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define MAX_N 105
int vx [4]= {1,0,-1,0};
int vy [4]= {0,1,0,-1};
long long  dp[MAX_N][21]={};//dp[i???????????§???][???]????????°
int V[MAX_N],W[MAX_N];
int data[MAX_N],B[MAX_N];
int K ,N,a[MAX_N];
using namespace std;
void init(){

  /*cin >> N;
  cin >> a[1];
    dp[1][a[1]]=1;
  for(int l= 2;l<=N-1;l++){
    cin >> a[l];
    for(int i= 0;i<=20;i++){
      if(i-a[l]>=0&&i-a[l]<=20) dp[l][i] += dp[l-1][i-a[l]];
      if(i+a[l]>=0&&i+a[l]<=20) dp[l][i] += dp[l-1][i+a[l]];
    }
      //REP(i,21)cout<<l<<':'<< i<<' '<<dp[l-1][i]<<endl;
  }
  //REP(i,21)cout<< i<<' '<<dp[N-1][i]<<endl;
  cin >> a[N];
  cout << dp[N-1][a[N]]<<endl;
  */
}
void solve(){
  init();

}
int main(){
    vector<int>h ;
    int t;
    REP(i,10)
    {cin >> t;
    h.push_back(t);
  }
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
  REP(i,3)cout << h[i]<<endl;
}

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

using namespace std;

void solve() {
	string S;
	long long int K;
	cin >> S >> K;

	/* calculate */
	char ans;
	int firsti = 0;
	char c;
	for (unsigned int i = 0; i < S.length(); ++i) {
		if (S[i] == '1') {
			firsti++;
		} else {
			c = S[i];
			break;
		}
	}

	if (K <= firsti) {
		ans = '1';
	} else {
		ans = c;
	}

	/* print */
	cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
    int N;
    cin >> N;
    vector<long long>A(N);
    long long sum = 0;
    long long tall;

    for (int i = 0 ; i < N; i++) {
        cin >> A.at(i);
        if (i == 0){
            tall = A.at(0);
        }
        if (i != 0){
            if (A.at(i) < tall){
                sum += tall - A.at(i);
            }
            else {
                tall = A.at(i);
            }  
        }
    }
    
        cout << sum << endl;     
    }





Measured memory_bytes: 4760
hash = Hash.new(0)

n = gets.chomp.to_i

n.times do
  a, v = gets.chomp.split.map(&:to_i)
  hash[a] += v
end

hash = hash.sort do |(k1, v1), (k2, v2)|
  if v1 == v2
    k1 <=> k2
  else
    v2 <=> v1
  end
end

puts hash.shift.join(' ')

Measured memory_bytes: 8676
n = int(input())

def count_digit(num):
    return len(str(num))

ln = count_digit(n)
i = 1
while ((i*i) <= n):
    if n % i == 0:
        b = int(n // i)
        cur = max(count_digit(i), count_digit(b))
        if ln > cur:
            ln = cur
    i+=1

print(ln)


Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Van Hanh Pham (skyvn97)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        private static final String goal = "CODEFESTIVAL2016";

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            int res = 0;
            for (int i = 0; i < s.length(); i++)
                if (s.charAt(i) != goal.charAt(i)) res++;
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String nextString() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 8404
#include <bits/stdc++.h>
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug& operator<<
#define eni(x) \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int N = 1e5+5;
vector<int> edges[N];
int dist[N], in_degree[N], n, m;
bool isVisited[N];

void dfs(int a) {
    assert(!isVisited[a]);
    isVisited[a] = true;
    for (auto b : edges[a]) {
        dist[b] = max(dist[b], dist[a]+1);
        --in_degree[b];
        if (!in_degree[b]) {
            dfs(b);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    while (m--) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        in_degree[b]++;
    }

    for (int i = 1; i <= n; i++) {
        if (!in_degree[i] && !isVisited[i]) {
            dfs(i);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dist[i]);
        debug() << edges[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9728
//#include <tourist>
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    ll y=x;
    ll ans=1;
    while(x%360){
        x+=y;
        ans++;
    }
    cout<<ans<<"\n";
}

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

string s, t;

int main() {
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'b') t += 'd';
		if (s[i] == 'd') t += 'b';
		if (s[i] == 'p') t += 'q';
		if (s[i] == 'q') t += 'p';
	}
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[t.length() - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
def find_negative_loop(n, w, edges):
    d = [float('inf')] * n
    d[0] = 0
    for i in range(n):
        for (u, v, c) in edges:
            if d[v] > d[u] + c:
                d[v] = d[u] + c
                if i == n - 1 and v == n - 1:
                    return None
    return d[n-1]

def main():
    N, M = map(int, input().split())
    edges = [None] * M
    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        edges[i] = (a, b, -c)


    ans = find_negative_loop(N, M, edges)

    if ans:
        print(-1 * ans)
    else:
        print('inf')

    
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 45928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N%2==1) {
			System.out.println("No");
			return ;
		}
		String s = sc.next();
		for (int i=0;i<s.length()/2;i++) {
			if (s.charAt(i)!=s.charAt(N/2+i)) {
				System.out.println("No");
				return ;
			}
		}
		System.out.println("Yes");
		return ;
	}
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    vi abc(3);
    fo(i, 3) cin >> abc[i];
    sort(all(abc));

    int ans;
    if ( (abc[2] - abc[1]) % 2 == (abc[2] - abc[0]) % 2 ) {
        ans = abc[2] - abc[1];
        ans += (abc[2] - (abc[0] + ans)) / 2;
    } else {
        ans = abc[2] - abc[1];
        ans += (abc[2] + 1 - (abc[0] + ans)) / 2;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

#define ll long long

int main(){
    int a,b;
    string s;
    cin >> a >> b;
    cin >> s;
    for(int i=0; i<a; i++){
        if(s[i]=='-'){
            cout << "No";
            return 0;
        }
    }
    if(s[a]!='-'){
        cout << "No";
        return 0;
    }
    for(int i=a+1; i<=a+b; i++){
        if(s[i]=='-'){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";


}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <string>

using namespace std;

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

  for(;n;n--){
    cin >> t;
    r += (t>=k ? 1 : 0);
  }
  
  cout << r << endl;
  
  return 0;
}


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

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

    long ans = 0;
    for (int i = 2; i <= n; i++){
        int a;
        cin >> a;
        if (a >= aMax){
            aMax = a;
        }
        else{
            ans += (long)(aMax - a);
        }
        
    }
    
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int solve(vector<int> a, vector<int> b, vector<int> parm, vector<int> use,int n,int m){
  if(n == parm.size()){
    //rep(i,n) cout<<parm[i];
    //cout<<endl;
    bool ans = true;
    rep(i,n-1){
      bool buf = false;
      rep(j,m)
        if ((parm[i]==a[j]-1&&parm[i+1]==b[j]-1)||(parm[i]==b[j]-1&&parm[i+1]==a[j]-1))
          buf = true;
      ans = ans && buf;
    }
    //cout<<ans<<endl;
    return ans ? 1 : 0 ;
  }
  int ans = 0;
  rep(i,n){
    if(use[i] == 0){
      use[i] = 1;
      parm.push_back(i);
      ans += solve(a,b,parm,use,n,m);
      use[i] = 0;
      parm.pop_back();
    }
  }
  return ans;
}
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m),b(m);
  vector<int> parm,use(n,0);
  rep(i,m) cin >> a[i] >> b[i];
  use[0] = 1;
  parm.push_back(0);
  cout << solve(a,b,parm,use,n,m) << endl;
}



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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
    // get values from input
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K, C;
    string S;

    cin >> N >> K >> C >> S;

    // main procedure
    vector<int> greedy_workdays(K, -1);
    vector<int> greedy_reverse_workdays(K, -1);

    int worked_day_count = 0;
    int last_worked_day = -C;

    for (int i = 1; i <= N; ++i) {
      if (S[i-1] == 'o' && last_worked_day < (int)i - C) {
        greedy_workdays[worked_day_count++] = i;
        last_worked_day = i;

        if (worked_day_count >= K) {
          break;
        }
      }
    }

    worked_day_count = 0;
    last_worked_day = N + C + 1;

    for (int i = N; i > 0; --i) {
      if (S[i-1] == 'o' && last_worked_day > (int)i + C) {
        greedy_reverse_workdays[K - (++worked_day_count)] = i;
        last_worked_day = i;

        if (worked_day_count >= K) {
          break;
        }
      }
    }

    vector<int> ans;
    for (size_t i = 0; i < K; ++i) {
      if (greedy_workdays[i] == greedy_reverse_workdays[i] &&
          greedy_workdays[i] != -1) {
        ans.push_back(greedy_workdays[i]);
      }
    }

    // output
    for (const auto &x : ans) {
      WRITE_N(x);
    }

    return 0;
}


Measured memory_bytes: 4236
#include <iostream>

using namespace std;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, X;
    cin >> A >> B >> X;
    if (X >= A && X <= A + B) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
    return 0;
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll ret = 0;
char c;

void input() {
  IN(c);
}

void solve() {
  switch(c) {
    case 'A': 
      PRINT('T');
      break;
    case 'T': 
      PRINT('A');
      break;
    case 'G': 
      PRINT('C');
      break;
    case 'C': 
      PRINT('G');
      break;
  }
}

int main(void){
  input();
  solve();
  // PRINT(ret);
}


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

int main(void)
{
	int N, M;
	cin >> N >> M;

	for(int i=M/N+1; i>0; i--){
		if(M%i != 0)
			continue;
		
		int cnt = M / i;
		if(cnt >= N){
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Pohe {
    static void Main() {
	var s = ReadLine();

	var n = (from x in s
		 where x == 'p'
		 select x).Count();

	WriteLine("{0}", (s.Count() / 2) - n);
    }
}


Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    vector<int> Dim(N, 0);
    REP(i, 0, N + M - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        Dim[b]++;
    }

    queue<int> q;
    int root = -1;
    REP(i, 0, N) {
        if (Dim[i] == 0) {
            q.emplace(i);
            root = i;
        }
    }

    vector<int> dp(N, 0);

    while (q.size()) {
        int e = q.front();
        q.pop();
        REP(i, 0, G[e].size()) {
            int ne = G[e][i];
            if (!(--Dim[ne])) {
                q.emplace(ne);
            }
            dp[ne] = max(dp[ne], dp[e] + 1);
        }
    }

    vector<int> par(N, 0);
    REP(i, 0, N) {
        dump(dp[i]);
    }
    while (q.size()) {
        q.pop();
    }

    q.emplace(root);
    while (q.size()) {
        int e = q.front();
        q.pop();
        REP(i, 0, G[e].size()) {
            int ne = G[e][i];
            dump(e);
            dump(ne);
            if (dp[e] + 1 == dp[ne]) {
                par[ne] = e + 1;
                q.emplace(ne);
            }
        }
    }

    REP(i, 0, N) {
        cout << par[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 7424
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  var V = input[1].split(" ");
  var C = input[2].split(" ");
  var sum = 0;
  var i = 0;
  for ( i = 0; i < N; i++){
    if( Number.parseInt(V[i]) - Number.parseInt(C[i]) > 0 ){
      sum = sum + Number.parseInt(V[i]) - Number.parseInt(C[i]);
    }
  }
  console.log(sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


using namespace std;


using ll = long long;
const int mod = 998244353;


mt19937 mt(736);


int foo(const string &x, int block)
{
	string bound = x.substr(0, block);

	bool ok = true, fn = false;

	for (int i = 0; !fn && ok && i * block < x.size(); i++)
		for (int j = 0; !fn && ok && j < block; j++)
		{
			char q = i % 2 == 0 ? bound[j] : '1' ^ '0' ^ bound[j];

			ok &= (q <= x[i * block + j]);

			if (q < x[i * block + j])
				fn = true;
		}

	bound = '0' + bound;

	if (ok)
		for (int i = bound.size() - 1; i >= 0; i--)
			if (bound[i]++ == '1')
				bound[i] = '0';
			else
				break;

	int cnt = 0;

	for (auto it : bound)
	{
		cnt *= 2;
		cnt += it - '0';

		if (cnt > mod)
			cnt -= mod;
	}

	return cnt;
}


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;
	string x;

	cin >> n >> x;

	vector<int> cnt(n + 1), arr;

	for (int i = 1; i * i <= n; i++)
		if (n % i == 0)
		{
			arr.push_back(i);
			arr.push_back(n / i);
		}

	sort(arr.begin(), arr.end());
	arr.erase(unique(arr.begin(), arr.end()), arr.end());

	for (auto it : arr)
		if (n / it % 2 == 1)
		{
			cnt[it] = foo(x, it);

			for (auto q : arr)
			{
				if (q == it)
					break;
				if (it % q == 0)
				{
					cnt[it] -= cnt[q];

					if (cnt[it] < 0)
						cnt[it] += mod;
				}
			}
		}

	ll ans = 0;

	for (auto it : arr)
	{
		ans += 2ll * it * cnt[it];
		ans %= mod;
	}

	cout << ans << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	auto st = clock();

	ifstream fin("../input.txt");

	solve(fin);

	cout << "clock: " << setprecision(4) << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}


Measured memory_bytes: 1812
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }
}

#endif

// main.cpp

int main() {
  i64 N, D, X;
  std::cin >> N >> D >> X;
  std::vector<i64> A;
  tools::read(A, N);

  std::cout << X + std::accumulate(A.begin(), A.end(), static_cast<i64>(0), [&D](const i64 sum, const i64 A_i) { return sum + (D - 1) / A_i + 1; }) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    if( s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3] ) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256