akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int h, w;
    cin >> h >>  w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<int>> l(h, vector<int>(w, 0)), r(h, vector<int>(w, 0)), u(h, vector<int>(w, 0)), d(h, vector<int>(w, 0));
    rep(row, h) rep(col, w){
        if (s[row][col] == '#'){
            l[row][col] = -1;
            u[row][col] = -1;
            continue;
        }
        if (col-1 >= 0) l[row][col] = l[row][col-1]+1;
        if (row-1 >= 0) u[row][col] = u[row-1][col]+1;
    }
    for(int row = h-1; row >= 0; row--){
        for(int col = w-1; col >= 0; col--){
            if (s[row][col] == '#'){
                r[row][col] = -1;
                d[row][col] = -1;
                continue;
            }
            if (col+1 != w) r[row][col] = r[row][col+1]+1;
            if (row+1 != h) d[row][col] = d[row+1][col]+1;
        }
    }

    int ans = 0;
    rep(row, h) rep(col, w){
        if (s[row][col] == '#') continue;
        int sum = l[row][col] + r[row][col] + d[row][col] + u[row][col] + 1;
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int CENTER = 300;
const int INF = 999;
const int MAX_H = 601;
const int MAX_W = 301;

int dp1[MAX_H][MAX_W];
int dp2[MAX_H][MAX_W];

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

	vi a(n), b(n), c(n), d(n);
	rep(i, n) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	rep(i, MAX_H) rep(j, MAX_W) {
		dp1[i][j] = -INF;
		dp2[i][j] = -INF;
	}

	dp1[y + CENTER][0] = x;

	rep(k, n) {
		rep(i, MAX_H) {
			rep(j, MAX_W) {
				if (dp1[i][j] == -INF)
					continue;

				dp2[i][j] = max(dp2[i][j], dp1[i][j]);
				if (i + b[k] < MAX_H) {
					dp2[i + b[k]][j] = max(dp2[i + b[k]][j], dp1[i][j] - a[k]);
				}
				if (i - c[k] >= 0) {
					dp2[i - c[k]][j + d[k]] = max(dp2[i - c[k]][j + d[k]], dp1[i][j]);
				}
			}
		}
		rep(i, MAX_H) rep(j, MAX_W) dp1[i][j] = dp2[i][j];

		// rep2(i, CENTER - 10, CENTER + 10) {
		// 	cout << i - CENTER << " ";
		// 	rep(j, 10) {
		// 		cout << dp2[i][j] << " ";
		// 	}
		// 	cout << endl;
		// }
		// cout << endl;
	}

	int ma = 0;
	rep2(i, CENTER, MAX_H) {
		rep(j, MAX_W) {
			if (dp2[i][j] >= 0) {
				ma = max(ma, j);
			}
		}
	}

	cout << ma << endl;

}

Measured memory_bytes: 4516
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define range(i,a,b) for(int i=a; i<(int)(b); i++)
#define rep(i,b) range(i,0,b)

typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, int cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<int> Array;
typedef vector<Array> Matrix;

int const inf = 1e9;

typedef int Capacity;
struct FordFulkerson {
    typedef vector<vector<Capacity>> Matrix;
    size_t n;
    Matrix cap, flow;
    vector<bool> vis;
    Capacity res;
    vector<vector<int>> g;
    FordFulkerson(const Graph &graph){
        n = graph.size();
        cap.assign(n, Array(n));
        flow.assign(n, Array(n));
        g.assign(n, {});
        res = 0;
        rep(i,n)rep(j,graph[i].size()){
            int u = graph[i][j].src, v = graph[i][j].dst;
            Capacity c = graph[i][j].cap;
            cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
        }
        rep(i,n)rep(j,n) if(cap[i][j]) g[i].push_back(j), g[j].push_back(i);
    }
    Capacity solve(int s, int t){
        Capacity f = -1;
        while(f) vis.assign(n,false), res += (f = augment(s,t,inf));
        return res;
    }
    Capacity augment(const int v, const int t, Capacity lim){
        vis[v] = true;
        if(v == t) return lim;
        for(const int &i : g[v]){
            if(vis[i] || flow[v][i] == cap[v][i]) continue;
            Capacity f = augment(i, t, min(lim, cap[v][i] - flow[v][i]));
            flow[v][i] += f; flow[i][v] -= f;
            if(f) return f;
        }
        return 0;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    cout << FordFulkerson(g).solve(0,N-1) << endl;
}

Measured memory_bytes: 1368
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] X = new int[N];
		int min =0;
		int answer = Integer.MAX_VALUE;
      
		for(int i=0; i<N; i++) {
			X[i] = sc.nextInt();
		}
      	//来るたびにminを初期化する
      	//制約以内で繰り返す
		for(int j=1;  j<=100; j++) {
			min = 0;
          //体力消費(Xi-P)の2乗を計算しminに加算
			for(int i=0; i<N; i++) {
			min += (X[i]-j)*(X[i]-j);
			}
          //answerにminとMAX_VALUEを比べ最小値を入れる
			answer = Math.min(min,answer);
		}
		System.out.println(answer);
	}		
}

Measured memory_bytes: 23120
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
     double a,b,C;
     cin>>a>>b>>C;
     cout << fixed << setprecision(6);
     double S=0.5*a*b*sin(M_PI*C/180);
     double c=sqrt(a*a+b*b-2*a*b*cos(M_PI*C/180));
     double L=a+b+c;
     double h=b*sin(M_PI*C/180);
     cout<<S<<" "<<L<<" "<<h<<endl;
      return 0;
    }


Measured memory_bytes: 3548
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int h, w, d;
    cin >> h >> w >> d;

    vector<vector<int>> a(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }

    vector<pair<int, int>> a2yx(h * w + 1);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            a2yx[a[i][j]] = make_pair(i, j);
        }
    }

    vector<int> a2pw(h * w + 1, 0);
    for (int i = h * w - d; i >= 0; i--) {
        a2pw[i] = a2pw[i + d]
                + abs(a2yx[i].first - a2yx[i + d].first)
                + abs(a2yx[i].second - a2yx[i + d].second);
    }

    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << a2pw[l] - a2pw[r] << endl;
    }
}


Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <ctime>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
#define enable_ll
#ifdef enable_ll
    #define int long long
#endif
#ifdef DEBUG
    #define out(u) cout<<u<<" "
    #define outln(u) cout<<u<<endl
    #define see(u) cout<<#u<<"="<<u<<" "
    #define seeln(u) cout<<#u<<"="<<u<<endl
    #define line cout<<"---------------------\n"
#else
    #define out(u)
    #define outln(u)
    #define see(u)
    #define seeln(u)
    #define line
#endif
#define m_p make_pair
#define pii pair<int,int>
#define piii pair<pii,int>
#define sz(x) (int)x.size()
#define fastio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
template <class T> void read(T &u)
{
    u=0; char c=getchar(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=getchar();
    while (c>='0'&&c<='9') u=(u<<3)+(u<<1)+(c^48),c=getchar();
    if (flag) u=-u;
}
template <class T> void write(T u)
{
    if (u<0) printf("-"),u=-u;
    if (u<10) putchar(48+u);
    else write(u/10),putchar(48+u%10);
}
void write(char u){putchar(u);}
template <class T,class ... Arg> void read(T &u,Arg&... v) {read(u); read(v...);}
template <class T,class ... Arg> void write(T u,Arg... v) {write(u); write(v...);}
template <class T> bool checkmin(T &a,T b){return (b<a ? a=b,1 : 0);}
template <class T> bool checkmax(T &a,T b){return (b>a ? a=b,1 : 0);}
template <class T> T _min(T a,T b){return (a<b ? a : b);}
template <class T> T _max(T a,T b){return (a>b ? a : b);}
const int N=100005;
int n,m,d;
void init()
{
    read(n,m,d);
    for (int i=1;i<=n;++i)
    {
        for (int j=1;j<=m;++j)
        {
            //cout<<i+j-2<<" "<<i-j+m-1<<endl;
        }
    }
}

void solve()
{
    //cout<<n<<" "<<m<<" "<<d<<endl;
    for (int i=1;i<=n;++i)
    {
        for (int j=1;j<=m;++j)
        {
            //cout<<i+j<<" "<<i-j<<endl;
            int x=i+j-2,y=i-j+m-1;
            if ((x/d)&1)
            {
                if ((y/d)&1) printf("R");
                else printf("G");
            }
            else
            {
                if ((y/d)&1) printf("Y");
                else printf("B");
            }
        } printf("\n");
    }
}

#undef int
int main()
{
    int T=1;
    //read(T);
    while (T--)
    {
        init();
        solve();
    }
    return 0;
}

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


class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    //-1で初期化。最初はすべてバラバラ
    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているか(Aの根)を調べる
    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
        return -parent[root(A)];
    }

    //AとBをくっつける
    bool unite(int A, int B) {
    //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        //既にくっついているからくっつけない
        if(A == B) return false; 

        //大きいほう(A)に小さいほう(B)をくっつける
        //大小が逆ならひっくり返す
        if(size(A) < size(B)) swap(A,B);

        //Aのサイズを更新する
        parent[A] += parent[B];
        //Bの親をAに変更する
        parent[B] = A;

        return true;
    }

    //AとBが同じグループならtrueを返す
    bool same(int A, int B){
        return root(A)==root(B);
    } 
};


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

    int n,q;
    cin>>n>>q;
    UnionFind uni(n);
    for(int i=0;i<q;i++){
        int a,x,y;
        cin>>a>>x>>y;
        if(a==0) uni.unite(x,y);
        else cout<<uni.same(x,y)<<endl;;
    }
    

}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int main(){
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;
  //dp
  bool flg = true;
  vector<int> dp(N + 1, INF);
  dp[0] = 0;
  for (int i = 1; i <= N; i++){
    if (S[i] == '0'){
      int j = max(0, i - M);
      while (S[j] == '1'){
        j++;
      }
      if (j >= i){
        flg = false;
        break;
      } else {
        dp[i] = dp[j] + 1;
      }
    }
  }
  if (!flg){
    cout << -1;
  } else {
    int A = dp[N];
    //逆DP
    vector<int> dp2(N + 1, INF);
    dp2[N] = 0;
    for (int i = N - 1; i >= 0; i--){
      if (S[i] == '0'){
        int j = min(N, i + M);
        while (S[j] == '1'){
          j--;
        }
        dp2[i] = dp2[j] + 1;
      }
    }
    vector<int> R;
    int j = 0;
    for (int i = A - 1; i >= 0; i--){
      while (dp2[j] != i){
        j++;
      }
      R.push_back(j);
    }
    cout << R[0];
    for (int i = 1; i < A; i++){
      cout << ' ' << R[i] - R[i - 1];
    }
    /*
    cout << endl;
    for (int i = 0; i <= N; i++){
      cout << dp[i];
    }
    cout << endl;
    for (int i = 0; i <= N; i++){
      cout << dp2[i];
    }
    cout << endl;
    for (int i = 0; i < A; i++){
      cout << R[i];
    }
    cout << endl;
    */
  }
}

Measured memory_bytes: 1912
from sys import stdin
X, Y = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
tmp = 10**9+7
P = set(list(range(-200, 200))) - set(P)
P = list(P)
P.sort(reverse=True)


ans = 0
for i in P:
    if abs(X-i) <= tmp:
        ans = i
        tmp = abs(X-i)

print(ans)

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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for ( int64_t i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    int64_t ans = 0;
    int64_t count = 1;
    int64_t pos = 0;
    for ( int i = 0; i < N-1; ++i){
        ans = ans + A[pos];
        if ( count == 0 ) {
            count = 1;
        } else {
            count = 0;
            ++pos;
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

struct LIST{
	int number;
	struct LIST *next;
	struct LIST *pre;
}L;

void show(struct LIST *L,int n,int m){
	int count=0;
	while(L!=NULL){
		count++;
		printf("%d ",L->number);
		L=L->next;
		if(count==(n-m)){break;}
	}
	printf("\n");
}

void show_r(struct LIST *L,int n){
	int count=0;
	while(L!=NULL){
		count++;
		printf("%d ",L->number);
		L=L->pre;
		if(count==n){break;}
	}printf("\n");
}

void ADD(struct LIST *L,int n){
	struct LIST **add;

	add=(struct LIST**)malloc(sizeof(struct LIST*)*n);
	for(int i=1;i<n;i++){
		add[i]=(struct LIST*)malloc(sizeof(struct LIST));
		add[i]->next=NULL;
		add[i]->number=i;
		add[i]->pre=NULL;
	}

	L->next=add[1];
	for(int i=1;i<(n-1);i++){
		add[i]->next=add[i+1];
	}
	add[n-1]->next=L;

	L->pre=add[n-1];
	for(int i=(n-1);i>1;i--){
		add[i]->pre=add[i-1];
	}
	add[1]->pre=L;	
}

void DEL(struct LIST *L){
	L->pre->next=L->next;
	L->next->pre=L->pre;

}

void calc(struct LIST *L,int A[],int M,int B[]){
	struct LIST *now=L;
	struct LIST *tmp;
	for(int i=0;i<M;i++){
		if((A[i]%2)==0){
			for(int j=0;j<A[i];j++){
				now=now->next;
			}
		}else{
			for(int j=0;j<A[i];j++){
				now=now->pre;
			}
		}
		B[now->number]=0;
		tmp=now->next;
		DEL(now);
		now=tmp;
	}
}

int main(){
	int N,M,Q;
	int *A;
	int *B;
	int q;

	struct LIST L;
	L.number=0;
	L.next=&L;

	scanf("%d %d %d",&N,&M,&Q);
	A=(int*)malloc(sizeof(int)*M);
	for(int i=0;i<M;i++){
		scanf("%d",&A[i]);
	}
	B=(int*)malloc(sizeof(int)*N);
	for(int i=0;i<N;i++){B[i]=1;}

	ADD(&L,N);

	calc(&L,A,M,B);

	for(int i=0;i<Q;i++){
		scanf("%d",&q);
		if(B[q]==1){
			printf("1\n");
		}else{
			printf("0\n");
		}
	}


	return 0;
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

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

int main(void) {
  ll h;
  cin >> h;

  ll ans=0;
  ll mp=1;
  while(h>0){
    h/=2;
    ans+=mp;
    mp*=2;
  }

  prt(ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k>0){
        if(k%2==1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k/=2;
    }
    return ans;
}
int main()
{
	ll n, k;
  cin>>n>>k;
  vector<ll> div;
  for(ll i=1; i*i<=n; i++){
    if(n%i==0){
      div.push_back(i);
      if(i*i<n) div.push_back(n/i);
    }
  }
  sort(div.begin(), div.end());
  ll ct1[1350], ct[1350];
  for(int i=0; i<div.size(); i++){
    ct1[i]=powmod(k, (div[i]+1)/2);
    ct[i]=ct1[i];
    for(int j=0; j<i; j++){
      if(div[i]%div[j]==0){
        ct[i]-=ct[j];
        ct[i]+=MOD;
        ct[i]%=MOD;
      }
    }
  }
  ll ans=0;
  for(int i=0; i<div.size(); i++){
    if(div[i]%2!=0) ans+=(ct[i]*div[i]%MOD);
    else ans+=(ct[i]*div[i]%MOD*(ll)(5e8+4)%MOD);
    ans%=MOD;
  }
  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
s_rem = s
flag = 0
while len(s_rem) > 0:
    s_spl = s_rem[:5]
    if s_spl != "dream" and s_spl != "erase":
        flag = 1
        break
    s_rem = s_rem[5:]
    if s_rem[:1] == "":
        break
    elif s_spl == "dream" and (s_rem[:1] != "d" and s_rem[:1] != "e"):
        flag = 1
        break
    elif s_spl == "dream" and s_rem[:1] == "d":
        continue
    elif s_spl == "dream" and s_rem[:1] == "e":
        if s_rem[:5] == "erase":
            continue
        elif s_rem[:2] == "er":
            s_rem = s_rem[2:]
            continue
        else:
            flag = 1
            break
    elif s_spl == "erase" and (s_rem[:1] != "d" and s_rem[:1] != "e" and s_rem[:1] != "r"):
        flag = 1
        break
    elif s_spl == "erase" and s_rem[:1] == "r":
        s_rem = s_rem[1:]
        continue
    elif s_spl == "erase" and s_rem[:1] == "d":
        continue
    else:
        if s_rem[:5] == "erase":
            continue
        elif s_rem[:2] == "er":
            s_rem = s_rem[2:]
            continue
        else:
            flag = 1
            break

if flag == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
using namespace std;
int n;
double a[1010],tot=1,cnt;
double s;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	s=a[1];
	for(int i=2;i<=n;i++){
	   s+=a[i]*tot;
	   tot*=2;
	}
	while(n>1){
		s/=2;
		n--;
	}
	cout<<s;
	return 0;
}

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

using namespace std;

using ll = long long;

ll gcd(ll a, ll b) {
  while (b) {
    ll c = b;
    b = a % b;
    a = c;
  }
  return a;
}

ll lcm(ll a, ll b) {
  if (!a || !b) return 0;
  return a * b / gcd(a, b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = b - a + 1;
  ans -= b / c - (a - 1) / c;
  ans -= b / d - (a - 1) / d;
  ans += b / lcm(c, d) - (a - 1) / lcm(c, d);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3596
/*
  Vivek Rathi
  CSE 3rd Year
  MNNIT
  THUMB RULE - THINK FOR DP FIRST AND THEN GREEDY!!!
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define sz(x)	(ll)x.size()
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#define endl '\n'
//unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
//shuffle (foo.begin(), foo.end(), std::default_random_engine(seed));
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above-----------------------------------------------
vector<ll> v[1000001];
void sieve()
{
	for(ll i=2;i<=1000000;i++)
	{
		if(sz(v[i])!=0)
			continue;
		for(ll j=2;j*i<=1000000;j++)
		{
			v[i*j].pb(i);
		}
	}
	for(ll i=2;i<=1000000;i++)
	{
		if(sz(v[i])==0)
			v[i].pb(i);
	}
}
int main()
{
	boost
	sieve();
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll gcd=a[n-1];
	ll flag=0;
	for(ll i=n-2;i>=0;i--)
	{
		gcd=__gcd(gcd,a[i]);
	}
	if(gcd==1)
	{	
		flag=1;
	}
	ll flag2=0;
	map<ll,ll> m;
	for(ll i=n-1;i>=0;i--)
	{
		for(auto it:v[a[i]])
		{
			if(present(m,it))
			{
				flag2=1;
				break;
			}
			m[it]++;
		}
		if(flag2==1)
			break;
	}
	if(flag2==0&&flag==1)
	{
		cout<<"pairwise coprime"<<endl;
	}
	else if(flag2==1&&flag==1)
		cout<<"setwise coprime"<<endl;
	else
		cout<<"not coprime"<<endl;
	return 0;
}

Measured memory_bytes: 81024
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;cin>>n;
	rep(i,50000)
	{
		if((int)(i*1.08)==n)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
	
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll a[n],b[n],c[n];
    ll i,j;
    for(i=0;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<ll>> dp(n,vector<ll>(3,0));
    
    // base case;
    // in first day he can do anything his wish;
    
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    
    for(i=1;i<n;i++){
        dp[i][0] = a[i] + max(dp[i-1][1] , dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0] , dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0] , dp[i-1][1]);
    }
    cout << max(dp[n-1][0] , max (dp[n-1][1] , dp[n-1][2])) << endl;
}

Measured memory_bytes: 11172
n = int(input())
s = [int(input()) for _ in range(n)]
sum_s = sum(s)
if sum_s%10==0:
    s = sorted(s)
    for i in range(n):
        if s[i]%10!=0:
            sum_s -= s[i]
            break
    if sum_s%10==0:
        print(0)
    else:
        print(sum_s)
else:
    print(sum_s)

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

int main(){
  int A,B,C,X,count=0;
  cin >> A >> B >> C >> X;
  for(int i=0;i<A+1;i++){
    for(int j=0;j<B+1;j++){
      for(int k=0;k<C+1;k++){
        if(500*i+100*j+50*k==X){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}  

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int n,a[10001],i;
  int min,max;
  long long sum=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
  }
  min=a[0];
  max=a[0];
  for(i=0; i<n; i++){
    if(min>a[i])min=a[i];
    if(max<a[i])max=a[i];
    sum+=a[i];
  }
  printf("%d %d %ld\n",min,max,sum);
  return 0;
}



Measured memory_bytes: 2760
#include <iostream>

using namespace std;

double dp[51][5001];
int event[51][2];
int step[4];
int X,Y,Z;

int main(void){
	while( cin >> X >> Y >> Z,X|Y|Z){
		// initialize
		for(int i=0;i<4;i++)
			step[i]=0;
		for(int i=0;i<51;i++)
			for(int j=0;j<5001;j++)
				dp[i][j]=0.0;
		dp[0][0]=1.0;
		for(int i=0;i<51;i++)
			event[i][0]=event[i][1]=0;
		//	reading
		for(int i=0;i<X;i++)
			cin >> step[i];
		for(int i=0;i<Z;i++){
			int tmp;
			cin >> tmp;
			cin >> event[tmp][0] >>event[tmp][1];
		}
		for(int i=0;i<Y;i++){
			for(int j=0;j<=5000;j++){
				for(int k=0;k<X;k++){
					int root=i+step[k];
					if(root>=Y)
						dp[Y][j]+=dp[i][j]/X;
					else if(event[root][0]==1){
						if(root+event[root][1]>Y)
							dp[Y][j]+=dp[i][j]/X;
						else
							dp[root+event[root][1]][j]+=dp[i][j]/X;
					}else if(event[root][0]==2)
						dp[root][j+event[root][1]]+=dp[i][j]/X;
					else if(event[root][0]==3){
						if(event[root][1]<j)
							dp[root][j-event[root][1]]+=dp[i][j]/X;
						else
							dp[root][0]+=dp[i][j]/X;
					}else
						dp[root][j]+=dp[i][j]/X;
				}
			}
		}
		double exp=0.0;
		for(int i=0;i<=5000;i++)
			exp+=dp[Y][i]*i;
		cout << (int)exp << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n;
bool ok;
int main() {
	cin >> n;
	vector<ll> s(n), t(n);
	REP(i, n) {
		t[i] = i + 1;
		cin >> s[i];
	}
	if (s == t)ok = true;
	REP(i, n) {
		REP(j, n) {
			swap(s[i], s[j]);
			if (s == t)ok = true;
			swap(s[i], s[j]);
		}
	}
	cout << (ok ? "YES" : "NO") << endl;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
typedef pair<int, int> P;

P data[40];
int cnt[11];
int main(){
  int m, a, b, c, score;
  while(cin >> m && m){
    rep(i, m){
      score = 0;

      fill(cnt, cnt + 10, 0);
      cin >> data[i].second;
      rep(j, 10){
	cin >> a;
	score += a;
	rep(k, 10) if(cnt[k] > 0){
	  cnt[k]--;
	  score += a;
	}

	if(a == 10){

	  if(j != 9)cnt[j]+=2;
	  else{
	    cin >> b >> c;
	    score += b + c;
	    rep(k, 10)if(cnt[k]){
	      cnt[k]--;
	      score += b;
	    }
	  }
	  
	}else{

	  cin >> b;
	  score += b;
	  rep(k, 10) if(cnt[k] > 0){
	    cnt[k]--;
	    score += b;
	  }
	  if(a + b == 10){
	    if(j != 9)cnt[j]++;
	    else{
	      cin >> c;
	      score += c;
	    }
	  }
	}
      }
      data[i].first = -score;
    }
    sort(data, data + m);
    rep(i, m){
      cout << data[i].second << " " << -data[i].first << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int M, K;
    cin >> M >> K;
    if(M == 1){
        if(K == 0)  cout << 0 << ' ' << 0 << ' ' << 1 << ' ' << 1 << '\n';
        else    cout << -1 << endl;
        return 0;
    }
    if(K >= 1 << M){
        cout << -1 << endl;
        return 0;
    }
    cout << K << ' ';
    for(int i = 0; i < 1 << M; ++i){
        if(i == K)  continue;
        cout << i << ' ';
    }
    cout << K << ' ';
    for(int i = (1 << M) - 1; i >= 0; --i){
        if(i == K)  continue;
        cout << i << ' ';
    }
    cout << '\n';
}

Measured memory_bytes: 3640
#include<stdio.h>
int main (void) {
 
  int eatCount;
  int count = 15;
  int yen = 800;
  int reyen = 200;
  
  do {
  printf(""); scanf("%d", &eatCount);
  } while (eatCount < 1 && eatCount > 100);
  printf("%d", (eatCount * yen) - (eatCount / count * reyen) );
 
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <ccomplex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int k; cin >> k;
	vector<int> a = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cout << a[k - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int s_cnt = 0;
  int ans = 0;
  while(1){
    char c = getchar();
    if(c == 'S'){
      s_cnt++;
      ans++;
    }else if(c == 'T' && s_cnt > 0){
      s_cnt--;
      ans--;
    }else if(c == 'T'){
      ans++;
    }else{
      break;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
	ll r, D, x; cin >> r >> D >> x;
	rep(_, 0, 10) {
		x = r * x - D;
		cout << x << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

signed main() {
	string s;
	cin >> s;
	int a0 = 0;
	int a1 = 0;
	rep(i, s.size()) {
		if(s[i] - '0' == i % 2) {
			a0++;
		}
		else {
			a1++;
		}
	}
	cout << min(a0, a1) << endl;
}

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

int main() {

    int N, K;
    cin >> N >> K;

    int cnt = 0;
    rep(i, N)
    {
        int h;
        cin >> h;
        if (h >= K) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3568
#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 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);
    ll x; cin>>x;
    ll n = x/500; x%=500;
    ll m = x/5;
    cout<<n*1000+m*5<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    n=int(input())
    a=[int(input()) for _ in [0]*n]
    cnt=a[0]-1
    now=2
    for i in range(1,n):
        if a[i]==now:
            now+=1
        elif a[i]>now:
            cnt+=(a[i]-1)//now
    print(cnt)
main()

Measured memory_bytes: 7884
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  long h,w;
  cin >> h >> w; 

  if(h==1 || w==1) {
    cout << 1 << endl;
    return 0;
  }
  
  long x,y;
  int a,b;
  a = h%2;
  b = w%2;
  x = h/2;
  y = w/2;
  cout << x*y*2 + a*y + b*x + a*b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {
  int p,l,r;
};

Node T[MAX];
int n,D[MAX];

void print(int u) {
  cout<<"node "<<u<<": "<<flush;
  cout<<"parent = "<<T[u].p<<", "<<flush;
  cout<<"depth = "<<D[u]<<", "<<flush;
  if (T[u].p==NIL) {
    cout<<"root, "<<flush;
  } else if (T[u].l==NIL) {
    cout<<"leaf, "<<flush;
  } else {
    cout<<"internal node, "<<flush;
  }
  cout<<"["<<flush;
  int i,c;
  for (i=0,c=T[u].l; c!=NIL; i++,c=T[c].r) {
    if (i) {
      cout<<", "<<flush;
    }
    cout<<c<<flush;
  }
  cout<<"]"<<endl;
}
void rec(int u,int p) {
  D[u]=p;
  if (T[u].r!=NIL) {
    rec(T[u].r,p);
  }
  if (T[u].l!=NIL) {
    rec(T[u].l,p+1);
  }
}
int main() {
  cin>>n;
  for (int i=0; i<n; i++) {
    T[i].p=T[i].l=T[i].r=NIL;
  }
  int v,d,c,l;
  for (int i=0; i<n; i++) {
    cin>>v>>d;
    for (int j=0; j<d; j++) {
      cin>>c;
      if (j==0) {
        T[v].l=c;
      } else {
        T[l].r=c;
      }
      l=c;
      T[c].p=v;
    }
  }
  int r;
  for (int i=0; i<n; i++) {
    if (T[i].p==NIL) {
      r=i;
    }
  }
  rec(r,0);
  for (int i=0; i<n; i++) {
    print(i);
  }
  return 0;
}



Measured memory_bytes: 7616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define read(x) scanf("%d",&x)
int P,R,T;
int pp[305][305];
int rr[305];
class state{
public:
	int p[305][305];
	int r[305];
	inline bool off(int i){
		for (int j=1;j<=R;++j) if (p[i][j]) return 0;
		return 1;
	}
	inline bool on(int i){
		for (int j=1;j<=R;++j) if (p[i][j]) return 1;
		return 0;
	}
	inline bool available(int i){
		for (int j=1;j<=R;++j) if (p[i][j]>r[j]) return 0;
		return 1;
	}
	inline void release(int i){
		for (int j=1;j<=R;++j) r[j]+=pp[i][j];
	}
	inline bool judge(){// O(n^3)
		int p1[305][305],r1[305];
		rep(i,305) rep(j,305) p1[i][j]=p[i][j];
		rep(j,305) r1[j]=r[j];
		while(1){
			int cnt=0;
			for (int i=1;i<=P;++i) if (on(i)) ++cnt;
			if (!cnt){
				rep(i,305) rep(j,305) p[i][j]=p1[i][j];
				rep(j,305) r[j]=r1[j];
				return 1;
			}
			bool term=1;
			for (int i=1;i<=P;++i){
				if (off(i)) continue;
				if (available(i)){
					term=0;
					for (int j=1;j<=R;++j){
						r[j]-=p[i][j];p[i][j]=0;r[j]+=pp[i][j];
					}
					break;
				}
			}
			if (term){
				rep(i,305) rep(j,305) p[i][j]=p1[i][j];
				rep(j,305) r[j]=r1[j];
				return 0;
			}
		}
		
	}
	state operator = (const state& st){
		rep(i,305) rep(j,305) p[i][j]=st.p[i][j];
		rep(j,305) r[j]=st.r[j];
		return *this;
	}
};

int p_[200005],r_[200005];
map<int,state> m;
map<int,state>::iterator it;
int main(){
	std::ios::sync_with_stdio(false);
	cin>>P>>R>>T;
	for (int i=1;i<=R;++i){
		cin>>rr[i];m[0].r[i]=rr[i];
	}
	for (int i=1;i<=P;++i) for (int j=1;j<=R;++j){
		cin>>pp[i][j];m[0].p[i][j]=pp[i][j];
	}
	m[T]=m[0];
	for (int i=1;i<=T;++i){
		cin>>p_[i]>>r_[i];
		--m[T].p[p_[i]][r_[i]];
		--m[T].r[r_[i]];
	}
	for (int i=1;i<=P;++i) if (m[0].on(i)&&m[T].off(i)) m[T].release(i);
	if (m[T].judge()){
		cout<<-1<<endl;return 0;
	}
	if (!m[0].judge()){
		cout<<0<<endl;return 0;
	}
	int l=0,r=T;// l can, r can't
	while(r-l>1){
		int t=(l+r)/2;
		m[t]=m[l];
		for (int i=l+1;i<=t;++i){
			--m[t].p[p_[i]][r_[i]];
			--m[t].r[r_[i]];
		}
		for (int i=1;i<=P;++i) if (m[l].on(i)&&m[t].off(i)) m[t].release(i);
		if (m[t].judge()) l=t;
		else r=t;
	}
	cout<<r<<endl;
	for (int i=1;i<1e9;++i) r=r+1;
	
	return 0;
}


Measured memory_bytes: 12592
#include<stdio.h>
int main(){
	int mid[50],fin[50],r[100];
	for(int i=0;i<50;i++){
		scanf("%d %d %d",&mid[i],&fin[i],&r[i]);
		if(mid[i]==-1&&fin[i]==-1&&r[i]==-1)break;
		if(mid[i]==-1||fin[i]==-1)printf("F\n");
		else if((mid[i]+fin[i])>=80)printf("A\n");
		else if((mid[i]+fin[i])>=65&&(mid[i]+fin[i])<80)printf("B\n");
		else if((mid[i]+fin[i])>=50&&(mid[i]+fin[i])<65)printf("C\n");
		else if((mid[i]+fin[i])>=30&&(mid[i]+fin[i])<50){
			if(r[i]>=50)printf("C\n");
			else printf("D\n");
			
		}
		else if((mid[i]+fin[i])<30){
			printf("F\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2624
-- IO バージョン

import Control.Applicative
import Data.List


solve :: ([Int], [Int]) -> IO ()
solve (as, []) = return ()
solve (as, b : bs) = do
  let cs = insert b as
  putStrLn $ unwords $ map show $ cs ++ bs
  solve (cs, bs)

main :: IO ()
main = do
  _  <- getLine
  xs <- map read . words <$> getLine
  solve ([], xs)



Measured memory_bytes: 4144
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a;
    cin>>n>>m;
   if(n+m>=10)
   {
       cout<<"error"<<endl;
   }
   else
   {
       cout<<n+m<<endl;
   }
}


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

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

	vector<long long> even;
	vector<long long> odd;

	long long a;
	for (long long i = 1; i <= N; ++i) {
		cin >> a;
		if (i % 2 == 1) {
			odd.push_back(a);
		} else {
			even.push_back(a);
		}
	}

	vector<long long> b;
	if (N % 2 == 1) {
		for (long long i = odd.size() - 1; i >= 0; --i) {
			b.push_back(odd[i]);
		}
		for (long long i = 0; i < even.size(); i++) {
			b.push_back(even[i]);
		}
	} else {
		for (long long i = even.size() - 1; i >= 0; --i) {
			b.push_back(even[i]);
		}
		for (long long i = 0; i < odd.size(); ++i) {
			b.push_back(odd[i]);
		}
	}

	for (long long i = 0; i < b.size(); ++i) {
		cout << b[i] << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 6940
while True:
    w,h=map(int,input().split())
    if h==0 and w==0:
        break
    c=[list(map(int,input().split())) for _ in [0]*h]
    
    visit=[[c[i][j]==0 for j in range(w)] for i in range(h)]
    d=[(1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)]
    cnt=0    
    for i in range(h):
        for j in range(w):
            if visit[i][j]==True:
                continue
            q=[[i,j]]
            visit[i][j]=True
            while q:
                k,l=q.pop()
                for dx,dy in d:
                    if not ((0<=k+dx<h) and (0<=l+dy<w)):
                        continue
                    if visit[k+dx][l+dy]==True:
                        continue
                    q.append([k+dx,l+dy])
                    visit[k+dx][l+dy]=True
            cnt+=1            
    print(cnt)


Measured memory_bytes: 5772
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 105;
int n, m;
int niz[maxn];
ll sum;
int main()
{
	cin >> n >> m;
	for(int i=0;i<n;i++){
		cin >> niz[i];
		sum += niz[i];
	}
	double kol = 4 * m;
	double pom = sum / kol;
	int brojac = n;
	for(int i=0;i<n;i++){
		if(niz[i] < pom)brojac--;
	}
	if(brojac >= m)cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#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 LL long long
string s[2000];
int h,w;
int u[2001][2001],d[2001][2001],l[2001][2001],r[2001][2001];
int main(){
  cin>>h>>w;
  REP(i,h)cin>>s[i];
  REP(i,h){
    REP(j,w){
      if(s[i][j]=='#')l[i][j]=0;
      else if(j==0)l[i][j]=(s[i][j]=='#')?0:1;
      else l[i][j]=l[i][j-1]+1;
    }
  }
  REP(i,h){
    REP(j,w){
      if(s[i][w-1-j]=='#')r[i][w-1-j]=0;
      else if(j==0)r[i][w-1-j]=(s[i][w-1-j]=='#')?0:1;
      else r[i][w-1-j]=r[i][w-j]+1;
    }
  }
  REP(j,w){
    REP(i,h){
      if(s[i][j]=='#')u[i][j]=0;
      else if(i==0)u[i][j]=(s[i][j]=='#')?0:1;
      else u[i][j]=u[i-1][j]+1;
    }
  }
  REP(j,w){
    REP(i,h){
      if(s[h-1-i][j]=='#')d[h-1-i][j]=0;
      else if(i==0)d[h-1-i][j]=(s[h-1-i][j]=='#')?0:1;
      else d[h-1-i][j]=d[h-i][j]+1;
    }
  }
  /*
  REP(i,h){
    REP(j,w){
      cerr<<u[i][j]<<" ";
    }
    cerr<<endl;
  }
  REP(i,h){
    REP(j,w){
      cerr<<d[i][j]<<" ";
    }
    cerr<<endl;
  }
  REP(i,h){
    REP(j,w){
      cerr<<l[i][j]<<" ";
    }
    cerr<<endl;
  }
  REP(i,h){
    REP(j,w){
      cerr<<r[i][j]<<" ";
    }
    cerr<<endl;
  }
  */


  int ret=0;
  REP(i,h){
    REP(j,w){
      ret=max(ret,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3);
    }
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 66944
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	if(y==0)return x;
	else return __gcd(y,x%y);
	
}
int main(){
	int T;
	cin>>T;
	rep(i,T){
		ll A,B,C,D;
		cin>>A>>B>>C>>D;
		bool ans=true;
		if(A<B)ans=false;
		else{
			ll hoge=A-(max((A-C+B-1)/B,(ll)0))*B;
			//cout<<hoge<<endl;
			if(hoge<0)ans=false;
			else{
				if(D<B)ans=false;
				else{
					ll x=D-B;
					if(x>0){
						ll E=hoge+((C-hoge+x)/x)*x;
						ll fuga=E-B;
						ll F=fuga+((C-fuga+x)/x)*x;
						ll y=abs(E-F);
						ll dif=__gcd(y,x);
						//cout<<E<<" "<<F<<endl;
						if(E-(E-C-1)/dif*dif-B<0)ans=false;
					}
				}
			}
		}
		if(ans)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    while(true){
        int N, INF=100000000;
        cin >> N;
        if(N==0) break;
        int sum=0;
        if(1<N) sum=1;
        for(int i=2; i*i<=N; i++){
            if(N%i==0){
                if(i*i==N) sum+=i;
                else sum+=(i+N/i);
            }
        }
        cout << (N==sum ? "perfect number" : (N>sum ? "deficient number" : "abundant number")) << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  cout << min(n,k)*x+max(n-k,0)*y << endl;
}


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

struct point{
    double x,y;
};

void koch(int n, point a, point b){
    if (n == 0) {return;}
    
    point l,m,r;
    double th = M_PI * 60.0/180.0;
    l.x = (2.0*a.x + 1.0* b.x)/3.0;
    l.y = (2.0*a.y + 1.0* b.y)/3.0;
   
    r.x = (2.0*b.x + 1.0* a.x)/3.0;
    r.y = (2.0*b.y + 1.0* a.y)/3.0;
    
    m.x = (r.x - l.x)*cos(th) - (r.y - l.y)*sin(th) + l.x;
    m.y = (r.x - l.x)*sin(th) + (r.y - l.y)*cos(th) + l.y;
    
    koch(n-1,a,l);
    printf("%.8f %.8f\n", l.x, l.y);
    koch(n-1,l,m);
    printf("%.8f %.8f\n", m.x, m.y);
    koch(n-1,m,r);
    printf("%.8f %.8f\n", r.x, r.y);
    koch(n-1,r,b);
}

int main(){
    point a,b;
    int n;
    scanf("%d", &n);
    
    a.x = a.y = 0;
    b.x = 100;
    b.y = 0;
    printf("%.8f %.8f\n", a.x, a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n", b.x, b.y);
}

Measured memory_bytes: 2704
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N,D,X;
  cin >> N >> D >> X;
  
  vector<int>choco(N,0);
  
  for(int i=0;i<N;i++){
    cin >> choco[i];
  }
  
  for(int i=0;i<N;i++){
    choco[i] = (D + choco[i] - 1) / choco[i];
  }
  
  int total = 0;
  
  for(int i=0;i<N;i++){
    total += choco[i];
  }
  
  cout << total + X << endl;
  
  return 0;
}


Measured memory_bytes: 256