akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef vector <string> VS;

const int size = 1002;
const char J = 'J', O = 'O', I = 'I';
int TJ[size][size], TO[size][size], TI[size][size];
int SJ[size][size], SO[size][size], SI[size][size];
VS D;

void init_table() {
    for ( int i = 0; i < size; ++ i ) {
        for ( int j = 0; j < size; ++ j ) {
            TJ[i][j] = TO[i][j] = TI[i][j] = 0;
            SJ[i][j] = SO[i][j] = SI[i][j] = 0;
        }
    }
}

int main() {
    int m, n;
    while ( cin >> m >> n ) {
        // input
        int k;
        cin >> k;
        D = VS( m );
        for ( int i = 0; i < m; ++ i ) {
            cin >> D[i];
        }
        // pre
        init_table();
        for ( int i = 0; i < m; ++ i ) {
            for ( int j = 0; j < n; ++ j ) {
                char c = D[i][j];
                TJ[i][j] = j-1<0 ? 0 : TJ[i][j-1];
                TO[i][j] = j-1<0 ? 0 : TO[i][j-1];
                TI[i][j] = j-1<0 ? 0 : TI[i][j-1];
                if ( c == J ) {
                    TJ[i][j] ++;
                } else if ( c == O ) {
                    TO[i][j] ++;
                } else if ( c == I ) {
                    TI[i][j] ++;
                }
            }
        }
        for ( int i = 0; i < m; ++ i ) {
            for ( int j = 0; j < n; ++ j ) {
                SJ[i][j] = ( i-1<0 ? 0 : SJ[i-1][j] ) + TJ[i][j];
                SO[i][j] = ( i-1<0 ? 0 : SO[i-1][j] ) + TO[i][j];
                SI[i][j] = ( i-1<0 ? 0 : SI[i-1][j] ) + TI[i][j];
            }
        }
        for ( int i = 0; i < m; ++ i ) {
            for ( int j = 0; j < n; ++ j ) {
                // debug
                //  cout << i << ", " << j << ": " << TJ[i][j] << ", " << TO[i][j] << ", " << TI[i][j] << " | ";
                //                 cout << SJ[i][j] << ", " << SO[i][j] << ", " << SI[i][j] << endl;
            }
        }
        
        // calc
        for ( int i = 0; i < k; ++ i ) {
            int s, t, p, q;
            cin >> s >> t >> p >> q;
            s --;
            t --;
            p --;
            q --;
            int NJ = SJ[p][q];
            int NO = SO[p][q];
            int NI = SI[p][q];
            if ( s - 1 >= 0 ) {
                NJ -= SJ[s-1][q];
                NO -= SO[s-1][q];
                NI -= SI[s-1][q];
            }
            if ( t - 1 >= 0 ) {
                NJ -= SJ[p][t-1];
                NO -= SO[p][t-1];
                NI -= SI[p][t-1];
            }
            if ( s - 1 >= 0 && t - 1 >= 0 ) {
                NJ += SJ[s-1][t-1];
                NO += SO[s-1][t-1];
                NI += SI[s-1][t-1];
            }
            cout << NJ << " " << NO << " " << NI << endl;
        }
    }
    return 0;
}

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(int64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

signed main() {
  uint64_t  a, b;
  cin >> a >> b;
  
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 3632
a,b,c,d = input()
for i in range(2**3):
    ls = ["+","+","+"]
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break

Measured memory_bytes: 9036
import Control.Monad
import Data.Array
import Data.Array.IO
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as BS

main = do
  (h:w:d:_) <- getLine >>= return . map read . words :: IO [Int]
  a <- replicateM h BS.getLine >>= return . concat . map (map (fst . fromJust . BS.readInt) . BS.words) :: IO [Int]
  let a' = array (1,h*w) (zip [1..] a)
  
  q <- readLn :: IO Int
  qs <- BS.getContents >>= return . map ((\(l:r:_) -> (l,r)) . map (fst . fromJust . BS.readInt) . BS.words) . BS.lines :: IO [(Int, Int)]

  arr <- newArray (1,h*w) (-1,-1) :: IO (IOArray Int (Int,Int))
  dists <- newArray (1,h*w) (-1) :: IO (IOArray Int Int)

  forM_ [1..h] $ \y -> do
    forM_ [1..w] $ \x -> do
      writeArray arr (a'!(x+(y-1)*w)) (x,y)

  forM_ [1..h*w] $ \i -> do
    p1 <- readArray arr i
    p2 <- readArray arr (if i+d<=h*w then (i+d) else i)
    writeArray dists i (dist p1 p2)

  dists' <- newArray (1,h*w) 0 :: IO (IOArray Int Int)
  forM_ [d+1..h*w] $ \i -> do
    d1 <- readArray dists (i-d)
    d2 <- readArray dists' (i-d)
    writeArray dists' i (d1+d2)

  forM_ qs $ \(l,r) -> do
    l' <- readArray dists' l
    r' <- readArray dists' r
    print $ r' - l'

  where
    dist (x1,y1) (x2,y2) = abs (x2-x1) + abs (y2-y1)


Measured memory_bytes: 23292
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		Combination cmb = new Combination(2 * n + 1);
		for (int i = 1; i <= k; i++) {
		    long ans = cmb.getComb(k - 1, i - 1) * cmb.getComb(n - k + 1, i);
		    ans %= MOD;
		    sb.append(ans).append("\n");
		}
		System.out.print(sb);
   }

}

class Combination {
    static final int MOD = 1000000007;
    long[] fac;
    long[] finv;
    long[] inv;
    
    public Combination (int size) {
        fac = new long [size];
        finv = new long [size];
        inv = new long [size];
        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < size; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    
    
    public long getComb(int n, int k) {
        if (n < k || n < 0 || k < 0) {
            return 0;
        }
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    
    public long getHcomb(int n, int k) {
        return getComb(n + k - 1, k);
    }
}



Measured memory_bytes: 23252
def main():
    n = int(input())
    As = list(map(int, input().split()))

    ans = 0
    for i in range(n):
        temp = As[i]
        if temp % 2 == 0:
            cnt = 0
            while temp % 2 == 0:
                cnt += 1
                temp //= 2
            ans += cnt

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10160
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0) {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll S,W;
    cin >> S >> W;
    if(W >= S){
        print("unsafe");
    }else{
        print("safe");
    }
    

}

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

class City {
public:
	int no;
	int no1;
	int no2;
	int ans;
	City(int i, int a, int b) {
		no = i, no1 = a, no2 = b;
	}
};

int main() {
	int a;
	string s;
	cin >>  a >> s;
	if (a >= 3200) {
		cout << s << endl;
		
	}
	else {
		cout << "red" << endl;
	}
}



Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::*;
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: i64,
        d: i64,
        xy: [(i64, i64); n],
    }

    let mut ans = 0;
    for (x, y) in xy {
        if x.pow(2) + y.pow(2) <= d.pow(2) {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 7820
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 10000
#define WHITE 0
#define GRAY 1
#define BLACK 2

typedef pair<int, int> pii;

struct edge { int to, c; };
vector<edge> G[MAX];
int color[MAX] = {};//WHITE

int n;

void dijkstra() {
	priority_queue<pii, vector<pii>, greater<pii> >PQ; //minc v
	int color[MAX] = {};
	int	minc[MAX];
	fill(minc, minc + MAX, INF);
	minc[0] = 0;

	//?§????????????\
	PQ.push(pii(0, 0));
	color[0] = GRAY;

	//PQ???????´????????????°
	while (!PQ.empty()) {
		//minc???????°??????¨??????????´????????????????
		pii p = PQ.top(); PQ.pop();

		int u = p.second;
		color[u] = BLACK;

		//????????§???????????°??????
		if (minc[u] < p.first) { continue; }

		//??£??\????????????????????¨????????????
		for (int j = 0; j < G[u].size(); j++) {
			edge e = G[u][j];
			if (color[e.to] == BLACK)continue;
			if (minc[e.to] > minc[u] + e.c) {
				minc[e.to] = minc[u] + e.c;
				PQ.push(pii(minc[e.to], e.to));
				color[e.to] = GRAY;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i << " " << (minc[i] == INF ? -1 : minc[i]) << endl;
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int u, k; scanf("%d%d", &u, &k);
		for (int j = 0; j < k; j++) {
			int v, c; scanf("%d%d", &v, &c);
			edge e; e.to = v; e.c = c;
			G[u].push_back(e);
		}
	}
	dijkstra();
	return 0;
}

Measured memory_bytes: 6440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int p[14][14]={0},x,y,s,i,j,n=0,max=0;
	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		x=x+2;y=y+2;
		p[x][y]++;
		p[x-1][y]++;
		p[x+1][y]++;
		p[x][y-1]++;
		p[x][y+1]++;
		if(s>1){
			p[x-1][y-1]++;
			p[x-1][y+1]++;
			p[x+1][y-1]++;
			p[x+1][y+1]++;		
		}
		if(s>2){
			p[x-2][y]++;
			p[x+2][y]++;
			p[x][y-2]++;
			p[x][y+2]++;
		}
	}
	for(i=2;i<12;i++){
		for(j=2;j<12;j++){
			if(p[i][j]>max)max=p[i][j];
			if(!p[i][j])n++;
		}
	}
	printf("%d\n%d\n",n,max);
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
struct node{
    int x,v;
    node(int a=0,int b=0){x=a;v=b;}
}p[100010];
int h[100010],nex[200010],to[200010],a[100010],b[100010],fa[100010],M;
ll s[100010],f[100010];
bool v[100010];
void add(int a,int b){
    M++;
    to[M]=b;
    nex[M]=h[a];
    h[a]=M;
}
bool operator<(node a,node b){return a.v<b.v;}
int get(int x){return x==fa[x]?x:(fa[x]=get(fa[x]));}
int main(){
    int n,m,i,j,x,y;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++){
        scanf("%d%d",a+i,b+i);
        a[i]=max(a[i]-b[i],0);
        p[i]=node(i,a[i]);
    }
    while(m--){
        scanf("%d%d",&x,&y);
        add(x,y);
        add(y,x);
    }
    sort(p+1,p+n+1);
    for(i=1;i<=n;i++){
        fa[i]=i;
        s[i]=b[i];
        f[i]=a[i];
    }
    for(i=1;i<=n;i++){
        v[p[i].x]=1;
        for(j=h[p[i].x];j;j=nex[j]){
            if(v[to[j]]){
                x=get(p[i].x);
                y=get(to[j]);
                if(x==y)continue;
                fa[y]=x;
                s[x]+=s[y];
                f[x]=min(f[x],max(f[y],a[x]-s[y]));
            }
        }
    }
    x=get(1);
    printf("%lld",f[x]+s[x]);
}

Measured memory_bytes: 5760
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int ans=0,n,m,q,a[55],b[55],c[55],d[55];
void dfs(vector<int> x){
  int i;
  if(x.size()==n){
    int sum=0;
    for(i=0;i<q;i++){
      if(x[b[i]]-x[a[i]]==c[i]){
        sum+=d[i];
      }
    }
    ans=max(ans,sum);
    return;
  }
  int b;
  if(x.size()==0){
    b=1;
  }
  else{
    b=x[x.size()-1];
  }
  for(i=b;i<=m;i++){
    x.push_back(i);
    dfs(x);
    x.pop_back();
  }
}
int main(){
  vector<int> x;
  int i;
  cin >> n >> m >> q;
  for(i=0;i<q;i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--,b[i]--;
  }
  dfs(x);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    
    // 1. 入力情報.
    char c[33];
    scanf("%s", c);
    
    // 2. 出力.
    rep(i, 19) printf("%c", (c[i] == ',') ? ' ' : c[i]);
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  REP(i,n){
    cin>>a[i];
  }
  
  if((n-1)%(k-1)==0){
    cout<<(n-1)/(k-1)<<endl;
  }else{
    cout<<(n-1)/(k-1)+1<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static double dist(int[] arr1, int[] arr2) {
    	double res = (arr1[0] - arr2[0])*(arr1[0] - arr2[0])
    			+ (arr1[1] - arr2[1])*(arr1[1] - arr2[1]);
    	return Math.sqrt(res);
    }
    
	public static void main(String[] args) {
		Scanner	in = new Scanner(System.in);
		int N = in.nextInt();
		// String S = in.next();
		int dist[][] = new int[N][2];
		for (int i = 0; i < N; i++) {
			dist[i][0] = in.nextInt();
			dist[i][1] = in.nextInt();
		}
		double ans = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				ans += dist(dist[i], dist[j]);
			}
			
		}
		System.out.println(String.format("%.07f", ans/N));
		
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b)

#define lint long long
#define pb push_back
#define F first 
#define S second 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef vector < int > vi ;
typedef pair < int, int > pii ;

// template <typename T>
inline int modpow(lint base, int exp, int modulo) {
  base %= modulo;
  lint result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulo;
    base = (base * base) % modulo;
    exp >>= 1;
  }
  return result;
}

const int N = 1e6 + 2 ;
const int MOD = 1e9 + 7 ;
const lint INF = 1e18 ;

int main()
{
    fastio;
    string s ; cin >> s ;
    int mx = 0, cnt = 0 ;
    for(char x : s) {
    	if(x == 'R') {
    		cnt++;
    		reMax(mx, cnt); 
    	}
    	else cnt = 0 ;
    }
    cout << mx ; 
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


string numToChar(int num){
    if(num == 0) return "A";
    else if(num == 1) return "B";
    else return "C";
}

int main()
{
    int N;
    vector<int> num(3);
    cin >> N >> num[0] >> num[1] >> num[2];
    vector<string> s(N);
    REP(i, N) cin >> s[i];

    vector<char> ans;
    long long S = accumulate(num.begin(), num.end(), (long long) 0);
    if(S == 0){
        cout << "No" << endl;
        return 0;
    }
    REP(i, N){
        // 選ばれているものを数字に変換
        int c1 = s[i][0] - 'A';
        int c2 = s[i][1] - 'A';
        int c3 = 3-c1-c2;
        if(num[c1]+num[c2] == 0){
            cout << "No" << endl;
            return 0;
        }
        if(S == 1){
            // 0の方に足す
            int small = (num[c1] > num[c2])? c2: c1;
            int large = (num[c1] > num[c2])? c1: c2;
            ans.push_back(char(small+'A'));
            ++num[small];
            --num[large];
        }else{
            bool flag = true;
            for(auto c: s[i]){
                int idx = c-'A';
                if(num[idx] == 0){
                    ans.push_back(c);
                    ++num[idx];
                    --num[(idx == c1)? c2: c1];
                    flag = false;
                    break;
                }
                if(i+1 < N and num[idx] == 1 and num[c3] == 0 and (s[i+1] == numToChar(idx)+numToChar(c3) or s[i+1] == numToChar(c3)+numToChar(idx))){
                    ans.push_back(c);
                    ++num[idx];
                    --num[(idx == c1)? c2: c1];
                    flag = false;
                    break;
                }
            }
            if(flag){
                ans.push_back(s[i][0]);
                ++num[c1];
                --num[c2];
            }
        }
    }
    cout << "Yes" << endl;
    for(auto c: ans) cout << c << endl;

    return 0;
}

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

int main()
{
    int R;
    scanf("%d", &R);
    if(R<1200)
    {
        printf("ABC");
    }
    else if (R<2800)
    {
        printf("ARC");
    }
    else 
    {
        printf("AGC");
    }
    return 0;
}



Measured memory_bytes: 256
N = int(input())
count = [1 for _ in range(N+2)]
count[-1] = 0
count[0] = 0
nextpoint = [[] for _ in range(N+1)]
for _ in range(N-1):
  u, v = map(int, input().split())
  if u > v:
    nextpoint[v].append(u)
  else:
    nextpoint[u].append(v)

#print(nextpoint)
for k in range(N+1):
  if len(nextpoint[k]) > 0:
    nextpoint[k].sort()

#print(nextpoint)
for k in range(1, N):
  for item in nextpoint[k]:
    count[item] -= 1

#print(count)
ans = 0
for k in range(1, N):
  count[k+1] += count[k]
#print(count)
ans = sum(count) #L=1
#print(ans)
before = ans
for k in range(1, N):#L=2~N
  before -= N-k+1
  for item in nextpoint[k]:
    before += N+1-item
  ans += before
print(ans)

  

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

int main(){
  int n, t, a, x;
  cin >> n >> t >> a;
  int ans = 0;
  int cc = 1 << 30;
  for(int i = 1; i <= n; i++){
    cin >> x;
    int d = (t * 1000 - x * 6) - a * 1000;
    if(d < 0) d = -d;
    if(cc > d) cc = d, ans = i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(i,s,n) for(ll i=s;i<=n;i++)
#define ford(j,s,n) for(int i=n;i>=s;i--)
#define pb push_back
#define TEST int t; cin>>t; for(int T=1;T<=t;T++)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k=0,n;
    int f=1;
    cin>>n;
    for(int i=0;i<=1000000;i++){
        k=((k*10)+7)%n;
        //cout<<k<<" ";
        if(k==0){
            cout<<i+1;
            f=0;
            break;
        }
    }
    if(f)
        cout<<"-1";
    return 0;
}


Measured memory_bytes: 3604
/*
PROG: agc025c
LANG: C++11
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
 */
#include <bits/stdc++.h>

using namespace std;

template<class T>
void readi(T &x)
{
	T input = 0;
	bool negative = false;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = input * 10 + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	x = input;
}
template<class T>
void printi(T output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
template<class T>
void ckmin(T &a, T b)
{
	a = min(a, b);
}
template<class T>
void ckmax(T &a, T b)
{
	a = max(a, b);
}
long long randomize(long long mod)
{
	return ((1ll << 30) * rand() + (1ll << 15) * rand() + rand()) % mod;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define fi first
#define se second
#define debug(x) cerr << #x << " = " << x << endl;

const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-10;

#define MAGIC 347
#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
#define MAXN 200039

long long normalize(long long x, long long mod = INF)
{
	return (((x % mod) + mod) % mod);
}

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N;
ll DIF = 100013;
pll coor[MAXN];
ll ans;
ll rtpref[MAXN], ltpref[MAXN];

int32_t main()
{
	ios_base::sync_with_stdio(0); 
	srand(time(0));
	//	cout << fixed << setprecision(10);	
	//	cerr << fixed << setprecision(10);
	if (fopen("agc025c.in", "r"))
	{	
		freopen ("agc025c.in", "r", stdin);
	//	freopen ("agc025c.out", "w", stdout);
	}
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> coor[i].fi >> coor[i].se;
		coor[i].fi += DIF; coor[i].se += DIF;
	}
	coor[N] = MP(DIF, DIF);
	N++;
	for (int i = 0; i < N; i++)
	{
		ltpref[coor[i].se]++;
		rtpref[coor[i].fi]++;
	}
	for (int i = 1; i < MAXN; i++)
	{
		ltpref[i] += ltpref[i - 1];
		rtpref[i] += rtpref[i - 1];
	}
	for (int i = 0; i < MAXN - 2; i++)
	{
		//i..i+1
		int lt = ltpref[i], rt = rtpref[MAXN - 1] - rtpref[i];
//		for (int j = 0; j < N; j++)
//		{
//			if (coor[j].se <= i)
//			{
//				lt++;
//			}
//			if (coor[j].fi > i)
//			{
//				rt++;
//			}
//		}
		ans += min(lt, rt);
	}
	cout << 2 * ans << '\n';
	//	cerr << "time elapsed = " << (clock() / (CLOCKS_PER_SEC / 1000)) << " ms" << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, ans=0;

	cin >> N;
	vector<int> a(N), b(N);
	rep(i,N) cin >> a[i];
	rep(i,N) cin >> b[i];
	b.push_back(0);

	rep(k,29){
		vector<int> _b = b;
		rep(i,N) _b[i] %= (1<<(k+1));
		sort(all(_b));

		int sum = 0;
		rep(i,N){
			int l1 = 0, r1 = N+1, l2 = 0, r2 = N+1;
			while(r1-l1>1 || r2-l2>1){
				int m1 = (l1+r1) / 2;
				int m2 = (l2+r2) / 2;
				if( _b[m1] > (1<<k) ){
					r1 = m1;
				}else if( ((_b[m1] + a[i]) & (1<<k)) == (a[i] & (1<<k)) ){
					l1 = m1;
				}else{
					r1 = m1;
				}
				if( _b[m2] <= (1<<k) ){
					l2 = m2;
				}else if( ((_b[m2] + a[i]) & (1<<k)) == (a[i] & (1<<k)) ){
					r2 = m2;
				}else{
					l2 = m2;
				}
			}
			int cnt;
			if( a[i] & (1<<k) ){
				cnt = l1 + N+1-r2;
			}else{
				cnt = r2 - r1;
			}
			sum += cnt % 2;
		}
		ans |= (sum%2)<<k;
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,M;
    string S;
    cin >> N>>M;
    ll P[M],Y[M],P_tmp[M],Y_tmp[M];
    REP(i, M)
        cin >> P[i] >> Y[i];


    REP(i,M){
        P_tmp[i] = P[i];
        Y_tmp[i] = Y[i];
    }

        vector<tuple<ll,ll, ll>> t(M);
    REP(i,M)t.at(i) = make_tuple(P[i], Y[i],i);

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

    vector<ll> num(M);
    ll count = 1;
    REP(i, M-1)
    {
        if (get<0>(t.at(i)) == get<0> (t.at(i + 1)))
        {
            num.at(i) = count;
            count++;
        }
        else{
            num.at(i) = count;
            count = 1;
        }
    }
    num.at(M-1) = count;

    vector<tuple<ll, ll, ll, ll>> t1(M);
    REP(i,M){
        t1.at(i) = make_tuple(get<2>(t.at(i)), get<0>(t.at(i)), get<1>(t.at(i)), num.at(i));
    }

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

    REP(i,M){
        printf("%06d", get<1>(t1.at(i)));
        printf("%06d\n", get<3>( t1.at(i)));
        
    }
}


Measured memory_bytes: 10880
// Author -- Frame

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<iostream>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x7fffffffffffffff;
const double eps=1e-10;

template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline bool _cmp(const _Tp &a,const _Tp &b){return abs(a-b)<=eps;}
template <typename _Tp>Finline void read(_Tp &x)
{
	register char ch(getchar());
	bool f(false);
	while(ch<48||ch>57) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();
	while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args)
{
	read(t);read(args...);
}
Finline int read_str(char *s)
{
	register char ch(getchar());
	while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	register char *tar=s;
	*tar=ch,ch=getchar();
	while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=300005;
std::vector<int> v,v1,v2;
template<typename _Tp>
class BIT{
public:
	_Tp c[N];
	Finline void add(int x,_Tp C){++x;for(;x;x-=lowbit(x))c[x]+=C;}
	Finline _Tp sum(int x){++x;_Tp ans=0;for(;x<N;x+=lowbit(x))ans+=c[x];return ans;}
};
BIT<int> tr;
ll calc(std::vector<int> v)
{
	memset(tr.c,0,sizeof(tr.c));
	ll ans=0;
	for(auto it:v)
	{
		ans+=tr.sum(it);
		tr.add(it,1);
	}
	return ans;
}
int main()
{
	int n;
	read(n);
	v.resize(n);
	for(int i=0;i<n;++i)
	{
		read(v[i]);
		if(i&1) v1.push_back(v[i]);
		else v2.push_back(v[i]);
		if((v[i]&1)==(i&1))
		{
			printf("No\n");
			return 0;
		}
	}
	if((calc(v1)+calc(v2))*3==calc(v))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 6380
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    int n;string res = "Yes";
    cin >> n;
    string s[n];
    rep(i,n) cin >> s[i];
    rep(i,n-1){
        string pre = s[i], sub = s[i+1];
        int end = pre.length() - 1;
        if(pre[end] != sub[0]){
            res = "No";
            break;
        }
    }

    sort(s,s+n);

    rep(i,n-1)if(s[i] == s[i+1]){
        res = "No";
        break;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define READ(i, j) FOR(i, 0, j, 1)
#define RREAD(i, j) RFOR(i, j, 0, 1)



void solve() 
{
    string s;
    cin>>s;
    if(s[s.size()-1] == 's')
        s.append("es");
    else
    {
        s.append("s");
    }
    cout<<s;
    
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int tc=1; 
    //cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    bool flag = true;
    for (int i = 0; i < S.size(); i++)
    {
        if (i == A)
        {
            if (S[i] != '-')
            {
                flag = false;
                break;
            }
        }
        else
        {
            if (!(('0' <= S[i]) && (S[i] <= '9')))
            {
                flag = false;
                break;
            }
        }
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

int main() {
  int n, k;
  while (cin >> n >> k) {
    cout << n - k + 1 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define lp(i,n) for(int i=0;i<(n);i++)
#define lps(i,j,n) for(int i=j;i<n;i++)

#define fordebug int hoge;cin>>hoge;

#define DEKAI 1000000007
#define floot10 cout<<fixed<<setprecision(15)
#define all(v) v.begin(),v.end()
double PI = acos(-1);

signed main(){
  int n;
  cin>>n;
  int placex=0,placey=0;
  int time=0;//初期地点と、時間
  string ans="Yes";
  
  lp(i,n){
    int t,x,y;
    cin>>t>>x>>y;
    
    //まず、時間内に到達できる？
    int need_time=abs(placex-x)+abs(placey-y);//最短の所要時間
    if(time+need_time>t){
      ans="No";
      //到達できないならNO
    }

    int remain_time=(t-time-need_time);//余った時間。
    //余った時間が2の倍数でないなら、時間潰し失敗
    if(remain_time%2!=0){
      ans="No";
    }

    time=t;
    placex=x;
    placey=y;
    //次の計算のために、初期地点と時間を更新
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,p,A,B,cnt_a=0 ,cnt_b=0 ,cnt_c=0;
	cin>>N>>A>>B;
	rep(i,N){
		cin>>p;
		if(p <= A){
			++cnt_a;
		}else if(p <= B){
			++cnt_b;
		}else{
			++cnt_c;
		}
	}
	cout<<min({cnt_a, cnt_b, cnt_c})<<endl;
	return 0;
}


Measured memory_bytes: 3556
from itertools import combinations

def main():
  l, r = map(int, input().split())

  if r - l >= 2019:
    print(0)
    return

  l = l % 2019
  r = r % 2019
  if r <= l:
    r += 2019

  print(min([(i * j) % 2019 for i, j in combinations(range(l, r+1), 2)]))

if __name__ == '__main__':
  main()

Measured memory_bytes: 112684
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

void no(void) {
	puts("WA");
	exit(0);
}

int main(void) {
	char S[16];
	size_t len;
	size_t i;
	size_t cidx = 0;
	if (scanf("%15s", S) != 1) return 1;
	len = strlen(S);
	if (len < 4) return 2;
	if (S[0] != 'A') no();
	for (i = 2; i < len - 1; i++) {
		if (S[i] == 'C') {
			if (cidx == 0) cidx = i; else no();
		}
	}
	if (cidx == 0) no();
	for (i = 1; i < len; i++) {
		if (i != cidx && !islower((unsigned char)S[i])) no();
	}
	puts("AC");
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

Graph graph;
vector<ll> color;
map<P, ll> info;

void dfs(ll u, ll prev, ll c) {
    if (prev != -1) {
        P edge = make_pair(u, prev);
        ll idx = info[edge];
        color[idx] = c;
    }
    ll s = 1;
    for (ll v : graph[u]) {
        if (v == prev) continue;
        if (s == c) s++;
        dfs(v, u, s);
        s++;
    }
}

void solve() {
    ll N;
    cin >> N;
    color.resize(N - 1);
    graph.resize(N);
    rep(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
        info[make_pair(a, b)] = i;
        info[make_pair(b, a)] = i;
    }
    dfs(0, -1, -1);
    ll m = *max_element(color.begin(), color.end());
    cout << m << '\n';
    rep(i, N - 1) {
        cout << color[i] << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
const int  Inv2 = (MOD+1)/2;
stack<int> que;
     signed main(){
string s[3];
cin>>s[0]>>s[1]>>s[2];
reverse(s[0].begin(),s[0].end());
reverse(s[1].begin(),s[1].end());
reverse(s[2].begin(),s[2].end());
int i=0,j;
while(!s[i].empty()){
   j=s[i][s[i].size()-1]-'a';
   s[i].pop_back();
   i=j;
}
cout<<char('A'+i)<<endl;
      }

        


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

int n;
string s;

int main()
{
	cin>>n>>s;
	int len=s.length();
	for(int i=0;i<len;i++)
	{
		char c=s[i]+n;if(c>'Z') c=c-'Z'+'A'-1;
		cout<<c;
	}
}

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

using namespace std;

int main() {
  int N;
  int o = 0, e = 0, f = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 2 == 1) {
      o++;
    } else if (a % 4 == 2) {
      e++;
    } else {
      f++;
    }
  }

  char p = 'F';
  for (int i = 0; i < N; i++) {
    if (p == 'F') {
      if (o) {
        o--;
        p = 'O';
      } else if (e) {
        e--;
        p = 'E';
      } else {
        f--;
      }
    } else if (p == 'E') {
      if (e) {
        e--;
        p = 'E';
      } else if (f) {
        p = 'F';
      } else {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (f) {
        f--;
        p = 'F';
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <math.h>
#include <cmath>
using namespace std;
#define ll long long

int main()
{
	ll a, b, c, x, y;
	ll ans = 0;
	cin >> a >> b >> c >> x >> y;

	if (a + b <= 2 * c) {
		cout << a * x + b * y << endl;
		return 0;
	}
	
	if (x == y) {
		cout << c * x * 2 << endl;
		return 0;
	}
	
	if (x > y) {
		ans += c * y * 2;
		x -= y;
		if (a <= c * 2) {
			ans += a * x;
		}
		else {
			ans += c * x * 2;
		}
	}
	else {
		ans += c * x * 2;
		y -= x;
		if (b <= c * 2) {
			ans += b * y;
		}
		else {
			ans += c * y * 2;
		}
	}

	cout << ans << endl;
	return 0;
	
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	string S;
	cin>>S;
    ll K;
    cin>>K;
    ll ans = 0;
    ll s_ind = 0,f_ind = S.length();
    if(S.front()==S.back()){
        ll nf=0,nb=0;      
        while(S[nf]==S.front()){
            nf++;
            if(nf==S.length()){
                break;
            }
        }
        if(nf==S.length()){
            cout<<(S.length()*K)/2<<"\n";
            return 0;
        }else{
            while(S[S.length()-1-nb]==S.back()){
                nb++;
            }
        }
        ans += ((nf+nb)/2)*(K-1);        
        ans += nf/2 + nb/2;

        s_ind += nf;
        f_ind -= nb;
    }
    char c_old = S[s_ind];
    ll n = 1;
    rep(i,f_ind - s_ind-1){
        if(S[s_ind+i+1]==c_old){
            n++;
        }else{
            ans += n/2*K;
            n = 1;
            c_old = S[s_ind+i+1];
        }
    }
    ans += n/2*K;

    cout<<ans<<"\n";

	return 0;
}

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();
		int l = sc.nextInt();
		int sum = 0;
		boolean zr=false;
		for(int i=1;i<=n;i++) {
			int azi=l+i-1;
			if(azi==0) {
				zr=true;
			}
			sum +=azi;
		}
		if(zr) {
			System.out.println(sum);
		}else if(l>=1) {
			System.out.println(sum-(l));
		}else {
			System.out.println(sum-(l+n-1));
		}
	}
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t
#include <math.h>

#define BUF_SIZE 15

//sqrt(100000000)
#define NUM_MAX 31623

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int main(void) {
    int n = get_int();
    int n1 = n;
    // less than NUM_MAX
    int max = ((int)sqrt(n)+1);
    char prime[NUM_MAX+1]; // flag
    memset(prime, 0x01, max);
    int ans[31]; // 2**31 = 2-billion > N
    int pidx = 0;
    int i, j;
    // get primes in advance @ Sieve of Eratosthenes
    for(i = 2; i <= max; i++) {
        if(!prime[i]) continue;
        // ensure that i is prime.
        int ulimit = max/i;
        // sieve
        for(j = 2; j <= ulimit; j++) {
            prime[i*j] = 0;
        }
    }
#ifdef DEBUG
    for(i = 2; i <= 10; i++) { printf("%d:%d ", i, prime[i]); }
    putchar('\n');
#endif
    int prev = 2;
    while(n>1) {
        int flag = 0;
        for(i = prev; i <= max; i++) {
            if(!prime[i]) continue;
            if(n%i) continue;
            // ensure that i is prime number
            ans[pidx++] = i;
            n = n / i;
            prev = i;
            flag = 1;
            break;
        }
        // num is unique prime number
        if(!flag) {
            ans[pidx++] = n; break;
        }
    }
    printf("%d: ", n1);
    for(i = 0; i < pidx; i++) {
        printf("%d%c", ans[i], (i==pidx-1) ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
//998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

int main(){
   ll n,k ;
   cin>>n>>k ;
  mint ans= 0;
  vector<mint> B(k+1) ;

  for(ll i=k;i>=1;i--){
   ll a= k/i ;
      mint sum = modpow(a,n) ;
    for(ll p=i*2;p<=k;p+=i){
      sum-=B[p] ;
    }
    B[i]=sum ;

    ans+=sum*i ;
   }
   cout<< ans<<endl ;
   
       return 0;
  }
   

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int mod = 1e9+7;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ull llrand() {ull r = 0;for(int i = 0; i < 5; ++i){r = (r << 15)|(rand() & 0x7FFF);}return r & 0xFFFFFFFFFFFFFFFFULL;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/*---------------------------------------------------------------------------------------------------------------------*/

const int M = 100001;

void write(int x){
    if(x == 0){
        cout<<"WA";
        exit(0);
    }
    else{
        cout<<"AC";
        exit(0);
    }

}
int main(){
    string str;
    cin >> str;
    set<int> se;

    int l = 0;
    for(int i = 0 ; i < str.size() ; i++){
        if(str[i] == 'C'){
            se.insert(i);
        }
        if(str[i] >= 'a' && str[i] <= 'z'){
            l++;
        }
    }

    if(str[0] != 'A'){
        write(0);
    }
    if(l != str.size() - 2){
        write(0);
    }
    if(se.size() != 1){
         write(0);
    }

    int x = *se.begin();

    if(x >= 2 && x <= str.size() - 2){
        write(1);
    }
    write(0);


}


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

int main( void ) {
    
    string str1, str2;
    cin >> str1 >> str2;
    
    for( int i = 0; i < str1.length(); i ++ ) {
        cout << str1[i];
        
        if( i < str2.length() )
            cout << str2[i];
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  if (a==b&&c==d||a==c&&b==d||a==d&&b==c) printf("yes\n");
  else printf("no\n");
  return 0;
}

Measured memory_bytes: 580