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

using namespace std;

#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

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

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int mod = 1e9 + 7;

int W, H, S;
char M[55][55];
char MS[11][55][55];
bool flr[55][55];
int sy, sx, gy, gx;

int dist[2][55][55][1<<10];
int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};

bool in(int y, int x) {
  return 0 <= y && y < H && 0 <= x && x < W;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> W >> H;
  rep(i, H) rep(j, W) {
    cin >> M[i][j];
    if(M[i][j] == '%') sy = i, sx = j;
    else if(M[i][j] == '&') gy = i, gx = j;
    else if(M[i][j] == '_' || islower(M[i][j])) flr[i][j] = 0;
    else if(M[i][j] == '^' || isupper(M[i][j])) flr[i][j] = 1;
  }
  cin >> S;
  rep(i, S) rep(j, H) rep(k, W) cin >> MS[i][j][k];

  queue< tuple<int, int, int, int> > que;

  memset(dist, -1, sizeof(dist));
  dist[0][sy][sx][0] = 0;
  que.emplace(0, sy, sx, 0);

  while(que.size()) {
    int f, y, x, bit;
    tie(f, y, x, bit) = que.front(); que.pop();
    if(y == gy && x == gx) {
      cout << dist[f][y][x][bit] << endl;
      return 0;
    }
    if(M[y][x] == '|' && dist[!f][y][x][bit] == -1) {
      dist[!f][y][x][bit] = dist[f][y][x][bit] + 1;
      que.emplace(!f, y, x, bit);
    }
    if(isalpha(M[y][x])) {
      int g = flr[y][x];
      rep(j, S) if(((bit >> j) & 1) && MS[j][y][x] == '*') g = !g;
      if(f == g) {
	int nf = f, ny = y, nx = x, nbit = bit;
	int digit = M[ny][nx] - (islower(M[ny][nx]) ? 'a' : 'A');
	nbit ^= 1<<digit;
	if(MS[digit][ny][nx] == '*') nf = !nf;
	if(dist[nf][ny][nx][nbit] == -1) {
	  dist[nf][ny][nx][nbit] = dist[f][y][x][bit] + 1;
	  que.emplace(nf, ny, nx, nbit);
	}
      }
    }
    rep(i, 4) {
      int nf = f, ny = y + dy[i], nx = x + dx[i], nbit = bit;
      if(!in(ny, nx) || M[ny][nx] == '#' || ~dist[nf][ny][nx][nbit]) continue;
      int g = flr[ny][nx];
      rep(j, S) if(((nbit >> j) & 1) && MS[j][ny][nx] == '*') g = !g;
      if(nf == g || M[ny][nx] == '|') {
	dist[nf][ny][nx][nbit] = dist[f][y][x][bit] + 1;
	que.emplace(nf, ny, nx, nbit);
      }
    }
  }
  cout << -1 << endl;


  return 0;
}

Measured memory_bytes: 27872
S = list(input())
N = len(S)
ans = "Yes"

for i in range((N-1)//2):
    if ans == "Yes":
        if S[i] != S[N -1 - i]:
            ans = "No"

for i in range((N-1)//2 -1):
    if ans == "Yes":
        if S[i] != S[(N - 1)//2 -1 - i]:
            ans = "No"

for i in range((N-1)//2 - 1):
    if ans == "Yes":
        if S[(N + 3)//2 -1 + i ] != S[N - 1 - i]:
            ans = "No"

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int a,b; cin>>a>>b;
  if(a>=b){
    for(int i=0; i<a; i++){
      cout<<b;
    }
  }
  else{
    for(int i=0; i<b; i++){
      cout<<a;
    }
  }
  cout<<endl;
}


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

const int MAX_N = 1e5;
vector<vector<int> > graph(MAX_N + 1);
vector<bool> searched(MAX_N + 1, false);

void dfs(int f) {
    for (int a : graph[f]) {
        if (!searched[a]) {
            searched[a] = true;
            dfs(a);
        }
    }
}

int main() {
    int N, M; cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int x, y, z; cin >> x >> y >> z;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (!searched[i]) {
            searched[i] = true;
            dfs(i);
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main(){
    string s;
    getline(cin, s);
    for (int i = 0; i < s.size(); i++){
        if(s[i] >= 65 && s[i] <= 90){
            s[i] = tolower(s[i]);
        }
        else if(s[i] >= 97 && s[i] <= 122){
            s[i] = toupper(s[i]);
        }
    }
    cout << s << endl;
}



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

using namespace std;
int n,m,q;
struct Str{
    int a,b,c,d;
};
Str a[51];
int x[51];
int ans;
void update()
{
    int sum  =0;
    for(int i=1;i<=q;i++)
    {
        if(x[a[i].b] - x[a[i].a] == a[i].c)
            sum+=a[i].d;
    }
    ans=max(ans,sum);
}
void trys(int i)
{
    for(int j=x[i-1];j<=m;j++)
    {
        x[i] = j;
        if(i==n)
        {
            update();
        }
        else
            trys(i+1);
    }
}
int main()
{
    cin>>n>>m>>q;
    x[0] = 1;
    for(int i=1;i<=q;i++)
    {
        cin>>a[i].a>>a[i].b>>a[i].c>>a[i].d;
    }
    trys(1);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3584
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	A = LI()
	ch = True
	for a in A:
		if(a%2==0 and (a%3!=0 and a%5!=0)):ch=False
	if ch:
		print("APPROVED")
	else:
		print("DENIED")

if __name__ == '__main__':
	main()

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

int main(){
	string taro, hanako;
	while(cin >> taro >> hanako, taro != "0" && hanako != "0"){
		int hit = 0, blow = 0;
		for(int i=0; i < 4; i++){
			if(taro[i] == hanako[i]) hit++;
			else {
				for(int j=0; j < 4; j++){
					if(i == j) continue;
					if(taro[i] == hanako[j]) blow++;
				}
			}
		}
		cout << hit << ' ' << blow << endl;

	}
}

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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

template<int SZ> struct Combo {
    ll fac[SZ+1], ifac[SZ+1];
    
    Combo() {
        fac[0] = ifac[0] = 1;
    	FOR(i,1,SZ+1) {
    	    fac[i] = i*fac[i-1] % MOD;
    	    ifac[i] = inv(fac[i]);
    	}
    }
    
    ll po (ll b, ll p) { return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD; }
    ll inv (ll b) { return po(b,MOD-2); }
    
    ll comb(ll a, ll b) {
        if (a < b || b < 0 || a < 0) return 0;
        ll tmp = fac[a]*ifac[b] % MOD;
        tmp = tmp*ifac[a-b] % MOD;
        return tmp;
    }
};

Combo<1000005> C;

int ad(int a, int b) { return (a+b)%MOD; }
int sub(int a, int b) { return (a-b+MOD)%MOD; }
int mul(int a, int b) { return (ll)a*b%MOD; }

ll dp[1000][1000], ans;
int N; 

ll complete(ll x) {
    return C.comb(x-1,N-x);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    dp[0][0] = 1;
    FOR(i,1,1000) FOR(j,1,i+1) {
        dp[i][j] = dp[i-1][j-1]+(i > 2 ? dp[i-2][j-1] : 0);
        // cout << i << " " << j << " " << dp[i][j] << "\n";
    }
    cin >> N; N--;
    FOR(i,1,N+1) {
        ans = ad(ans,C.fac[N]);
        ans = sub(ans,mul(C.fac[N+1-i],mul(C.fac[i-1],complete(i-1))));
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 22912
n, m, x = list(map(int, input().split()))
books = []
for i in range(0, n):
    books.append(list(map(int, input().split())))

prices = []
skills = []
patterns = 2 ** n
ans = 10 ** 10 * n
for i in range(patterns - 1, -1, -1):
    pattern = i
    skill = [0] * m
    price = 0
    for book in books:
        if pattern & 1 == 1:
            price += book[0]
            for j in range(1, m + 1):
                skill[j-1] += book[j]
        pattern >>= 1
    prices.append(price)
    skills.append(skill)
    flg = True
    for k in skill:
        if k < x:
            flg = False
            break
    if flg:
        if ans > price:
            ans = price
if ans == 10 ** 10 * n:
    ans = -1
print(str(ans))



Measured memory_bytes: 11380
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        String ans = "No";
        outloop:for(;;){
            c = c-b;
            if(c<=0){
                ans = "Yes";
                break outloop;
            }
            a = a-d;
            if(a<=0){
                break outloop;
            }
        }
        System.out.println(ans);
        }
    }


Measured memory_bytes: 35808
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    long long int n,m,x,i,t;
    scanf("%lld%lld%lld",&n,&m,&x);
    for(i=1;i<=10;i++)
    {
        t=n*x-m;
        printf("%lld\n",t);
        x=t;
    }
    return 0;
}



Measured memory_bytes: 128
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input=input.replace(/\?/g,".");
var arr=input.trim().split("\n");
while(true){
   var nm=arr.shift().split(" ").map(Number);
   var n=nm[0];
   var m=nm[1];
   if(n==0 && m==0)break;
   var rule=[];
   while(n--){
      var ary=arr.shift().split(" ");
      var flag=(ary[0]=="permit")?true:false;
      rule.push([flag,new RegExp(ary[1]+ary[2])]);
   }
   var ans=[];
   while(m--){
      var packet=arr.shift().split(" ");
      var str=packet[0]+packet[1];
      var flag=false;
      rule.forEach(function(v){
         if(v[0]==true && v[1].test(str))flag=true;
         else if(v[0]==false && v[1].test(str))flag=false;  
      });
      if(flag)ans.push(packet.join(" "));
   }
   console.log(ans.length);
   ans.forEach(function(v){console.log(v);});
}

Measured memory_bytes: 21992
#include <stdio.h>

int main(void){
    int i, n, y;
    char s[101];
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%c", &s[i]);
    }
    y = 0;
    for(i=0; i<n; i++){
        if(s[i] == 'Y'){
            y = 1;
        }
    }
    if(y == 0){
        printf("Three\n");
    }
    else {
        printf("Four\n");
    }
    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

class union_find {
public:
	union_find(int n)
		: par_(n, -1)
	{}
	void init(int n) {
		par_.assign(n, -1);
	}

	int root(int x) {
		return par_[x] < 0 ? x : par_[x] = root(par_[x]);
	}

	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) {
			return false;
		}
		else {
			if (par_[x] < par_[y]) {
				par_[x] += par_[y];
				par_[y] = x;
			}
			else {
				par_[y] += par_[x];
				par_[x] = y;
			}
			return true;
		}
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	int size(int x) {
		return -par_[root(x)];
	}

private:
	std::vector<int> par_;
};

int main() {
	ll n, q, com, x, y;

	cin >> n >> q;

	union_find uf(n);

	REP(i, q) {
		cin >> com >> x >> y;

		if (com == 0) {
			uf.unite(x, y);
		}
		else if (com == 1) {
			cout << uf.same(x, y) << endl;
		}
	}
}

Measured memory_bytes: 3116
n = int(input())
a = list(map(int, input().split()))
if a[0]<0: count=1
else: count = 0
ans, mina = abs(a[0]), abs(a[0])
flag = False
for i in range(1, n):
    ans += abs(a[i])
    mina = min(mina, abs(a[i]))
    if a[i]<0: count += 1
if count%2 or a.count(0): print(ans-mina*2)
else: print(ans)

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

int main()
{
	int count=0;
	string s;
	cin>>s;
	for(int i=0;i<(s.length()/2);i++)
	{
		if(s[i] != s[s.length()-i-1])
		{
			count++;
		}
	}
	cout<<count;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    ll sum=0, ma=-LONG_LONG_MAX, mi=LONG_LONG_MAX;
    rep(i,n){
        ll a; cin>>a;
        sum += a;
        chmax(ma,a);
        chmin(mi,a);
    }
    cout<<mi<<" "<<ma<<" "<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int k,t,n,arr[200];
  cin>>n;
  n--;
  cin>>arr[0];
  k=arr[0];
  arr[1]=k;
  if(n!=1){
  for(int i=1;i<n;i++)
  {
    cin>>t;
    if(arr[i]>t)
      arr[i]=t;
    arr[i+1]=t;
    k+=arr[i];
  }
  k+=t;}
  else{
      k+=arr[1];
  }
  cout<<k;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define vci vector<char>
 
 
 
int main() {
   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fast;
  ll n,k;
  cin>>n>>k;
  ll a[n],i;
  scan(a,n);
  ll f=0;
  for(i=k;i<n;i++){
    if(a[i]<=a[i-k]) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

  }
  // if(f==1) cout<<"No"<<endl;
  // else cout<<"Yes"<<endl;


return 0;
    
 }  

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

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> t(n + 1), x(n + 1), y(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 1; i <= n; ++i) {
        int time = t[i] - t[i - 1];
        int diff = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        if (diff > time || time % 2 != diff % 2) {
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
    return 0;
}


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

int main() {

    int a,b;
    scanf("%d%d", &a,&b);
    
    if(a>=13){
        printf("%d",b);
    }else if(a>=6) {
        printf("%d", b/2);
    }else{
        printf("0");
    }
    
    return 0;
    
}


Measured memory_bytes: 128
// 2008_PrincessGamble.cpp
//
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 110;

int n, m, p, pool, sum, result;
int x[MAX_N];

int main() {
  while(cin >> n >> m >> p) {
    sum = 0; result = 0;
    if(n == 0 && m == 0 && p == 0) break;

    for(int i = 1; i <= n; ++i) {
      cin >> x[i];
      sum += x[i] * 100;
    }
    if(x[m] != 0) {
      pool = sum * (100 - p) / 100;
      result = pool / x[m];
    }
    cout << result << endl;
  }
  return 0;
}



Measured memory_bytes: 3040
import sys
import numpy as np
input = sys.stdin.readline

D = int(input())
C = np.array(list(map(int,input().split())),dtype=np.int)
S = np.array([list(map(int,input().split())) for i in range(D)],dtype=np.int)

sumC = sum(C)
def score(strategy):
    sat = 0
    last = np.zeros(26).astype(np.int)
    for i,ind in enumerate(strategy):
        last += 1
        last[ind] = 0
        sat -= np.sum(C * last)
        sat += S[i][ind]
    return sat

#first = [np.argmax(ds) for ds in S]
first = [i % 26 for i in range(D)]

ans = first
now_score = score(ans)

for i in range(1):
    #samples = np.random.randint(0,26,size=D).tolist()
    for d in range(D):
        temp = ans[:]
        temp[d] = np.argmax(S[d])
        #temp[d] = samples[d]
        if score(temp) > now_score:
            ans = temp

for a in ans:
    print(a+1)



Measured memory_bytes: 27584
#pragma GCC optimize(3)
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int b[200010];
pii a[200010];
int n;
int main(int argc,char** argv){
	cin>>n;
	rep(i,n){
		int x;
		cin>>x;
		a[i]=mp(x,i);
	}
	sort(a,a+n);
	int m=n/2;
	rep(i,n){
		if(i<m){
			b[a[i].sc]=a[n/2].fi;
		}
		else{
			b[a[i].sc]=a[n/2-1].fi;
		}
	}
	rep(i,n){
		cout<<b[i]<<endl;
	}
	return 0;
}

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

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

    int n, k;
    cin >> n >> k;
    vector<int> hoge(n);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            a--;
            hoge[a]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (hoge[i] == 0) ans++;
    }
    cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
  int a, z;
  
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'A') {
      a = i;
      break;
    }
  }
  for (int j = 0; j < S.size(); j++) {
    int k = S.size() - j - 1;
    if (S.at(k) == 'Z') {
      z = k;
      break;
    }
  }
  cout << z - a + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

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

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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

const int MOD = 998244353;
#define int ll

int32_t main() {
	int n, s;
	cin >> n >> s;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int dp[n][3010] = {0}; //dp[i][j] = all subsequences which end with a[i] and sum to j, stores the sum of all their (left index + 1)
	vi pref(3010, 0);
	for(int i = 0; i < n; i++) {
		//get dp[i][j]
		//vi temp(3010,0);
		dp[i][a[i]] = i + 1;
		for(int j = a[i] + 1; j < 3010; j++)  {
			dp[i][j] = pref[j - a[i]];
			// temp[j] = pref[j] + dp[i][j];
			// for(int k = 0; k <  i; k++)
			// 	dp[i][j] += dp[k][j - a[i]];
		}
		for(int j = a[i]; j < 3010; j++) {
			pref[j] += dp[i][j];
			pref[j] %= MOD;
		}
		// temp[a[i]] = pref[a[i]] + i + 1;
		// pref = temp;
	}
	ll res = 0;
	for(int i = 0; i < n; i++) {
		//error(dp[i][s]);
		res = (res + 1LL*dp[i][s]*(n - i))%MOD;
	}
	cout << res;
}

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

int N, K;
int X1[50], Y1[50], D1[50], X2[50], Y2[50], D2[50];
vector<int> x, y, d;
long long ans;

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
		x.push_back(X1[i]), x.push_back(X2[i]);
		y.push_back(Y1[i]), y.push_back(Y2[i]);
		d.push_back(D1[i]), d.push_back(D2[i]);
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	sort(d.begin(), d.end());
	for (int i = 0; i < 2 * N - 1; i++) {
		for (int j = 0; j < 2 * N - 1; j++) {
			for (int k = 0; k < 2 * N - 1; k++) {
				int cnt = 0;
				for (int l = 0; l < N; l++) {
					if (X1[l] <= x[i] && x[i + 1] <= X2[l]
						&& Y1[l] <= y[j] && y[j + 1] <= Y2[l]
						&& D1[l] <= d[k] && d[k + 1] <= D2[l]) cnt++;
				}
				if (cnt >= K) ans += (long long)(x[i + 1] - x[i]) * (y[j + 1] - y[j]) * (d[k + 1] - d[k]);
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3168
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

use std::ascii::AsciiExt;
use std::cmp;
use std::iter::Iterator;

fn main() {
    input! {
        n:usize,
        v:[f64; n],
    }

    let mut v_mut = v;

    loop {
        
        if v_mut.len() == 1 {
            break;
        }

        //float昇順ソート　partial_cmp使う
        v_mut.sort_by(|a, b| a.partial_cmp(b).unwrap());


        let new_value = (v_mut[0] + v_mut[1]) / 2.0;
        v_mut.remove(0);
        v_mut.remove(0);
        v_mut.push(new_value);
    }

    println!("{}", v_mut[0]);
}


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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

int mod_inv(int a, int m = MOD) {
  int b = m, u = 1, v = 0;
  while (b) {
    int t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

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

  static int inv[101010];
  inv[0] = 0;
  int f = 1;
  for (int i = 1; i <= N; i++) {
    inv[i] = inv[i - 1] + mod_inv(i);
    inv[i] %= MOD;
    f *= i;
    f %= MOD;
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    (ans += a * (inv[i] + inv[N + 1 - i] - 1));
    ans %= MOD;
  }

  cout << ans * f % MOD << endl;
  return 0;
}


Measured memory_bytes: 1024
N, M = gets.split.map(&:to_i)
graph = Array.new(N + 1) { [] }
M.times do
  a, b = gets.split.map(&:to_i)
  graph[a] << b
  graph[b] << a
end

ans = 0
(2..N).to_a.permutation(N - 1).each do |p|
  p.unshift(1)
  ans += 1 if (1...N).all? { |i| graph[p[i - 1]].include?(p[i]) }
end
puts ans


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


int main() {
  cout << "Yes" << endl;
  int n, m;
  cin >> n >> m;
  vector<vector<int>> way(n);
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    way.at(a - 1).push_back(b - 1);
    way.at(b - 1).push_back(a - 1);
  }
  queue<int> keep;
  keep.push(0);
  vector<int> step(n, -1);
  step.at(0) = 0;
  while(!keep.empty()) {
    int a = keep.front();
    keep.pop();
    for(int i = 0; i < way.at(a).size(); i++) {
      if (step.at(way.at(a).at(i)) == -1) {
        step.at(way.at(a).at(i)) = step.at(a) + 1;
        keep.push(way.at(a).at(i));
      }
    }
  }
  for(int i = 1; i < n; i++) {
    for(int j = 0; j < way.at(i).size(); j++) {
      if (step.at(i) == step.at(way.at(i).at(j)) + 1) {
        cout << way.at(i).at(j) + 1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 10232
from collections import deque
n = int(input())
inf = float("inf")
tree = [[] for _ in range(n+1)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    tree[a].append([b, c])
    tree[b].append([a, c])
q, k = map(int, input().split())

depth = [inf] * (n+1)
visited = [False] * (n+1)
depth[k] = 0
queue = deque([k])
while queue:
    now = queue.popleft()
    visited[now] = True
    for i, v in tree[now]:
        if visited[i]:
            pass
        else:
            queue.append(i)
            depth[i] = min(depth[i], depth[now] + v)
for _ in range(q):
    x, y = map(int, input().split())
    ans = depth[x] + depth[y]
    print(ans)

Measured memory_bytes: 52140
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

class Point{
    public:
        double x,y;
        Point(){}
        Point(double x,double y) : x(x),y(y){}

        Point operator+(const Point& p) const{ return Point(x+p.x,y+p.y); }
        Point operator-(const Point& p) const{ return Point(x-p.x,y-p.y); }

        friend ostream& operator<<(ostream& os,const Point& p){
            os << "(" << p.x << "," << p.y <<")";
            return os;
        }
};

using Vector = Point;


// ベクトルの偏角(ラジアン)
double arg(const Vector& v){
    return atan2(v.y,v.x);
}

double abs(const Vector& v){
    return sqrt(v.x*v.x+v.y*v.y);
}

int main(){
    vector<Point> ps(3);
    rep(i,3) cin >> ps[i].x >> ps[i].y;
    swap(ps[1],ps[2]);

    double ans = 0;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<3;j++){
            int k = 3 - i - j;
            Point a = ps[i];
            Point b = ps[j];
            Point c = ps[k];
            debug(a);
            debug(b);
            debug(c);

            double th1 = (arg(c-a) - arg(b-a))/2.0;
            double th2 = (arg(a-b) - arg(c-b))/2.0;
            if(tan(th1)< 0) th1 *= -1;
            if(tan(th2)< 0) th2 *= -1;

            //assert(tan(th1) > 0);
            //assert(tan(th2) > 0);

            double r = abs(b-a) / (2 + 1/tan(th1) + 1/tan(th2));
            //assert(r > 0);
            ans = max(ans,r);
        }
    }
    cout << Double(ans) << endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif


typedef long long lint;

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

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


int c[10];

inline lint calc(lint dig, bitset<9> b) {
	lint p = 0, ret = 0;
	rep(i, dig) {
		ret += pow(10, p++)*c[i];
		if (b[i])p = 0;
	}
	return ret;
}

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

	string s; cin >> s;
	lint d = s.length();
	rep(i, d) {
		c[i] = s[d - i - 1] - '0';
	}
	lint bint = 0;
	bitset<9> b(bint);
	lint sum = 0;
	lint last = pow(2, d-1);
	lint i = 0;
	do {
		sum += calc(d, b);
		b = ++bint;
	} while (++i < last);
	co(sum);
	gc();
}

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

typedef long long ll;

int nc2 (int x) {
	return (x * (x - 1) / 2);
}

int main () {
	int n, m;
	
	cin >> n >> m;
	int ans = 0;
	if (n >= 2) {
		ans += nc2(n);
	}
	if (m >= 2) {
		ans += nc2(m);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	int x,a,b;
	cin>>x>>a>>b;
	
	if(b<=a){
		cout<<"delicious"<<endl;
	}else if(b<=a+x){
		cout<<"safe"<<endl;
	}else{
		cout<<"dangerous"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    string S, T;
    cin >> S >> T;
 
    //Initialize ans with a temporal value.
    //This value should be large enough; otherwise you will get wrong answer
    //Make sure that the value will lead to the correct answer.
    int ans = T.size();
 
    //Brute force through all initial position in S
    for (int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << endl;
}


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

string grid[2001];
int hori[2001][2001];
int verti[2001][2001];
int main(void){
ios_base:: sync_with_stdio(false);
cin.tie(0);
  
  
  
 int h,w;
            int result=0;
 cin >> h >> w;
 queue<pair<int,int> >temp;
 for(int i=1;i<=h;i++){
    cin >> grid[i];
 }
 for(int i=1;i<=h;i++){
    int cur=0;
    for(int j=0;j<=w;j++){
        if(j==w || grid[i][j]=='#')
        {while(!temp.empty()){
          hori[temp.front().first][temp.front().second]=cur;
          temp.pop();
        
        }
        cur=0;
        }
        else{
            cur++;
            temp.push({i,j});
        }
    }
 }
 for(int i=0;i<w;i++){
    int cur=0;
    for(int j=1;j<=h+1;j++){
        if(j==h+1 || grid[j][i]=='#')
        {while(!temp.empty()){
          verti[temp.front().first][temp.front().second]=cur;
          temp.pop();
        
        }
        cur=0;
        }
        else{
            cur++;
            temp.push({j,i});
        }
    }
 }
 for(int i=1;i<=h;i++){
    for(int j=0;j<w;j++){
        result=max(hori[i][j]+verti[i][j]-1,result);
       
    }
 }

cout << result;




}


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

int main() {
    int n;
    cin >> n;
    cout << n*n*n;

    return 0;
} 


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

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


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e18;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

class modint {
	static constexpr std::int_fast64_t Modulus = 1e9 + 7;
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr operator u64() const { return a; }
};

int main() {
    ll n;
    cin >> n;
    vector<ll> as(n);
    rep(i, n) {
        cin >> as[i];
    }
    vector<ll> sums(n + 1, 0);
    rep(i, n) {
        sums[i + 1] = sums[i] + as[i];
    }
	modint ans = 0;
	rep(i, n) {
		modint e = as[i];
		modint r = sums[n] - sums[i+1];
		ans += e * r;
	}
	cout << ans.a << endl;
    return 0;
}


Measured memory_bytes: 6368
<?php

$s = trim(fgets(STDIN));

$cand = ['A', 'G', 'C', 'T'];
$max = 0;
$tmp = 0;
$len = strlen($s);
for ($i=0; $i < $len; $i++) { 
	if (in_array($s[$i], $cand)) {
		$tmp += 1;
		$max = max($max, $tmp);
	}else{
		$tmp = 0;
	}
}
echo $max;

Measured memory_bytes: 4856
#include <iostream>
#include <array>
#include <stack>
#include <cstdlib>

constexpr int MAX_OP = 1000000;

std::stack<int> stacked;

void plus();
void minus();
void times();

int main()
{
    std::string symbol;
    while (std::cin >> symbol) {
        if (symbol == "+") {
            plus();
        } else if (symbol == "-") {
            minus();
        } else if (symbol == "*") {
            times();
        } else {
            stacked.push(atoi(symbol.c_str()));
        }
    }

    std::cout << stacked.top() << std::endl;

    return 0;
}

void plus()
{
    int op1 = stacked.top();
    stacked.pop();
    int op2 = stacked.top();
    stacked.pop();
    stacked.push(op1 + op2);
}

void minus()
{
    int op2 = stacked.top();
    stacked.pop();
    int op1 = stacked.top();
    stacked.pop();
    stacked.push(op1 - op2);
}

void times()
{
    int op1 = stacked.top();
    stacked.pop();
    int op2 = stacked.top();
    stacked.pop();
    stacked.push(op1 * op2);
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
#define pb push_back
#define INF 1e5
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        if (a < b && b < c) System.out.println("Yes");
        else System.out.println("No");
    }
}



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

int main() {
  int h,w;
  cin >> h >> w;
  vector<string> v(200);
  rep(i,h){
    cin >> v[i];
  }
  
  rep(i,w+2){
    cout << '#';
  }
  cout << endl;
  
  rep(i,h){
    cout << '#' << v[i] << '#' << endl;
  }
  
   rep(i,w+2){
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans=0, res=0;
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h.at(i);
  }
  for(int i=0; i<n-1; i++){
    if(h.at(i) >= h.at(i+1)){
      res++;
      if(res >= ans){
        ans = res;
      }
    }else{
      res = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  	int N, h_k, sum;
  	int tmp = 0;
	std::vector<int> h;
  	
  	std::cin >> N;
  	for(int i=0; i<N; i++){
      	std::cin >> h_k;
      	h.push_back(h_k);
    }
  
  	for(auto itr = h.begin(); itr != h.end(); ++itr){
      	if(tmp > *itr) sum += tmp -*itr;
      	if(itr == h.end() - 1) sum += *itr;
      	tmp = *itr;
    }  
  	std::cout << sum << "\n";
      
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  priority_queue<long double,vector<long double>,greater<long double>> q;
  rep(i,n){
    long double v;
    cin >> v;
    q.push(v);
  }
  while(q.size()>1){
    long double x = q.top(); q.pop();
    long double y = q.top(); q.pop();
    q.emplace((x+y)/2);
  }
  printf("%.10Lf\n",q.top());
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//  10:00-
//A 10:05 AC
//B 10:15 AC
//C 10:21 AC
//F 10:49 AC
//D 10:59 RE
//D 11:04 TLE
//D 11:10 TLE
/*
3
2
1
*/
int solve(void){
	int n,m,i,j,ans=0;cin>>n>>m;
	if(n==0){return 0;}
	vector<string>iru(n);
	for(i=0;i<n;i++){cin>>iru[i];}
	if(n+5<m){
		//nで全列挙できる
		vector<bool>nai(m);
		for(int bi=0;bi<(1<<n);bi++){
			int kaz=0;
			vector<bool>aaa(m);
			for(i=0;i<n;i++){
				if(!(bi&(1<<i))){continue;}
				kaz++;
				for(j=0;j<m;j++){
					if(iru[i][j]=='1'){aaa[j]=!aaa[j];}
				}
			}
			if(aaa==nai){maxeq(ans,kaz);}
		}
	}else{
		//bitdpが通る
		static int dp[1<<25];
		for(i=0;i<(1<<m);i++){dp[i]=-9999;}
		dp[0]=0;
		for(i=0;i<n;i++){
			int bi=0;
			for(j=0;j<m;j++){
				if(iru[i][j]=='1'){bi+=(1<<j);}
			}
			for(j=0;j<(1<<m);j++){
				if(j<(j^bi)){continue;}
				int mae=dp[j];
				maxeq(dp[j],dp[j^bi]+1);
				maxeq(dp[j^bi],mae+1);
			}
		}
		ans=dp[0];
	}
	cout<<ans<<endl;
	return 1;
}
int main(void){
	while(solve()){}
}



Measured memory_bytes: 134196