akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

vl a,b;
ll solve(ll n, ll x){
    if(n==0) return x;
    if(x<=1) return 0;
    if(x<=1+a[n-1]) return solve(n-1,x-1);
    return b[n-1]+1+solve(n-1,min(x-a[n-1]-2,a[n-1]));
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll n,x;
	cin>>n>>x;
	a=vl(n+1,0); a[0]=1;
	b=vl(n+1,0); b[0]=1;
	range(i,1,n+1){
	    a[i]=a[i-1]*2+3;
	    b[i]=b[i-1]*2+1;
	}
	cout<<solve(n,x)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define int long long
using namespace std;

signed main(){
    int n, A[200000]={0};
    cin >> n;
    for(int i=0;i<n;i++) cin >> A[i];
    int right=0;
    int sum=0;
    int ans=0;
    for(int left=0;left<n;left++){
        while(right<n&&((sum+A[right])==(sum ^ A[right]))){
            sum += A[right];
            right++;
        }
        ans += right-left;
        if(left==right) right++;
        else sum -= A[left];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cctype>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

bool isin(int i, int j){
    return i >= 0 && j >= 0 && i < h && j < w;
}

int main() {
    int n;
    while (cin >> n, n){
        VI l(n), t(n), r(n), b(n), x, y;
        REP(i,n){
            cin >> l[i] >> t[i] >> r[i] >> b[i];
            l[i] *= 2;
            t[i] *= 2;
            r[i] *= 2;
            b[i] *= 2;
            FOR(j,-1,1){
                x.push_back(l[i]+j);
                x.push_back(r[i]+j);
                y.push_back(b[i]+j);
                y.push_back(t[i]+j);
            }
        }
        sort(ALL(x));
        sort(ALL(y));
        x.erase(unique(ALL(x)), x.end());
        y.erase(unique(ALL(y)), y.end());
        REP(i,n){
            l[i] = find(ALL(x), l[i]) - x.begin();
            r[i] = find(ALL(x), r[i]) - x.begin();
            b[i] = find(ALL(y), b[i]) - y.begin();
            t[i] = find(ALL(y), t[i]) - y.begin();
        }
        h = x.size(), w = y.size();

        VVI a(h, VI(w)), f(h, VI(w));
        REP(i,n){
            FOR(j,b[i],t[i]) a[l[i]][j] = a[r[i]][j] = 1;
            FOR(j,l[i],r[i]) a[j][b[i]] = a[j][t[i]] = 1;
        }

        int ans = 0;
        REP(i,h) REP(j,w){
            if (!a[i][j] && !f[i][j]){
                ans++;
                queue<P> que;
                que.push(P(i,j));
                while (!que.empty()){
                    P p = que.front();
                    que.pop();
                    int x = p.first, y = p.second;
                    if (f[x][y]) continue;
                    f[x][y] = 1;
                    REP(k,4){
                        int xx = x + dx[k], yy = y + dy[k];
                        if (!isin(xx,yy) || a[xx][yy] || f[xx][yy]) continue;
                        que.push(P(xx,yy));
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3568
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			var ny = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = ny[0];
			int y = ny[1];

			for (int i = 0; i <= n; i++) {
				for (int j = 0; j <= n; j++) {
					int k = n - i - j;
					if (k < 0) {
						continue;
					}

					int val = i * 10000 + j * 5000 + k * 1000;
					if (val == y) {
						Console.WriteLine($"{i} {j} {k}");
						return;
					}
				}
			}

			Console.WriteLine("-1 -1 -1");
		}
	}
}

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

int main() {
	string S;
	cin >> S;
	int result = 0;
	for (int i = 0; i < 4; i++) {
		if (S[i] == '+') result++;
		else if (S[i] == '-') result--;
	}
	cout << result << endl;
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            if ((line[0] == "0") && (line[1]=="0"))goto readend;
            var h = int.Parse(line[0]);
            var w = int.Parse(line[1]);
            var s1 = "";
            var s2 = "";
            for (int i = 0; i < w; i++) s1 += "#";
            for (int i = 0; i < w-2; i++) s2 += ".";
            s2 = "#" + s2 + "#";
            Console.WriteLine(s1);
            for (int i = 0; i < h - 2;  i++)
                Console.WriteLine(s2);
            Console.WriteLine(s1);
            Console.WriteLine();
        }
        readend:;
    }
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int N = S.size(), K = T.size();
  vector<string> ans;
  
  for (int i = 0; i < N - K + 1; i++) {
    bool R = true;
    for (int j = 0; j < K; j++) {
      if (S.at(i + j) != '?' && S.at(i + j) != T.at(j)) R = false;
    }
    if (R) {
      string A = S;
      for (int l = 0; l < A.size(); l++) {
        if (l >= i && l < i + K) A.at(l) = T.at(l - i);
        else if (A.at(l) == '?') A.at(l) = 'a';
      }
      ans.push_back(A);
    }
  }
  
  if (ans.size() == 0) cout << "UNRESTORABLE" << endl;
  else {
    sort(ans.begin(), ans.end());
    cout << ans.at(0) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define endl '\n'
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int M = 1e9 + 7;

int dp[65][2][2][2];

int32_t main()
{
	IO_OP;
	
	int L, R;
	cin >> L >> R;
	dp[60][0][0][0] = 1;
	for(int i=60;i>0;i--) {
		for(int j=0;j<2;j++) {
			for(int k=0;k<2;k++) {
				for(int l=0;l<2;l++) {
					if(!dp[i][j][k][l]) continue;
					// 0
					// 0
					if(R>>(i-1)&1) {
						if(L>>(i-1)&1) {
							if(k == 1)
								(dp[i-1][1][1][l] += dp[i][j][k][l]) %= M;
						} else {
							(dp[i-1][1][k][l] += dp[i][j][k][l]) %= M;							
						}
					}
					else {
						if(L>>(i-1)&1) {
							if(k == 1)
								(dp[i-1][j][1][l] += dp[i][j][k][l]) %= M;
						} else {
							(dp[i-1][j][k][l] += dp[i][j][k][l]) %= M;
						}
					}
					// 1
					// 1
					if(R>>(i-1)&1) {
						if(L>>(i-1)&1) {
							(dp[i-1][j][k][1] += dp[i][j][k][l]) %= M;
						} else {
							(dp[i-1][j][1][1] += dp[i][j][k][l]) %= M;
						}
					} else if(j == 1) {
						if(L>>(i-1)&1) {
							(dp[i-1][1][k][1] += dp[i][j][k][l]) %= M;
						} else {
							(dp[i-1][1][1][1] += dp[i][j][k][l]) %= M;
						}
					}
					// 1
					// 0
					if(l == 1) {
						if(R>>(i-1)&1) {
							if(L>>(i-1)&1) {
								if(k == 1)
									(dp[i-1][j][1][1] += dp[i][j][k][l]) %= M;
							} else {
								(dp[i-1][j][k][1] += dp[i][j][k][l]) %= M;
							}
						} else if(j == 1){
							if(L>>(i-1)&1) {
								if(k == 1)
									(dp[i-1][1][1][1] += dp[i][j][k][l]) %= M;
							} else {
								(dp[i-1][1][k][1] += dp[i][j][k][l]) %= M;
							}
						}
					}
				}
			}
		}
	}

	int ans = 0;
	for(int i=0;i<2;i++)
		for(int j=0;j<2;j++)
			ans += dp[0][i][j][1];
	cout << ans % M << endl;

	
}



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

using namespace std;

const int N = 105;
int a[N],b[N];

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
	cin >> n;
	for(int i=1;i<=n-1;i++) cin >> b[i];
	for(int i=1;i<=n;i++) a[i] = 1e5+5;
	int ans = 0;
	for(int i=1;i<=n-1;i++){
		if(a[i]>b[i]) a[i] = b[i];
		a[i+1] = b[i];
	}
	for(int i=1;i<=n;i++){
		ans += a[i];
	}
	cout << ans << endl;
    
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m;
	int cnt;
	int i;
	int x;
	cin>>n>>m;
	cnt=0;
	for(i=0;i<n;i++){
		cin>>x;
		if(x>=m)	cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

#ライブラリインポート
from collections import deque
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	H, W, A, B = getlist()
	for i in range(B):
		print("0" * A + "1" * (W - A))
	for i in range(H - B):
		print("1" * A + "0" * (W - A))


if __name__ == '__main__':
	main()

Measured memory_bytes: 6016
let () =
  let rec read l p =
    try let n = read_int () in
        if n != 0 then read (n::l) p
        else read (List.tl l) ((List.hd l)::p)
    with End_of_file ->
      List.rev p |> List.iter (fun x -> Printf.printf "%d\n" x)
  in read [] []
;;

Measured memory_bytes: 2300
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  int ans = 0;
  rep(i, n) {
    for (int j = i + 1; j < n; ++j) {
      int s = l[i] + l[j];
      int c = lower_bound(l.begin(), l.end(), s) - l.begin();
      ans += c - 1 - j;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2 + 2],R[MAX/2 +2];

void merge (struct Card A[], int n, int left, int mid, int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i = 0; i < n1; i++) L[i] = A[left + i];
  for(i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k = left; k < right; k++){
    if(L[i].value <=R[j].value){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
    }
  }
}
void mergeSort(struct Card A[], int n, int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r){
  int i,j;
  struct Card t,x;
  x = A[r];
  i =  p - 1;
  for( j = p; j < r; j++){
    if( A[j].value <= x.value){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i + 1];A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if( p < r){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q-1);
    quickSort(A, n, q +1, r);
  }
}
int main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s %d",S,&v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n -1);

  for(i = 0; i < n;  i++){
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if( stable == 1) printf("Stable\n");
  else printf("Not stable\n");
  for(i = 0; i < n; i++){
    printf("%c %d\n",B[i].suit, B[i].value);

  }

  return 0;
}
			 



Measured memory_bytes: 4196
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll cnt = 1;
  ll N;cin>>N;
  if(N<10){
    cout<<N<<endl;
  }
  else if(N<100){
    cout<<9<<endl;
  }
  else if(N<1000){
    cout<<N-90<<endl;
  }
  else if(N<10000){
    cout<<909<<endl;
  }
  else if(N<100000){
    cout<<N-9090<<endl;
  }
  else{
    cout<<90909<<endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void rotate(vector<int>& v, int a, int b, int c, int d){
  int t = v[a];
  v[a] = v[b];
  v[b] = v[c];
  v[c] = v[d];
  v[d] = t;
}
void rotate_x(vector<int>& v){
  rotate(v, 1, 2, 6, 5);
  rotate(v, 0, 3, 7, 4);
}
void rotate_y(vector<int>& v){
  rotate(v, 0, 1, 5, 4);
  rotate(v, 3, 2, 6, 7);
}
void rotate_z(vector<int>& v){
  rotate(v, 0, 1, 2, 3);
  rotate(v, 4, 5, 6, 7);
}
bool equal(const vector<int>& d, vector<int> e){
  for(int i = 0; i < 6; i++){
    if(i & 1) rotate_x(e);
    else rotate_y(e);
    for(int j = 0; j < 4; j++){
      rotate_z(e);
      if(d == e) return true;
    }
  }
  return false;
}
void all_insert(set< vector<int> >& s, vector<int> e){
  for(int i = 0; i < 6; i++){
    if(i & 1) rotate_x(e);
    else rotate_y(e);
    for(int j = 0; j < 4; j++){
      rotate_z(e);
      s.insert(e);
    }
  }
}
int main(){
  string line;
  while(getline(cin, line)){
    string s;
    stringstream ss(line);
    map<string, int> id;
    vector<int> d(8);
    REP(i, 8){
      ss>>s;
      if(id.count(s)){
        d[i] = id[s];
      }else{
        int t = id.size();
        d[i] = id[s] = t;
      }
    }
    sort(d.begin(), d.end());
    int ans = 0;
    set< vector<int> > check;
    do{
      bool ok = true;
      if(!check.count(d)){
        ans++;
        all_insert(check, d);
      }
    }while(next_permutation(d.begin(), d.end()));
    cout<<ans<<endl;
  }
  return 0;
}

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

using namespace std;

const int maxn = 5e5 + 10;

int n, a[maxn], w[maxn], par[maxn];
long long ans;

inline int F(int u) {
	return par[u] == u ? u : par[u] = F(par[u]);
}

struct Info {
	int u, c0, c1;

	Info() {}
	Info(int u, int c0, int c1): u(u), c0(c0), c1(c1) {}
} oo;

bool operator < (const Info &a, const Info &b) {
	return (long long) a.c1 * b.c0 < (long long) a.c0 * b.c1;
}

struct node {
	node *ch[2];
	Info x;

	node() {
		memset(ch, 0, sizeof ch);
	}

	void pull() {
		x = oo;
		for (int i = 0; i < 2; ++i) {
			if(ch[i] && ch[i]->x < x) {
				x = ch[i]->x;
			}
		}
		return;
	}
} *root;

Info seg_q;
int seg_i;

void B(node* &u = root, int l = 1, int r = n) {
	u = new node;
	if(l == r) {
		u->x = Info(l, w[l] == 0, w[l] == 1);
		return;
	}
	int mid = l + r >> 1;
	B(u->ch[0], l, mid);
	B(u->ch[1], mid + 1, r);
	return u->pull();
}

void M(node* &u = root, int l = 1, int r = n) {
	if(l == r) {
		ans += (long long) seg_q.c0 * u->x.c1;
		u->x.c1 += seg_q.c1;
		u->x.c0 += seg_q.c0;
		return;
	}
	int mid = l + r >> 1;
	if(seg_i <= mid) {
		M(u->ch[0], l, mid);
	}
	else {
		M(u->ch[1], mid + 1, r);
	}
	return u->pull();
}

void D(node* &u = root, int l = 1, int r = n) {
	if(l == r) {
		u->x = oo;
		return;
	}
	int mid = l + r >> 1;
	if(seg_i <= mid) {
		D(u->ch[0], l, mid);
	}
	else {
		D(u->ch[1], mid + 1, r);
	}
	return u->pull();
}

int main() {
#ifdef DEBUG
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif
	scanf("%d", &n);
	if(n == 1) {
		puts("0");
		return 0;
	}
	--n;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		--a[i];
		par[i] = i;
	}
	for (int i = 0; i <= n; ++i) {
		scanf("%d", w + i);
	}
	oo = Info(0, -1000000000, 1000000000);
	B();
	int c0 = 0, c1 = 0;
	for (int _ = 1; _ <= n; ++_) {
		Info t = root->x;
		int u = t.u, p = F(a[u]);
		if(!u) {
			while(1) {
				u += rand();
			}
		}
		par[u] = p;
		if(p) {
			seg_i = p;
			seg_q = t;
			M();
		}
		else {
			ans += (long long) t.c0 * c1;
			c0 += t.c0;
			c1 += t.c1;
		}
		seg_i = u;
		D();
	}
	if(w[0]) {
		ans += c0;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 22528
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://apc001.contest.atcoder.jp/tasks/apc001_c>
問題文============================================================
 N を 3 以上の奇数とします。
 
 N 個の席が円状に並んでいます。 席には 0 から N−1 まで番号が振られています。
 各 i (0≤i≤N−2) について、席 i と席 i+1 は隣り合っています。 また、席 N−1 と席 0 は隣り合っています。
 
 各席の状態は「空席」「男性が座っている」「女性が座っている」のどれかです。
 ただし、同性どうしが隣り合う席に座っていることはありません。
 N が 3 以上の奇数の場合、空席が少なくとも 1 つは存在することが示せます。
 
 あなたには N のみが与えられ、各席の状態は与えられません。
 あなたの目標は、どれか 1 つの空席の番号を当てることです。
 そのために、あなたは次のクエリを繰り返し送ることができます。
 
 整数 i (0≤i≤N−1) を選ぶ。 席 i が空席ならば、正答となる。
 そうでなければ、席 i に座っている人の性別が知らされる。
 クエリを高々 20 回まで送ることで、どれか 1 つの空席の番号を当ててください。
 
 N は奇数である。
 3≤N≤99,999
=================================================================

解説=============================================================

 r - l is even then l,r が異性 => Vを含む
 r - l is odd then l,r が同性 => Vを含む
 
 の条件でにぶたん
================================================================
*/

bool c(ll m){
    cout << m << endl;
    string s; cin >> s;
    if(s == "Vacant") exit(0);
    else if(s == "Female") return 0;
    else return 1;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll l = 0, r = N - 1;
    bool ff = c(l);
    while(r - l > 1){
        ll m = (r + l)/2;
        bool f = c(m);
        if(((m&1)^ff)!=f) r = m-1;
        else l = m+1;
    }
    
    c(l); c(l+1); c(r);
	return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	long N, M;
	cin >> N >> M;
	
	vector<pair<long, long>> drink(N);
	
	for (long i = 0; i < N; i++)
	{
		long A, B;
		cin >> A >> B;
		drink[i] = make_pair(A, B);
	}
	
	// 昇順にソート
	sort(drink.begin(), drink.end());
	
	long answer = 0;
	long count = 0;
	for (long i = 0; i < N; i++)
	{
		answer += drink[i].first * min(drink[i].second, M - count);
		count += min(drink[i].second, M - count);
		if (count == M)
		{
			break;
		}
	}
	
	// 出力
	cout << answer << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#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()

typedef long long lint;

using namespace std;

int main(){
  lint K,A,B;
  cin>>K>>A>>B;
  if(A>=B-1 or K<A){
    cout<<K+1<<endl;
    return 0;
  }
  lint S=1;
  K-=A-1;
  S=A;
  S+=K/2*(B-A);
  if(K%2==1)S+=1;
  cout<<S<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void){

  
 string S, ans;

 cin >> S ;

if(S == "Sunny"){
  ans = "Cloudy";
} else if(S == "Cloudy"){
  ans = "Rainy";
} else {
  ans = "Sunny";
} 

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


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

typedef long long ll;

ll f(ll a, ll b) {
	if (b % a == 0) return 2 * b - a;
	if (a % b == 0) return 2 * a - b;
	if (a < b) {
		return 2 * a * (b / a) + f(b % a, a);
	}
	else {
		return 2 * b * (a / b) + f(a % b, b);
	}
}

int main() {
	//freopen("in.txt", "r", stdin);
	ll n, x;
	cin >> n >> x;
	cout << n + f(x, n - x);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
vector <int> bio[30];
long long f(vector <int> a, vector <int> b)
{
    int s = 0, i1 = 0, i2 = 0;
    long long r = 0;
    if(a.size() % 2 == 1)
    {
        swap(a, b);
    }
    vector <int> ap;
    while(i1 < a.size() || i2 < b.size())
    {
        if(i2 >= b.size() || (i1 < a.size() && a[i1] < b[i2]))
        {
            ap.push_back(s);
            i1++;
        }
        else
        {
            i2++;
        }
        s++;
    }
    for(int i = 0; i < a.size() / 2; i++)
    {
        int x = ap[i], y = a.size() + b.size() - 1 - ap[a.size()-1-i];
        r += abs(x-y);
    }
    return r;
}
int main()
{
    string t;
    cin >> t;
    for(int i = 0; i < t.size(); i++)
    {
        bio[t[i]-'a'].push_back(i);
    }
    int n = 0;
    for(int i = 0; i < 26; i++)
    {
        if(bio[i].size() % 2 == 1)
        {
            n++;
        }
    }
    if(n > t.size() % 2)
    {
        cout << -1 << endl;
        return 0;
    }
    long long z = 0;
    for(int i = 0; i < 26; i++)
    {
        for(int j = i+1; j < 26; j++)
        {
            z += f(bio[i], bio[j]);
        }
    }
    cout << z << endl;
    return 0;
}


Measured memory_bytes: 3864
#include <iostream>
using namespace std;
int main(void){
    
    int A, B, C;
    cin >> A >> B >> C;
    
    if(A == B && B != C ){
        cout << "Yes" << endl;
    }
    else if(A != B && B == C){
        cout << "Yes" << endl;
    }
    else if(A == C && C != B){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    

}


Measured memory_bytes: 3104
def calculate(S):
    arr = list(S)

    if len(arr) == 0:
        return 0

    if len(arr) == 1:
        return 1

    N = len(arr)

    tmp = 1
    for i in range(1,N):
        if arr[i] != arr[i-1]:
            tmp = tmp + 1
    return tmp

N = input()
S = input()
res = calculate(S)
print(res)

Measured memory_bytes: 4084
#include<stdio.h>

int judge(int,int);

int memo[1000001];

int main(void){
  int n,m,i,count;

  for(i=0;i<1000001;i++)
    memo[i]=-1;
  
  memo[0]=1;
  memo[1]=0;

  while(scanf("%d",&n),n){
      scanf("%d",&m);

    count=0;
    for(i=n;i<=m;i++){
      if(judge(i,1)==0){
	memo[i]=0;
	count++;
      }
    }
    printf("%d\n",count);
  }
  return 0;
}

int judge(int x,int fg){

  if(x%2==0)judge(x/2,2);
  else if(x%3==0)judge(x/3,3);
  else if(x%5==0)judge(x/5,5);

  if(memo[x]==0){
    memo[x*fg]=0;
    return 0;
  }
  return memo[x]=1;
}

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

int main()
{
  int A, B;
  cin >> A >> B;
  if(A == B)
  {
    cout << "Draw" << endl;
  }
  else if(A == 1)
  {
    cout << "Alice" << endl;
  }
  else if(B == 1)
  {
    cout << "Bob" << endl;
  }
  else if(A > B)
  {
    cout << "Alice" << endl;
  }
  else
  {
    cout << "Bob" << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

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

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

bool check_1(int* a, int* b, int n)
{
    for (int i=0;i<n;i++)
    {
        if (a[i]!=b[i])
        {
            return false;
        }
    }
    return true;
}
int main()
{
    start();
    int n;
    cin>>n;
    int t[n];
    for (int i=0;i<n;i++)
    {
        t[i]=i+1;
    }
    int a[n];
    for (int i=0;i<n;i++)
    {
        a[i]=t[i];
    }
    int b[n], c[n];
    for (int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for (int i=0;i<n;i++)
    {
        cin>>c[i];
    }

    int d=0;
    do
    {
        d++;
        if (check_1(a, b, n))
        {
            break;
        }
    } while (next_permutation(a, a + n));
    int e=0;
    for (int i=0;i<n;i++)
    {
        a[i]=t[i];
    }
    do
    {
        e++;
        if (check_1(a, c, n))
        {
            break;
        }
    } while (next_permutation(a, a + n));
    cout<<abs(e-d);
    return 0;
}

Measured memory_bytes: 3560
#include<stdio.h>
#include<math.h>
int main(void){
    int N,i,j,box,count=0;
    double tri[3]={0};
    scanf("%d",&N);
    while(count<N){
        scanf("%lf %lf %lf",&tri[0],&tri[1],&tri[2]);
        for(i=0;i<2;i++){
            for(j=i+1;j<3;j++){
                if(tri[i]>tri[j]){
                    box=tri[i];
                    tri[i]=tri[j];
                    tri[j]=box;
                }
            }
        }
        tri[0]=pow(tri[0],2.0);
        tri[1]=pow(tri[1],2.0);
        tri[2]=pow(tri[2],2.0);
        
        if(tri[0]+tri[1]==tri[2]){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
        count++;
    }
return 0;
}

Measured memory_bytes: 612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
//begin
template <class T>
class SqrtDecompositionRangeAddRangeSum
{
private:
  int N, K;
  int sqrtN;
  vector<T> data;
  vector<T> bucket_sum;
  vector<T> bucket_add;

public:
  SqrtDecompositionRangeAddRangeSum(int n) : N(n), K(0), sqrtN(1)
  {
    while (sqrtN * sqrtN <= N)
    {
      sqrtN++;
    }
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, 0);
    bucket_sum.assign(K, 0);
    bucket_add.assign(K, 0);
  }
  // [s, t)
  void add(int s, int t, T x)
  {
    int p = s / sqrtN;
    int q = t / sqrtN;
    for (int k = p; k <= q; ++k)
    {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t)
      {
        bucket_add[k] += x;
      }
      else
      {
        for (int i = max(s, l); i < min(t, r); ++i)
        {
          data[i] += x;
          bucket_sum[k] += x;
        }
      }
    }
  }
  // [s, t)
  T get_sum(int s, int t)
  {
    int p = s / sqrtN;
    int q = t / sqrtN;
    T sum = 0;
    for (int k = p; k <= q; ++k)
    {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t)
      {
        sum += bucket_sum[k] + bucket_add[k] * sqrtN;
      }
      else
      {
        for (int i = max(s, l); i < min(t, r); ++i)
        {
          sum += data[i] + bucket_add[k];
        }
      }
    }
    return sum;
  }
  T get_value(int i)
  {
    int k = i / sqrtN;
    return data[i] + bucket_add[k];
  }
};
//end
int main()
{
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    SqrtDecompositionRangeAddRangeSum<ll> decomp(N);
    while (Q--)
    {
        int c;
        cin >> c;
        if (c == 0)
        {
            int s, t, x;
            cin >> s >> t >> x;
            decomp.add(s, t + 1, (long long)x);
        }
        else
        {
            int s, t;
            cin >> s >> t;
            cout << decomp.get_sum(s, t + 1) << endl;
        }
    }
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    cout << (b % a == 0 ? (a + b) : (b - a)) << endl;

    return 0;
}


Measured memory_bytes: 256
import collections

def insert_card(card_number, card_list):
    i = 0
    while i < card_number:
        card_list.append(input())
        i += 1


blue_card_number = int(input())
blue_card_list = []
insert_card(blue_card_number, blue_card_list)

red_card_number = int(input())
red_card_list = []
insert_card(red_card_number, red_card_list)

blue_card_collection = collections.Counter(blue_card_list)
red_card_collection = collections.Counter(red_card_list)

result_card_collection = blue_card_collection - red_card_collection

answer_collection = sorted(result_card_collection.items(), key=lambda x:x[1], reverse=True)
if answer_collection == []:
    print(0)
else:
    print(answer_collection[0][1])


Measured memory_bytes: 3316
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <iostream>
#define mod 998244353
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535898
using namespace std;

int main()
{
	long double a,b;
	long double x;
	cin>>a>>b>>x;
	long double s=a*a*b/2;
	long double num=0;
	if(x<=s)
	{
		long double h=(x*2)/(b*a);
		num=(atan(b/h)/PI)*180;
	}
	else if(x>s)
	{
		long double h =((a*a*b-x)*2)/(a*a);
		num=(atan(h/a)/PI)*180;
	}
	printf("%0.10llf\n",num);
}

Measured memory_bytes: 256
def main():
    A, B, K = map(int, input().split(' '))
    if A < B:
        A, B = B, A
    cnt = 0
    result = -1

    for b in range(B, 0, -1):
        if B % b == 0:
            if A % b == 0:
                cnt += 1
                if cnt == K:
                    result = b
                    break
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
      String[] t=sc.nextLine().split(" ");
 
//    String nyuA=sc.nextLine();
 //  String nyuB=sc.nextLine();

//int n=Integer.parseInt(nyu);

int H=Integer.parseInt(t[0]);
int W=Integer.parseInt(t[1]);
//long H=Long.parseLong(t[0]);
//long W=Long.parseLong(t[1]);
//long C=Long.parseLong(t[2]);

//boolean[][] data=new boolean[H][W];

String[][] list=new String[H][W];
String[][] listnew=new String[H*2][W*2];

for(int i=0;i<H;i++){
String[] temp=sc.nextLine().split("");
for(int j=0;j<W;j++){

list[i][j]=temp[j];
}
}
/*
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
System.out.print(list[i][j]);
}
System.out.println();
}
System.out.println();

*/



for(int i=0;i<2*H;i++){
for(int j=0;j<W;j++){

listnew[i][j]=list[i/2][j];
}
System.out.println();
}


for(int i=0;i<2*H;i++){
for(int j=0;j<W;j++){
System.out.print(listnew[i][j]);
}
System.out.println();
}

	}
}

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

int main(){
   int n; cin>>n;
   int x[n];
   int y[n];
   ll h[n];

REP(i,n)cin>>x[i]>>y[i]>>h[i];
int CX,CY;
ll H=0;

REP(cx,101){
  REP(cy,101){
    bool check=true;
    int count=0;
     REP(i,n){
       if(h[i]!=0){
         if(count==0)H=abs(x[i]-cx)+abs(y[i]-cy)+h[i]; //Hをリセット
         else if(H!=abs(x[i]-cx)+abs(y[i]-cy)+h[i])check=false; //
         
       count++;
       }
    } 
      REP(i,n){//このHがh＝０の場合の条件を満たすかどうか
       if(h[i]==0&&H>abs(x[i]-cx)+abs(y[i]-cy))check=false;
      }
     if(check){
      CX=cx;
      CY=cy;
      goto loopend;
     }
  }
}
 loopend:
  cout<<CX<<" "<<CY<<" "<<H<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct linklist *list;
struct linklist{
 int key;
 list next;
 list back;
};
list head;
list tail;
void init(void){
 head = (list)malloc(sizeof(*head));
 tail = head;
 tail->next = NULL;
}
void insert(int k){
 list x;
 x = (list)malloc(sizeof(*x));
 x->next = head;
 x->key = k;
 x->back = NULL;
 head->back = x;
 head = x;
// printf("insert\n");
 return;
}
void delete(int k){
 list x;
 list ins;
 x = head;
// printf("delete\n");
 if(head->key==k){
  head = head->next;
  head->back = NULL;
  free(x);
  return;
 }
 while(x->next!=tail){
  if((x->next)->key==k){
   ins = x->next;
   x->next = ins->next;
   ins->next->back = x;
   free(ins);
   return;
  }else{
   x = x->next;
  }
 }
 return;
}
void deleteFirst(void){
 list ins;
 ins = head;
 head = head->next;
 head->back = NULL;
 free(ins);
 return;
}
void deleteLast(void){
 list x;
 list ins;
 x = tail;
 tail = tail->back;
 tail->next = NULL;
 free(x);
 return;
}
int main(int argc, char argv[]){
 int n;
 char command[20] = "\0";
 int d;
 list x;
 init();
 scanf("%d",&n);
 int i,j;
 for(i=0;i<n;i++){
  scanf("%s %d",command,&d);
  if(!strcmp(command,"insert"))insert(d);
  else if(!strcmp(command,"delete"))delete(d);
  else if(!strcmp(command,"deleteFirst"))deleteFirst();
  else if(!strcmp(command,"deleteLast"))deleteLast();
  else printf("The command does not exist.\n");
 }
 x = head;
 if(x!=tail)printf("%d",x->key);
 x = x->next;
 while(x != tail){
  printf(" ");
  printf("%d",x->key);
  x = x->next;
 }
 printf("\n");
 return 0;
}

Measured memory_bytes: 32920
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n;
    cin >> n;
    int a[n];
    repi(i,n,0){
        cin >> a[i];
    }
    sort(a,a+n,greater<int>());
    int A = 0,B = 0;
    repi(i,n,0){
        if(i%2)B+=a[i];
        else A+=a[i];
    }
    cout << A - B << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

void greatFirst(int& a, int& b)
{
  if(a < b)
  {
    int tmp = a;
    a = b;
    b = tmp;
  }
}

int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  int dist[n];
  x--;
  y--;
  greatFirst(x, y);
  memset(dist, 0, sizeof(int)*n);
  rep(i,n)
  {
    for(int j = i+1; j < n; j++)
    {
       int tmp = min(min(
         j-i,
         abs(i-x) + 1 + abs(y-j)),
         abs(i-y) + 1 + abs(x-j)
         );
       dist[tmp]++;
    }
  }
  
  rep(i,n-1)
  {
    cout << fixed << dist[i+1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int x = 9;
      for (int i = 1; x != 0; i++) {
        x = sc.nextInt();
        if (x == 0) {
          break;
        }
        System.out.println("Case " + i + ": " + x);
      }

      sc.close();
  }
}


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

nums = list(map(int,input().split()))

ans = nums[0]

for i in range(N):
    if nums[i] == 0:
        print("0")
        exit()

for x in range(N - 1):
    ans = ans * nums[x + 1]
    if ans > 1000000000000000000:
        print("-1")
        exit()
        
print(ans)


Measured memory_bytes: 21784
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		for(;;){
			int N=Integer.parseInt(cin.nextLine());
			if(N==0)break;
			
			int[][] a = new int[N][2];
			for(int i=0;i<N;i++){
				String[] s =cin.nextLine().split(" ");
				int[] b = new int[s.length-1];
				a[i][0]=Integer.parseInt(s[0]);
				int frame=1;
				for(int j=1;j<s.length;j++){
					b[j-1]=Integer.parseInt(s[j]);
				}
				for(int j=0;j<b.length;){
					if(frame==10){
						a[i][1]+=b[j];
						j++;
						continue;
					}
					a[i][1]+=b[j]+b[j+1];
					if(b[j]==10){
						a[i][1]+=b[j+2];
						j++;
					}
					else{
						if(b[j]+b[j+1]==10){
							a[i][1]+=b[j+2];
						}
						j+=2;

					}
					frame++;
				}
//				System.out.println(a[i][1]);
			}
			Arrays.sort(a,new Comparator<int[]>(){
				public int compare(int[] a,int[] b){
					if(a[1]==b[1]){
						return a[0]-b[0];
					}
					return b[1]-a[1];
				}
			});
			
			for(int i=0;i<N;i++){
				System.out.println(a[i][0]+ " " + a[i][1]);
			}
		}
	}
	
}

Measured memory_bytes: 23660
import java.util.*;

public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		 while(true) {
        int H = sc.nextInt();
        int W = sc.nextInt();
        if(H == 0 && W == 0) {
        	break;
        }
        for(int i =0;i < H;i++){
            for(int j = 0; j < W;j++){
                if((i + j) % 2 == 0 ){
                    System.out.print("#");
                }else {
                	System.out.print(".");
                }
            }
            System.out.println();
        }
        System.out.println();
		}
    }
}


Measured memory_bytes: 34896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int R = scan.nextInt();
		scan.close();
		
		String str = "";
		if (R >= 2800) {
			str = "AGC";
		} else if (R >= 1200) {
			str = "ARC";
		} else {
			str = "ABC";
		}
		System.out.print(str); 
	}
}

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

main()
{
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n,i,j,k;
	cin>>n;
    vector<pair<string,int> >v(4);
    v[0].first="AC";
    v[1].first="WA";
    v[2].first="TLE";
    v[3].first="RE";
    for(i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s=="AC")
        {
            v[0].second++;
        }
        else if(s=="WA")
        {
              v[1].second++;
        }
        else if(s=="TLE")
        {
              v[2].second++;
        }
        else
        {
              v[3].second++;
        }
    }
    for(i=0;i<v.size();i++)
    {
        cout<<v[i].first<<" x "<<v[i].second<<endl;
    }
    
    

}




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

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	bool flag = true;
	int count = 0;

	while (true)
	{
		for (int i = 0; i < n; i++)
		{
			if (a.at(i) % 2 != 0)
			{
				flag = false;
				break;
			}
			else
			{
				a.at(i) /= 2;
			}
		}
		if (!flag)
		{
			break;
		}
		count++;
	}

	cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int sx, sy, tx, ty, diffx, diffy;
    cin >>sx >>sy >>tx >>ty;
    diffx = tx - sx;
    diffy = ty - sy;
    //1回
    for(int i = 0; i < diffx; i++){
        cout << "R";
    }
    for(int i = 0; i < diffy; i++){
        cout << "U";
    }
    //2回
    for(int i = 0; i < diffx; i++){
        cout << "L";
    }
    for(int i = 0; i < diffy; i++){
        cout << "D";
    }
    //3回
    cout << "D";
    for(int i = 0; i < diffx + 1; i++){
        cout << "R";
    }
    for(int i = 0; i < diffy + 1; i++){
        cout << "U";
    }
    cout << "L";
    //4回
    cout << "U";
    for(int i = 0; i < diffx + 1; i++){
        cout << "L";
    }
    for(int i = 0; i < diffy + 1; i++){
        cout << "D";
    }
    cout << "R";
    cout << endl;



}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main(){
	double s[1001];
	int n,i;
	double w=0,tw=0;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%lf",&s[i]);
			w+=s[i];
		}
		w/=(double)n;
		for(i=0;i<n;i++)tw+=pow(s[i]-w,2.0);
		tw/=(double)n;
		printf("%lf\n",sqrt(tw));
		w=0;
		tw=0;
	}
	return 0;
}



Measured memory_bytes: 2024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int H, A;
    cin >> H >> A;
    output((H + A - 1) / A);
    
    return 0;
}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 998244353
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAX = 1000005;
int fac[MAX], inv[MAX], finv[MAX];

int modpow(int x, int n, int m) {
    if (n == 0) return 1%m;
    long long u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}

void pre(){
  inv[1]=1;
  for (int i = 2; i <MAX ; i++)
  {
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
  }
  fac[0]=finv[0]=1;
  for (int i = 1; i < MAX; ++i)
  {
    fac[i]=fac[i-1]*i%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
int ncr(int n, int r){
  if(r<0||r>n)return 0;
  return fac[n]*finv[r]%mod*finv[n-r]%mod;
}

int n,m,k;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  pre();
  cin >> n >> m >> k;
  int ans = 0;
  for(int i=0;i<=k;i++){
    int cur = ncr(n-1,i)*m%mod;
    int rem = n-1-i;
    cur = cur*modpow(m-1,rem,mod)%mod;
    ans = (ans + cur )%mod;
  }
  cout << ans << endl;


return 0;
}
///....


Measured memory_bytes: 27052
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 10000000001
using namespace std;

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

  string s,t;
  cin>>s>>t;
  ll n=s.length();
  ll m=t.length();
  ll dp[n+1][m+1];
  for(ll i=0;i<=n;i++)
  {
    for(ll j=0;j<=m;j++)
    {
      if(i==0||j==0)
      {
        dp[i][j]=0;
      }
      else if(t[j-1]==s[i-1])
      {
        dp[i][j]=dp[i-1][j-1]+1;
      }
      else
      {
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }
  string ans="";
  ll i=n,j=m;
  while(i>0 && j>0)
  {
    if(dp[i][j]==dp[i-1][j])
    {
      i--;
    }
    else if(dp[i][j]==dp[i][j-1])
    {
      j--;
    }
    else
    {
      i--;
      j--;
      ans+=s[i];
    }
  }
  reverse(ans.begin(),ans.end());
  cout<<ans;
}


Measured memory_bytes: 70656
import collections
n = int(input())
v = list(map(int, input().split()))
ve = v[0::2]
vo = v[1::2]
# print(ve,vo)

ce=collections.Counter(vo).most_common(2)
co=collections.Counter(ve).most_common(2)

if(ce[0][0] != co[0][0]):
    ans = len(v) - ce[0][1] - co[0][1]
elif(len(ce)==1 and len(co)==1):
    ans = len(v) // 2
elif(len(ce)==1):
    ans = len(v) // 2 - co[1][1]
elif(len(co)==1):
    ans = len(v) // 2 - ce[1][1]
else:
    ans = len(v) - max( ce[0][1]+co[1][1], ce[1][1]+co[0][1])

print(ans)


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

vector< vector < int > > adjList;
vector< int > depths;

void bfs(void) {
  queue< int > currentLevel;
  queue< int > nextLevel;
  nextLevel.push(1);
  int depth = 0;
  while (nextLevel.size()) {
    while (nextLevel.size()) {
      currentLevel.push(nextLevel.front());
      nextLevel.pop();
    }
    while (currentLevel.size()) {
      if (depths[currentLevel.front()-1] == -1) {
	depths[currentLevel.front()-1] = depth;
	for (int i = 0; i < adjList[currentLevel.front()-1].size(); i++)
	  nextLevel.push(adjList[currentLevel.front()-1][i]);
      }
      currentLevel.pop();
    }
    depth++;
  }
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  adjList = vector< vector < int > > (n, vector< int > ());
  depths = vector< int > (n, -1);
  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int holder;
      cin >> holder;
      adjList[i].push_back(holder);
    }
  }
  bfs();
  for (int i = 0; i < n; i++)
    cout << i+1 << ' ' << depths[i] << endl;
  return 0;
}



Measured memory_bytes: 3256