akhauriyash/Code-Regression huggingface dataset:
/**
 *    Author: "Robin Singh" !!
 *    BrainyIsTheNewSexy    (CodeForces, CodeJam)
 *    rob_in_1              (All Other OJs)
**/

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

#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ff first
#define ss second
#define MP make_pair
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     
#define bk(i, j, k) for(int i = j-1; i >= k; i--)
#define mem(ptr, val)  memset(ptr, val, sizeof ptr)
#define sbit(n)  __builtin_popcount(n)
#define nl "\n"

typedef long double ld;
typedef pair<int, int> pii;
typedef vector <int> vi;
typedef vector < pair<int,int> > vpii;
const long double eps = 1e-9;
const int mod = 1e9+7;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

//*****************************************!Template Ends Here!******************************************//

const int nn = 2e5+5;

void solve(){
    int n;
    cin >> n;
    int k = -1;
    for(int i=1; i<=1000; i++){       // i <= n will give WA for n = 1, as k = 2 is answer for n = 1 (as 2 > 1, k > n)
        if(i * (i - 1)/2 == n){       // n = 1 => (1), (1) 2 sets
            k = i;
            break;
        }
    }
    // k subsets of size (k-1)  [for one set one common from each k-1 set]
    // tot elements = k * (k-1)/2  [ /2  as all elements appear twice]
    if(k == -1){
        cout << "No";
        return;
    }
    cout << "Yes\n" << k << nl;

    int cur = 1;
    vector <int> s[k];

    for(int i = 0; i < k; i++){
        for(int j = i+1; j < k; j++){
            s[i].push_back(cur);
            s[j].push_back(cur++);
        }
    }
    for(int i=0; i<k; i++){
        cout << szz(s[i]) << ' ';
        for(int x : s[i]) cout << x << ' ';
        cout << nl;
    }
}

int32_t main(){
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int N;
	cin >> N;
	vector<ll> X(N), Y(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i];
		Y[i] = X[i];
	}

	sort(Y.begin(), Y.end());

	for (int i = 0; i < N; i++) {
		if (X[i] <= Y[(N-1) / 2]) {
			cout << Y[(N -1)/ 2 + 1] << endl;
		}
		else {
			cout << Y[(N-1) / 2] << endl;
		}


	}




}	


Measured memory_bytes: 5376
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            while (sc.hasNextInt()) {
                int n = sc.nextInt();
                boolean arr[] = new boolean[n+1];
                for (int i=0;i<=n;i++){
                    arr[i] = true;
                }
                arr[0] = false;
                arr[1] = false;
                for (int i=2;i<=n;i++){
                    if (arr[i]) {
                        for (int j=0;i*(j+2)<=n;j++){
                            arr[i*(j+2)] = false;
                        }
                    }
                }
                int m=0;
                for (int i=1;i<=n;i++){
                    if (arr[i]){
                        m++;
                    }
                }
                System.out.println(m);
            }
        }
    }
}


Measured memory_bytes: 41144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll a[N],x=1e18;
long long ans=1;
int main(){
     int n,f=0;
  	 scanf("%d",&n);
  	 for(int i=1;i<=n;i++){
	    scanf("%lld",&a[i]);
	    if(!a[i]) f=1;
		}
  	 if(f) puts("0"),exit(0);
  	 for(int i=1;i<=n;i++){
         if(a[i]>(x/ans)){
         	puts("-1");
         	exit(0);
		 }
         else ans*=a[i];
     }
    printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 4600
#include<bits/stdc++.h>
using namespace std;
vector<long long>v;
int f(int x)
{
	int ans=0;
	for(int i=1;i<=100;i++)
	{
		ans+=i;
		if(ans>x)
		{
			return i-1;
		 } 
	}	
}
int main()
{
	int ans=0;
    long long x;
    cin>>x;if(x==1)
    {
    	cout<<"0"<<endl;
    	return 0;
	}
    for(int i=2;i<=sqrt(x);i++)
    {
        while(x%i==0)
        {
            x/=i;
            v.push_back(i);
        }
    }
    if(x>1)
    {
    	v.push_back(x);
	}
	int count1=1;
	for(int i=1;i<v.size();i++)
	{
		if(v[i]!=v[i-1])
		{
			//cout<<count1<<endl;
			ans+=f(count1);
			count1=1;
		}
		else
		{
			count1++;
		} 
	}
//	cout<<count1<<endl;
	if(count1)ans+=f(count1);
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3716
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
#define MAX_N 200000
int t[MAX_N];
int main(){
    int N,T;
    int ans;
    cin >> N >> T;
    REP(i,N) cin >> t[i];
    ans = T;
    REP(i,N-1){
        ans += min(t[i+1]-t[i],T);
    }
    cout << ans << endl;
    return 0;
}


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

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

    int cnt = 0;
    if (abs(x) < abs(y))
    {
        if (x < 0) ++cnt;
        cnt += abs(y) - abs(x);
        if (y < 0) ++cnt; 
    }
    else
    {
        if (x > 0) ++cnt;
        cnt += abs(x) - abs(y);
        if (y > 0) ++cnt;
    }
    cout << cnt << endl;;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    int ok = 0, ng = n+1;
    while(ng-ok > 1){
        int mid = (ok+ng)/2, cnt = 0;
        for (auto &&i : v) if(i >= mid) cnt++;
        if(cnt >= mid) ok = mid;
        else ng = mid;
    }
    cout << ok << "\n";
    return 0;
}


Measured memory_bytes: 3240
N = int(input())
M = 10**9+7
Uset = 1
Aset = 1
Bset = 1
Cset= 1
for _ in range(N):
    Uset = (Uset*10)%M
    Aset = (Aset*9)%M
    Bset = (Aset*9)%M
    Cset = (Cset*8)%M
print((Cset+Uset-2*Aset)%M)


Measured memory_bytes: 9204
n , q = list(map(int, input().split()))
s = input()
data = []
for i in range(q):
    data.append(list(map(int, input().split())))
ans = [0 for i in range(n)]
count = 0
for i in range(1,n):
    if s[i - 1] == 'A' and s[i] == 'C':
        count += 1
    ans[i] = count
for i in range(q):
    l = data[i][0]
    r = data[i][1]
    print(ans[r - 1] - ans[l - 1])

Measured memory_bytes: 30704
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int m;
	int count_AC = 0,count_WA = 0, count_TLE = 0, count_RE = 0;
	cin >> m;
	string str[m+1];
	for(int i = 0; i < m; i++){
		cin >> str[i];
		if(str[i] == "AC")
			count_AC++;
		else if(str[i] == "WA")
			count_WA++;
		else if(str[i] == "TLE")
			count_TLE++;
		else if(str[i] == "RE")
			count_RE++;
	}
	cout << "AC x " << count_AC <<endl
		 << "WA x " << count_WA <<endl
		 << "TLE x " << count_TLE <<endl
		 << "RE x " << count_RE <<endl;
		   
}


Measured memory_bytes: 6752
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,m,a[200005],b[200005],c[200005],ans;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)scanf("%d",a+i),++b[a[i]];
    for(int i=1;i<=n;++i){
        int k=i-b[i]+1;
        if(k<1)k=1;
        ++c[k],--c[i+1];
    }
    for(int i=2;i<=n;++i)c[i]+=c[i-1];
    for(int i=1;i<=n;++i)if(!c[i])++ans;
    for(int i=1;i<=m;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        int k=a[x]-b[a[x]]+1;
        if(k>0){
            if(!--c[k])++ans;
        }
        --b[a[x]];
        ++b[a[x]=y];
        k=y-b[y]+1;
        if(k>0){
            if(!c[k]++)--ans;
        }
        printf("%d\n",ans);
    }
    //system("pause");
    return 0;
}


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

int Min = 1000000;
int Hantei(vector<int> _P, int _i){

  for (int i = 0; i < _i; i++){
    
    if (_P.at(i) < _P.at(_i)) return 0;
  }
  return 1;
}

int main(){
  
  int N, i, j, Num = 0;
  cin >> N;
  vector<int> P(N);
  for (i = 0; i < N; i++) cin >> P.at(i);
  
  for (i = 0; i < N; i++) {
    
    if (Min > P.at(i)){
      Min = min(Min, P.at(i));
      Num++;
    }
  }
  cout << Num << endl;
}

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

int main() {
	string s;
	cin >> s;
	ll ans = 0;
	for(int i=0; i<s.size(); i++) {
		ans += (ll)(s[i]-'0');
	}
	if(ans % 9 == 0) {
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
}

Measured memory_bytes: 3720
Public Class Main
    Public Shared Sub Main(ByVal args() As String)
        Dim N As Integer
        N = console.ReadLine()
        Dim A() As Integer
        A = Array.ConvertAll(Of String, Integer)(Split(Console.ReadLine()), AddressOf Integer.Parse)
        Dim flg As Boolean = True
        For Each Ai As Integer In A
            If (Ai Mod 2 = 0) AndAlso (Ai Mod 3 <> 0) AndAlso (Ai Mod 5 <> 0) Then
                flg = False
                Exit For
            End If
        Next
        console.WriteLine(If(flg, "APPROVED", "DENIED"))
    End Sub
End Class


Measured memory_bytes: 13536
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

S=input()

if len(S)%2==1:
    S = S[:-1]
    if S[:len(S)//2] == S[len(S)//2:]:
        print(len(S))
        sys.exit()

for i in range(len(S)//2):
    S = S[:-2]
    if S[:len(S)//2] == S[len(S)//2:]:
        print(len(S))
        sys.exit()    



Measured memory_bytes: 77464
n = int(input())
A = list(map(int, input().split()))

money = 1000
kabu = 0
memo = []

buy = True

for i in range(n-1):
    if buy:
        if A[i] < A[i+1]:
            kabu = money //A[i]
            money %= A[i]
            buy = False
    else:
        if A[i] > A[i+1]:
            money += kabu * A[i]
            kabu = 0
            buy = True

if kabu:
    money += kabu * A[n-1]

print(money)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<ll> T(N);
  ll sum=0;
  for(ll i=0;i<N;i++) {
cin>>T[i];
    sum+=T[i];
    
  }
  ll M;
  cin>>M;
  for(ll i=0;i<M;i++) {
ll P,X;
    cin>>P>>X;
    
    cout<<sum-(T[P-1]-X)<<endl;
  }
  
}
    

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

long long GCD(unsigned long long a,unsigned long long b){
	if(b==0)return a;
	unsigned long long alt=a%b;
	GCD(b,alt);
}

int main(){
	unsigned long long a,b;
	while(cin>>a){
		cin>>b;
		unsigned long long ansGCD=GCD(a,b);
		cout<<ansGCD<<" "<<a*b/ansGCD<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())


# 先にふるってprimesを作る
def hurui(N):
    koho = list(range(2,N))
    prime = []
    limit = math.sqrt(koho[-1])
    while True:
        p = koho[0]
        if limit <= p:
            prime = prime + koho
            break
        else:
            prime.append(p)
            koho = [e for e in koho if e%p != 0]

    return prime

# N を素因数分解
def factorization(N):
    ans = defaultdict(int)
    L = len(primes)
    pind = 0
    while N > 1:
        p = primes[pind]
        while N%p == 0:
            N //= p
            ans[p] += 1
        pind += 1
        if pind >= L:
            ans[N] += 1
            break
    return ans

N,P = inpl()

primes = hurui(int(math.sqrt(P))+3)
facs = factorization(P)

ans = 1
for p,n in facs.items():
    if n >= N:
        ans *= p**(n//N)

print(ans)


Measured memory_bytes: 134648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static double debt = 100000;

	public static void main(String[] args) throws IOException {

		int n;
		double hell = debt;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine());

		for (int i = 1; i <= n; i++) {
			hell += hell * 0.05;
			hell = Math.ceil(hell / 1000) * 1000;
		}

		System.out.println((int) hell);
	}
}

Measured memory_bytes: 16872
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
tot = 0
for i in range(1,N+1):
    tot += abs(A[i]-A[i-1])
tot += abs(A[0]-A[N])
for i in range(1,N):
    a = tot-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])
    print(a)
a = tot-abs(A[N]-A[N-1])-abs(0-A[N])+abs(0-A[N-1])
print(a)

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

using namespace std;

typedef long long ll;

void solve() {
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);
    ll cnt = x / d;
    if (cnt >= k) {
        cout << x - k * d; return;
    }
    x = x - cnt * d;
    k -= cnt;
    if (k & 1)
        x -= d;
    cout << abs(x);
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 3644
# coding: utf-8
# Your code here!

x, a, b = map(int, input().split())

# print(x)
# print(a)
# print(b)

# print(abs(x - a))
# print(abs(x - b))

if abs(x - a) <= abs(x - b):
    print('A')
else:
    print('B')

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int h,w;cin>>h>>w;
    char a[h][w];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>a[i][j];
    for(int i=0;i<h;i++){for(int j=0;j<w;j++)cout<<a[i][j];cout<<endl;for(int j=0;j<w;j++)cout<<a[i][j];cout<<endl;}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

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


Measured memory_bytes: 3592
a,b,c = map(int, input().split())
 
if a == 5:
  if b == 5:
    if c == 5:
      print('NO')
    else:
      print('YES')
  else:
    if c == 5:
      print('YES')
    else:
      print('NO')
else:
  if b == 5:
    if c == 5:
      print('YES')
    else:
      print('NO')
  else:
    print('NO')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int W, H;
  char c;
  cin >> W >> H >> c;
  for(int i=0; i<H; ++i) {
    for(int j=0; j<W; ++j) {
      if((i == 0 && j == 0) || (i == 0 && j == W-1) || (i == H-1 && j == 0) || (i == H-1 && j == W-1)) cout << "+";
      else if(i == 0 || i == H-1) cout << "-";
      else if(j == 0 || j == W-1) cout << "|";
      else if(i == H/2 && j == W/2) cout << c;
      else cout << ".";
    }
    cout << endl;
  }
}




Measured memory_bytes: 3104
package main

import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)
	for i := 0; i <= N; i++ {
		for j := 0; j <= N-i; j++ {
			x := (Y - 10000*i - 5000*j) / 1000
			if i+j+x == N {
				fmt.Printf("%d %d %d\n", i, j, x)
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")

}

Measured memory_bytes: 512
#include <stdio.h>
char m[100][160];
int n[100][52];
int main()
{
  int l=0,i,j,k,p;
  while((scanf("%s",m[l++]))!=EOF);
  l--;
  for(i=0;i<l;i++){
    j = 1;
    k = p = 0;
    while(m[i][p] != '\0'){
      switch(m[i][p]){
      case ',':
	n[i][j++] = k;
	k = 0;
	break;
      default:
	k = k * 10 + (m[i][p] - '0');
	break;
      }
      p++;
    }
    n[i][j] = k;
  }
  for(i=1;i<=l/2;i++){
    for(j=1;j<=i+1;j++){
      n[i][j] += (n[i-1][j-1] > n[i-1][j]) ? n[i-1][j-1] : n[i-1][j];
    }
  }
  for(;i<l;i++){
    for(j=1;j<=l-i;j++){
      n[i][j] += (n[i-1][j] > n[i-1][j+1]) ? n[i-1][j] : n[i-1][j+1];
    }
  }
  printf("%d\n",n[l-1][1]);
  return 0;
}

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

signed main(){
    int A,B,C;
    cin>>A>>B>>C;
    int ans=0;
    while(A%2==0&&B%2==0&&C%2==0){
        if(A==B&&B==C){
            ans=-1;
            break;
        }
        int cA=A;
        int cB=B;
        int cC=C;
        A=(cB+cC)/2;
        B=(cC+cA)/2;
        C=(cA+cB)/2;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
int main(){
  ll n;
  cin >> n;
  ll a[100];
  a[0]=2;
  a[1]=1;
  for(int i=2;i<100;i++){
    a[i]=a[i-1]+a[i-2];
  }
  cout << a[n];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
ll w[100000];
ll v[100000];
ll c[101][100001];
ll n,m;
ll backpack(int x,int y){
	if(x==0) return 0;
	if(c[x][y]) return c[x][y];
	if(w[x-1]<=y) c[x][y]=max(backpack(x-1,y-w[x-1])+v[x-1],backpack(x-1,y));
	else c[x][y]=backpack(x-1,y);
	return c[x][y];
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	cout<<backpack(n,m)<<endl;
}

Measured memory_bytes: 79488
#include<iostream>
#include<cstdlib>
#include<vector>
using namespace std;

class union_find{
    vector<int> set;
public:
    union_find(int size){ for(int i=0; i<size; i++)set.push_back(-1); }
    int find(int x);
    void unite(int x, int y);
    void printV();
    int getTreeSize(int x);
};

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

    union_find uf(n);

    int com, x, y;
    for(int i=0; i<q; i++){
        cin >> com >> x >> y;

        switch(com){
        case 0 :
            uf.unite(x, y);
            break; 
        case 1 :
            uf.find(x) == uf.find(y) ? cout << "1" : cout << "0";
            cout << endl;
            break;
        }
        // uf.printV();
    }

     return 0;
 }

 int union_find::find(int x)
 {
     if( !(x >= 0 && x < set.size()) ) exit(1);

     while( set.at(x) >= 0 ){
         x = set.at(x);
     }
     return x;
 }

 void union_find::unite(int x, int y)
 {
     int rootX, rootY;
     rootX = find(x);
     rootY = find(y);

     if( rootX == rootY ) return;

     if( set.at(rootX) < set.at(rootY) ){
         set.at(rootX) += set.at(rootY);
         set.at(rootY) = rootX;
     }else{
        set.at(rootY) += set.at(rootX);
        set.at(rootX) = rootY;
    }
 }

void union_find::printV()
{
    for(int i=0; i<set.size(); i++) cout << set.at(i) << " ";
    cout << endl;
}

Measured memory_bytes: 1316
//Compiler optimization
#pragma GCC optimize("Ofast")

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

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    ll n;cin >> n;
    S s = "";
    while(n){
        --n;
        s += (char)('a' + (n%26));
        n /=26;
    }
    reverse(s);
    cout << s << endl;
}

Measured memory_bytes: 3624
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const u32 n = scan<u32>();
  std::cout << (n - 1) / 2 << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


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

using namespace std;
typedef long long ll;

map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main() {
    ll n;
    cin >> n;

    int ret = 1; // self
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ll now = i;
            ll tmp = n;
            while (tmp % now == 0)tmp /= now;
            if (tmp % now == 1)ret++;

            if (n / i == i) continue;
            now = n / i;
            tmp = n;
            while (tmp % now == 0)tmp /= now;
            if (tmp % now == 1)ret++;
        }
    }

    n--;
    if (n > 1)ret++; // self
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ret++;
            if (n / i != i)ret++;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [int(x) for x in input().split()]
D = set() #Duplication
S = set() #all
for x in l:
    if x in S:
        D.add(x)
    else:
        S.add(x)

limit = 10**6+1
mp = [0]*(limit)

cnt = 0
S = sorted(S)
for x in S:
    for y in range(x,limit,x):
        mp[y] += 1
    if(x in D):
        continue
    if(mp[x]==1):
        cnt += 1
        
print(cnt)





Measured memory_bytes: 36652
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int binomialCoeff(int n, int k) 
{ 
	int res = 1; 
	if ( k > n - k ) 
		k = n - k; 
	for (int i = 0; i < k; ++i) 
	{ 
		res *= (n - i); 
		res /= (i + 1); 
	} 
	return res; 
} 
signed main()
{
    SPEED;
    int n;
    cin>>n;
    int a[n],ans[n];
    int freq[n+1]={0},sum=0,i;
    for(i=0;i<n;++i)
    {
        cin>>a[i];
        freq[a[i]]++;
    }
    for(i=1;i<=n;++i)
    {
        if(freq[i]>=2)
            sum+=binomialCoeff(freq[i],2);
    }
    int sum1=sum;
    for(i=0;i<n;++i)
    {
        if(freq[a[i]]>=2)
        {
            sum-=binomialCoeff(freq[a[i]],2);
            if(freq[a[i]]-1>=2)
                sum+=binomialCoeff(freq[a[i]]-1,2);
        }
        cout<<sum<<endl;
        sum=sum1;
    }
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<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 FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

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

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

ll N = 0;
ll t;
ll ret = 0;
ll A = 0, B = 0, C = 0;
string s;


void input() {
  IN(N);
}

void solve() {
  double l = ((double)N) * 3.141592 * 2.0f;
  cout << l << endl;
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<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 FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

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

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

ll N = 0;
ll t;
ll ret = 0;
ll A = 0, B = 0, C = 0;
string s;


void input() {
  IN(N);
}

void solve() {
  PRINT((N+1)/2);
}

int main(void){
  input();
  solve();
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const  long long  INF = 5e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll n, X, x[100010], ans;

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

int main() {
	cin >> n >> X;
	for (int i = 0;i < n;i++) {
		cin >> x[i];
	}
	x[n] = X;
	sort(x, x + n + 1);
	ans = x[1] - x[0];
	for (int i = 1;i < n;i++) {
		ans = gcd(ans, x[i + 1] - x[i]);
	}
	cout << ans << endl;
	return 0;
}



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

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


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  int A[n];
  int B[n];
  for(int i = 0;i < n;i++)
  {
    cin>>A[i]>>B[i];
  }
  for(int i = 0;i < n-2;i++)
  {
    if((A[i] == B[i])&&(A[i+1] == B[i+1])&&(A[i+2] == B[i+2]))
    {
      cout<<"Yes"<<"\n";
      return 0;
    }
  }
  cout<<"No"<<"\n";
  return 0;
}

Measured memory_bytes: 3616
n = gets.to_i
a = gets.split.map(&:to_i)

i = 0
count = 0

while (i < n) do
  j = i
  minj = i

  while (j < n) do
    # 未ソート部分から最小値を探す
    minj = j if a[minj] > a[j]
    j += 1
  end

  # 未ソートの先頭と最小値を交換する
  if minj != i
    a[i], a[minj] = a[minj], a[i]
    count += 1
  end

  i += 1
end

puts a.join(" ")
puts count



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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int t=1;
	//cin>>t;
	//SieveOfEratosthenes(1000000);
    while(t--){
        int n,k;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=k;i<n;i++){
            if(a[i]>a[i-k])
                cout<<"Yes\n";
            else cout<<"No\n";
        }
    }
}

Measured memory_bytes: 4416
#include <stdio.h>

int main(){
  int cmode[101] = {}, n, mode = 0, i;
  while(scanf("%d", &n) != EOF){
    cmode[n]++;
    if(mode < cmode[n]) mode = cmode[n];
  }

  for(i = 1;i < 101;i++)
    if(cmode[i] == mode)
      printf("%d\n", i);

  return 0;
}

Measured memory_bytes: 596
//32
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  int m[50],b[50][50];
  for(int i=0;i<k;i++){
    cin>>m[i];
    for(int j=0;j<m[i];j++){
      cin>>b[i][j];
    }
  }
  int r;
  cin>>r;
  bool d[51]={};
  while(r--){
    int p,q;
    cin>>p>>q;
    for(int i=0;i<k;i++){
      bool pb,qb;
      pb=qb=false;
      for(int j=0;j<m[i];j++){
	pb|=b[i][j]==p;
	qb|=b[i][j]==q;
      }
      if(pb&qb){
	d[p]=d[q]=true;
      }
    }
  }
  cout<<count(d,d+51,true)<<endl;
  return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
ll gcd(ll a, ll b){
        if(b == 0) return a;
        return gcd(b, a % b);
}

bool isprime(long long int val) {
 if (val <= 1)return false;
 for (long long int i = 2; i*i <= val; i++) {
   if (val%i == 0LL)return false;
 }
 return true;//ç´ æ•°
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(int argc, char const *argv[]) {
  ll a,b;
  cin >> a >> b;
  ll m=gcd(a,b);
  set<ll> S;
  for(auto p : prime_factor(m)) {
    while(p.second--){
      S.insert(p.fi);
    }
  }
  cout << S.size()+1 << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void) {
  int n,x;
  int c=0;
  int a[101]={0};
  cin>>n;
  for(int i; i<n; i++) {
    cin>>x;
    if(a[x]) c++;
    else a[x] = 1;
  }
  cout<<n-c<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

int main()
{
	int a, b, c, d;
	std::cin >> a >> b;
	c = a, d = b;
	if (a < b)
		std::swap(a, b);
	while (b != 0)
	{
		int r = a%b;
		a = b;
		b = r;
	}

	std::cout << a << "\n";

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
char mp[2005][2005];
int sum[2005][2005];
int main()
{
	int x,y,cnt,t,fir,max=0;
	scanf("%d%d",&x,&y);
	getchar();
	for(int i=0;i<x;i++)scanf("%s",mp[i]);
	for(int i=0;i<x;i++)
	{
		cnt=0;t=0;fir=0;
		while(1)
		{
			if(mp[i][t]=='.')
			{
				cnt++;
				t++;
			}
			else
			{
				for(int j=fir;j<=t-1;j++)sum[i][j]=cnt;
				cnt=0;
				while(mp[i][t]=='#')t++;
				if(t>=y)break;
				else fir=t;
			}
		}
	}
	for(int i=0;i<y;i++)
	{
		cnt=0;t=0;fir=0;
		while(1)
		{
			if(mp[t][i]=='.')
			{
				cnt++;
				t++;
			}
			else
			{
				for(int j=fir;j<=t-1;j++)sum[j][i]+=cnt-1;
				cnt=0;
				while(mp[t][i]=='#')t++;
				if(t>=x)break;
				else fir=t;
			}
		}
	}
	for(int i=0;i<x;i++)
	{
		for(int j=0;j<y;j++)if(sum[i][j]>max)max=sum[i][j];
	}
	printf("%d\n",max);
}

Measured memory_bytes: 19840
#include <iostream>

using namespace std;

const int MAX_N = 20000;

int main () {
  int n;
  int p[MAX_N];
  int a[MAX_N], b[MAX_N];
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> p[i];
    a[i] = (i + 1) * 40000;
    b[i] = (n - i) * 40000; 
  }
  for (int i=0;i<n;i++) {
    a[p[i]-1] -= (n - i);
  }
  for (int i=0;i<n-1;i++) {
    cout << a[i] << " ";
  } cout << a[n-1] << endl;
  for (int i=0;i<n-1;i++) {
    cout << b[i] << " ";
  } cout << b[n-1] << endl;

  // for (int i=0;i<n-1;i++) {
  //   cout << a[i] + b[i] << " ";
  // } cout << a[n-1] + b[n-1] << endl;


  return 0;
}

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

int main() {
  int n, l;
  cin >> n >> l;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    vec.at(i) = l + i;
  }
  int ans = 0;
  ans = accumulate(vec.begin(), vec.end(),0LL);
  if (vec.at(0) > 0) {
    ans -= l;
  }
  else {
    if (vec.at(n-1)>=0) {
    }
    else {
      ans -= vec.at(n-1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def fib(n,memo={}):
    if n == 0:
        return 1
    elif n == 1:
        return 1
    elif n in memo:
        return memo[n]
        
    else:
        memo[n]=fib(n-1,memo)+fib(n-2,memo)
        return memo[n]
a=int(input())
print(fib(a))


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char b;
    cin >> b;
    char ans[256];
    ans['A'] = 'T';
    ans['T'] = 'A';
    ans['C'] = 'G';
    ans['G'] = 'C';
    cout << ans[(int)b] << ln;
    return 0;
}


Measured memory_bytes: 256
N = int(input())

trains = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    trains.append((c, s, f))


for n in range(N-1):
    t = 0
    for c, s, f in trains[n:]:
        k = (t-1)//f + 1
        t = max(k*f, s) + c
    print(t)
print(0)




Measured memory_bytes: 3188
from collections import Counter


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
n_data = Counter(A)
ans = sum(A)
for _ in range(Q):
  b, c = map(int, input().split())
  ans += (c - b) * n_data[b]
  n_data[c] += n_data[b]
  n_data[b] = 0
  print(ans)

Measured memory_bytes: 24120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			int d = sc.nextInt();
			
			int s = d * 2 + 1;
			if (n % s == 0) {
				System.out.println(n / s);
			} else {
				System.out.println(n / s + 1);
			}

		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    ll A, B, K, ansA, ansB;
    cin >> A >> B >> K;
    
    if(A > K){
        ansA = A - K;
        ansB = B;
    } else if(A + B > K){
        ansA = 0;
        ansB = B - (K - A);
    } else {
        ansA = 0;
        ansB = 0;
    }
    cout << ansA << " " << ansB << endl;

    return 0;
}


Measured memory_bytes: 256
##!/usr/bin/env python3
import sys
# from operator import itemgetter
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_1.txt', 'r')
# sys.stdin = fin
# 提出時はコメントアウト+上のshebangを有効にする
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int

    # write code
    A = [L + i - 1 for i in range(1, N + 1)]
    subA = deepcopy(A)
    sum_A = sum(A)
    # print(A)
    A = list(map(abs, A))
    A.sort()
    if A[0] in subA:
        print(sum_A - A[0])
    else:
        print(sum_A + A[0])




Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int find(vector<int>& grp, int x) {
    if (grp[x] == x)
        return x;
    return grp[x] = find(grp, grp[x]);
}

bool is_bridge(vector<vector<int>>& e, int n, int rmv) {
    vector<int> grp(n, 0);
    for(int i = 0; i < n; i++)
        grp[i] = i;
    for(int i = 0; i < e.size(); i++) {
        if (i == rmv) continue;
        int r1 = find(grp, e[i][0]);
        int r2 = find(grp, e[i][1]);
        if (r1 != r2)
            grp[r1] = grp[r2] = min(r1, r2);
    }
    unordered_set<int> kind;
    for(int i = 0; i < n; i++)
        kind.insert(find(grp, i));
    return kind.size() > 1;
}

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<vector<int>> e;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        e.push_back({a-1, b-1});
    }
    int ans = 0;
    for(int i = 0; i < m; i++) {
        ans += is_bridge(e, n, i);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
def solve()
  [false, true].repeated_permutation(2) do |s|
    (1..N).each do |i|
      s << (S[i]==?o ? s[i]^s[i-1] : s[i]^!s[i-1])
    end
    return s[0...-2].map{|i| i ? ?W : ?S}.join if s[0]==s[-2] && s[1]==s[-1]
  end
  -1
end
N=gets.to_i
S=gets.chop*2
puts solve


Measured memory_bytes: 8668
import math
n = int(input())
a = list(map(int, input().split()))

ave = sum(a)/n
s_ave = math.ceil(ave)
l_ave = math.floor(ave)
s_cost = 0
l_cost = 0
for i in range(n):
  s_cost += (a[i]-s_ave)**2
  l_cost += (a[i]-l_ave)**2

print(min(s_cost, l_cost))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;

int main(){
ll x; cin>>x;
ll res =0;
res+=(x/11)*2;
if(x%11!=0&&x%11<=6)res++;
else if(x%11>6) res+=2;
cout<<res<<endl;
}


Measured memory_bytes: 256
#include <functional>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
using namespace std;
 
#define pii pair<int, int>
#define rank asdf
#define ll long long
 
const int mod = (int)1e9 + 7;

int n, m;
int a[88][88];
int b[88][88];
bool dp[88][88][30000];
int T = 13000;

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            cin >> a[i][j];
        }
    }
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            cin >> b[i][j];
        }
    }
    dp[1][1][T + a[1][1] - b[1][1]] = true;
    dp[1][1][T + -a[1][1] + b[1][1]] = true;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            int diff = a[i][j] - b[i][j];
            for(int sum = 0; sum <= 25600; ++sum){
                if(j != 1 && sum >= diff) {
                    dp[i][j][sum] |= dp[i][j - 1][sum - diff];
                }
                if(j != 1 && sum + diff <= 25600) {
                    dp[i][j][sum] |= dp[i][j - 1][sum + diff];
                }
                if(i != 1 && sum >= diff) {
                    dp[i][j][sum] |= dp[i - 1][j][sum - diff];
                }
                if(i != 1 && sum + diff <= 25600) {
                    dp[i][j][sum] |= dp[i - 1][j][sum + diff];
                }
            }
        }
    }
    int ans = (int)1e9;
    for(int i = 0; i <= 25600; ++i){
        if(dp[n][m][i]) ans = min(ans, abs(i - T));
    }
    cout << ans << "\n";
}


Measured memory_bytes: 207232
import sys

n_kukann = int(input())
kukann_nagasa = list(map(int, input().split()))
all_length=0
some=0
i=0
remaining=0
#print(n_kukann//2)
#N個の空のリストを作成
for i in range(n_kukann):
 all_length= all_length + kukann_nagasa[i]

abss = [all_length]*n_kukann
#print(n_kukann)
#print(all_length)
#if n_%2==0:
  # for i in range(n_kukann):
#        some=some +kukann_nagasa[i]
#        if some == all_length/2:
#           print(0)
#           sys.exit
#        else:
#            pass

#else:
for i in range(n_kukann):
    some=some +kukann_nagasa[i]
    remaining=all_length-some
    abss[i]=abs(some-remaining)
    if some == remaining:
      
       break
       sys.exit

    #elif some >= remaining:
       #print(some)
       #print(all_length-some)
       #print(min(some-all_length/2,-(all_length/2-some) ))
      # break
     #  sys.exit

    else:
        pass

#print(abss)
abss.sort()
print(abss[0])
#print(all_length)


Measured memory_bytes: 26220
n = int(input())
ls = [int(x) for x in input().split()]
ls[0] = sum(ls[0::2]) - sum(ls[1::2])
ls[n-1] = 2*ls[n-1] - ls[0]
for i in range(n-2, 0, -1):
    ls[i] = 2*ls[i] - ls[i+1]
print(*ls)

Measured memory_bytes: 14092