akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9
vector<int> S;
bool binary_search(int key){
  int left = 0, right = S.size()-1;
  while(right >= left){
    int mid = left + (right-left)/2;
    if(S[mid] == key){
      return true;
    }
    else if(S[mid] > key){
      right = mid-1;
    }
    else{
      left = mid+1;
    }
  }
  return false;
}

int main(){
  int n;
  cin >> n;
  S.resize(n);
  REP(i, n){
    cin >> S[i];
  }
  int q;
  cin >> q;
  vector<int> T(q);
  REP(i, q){
    cin >> T[i];
  }
  sort(S.begin(), S.end());
  int ans = 0;
  REP(i, q){
    if(binary_search(T[i])){
      ans++;
    }
    else{
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3340
n,m=map(int,input().split())

k=[list(map(int,input().split()))[1:] for i in range(m)]

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

count=0
flag=True
for i in range(1<<n):
    flag=True
    for j in range(m):
        count2=0
        for l in k[j]:
            if i & (1<<(l-1)):
                count2+=1
        if not count2%2==p[j]:
            flag=False
    if flag:
        count+=1

print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
#define MOD 998244353
vpii v;
ll a[N] = {}, b[N] = {1, -1};

int main(){
	int n, k; scanf("%d%d", &n, &k);
	REP(i, k) {
		int p, q; scanf("%d%d", &p, &q); q++;
		v.EB(p, q);
	}
	REP(i, n){
		a[i] = b[i] % MOD;
		b[i+1] = (b[i] + b[i+1]) % MOD;
		DEBUG("a[%d] = %lld\n", i, a[i]);
		for(auto &[p, q] : v){
			b[min(i+p, n)] +=     a[i];
			b[min(i+q, n)] += MOD-a[i];
		}
		// REP(i, n+1) DEBUG("%2lld  ", b[i]); DEBUG("\n");
	}
	printf("%lld\n", a[n-1]);
}


Measured memory_bytes: 6960
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .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)*}
    }
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt), * )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($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, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}



fn main() {
    input!(n: usize, k: i32, h:[i32; n]);
    let sum = h.iter().filter(|&x| x >= &k).count();
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int a,b,c;
    string s;
    cin>>s;
    if(s[1]=='B'){
        cout<<"ARC"<<endl;
    }
    else {
        cout<<"ABC"<<endl;
    }
    return 0;
}




Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
	int a,b,c;

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);

	if(a<b && b<c){
		printf("Yes\n");
		}

	else{	
		printf("No\n");
		}

	return 0;
}


Measured memory_bytes: 2140
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int UF[110000];
int d[110000];
pair<int,int> FIND(int a){
	if(UF[a]<0)return make_pair(a,0);
	pair<int,int> par=FIND(UF[a]);
	d[a]+=par.second;
	UF[a]=par.first;
//	printf("%d: %d %d\n",a,par.first,d[a]);
	return make_pair(par.first,d[a]);
}
bool dame=false;
void UNION(int a,int b,int c){
	pair<int,int>L=FIND(a);
	pair<int,int>R=FIND(b);
	if(L.first==R.first){
		if(L.second+c!=R.second){
			dame=true;
		}
		return;
	}
	UF[R.first]=L.first;
	d[R.first]=c+L.second-R.second;
	//printf("%d %d %d\n",b,UF[b],d[b]);
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)UF[i]=-1;
 
	for(int i=0;i<b;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);
		p--;q--;
		UNION(p,q,r);
		if(dame){
			printf("No\n");return 0;
		}
	}
	printf("Yes\n");
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vec vector<int>
#define vecll vector<ll>

using namespace std;
///////////////////////////////////////////////////////////



int main() {
    double h, a;
    cin >> h >> a;
    int ans = ceil(h / a);
    cout << ans << endl;


    return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		





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

	VLL v(50);
	if (k < 50) {
		REP(i, 50)v[i] = 49;
	}
	else {
		k -= 50;
		REP(i, 50) {
			v[i] = 50 + k / 50;
		}
	}
	k %= 50;
	REP(i, k) {
		REP(j, 50) {
			if (i == j)v[j] += 50;
			else v[j]--;
		}
	}
	cout << 50 << endl;
	REP(i, 50)cout << v[i] << ' ';
}

Measured memory_bytes: 256
visited = []

def dfs(v):
    for i in edges[v]:
        if i not in visited:
            dfs(i)
    visited.append(v)

if __name__ == '__main__':
    m = int(input())
    n = int(input())
    edges = [[] for i in range(m)]
    for i in range(n):
        x, y = map(int, input().split())
        edges[x - 1].append(y - 1)
    for i in range(m):
        if i not in visited:
            dfs(i)
    ans = reversed([i + 1 for i in visited])
    print('\n'.join(map(str, ans)))

Measured memory_bytes: 6724
S = input()
from collections import defaultdict
d = defaultdict(lambda:0)
N = len(S)
s = 0
p = [1]*N
for i in range(N):
    p[i] = p[i-1]*10%2019

for i in range(N-1,-1,-1):
    s += int(S[i])*(p[N-1-i])
    s %= 2019
    d[s] += 1
ans = 0
for k in d:
    n = d[k]
    ans += (n*(n-1))//2
ans += d[0]
print(ans)

Measured memory_bytes: 76224
#include <iostream>

using namespace std;

int main() {
    for (int N, M, L, K, A, H; cin >> N >> M >> L >> K >> A >> H, N | M | L | K | A | H;) {
        bool freez[100];
        int  time[100][100];

        const int INF = 900100100 / 4;

        for (int i = 0; i < N; ++i) {
            freez[i] = false;

            for (int j = 0; j < N; ++j) time[i][j] = INF;
        }

        for (int i = 0; i < L; ++i) {
            int x;
            cin >> x;
            freez[x] = true;
        }

        freez[H] = freez[A] = true;

        for (int i = 0; i < K; ++i) {
            int x, y, t;
            cin >> x >> y >> t;
            time[x][y] = time[y][x] = t;
        }

        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                for (int k = 0; k < N; ++k) time[j][k] = min(time[j][i] + time[i][k], time[j][k]);

        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                if (!freez[i] || !freez[j] || time[i][j] > M) time[i][j] = INF;

        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                for (int k = 0; k < N; ++k) time[j][k] = min(time[j][i] + time[i][k], time[j][k]);

        if (time[A][H] == INF)
            cout << "Help!" << endl;
        else
            cout << time[A][H] + max(0, time[A][H] - M) << endl;
    }

    return 0;
}



Measured memory_bytes: 3004
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int dp[4001][4001];
int main(void){
	while(1){
		string s1, s2; cin >> s1 >> s2;
		if(s1 == "") return 0;
		int s1size = s1.size(), s2size = s2.size();
		rep(i, 4001) dp[i][0] = dp[0][i] = 0;
		//dp[i][j] = dp[s1???i??????????????§][s2???j??????????????§] = (??£?¶???????????????????)

		int ans = 0;
		rep(i, s1size){
			rep(j, s2size){
				if(s1[i] == s2[j]){
					dp[i + 1][j + 1] = dp[i][j] + 1;
					ans = max(ans, dp[i + 1][j + 1]);
				}else{
					dp[i + 1][j + 1] = 0;
				}

			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

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

    set<char> odd = {'R', 'U', 'D'};
    set<char> even = {'L', 'U', 'D'};

    string s; cin >> s;
    rep(i, s.size()) {
        if (i%2 != 0) {
            if (!even.count(s[i])) {
                cout << "No" << endl;
                return 0;
            }
        }
        if (i%2 == 0) {
            if (!odd.count(s[i])) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf INT_MAX
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("%d %d",&a,&b)
#define sccc(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pff(a,b) printf("%d %d",a,b)
#define pfff(a,b,c) printf("%d %d %d",a,b,c)
#define pb(a) push_back(a)
#define em empty()
#define fr front()
#define cl clear()
#define sz size()
#define mp(a,b) make_pair(a,b)
#define fri(b) freopen(b,"r",stdin)
#define fro(b) freopen(b,"w",stdout)
/*
ID: uslusam1
TASK: test
LANG: C++
*/
using namespace std;

int main(){
	//fri("a.gir");
	//fro("a.cik");
	long long n;
	cin>>n;
	long long x=(int)sqrt(n);
	while(n%x!=0){
		x--;
	}
	long long y=n/x;
	cout<<x+y-2;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = 4
if n == 2 or n == 1:
         print(4)
         exit()
while n != 4:
         if n % 2 == 0:
                  n = (n//2)
                  ans += 1
         else:
                  n = (n*3)+1
                  ans +=1
print(ans)


Measured memory_bytes: 3316
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
//		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			//aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
	//	aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
const int N = 1e5 + 50;
int a[N], cnt1[N], cnt2[N];
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int>a(n), b(m);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int cnt = 0,xx=-1,yy=0;
	while (cnt < 100)
	{
		if (xx > x&&xx <= y&&xx > a[n - 1] && xx <= b[0])
			return cout << "No War\n", 0;
		else
			xx--;
		if(yy>x&&yy<=y&&yy>a[n-1]&&yy<=b[0])
			return cout << "No War\n", 0;
		else yy++;
		cnt++;
	}
	cout << "War\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    bool isok = false;
    for(int i=0; i<=n/4; i++){
        for(int j=0; j<=n/7; j++){
            if(4*i+7*j==n){
                isok = true;
                break;
            }
        }
        if(isok){
            break;
        }
    }
    if(isok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int n,p = 0;
  cin >> n;
  vector<int>data(1000000);
  data.at(0) = n;
  if(n%2 == 0){
    data.at(1) = n/2;
  }
  else{
    data.at(1) = 3*n+1;
  }
  for(int i = 2;i < 1000000; i++){
    if(data.at(i-1)%2 == 0){
      data.at(i) = data.at(i-1)/2;
    }
    else{
      data.at(i) = data.at(i-1)*3+1;
    }
    for(int j = 0;j < i;j++){
      if(data.at(i) == data.at(j)){
        cout << i+1 << endl;
        p = 1;
        break;
      }
    }
    if(p == 1){
      break;
    }
  }
}

Measured memory_bytes: 4096
import heapq
class edge:
    def __init__(self,to,cost):
        self.to=to
        self.cost=cost

N,W=map(int,input().split())
G=[list() for i in range(N)]
for i in range(W):
    a,b,c=map(int,input().split())
    G[a-1].append(edge(b-1,c))
    G[b-1].append(edge(a-1,c)) #無向グラフならこれも

def dijkstra(o):
    d=[float('inf') for i in range(N)]
    d[o]=0
    hq=[]
    prev=[[] for i in range(N)]
    heapq.heappush(hq,(0,o))
    while hq:
        p=heapq.heappop(hq)
        v=p[1]
        if(d[v]<p[0]):
            continue
        for i in G[v]:
            if(d[i.to]>d[v]+i.cost):
                d[i.to]=d[v]+i.cost
                prev[i.to]=prev[v]+[str(sorted([v,i.to]))]
                heapq.heappush(hq,(d[i.to],i.to))
    return d,prev


ans=set()
for i in range(N):
    tmp=dijkstra(i)[1]
    for j in tmp:
        if(j):
            ans.add(str(j[0]))
print(W-len(ans))

Measured memory_bytes: 3564
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;

typedef struct pp {
    char name[100];
    int t;
} P;

int main() {
    queue<P> Q;
    int n,q,a,current=0;
    P buf;
    scanf("%d",&n);
    scanf("%d",&q);

    for(int i=1;i<=n;i++){
        P buff;
        scanf("%s",buff.name);
        scanf("%d",&buff.t);
        Q.push(buff);
    }
    
    while(!Q.empty()){
        buf = Q.front();
        Q.pop();
        a=min(buf.t,q);
        buf.t -= a;
        current += a;
        if(buf.t>0){
            Q.push(buf);
        }else{
            printf("%s %d\n", buf.name, current);
        }
    }
    
}


Measured memory_bytes: 7588
#include <bits/stdc++.h>
using namespace std;
int l[105];
int main()
{
    int x,n;cin>>n>>x;
    for(int i=1;i<=n;i++) cin>>l[i];
    for(int i=1;i<=n;i++) l[i] = l[i-1]+l[i];
    l[n+1]=1000005;
    cout<<upper_bound(l,l+n+2,x)-l<<endl;
    return 0;
}

Measured memory_bytes: 256
x=int(input())
if 400<=x<600:
    print(8)
elif 600<=x<800:
    print(7)
elif 800<=x<1000:
    print(6)
elif 1000<=x<1200:
    print(5)
elif 1200<=x<1400:
    print(4)
elif 1400<=x<1600:
    print(3)
elif 1600<=x<1800:
    print(2)
elif 1800<=x<2000:
    print(1)


Measured memory_bytes: 61612
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<typeof((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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

int fact(int n) {
  if (n == 1) return 1;
  return n * fact(n - 1);
}

int main() {
  int N, M, R;
  cin >> N >> M >> R;
  VI r(R);
  REP(i, R) {
    cin >> r[i];
  }

  VVI d(N + 1, VI(N + 1, INF));

  NREP(i, N) {
    d[i][i] = 0;
  }

  REP(i, M) {
    int A, B, C;
    cin >> A >> B >> C;
    d[A][B] = d[B][A] = C;
  }

  NREP(k, N) {
    NREP(i, N) {
      NREP(j, N) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int min_cost = INF;

  REP(k, fact(R)) {
    int cost = 0;
    REP(i, R - 1) {
      cost += d[r[i]][r[i + 1]];
    }
    min_cost = min(min_cost, cost);
    next_permutation(r.begin(), r.end());
  }

  cout << min_cost << endl;

  return 0;
}

Measured memory_bytes: 384
N = gets.to_i
MOD = 10**9 + 7

def f(n)
  @m ||= {0 => 1, 1 => 2}
  @m[n] ||= (f(n/2) + f((n - 1)/2) + f((n - 2)/2)) % MOD
end

puts f(N)

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

#define ll long long
#define INF 1e9
#define fi first
#define se second

typedef vector <int> vi;
typedef pair <int, int> ii;

vector <vi> adj;
vi dp;

int dfs(int n) {
    if (dp[n] != -1) return dp[n];

    for (int i : adj[n]) {
        dp[n] = max(dp[n], dfs(i));
    }
    return ++dp[n];
}

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

    adj.assign(n, vi(0));
    for (int i = 0; i < e; i++) {
        int a, b;
        cin >> a >> b;
        adj[a-1].push_back(b-1);
    }

    dp.assign(n, -1);

    for (int i = 0; i < n; i++) {
        if (dp[i] == -1) dfs(i);
    }

    int res = 0;
    for (int i = 0; i < n; i++) res = max(res, dp[i]);

    // for (int i = 0; i < n; i++) cout << dp[i] << " ";
    // cout << endl;

    cout << res << endl;
}


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

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

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int h, w; cin >> h >> w;
  vector<string> c(h); rep(i, h) cin >> c[i];
  for (int i = 0; i < h; i++) {
    outl(c[i]);
    outl(c[i]);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[], int N) {
    int i;
    for(i = 0; i < N; i++) {
        if(i>0)printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N){
    int j,i,v;
    for(i=1; i<N; i++) {
        v = A[i];
        j = i - 1;
        while(j>=0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A,N);
    }
}

int main() {
    int N, i, j;
    int A[100];
    
    scanf("%d", &N);
    for (i = 0; i < N; i++) scanf("%d", &A[i]);
    
    trace(A,N);
    insertionSort(A,N);
    
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {
    int x,a,b;
    cin>>x>>a>>b;
    
    int da,db;
    da=fabs(x-a);
    db=fabs(x-b);
    
    if(da<db)printf("A");
    else printf("B");
    
    return 0;
}


Measured memory_bytes: 256
def c_next_letter(S, K):
    s = list(S)
    for t, elem in enumerate(s):
        if t == len(s) - 1 and K > 0:
            # 末尾に来たときに操作回数が残っていたら、その回数だけ操作する
            s[t] = chr(ord('a') + (ord(elem) - ord('a') + K) % 26)
        elif elem == 'a':
            continue  # 文字が最初から'a'ならば、何もしなくていい
        elif ord('z') - ord(elem) + 1 <= K:
            # K回以下の操作で'a'にできるなら、そうする
            s[t] = 'a'
            K -= ord('z') - ord(elem) + 1
    ans = ''.join(s)
    return ans

S = input()
K = int(input())
print(c_next_letter(S, K))

Measured memory_bytes: 4084
#include <iostream>
using namespace std;
int main()
{
	int a,b;

	cin >> a >> b ;

	if ( a < b)
	{
		cout << "a < b\n";
	}

	 else if ( a > b )
	{
		cout << "a > b\n";
	}

	else{
		cout << "a == b\n";
	}

	return 0;
}

Measured memory_bytes: 3048
n,m,x = map(int,input().split())
a = [int(i) for i in input().split()]

count0 = 0
countn = 0
for i in range(x):
    if i in a:
        count0 += 1
for i in range(x,n):
    if i in a:
        countn += 1
ans = min(count0,countn)
print(ans)

Measured memory_bytes: 3188
// Written By NewbieChd
#include <cstdio>
#include <cctype>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline long long read() {
    long long f = 0;
    char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int maxN = 100003;
long long d[maxN];
map<long long, int> mp;

int ind[maxN];
inline bool cmp(int x, int y) { return d[x] > d[y]; }

int siz[maxN];
vector<int> g[maxN];
long long dfs(int x) {
    long long o = 0;
    for (int y : g[x])
        o += dfs(y) + siz[y];
    return o;
}

int main() {
    int n = read(), i, x, y;
    long long tmp;
    for (i = 1; i <= n; ++i)
        d[i] = read(), mp[d[i]] = i, ind[i] = i, siz[i] = 1;
    sort(ind + 1, ind + n + 1, cmp);
    for (i = 1; i < n; ++i) {
        x = ind[i], tmp = d[x] - n + (siz[x] << 1);
        if (mp.find(tmp) == mp.end() || siz[x] << 1 == n) {
            printf("-1\n");
            return 0;
        }
        y = mp[tmp], g[y].push_back(x), siz[y] += siz[x];
    }
    
    if (dfs(ind[n]) == d[ind[n]])
        for (x = 1; x <= n; ++x)
            for (int y : g[x])
                printf("%d %d\n", x, y);
    else
        printf("-1\n");
    return 0;
}


Measured memory_bytes: 17920
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
int  pow(int x,int n) {int res=1; while(n){if(n&1) res=(res*x);x=(x*x);n>>=1;}return res;}
 

 int solve(int n, int a[]){

 		int dp[n+1] ={};
 		// dp[0] =0;
 				int op1=0, op2=0;
 		for(int i=2 ;i<=n; i++ ){
 				op1 = op2 =INT_MAX;

 				op1 = abs(a[i] - a[i-1]) +  dp[i-1];
 				if(i > 2)
 				op2 = abs(a[i] - a[i-2]) +  dp[i-2];

 				dp[i] = min(op1, op2);


 		}

 		return dp[n];
 	
 }
int32_t main()
{
	
	//Paawan Singal
	FIO;
	int n;  cin >> n;
	mk(a, n+1, int );
	for(int i=1 ;i<=n;i++)
		cin >> a[i];


	cout << solve(n, a)<< '\n';
	return 0;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ret = 0;
  int sum_ = 0, xor_ = 0;
  for (int l = 0, r = 0; l < n; l++) {
    while (r < n && (sum_ + a[r]) == (xor_ ^ a[r])) {
      sum_ += a[r];
      xor_ ^= a[r];
      r++;
    }
    ret += r - l;
    sum_ -= a[l];
    xor_ ^= a[l];
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long M = sc.nextLong();
        System.out.println( solve(N, M) );
    }

    private static long solve(long N, long M) {
        // (1, 2) or (0, 4)消費で一つ

        long ans = 0;
        // (1, 2)
        long scc12 = Math.min(N, M / 2);
        ans += scc12;
        N -= scc12;
        M -= scc12 * 2;

        // (0, 4)
        long scc04 = M / 4;
        ans += scc04;

        return ans;
    }
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int N,X;
  cin>>N>>X;
  vector<int> v(N);
  cinv(v,0,N);
  ll res=N;
  ll min=X;
  ll rest=X;
  FOR(i,0,N){
    rest-=v[i];
    if(min>v[i]) min=v[i];
  }
  while(min<=rest){
    rest-=min;
    res++;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int x;
  cin >> x;

  for (ll l = 0, r = 0; l <= x; l += 100, r += 105) {
    if (l <= x && x <= r) {
      cout << 1 << endl;
      return 0;
    }
  }
  
  cout << 0 << endl;
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val factors       = io.StdIn.readLine().split(" ").map{_.toInt}
    val b_nums        = io.StdIn.readLine().split(" ").map{_.toInt}
    var correct_count = 0

    (0 until factors(0)).foreach { i =>
      val a_nums = io.StdIn.readLine().split(" ").map{_.toInt}
      var ab_sum = 0
      (0 until a_nums.length).foreach { j =>
        ab_sum += a_nums(j)*b_nums(j)
      }
      if(ab_sum + factors(2) > 0) correct_count += 1
    }

    println(correct_count)
  }
}

Measured memory_bytes: 25428
#include<bits/stdc++.h>
using namespace std;
long long n,a;
int lele(long long o)
{
	int s=0;
	while(o!=0)
	{
        s+=1;
        o/=10;
    }
    return s;
}
main()
{
	ios::sync_with_stdio(false);
    cin>>n;
    for(int i=sqrt(n);i>0;i--)
    {
        if(n%i==0)
		{
            a=n/i;
            break;
        }
    }
    cout<<lele(a)<<endl;
    return ~~0*~~(0-0)*~~0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n,k;
    cin>>n>>k;
    cout<<(k==1?0:n-k)<<endl;
}

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

int main() {
  int dp[MAX];
  dp[0] = dp[1] = 1;
  for (int i = 2; i < MAX; i++) {
    dp[i] = dp[i - 1] + dp[i - 2];
  }

  int n;
  cin >> n;
  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

#define int long long

using namespace std;

void Main()
{
	int N;
	cin >> N;
	vector<int> A(N + 1, 0);
	vector<int> B(N, 0);
	for (int i = 0; i < N + 1; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	int num = 0;
	for (int i = 0; i < N; i++) {
		int num_i = min(A[i], B[i]);
		num += num_i;
		B[i] -= num_i;
		int num_i1 = min(A[i + 1], B[i]);
		num += num_i1;
		A[i + 1] -= num_i1;
	}
	cout << num << endl;
}

int32_t main()
{
	Main();
	return 0;
}

/*
void sample()
{
	vector<int> v;
	sort(v.begin(), v.end());
	sort(v.begin(), v.end(), greater<int>());

}
*/



Measured memory_bytes: 1792
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

class Program
{
	static void Main(string[] args)
	{
		int[] inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int N = inputintArray[0];
		int M = inputintArray[1];

		int sum = 0;
		for (int i = N - 1; i > 0; i--)
		{
			sum += i;
		}
		for (int i = M - 1; i > 0; i--)
		{
			sum += i;
		}
		Console.WriteLine(sum.ToString());
		Console.ReadKey();
	}
}

//string s = Console.ReadLine();
//int[] inputintArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = inputintArray[0];
//int W = inputintArray[1];
//int N = int.Parse(Console.ReadLine());
//int[] a = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

//Console.WriteLine(ans);

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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    for(int i=0;i<n-1;i++) cin >> b[i];

    for(int i=0;i<n;i++){
        if(i==0){
            a[0]=b[0];
        }else if(i==n-1){
            a[i]=b[i-1];
        }else if(b[i-1]<b[i]){
            a[i]=b[i-1];
        }else{
            a[i]=b[i];
        }
    }
    cout << accumulate(a,a+n,0);
}

Measured memory_bytes: 256
#include<stdio.h>


int main() {
	char str[11];
	int i, maxcount = 0,count = 0;
	scanf("%s", str);
	for (i = 0; str[i] != 0; i++) {
		if (str[i] == 'A' || str[i] == 'T' || str[i] == 'G' || str[i] == 'C') {
			count++;
			if (count > maxcount) { maxcount = count; }
		}
		else { count = 0; }
	}
	printf("%d\n", maxcount);
	return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  string s;
  int w;
  cin >> s >> w;
  for(int i = 0; i < s.length(); i+=w){
    cout << s[i];
  }
  cout << endl;
  return 0;
}


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

int main(){
	string s;
	cin >> s;
	for(int i=1;i<s.size();i++){
		if(s[i]==s[i-1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n,k;
	cin >> n >> k;
	vector<ld> p(n);
	rep(i, n) cin >> p[i];

	vector<ld> sum(n + 1, 0);
	for(int i = 1; i <= n; i++)
		sum[i] = sum[i-1] + (p[i-1]+1)/2;
	ld m = 0;
	for(int i = 0; i <= n-k; i++){
		m = max(m, sum[i+k]-sum[i]);
	}

	cout << fixed << setprecision(10);
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 6528
# hitachi2020_b.py
_, _, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
X = []
Y = []
C = []
amin = min(A)
bmin = min(B)
for i in range(M):
    x, y, c = map(int, input().split())
    X.append(x)
    Y.append(y)
    C.append(c)

ans = amin+bmin
for i in range(M):
    if ans >= A[X[i]-1]+B[Y[i]-1]-C[i]:
        ans = A[X[i]-1]+B[Y[i]-1]-C[i]
print(ans)


Measured memory_bytes: 24804
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;
}


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

using namespace std;

int main() {
    int n, temp, add;
    cin >> n;
    vector<int> v(n+1, 0);
    for(int x = 1; x*x <= n; x++) {
        for(int y = x; y*y + x*x <= n; y++) {
            for(int z = y; x*x + y*y + z*z <= n; z++) {
                temp = x*x+y*y+z*z+x*y+y*z+z*x;
                if(x==y && y == z) add = 1;
                else if(x!=y && y!=z && z!=x) add = 6;
                else add = 3;
                if(temp <= n) v[temp]+=add;
                //cout << x << ' ' << y << ' ' << z << ' ' << temp << endl;
            }
        }
    }
    for(int i = 1; i <= n; i++) cout << v[i] << endl;
    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
 int main() {
   ll x,y,ck=0;
   cin>>x>>y;
   
   while (x<=y) {
      ck++;
      x*=2;
   }
   cout <<ck<< endl;
 
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,a[3][201],b[201]={0};
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>a[j][i];
		}
	}
	for(int i=0;i<3;i++){
		for(int j=0;j<n;j++){
			int c=0;
			for(int z=0;z<n;z++){
				if(a[i][j]==a[i][z])c++;
			}
			if(c==1)b[j]+=a[i][j];
		}
	}
	for(int i=0;i<n;i++){
		cout<<b[i]<<endl;
	}
}

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

using namespace std;

int64_t gcd(int64_t a, int64_t b) {
  auto x = minmax(a, b);
  auto lesser = x.first;
  auto greater = x.second;
  if (greater % lesser == 0)
    return lesser;
  return gcd(greater - lesser, lesser);
}

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

  int64_t N, M;
  cin >> N >> M;

  auto g = gcd(N, M);
  int count = 1;

  if (g % 2 == 0) {
    ++count;
    for (; g % 2 == 0; g /=2) {
    }
  }


  auto limit = sqrt(g + 1);

  int64_t num = 3;
  for (; g != 1; num += 2) {
    if (num > limit) {
      ++count;
      break;
    }
    // cout << " g " << g << endl;
    if (g % num == 0) {
      // cout << " num " << num << endl;
      ++count;
      g /= num;
      for (; g % num == 0; g /= num) {
      }
      limit = sqrt(g + 1);
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>
#include <iomanip>
#include <queue>

using namespace std;
using ull = unsigned long long;
using ll = long long;

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

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)

int main() {
	ll N;
	cin >> N;
	cout << (N - 2)* 180 << endl;
	return 0;
}


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

int main()
{
  string S;
  cin >> S;
  int64_t ans = 0, N = S.size();
  for (int bit = 0; bit < (1 << (N - 1)); bit++)
  {
    int64_t s = 0, tmp = S.at(0) - '0';
    for (int i = 0; i < N - 1; i++)
    {
      if (bit & (1 << i))
      {
        tmp = (tmp * 10) + (S.at(i + 1) - '0');
      }
      else
      {
        s += tmp;
        tmp = S.at(i + 1) - '0';
      }
    }
    ans += (s + tmp);
  }
  cout << ans << endl;
}

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

int main(){
  int n;  cin >> n;
  int a[n];

  map<int, int> m;
  for(int i=0; i<n; i++){
    cin >> a[i];
    m[a[i]-1]++;
    m[a[i]]++;
    m[a[i]+1]++;
  }

  int ans=0;
  for(auto itr=m.begin(); itr!=m.end(); itr++){
    ans = max(itr->second, ans);
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    int N,max,min,tmp;
    cin >> N;
    cin >> max;
    min = max;
    for(int i=0; i< N - 1; ++i){
        cin >> tmp;
        if(tmp >max) max = tmp;
        if(tmp < min) min = tmp;
    }
    
    cout << max - min << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
	if(a%2==1 && b%2==0)
	{
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	if(a%2==0 && b%2==1)
	{
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	if(a<b)
	swap(a,b);
	cout<<(a+b)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
h.append(float("inf"))

flag = [0]*(n+1)
for i in range(1,n+1):
  if h[i-1] >= h[i]:
    flag[i-1] = 1

for i in range(n):
  if flag[i] == 1:
    flag[i] = flag[i-1] + 1


print(max(flag))

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		int m[] = new int[q];
		for (int i = 0; i < q; i++) {
			m[i] = sc.nextInt();
		}
		for (int i = 0; i < q; i++) {
			if(dfs(n, a, m[i], 0, 0)) {
				System.out.println("yes");
			}else {
				System.out.println("no");
			}
		}
	}

	public static boolean dfs(int n, int a[], int m, int sum, int i) {
		if (i == n)
			return sum == m;
		if (dfs(n, a, m, sum + a[i], i + 1))
			return true;
		if (dfs(n, a, m, sum, i + 1))
			return true;
		return false;
	}
}



Measured memory_bytes: 27040
using System;

namespace abc111_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string array = Console.ReadLine();
            int[] answer = new int[array.Length];
            string word;
            char ch;
            for (int i = 0; i < array.Length; i++)
            {
                ch = array[i];

                if (ch == '1')
                {
                    answer[i] = 9;
                }
                else if (ch == '9')
                {
                    answer[i] = 1;
                }

            }
                Console.WriteLine(answer[0] * 100 + answer[1] * 10 + answer[2]);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a,cnt=0;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a == 1){
      cnt += ceil(i/(double)(k-1));
      cnt += ceil((n-i-1)/(double)(k-1));
      for(int j=1;j<k-1;j++){
        int tmp = 1;
        tmp += ceil((i-(k-j-1)>0?i-(k-j-1):0)/(double)(k-1));
        tmp += ceil(((n-i-1-j)>0?(n-i-1-j):0)/(double)(k-1));
        cnt = min(cnt, tmp);
      }
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N, K;
    std::cin >> N >> K;
    std::map<int64_t, int64_t> num;
    for (int64_t i = 0; i < N; i++)
    {
        int64_t a, b;
        std::cin >> a >> b;
        num[a] += b;
    }

    for (auto v : num)
    {
        if (v.second < K)
        {
            K -= v.second;
            continue;
        }
        else
        {
            std::cout << v.first << std::endl;
            return;
        }
        
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 7544