akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    unsigned long long N;
    cin >> N;
    // scanf("%lld",&N);
    // 1000000000000001
    // N=754;
    unsigned long long q=N;
    unsigned long long r=N%26;
    string s;

    do {
        char c;
        if(r==0){
            c='z';
        }else{
            c='a'+r-1;
        }
        s+=c;
        q/=26;
        if(r==0){
            q--;
        }
        r=q%26;
    } while (q>0);

    reverse(all(s));
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  ll x;
  cin >> x;

  ll k = (x+10)/11;

  if(x%11 >= 1 && x%11 <= 6){
    cout << 2*k-1 << endl;
  }else{
    cout << 2*k << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main ()
{    int n;
     scanf("%d",&n);
     int a[105];
     for(int i=1;i<=n;i++)
      scanf("%d",&a[i]);
      int i;
      for(i=1;i<=n;i++)
        if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0) 
           break;
       if(i<=n)  printf("DENIED");
       else   printf("APPROVED");
       return 0;
 }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 200003, K = 999;
int n, a[N], q, ind[N], dp[N], f[N];
pii query[N], p[N];
vi vec[N];

struct block {
	vector <pii> v, tmp_v;
	vi s, ord, tmp;
	int suf = N, val = -1;
	void add(int x) {
		for (int i = suf; i < (int)v.size(); i++) {
			v[i].F = val;
		}
		suf = N, val = -1;
		int l = p[x].F, r = p[x].S;
		v.pb({r, l});
		s.pb(dp[l - 1] - f[l - 1]);
		for (int i = (int)s.size() - 2; i >= 0; i--) {
			s[i] = min(s[i], s[i + 1]);
		}
	}
	int get(int x) {
		if (v.empty()) {
			return N;
		}
		int L = p[x].F, R = p[x].S;
		int pos = lower_bound(all(v), mp(L - 1, 0)) - v.begin();
		if (pos < suf) {
			if (pos == (int)v.size()) {
				return N;
			}
			suf = pos, val = R;
			return s[pos];
		}	else {
			if (val >= L - 1) {
				val = R;
				return s[suf];
			}	else {
				return N;
			}
		}
	}
	int naive_get(int x) {
		if (v.empty()) {
			return N;
		}
		int L = p[x].F, R = p[x].S, res = N;
		for (int i = 0; i < (int)v.size(); i++) {
			if (i >= suf) {
				v[i].F = val;
			}
			if (v[i].S <= L && v[i].F >= L - 1) {
				res = min(res, dp[v[i].S - 1] - f[v[i].S - 1]);
				v[i].F = R;
				tmp.pb(i);
			}	else {
				ord.pb(i);
			}
		}
		suf = N, val = -1;
		for (int i = 0; i < (int)ord.size(); i++) {
			tmp_v.pb(v[ord[i]]);
		}
		for (int i = 0; i < (int)tmp.size(); i++) {
			tmp_v.pb(v[tmp[i]]);
		}
		v = tmp_v;
		ord.clear();
		tmp.clear();
		tmp_v.clear();
		for (int i = (int)s.size() - 1; i >= 0; i--) {
			if (i == (int)s.size() - 1) {
				s[i] = dp[v[i].S - 1] - f[v[i].S - 1];
			}	else {
				s[i] = min(s[i + 1], dp[v[i].S - 1] - f[v[i].S - 1]);
			}
		}
		return res;
	}
};

block b[N / K + 1];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	int s = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		f[i] = f[i - 1] + (a[i] == 0) - (a[i] == 1);
		s += a[i];
	}
	cin >> q;
	for (int i = 1; i <= q; i++) {
		int l, r;
		cin >> l >> r;
		p[i] = {l, r};
		vec[r].pb(i);
		query[i - 1] = {l, i};
	}
	sort(query, query + q);
	for (int i = 0; i < q; i++) {
		ind[query[i].S] = i;
	}
	for (int i = 1; i <= n; i++) {
		int res = N;
		for (int j : vec[i]) {
			b[ind[j] / K].add(j);
			for (int k = 0; k <= (q - 1) / K; k++) {
				int last = min(q - 1, K * (k + 1) - 1);
				if (query[last].F <= p[j].F && last < q - 1) {
					res = min(res, b[k].get(j));
				}	else {
					res = min(res, b[k].naive_get(j));
					break;
				}
			}
		}
		dp[i] = min(dp[i - 1], res + f[i]);
	}
	cout << dp[n] + s;
}


Measured memory_bytes: 21120
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n,c,k;
    int ans=0;
    cin >>n>>c>>k;
    vector<int>t(n);
    rep(i,n){
        cin>>t[i];
    }
    sort(all(t));
    auto ati=t.begin();
    auto ati2=ati;
    int at=0;
    while(ati!=t.end()){
        ans++;
        ati2=upper_bound(ati,t.end(),*(ati)+k);
       if(ati2!=t.end() ){
           
       }
        if(distance(ati,ati2)>c){
            ati+=c;
        }else{
            ati=ati2;
        }
        
      //  cout<<(*ati)<<endl;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main()
{
    int n,W;cin>>n>>W;
    vector<ll> w( n + 1 ),v(n + 1);
    for(int i=  1 ;i <=  n ;i++)
    {
        cin>>w[i]>>v[i];
    } 
    vector<vector<ll> > d(n + 1,vector<ll> (W + 1,0));
    for(int i = 1 ;i <= n ;i++)
    {
        for(int j = 0 ; j <= W ; j++)
        {
            d[i][j] = d[i - 1][j];
            if(j >= w[i])
            {
                d[i][j] = max(d[i][j],d[i - 1][j - w[i]] + v[i]);
            }
        }
    }
    // for(int i = 0 ;i <= n ;i++)
    // {
    //     for(int j = 0 ; j <= W ; j++)
    //     {
    //         cout<<d[i][j]<<' ';
    //     }
    //     cout<<endl;
    // }
    cout<<d[n][W]<<endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> ii;
const int Maxn = 52;
int n;
int X[Maxn], Y[Maxn];
map <ii, int> M;
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d %d", &X[i], &Y[i]);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            int dx = X[i] - X[j], dy = Y[i] - Y[j];
            if (dx || dy) M[ii(dx, dy)]++;
        }
    int mx = 0;
    for (map <ii, int>::iterator it = M.begin(); it != M.end(); it++)
        mx = max(mx, it->second);
    printf("%d\n", n - mx);
    return 0;
}

Measured memory_bytes: 384
import sys
a=input()
b=input()
for i in reversed(range(len(a)-len(b)+1)):
  t=True
  for j in range(len(b)):
    if not(a[i+j]=="?") and not(a[i+j]==b[j]):
      t=False
      break
  if t:
    for p in range(i):
      if a[p]=="?":
        print("a",end="")
      else:
        print(a[p],end="")
    print(b,end="")
    for w in range(i+len(b),len(a)):
      if a[w]=="?":
        print("a",end="")
      else:
        print(a[w],end="")
    sys.exit()
print("UNRESTORABLE")

Measured memory_bytes: 3064
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    if s == "RRR":
        print(3)
    elif s == "RRS" or s == "SRR":
        print(2)
    elif s.count("R") == 0:
        print(0)
    else:
        print(1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 61860
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] array = line.split(" ");
		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);

		int c = a * b;
		int d = 2 * (a + b);

		System.out.println(c + " " + d);

	}

}

Measured memory_bytes: 25968
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n;
    cin >> n;
    bool res = true;
    rep(i, n) {
        int a;
        cin >> a;
        if(a%2==0) {
            if(a%3 && a%5) res = false;
        }
    }

    if(res) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    
    return 0;
}

Measured memory_bytes: 256
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if i == 0 or j == 0 or i == H-1 or j == W-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


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

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

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

int dice[6];

//idx: 0 1 2 3 4 5
//v  : 1 2 3 4 5 6
int rotate(string dir){
  
  int prev[6];
  for(int i = 0; i < 6; i++) prev[i] = dice[i];
  
  if(dir == "North"){
    dice[0] = prev[1];
    dice[1] = prev[5];
    dice[4] = prev[0];
    dice[5] = prev[4];
  }
  else if(dir == "East"){
    dice[0] = prev[3];
    dice[2] = prev[0];
    dice[3] = prev[5];
    dice[5] = prev[2];
  }
  else if(dir == "West"){
    dice[0] = prev[2];
    dice[2] = prev[5];
    dice[3] = prev[0];
    dice[5] = prev[3];
  }
  else if(dir == "South"){
    dice[0] = prev[4];
    dice[1] = prev[0];
    dice[4] = prev[5];
    dice[5] = prev[1];
  }
  else if(dir == "Right"){
    dice[1] = prev[2];
    dice[2] = prev[4];
    dice[3] = prev[1];
    dice[4] = prev[3];
  }
  else if(dir == "Left"){
    dice[1] = prev[3];
    dice[2] = prev[1];
    dice[3] = prev[4];
    dice[4] = prev[2];
  }
  
  return dice[0];
}

int main(){
 
  int n, sum;
  
  while(cin >> n, n){
    sum = 0;
    for(int i = 0; i < 6; i++) dice[i] = i + 1;
    while(n--){
      string s;
      cin >> s;
      sum += rotate(s);
    }
    cout << sum + 1 << endl;
  }

}

Measured memory_bytes: 1220
import java.util.*;

public class Main {
	public static void printArray(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + ", ");
		}
		System.out.println();
	}

	public static int bitCount(int i) {
		i = i - ((i >>> 1) & 0x55555555);
		i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
		i = (i + (i >>> 4)) & 0x0f0f0f0f;
		i = i + (i >>> 8);
		i = i + (i >>> 16);
		return i & 0x3f;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		// int[][] S = new int[M][];
		int[] S = new int[M];
		for (int i = 0; i < M; i++) {
			int flag = 0;
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int x = sc.nextInt();
				flag |= 1 << (x - 1);
			}
			S[i] = flag;
			// System.out.println(flag);
		}
		int[] P = new int[M];
		for (int i = 0; i < M; i++) {
			P[i] = sc.nextInt();
		}
		// printArray(P);

		// solve
		int count = 0;
		outside: for (int bits = 0; bits < 1 << N; bits++) {
			// System.out.println("--" + bits);
			for (int i = 0; i < M; i++) {
				int and = bits & S[i];
				if (bitCount(and) % 2 != P[i]) {
					continue outside;
				}
				// System.out.println("OK " + i + " - " + bitCount(and) + " = " + P[i]);
			}
			count++;
		}
		System.out.println(count);
	}
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

vll a;

bool f(ll r, vll& now){
  rep(j,21){
    if(now[j]==1 && a[r]>>j&1) return false;
  }
  rep(j,21){
    now[j]|=a[r]>>j&1;
  }
  return true;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  a.resize(n);
  rep(i,n) cin>>a[i];
  
  
  ll ans=0;
  ll r=0;
  
  vll now(21);
  rep(l,n){
    while(r<n && f(r,now)){
      r++;
    }
    ll span=r-l;
    ans+=span;
    
    rep(j,21) if(a[l]>>j&1) now[j]=0;
    if(l==r) r++;
    
    // cout<<l<<' '<<r<<' '<<span<<endl;
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 998244353
#define inf 1000000000000000
#define bpc(x) __builtin_parityll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

ll que(ll ft[], ll l, ll r, ll l1, ll r1, ll i)
{
    if(l>r1 || l1>r)
        return 0;
    if(l>=l1 && r<=r1)
        return ft[i];
    ll mid = (l+r)/2;
    
    return max(que(ft,l,mid,l1,r1,2*i+1),que(ft,mid+1,r,l1,r1,2*i+2));
}
 
void upd(ll ft[], ll l, ll r, ll l1, ll i, ll val)
{
    if(l>l1||r<l1)
        return;
    if(l == r)
    {
        ft[i] = val;
        return;
    }
    
    ll mid = (l+r)/2;
    upd(ft,l,mid,l1,2*i+1,val);
    upd(ft,mid+1,r,l1,2*i+2,val);
    
    ft[i] = max(ft[2*i+1],ft[2*i+2]);
}

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   pair<ll,ll> arr[n];
   rep(n)
        cin>>arr[i].ff>>arr[i].ss;
   ll arr1[n];
   rep(n)
        arr1[i] = arr[i].ff;
   sort(arr1,arr1+n);        
   sort(arr,arr+n);
   ll ht = ceil(log2(n));
   ht = (1ll<<(ht + 1)) - 1;
   ll st[ht];
   memset(st,0,sizeof(st));
   ll fun[n];
   memset(fun,0,sizeof(fun));
   fun[n-1] = 2;
   upd(st,0,n-1,n-1,0,n-1);
   for(ll i=n-2;i>-1;i--)
   {
       ll temp = upper_bound(arr1,arr1+n,arr[i].ff+arr[i].ss-1) - arr1;
       temp--;
       //cout<<"for "
       if(temp == i)
       {
           upd(st,0,n-1,i,0,i);
           fun[i] = 2*fun[i+1];
           fun[i]%=mod;
           continue;
       }
       ll inde = que(st,0,n-1,i+1,temp,0);
       upd(st,0,n-1,i,0,inde);
       fun[i] = fun[i+1];
       if(inde<n-1)
            fun[i]+=fun[inde+1];
       else fun[i]++;         
       fun[i]%=mod;        
   }
   /*rep(n)
   {
       cout<<fun[i]<<" ";
   }
   cout<<'\n';*/
   cout<<fun[0];
   
   return 0;        
}  
   

Measured memory_bytes: 10752
A,B,C,D = [int(_n) for _n in input().split()]
taka = C // B + (0 if C % B == 0 else 1)
aoki = A // D + (0 if A % D == 0 else 1)
# print(taka)
# print(aoki)
print("Yes" if taka <= aoki else "No")

Measured memory_bytes: 61632
#include<stdio.h>

int main() {
	int n, h[100], i, flg, cnt, stop;
	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &h[i]);

	cnt = 0;
	while (1) {
		flg = 0;
		stop = 1;
		for (i = 0; i < n; i++) {
			if (h[i] > 0) {
				if (flg) h[i]--;
				else {
					flg = 1;
					stop = 0;
					cnt++;
					h[i]--;
				}
			}
			else flg = 0;
		}
		if (stop) break;
	}

	printf("%d", cnt);
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int mod = 100000003;

int n, c, v;
int s[52], t[52], y[52], m[52];
int dp[51][301];


int main() {
	int u, d, h;
	cin >> u >> d >> h;
	print((u + d)*h / 2);
		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n, m, k;
	cin >> n >> m >> k;
	vector<long long> a(n+1,0), b(m+1,0), sa(n+1,0), sb(m+1,0);
	for(int i=1; i<=n; ++i){
		cin >> a[i];
		sa[i] =sa[i-1]+a[i];
	}
	for(int i=1; i<=m; ++i){
		cin >> b[i];
		sb[i] =sb[i-1]+b[i];
	}
	
	int ans=0;
	for(int i=0; sa[i]<=k && i<=n; ++i){
		auto itr=upper_bound(sb.begin(),sb.end(),k-sa[i]);
		--itr;
		int numb=distance(sb.begin(),itr);
		ans = max(ans, i+numb);
	}

	cout << ans << endl;
}

Measured memory_bytes: 9588
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define b(v) v.begin()
#define e(v) v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vii vector<int>
#define vll vector<long long>
#define gl(cin,s)  getline(cin,s);
#define bitc(n) __builtin_popcountll(n)
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define SIZE 3010
#define SZ 110

typedef long long  ll;
typedef unsigned long long ull;
typedef long double  ldo;
typedef double  db ;
using namespace std;
int N;
double A[SIZE];
double B[SIZE];
long double dp[SIZE][SIZE];
int main()
{  	
	/* #ifndef ONLINE_JUDGE
	freopen(fi, "r", stdin);
	#endif */
	//freopen("route.in","r",stdin);
	//freopen("route.out","w",stdout);
	//cin.ignore();
	//cin.clear();
	boost;
	//cin.tie(0);
	//cout<<"Case "<<tt<<": ";
	cin>>N;
	for(int i=1;i<=N;i++){
	    cin>>A[i];
	    B[i] = 1-A[i];
	}
	dp[1][0] = 1-A[1];
	dp[1][1] = A[1];
	for(int i=2;i<=N;i++){
	    for(int j=0;j<=i;j++){
	        if(j){
	            dp[i][j] = dp[i-1][j]*(1-A[i]) + dp[i-1][j-1]*A[i];
	        }
	        else{
	            dp[i][j] = dp[i-1][j]*(1-A[i]);
	        }
	    }
	}
	double fans = 0;
	for(int i=0;i<=N;i++){
	    int val = N-i;
	    if(val < i){
	        fans += dp[N][i];
	    }
	}
	cout<<fixed<<setprecision(10);
	cout<<fans<<endl;
	return 0;
}

Measured memory_bytes: 139776
#include <iostream>
using namespace std;
 
int main() {
  unsigned int N, K, Q;
  cin >> N >> K >> Q;
  
  unsigned int A[Q];
  for(int i=0; i<Q; i++) cin >> A[i];
  
  unsigned int counters[N];
  for(int i=0; i<N; i++) counters[i] = 0;
  
  for(int i=0; i<Q; i++){
    counters[A[i]-1] += 1;
  }
  
  int damage = 0;
  for(int i=0; i<N; i++){
    damage = Q - counters[i];
    if (damage >= K){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  }
  return 0;
}

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

#define REPR(i, s, e) for(int i = (int)(s-1); i >= (int)(e); --i)
#define repr(i, n) REPR(i, n, 0)

bool isdig(char c) {
  return '0' <= c && c <= '9';
}

void calc(string& s, const string& t) {
  if(s.size() < t.size()) s = t;
  else if(s.size() == t.size()) {
    rep(i, s.size()) {
      if(s[i] < t[i]) {
	s = t;
	return;
      }
      else if(s[i] > t[i]) {
	return;
      }
    }
  }
}

int main() {
  int w, h;
  while(cin >> w >> h) {
    if(w == 0 && h == 0) break;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<string>> dp(h, vector<string>(w));
    repr(i, h) repr(j, w) {
      if(!isdig(s[i][j])) continue;
      dp[i][j] += s[i][j];
      if(i+1 < h) calc(dp[i][j], s[i][j] + dp[i+1][j]);
      if(j+1 < w) calc(dp[i][j], s[i][j] + dp[i][j+1]);
    }
      string ans = "";
      rep(i, h) rep(j, w) if(dp[i][j].size() > 0 && dp[i][j][0] != '0') calc(ans, dp[i][j]);
      cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String []args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		
		//a???????????????
		int a = sc.nextInt();
		
		//b???????????????
		int b = sc.nextInt();
		//?????¶??? a??????b???????????§????????´??? a<b
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
		//?????¶??? a??????b??????????°?????????´??? a>b
			System.out.println("a > b");
		}else if(a ==b){
		//?????¶??? a??¨b?????????????????° a==b
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26304
def f(x):
  res=0
  cnt_xor=0
  cnt_xor=(x+2-1)//2
  if x%2==0:
    if cnt_xor%2==1:
      res=1^x
    else:
      res=0^x
  else:
    if cnt_xor%2==1:
      res=1
    else:
      res=0
  return res
a,b=map(int,input().split())
print(f(b)^f(a-1))


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

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

  map<int, int> freq;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;

    freq[x]++;
  }

  int res = 0;
  for (auto e: freq) {
    int x = e.first;
    int cnt = e.second;

    if (cnt >= x) {
      res += cnt - x;
    } else {
      res += cnt;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    rep(i,s.size()){
        if(i%2==0&&(s[i]=='R'||s[i]=='U'||s[i]=='D')){
            continue;
        }else if(i%2==1&&(s[i]=='L'||s[i]=='U'||s[i]=='D')){
            continue;
        }
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


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

const int N = 1e5 + 10, P = 1e9 + 7;

inline int mpow(int a, int b) {
    int ans = 1;
    for (; b; b >>= 1, a = (ll) a * a % P)
        if (b & 1) ans = (ll) ans * a % P;
    return ans;       
}

int x[N], f[N];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> x[i];
    f[1] = 1;
    for (int i = 2; i < n; ++i) {
        f[i] = (f[i - 1] + mpow(i, P - 2)) % P;
    }
    int ans = 0;
    for (int i = 1; i < n; ++i) {
        ans = (ans + (ll) (x[i + 1] - x[i]) * f[i] % P) % P;
    }
    for (int i = 1; i < n; ++i)
        ans = (ll) ans * i % P;
    cout << ans << '\n';
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N+1);
    for(int i=0; i<N; i++){
        cin >> vec[i];
    }
    vec[N] = 2e9;

    int m=0;
    int count=0;
    for(int i=0; i<N; i++){
        if(vec[i+1]<=vec[i]){
            count++;
        }
        else{
            m = max(m, count);
            count =0;
        }
    }

    cout << m << endl;

}


Measured memory_bytes: 640
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        long[][] dp = new long[n+1][2];
        dp[0][1] = Integer.MIN_VALUE;

        for (int i=1; i<=n; i++) {
            dp[i][0] = Math.max(dp[i-1][0]+arr[i-1], dp[i-1][1]-arr[i-1]);
            dp[i][1] = Math.max(dp[i-1][0]-arr[i-1], dp[i-1][1]+arr[i-1]);
        }

//        System.out.println(Math.max(dp[n][0], dp[n][1]));
        System.out.println(Math.max(dp[n][0], 0));
//        System.out.println(Math.max(0, dp[n][1]));


    }

    int gcd(int m, int n) {
        if (n == 0) return m;
        return gcd(n, m%n);
    }


}



Measured memory_bytes: 52772
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;
const int inf=1001001001;
ll absc(ll a,ll b){return (a-b>0?a-b:b-a);
}
ll mini(ll a,ll b){return (a>b?b:a);}
ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	return (a%b?gcd(a%b,b):b);
}
int main()
{
    ll N,ans=0,r=0,g=0,b=0;
    string s;
    cin>>N;
    cin>>s;
    for(int i=0;i<N;i++)
    {
    	if(s[i]=='R')r++;
    	if(s[i]=='G')g++;
    	if(s[i]=='B')b++;
    }
    ans=r*g*b;
    for(int i=0;i<N-2;i++)
    {
    	for(int j=i+1;j<N-1;j++)
    	{
    		if(j+j-i<N&&s[i]!=s[j]&&s[j]!=s[j+j-i]&&s[j+j-i]!=s[i])--ans;
    	}
    }
    cout<<ans;
}


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

using namespace std;

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

    vector<int> B(N - 1);
    for(int i = 0; i < N - 1; i++)
    {
        cin >> B[i];
    }

    vector<int> A(N);



    long long ans = B[0] + B[N - 2];
    for (int i = N - 2; i > 0; i--)
    {
        ans += min(B[i], B[i - 1]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

int a[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	int mini=n;
	int maxi=0;
	for(int i=0;i<n;i++) 
	{
		cin>>a[i];
		mini=min(mini,a[i]);
		maxi=max(maxi,a[i]);
	}
	if(maxi-mini<=1)
	{
		int s = 0; int b = 0;
		for(int i=0;i<n;i++)
		{
			if(a[i]==maxi)
			{
				b++;
			}
			else if(a[i]==maxi-1)
			{
				s++;
			}
		}
		if(b==1)
		{
			cout<<"No\n";
			return 0;
		}
		if(s==0&&maxi==n-1)
		{
			cout<<"Yes\n";
			return 0;
		}
		//from here b >= 2
		//there must be s extra unique colors
		//n - s
		int l = s + 1;
		int r = s + (n-s)/2;
		if(maxi>=l&&maxi<=r) cout<<"Yes\n";
		else cout<<"No\n";
	}
	else
	{
		cout<<"No\n";
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define pb push_back
typedef long double ld;
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vpl;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9+7;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll n;cin >> n;
        vll h(n+1);
        repA(i,1,n) cin >> h[i];

        vll d(n+1,0);
        d[1]=0; d[2]=abs(h[2]-h[1]);
        
        repA(i,3,n){
            d[i] = min(d[i-1]+abs(h[i-1]-h[i]),d[i-2]+abs(h[i-2]-h[i]));
        }
        cout << d[n] << endl;
    }
}


Measured memory_bytes: 4700
#include<stdio.h>
int main()
{
	int A,B,k,l,m;
	scanf("%d",&A);
	scanf("%d",&B);
	k=A+B;
	l=A-B;
	m=A*B;
  if (k>= l) {
        if (k >= m)
            printf("%d",k);
        else
            printf("%d",m);
    } else {
        if ( l>= m)
            printf("%d",l);
        else
            printf("%d",m);
    }
}

Measured memory_bytes: 128
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

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

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

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

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

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, parser) => {
        $next
    };

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        s: chars,
    }

    println!(
        "{}",
        700 + s.into_iter().filter(|&x| x == 'o').count() * 100
    );
}


Measured memory_bytes: 4352
sstr=list(input())
# s=[int(n) for n in sstr]
# print(sstr)
sf=[sstr[0],sstr[1]]
sb=[sstr[2],sstr[3]]
if sf[0]=="0":
  sf.pop(0)
if sb[0]=="0":
  sb.pop(0)
fws="".join(sf)
bks="".join(sb)
fwb=[int(n) for n in fws]
bkb=[int(n) for n in bks]
# print(fwb)
# print(bkb)
if len(fwb)==2:
    fw=(fwb[0]*10)+(fwb[1])
else:
    fw=fwb[0]
if len(bkb)==2:
    bk=(bkb[0]*10)+(bkb[1])
else:
    bk=bkb[0]
# print(fw)
# print(bk)
if 1<=fw<=12:
  if 1<=bk<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1<=bk<=12:
    print("YYMM")
  else:
    print("NA")
"""
sstr=list(input())
s=[int(n) for n in sstr]
if s[0]>=2: #前2桁の十の位が2より大きければ前は年
    if s[2]>=2: #後2桁の十の位が2以上ならば該当なし
        print("NA")
    elif s[2]==1: #後2桁の十の位が1なら一の位は0-2
        if s[3]>=3: #後2桁の一の位が3以上ならNA
            print("NA")
        else: #後2桁の一の位が0-2ならYYMM
            print("YYMM")
    else: #後2桁の十の位が0ならYYMMかNA
        if s[3]==0: #後2桁の一の位が0ならNA
            print("NA")
        else: #後2桁の一の位が0でなければYYMM
            print("YYMM")

elif s[0]==1: #前2桁の十の位が1なら場合分け
    if s[1]>=3: #前2桁の一の位が3以上ならYYMMかNA
        if s[2]>=2: #後2桁の十の位が2以上ならNA
            print("NA")
        elif s[2]==1: #後2桁の十の位が1なら一の位は0-2
            if s[3]>=3: #後2桁の一の位が3以上ならNA
                print("NA")
            else: #後2桁の一の位が2以下ならYYMM
                print("YYMM")
        else: #後2桁の十の位が0ならYYMMかNA
            if s[3]==0:
                print("NA")
            else:
                print("YYMM")
    else: #前2桁の一の位が0-2ならMMYYかAMBIGUOUS
        if s[2]>=2: #後2桁の十の位が2以上ならMMYY
            print("MMYY")
        elif s[2]==1: #後2桁の十の位が1なら場合分け
            if s[3]>=3: #後2桁の一の位が3以上ならMMYY
                print("MMYY")
            else: #後2桁の一の位が2以下ならAMBIGUOUS
                print("AMBIGUOUS")
        else: #後2桁の十の位が0ならAMBIGUOUS
            print("AMBIGUOUS")

else: #前2桁の十の位が0ならMMYYかAMBIGIOUS
    if s[2]>=2: #後2桁の十の位が2以上ならMMYY
        if s[1]==0:
            print("NA")
        else:
            print("MMYY")
    elif s[2]==1: #後2桁の十の位が1なら場合分け
        if s[3]<=2: #後2桁の一の位が0-2ならAMBIGUOUS
            print("AMBIGUOUS")
        else: #後2桁の一の位が3以上ならMMYY
            print("MMYY")
    else: #後2桁の十の位が0ならAMBIGUOUSかNA
        if s[3]==0: #後2桁の一の位が0なら0x00のxを調査
            if s[1]==0:
                print("NA")
            else:
                print("MMYY")
        else:
            print("AMBIGUOUS")
            """

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	a := nextInt()

	if a >= 30 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, ga, sa, ba, gb, sb, bb;
  cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
  
  vector<pair<ll, ll>> x, y;
  if (ga < gb) x.emplace_back(make_pair(ga, gb));
  if (sa < sb) x.emplace_back(make_pair(sa, sb));
  if (ba < bb) x.emplace_back(make_pair(ba, bb));
  if (ga > gb) y.emplace_back(make_pair(gb, ga));
  if (sa > sb) y.emplace_back(make_pair(sb, sa));
  if (ba > bb) y.emplace_back(make_pair(bb, ba));
  
  if (x.size() == 1) {
    n = (n % x[0].first) + n / x[0].first * x[0].second;
  }
  else if (x.size() == 2) {
    ll hold = n;
    for (ll i = 0; i <= n; i++) {
      ll j = n - i;
      ll keep = (i % x[0].first) + i / x[0].first * x[0].second;
      keep += (j % x[1].first) + j / x[1].first * x[1].second;
      hold = max(hold, keep);
    }
    n = hold;
  }
  else if (x.size() == 3) {
    ll hold = n;
    for (ll i = 0; i <= n; i++) {
      for (ll j = 0; i + j <= n; j++) {
        ll k = n - i - j;
        ll keep = (i % x[0].first) + i / x[0].first * x[0].second;
        keep += (j % x[1].first) + j / x[1].first * x[1].second;
        keep += (k % x[2].first) + k / x[2].first * x[2].second;
        hold = max(hold, keep);
      }
    }
    n = hold;
  }
  
  if (y.size() == 1) {
    n = (n % y[0].first) + n / y[0].first * y[0].second;
  }
  else if (y.size() == 2) {
    ll hold = n;
    for (ll i = 0; i <= n; i++) {
      ll j = n - i;
      ll keep = (i % y[0].first) + i / y[0].first * y[0].second;
      keep += (j % y[1].first) + j / y[1].first * y[1].second;
      hold = max(hold, keep);
    }
    n = hold;
  }
  else if (y.size() == 3) {
    ll hold = n;
    for (ll i = 0; i <= n; i++) {
      for (ll j = 0; i + j <= n; j++) {
        ll k = n - i - j;
        ll keep = (i % y[0].first) + i / y[0].first * y[0].second;
        keep += (j % y[1].first) + j / y[1].first * y[1].second;
        keep += (k % y[2].first) + k / y[2].first * y[2].second;
        hold = max(hold, keep);
      }
    }
    n = hold;
  }
  
  cout << n << '\n';
}

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

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int mt[256][256];
int n;

int f(int i,int j){
	int k;
	int max=0;
	int c;
	c=0;
	for(k=0;k+j<n;k++){
		if(mt[i][k+j])c++;
		else break;
	}
	chmax(max,c);
	c=0;
	for(k=0;k+i<n;k++){
		if(mt[k+i][j])c++;
		else break;
	}
	chmax(max,c);
	c=0;
	for(k=0;k+i<n&&k+j<n;k++){
		if(mt[k+i][k+j])c++;
		else break;
	}
	chmax(max,c);
	c=0;
	for(k=0;k+i<n&&0<=j-k;k++){
		if(mt[k+i][j-k])c++;
		else break;
	}
	chmax(max,c);
	return max;
}

int main() {
	while(n=in()){
		int i,j;
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				scanf("%1d",&mt[i][j]);
			}
		}
/*
for(i=0;i<n;i++){
	for(j=0;j<n;j++){
		cout<<mt[i][j];
	}
	cout<<endl;
}
*/
		int max=0;
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				chmax(max,f(i,j));
			}
		}
		cout<<max<<endl;
	}
	return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

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

    long long ans = 0;
    long long temp = 1;

    while (h > 1)
    {
        h = h / 2;
        ans += temp;
        temp *= 2;
    }
    ans += temp;
    ANS(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
typedef pair < int , int > Pi;
typedef pair < int , Pi > Ti;

int N, Z, W;
int memo[2005][2005];
int A[2005];

int dfs(int a, int b)
{
    if(~memo[a][b]) return (memo[a][b]);
    if(a == N || b == N) {
        return (abs(A[a] - A[b]));
    }
    if(a > b) {
        return memo[a][b] = (max(dfs(a + 1, b), dfs(a, a + 1))); 
    } else {
        return memo[a][b] = (min(dfs(a, b + 1), dfs(b + 1, b)));
    }
}
int main()
{
    memset(memo, -1, sizeof(memo));

    cin >> N >> Z >> A[0];
    
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    cout << dfs(1, 0) << endl;

    return (0);
}
     


Measured memory_bytes: 16000
#include <stdio.h>

int main(){
  int a,b,c,x;
  
  scanf("%d%d%d",&a,&b,&c);

  if(a>b){
    x=a;
    a=b;
    b=x;
  }

  if(b>c){
    x=b ;
    b=c;
    c=x;
  }

  if(a>b){
    x=a;
    a=b;
    b=x;
  }

  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 2724
n = gets.to_i
data = n.times.map { gets.strip.split.map(&:to_i) }

def is_reachable(current, next_data)
    tc, xc, yc = current
    tn, xn, yn = next_data
    dist = (xc - xn).abs + (yc - yn).abs

    return false if dist > tn - tc

    (dist - (tn - tc)).even?
end

current = [0, 0, 0]
data.each do |d|
    unless is_reachable(current, d)
        puts 'No'
        exit 0
    end
    current = d
end

puts 'Yes'

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

int main(){
  string str;
  
  //空白も含めて1行まるごとを文字列として受け取るためにはgetline関数を使う
  getline(cin,str);

  for(int i=0;i<(int)str.size();i++){
    if('a'<=str[i]&&str[i]<='z'){
      str[i]=str[i]-'a'+'A';
    }else if('A'<=str[i]&&str[i]<='Z'){
      str[i]=str[i]-'A'+'a';
    }
  }
  cout<<str<<endl;
  return 0;
}




Measured memory_bytes: 3112
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void){
  int a,b;
  cin >> a >> b;
  if(a>b){
    printf("a > b\n");
  }else if(a<b){
    printf("a < b\n");
  }else{
    printf("a == b\n");
  }
  return 0;
}



Measured memory_bytes: 3096
t,a,k=list(map(int,input().split()))
i=0
while True:
    if t%2==1:
        t-=1
    a+=t//2
    t-=t//2
    i+=1
    if i>=k:
        break
    if a%2==1:
        a-=1
    t+=a//2
    a-=a//2
    i+=1
    if i>=k:
        break

print(t,a)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
typedef pair<int,int> pii;

int main()
{
    ll N,a,b;
    cin>>N>>a>>b;
    ll numm=N%(a+b)>=a?a:N%(a+b);
    cout<<N/(a+b)*a+numm<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> studentPointX(n);
	vector<int> studentPointY(n);
	for (int i = 0; i < n; i++)
	{
		cin >> studentPointX[i];
		cin >> studentPointY[i];
	}

	vector<int> checkPointX(m);
	vector<int> checkPointY(m);
	for (int i = 0; i < m; i++)
	{
		cin >> checkPointX[i];
		cin >> checkPointY[i];
	}

	for (int i = 0; i < n; i++)
	{
		int manhattanDistance = INT_MAX;
		int ans = INT_MAX;
		for (int j = 0; j < m; j++)
		{
			int tmpDistance = abs(studentPointX[i] - checkPointX[j]) + abs(studentPointY[i] - checkPointY[j]);
			if (tmpDistance < manhattanDistance)
			{
				manhattanDistance = tmpDistance;
				ans = j + 1;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
t = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = [t[0] * a[0] + t[1] * a[1], t[0] * b[0] + t[1] * b[1]]
if d[0] == d[1]:
	print('infinity')
	exit(0)
if d[0] > d[1]:
	a, b = b, a
	d[0], d[1] = d[1], d[0]
if a[0] < b[0]:
	print(0)
	exit(0)

l, r = 1, 1000000000000000  # номер периода, с которого пересечений не будет больше 2
while l < r:
	mid = (l + r) >> 1
	offset = d[1] * mid - d[0] * mid
	if t[0] * a[0] > offset + t[0] * b[0]:
		l = mid + 1
	else:
		r = mid
offset = d[1] * l - d[0] * l
print(l * 2 - 1 + (t[0] * a[0] == offset + t[0] * b[0]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans=0,curr;
    scanf("%d",&n);
    scanf("%d",&k);
    int avg = k*2;
    int nilai = avg - n;
    printf("%d\n",nilai);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
#define ll long long
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
#define test  ll int tcase ; cin>>tcase ; while(tcase--) 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    io ; 
    ll int a,b,c,k ; 
    cin>>a>>b>>c>>k ;  
    ll int sum = 0 ;  
    if(k<=a){
        cout<<k ; 
        return 0 ; 
    }else{
         sum = sum + a ; 
         k = k-a ; 
         k=k-b ; 
        if(k>0){
             sum  = sum - k ; 
        }

       }     
  cout<<sum ; 
}

Measured memory_bytes: 3628