akhauriyash/Code-Regression huggingface dataset:
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll e = (c*d)/__gcd(c,d);
    ll n = b-a+1;
    
    ll n_cid,n_c,n_d;

    if(a%e==0)  n_cid = (b/e - a/e)+1;
    else        n_cid = b/e - a/e;

    if(a%c==0)  n_c = (b/c - a/c)+1;
    else        n_c = b/c - a/c;

    if(a%d==0)  n_d = (b/d - a/d)+1;
    else        n_d = b/d - a/d;

    ll res = n - (n_c + n_d - n_cid);

    cout<<res<<endl;
    /*
    if(a%e==0)  i=a;
    else        i=a+e-(a%e);
    //ll m=2;
    while(i<=b){
        cnt++;
        i+=e;
      //  m++;
    }

    if(a%c==0)  i=a;
    else        i=a+c-(a%c);
    //m=2;
    while(i<=b){
       if(i%e!=0)   cnt++;
        i+=c;
      //  m++;
    }

    if(a%d==0)  i=a;
    else        i=a+d-(a%d);
    //m=2;
    while(i<=b){
        if(i%e!=0)  cnt++;
        i+=d;
        //m++;
    }
    ll res = n-cnt;
    cout<<res<<endl;
    */
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=100000+10;
int ans[maxn],d[maxn*2],fa[maxn*2],h[maxn*2],now[maxn*2],go[maxn*6],nxt[maxn*6],sta[maxn*6];
bool bz[maxn*6],czy;
int i,j,k,l,r,s,t,n,m,tot,top,rot1,rot2;
/*int read(){
    int x=0,f=1;
    char ch=getchar();
    while (ch<'0'||ch>'9'){
        if (ch=='-') f=-1;
        ch=getchar();
    }
    while (ch>='0'&&ch<='9'){

    }
}*/
void add(int x,int y){
    go[++tot]=y;
    nxt[tot]=h[x];
    h[x]=tot;
}
void dfs(int x,int y){
    int t=h[x];
    while (t){
        if (go[t]!=y){
            dfs(go[t],x);
            d[x]^=1;
        }
        t=nxt[t];
    }
    d[x]^=1;
}
void travel(int x){
    int t=now[x];
    while (t=now[x]){
        now[x]=nxt[t];
        if (!bz[(t+1)/2]){
            bz[(t+1)/2]=1;
            //now[x]=nxt[t];
            travel(go[t]);
        }
    }
    sta[++top]=x;
}
int main(){
    scanf("%d",&n);
    fo(i,1,n){
        scanf("%d",&fa[i]);
        if (fa[i]==-1){
            fa[i]=0;
            rot1=i;
        }
        else{
            add(fa[i],i);
            add(i,fa[i]);
        }
    }
    fo(i,n+1,2*n){
        scanf("%d",&fa[i]);
        if (fa[i]==-1){
            fa[i]=0;
            rot2=i;
        }
        else{
            add(fa[i]+n,i);
            add(i,fa[i]+n);
        }
    }
    dfs(rot1,0);
    dfs(rot2,0);
    czy=1;
    fo(i,1,n)
        if (d[i]^d[i+n]){
            czy=0;
            break;
        }
    if (!czy){
        printf("IMPOSSIBLE\n");
        return 0;
    }
    printf("POSSIBLE\n");
    s=0;
    add(s,rot1);
    add(rot1,s);
    add(s,rot2);
    add(rot2,s);
    fo(i,1,n)
        if (d[i]){
            add(i,i+n);
            add(i+n,i);
        }
    fo(i,s,2*n) now[i]=h[i];
    travel(s);
    fo(i,1,n)
        if (d[i]) ans[i]=-1;
    fo(i,1,top-1)
        if (sta[i]>0&&sta[i]<=n&&sta[i+1]==sta[i]+n) ans[sta[i]]=1;
    fo(i,1,n) printf("%d ",ans[i]);
}

Measured memory_bytes: 20352
#include<iostream>
#include<math.h>
#include<vector>
#include<map>


using namespace std;
int main()
{  
    int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0 and c>0){
		if((c-b)<=0){
			cout<<"Yes"<<endl;
			break;
		}else{
			c -= b;
		}
		if((a-d)<=0){
			cout<<"No"<<endl;
			break;
		}else{
			a -= d;
		}
	}
	
	
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[])
{
  std::string S;
  std::cin >> S;

  std::vector<std::string> cand_strs = {
    "dream",
    "dreamer",
    "erase",
    "eraser"
  };

  int i = int(S.length()) - 1;
  while(i >= 0)
  {
    for (int j = 0; j < int(cand_strs.size()); j++)
    {
      std::string cand_str = cand_strs.at(j);
      int cand_str_len = int(cand_str.length());
      int S_sub_str_head = i - (cand_str_len - 1);

      if (S_sub_str_head < 0)
        continue;

      std::string S_sub_str = S.substr(S_sub_str_head, cand_str_len);

      if (cand_str == S_sub_str)
      {
        if (!S_sub_str_head)
        {
          std::cout << "YES" << std::endl;
          return 0;
        }
        i -= cand_str_len;
        break;
      }

      if (j == int(cand_strs.size()) - 1)
      {
        std::cout << "NO" << std::endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 512
n,m = map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for _ in range(m)]
bc.sort(key=lambda x:x[1], reverse=True)

for b,c in bc:
  a.extend([c]*b)
  if len(a) > n*2:
    break

a.sort(reverse=True)
print(sum(a[:n]))

Measured memory_bytes: 34760
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int ans;
map<int, vector<int> > x,y;
set<PII> visit;
int n,w,h;

void DFS(int fx, int fy){
	if(EXIST(visit, MP(fx,fy)))return;
	visit.insert(MP(fx,fy));
	REP(i,x[fx].size()){
		if(x[fx][i]!=fy)DFS(fx, x[fx][i]);
	}
	REP(i,y[fy].size()){
		if(y[fy][i]!=fx)DFS(y[fy][i], fy);
	}
}

int main(){
	cin>>n>>w>>h;
	ans = n-1;
	int flag = 0,cnt=0;
	REP(i,n){
		int tx, ty;
		scanf("%d%d", &tx,&ty);
		x[tx].PB(ty);
		y[ty].PB(tx);
		if(tx==1||ty==1||tx==w||ty==h)flag=1;
	}
	for(map<int, vector<int> >::iterator it=x.begin(); it!=x.end(); it++){
		if(!EXIST(visit, MP(it->first, it->second[0]))){
			DFS(it->first, it->second[0]);
			cnt++;
		}
	}
	if(cnt!=1){
		if(flag==0){
			ans+=cnt;
		}else{
			ans+=cnt-1;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    for(int i=0;i<S.length();i++){
        if(i%2==0){
            if(S[i]!='R'&&S[i]!='U'&&S[i]!='D'){
                cout << "No";
                break;
            }
        }
        else{
            if(S[i]!='L'&&S[i]!='U'&&S[i]!='D'){
                cout << "No";
                break;
            }
        }
        if(i==S.length()-1) cout << "Yes";
    }
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

N, M, Q = map(int, input().split())
E = [list(map(int, input().split())) for i in range(Q)]
f = [i for i in range(N)]
def find(x):
    if x != f[x]:
        f[x] = find(f[x])
    return f[x]
def union(x, y):
    fx, fy = find(x), find(y)
    if fx == fy:    return False
    f[fx] = fy
    return True
   
E1 = []
for a, b, c in E:
    if c == 0:
        union(a, b)
    else:
        E1.append((a, b))

par = [find(x) for x in range(N)]
for a, b in E1:
    if par[a] == par[b]:
        print('No')
        exit()
C = len(set(par))

if len(E1) == 0:
    if N - 1 <= M <= (N - C) + C * (C - 1) // 2:
        print("Yes")
    else:
        print("No")

else:
    if N <= M <= (N - C) + C * (C - 1) // 2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 45448
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define ll long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#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 red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    double l;
    cin>>l;
    printf("%.8f\n",(l/3.0)*(l/3.0)*(l/3.0));
    return 0;
}












Measured memory_bytes: 256
import numpy as np
N,K = map(int,input().split())
q = list(map(int,input().split()))
q = np.array(q)

p = (q + 1) /2
p = p.tolist()
a = sum(p[:K])
mx = a

for i in range(0,N-K):
    a = a - p[i] + p[i+K]
    if a > mx:
        mx = a

print(mx)

Measured memory_bytes: 33848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
vector<bool> make_is_prime(int N) {
    vector<bool> prime(N + 1, true);
    if (N >= 0) prime[0] = false;
    if (N >= 1) prime[1] = false;
    for (int i = 2; i * i <= N; i++) {
        if (!prime[i]) continue;
        for (int j = i * i; j <= N; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}
int main() {
    int x;
    cin >> x;
    int ans;
    vector<bool> p;
    p = make_is_prime(1e5 + 5);
    for (int i = x; i < 1e5 + 5; i++) {
        if (p[i]) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e6 + 9;

int _;

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

//========================================================================
int main()
{
    int n;
    scanf("%d",&n);
    if(n>=30) puts("Yes");
    else puts("No");
    
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  ll a, b;
  cin>>a>>b;
  if ((b % a) == 0) {
    cout<<-1<<endl;
    return 0;
  }
  FOR(i,1,a) {
    ll v = b * i;
    ll cnt = (v + a - 1) / a;
    ll rem = (a * cnt) % b;
    if (rem + i > cnt) {
      cout << (a * cnt) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

ll dp[65][3];

int main() {
	ll N;
	cin >> N;
	vector<bool> trans;

	while (N > 0) {
		if (N & 1) { trans.insert(trans.begin(), 1); }
		else { trans.insert(trans.begin(), 0); }
		N >>= 1;
	}

	dp[0][0] = 1;
	for (int keta = 0; keta < trans.size(); keta++) {
		for (int j = 0; j < 3; j++) {
			dp[keta][j] %= MOD;
			if (trans[keta] == 0) {
				if(j * 2 - 2 >= 0)dp[keta + 1][min(2, j * 2 - 2)] += dp[keta][j];//(1, 1)
				if(j * 2 - 1 >= 0)dp[keta + 1][min(2, j * 2 - 1)] += dp[keta][j];//(1, 0)
				dp[keta + 1][min(2, 2 * j)] += dp[keta][j];//(0, 0)
			}
			else {
				dp[keta + 1][min(2, j * 2 + 1)] += dp[keta][j];//(0, 0)
				dp[keta + 1][min(2, j * 2)] += dp[keta][j];//(1, 0)
				if(j * 2 - 1 >= 0)dp[keta + 1][min(2, 2 * j - 1)] += dp[keta][j];//(1, 1)
			}
		}
	}

	cout << (dp[trans.size()][0] + dp[trans.size()][1] + dp[trans.size()][2]) % MOD << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i,count[4]={0,0,0,0};
  scanf("%d",&n);
  char s[n][4];
  for(i=0;i<n;i++)
    scanf("%s",s[i]);

  for(i=0;i<n;i++){
    if(s[i][0]=='A'&&s[i][1]=='C')
      count[0]++;
    else if(s[i][0]=='W'&&s[i][1]=='A')
      count[1]++;
    else if(s[i][0]=='T'&&s[i][1]=='L'&&s[i][2]=='E')
      count[2]++;
    else
      count[3]++;
  }

    printf("AC x %d\n",count[0]);
    printf("WA x %d\n",count[1]);
    printf("TLE x %d\n",count[2]);
    printf("RE x %d",count[3]);
  
}

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

int cnt, a[23][23];  //black : 0, red : 1

void dfs(int x, int y){
    cnt++;
    a[x][y] = 1;
    if(!a[x + 1][y]) dfs(x + 1, y);
    if(!a[x - 1][y]) dfs(x - 1, y);
    if(!a[x][y + 1]) dfs(x, y + 1);
    if(!a[x][y - 1]) dfs(x, y - 1);
    return;
}

int main(){
    while(1){
        int i, j, w, h, si, sj;
        char in;
        cin >> w >> h;
        if(w == 0)break;
        
        cnt = 0;
        for(i = 0; i <= h + 1; i++){
            a[i][0] = a[i][w + 1] = 1;
        }
        for(j = 0; j <= w + 1; j++){
            a[0][j] = a[h + 1][j] = 1;
        }
       
        i = 1;
        j = 1;
        while(i <= h){
            while(j <= w){
                cin >> in;
                //cout << "~~" << endl;
                if(in == '.'){
                   a[i][j] = 0;
                   j++; 
                }else if(in == '#'){
                    a[i][j] = 1;
                    j++;
                }else if(in == '@'){
                    si = i;
                    sj = j;
                    a[i][j] = 1;
                    j++;
                }
                //cout << j << endl;
            
            
            
            }
            i++;
            j = 1;
        }
        dfs(si, sj);
        cout << cnt << endl;
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    int aa, bb, cc;
    rep(i, n) {cin >> a[i];}
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];
    int ans = 0;
    rep(i, n) ans += b[a[i]-1];
    rep(i, n-1) {
        if (a[i]+1 == a[i+1]) ans += c[a[i]-1];
    }
    cout << ans << endl;
    return 0;
}

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

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

    int a[200];
    for (int i=0; i<n; i++){
        cin >> a[i];
    }

    int ans = 0;
    bool flag = true;

    while (flag) {
        for (int i=0; i<n; i++){
            if (a[i] % 2 == 0) {
                a[i] /= 2;
            } else {
                flag = false;
                break;
            }
        }

        if (flag) {
            ans++;
        }
    }

    cout << ans;
    //cout << "\n";
}

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

using ll = long long;

int main(){
    int n;
    cin >> n;
    string s[100005];
    rep(i,n){
        string t;
        cin >> t;
        sort(t.begin(),t.end());
        s[i] = t;
    }
    sort(s,s+n);
    int it = 0;
    ll ans = 0;
    while(1){
        if(it + 1 >= n) break;
        ll cnt = 1;
        while(s[it] == s[it+1]){
            cnt++;
            it++;
            if(it == n) break;
        }
        it++;
        ans += cnt*(cnt-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 1;

int main() {
  ll L, N, ans = -1;
  cin >> L >> N;
  vi Xs(N), Ys(N);
  vi sum_X(N+1, 0), sum_Y(N+1, 0);
  for (int i = 0; i < N; i++) {
    cin >> Xs[i]; Ys[N-i-1] = L - Xs[i];
  }
  for (int i = 0; i < N; i++) {
    sum_X[i+1] = sum_X[i] + Xs[i];
    sum_Y[i+1] = sum_Y[i] + Ys[i];
  }
  for (int i = 1; i <= N; i++) {
    int R = (N-i)/2, L = (N-i+1)/2;
    ll ans_R = 2*(sum_X[R+i] - sum_X[i-1]) + 2*sum_Y[L];
    ll ans_L = 2*(sum_Y[R+i] - sum_Y[i-1]) + 2*sum_X[L];
    ans_R -= ((N-i)&1) ? Ys[L-1] : Xs[R+i-1];
    ans_L -= ((N-i)&1) ? Xs[L-1] : Ys[R+i-1];
    ans = max(ans, ans_R);
    ans = max(ans, ans_L);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()
if s == "ABC":
    print("ARC")
else:
    print("ABC")

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

int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x>=r&&y>=r&&x+r<=W&&y+r<=H) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3108
import sys
from itertools import permutations
n = int(input())
a = [0] + list(map(int, input().split()))
if n == 2:
	print(-1)
	sys.exit()
used = [False for _ in range(n+1)]
hate = dict()
for x in a[1:]:
	if x in hate:
		hate[x] += 1
	else:
		hate[x] = 1
cur = 1
ng = 0
ans = []
while len(ans) < n-3:
	if len(hate) == 2:
		worst = False
		for k, v in hate.items():
			if v == n - len(ans) - 1 and not used[k]:
				worst = k
				break
		if worst:
			ans.append(k)
			used[k] = True
			ng = a[k]
			hate[a[k]] -= 1
			if hate[a[k]] == 0:
				del hate[a[k]]
			continue

	while used[cur]:
		cur += 1

	if cur == ng:
		cur_copy = cur+1
		while used[cur_copy]:
			cur_copy += 1
		ans.append(cur_copy)
		used[cur_copy] = True
		ng = a[cur_copy]
		hate[ng] -= 1
		if hate[ng] == 0:
			del hate[ng]
	else:
		ans.append(cur)
		used[cur] = True
		ng = a[cur]
		hate[ng] -= 1
		if hate[ng] == 0:
			del hate[ng]

yet = [i for i in range(1, n+1) if not used[i]]
for p in permutations(yet):
	if p[0] != ng and p[1] != a[p[0]] and p[2] != a[p[1]]:
		ans += list(p)
		break

print(*ans)

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

int main(){
    string s;
    cin >> s;

    int pos_a;
    int pos_z;
    for (int i=0; i < s.length(); i++){
        if (s[i] == 'A'){
            pos_a = i;
            break;
        }
    }
    for (int i=s.length()-1; i > 0; i--){
        if (s[i] == 'Z'){
            pos_z = i;
            break;
        }
    }
    cout << (pos_z - pos_a + 1) << endl;
}

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

typedef long long ll;
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

void DP_82(){
    ll a,b,ans=-1;
    cin>>a>>b;
    for(int i=1;i<=10*(b+1);i++){
        if(floor(i*0.08)==a && floor(i*0.1)==b){
            ans=i;break;
        }
    }
    cout<<ans<<endl;
}

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    DP_82();
    return 0;
}

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

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

	if(a+b==c or a+c==b or b+c==a){
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;

	return 0;
	
}

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

#define MAX 500001

int heap_size;

int Parent(int i){
  return i/2;
}
int Left(int i){
  return 2*i;
}
int Right(int i){
  return 2*i+1;
}

void maxHeapify(int A[],int i){
  int l,r,largest;
  int temp;
  
  l = Left(i);
  r = Right(i);
  

  if((l <= heap_size) && (A[l] > A[i])){
    largest = l;
  }
  else {
    largest = i;
  }
  
  if((r <= heap_size) && (A[r] > A[largest])){
    largest = r;
  } 
  
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    
    maxHeapify(A,largest);
  } 
}

void buildMaxHeap(int A[]){
  int i;

  for(i = heap_size/2 ; i >= 1 ; i--){
    maxHeapify(A,i);
  }
}

int main(void){
  int i,key[MAX];
  
  scanf("%d",&heap_size);
  
  for(i = 1 ; i <= heap_size ; i++){
    scanf("%d",&key[i]);  
  }
  
  buildMaxHeap(key);
  
  for(i = 1 ; i <= heap_size ; i++){
    printf(" %d",key[i]);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 2360
#include <iostream>

using namespace std;

int main()
{
	//int total = 0; // test
	
	int n;
	while ( cin >> n ) {
		int count;
		if (n>36) count = 0;
		else if (n<=9) count = ((n+1)*(n+2)*(n+3))/6;
		else if (n<=18) count = ((n+1)*(n+2)*(n+3))/6 - 4*((n-9)*(n-8)*(n-7))/6;
		// 220 - ((n-10+1)*(n-10+2)*(n-10+3))/6 + \sum_{k=10}^n { (k+1)(k+2)/2 - 3*(k-9)(k-8)/2 }
		// 220 - ((n-10+1)*(n-10+2)*(n-10+3))/6 + \sum_{k=10}^n { -k^2 + 27k - 107 }
		// 220 - ((n-10+1)*(n-10+2)*(n-10+3))/6 + \sum_{k=1}^n { -k^2 + 27k - 107 } - \sum_{k=1}^9 { -k^2 + 27k - 107 }
		// 220 - ((n-9)*(n-8)*(n-7))/6        - n(n+1)(2n+1)/6      + 27 * n(n+1)/2   - 107n    - 9*10*11/6 + 27*9*10/2 - 107*9
		// 220 - (n^3 - 24n^2 + 191n - 504)/6 - (2n^3 + 3n^2 + n)/6 + (27n^2 + 27n)/2 - 107n    - 165 + 1215 - 963
		// 307 - (3n^3 - 21n^2 + 192n - 504)/6                      + (81n^2 + 81n)/6 - 642n/6
		// 307 - (3n^3 - 102n^2 + 753n - 504)/6
		// 307 - (n^3  -  34n^2 + 251n - 168)/2
		// (-n^3 + 34n^2 - 251n + 782)/2 
		
		// 220  + \sum_{k=10}^n { (k+1)(k+2)/2 } - 4 * ((n-10+1)*(n-10+2)*(n-10+3))/6
		// \sum_{k=1}^n { (k+1)(k+2)/2 }         - 4 * ((n-10+1)*(n-10+2)*(n-10+3))/6
		else if (n<=27) count = ((37-n)*(38-n)*(39-n))/6 - 4*((27-n)*(28-n)*(29-n))/6;
		else count = ((37-n)*(38-n)*(39-n))/6;
		
		cout << count << endl;
		
		//total += count; // test
	}
	
	//cout << "total = " << total << endl; // test
	
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
string s;
int n;
int dp[100010][2];
int main() {
    cin.tie(0); cin.sync_with_stdio(0);
    cin >> s;
    n = s.length();
    for (int i = 0; i <= n; i++) {
        dp[i][0] = n + 1;
        dp[i][1] = n + 1;
    }
    dp[0][0] = dp[0][1] = 0;
    dp[1][0] = (s[0] != '0');
    dp[1][1] = (s[0] != '1');
    for (int i = 2; i <= n; i++) {
        int cur = s[i - 1] - '0';
        int prev = s[i - 2] - '0';
        if (cur == prev) {
            dp[i][cur] = dp[i - 1][prev ^ 1];
            dp[i][cur ^ 1] = dp[i - 1][prev] + 1;
        } else {
            dp[i][cur] = dp[i - 1][prev];
            dp[i][cur ^ 1] = dp[i - 1][prev ^ 1] + 1;
        }
    }
    cout << min(dp[n][0], dp[n][1]);
}

Measured memory_bytes: 1232
def calc(K):
    l = [i for i in range(1, 10)]
    n = 9
    while True:
        if n >= K:
            return l[K - 1]
        K -= n
        newl = []
        n = 0
        for x in l:
            d = x % 10
            newl += [x * 10 + y for y in [d - 1, d, d + 1] if y > -1 and y < 10]
            n += (2 if (d == 0 or d == 9) else 3)
            if n >= K:
                return newl[K - 1]
        l = newl


K = int(input())
print(calc(K))

Measured memory_bytes: 6276
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int main(){
	int n;
	vector<int> ans;
	stack<int> a;
	while (cin >> n) {
		if (n > 0)a.push(n);
		else if (n == 0) {
			int temp;
			temp = a.top();
			ans.push_back(temp);
			a.pop();
		}
	}
	for (int i = 0; i < ans.size(); i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>
#include <ctype.h>

int stack[102]; int top;
char buf[2000];

int main()
{
	int  v1, v2;
	char *p;

	fgets(p=buf, 500, stdin);
	top = 0;
	while (*p >= ' ') {
		while (isspace(*p)) p++;
		if (isdigit(*p)) {
			v1 = 0;
			while (isdigit(*p)) v1 = 10*v1 + (*p++ & 0xf);
			stack[top++] = v1;
		} else {
			v1 = stack[--top];
			v2 = stack[--top];
			if      (*p == '+') v2 += v1;
			else if (*p == '-') v2 -= v1;
			else if (*p == '*') v2 *= v1;
			stack[top++] = v2;
			p++;
		}
	}
	printf("%d\n", stack[--top]);
	return 0;
}



Measured memory_bytes: 2148
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if ((b-a) == (c-b))System.out.println("YES");
		else System.out.println("NO");
	}
}

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

int main() {
  vector<int> V2, V3, V6;
  for(int i = 2; i <= 30000; i++) {
    if((i % 2) == 0 and (i % 3) != 0) V2.push_back(i);
    else if((i % 2) != 0 and (i % 3) == 0)  V3.push_back(i);
    else if((i % 6) == 0) V6.push_back(i);
  }

  int n;
  cin>>n;
  if(n == 3) {
    cout<<"2 5 63\n";
    return 0;
  }
  n -= 4;
  set<int> ans;
  ans.insert(2);
  ans.insert(4);
  ans.insert(3);
  ans.insert(9);
  if(n >= V2.size() - 2) {
    for(int i = 2; i < V2.size(); i++) {
      ans.insert(V2[i]);
    }
    n -= V2.size() - 2;
  } else {
    for(int i = 0; i < n - (n % 2); i++) {
      ans.insert(V2[i + 2]);
    }
    n = (n % 2);
  }
  
  if(n >= V3.size() - 2) {
    for(int i = 2; i < (int)V3.size(); i++) {
      ans.insert(V3[i]);
    }
    n -= V3.size() - 2;
  } else {
    for(int i = 0; i < n - (n % 2); i++) {
      ans.insert(V3[i + 2]);
    }
    n = (n % 2);
  }

  for(int i = 0; i < n; i++) {
    ans.insert(V6[i]);
  }

  for(auto v : ans) cout<<v<<" ";
  cout<<endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> p(M);
    rep(i,M){
        cin >> p[i].first >> p[i].second;
    }
    sort(ALL(p),greater<>());
    int ans = 0;
    int l = N+5;
    rep(i,M){
        if(l>p[i].second){
            l = p[i].first + 1;
            ans ++ ;
        }
    }
    cout << ans << endl;
}

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

int main(){
	int n, k, ans = 0;
	scanf("%d %d", &n, &k);
	for(int i=0; i<n; i++){
		int x;
		scanf("%d", &x);
		ans += std::min(x, k-x) * 2;
	}
	printf("%d\n", ans);
}


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

int main(void){
    int N, i;
    double eve;

    scanf("%d", &N);
    double x[N];
    char array_u[N][3];
    for (i = 0; i < N; i++){
        scanf("%lf %c%c%c", &x[i], &array_u[i][0], &array_u[i][1], &array_u[i][2]);
    }
    eve=0.0;
    for (i = 0; i < N; i++){
        if (array_u[i][0]=='J'&&array_u[i][1]=='P'&&array_u[i][2]=='Y'){
            eve+=x[i];
        }else{
            eve+=x[i]*380000.0;
        }
    }
    printf("%f\n", eve);    
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {
  
  string S; cin >> S;
  int K; cin >> K;

  int N = S.size();

  // aにできるなら先頭から、できないなら後ろから

  rep(i, N) {
    if(S[i] == 'a') continue;
    if(K > 26 || (int)S[i] + K % (26 * 2) > (int)'z') {
      K -= 'z' - S[i] + 1;
      S[i] = 'a';
    }
  }
  
  S.back() = ((S.back() - 'a') + K) % 26 + 'a';

  cout << S << endl;

  return 0;
}

Measured memory_bytes: 512
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D
# Shell Sort
# Result:
import sys
import math

def insertion_sort(ary, g):
    cnt = 0
    ary_len = len(ary)
    for i in range(g, ary_len):
        v = ary[i]
        j = i - g
        while (j >= 0 and ary[j] > v):
            ary[j + g] = ary[j]
            j -= g
            cnt += 1
        ary[j + g] = v
    return cnt

def shell_sort(ary):
    ary_len = len(ary)
    gs = []
    v = ary_len
    while v > 0:
        gs.append(v)
        v >>= 1
    m = len(gs)

    cnt = 0
    for i in range(0, m):
        cnt += insertion_sort(ary, gs[i])
    return [m, gs, cnt]

lines = sys.stdin.readlines()
ary_len = int(lines.pop(0))
ary = map(int, lines)
assert ary_len == len(ary)

m, gs, cnt = shell_sort(ary)
print m
print ' '.join(map(str, gs))
print cnt
for v in ary:
    print v

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

int main(){
    int flag=1;
    string s;
    int ans=700;

    cin >>s;

    if(s[0]=='o')ans+=100;
    if(s[1]=='o')ans+=100;
    if(s[2]=='o')ans+=100;
    
    cout << ans <<endl;
    //cout <<fixed<<setprecision(16)<< ans <<endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑


ll n, k[100005], mon, ans;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
	}
	reverse(k, k + n);

	for (int i = 1; i < n; ++i) {
		if (k[i] >= k[i - 1]) { ++mon; }
		else { ans = max(ans, mon); mon = 0; }
	}

	cout << max(ans, mon) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll a,b,k;
	cin>>k>>a>>b;
	for(ll i=a;i<=b;i++){
		if(i%k==0){
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	// your code goes here
	return 0;
}

Measured memory_bytes: 3456
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var P = one[0];
	var Q = one[1];
	var R = one[2];
	var output = [P+Q, Q+R, R+P];
	myout(Math.min.apply(null, output));
}


Measured memory_bytes: 29956
#include <bits/stdc++.h>
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
const int maxn= 2000 +10, oo= 2147483647;

int f[maxn][maxn][2] ,N, w[maxn];

void Transf(int i, int j, bool typ){  // 0,the player is X;   1:Y
	int nx = max(i,j)+1;
	#ifdef che
	debug("nx=%d\n", nx);
	#endif
	f[i][j][typ] = typ?oo:0;
	if (nx != N+2){
	
		if ( typ==0) f[i][j][typ] = max(f[nx][j][typ], f[i][j][typ]);
			else f[i][j][typ] = min( f[i][nx][typ], f[i][j][typ]);
			
		if ( (i<j)==typ) f[i][j][typ] = typ?min(f[i][j][typ], f[i][j][typ^1]) :max( f[i][j][typ] , f[i][j][typ^1]);
		
	}	else f[i][j][typ] = abs(w[i]-w[j]);
	#ifdef che
	debug("f[%d][%d][%d] = %d\n",i,j,typ, f[i][j][typ] );
	#endif 
}

int main(){
//	freopen("input.txt","rt",stdin);
//	freopen("output.txt","wt",stdout);
	scanf("%d", &N);
	scanf("%d%d", &w[0] , &w[1]);
	for (int i=2; i<=N+1; i++) scanf("%d", &w[i]);
	// the last card is N+1!!!! 
	for (int i=N+1; i>=0; i--)
		for (int j=N+1,nx; j>=0; j--){
			if ( i==j) continue;
			
			if ( i<j) Transf(i,j,0), Transf(i,j,1);
				else Transf(i,j,1), Transf(i,j,0);
		}
	printf("%d\n", f[0][1][0]);
	return 0;
}


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

int main(){
	int a,b;
	cin>>a>>b;
	if((a+b)%2==0){
		cout<<(a+b)/2<<endl;
	}
	else{
		cout<<"IMPOSSIBLE"<<endl;
	}
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N, T; cin >> N >> T;
    vector<int> A(N), B(N);
    REP(i, 0, N) cin >> A[i] >> B[i];

    vector<int> idx(N);
    iota(ALL(idx), 0);
    sort(ALL(idx), [&](auto l, auto r) { return A[l] < A[r]; });

    vector<vector<int>> dp(N + 1, vector<int>(6001, 0));
    REP(i, 0, N) {
        REP(j, 0, 6000) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j < T) dp[i + 1][j + A[idx[i]]] = max(dp[i + 1][j + A[idx[i]]], dp[i][j] + B[idx[i]]);
        }
    }

    int ans = 0;
    REP(i, 0, 6000) ans = max(ans, dp[N][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 73684
#include<bits/stdc++.h>
using namespace std;
const double pi=3.141592653589793238462;
const double val=pi/180.0;
int main()
{
  double A,B,C,D,E;
  cin>>A>>B>>C>>D;
  C+=D/60.0;
  C*=330.0;
  while(C>360.0)
  	C-=360.0;
  C=min(C,360.0-C);
  E=sqrt(A*A+B*B-2.0*A*B*cos(val*C));
  printf("%.12lf\n",E);
  return 0;
}

Measured memory_bytes: 4288
N,M = map(int,input().split())

pattern = ["."] * N
for i in range(M):
  s,c = input().split()
  s = int(s)
  if pattern[s - 1] not in (".",c):
    print(-1)
    exit(0)
  pattern[s - 1] = c
  

import re

comp = re.compile("".join(pattern))

for i in range(1001):
  res = comp.match(str(i))
  if res:
    print(i)
    break
else:
  print(-1)

Measured memory_bytes: 9844
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
//const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int a,b;cin>>a>>b;
    int k = 50;
    vector<vector<char>> grid(2*k);
    rep(i,k)grid[i].resize(2*k,'#');
    repsg(i,k,2*k) grid[i].resize(2*k,'.');
    a--;
    b--;
    rep(i,k-1){
        if(a==0)break;
        rep(j,2*k){
            grid[i][j]='.';
            a--;
            j++;
            
            if(a==0){
                break;
            }
        }
        i++;
    }
    
    repsg(i,k+1,2*k){
        
        if(b==0)break;
        
        rep(j,2*k){
            grid[i][j]='#';
            b--;
            j++;
            
            if(b==0){
                break;
            }
        }
        i++;
        
    }
    cout<<100<<" "<<100<<endl;
    
    rep(i,2*k){
        rep(j,2*k){
            cout<<grid[i][j];
        }
        cout<<endl;
    }
    
    
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<double> v(n);
  rep(i,n) cin >> v.at(i);
  
  for(int i=0;i<n-1;i++){
    sort(v.begin(),v.end());
    v.at(1) = (v.at(0)+v.at(1))/2.0;
    if( i != n-2 ) v.at(0) = 1200;
  }
  cout << v.at(1) << endl;
      
  return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		String S = sc.next();
		String T = sc.next();

		sc.close();

		long L = lcm(N, M);

		Map<Long, Character> X = new HashMap<>();

		for (int i = 0; i < N; i++) {
			X.put((i * (L / N)), S.charAt(i));
		}

		long ans = L;
		for (int i = 0; i < M; i++) {
			Character c = X.get(i * (L / M));
			if (c != null && c != T.charAt(i)) {
				ans = -1;
				break;
			}
		}

		out.println(ans);

	}

	// 最大公約数
	private static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	// 最小公倍数
	private static long lcm(long a, long b) {
		return (a / gcd(a, b)) * b; // a*bがオーバーフローしないように
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 32684
a,b,n=map(int,input().split())

def floor(A,B,x):
    num=int(A*x/B)
    return num

ans=0
if n>=b-1:
    x=b-1
else:
    x=n

f1=floor(a,b,x)
f2=a*floor(1,b,x)
print(f1-f2)
 
 


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

int n;
vector<long long> a;
long long ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		long long t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	vector<long long> b(a);
	for(int i=1; i<n; ++i)
		b[i] += b[i-1];
	if(n % 2 == 0){
		if(n == 2) ans = a[1]-a[0];
		else{
			int m = n / 2;
			ans = a[m]+2*(b[n-1]-b[m])-a[m-1]-2*b[m-2];
		}
	}else{
		if(n == 3) ans = max(a[2]+a[1]-2*a[0], 2*a[2]-a[0]-a[1]);
		else{
			int m = n / 2;
			ans = max(-2*b[m-1]+a[m]+a[m+1]+2*(b[n-1]-b[m+1]), -2*b[m-2]-a[m-1]-a[m]+2*(b[n-1]-b[m]));
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1908
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    char s[100];
    int n, k;
    scanf("%d%d", &n, &k);
    scanf("%s", s);
    s[k-1] -= ('A' - 'a');
    printf("%s\n", s);
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++) cin >> a.at(i);
    for (int i=0;i<n;i++) {
      cout << a.at(n-i-1);
      if (i == n-1) break;
      cout << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 3104
#include <iostream>
using namespace std;
#include <set>
#include <algorithm>

int a[4];
int main()
{
	cin >> a[1] >> a[2] >>a[3];
	
	sort(a+1,a+4);
	
	int cnt = 0;
	while(1)
	{
		int a31 = a[3] - a[1];
		int a32 = a[3] - a[2];
		
//		cout << a31 << " " << a32 << endl;
//		system("pause");
		
		if(a32>=1&&a31>=1)
		{
			a[2]++;
			a[1]++;
			cnt++;
		}
		else
		{
			if(a32==1&&a31>2)
			{
				a[1]+=2;
				cnt++;
			}
			else if(a32==1&&a31==1)
			{
				cnt++;
				cout << cnt << endl;
				return 0;
			}
			else if(a32==1&&a31==2)
			{
				cnt+=3;
				cout << cnt << endl;
				return 0;
			}
			else if(a32==0&&a31==1)
			{
				cnt+=2;
				cout << cnt << endl;
				return 0;
			}
			else if(a32==0&&a31==2)
			{
				cnt++;
				cout << cnt << endl;
				return 0;
			}
			else if(a32==0&&a31>2)
			{
				a[1]+=2;
				cnt++;
			}
			else if(a32==0&&a31==0)
			{
				cout << cnt << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		if(x ==1) {
			System.out.println(b - a + 1);
			return;
		}
		// b をxで割った数
		long bx = b/x;
		// a未満の数 をxで割った数
		long ax = (a-1)/x;
		if(a ==0) {
			System.out.println(bx + 1);
			return;
		}
		System.out.println(bx - ax);
	}
}

Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
	int x,y,z,w;
	scanf("%d%d%d%d",&x,&y,&z,&w);
	if(x+y>z+w)
		printf("Left\n");
	else
		if(x+y<z+w)
			printf("Right\n");
		else
			printf("Balanced\n"); 
	
	
	
	
	return 0;
 } 

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] A = new int[n];
		for(int i=0; i<n; i++){
			A[i] = sc.nextInt();
		};
		sc.close();
		int o=1;
		for(int i=0; i<n; i++){
			if(A[i]%2 == 0) o *=2;
		};
		System.out.println((int)Math.pow(3,n) - o);
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(){

  int n;
  set <int> a;

  cin>>n;
  for(int i=0;i<n;i++){

    int t;
    cin>>t;

    a.insert(t);

  }

  int i=0;
  for(int e:a) cout<<(i++?" ":"")<<e;
  cout<<endl;

  return 0;

}



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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int solve(int b, int n) {
	if(b < 2) return LINF;
	int res = 0;
	while(n >= b) {
		res += n % b;
		n /= b;
	}
	return res + n;
}

signed main() {
	int n, s;
	cin >> n >> s;
	if(n == s) {
		cout << n + 1 << endl;
		return 0;
	}
	int res = LINF;
	for(int i = 1; i < sqrt(n); ++i) {
		if(solve(i + 1, n) == s) chmin(res, i + 1);
	}
	for(int i = 1; i < sqrt(n); ++i) {
		int b = (n - s) / i + 1;
		if(solve(b, n) == s) chmin(res, b);
	}
	if(res == LINF) cout << -1 << endl;
	else cout << res << endl;
	return 0;
}


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

int64_t lucas(int16_t N){
  if(N == 0){
  	return 2;
  } else if(N == 1){
  	return 1;
  }
  int64_t ans = 0;
  int64_t tmp1 = 1; //l1
  int64_t tmp0 = 2; //l0
  for(int16_t i = 0; i < N-1; i++){
    ans = tmp1 + tmp0;
    tmp0 = tmp1;
    tmp1 = ans;
  }
  return ans;
}

int main(){
  int16_t N = 0;
  cin >> N;
  
  cout << lucas(N) << endl;
}

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

using namespace std;

int MAX_N = 100;

int main()
{
    // スペース区切りの整数の入力
    int N,R;
    cin >> N >> R;

    if (N >=10)
    {
        cout << R << endl;
    }else
    {
        cout << R + 100*(10-N) << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    vector<int> v[200001];
    int ans[200001],visited[200001];

    void bfs(int i)
    {
        queue<int> q;
        q.push(1);
        visited[1]=1;
        while(!q.empty())
        {
            int i = q.front();
            q.pop();
            for(int j=0;j<v[i].size();++j)
            {
                if(visited[v[i][j]]==0)
                {
                    visited[v[i][j]]=1;
                    ans[v[i][j]]=i;
                    q.push(v[i][j]);
                }
            }
        }
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,m,i,j,a,b;
            cin>>n>>m;
            for(i=1;i<=m;++i)
            {
                cin>>a>>b;
                v[a].pb(b);
                v[b].pb(a);
            }
            bfs(1);
            cout<<"Yes"<<endl;
            for(i=2;i<=n;++i)
            {
                cout<<ans[i]<<endl;
            }
        }
        return 0;
    }


Measured memory_bytes: 13216