akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, 60) {
    ll x = 0;
    rep(j, n) {
      if (a[j] >> i & 1) {
        x++;
      }
    }

    ll now = x * (n - x) % mod;
    rep(j, i) { now = now * 2 % mod; }
    ans += now;
    ans %= mod;
  }

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX_N 100000

int dp[MAX_N];

signed main(){
	int n;
	cin >> n;
	int h[n];
	REP(i,n){
		cin >> h[i];
	}
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for(int i = 2; i < n; i++){
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

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

int main(void) {
  int N;
  bool d[100];
  int ans = 0;
  fill(d, d + 100, false);

  cin >> N;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    d[x - 1] = true;
  }

  for (int i = 0; i < 100; i++) {
    if (d[i]) {
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007




int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N),B(M);
  rep(i, N)  cin >> A[i];
  rep(i, M)  cin >> B[i];
  
  rep(i,N-M+1){rep(j,N-M+1){
    
  bool a=true;
   
    rep(q,B.size()){rep(p,B.size()){
  if(A[q+j].at(p+i)!=B[q].at(p))
    a=false;
      }}
    
  if(a==true){cout <<"Yes"<<endl;
             return 0;
            } 
    }}
  cout << "No"<<endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <limits.h>

long long maxdiff(long long a, long long b, long long c) {
    long long diff[6] = {
        a - b,
        a - c,
        b - a,
        b - c,
        c - a,
        c - b
    };

    long long max = -LLONG_MAX;
    for (int i = 0; i < 6; i++) {
        if (diff[i] > max) {
            max = diff[i];
        }
    }
    return max;
}


int main(void) {
    long long H, W;
    scanf("%lld %lld", &H, &W);

    if (H == 2 && W == 2) {
        printf("1\n");
        return 0;
    }

    long long diff = LLONG_MAX;
    for (long long h = 1; h < H - 1; h++) {
        long long a, b, c;
        a = h * W;

        long long bw = W / 2;
        b = (H - h) * bw;

        c = (H - h) * (W - bw);

        long long tmp = maxdiff(a, b, c);
        if (tmp < diff) {
            diff = tmp;
        }

        long long bh = (H - h) / 2;
        b = bh * W;

        c = (H - h - bh) * W;

        long long tmp2 = maxdiff(a, b, c);
        if (tmp2 < diff) {
            diff = tmp2;
        }
    }

    for (long long w = 1; w < W - 1; w++) {
        long long a, b, c;
        a = H * w;

        long long bh = H / 2;
        b = bh * (W - w);

        c = (H - bh) * (W - w);

        long long tmp = maxdiff(a, b, c);
        if (tmp < diff) {
            diff = tmp;
        }

        long long bw = (W - w) / 2;
        b = H * bw;

        c = H * (W - w - bw);

        long long tmp2 = maxdiff(a, b, c);
        if (tmp2 < diff) {
            diff = tmp2;
        }
    }

    printf("%lld\n", diff);

    return 0;
}





Measured memory_bytes: 128
import numpy as np

N = int(input())
X = [list(map(int, input().split())) for l in range(N)]

X.insert(0, [0,0,0])

## N < 1e5 なので普通にfor文で回してみる
lst_bool = []
for i in range(N):
  dt = X[i+1][0] - X[i][0]
  dx = X[i+1][1] - X[i][1]
  dy = X[i+1][2] - X[i][2]
  dl = abs(dx) + abs(dy)
  bool_1 = (dt >= dl)
  bool_2 = ((dt - dl) % 2 == 0)
  lst_bool.append(bool_1 and bool_2)

if all(lst_bool):
  print('Yes')
else:
  print('No')




#X = np.array(X)
#var = np.roll(X, -1, axis=0) - X
#print(var)

Measured memory_bytes: 37384
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = 1;
        while(true) {
            if(M * (M-1) < 2 * N) {
                M++;
                continue;
            }
            if(M * (M-1) == 2 * N) {
                break;
            }
            System.out.println(String.format("No"));
            return;
        }
        System.out.println(String.format("Yes", M));
        System.out.println(String.format("%d", M));

        ArrayList<ArrayList<Integer>> a = new ArrayList<ArrayList<Integer>>();
        for(int i=0; i<M; i++) {
            a.add(new ArrayList<>());
        }
        int s=0;
        int t=1;
        int v=1;
        while(s<M-1) {
            while(t<M) {
                a.get(s).add(v);
                a.get(t).add(v);
                v++;
                t++;
            }
            s++;
            t=s+1;
        }
        for(int i=0; i<M; i++) {
            System.out.print(String.format("%d ", a.get(i).size()));
            for(int k=0; k<a.get(i).size(); k++) {
                if(k!=0) System.out.print(" ");
                System.out.print(String.format("%d", a.get(i).get(k)));
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 104960
# -*- coding: utf-8 -*-


def main():
    from collections import defaultdict
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    d = defaultdict(int)
    ans = 0

    # KeyInsight:
    # j - i = Ai + Aj (j > i)、条件つきで絶対値の記号を外す
    # ▲: 計算量を落とす: 片方を固定して、考えられないか?
    # 左辺・右辺を独立として考えられないか?
    # See:
    # https://www.youtube.com/watch?v=OCRLlMa7kL0&feature=youtu.be
    for i in range(n):
        # jまでにiがどれだけ条件を満たすかを判定している
        # Ai + i = j - Aj
        # jの計算に相当
        diff = i - a[i]
        ans += d[diff]

        # iの計算に相当
        summed = i + a[i]
        d[summed] += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61412
sub f{map{push@$_,$a[--$|]for@a=glob}<>;my($x,$b,$w)=($_,1,1);$_-"@_"and($w*=f($x))%=$==1e9+7,$b=$b*$c%$=for@$x;($b+($c=$w))%$=}print f$_+=<>

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	string s;cin>>s;
	int cnt = 0,f=0;
	trav(i,s){
		if(i=='1') cnt++;
	}
	string t;
	trav(i,s){
		if(sz(t)&&t.back()=='1'&&i=='1'){
			t.pop_back();
			f++;
		}
		else t+=i;
	}
	ll ans = 0;
	rep(i,f) ans+=sz(s)-2*i;
	int cur = 0;
	vi v;
	trav(i,t){
		if(i=='0') cur++;
		else v.pb(cur),cur=0;
	}
	v.pb(cur);
	int n = sz(t);
	int sum  =0;
	rep(i,sz(v)-1){
		sum+=v[i];
		ans+=n-2*i;
		ans-=(sum+1)/2;
		ans+=i;
		sum++;
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 4204
#include<bits/stdc++.h>
using namespace std;
int n,a[23],ans;
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=1;i<n-1;i++)if((a[i]<a[i+1]&&a[i-1]<a[i])||(a[i]>a[i+1]&&a[i-1]>a[i]))ans++;
	cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
  long int A,B,K,i;
  scanf("%ld %ld %ld",&A,&B,&K);

  if(A>=K){
    A=A-K;
  }else {
    i = K - A;
    A = 0;
  }
    if(B >= i){
      B=B-i;
    }else {
      B=0;
  }
  printf("%ld %ld",A,B);
  return 0;
}


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

vector<int> to[200005];
vector<bool> seen(200005);

void dfs(int v, int p){
	seen[v] = true;
	for(auto nextv: to[v]){
		if(nextv == v) continue;
		if(seen[nextv] == true) continue;
		dfs(nextv, v);
	}
}

int main(){
	int n,m;
	cin >> n >> m;
	rep(i,n){
		int k;
		cin >> k;
		rep(j,k){
			int l;
			cin >> l;
			to[i].push_back(n+l-1);
			to[n+l-1].push_back(i);
		}
	}
	
	dfs(0, -1);
	bool ok = true;
	
	rep(i,n){
		if(seen[i] == false) ok = false;
	}
	
	if(ok){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
			
    return 0;
}



Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
// #define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
// #define ub(x)       upper_bound(x)
// #define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("b1.in","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
// #define M           1e9+7
#define MAX         50000
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define pi          3.14159265358979323

struct cmp { 
    bool operator() (pii a,pii b){
        return ((a.F-a.F/2)*a.S)<((b.F-b.F/2)*b.S);
    }
};

const int N=1e6+1;
// int n,m,k;
// int cnt[N],all;
const int MOD=1e9+7;
int func(int n){
    return n*(n+1)/2;
}
const bool cmp(int a,int b){
    return a>b;
}

void Anon_mouS(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(max(a*c,b*c),max(a*d,b*d));
}
int32_t main(){
    fastio;
    int q=1;
    // sieve();
    // cin>>q;
    for(int it=1;it<=q;it++){
        // cout<<"Case #"<<it<<": ";
        Anon_mouS();
    }
    return 0;   
}

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

int main() {
  int H;
  int stone[10][5];
  int i, j, k;
  int score;

  while(1) {
    score = 0;
    cin >> H;

    if(H == 0) break;
  
    for(i = 0; i < H; i++) {
      for(j = 0; j < 5; j++) {
	cin >> stone[i][j]; 
      }
    }
    
    while(1) {
      //石を消去
      int score_temp = 0;
      
      for(i = 0; i < H; i++) {
	for(j = 0; j < 3; j++) {
	  for(k = 1; k + j < 5; k++) {
	    if(stone[i][j] != stone[i][j+k]) {
	      break;
	    }
	  }
	  if(k < 3) {
	    continue;
	  }
	  for(int l = 0; l < k; l++) {
	    score_temp += stone[i][j+l];
	    stone[i][j+l] = 0;
	  }
	}
      }
      
      
      if(score_temp == 0) break;
      score += score_temp;
      
      //石を落下
      
      for(j = 0; j < 5; j++) {
	for(i = 0; i < H; i++) {
	  for(k = H-1; k > i; k--) {
	    if(stone[k][j] == 0) {
	      stone[k][j] = stone[k-1][j];
	      stone[k-1][j] = 0;
	    }
	  }
	}
      }
    }
    cout << score << endl;
  }  
  return 0;
}



Measured memory_bytes: 3060
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(input())
  ans = 0
  for i in range(1, N+1):
    if len(str(i))%2==1:
      ans += 1
  print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#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 A, B, C, D;
  cin >> A >> B >> C >> D;
  while (1) {
    C -= B;
    if (C <= 0) {
      puts("Yes");
      break;
    }
    A -= D;
    if (A <= 0) {
      puts("No");
      break;
    }
  }
  return 0;
}

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

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define PI 3 .14159265

//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP(a,b) make_pair( a, b )

#define MOD 1000000007LL
#define INF 1000000000
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= e38d; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)   
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
#define endl "\n"
const int mod =1e9+7;
const ll inf=1e18L+5;
void min_(ll &a,ll b)
{
    a=min(a,b);
}
ll sum;
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    ll n,W;
    cin>>n>>W;
    vector<ll> w(n),val(n);
    for(int i=0;i<n;++i) cin>>w[i]>>val[i];
    for(ll x:val)
    {
        sum+=x;
    }
    vector<ll> dp(sum+1,inf);
    dp[0]=0;
    for(int item=0;item<n;++item)
    {
        for(int i=sum-val[item];i>=0;--i)
        {
            min_(dp[i+val[item]],dp[i]+w[item]);
        }
    }
    ll ans=0;
    for(ll i=0;i<=sum;++i)
    {
        if(dp[i]<=W) ans=max(ans,(ll)i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 4e5 + 5, mod = 998244353;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int l, r;
    cin >> l >> r;
    vector<int> v;
    int ans = 2e9;
    for(int i = l; i <= min(l + 4100, r); i++){
        v.push_back(i % 2019);
    }
    int n = v.size();
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            ans = min(ans, (v[i] * v[j]) % 2019);
        }
    }
    cout << ans;

    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  map<char, bool> m;
  bool ans = true;

  for(char c : s) {
    if (m[c]) {
      ans = false;
      break;
    }
    m[c] = true;
  }

  if (ans) cout << "yes" << endl;
  else cout << "no" << endl;
  
  return 0;
}


Measured memory_bytes: 3596
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  for (let i = 1; i < input.length; i++) {
    const S = input[i].split(' ')
    for (let j = 0; j < S.length; j++) {
      if (S[j] == 'snuke') {
        console.log(abc[j] + i)
        return
      }
    }
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 30552
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
#define br "\n"

void solve(){
    ll n;
    cin >> n;
    vll v(n);
    rep(i,0,n){
        cin >> v[i];
    }
    vll a;
    ll b = 1;
    ll i = 0;
    while(i < n){
        if(b == 1){    
            while(i + 1 < v.size() && v[i] >= v[i + 1]){
                i++;
            } 
            a.pb(v[i]);
            b = 0;
            i++;
        }
        else{
            while(i + 1 < v.size() && v[i] <= v[i + 1]){
                i++;
            }
            a.pb(v[i]);
            b = 1;
            i++;
        }
    }
    if(a.size() % 2 == 1) a.pop_back();
    ll ans = 1000;
    ll save = 0;
    for(ll j = 0; j < a.size(); j++){
        if(j % 2 == 0){
            save = ans - (ans % a[j]);
            ans = ans - save;
            save = (save/a[j]);
        }
        else{
            ans = ans + (save)*a[j];
        }
    }
    cout << ans << br;


}
 
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#include<map>
#include<deque>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> line(N);
    LL sum = 0;
    REP(i, N){
        cin >> line[i];
        sum += line[i];
    }
    LL ans = N<=K?sum:0;
    REP(i, N){
        for(int j = N - 1;i <= j;--j){
            if(i + N - 1 - j > K)continue;
            LL nsum = 0;
            vector<int> nl;
            REP(k, i){
                nl.push_back(line[k]);
                nsum += line[k];
            }
            for(int k = N - 1;k > j;--k){
                nl.push_back(line[k]);
                nsum += line[k];
            }
            sort(ALL(nl));
            REP(k, min((int)nl.size(), K-(i+N-1-j))){
                if(nl[k]>0)break;
                nsum -= nl[k];
            }
            ans = max(ans, nsum);
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 M1, D1; cin >> M1 >> D1;
    i64 M2, D2; cin >> M2 >> D2;

    if (M1 == M2) cout << 0 << endl;
    else cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 3600
n = (int)(input())
a = list(map(int, input().split(" ")))
total = sum(a)
temp = 0
for i in range(n):
  #print(a[i])
  temp += a[i]
  if temp >= total - temp:
    ko1 = abs(temp - (total - temp))
    temp -= a[i]
    ko2 = total - 2 * temp
    print(min(ko1, ko2))
    break

Measured memory_bytes: 31680
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

bool compare_b(tuple<string,int,int> a, tuple<string,int,int> b){
  if(get<0>(a) != get<0>(b)){
    return get<0>(a) < get<0>(b);
  }

  if(get<1>(a) != get<1>(b)){
    return get<1>(a) > get<1>(b);
  }
}

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

  vector<tuple<string, int,int>> vec(N);
  rep(i,N){
    string a;
    int b,c;
    cin >> a >> b;
    c = i+1;
    tuple<string,int,int> p(a,b,c);
    vec.at(i) = p;
  }

  sort(vec.begin(),vec.end(),compare_b);

  rep(i,N){
    string d;
    int e,f;
    tie(d,e,f) = vec.at(i);
    cout << f << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef list<ll> listl;
typedef string str;

#define min(A, B) min(static_cast<ll>(A), static_cast<ll>(B))
#define max(A, B) max(static_cast<ll>(A), static_cast<ll>(B))

void in(ll& I)
{
	cin >> I;
}

void in(vl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(listl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(str& s)
{
	cin >> s;
}

void out(ll& O)
{
	cout << O;
}

void out(ll O)
{
	cout << O;
}

void out(vl& O)
{
	for (auto& o : O)
	{
		cout << o;
	}
}

struct ITR
{
	ll i = 0;
	vector<ITR*> N;
	vector<ll> L;
	ll Color = 0;
};

struct Buf
{
	ll U;
	ll V;
	ll W;
};

void Color(ITR* I, ITR* P, ll C)
{
	I->Color = C;
	ll Size = I->N.size();
	for (int i = 0; i < Size; i++)
	{
		if (I->N[i] == P)continue;
		Color(I->N[i], I, I->L[i] % 2 == 0 ? I->Color : 1 - I->Color);
	}
}

int main()
{
	ll N;
	in(N);

	vector<Buf> B(N - 1);
	for (auto& b : B)
	{
		cin >> b.U;
		cin >> b.V;
		cin >> b.W;
	}

	vector<ITR> I(N + 1);

	for (int i = 0; i <= N; i++)
	{
		I[i].i = i;
	}

	for (auto& b : B)
	{
		I[b.U].N.push_back(&I[b.V]);
		I[b.U].L.push_back(b.W);

		I[b.V].N.push_back(&I[b.U]);
		I[b.V].L.push_back(b.W);
	}

	Color(&I[1], nullptr, 0);

	for (ll i = 1; i <= N; i++)
	{
		cout << I[i].Color << endl;
	}

	return 0;
}

Measured memory_bytes: 16512
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
        int T = sc.nextInt();
        int S = sc.nextInt();
        
        if(S*T>=D){
            System.out.println("Yes");

        }else{
            System.out.println("No");
        }
        
        
        
        
        
        
        
        
        
          
        }
    }

Measured memory_bytes: 35648
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int K,N;
    cin >> K >> N;
    vector<int> dis(N);
    rep(i,N) cin >> dis[i];
    sort(dis.begin(), dis.end());
    pair<int,int> mi;
    mi.first = 0;
    rep(i, N){
        int dif;
        if(i+1 != N) dif = dis[i+1] - dis[i];
        else dif = K-dis[i]+dis[0];
        if(mi.first < dif){
            mi.first = dif;
            mi.second = i+1; if(i+1 == N) mi.second = 0;
        }
    }
    if(mi.second == 0) cout << dis[N-1] - dis[0] << endl;
    else cout << dis[mi.second-1]-(dis[mi.second]-K) << endl;
    return 0;
}

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

typedef long long lint;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;

const int INF = 2e9;
const int MAX = 2e5+10;
const lint LNF = 2e18;

int n, q; // s-x가 작은것 부터

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

	map<int, vector<int>> inc;
	cin>>n>>q;
	for(int i=1; i<=n; i++){
		int s,t,x; cin>>s>>t>>x;
		inc[s-x].push_back(x), inc[t-x].push_back(-x);
	}

	// for(auto p:inc){
	// 	cout<<p.first<<": ";
	// 	for(int x:p.second) cout<<x<<' ';
	// 	cout<<'\n';
	// }
	// cout<<'\n';
	
	for(int i=1; i<=q; i++){
		static multiset<int> S;
		int d; cin>>d;
		while(!inc.empty() && inc.begin()->first<=d){
			vector<int> &V = inc.begin()->second;
			for(int x:V){
				if(x<0) S.erase(S.find(-x));
				else S.insert(x);
			}
			inc.erase(inc.begin());
		}
		if(S.empty()) cout<<-1<<'\n';
		else cout<<*S.begin()<<'\n';
		
	}

	return 0;
}


Measured memory_bytes: 45056
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    ll N,M,K;
    cin >> N >> M >> K;
    vll A_(N+2),B_(M+2);
    vll A(N+1),B(M+1);
    rep(i,N) cin >> A_[i];
    rep(i,M) cin >>B_[i];
    ll a = 0,b=0;
    A[0] = 0;
    rep(i,N){
        a+=A_[i];
        A[i+1] = a;
    }
    B[0] = 0;
    rep(i,M){
        b+=B_[i];
        B[i+1] = b;
    }
    A.push_back(A[N]+1);
    B.push_back(B[M]+1);

    ll i,j;
    i = distance(A.begin(),upper_bound(A.begin(),A.end(),K));
    i--;

    j = distance(B.begin(),upper_bound(B.begin(),B.end(),K-A[i]));
    j--;

    ll ans = 0;
    for (; i >= 0; i--)
        for (; j <= M && A[i]+B[j] <= K; j++)
        {
            if(ans < i+j)
                ans = i+j;
        }
    




    // ll ans = 0;
    // j = 0;
    // while(i >= 0){
    //     j = distance(B.begin(),lower_bound(B.begin(),B.end(),K-A[i]));
    //     // if(j!=0){
    //         // j--;
    //         if(i+j+1 > ans)
    //         {
    //             ans = i+j+2;
    //         }
    //     // }
    //     i--;
    // }
    cout << ans << endl;

}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var dp = new int[N + 1];
        dp[0] = 0;
        for (int i = 1; i <= N; ++i) dp[i] = 100000;
        for (int i=1;i<=N;i++)
        {
            for(int j = 1; j <= i; j *= 6)
            {
                dp[i] = Math.Min(dp[i],dp[i-j]+1);
            }
            for (int k = 1; k <= i; k *= 9)
            {
                dp[i] = Math.Min(dp[i], dp[i - k] + 1);
            }
        }
        Console.WriteLine(dp[N]);
    }
}

Measured memory_bytes: 11232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastScanner fs=new FastScanner();
        int n=fs.nextInt();
        long mod= (long)(1e9+7);
        int[] in=fs.readArray(n);
        long sum=0;
        long ans=0;
        for (int i=0; i<n; i++) {
            ans+=(sum*in[i])%mod;
            ans%=mod;
            sum+=in[i];
            sum%=mod;
        }


        System.out.println((long)(ans%mod));
    }
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 54964
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=5005;
const int mod=1e9+7;
int dp[maxn][maxn];
signed main() {
	int n;
	string str;
	cin>>n>>str;
	int m=str.length();
	dp[0][0]=1;
	for(int i=1 ; i<=n ; i++) {
		for(int j=0 ; j<=i ; j++) {
			if(i==1&&j==0) dp[1][0]=1;
			else {
				if(j==0) dp[i][j]=(dp[i-1][j]+2*dp[i-1][1])%mod;
				else dp[i][j]=(2*dp[i-1][j+1]+dp[i-1][j-1])%mod;
			}
		}
	}
	cout<<dp[n][m]%mod;
}

Measured memory_bytes: 120284
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename T, typename U> P<T,U> operator+(const P<T,U> &a, const P<T,U> &b){return {a.first + b.first, a.second + b.second};}
template <typename T, typename U> P<T,U> operator-(const P<T,U> &a, const P<T,U> &b){return {a.first - b.first, a.second - b.second};}
template <typename T> void cout_join(vector<T> &v,string d=" "){REP(i,v.size()){if(i>0)cout<<d;cout<<v[i];}cout<<endl;}

const LLI mod = 1e9+7;

LLI dp[110][1<<7][8];

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

  int h,w,k; cin >> h >> w >> k;

  vector<int> pattern;

  REP(i,1<<(w-1)){
    bool f = true;
    REP(j,w-2){
      if((1&(i>>j)) && (1&(i>>(j+1)))){
	f = false;
	break;
      }
    }
    if(f) pattern.push_back(i);
  }

  //cout_join(pattern);
  
  dp[0][0][0] = 1;

  FORE(i,1,h){
    for(auto j : pattern){
      REP(p,w){

	int m;
	if(p==0){
	  if(j & 1) m=1;
	  else m=0;
	}else if(p==w-1){
	  if(j & (1<<(w-2))) m=w-2;
	  else m=w-1;
	}else{
	  if(j & (1<<p)) m=p+1;
	  else if(j & (1<<(p-1))) m=p-1;
	  else m=p;
	}


	for(auto l : pattern){
	  (dp[i][j][p] += dp[i-1][l][m]) %= mod;

	}
      }
    }
  }


  LLI ans = 0;
  for(auto i : pattern){
    (ans += dp[h][i][k-1]) %= mod;
  }

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


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans=a+b+c+max(a,max(b,c))*(pow(2,k)-1);
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
lst = []

for i in range(n):
  a, b = input().split()
  b = int(b)
  lst.append([a, b])
x = input()
sum_time = 0
flag = False
for i in lst:
  if flag:
    sum_time += i[1]
  if i[0] == x:
    flag = True
print(sum_time)


Measured memory_bytes: 3060
# coding: utf-8

from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect


a, b = map(int, input().split(" "))

p = "Positive"
n = "Negative"
z = "Zero"

if a > 0:
    print(p)
elif a == 0 or b == 0:
        print(z)
else:
    # a < 0
    if b >= 0:
        print(z)
    else:
        # a < 0, b < 0
        if (b - a) % 2 == 0:
            print(n)
        else:
            print(p)


Measured memory_bytes: 5844
#include<iostream>
#include<stdio.h>
#define MAX 100004
#define NIL -1

struct Node { int parent, left, right, depth; };	//親、最も左の子、右隣の兄弟、深さ
Node T[MAX];	//根付き木

using namespace std;

//深さを求める関数
void Depth(int r, int s) {
	T[r].depth = s;
	if (T[r].left != NIL) {
		Depth(T[r].left, s + 1);		//子の深さ
	}if (T[r].right != NIL) {
		Depth(T[r].right, s);		//兄弟の深さ
	}
}

//子の出力
void printchild(int q){
	int s = T[q].left;
	int count = 0;
	printf("[");
	while(s != NIL){
		if (count != 0) printf(", ");
		printf("%d", s);
		s = T[s].right;
		count++;
	}
	printf("]\n");
}

int main() {
	int n, id, k, c;	//節点の個数、番号、子の数、子の節点番号
	int p;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		T[i].depth = NIL;
		T[i].parent = NIL;
		T[i].left = NIL;
		T[i].right = NIL;
	}
	for (int i = 0; i 
		< n; i++){
		cin >> id >> k;
		for (int j = 0; j < k; j++) {
			cin >> c;
			if (j == 0) T[id].left = c;		//左の子の設定
			else {
				T[p].right = c;		//兄弟の設定
			}
			p = c;
			T[c].parent = id;	//親の設定

		}

	}
	int r = 0;
	for (int i = 0; i < n; i++) {
		if (T[i].parent == NIL) {
			r = i;
		}
	}
	
	Depth(r, 0);

	for (int i = 0; i < n; i++) {
		if (T[i].parent == NIL) {
			printf("node %d: parent = %d, depth = %d, root, ", i, T[i].parent, T[i].depth);
			printchild(i);
		}
		else if (T[i].left == NIL) {
			printf("node %d: parent = %d, depth = %d, leaf, ", i, T[i].parent, T[i].depth);
			printchild(i);
		}
		else {
			printf("node %d: parent = %d, depth = %d, internal node, ", i, T[i].parent, T[i].depth);
			printchild(i);
		}
	}
	
	return 0;
}


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

#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define all(x) (x).begin(), (x).end()

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int MOD = 1000000007;

int main() {
    IOS;
    int a, b, t;
    cin >> a >> b >> t;
    int k = t/a;
    cout<<(k*b)<<"\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    cin >> n;
    string st;
    int s[n];
    cin >> st;
    rep(i, n){
        if(st[i] == 'R') s[i] = 0;
        else if(st[i] == 'G') s[i] = 1;
        else s[i] = 2;
    }
    long long cnt = 0;

    for(int i = 0; i < n-3; i++){
        for(int j = i+1; j < n-1; j++){
            if(s[i]!=s[j]){
                for(int k = j+1; k < n; k++){
                    if(s[j]!=s[k] && s[k]!=s[i] && (j-i)!=(k-j)) cnt++;
                }
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
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;}
bool seen[100000];
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

ll monster(ll X) {
    if (X == 1) return 1;
    else {
        X /= 2;
        return 2 * monster(X) + 1;
    }
}

//input
ll H;


//processing




//dpTable
//int dp[100050];
int main(){
    cin >> H;
    cout << monster(H) << endl;
    return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}
void solve()
{
	int n, x;
	cin >> n >> x;
	int a[n];
	ll res = 0;
	rep(i, n) cin >> a[i];
	rep(i, n){
		if(i){
			int sum = a[i] + a[i - 1];
			int p = min(a[i], max(0, sum - x));
			a[i] -= p;
			sum -= p;
			res += 1ll * p;
			p = min(a[i - 1], max(0, sum - x));
			a[i - 1] -= p;
			sum -= p;
			res += 1ll * p;
		}
	}
	cout << res;
}	 

 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}


Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100000;


int main(){
  int A = in(), B = in(), K = in(), count = 0, ans;
  if(A < B) swap(A, B);

  for(int i = B; i >= 1; i--){
    if(A % i == 0 && B % i == 0)count++;
    if(count == K){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

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

int main() {
    int m, f, r, p;

    while(1) {
        cin >> m >> f >> r;
        p = m + f;
        if (m == -1 && f == -1 && r == -1) break;
        
        if (m == -1 || f == -1 ) cout << "F" << endl;
        else if ( p >= 80 ) cout << "A" << endl;
        else if ( p >= 65 ) cout << "B" << endl;
        else if ( p >= 50 ) cout << "C" << endl;
        else if ( p >= 30 ) {
            if ( r >= 50 ) cout << "C" << endl;
            else cout << "D" << endl;
        }
        else cout << "F" <<endl;

    }
    return 0;
}


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

int main()
{
    int N,K,Q,a;
    cin>>N>>K>>Q;
int B[N]{};    

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

    
     for(int i=0;i<N;i++){
        if(K-Q+B[i]>=1) {
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    
    
    return 0;
}


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

int main() {
  vector<int> a(5) ;
  cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3) >> a.at(4);
  for(int i = 0; i < 5; i++){
    if(a.at(i) == 0){
      cout <<  i + 1 << endl;
      break;
    }
    }
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  int N;
  cin>>N;
  bool CAN=true;
  vector<int> L;
  REP(i,N){
    int a; cin>>a;
    L.push_back(a);
  }
  
  SORT(L);
  int DIM[L.at(N-1)+1];
  REP(i,L.at(N-1)+1) DIM[i]=0;
  for(int i=0; i<L.size(); ++i) DIM[L.at(i)]++;
  
  if(L.at(N-1)%2==0){
    if(L.at(N-1)!=2*L.at(0)) CAN=false;
    for(int i=L.at(0)+1; i<=L.at(N-1); ++i){
      if(DIM[i]<2) CAN=false;
    }
    if(DIM[L.at(0)]!=1) CAN=false;
  }
  else{
    if(L.at(N-1)!=2*L.at(0)-1) CAN=false;
    for(int i=L.at(0); i<=L.at(N-1); ++i){
      if(DIM[i]<2) CAN=false;
    }
    if(DIM[L.at(0)]!=2) CAN=false;
  }
  
  if(CAN) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n,a,b = map(int, input().split())
k = abs(a - b)
if k % 2 == 1:
    count = 0
    if n - b > a - 1:
        count += a - 1 + 1 + ((k - 1) // 2)
    else:
        count += n - b + 1 + ((k - 1) // 2)
    print(int(count))
else:
    print(k // 2)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    string s;
    cin >> s;

    bool ok = true;

    REP(i,3){
       if (s[i] == s[i+1]) ok = false;
    }

    if (ok) cout << "Good" << endl;
    else cout << "Bad" << endl;

    return 0;
}


Measured memory_bytes: 256
// VSCF.cpp : Defines the entry point for the console application.
//
#include <cassert>
#include <functional>
#include <cmath>
#include <list>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <sstream>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define FOR(v,p,k) for(int v=p;v<=k;++v)
#define FORD(v,p,k) for(int v=p;v>=k;--v)
#define REP(i,n) for(int i=0;i<(n);++i)
#define VAR(v,i) __typeof(i) v=(i)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define PB push_back
#define ST first
#define ND second
#define SIZE(x) (int)x.size()
#define ALL(c) c.begin(),c.end()
#define int long long
#define MAXN 1000010
typedef long double LD;

#undef int
int main() {
#define int long long
	int k, t;
	cin >> k >> t;
	int sum = 0;
	int mx = 0;
	REP(i, t) {
		int a;
		cin >> a;
		sum += a;
		mx = max(mx, a);
	}
	cout << max(mx - (sum - mx) - 1, 0LL) << "\n";
	return 0;
}



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

int W, H;
vector<string> str;
bool used[70][70];
string memo[70][70];
const int dx[] = { 1, 0 };
const int dy[] = { 0, 1 };


bool Comp(const string& l, const string& r) {
	return l.size() == r.size() ? l < r : l.size() < r.size();
}

string MAX(const string& l, const string& r) {
	return Comp(l, r) ? r : l;
}

string dfs(int x, int y) {
	if (memo[x][y] != "") return memo[x][y];
	string res[2];
	for (int i = 0; i < 2; i++) {
		int tx = x + dx[i], ty = y + dy[i];
		if (tx >= 0 && tx < H && ty >= 0 && ty < W && str[tx][ty] >= '0' && str[tx][ty] <= '9') {
			res[i] = dfs(tx, ty);
		}
	}
	used[x][y] = true;
	return memo[x][y] = str[x][y] + MAX(res[0], res[1]);
}

int main()
{
	while (cin >> W >> H, W || H) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				used[i][j] = false;
				memo[i][j].clear();
			}
		}
		str.resize(H);
		for (int i = 0; i < H; i++) {
			cin >> str[i];
		}
		string res;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (!used[i][j] && str[i][j] >= '1' && str[i][j] <= '9') {
					res = MAX(res, dfs(i, j));
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>
using namespace std;
int main(void){
    string a,b;
    cin>>a>>b;
    b.erase(b.size()-1);
    if(a==b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632