akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
#define vvv vector<vector<vector<long long int>>>
#define vvvl(a, b, c, d) vector<vector<bitset<80*80*81>>>(a, vector<vector<long long int>>(b, vector<long long int> (c, d)));
using namespace std;

/*
bitset<10> b("100"); //0000000100 insert "100"
bitset<10> b2(100);  //0001100100 insert 100
bitset<10> b3;
b3.set(5);           //0000100000 insert 2^5
std::cout << b << '\n';
std::cout << b2 << '\n';
std::cout << b3 << '\n';
std::cout << b[2] << '\n'; //access
std::cout << b.any() << '\n';
std::cout << (b & b2) << '\n';
std::cout << (b | b2) << '\n';
std::cout << (b ^ b2) << '\n';
std::cout << (b << 3) << '\n';
std::cout << (~b) << '\n';
*/
int main(int argc, char const *argv[]) {
  ll h, w;std::cin >> h >> w;
  vvl a = vv(h, w, 0, ll);
  vvl b = vv(h, w, 0, ll);
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) std::cin >> a[i][j];
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) std::cin >> b[i][j];
  vector<vector<bitset<80*80*170>>> dp = vector<vector<bitset<80*80*170>> >(h+1, vector<bitset<80*80*170>>(w+1, 0));
  ll zero = 80*80*85;
  dp[1][1].set(zero);
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      ll sa = abs(a[i-1][j-1] - b[i-1][j-1]);
      if(i==1&&j==1){
        dp[i][j] = ((dp[i][j] << sa) | (dp[i][j] >> sa));
        continue;
      }
      if(i==1){
        dp[i][j] = ((dp[i][j-1] << sa) | (dp[i][j-1] >> sa));
        continue;
      }
      if(j==1){
        dp[i][j] = ((dp[i-1][j] << sa) | (dp[i-1][j] >> sa));
        continue;
      }
      dp[i][j] = (((dp[i-1][j] | dp[i][j-1]) << sa) | ((dp[i-1][j] | dp[i][j-1]) >> sa));
    }
  }
  for(int i=zero;i<80*80*170;i++){
    if(dp[h][w][i]) {
      std::cout << i-zero << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 883320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  double input(a, b, x);
  double xd = x / (a*a);
  cout << setprecision(10);
  if (xd <= b / 2) {
    cout << (atan(b * b / (2 * a * xd)) * (180 / M_PI));
  } else {
    cout << (atan((b - xd) / (a / 2)) * (180 / M_PI));
  }
  cout << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const ll INF = 1e18;
const int mod = 1e9+7;
const int MAX = 1e6;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問の有無

int gcd(int a, int b) { // aとbの最大公約数（ユークリッドの互除法）
    if (b == 0) return a;
    return gcd(b, a % b);
}

bool is_prime[MAX+1];
int d[MAX+1];

void erat() { // エラトステネスのふるい
    memset(is_prime, true, sizeof(is_prime));
    for (int i = 2; i <= MAX; i++) {
        if (is_prime[i]) {
            for (int j = i + i; j <= MAX; j += i) {
                is_prime[j] = false;
                d[j] = i;
            }
        }
    }
}

void prime_fact(int x, set<int> &fact) { // 素因数分解
    if (x < 2) return;
    // for (int i = 2; i * i <= x; i++) {
    //     if (x % i == 0) {
    //         fact.insert(i);
    //         while (x % i == 0) x /= i;
    //     }
    // }
    // if (x != 1) fact.insert(x);
    while (not is_prime[x] && x % d[x] == 0) {
        fact.insert(d[x]);
        x /= d[x];
    }
    if (x != 1) {
        fact.insert(x);
    }
}

int n;
int a[MAX];
set<int> s;
bool flag = true;

int main() {
// input
    erat();
    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }
// solve
    rep(i, n) {
        if (a[i] == 1) continue;
        // if (flag) {
            set<int> fact;
            prime_fact(a[i], fact);
            for (int x : fact) {
                if (not s.count(x)) {
                    s.insert(x);
                } else {
                    flag = false;
                    // break;
                }
            }
        // }
        if (i > 0) a[i] = gcd(a[i], a[i-1]);
    }
// output
    if (flag) cout << "pairwise coprime" << "\n";
    else {
        if (a[n-1] == 1) cout << "setwise coprime" << "\n";
        else cout << "not coprime" << "\n";
    }
}

Measured memory_bytes: 16064
N=int(input())
T=input()
M=int(input())
P=[input() for i in range(M)]

def ans050(N:int, T:str, M:int, P:list):
    T_list=list(map(int,T.split()))
    ans_list=[]
    for i in range(M):
        T_list = list(map(int, T.split()))
        P_list=list(map(int,P[i].split()))
        del T_list[P_list[0]-1]
        T_list.append(P_list[1])
        ans_list .append(sum(T_list))
    return ans_list
for i in range(M):
    print((ans050(N,T,M,P))[i])

Measured memory_bytes: 9064
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	if (a < b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
struct Edge { 
  int src,dst,w; 
  bool operator < ( const Edge& e ) const {
    if( w != e.w ) return w < e.w;
    if( src != e.src ) return src < e.src;
    return dst < e.dst;
  }
};
const int MAX_V = 510; //
int V,E; //
vector<Edge> G[MAX_V]; // undirected graph
vector<int> dfs_num,dfs_low,dfs_parent,articulation_vertex;
int dfsNumberCounter, dfsRoot, rootChildren;
int cost[MAX_V][MAX_V];
 
//O(V+E)
int base_weight;
vector<Edge> bridges;
#define UNVISITED -1
void articulationPointAndBridge(int u){
  dfs_low[u] = dfs_num[u] = dfsNumberCounter++;
  rep(j,(int)G[u].size()){
    Edge &v = G[u][j];
    if( dfs_num[v.dst] == UNVISITED ) {
      dfs_parent[v.dst] = u;
      if( u == dfsRoot ) rootChildren++;
 
      articulationPointAndBridge(v.dst);
 
      if( dfs_low[v.dst] >= dfs_num[u] ) articulation_vertex[u] = true;
      if( dfs_low[v.dst] >  dfs_num[u] ) {
        if( base_weight == cost[u][v.dst] ) {
          bridges.push_back((Edge){u,v.dst,base_weight});
        }
        //printf("Edge (%d,%d) is a bridge\n",u,v.dst);
      }
      dfs_low[u] = min(dfs_low[u],dfs_low[v.dst]);
    } else if( v.dst != dfs_parent[u] ) {
      dfs_low[u] = min(dfs_low[u],dfs_num[v.dst]);
    }
  }
}
 
void calculateArticulationPointAndBridge(){
  dfsNumberCounter = 0;
  dfs_num.assign(V,UNVISITED);
  dfs_low.assign(V,0);
  dfs_parent.assign(V,0);
  articulation_vertex.assign(V,0);
   
  rep(i,V) {
    if( dfs_num[i] == UNVISITED ) {
      dfsRoot = i, rootChildren = 0;
      articulationPointAndBridge(i);
      articulation_vertex[dfsRoot] = ( rootChildren > 1 );
    }
  }
}
 
int par[MAX_V];
 
int find(int x){
  if( x == par[x] ) return x;
  return par[x] = find(par[x]);
}
 
void unit(int x,int y){
  x = find(x), y = find(y);
  if( x != y ) par[x] = y;
}
 
 
void compute(vector<Edge> edges){
  set<int> weights;
  rep(i,V) par[i] = i;
  sort(edges.begin(),edges.end());
  rep(i,E){
    Edge &e = edges[i];
    if( find(e.src) != find(e.dst) ) {
      unit(e.src,e.dst);
      weights.insert(e.w);
    }
  }
  int cnt=0,sum=0;
  int cur = 0;
  for(set<int>::iterator it=weights.begin();it!=weights.end();it++){
    int w = *it;
    while( cur < E && edges[cur].w < w ) ++cur;
    if( cur >= E ) break;
    if( edges[cur].w > w ) continue;
    base_weight = w;
    while( cur < E && edges[cur].w == w ) {
      Edge &e = edges[cur++];
      G[e.src].push_back((Edge){e.src,e.dst,e.w});
      G[e.dst].push_back((Edge){e.dst,e.src,e.w});
    }
    bridges.clear();
    calculateArticulationPointAndBridge();
    cnt += (int)bridges.size();
    sum += (int)bridges.size() * w;
  }
  printf("%d %d\n",cnt,sum);
}
 
int main(){
  memset(cost,-1,sizeof(cost));
  vector<Edge> edges;
  scanf("%d %d",&V,&E);
  {
    int s,t,w;
    rep(i,E){
      scanf(" %d %d %d",&s,&t,&w);
      --s, --t;
      edges.push_back((Edge){s,t,w});
      cost[s][t] = cost[t][s] = w;
    }
  }
  compute(edges);
  return 0;
}

Measured memory_bytes: 5076
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>

using namespace std;
using lint = long long;
using pii = pair<int, int>;
using vec = vector<int>;
using pq = priority_queue<int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define mp(x, y) make_pair((x), (y))
#define space " "

constexpr lint MOD = 1e9 + 7;
constexpr int INF = 1<<(int)29;
int A, B, C, F, H, I, J, K, L, M, N, P, Q, R, S, T, U, V, W, X, Y;
// lint A, B, C, F, H, I, J, K, L, M, N, P, Q, R, S, T, U, V, W, X, Y;
// int ans;
// string ans;
vec a, b;
set<int> ans;

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

	cin >> N;
    a.resize(N + 1);
	rep(i, N) {
        cin >> a[i + 1];
	}
    
    b.assign(N + 1, 0);
    repr(i, N) {
        int sum = 0;
        for (int j = 2; i * j <= N; j++) {
            if (b[i * j] == 1) sum++;
        }
        if (sum % 2 != a[i]) {
            ans.insert(i);
            b[i]++;
        }
    }

    cout << ans.size() << endl;
    foreach(it, ans) {
        cout << *it << space;
    }
    cout << endl;
	return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
	char a[100];
	int flag = 0;
	scanf("%s",a);
	for(int i = 0; i < 6; i++){
		if(a[i] == '1'){
             flag++;
		}
	}
	printf("%d\n",flag);

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

typedef long long ll;
using namespace std;

//char name[] = {'I','V','X','L','C','D','M'};
//int num[] = {1,5,10,50,100,500,1000};

int roma2num(char c){
	return c=='I'? 1:
		c=='V'? 5:
		c=='X'? 10:
		c=='L'? 50:
		c=='C'? 100:
		c=='D'? 500: 1000;
}

int main(){

	string str;
	while(cin >> str){
		int sum=0;
		int i=0;
		for(;i<str.size()-1;i++){
			int now = roma2num(str[i]);
			int next = roma2num(str[i+1]);

			if(now >= next){
				sum += now;
			}else{
				sum += next - now;
				i++;
			}
		}

		if(i < str.size()) sum += roma2num(str[i]);

		cout << sum << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
struct RMQ{
  int n;
  vector<int> dat;
  const int def=1<<28;
  RMQ(){}
  RMQ(int n_){init(n_);}
  RMQ(int n_,int* a){init(n_);build(n_,a);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,def);
  }
  void build(int n_, int* a){
    for(int i=0;i<n_;i++) dat[i+n-1]=a[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=min(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return def;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};

signed main(){
  int n;
  //cin>>n;
  scanf("%d",&n);
  int a[n];
  //for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) scanf("%d",a+i);
  int b[n],c[n];
  int m[n+1];
  for(int i=0;i<n;i++){
    m[a[i]]=i;
    b[i]=c[i]=1<<28;
    if(i%2) c[i]=a[i];
    else b[i]=a[i];
  }
  //for(int i=0;i<n;i++) cout<<b[i]<<" ";cout<<endl;
  //for(int i=0;i<n;i++) cout<<c[i]<<" ";cout<<endl;
  RMQ rmq1(n,b);
  RMQ rmq2(n,c);
  //puts("ok");
  typedef pair<int,int> P;
  typedef pair<int,P> PP;
  typedef deque<P> deq;
  deq ans;
  priority_queue<PP,vector<PP>,greater<PP> > qu;
  auto calc = [&](int l,int r){
    if(l%2==0){
      return rmq1.query(l,r);
    }else{
      return rmq2.query(l,r);
    }
  };
  qu.push(PP(calc(0,n),P(0,n)));
  while(!qu.empty()){
    PP pp=qu.top();qu.pop();
    int l=pp.second.first,r=pp.second.second;
    //cout<<l<<" "<<r<<endl;
    if(l>=r) continue;
    int x,y;
    if(l%2==0){
      x=rmq1.query(l,r);
      y=rmq2.query(m[x],r);
    }else{
      x=rmq2.query(l,r);
      y=rmq1.query(m[x],r);
    }
    ans.push_back(P(x,y));
    int p=m[x],q=m[y];
    qu.push(PP(calc(l,p),P(l,p)));
    qu.push(PP(calc(p+1,q),P(p+1,q)));
    qu.push(PP(calc(q+1,r),P(q+1,r)));
  }
  
  for(int i=0;i<n/2;i++){
    //if(i) cout<<" ";
    //cout<<ans[i].first<<" "<<ans[i].second;
    if(i) printf(" ");
    printf("%d %d",ans[i].first,ans[i].second);
  }
  //cout<<endl;
  puts("");
  
  return 0;
}


Measured memory_bytes: 12568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int a, b, t; cin >> a >> b >> t;
  int res = b * (int)((t + 0.5) / a);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 12.08.2020 23:03:31
**/

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

int main() {

    int n;
    cin >> n;
    int a=(n+1)/2,b=n/2;
    vector<int> v(n),o(a),e(b);
    rep(i,n) cin >> v.at(i);
    rep(i,a) o.at(i)=v.at(2*i);
    rep(i,b) e.at(i)=v.at(2*i+1);

    // rep(i,a) cout << o.at(i) << endl;
    // rep(i,b) cout << e.at(i) << endl;

    sort(o.begin(),o.end());
    sort(e.begin(),e.end());

    int count=1;
    int on,en,co1=0,co2=0,ce1=0,ce2=0;

    rep(i,a){
        if(i==0) continue;
        else if(o.at(i)==o.at(i-1)) count++;
        else if(o.at(i)!=o.at(i-1)){
            if(count>=co1){
                co2=co1;
                co1=count;
                on=o.at(i-1);
            }
            else if(count>=co2){
                co2=count;
            }
            count=1;
        }
        if(i==a-1){
            if(count>=co1){
                co2=co1;
                co1=count;
                on=o.at(i);
            }
            else if(count>=co2){
                co2=count;
            }
            count=1;
        }
    }
    rep(i,b){
        if(i==0) continue;
        else if(e.at(i)==e.at(i-1)) count++;
        else if(e.at(i)!=e.at(i-1)){
            if(count>=ce1){
                ce2=ce1;
                ce1=count;
                en=e.at(i-1);
            }
            else if(count>=ce2){
                ce2=count;
            }
            count=1;
        }
        if(i==b-1){
            if(count>=ce1){
                ce2=ce1;
                ce1=count;
                en=e.at(i);
            }
            else if(count>=ce2){
                ce2=count;
            }
            count=1;
        }
    }

    int ans;
    if(on==en) ans=min(n-ce1-co2,n-co1-ce2);
    else ans=n-ce1-co1;

    // cout << co1 << ' ' << co2 << ' ' << ce1 << ' ' << ce2 << endl;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4044
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define pb push_back
#define fr first
#define sc second

struct MP{
	string s;
	int a[500010];
	void calc_MP(){
		a[0] = -1;
		int j = -1;
		for(int i = 0 ; i < s.size() ; i ++){
			while(j >= 0 && s[i] != s[j])j = a[j];
			j ++;
			a[i+1] = j;
		}
	}
}S,T;

int main(){
	string s;
	cin >> s;
	
	S.s = s;
	T.s = s;
	reverse(T.s.begin(),T.s.end());
	S.calc_MP();
	T.calc_MP();
	
	if(S.a[S.s.size()] == S.s.size()-1){
		printf("%d\n%d\n",(int)s.size(),1);
		return 0;
	}
	if(S.a[S.s.size()] == 0 || S.s.size()%(S.s.size()-S.a[S.s.size()]) != 0){
		printf("%d\n%d\n",1,1);
		return 0;
	}
	int cnt = 0;
	for(int i = 1 ; i <= -1+(int)s.size() ; i ++){
		int j = s.size()-i;
		if((S.a[i] == 0 || i%(i-S.a[i]) != 0)&&(T.a[j] == 0 || j%(j-T.a[j]) != 0))cnt ++;
	}
	printf("%d\n%d\n",2,cnt);
}



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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

//#define int ll
//#define int long long

//配列版
signed main()
{
  array<array<int,110>, 110> t{0};
	int w,h,n; cin >> w >> h >> n;
  
	for(int i=0; i < n; ++i){
		int x,y,a; cin >> x >> y >> a;
      
		if(a==1){
			for(int j=0; j < x; ++j){
              for(int k=0; k < h; ++k)
                t[j][k]=1;
            }
		}
      
		if(a==2){
			for(int j=x; j < w; ++j){
              for(int k=0; k < h; ++k)
                t[j][k]=1;
            }
		}
      
		if(a==3){
			for(int j=0; j < w; ++j){
              for(int k=0;k < y; ++k)
                t[j][k]=1;
            }
		}
          
		if(a==4){
			for(int j=0; j < w; ++j){
              for(int k=y; k < h; ++k)
                t[j][k]=1;
            }
		}
	}
	
	int cnt=0;
	for(int i=0; i < w; ++i){
      for(int j=0; j < h; ++j){
        if(t[i][j]==0)
          ++cnt;
      }
    }
  
	cout << cnt;
  
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);

	int n, p;
	cin >> n >> p;
	vector<int> a(n);
	ll d[64][2] = {0};
	for(int i=0; i<n; ++i)
		cin >> a[i];

	d[0][0] = 1;
	for(int i=0; i<n; ++i)
	{
		d[i+1][0] = d[i][0] + d[i][a[i]%2];
		d[i+1][1] = d[i][1] + d[i][1-a[i]%2];
	}
	
	ll ans = d[n][p];
	
	cout << ans << "\n";

	return 0;
}


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

using namespace std;

typedef long long ll;
 
ll n,p[3100],dp[3100][3100];

ll rek(int l, int r) {
	
	//printf("%d %d\n",l,r);
	
	if(l == r) return 0;
	
	if(dp[l][r] != -1) return dp[l][r];
	
	return dp[l][r] = max(p[l] - rek(l + 1,r), p[r - 1] - rek(l, r - 1));
}

int main() {
	
	scanf("%lld", &n);
	
	memset(dp, -1, sizeof(dp));
	
	for(int i = 0; i < n; i++) {
		scanf("%lld", &p[i]);
	}
	
	printf("%lld",rek(0,n));
	
	return 0;
}
		

Measured memory_bytes: 75520
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
"""
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
"""

#C
"""
k,a,b = LI()
if k <= a:
    print(k+1)
else:
    if b-a < 3:
        print(k+1)
    else:
        ans = a+((k-a+1)//2)*(b-a)+(k-a+1)%2
        print(ans)
"""

#D

#E
n,m = LI()
a = LIR(n)
a.sort()
a = a[::-1]
for i in range(n):
    for j in range(i+1,n):
        s = 0
        while a[i][s] == 0 and s < m-1:s+=1
        if s < m and a[i][s] != 0:
            if a[j][s] > 0:
                for k in range(s,m):
                    a[j][k] -= 1*a[i][k]
                    a[j][k] = abs(a[j][k])
r = 0
for i in range(n):
    if sum(a[i]) > 0:r += 1
print((pow(2,n+m-1)-pow(2,n-r+m-1))%998244353)
#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 45536
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
     int a,b,c,d,e,f,g,h,j,i;
     cin>>a;
     int ar[a];
     cin>>b;
     for(i=0;i<a;i++)
     {
         cin>>ar[i];
     }
     sort(ar,ar+a);
      c=INT_MAX;
      for(i=0;i<a;i++)
      {
          if(b+i-1>=a)
          {
              break;
          }
          c=min(c,ar[b+i-1]-ar[i]);
      }
      cout<<c<<endl;
 }


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int n;
  cin >> n;
  int ans=0;
  int a;
  REP(i,n){
    cin>>a;
    a--;
    ans+=a;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        double len = (double)n / 3;
        // cout << len << "\n";
        double ans = len * len * len;
        cout << fixed << setprecision(12) << ans << "\n";
    }
}

Measured memory_bytes: 3792
using System;
using System.Linq;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var hn = Console.ReadLine().Split().Select(double.Parse).ToArray();

            var a = Console.ReadLine().Split().Select(double.Parse).ToList();

            var asum = a.Sum();

            Console.WriteLine(asum >= hn[0] ? "Yes" : "No");

        }
    }
}


Measured memory_bytes: 20576
void main() {
	int[] arr;
	arr ~= 1;
	foreach(i; 2..1001) {
		auto a = i;
		auto b = a;
		auto k = 2;

		a *= a;
		while(a <= 1000) {
			arr ~= a;
			k++;
			a = b^^k;
		}
	}
	auto X = ri;
	while(true) {
		if(arr.canFind(X)) {
			X.writeln;
			return;
		}
		X--;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

T[] deepcopy(T)(T[] a) {
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}

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

int main() {
    int n ;
    cin >> n ;
    ll a[n] ;
    for (int i = 0; i < n; i++) cin >> a[i] ; 
    ll ans = 0 ;
    sort(a,a+n,greater<ll>()) ;

    int t = n-1 ;
    for (int i = 0; i < n; i++)
    {
        int lim = 2;
        if(i==0) lim = 1 ;
        for (int j = 0; j < lim; j++){
            if(t>0){
                ans+= a[i] ;
                t-- ;
            }
        }
    }
    
    cout << ans << endl ;

}

Measured memory_bytes: 5184
s = input()
n = len(s)
up = []
down = []
for i in range(1,n):
  if s[i] != s[i-1]:
    if s[i] == 'L':
      down.append(i)
    else:
      up.append(i)
ans = [0 for _ in range(n)]
try:
  top = up[0]
except:
  top = 2 * n
bottom = down[0]
count = 0
for i in range(n):
  diff = i - bottom
  if diff % 2 == 0:
    ans[bottom] += 1
  else:
    ans[bottom-1] += 1
  #print(ans)
  if i+1 == top:
    count += 1
    try:
      top = up[count]
    except:
      pass
    bottom = down[count]
print(' '.join(map(str,ans)))

Measured memory_bytes: 14400
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    stack<char> st;
    for(int i=0;i<s.size();i++)
    {
        if(st.empty())
            st.push(s[i]);
        else
        {
            if(s[i]!=st.top())
                st.push(s[i]);
        }
    }
    cout<<st.size()<<"\n";

}


Measured memory_bytes: 3832
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

class ComMod():
  def __init__(self,n,mod):
    self.n=n
    self.mod=mod
    self.fact=[0]*(n+1)
    self.ifact=[0]*(n+1)
    self.fact[0]=1  
    for i in range(1,n+1):
      self.fact[i]=self.fact[i-1]*i
      self.fact[i]%=self.mod
    self.ifact[n]=pow(self.fact[n],self.mod-2,self.mod)
    for i in range(n,0,-1):
      self.ifact[i-1]=self.ifact[i]*i
      self.ifact[i-1]%=self.mod
  def com(self,n,k):
    if n<0 or k<0 or n<k:
      return 0
    return self.fact[n]*(self.ifact[k]*self.ifact[n-k]%self.mod)%self.mod

def main():
  n,m,k=LI()
  res=0
  mod=998244353
  tmp=m*pow(m-1,n-k-1,mod)

  c=ComMod(200005,mod)
  for r in range(n-k-1,n):
    res=(res+tmp*c.com(n-1,r)%mod)%mod
    tmp=tmp*(m-1)%mod
  return res

# main()
print(main())


Measured memory_bytes: 76424
n, m = map(int, input().split())
ab = [[0, 0] for _ in range(n)]
for i in range(n):
    ab[i][0], ab[i][1] = map(int, input().split())
ab.sort()
c = 0
i = 0
while m != 0:
    if ab[i][1] <= m:
        c += ab[i][0] * ab[i][1]
        m -= ab[i][1]
    else:
        c += ab[i][0] * m
        break
    if i == n - 1:
        break
    else:
        i += 1
print(c)


Measured memory_bytes: 20012
import           Control.Applicative()

check :: String -> Bool
check [] = False
check [_] = False
check (c1:c2:s)
    | c1 == c2 = True
    | otherwise = check(c2:s)


main :: IO ()
main = do
    s <- getLine
    putStrLn $ if check s then "Bad" else "Good"

Measured memory_bytes: 380
n = int(input())
ss = "MARCH"
c = [0 for i in range(5)]
for i in range(n):
	s = input()
	for j in range(5):
		if s[0] == ss[j]:
			c[j] += 1
ans = 0
for i in range(5):
	for j in range(i+1,5):
		for k in range(j+1,5):
			ans += c[i]*c[j]*c[k]
print (ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t; cin>>s>>t;
	string ans;
	int dp[s.size()+1][t.size()+1]={0};
	for(int i=0;i<=s.size();i++){
		for(int j=0;j<=t.size();j++){
			if(i==0 or j==0){
				dp[i][j]=0;
			}else if(s[i-1]==t[j-1]){
				dp[i][j]=1+dp[i-1][j-1];
			}else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int i=s.size(); int j=t.size();
	while(i>0 and j>0){
		if(dp[i][j]==dp[i-1][j]){
              i--;  
		}else if(dp[i][j]==dp[i][j-1]){
			j--;
		}else if(dp[i][j]==1+dp[i-1][j-1]){
			ans+=s[i-1];
			i--; j--;
		}
	}
	reverse(ans.begin(),ans.end());
	//cout<<dp[s.size()][t.size()];
	cout<<ans;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
int  main(){
    cout<<fixed<<setprecision(12);
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    double X=pow(x1-x2,2);
    double Y=pow(y1-y2,2);
    cout<<sqrt(X+Y)<<endl;
    return 0;
}


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

int main(){
  int a, b, c, x;
  scanf("%d%d%d",&a,&b,&c);
  x = 3*max(max(a,b),c)-a-b-c;
  printf("%d",x/2+x%2*2);
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (2000000000)
#define MOD (1000000007)
#define PI (acos(-1))

string s;
bool iwaiwa(int f,int t){
  reps(i,f,t){
    if(s[i]=='#' && s[i+1]=='#'){
      return false;
    }
  }
  return true;
}

bool kkk(int f,int t){
  reps(i,f,t-1){
    if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
      return true;
    }
  }
  return false;
}

int main(){
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  a--;b--;c--;d--;
  cin >> s;
  //cout << a << " "<< b << " " << c << " " << d << endl;
  //cout << iwaiwa(a,c) << " " << iwaiwa(b,d) << endl;
  if((a<c && c<b && b<d) || (a<b && b<c && c<d)){
    if(iwaiwa(a,c) && iwaiwa(b,d)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    return 0;
  }

  //ABDC
  
  if(a<b && b<d && d<c){
    if(iwaiwa(a,c) && kkk(b-1,d+1)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int a[225816];
bool used[225816];

int main(void){
	int n,i,p[25816];
	ll a[25816],b[25816];
	fill(b,b+25816,0ll);
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> p[i]; --p[i];
		a[i] = 30000ll * (i+1);
		b[i] += 30000ll * (n-i);
		b[p[i]] += i;
	}
	for(i=0; i<n; ++i){
		cout << ((i)?" ":"") << a[i];
	}
	cout << endl;
	for(i=0; i<n; ++i){
		cout << ((i)?" ":"") << b[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,i;
    cin>>n;
    long long a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]!=i)
        {
            swap(a[i],a[a[i]]);
            break;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]!=i)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}


Measured memory_bytes: 3612
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::io::Write;

#[derive(Copy, Clone, Eq, PartialEq)]
struct State {
    v: usize,
    d: u32,
}

use std::cmp::Ordering;

impl Ord for State {
    fn cmp(&self, other: &State) -> Ordering {
        other.d.cmp(&self.d)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<Ordering> {
        Some(self.cmp(&other))
    }
}

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        n: usize,
        edge: usize,
        src: usize,
        e: [(usize, usize, u32); edge],
    }
    let mut g = vec![vec![]; n];
    for (s, t, d) in e {
        g[s].push((t, d));
    }
    let inf = (n * 10000 + 1) as u32;
    let mut dp = vec![inf; n];
    dp[src] = 0;
    let mut h = std::collections::BinaryHeap::new();
    h.push(State{v: src, d: 0});
    while let Some(State{v, d}) = h.pop() {
        if dp[v] < d {
            continue;
        }
        for e in g[v].iter() {
            let (u, c) = *e;
            if dp[u] > d + c {
                dp[u] = d + c;
                h.push(State{v: u, d: dp[u]});
            }
        }
    }
    for d in dp.iter() {
        if *d == inf {
            writeln!(out, "INF").unwrap();
        } else {
            writeln!(out, "{}", *d).unwrap();
        }
    }
}

fn main() {
    run();
}



Measured memory_bytes: 39784
import java.io.*;
import java.util.*;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        pw.println(solve());
        pw.close();
    }

    private static int solve() throws IOException {
        int K = readInt();
        if (K % 2 == 0 || K % 5 == 0) return -1;

        // 7 * (10*n-1)/9
        // K | 77..7 (n 7s)  <=> 9K | 7 * (10*n-1)
        if (K % 7 == 0) K /= 7;
        K *= 9;

        int ans = 1;
        int remainder = 10 % K;
        while (remainder != 1) {
            ans++;
            remainder = remainder * 10 % K;
        }

        return ans;
    }
}


Measured memory_bytes: 32700
#include<iostream>
using namespace std;
int main(void){
  int a,b;
  string s;
  cin >> a >> b;
  for(int i = 1;i <= a;i++){
    for(int j = 0;j < b;j++){
      cin >> s;
      if(s == "snuke"){
        cout << (char)('A'+j) << i; 
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int map_j[2000][2000], map_o[2000][1500], map_i[1200][1300];
signed main() {
	int h, w, n; cin >> h >> w >> n;
	for (int i = 1; i <= h; i++) {
		string s; cin >> s;
		for (int j = 1; j <= w; j++) {
			map_j[i][j] = map_j[i - 1][j] + map_j[i][j - 1] - map_j[i - 1][j - 1]; if (s[j - 1] == 'J')map_j[i][j]++;
			map_o[i][j] = map_o[i - 1][j] + map_o[i][j - 1] - map_o[i - 1][j - 1]; if (s[j - 1] == 'O')map_o[i][j]++;
			map_i[i][j] = map_i[i - 1][j] + map_i[i][j - 1] - map_i[i - 1][j - 1]; if (s[j - 1] == 'I')map_i[i][j]++;
		}
	}
	for (int i = 0; i < n; i++) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		a--; b--;
		cout << map_j[c][d] - map_j[c][b] - map_j[a][d] + map_j[a][b] << ' ';
		cout << map_o[c][d] - map_o[c][b] - map_o[a][d] + map_o[a][b] << ' ';
		cout << map_i[c][d] - map_i[c][b] - map_i[a][d] + map_i[a][b] << endl;
	}
}


Measured memory_bytes: 21704
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main()
{
	int M1,M2,D1,D2;
	cin>>M1>>D1;
	cin>>M2>>D2;
	if( M1 != M2){
		cout<<1<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	ans := 0
	for i := 0; i <= n; i++ {
		num := i
		sum := 0
		for num > 0 {
			mod := num % 10
			sum += mod
			num /= 10
		}
		if sum >= a && sum <= b {
			ans += i
		}
	}
	fmt.Println(ans)
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		String ans = "";

		if (num < 1200) {
			ans = "ABC";
		} else if (num < 2800) {
			ans = "ARC";
		} else {
			ans = "AGC";
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
N = int(input())
for i in range(N):
    s = int(input(), 16)
    ans = (s & ~(1 << 31)) >> 7
    v = 0.5
    for i in range(6, -1, -1):
        if (s >> i) & 1:
            ans += v
        v /= 2
    if s & (1 << 31):
        t = "-%.10f" % ans
    else:
        t = "%.10f" % ans
    i = len(t)
    while t[i-1] == '0':
        i -= 1
    if t[i-1] == '.':
        i += 1
    print(t[:i])



Measured memory_bytes: 5628
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

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

        vector<ll> a(n), c(n + 1, 0);
        rep (i, n) {
                cin >> a[i];
                c[i + 1] = c[i] + a[i];
        }

        auto get = [&](int i, int j) {
                return c[j] - c[i];
        };

        auto find = [&](int i, int j) {
                int l = i, r = j;
                while (r - l > 1) {
                        int m = (r + l) / 2;                
                        ll s = get(i, m), t = get(m, j);
                        if (s >= t) {
                                r = m;
                        } else {
                                l = m;
                        }
                }

                if (abs(get(i, r) - get(r, j)) < abs(get(i, l) - get(l, j))) {
                        return r;
                } else {
                        return l;
                }
        };

        ll ans = numeric_limits<ll>::max();
        rep (i, n + 1) {
                int x = find(0, i), y = find(i, n);
                vector<ll> t;
                t.push_back(c[x] - c[0]);
                t.push_back(c[i] - c[x]);
                t.push_back(c[y] - c[i]);
                t.push_back(c[n] - c[y]);

                auto p = minmax_element(t.begin(), t.end());
                ans = min(ans, *p.second - *p.first);
        }
                
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0; i<n; ++i)

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  int max = 0;

  x -= z;

  while(x >= y+z) {
    x -= y+z;
    max += 1;
  }

  cout << max << endl;

  return 0;
}


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

string str;
int sum = 0, num = 0;

int main(){
	cin >> str;
	for(int i = 0; i < str.size(); i++){
		int n = str[i]-'0';
		sum += n;
		num += n*pow(10, str.size()-i-1);
	}
	if(num % sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int m[3][3];
int cpy[3][3];

void input(void){
  int i,j;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&m[i][j]);
    }
  }
}
void output(void){
  int i,j;
 for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      printf("%3d",m[i][j]);
      puts("");
    }
 }
}
void copy(int a[3][3],int b[3][3]){
  int i,j;
 for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      a[i][j] = b[i][j];
    }
 }
}
int calc(void){
  int i,sum = 0;
  for(i=0;i<9;i++){
    int a = m[i/3][i%3];
    if(a){
      a--;
      sum += abs(i/3 - a/3)+abs(i%3 - a%3);
    }
  }
  return sum;
}
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

void swap(int *a, int *b){
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}
int in(int a,int b){
  return 0<=a&&a<3&&0<=b&&b<3;
}
int df(int a,int b,int p,int d,const int lim){
  int i , h=calc();
  if(h == 0)return d;
  if(d+h > lim)return -1;

  for(i=0;i<4;i++){
    int x= a+dx[i],y=b+dy[i];
    int res;
    if(~p && i == (p+2)%4)continue;
    if(!in(x,y))continue;
    swap(&m[b][a],&m[y][x]);
    res = df(x,y,i,d+1,lim);
    if(~res)return res;
    swap(&m[b][a],&m[y][x]);
  }
  return -1;
}

void empty(int *a, int *b){
  int i,j;
   for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(!m[i][j]){
	*a = j;
	*b = i;
	return;
      }
    }
   }
}
int s(void){
  int a,b,lim,x;
  empty(&a,&b);
  for(lim = 0;lim < 50;lim++){
    copy(cpy,m);
    if((x = df(a,b,-1,0,lim)) != -1)return x;
    copy(m,cpy);
  }
  return -1;
}
int main(){
  input();
  printf("%d\n",s());

  return 0;
}

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

int main(){
    int h, w, k;
    string s[300];
    int cnt[300];
    int ans[300][300];
    cin >> h >> w >> k;
    for(int i=0;i<h;++i){
        cin >> s[i];
        cnt[i] = 0;
        for(int j=0;j<w;++j){
            if(s[i][j] == '#') ++cnt[i];
        }
    }

    int i_beg = 0;
    int id = 1;
    for(int i=0;i<h;++i){
        if(cnt[i] > 0){
            i_beg = i;
            break;
        }
    }
    for(int i=i_beg;i<h;++i){
        if(cnt[i] == 0){
            for(int j=0;j<w;++j) ans[i][j] = ans[i-1][j];
        }else{
            int j_beg = 0;
            for(int j=0;j<w;++j){
                if(s[i][j] == '#'){
                    j_beg = j;
                    break;
                }
            }
            for(int j=j_beg;j<w;++j){
                if(s[i][j] == '#'){
                    ans[i][j] = id;
                    ++id;
                }else ans[i][j] = ans[i][j-1];
            }
            for(int j=0;j<j_beg;++j) ans[i][j] = ans[i][j_beg];
        }
    }

    for(int i=0;i<i_beg;++i){
        for(int j=0;j<w;++j) ans[i][j] = ans[i_beg][j];
    }

    for(int i=0;i<h;++i){
        cout << ans[i][0];
        for(int j=1;j<w;++j) cout << " " << ans[i][j];
        cout << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& as, const vector<int>& bs, const vector<int>& cs) 
{
    int ans = 0, last = -2;

    for (auto a : as)
    {
        ans += bs[a];

        if (a == last + 1)
            ans += cs[a - 1];

        last = a;
    }
        
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> as(N + 1), bs(N + 1), cs(N + 1);

    for (int i = 1; i <= N; ++i)
        cin >> as[i];

    for (int i = 1; i <= N; ++i)
        cin >> bs[i];

    for (int i = 1; i <= N; ++i)
        cin >> cs[i];

    auto ans = solve(N, as, bs, cs);

    cout << ans << '\n';

    return 0;
}


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

using namespace std;

#define fo(i,CApiTaL_N) for(int i=0; i<CApiTaL_N; i++)
#define Fo(i,k,CApiTaL_N) for(int i=k; i<CApiTaL_N; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int t;
int n;
const int mod=1e9+7;
vl dp(1<<21+5);
vvi conn(21+1,vi(21+1));

void test_case(){
    cin>>n;
    dp[0]=1;
    fo(i,n)fo(j,n)cin>>conn[i][j];
    fo(mask,1<<n){
        int men=__builtin_popcount(mask);
        fo(bit,n){
            if(conn[men][bit]&&!(1<<bit&mask)){
                int target=(mask^(1<<bit));
                dp[target]=(dp[target]+dp[mask])%mod;
            }
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
}

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

    t=1;
    while(t--){
        test_case();
    }
    
    return 0;
}

Measured memory_bytes: 527344
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;
ll x[4],y[4];
int main(void){
	ll S;
	cin >> S;
	// S = abs(x1y2 - x2y1);
	x[1] = y[1] = 0;
	x[2] = 1e9;
	y[2] = 1;
	y[3] = (S-1+x[2])/x[2];
	x[3] = (y[3] * x[2]) - S;
	cout << x[1] << " " << y[1] <<" ";
	cout << x[2] << " " << y[2] <<" ";
	cout << x[3] << " " << y[3] << endl;
}

Measured memory_bytes: 256