akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;
const int N = 15;
const int M = 1005;
const int INF = 0x3f3f3f3f;
char g[N][M];

int h, w, k;
vector<int> v[1 << N];
vector<pair<int, int>> p[1 << N];
//行的切法，上一刀，当前刀
int cnt[1 << N];
int sum[N][M];
bool cal(int st, int last, int now)
{
	bool flag = true;
	++last;
	for (int i = 0; i < p[st].size(); ++i)
	{
		int t = 0;
		int left = p[st][i].first, right = p[st][i].second;

		t = sum[right][now] - sum[right][last - 1] - sum[left - 1][now] + sum[left - 1][last - 1];
	
		if (t > ::k)
		{
			flag = false;
			break;
		}
	}
	
	return flag;
}

void pre()
{
	
	for (int i = 0; i < 1 << (h - 1); ++i)//存储每个状态切的位置
	{
		for (int j = 0; j < h; ++j)
		{
			if (i >> j & 1)
				v[i].push_back(j + 1);//存储每个切法切的位置
		}

		int pre = 1;
		for (int j = 0; j < v[i].size(); ++j)
		{
			//切的位置
			int k = v[i][j];
			p[i].push_back({ pre, k });
			pre = k + 1;
		}
		if (pre <= h)
			p[i].push_back({ pre, h });
	}	
}

void pre2()
{
	for (int i = 0; i < 1 << (h - 1); ++i)
	{
		for (int j = 0; j <= h; ++j)
		{
			if (i >> j & 1)
				++cnt[i];
		}
	}
}

void pre3()
{
	for(int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j)
		{
			if (g[i][j] == '0')
				sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + 0;
			else
				sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + 1;
		}
}

int main()
{
	scanf("%d%d%d", &h, &w, &k);

	for (int i = 1; i <= h; ++i)
		scanf("%s", g[i] + 1);
	pre();
	pre2();
	pre3();
	int ans = INF;
	//枚举行的切法
	
	for (int i = 0; i < 1 << (h - 1); ++i)
	{
		bool flag = true;
		
		int p = 0;//时间
		int last = 0;//上一刀竖直切的位置
		for (int j = 1; j <= w; ++j)
		{
			//切下一刀才失败
			if (!cal(i, last, j))
			{
				if (j - last >= 2)
				{
					last = j - 1;
					++p;
				}
				else
				{
					flag = false;
					break;
				}
			}
		}
		if (flag)
		{
			ans = min(ans, p + cnt[i]);
		}
	}
	
	printf("%d\n", ans);

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

int divisor_func(int num){
    int divisors = 1;
    for(int i=2; i*i <= num; i++){
        int p = 0;
        while(num%i==0){ num /= i; p++; }
        divisors *= (p+1);
    }
    if(num != 1) divisors *= 2;
    return divisors;
}

signed main(){
    int n; cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i+=2){
        if(divisor_func(i)==8){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int A,B;
  cin>>A>>B;
  
  if(A<=5){
    cout<<0<<endl;
  }
  else if(5<A&&A<=12){
    cout<<B/2<<endl;
  }
  else{
    cout<<B<<endl;
  }
}

    

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n = I()
    ans = 0
    for i in range(1, n+1):
        cnt = 0
        for j in range(1, i+1):
            if i % j == 0:
                cnt += 1
        if cnt == 8 and i % 2 == 1:
            ans += 1
    print(ans)

main()



Measured memory_bytes: 83540
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
#ifdef DEBUG
	printf("");
#endif

	int N, M;
	int tmp1, tmp2;
	char hatu[200000];
	char tyaku[200000];
	int i;

	memset(hatu, '0', sizeof(hatu));
	memset(tyaku, '0', sizeof(tyaku));

	scanf("%d %d", &N, &M);

	for (i = 0; i < M; i++) {
		scanf("%d %d", &tmp1 ,&tmp2);

#ifdef DEBUG
		printf("tmp1=%d, tmp2=%d\n", tmp1, tmp2);
#endif
		if (tmp1 == 1) {
			hatu[tmp2-1] = '1';
		}
		else if(tmp2==N){
			tyaku[tmp1-1] = '1';
		}
	}

	for (i = 0; i < M; i++) {
#ifdef DEBUG
		printf("hatu[%d]=%c, tyaku[%d]=%c\n", i, hatu[i], i, tyaku[i]);
#endif
		if (hatu[i] == '1' && tyaku[i] == '1') {
			printf("POSSIBLE\n");
			return 0;
		}
	}
	printf("IMPOSSIBLE\n");
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(a * b > c * d){
    cout << a * b << endl;
  }
  else{
    cout << c * d << endl;
  }
  
}
  

Measured memory_bytes: 256
from collections import defaultdict
def inpl(): return list(map(int,input().split()))

class increment:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

ui = defaultdict(increment())
plist = []
clists = []
Np = 0

N, M = inpl()
P = [0]*M
Y = [0]*M
for i in range(M):
    P[i], Y[i] = inpl()
    p = ui[P[i]]
    if p >= Np:
        plist.append(P[i])
        clists.append([[i,Y[i]]])
        Np += 1
    else:
        clists[p].append([i,Y[i]])

ids = ['']*M
for p in range(Np):
    clists[p].sort(key=lambda x: x[1])
    for c in range(len(clists[p])):
        cid = "{0:06d}".format(plist[p]) + "{0:06d}".format(c+1)
        ids[clists[p][c][0]] = cid

for i in range(M):
    print(ids[i])

Measured memory_bytes: 54152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),M = in(),X = in(),Y = in();
    vector<int> xs(N);
    vector<int> ys(M);
    REP(i,N)xs[i] = in();
    REP(i,M)ys[i] = in();
    sort(ALL(xs));
    sort(ALL(ys));
    cout << (max(X,xs[N-1]) < min(Y,ys[0]) ? "No War" : "War") << "\n";
}

Measured memory_bytes: 256
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 1e6+10;
bool vis[N];		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
  
    while(tt--)
    {
		int n,ct=0;
		cin>>n;
		int arr[n];
		map<int,int> mp;
		for(int i=0;i<n;++i)
		{
			cin>>arr[i];
			mp[arr[i]]++;
		}
		sort(arr,arr+n);
		int maxx = arr[n-1];
		//for(int i=0;i<n;++i)
		//cout<<arr[i]<<" ";
		for(int i=0;i<n;++i)
		{
			if(vis[arr[i]]==false)
			{
				if(mp[arr[i]]==1)
				ct++;
				for(int j=arr[i];j<=maxx;j+=arr[i])
				{
					vis[j] = true;
				}
			}
		}
		cout<<ct;
    }
    return 0;
}


Measured memory_bytes: 17872
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>


using namespace std;

typedef pair<int,char> P;

int main()
{
	int T;
	cin>>T;
	
	for(int t=0;t<T;t++){
		vector<P> vp(9);
		for(int i=0;i<9;i++){
			cin>>vp[i].first;
		}
		for(int i=0;i<9;i++){
			cin>>vp[i].second;
		}
		
		vector<int> order(9);
		for(int i=0;i<9;i++) order[i]=i;
		
		bool ok=false;
		do{
			int cnt=0;
			P card[3];
			for(int i=0;i<3;i++){
				for(int j=0;j<3;j++){
					card[j]=vp[order[3*i+j]];
				}
				
				if(card[0].second != card[1].second || card[1].second != card[2].second) continue;
				sort(card,card+3);
				if(card[0].first == card[1].first && card[1].first == card[2].first
				|| card[0].first == card[1].first-1 && card[1].first == card[2].first-1) cnt++;
				
			}
		
			if(cnt==3){ok=true; break;}

		}while(next_permutation(order.begin(),order.end()));

		if(ok) cout<<1<<endl;
		else cout<<0<<endl;

	}
	
	return 0;
}

Measured memory_bytes: 1196
var
	s,i:Longint;
begin
	read(s);
	i:=1;
	while s<>1 do begin
		if s mod 2=0 then s:=s div 2 else s:=s*3+1;
		inc(i);
	end;
	if i<3 then writeln(4)else writeln(i+1);
end.


Measured memory_bytes: 128
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
using namespace std;
using tsii = tuple<string, int, int>;
using vtsii = vector<tsii>;

int main(void){
    int n;
    cin >> n;
    vtsii res(n);
    for(int i=0; i<n; i++){
        string s;
        int t;
        cin >> s >> t;
        res[i] = tsii(s, -t, i+1);
    }
    sort(res.begin(), res.end());
    for(tsii &t : res) cout << get<2>(t) << '\n';
    return 0;
}

Measured memory_bytes: 3608
from fractions import Fraction

n, k = map(int, input().split())
r = Fraction(0, 1)

for i in range(n):
    m = i + 1
    l = 1
    while m < k:
        m *= 2
        l *= 2
    r += Fraction(1, l)

print(float(r * Fraction(1, n)))

Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  #define int long long
  #define endl "\n"
  const int N = 200005;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>



int32_t main()
{



    IOS

    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;


    int x = k/60;
    int y = k%60;


    h2-=x;
    m2 -= y;

    if(m2 < 0)
    {
    m2 += 60;
         h2--;
    }


    if(h2 > h1)
    {
        cout << (h2-h1-1)*60 + 60-m1 + m2;
    }
    else if(h2 == h1)
    {
        cout << max(0LL,m2-m1);
    }
    else
    {
        cout << 0;
    }
 




    return 0;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstdint>
#include <vector>
#include <queue>

int nya(std::vector<std::vector<int>>& a) {
  size_t h = a.size();
  int res = 0;
  for (size_t i = 0; i < h; ++i) {
    size_t l = 2;
    size_t r = 2;
    if (a[i][1] == a[i][2]) {
      l = 1;
      if (a[i][0] == a[i][1]) l = 0;
    }
    if (a[i][3] == a[i][2]) {
      r = 3;
      if (a[i][4] == a[i][3]) r = 4;
    }
    if (r-l+1 < 3) continue;

    res += a[i][2] * (r-l+1);
    for (size_t j = l; j <= r; ++j) a[i][j] = 0;
  }

  for (size_t j = 0; j < 5; ++j) {
    std::queue<int> q;
    for (size_t i = h; i--;) {
      if (a[i][j]) q.push(a[i][j]);
      a[i][j] = 0;
    }
    size_t i = h-1;
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      a[i--][j] = t;
    }
  }
  return res;
}

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<std::vector<int>> a(n, std::vector<int>(5));
  for (auto& ai: a)
    for (auto& aij: ai)
      scanf("%d", &aij);

  int res = 0;
  while (true) {
    int kieta = nya(a);
    if (!kieta) break;
    res += kieta;
  }
  printf("%d\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2668
#include <stdio.h>

int main(){
	int a,b,c,h;
	scanf("%d %d %d",&a,&b,&c);
	if(a > b){   //一番目と二番目を比較
		h = a;
		a = b;
		b = h;
	}
	if(b > c){   //二番目と三番目を比較
		h = b;
		b = c;
		c = h;
	}
	if(a > b){   //二番目と三番目の大きかった方と一番目の数字を比較
		h = a;
		a = b;
		b = h;
	}
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}


Measured memory_bytes: 2104
using namespace std;
typedef long long ll;
#include <bits/stdc++.h>
#define endl "\n";
int main(void){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    if(n%2 == 0) cout << n/2;
    else cout << (n/2) + 1;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int solve( int ,int ) ;
int n, a[20], ans = 0 ;
int main () {
	
	int m[200], i, j, q;
	int count = 0 ;

	
	scanf ("%d",&n) ;
	for ( i = 0 ; i < n ; i ++ ) {
		scanf("%d", &a[i] ) ;
	}
	scanf ("%d",&q) ;
	for ( j = 0 ; j < q ; j ++ ) {
		scanf("%d", &m[j] ) ;
	}
	
	
	for ( j = 0 ; j < q ; j++) {
		ans = 0 ;
		solve ( 0 , m[j] );
		if ( ans == 1 ) {
			printf("yes\n");
		}
		else { 
			printf("no\n");
		}
	}
	
return 0 ;
}


int solve( int j ,int m ) {
	if (m == 0 ) {
		ans =  1;
		return 1 ; 
	}
	
	else if ( j < n ) {
		solve( j + 1 , m) ;
		solve( j + 1 , m - a[j]) ;
	}
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < sz(s); i++) {
		int X = ((int) s[i] + n - 'A') % 26 + (int)'A';
		s[i] = X;
	}		
	cout << s << "\n";
}



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

string N;

int main()
{
    cin >> N;
    reverse(N.begin(), N.end());
    int ret = 0;
    for (auto i : N) ret += i - '0';
    for (unsigned i=1; i<N.size(); i++)
    {
        int tmp = 9*i - 1;
        for (unsigned j=i; j<N.size(); j++) tmp += N[j] - '0';
        ret = max(ret, tmp);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#define rint register int
#define LL long long
#define P 998244353
#define MAXN 3005
using namespace std;

int n, x, ans, c[MAXN][MAXN];

inline int add(int x, int y) {return x+y<P?x+y:x+y-P;}
inline int sub(int x, int y) {return x<y?x-y+P:x-y;}

int solve(int tot)
{
	int ans=0;
	if(x&1 || 2*tot<x) ans=1;
	for(rint i=tot; i<tot*2; ++i)
	{
		if(i>=x && (i-x)%2==0) continue;
		if(i<x) {ans=add(ans, c[tot][i-tot]); continue;}
		int temp=(i-x+1)/2;
		int resnum=i-temp*4, respos=tot-temp*2;
		if(temp*2<tot && resnum>=respos && resnum<=respos*2) ans=add(ans, c[respos][resnum-respos]);
	}
	return ans;
}

int main()
{
	scanf("%d%d", &n, &x);
	c[0][0]=1;
	for(rint i=1; i<=n; ++i)
	{
		c[i][0]=1;
		for(rint j=1; j<=i; ++j) c[i][j]=add(c[i-1][j], c[i-1][j-1]);
	}
	for(rint i=0; i<=n; ++i) ans=(ans+1LL*c[n][i]*solve(n-i))%P;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 34176
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e3 + 5, M = 1e5 + 5;

int n, k;
int main(){
    scanf("%d%d", &n, &k);
    int x = n - 2;
    int kam = (x * (x + 1)) / 2;
    if(k > kam){
        puts("-1");
        return 0;
    }
    vector<pair<int, int> > out;
    for(int i = 2 ; i <= n ; ++i)
        out.emplace_back(1, i);
    int u = 2, v = 3;
    while(kam > k){
        --kam;
        out.emplace_back(u, v);
        ++v;
        if(v > n)v = ++u + 1;
    }
    printf("%d\n", out.size());
    for(auto p : out)printf("%d %d\n", p.first, p.second);
}

Measured memory_bytes: 384
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){}
        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for(int i=0;i<size;i++){
                makeSet(i);
            }
        }

        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }

        void link(int x, int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x] == rank[y]){
                    rank[y] ++;
                }
            }
        }

        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

void Main(){
    ll M, N, K, a, b;
    sll(N);
    sll(M);
    sll(K);

    DisjointSet DS(N);
    map<ll, set<ll>> friends;
    map<ll, set<ll>> blocks;

    rep(i, M){
        sll(a);
        sll(b);
        -- a;
        -- b;
        DS.unite(a, b);
        friends[a].insert(b);
        friends[b].insert(a);
    }

    rep(j, K){
        sll(a);
        sll(b);
        -- a;
        -- b;
        blocks[a].insert(b);
        blocks[b].insert(a);
    }

    map<ll,ll> group;
    map<ll, set<ll>> childlen;
    rep(i, N){
        ll parent = DS.findSet(i);
        ++group[parent];
        childlen[parent].insert(i);
    }
    // printf("ok\n");
    ll ans = 0;
    rep(i, N){
        ll parent = DS.findSet(i);
        // cout <<"i=" << i << ", parent=" << parent <<endl;
        ll union_size = group[parent];
        ll this_ans = 0;
        for(auto _friend:friends[i]){
            this_ans += (ll)(childlen[parent].find(_friend) != childlen[parent].end());
        }

        for(auto _block:blocks[i]){
            this_ans += (ll)(childlen[parent].find(_block) != childlen[parent].end());
        }

        if(i!=N-1){
            printf("%lld ", union_size-this_ans-1);

        }else{
            printf("%lld",  union_size-this_ans-1);
        }
    }
    printf("\n");


}

int main(){
    Main();
}

Measured memory_bytes: 56616
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if (a-c <= d && d*-1 <= a-c) {
		cout << "Yes" << "\n";
		return 0;
	}
	if (a-b < d && d*-1 <= a-b && b-c < d && d*-1 <= b-c){
		cout <<"Yes" << "\n";
		return 0;
	}
	cout << "No" << "\n";
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let p: usize = sc.cin();
    let s: Vec<_> = sc.chars().iter().map(|&c| ((c as u8) - ('0' as u8)) as usize).collect();

    if p == 2 || p == 5 {
        let mut ans = 0;
        let mut i = 0i64;
        for &x in s.iter() { i += 1; if x % p == 0 { ans += i; } }
        put!(ans);
        return
    }

    let mut memo = vec![0i64; p];
    memo[0] = 1;
    {
        let mut base = 1;
        let mut ac = 0;
        for &x in s.iter().rev() {
            ac += base * x;
            ac %= p;
            memo[ac] += 1;
            base = (base * 10) % p;
        }
    }
    let mut ans = 0i64;
    for x in 0..p {
        if memo[x] > 1 {
            // trace!(x, memo[x]);
            ans += memo[x] * (memo[x] - 1) / 2;
        }
    }
    put!(ans);

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 6396
#include<stdio.h>
int main(void){
int  D;
scanf("%d", &D);
if(D==25) printf("Christmas\n");  
if(D==24) printf("Christmas Eve\n");  
if(D==23) printf("Christmas Eve Eve\n");  
if(D==22) printf("Christmas Eve Eve Eve\n");  
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<complex>
#include<fstream>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

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

	cout << (n + n % 2) / 2 << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <set>
#include <stdlib.h>
#include <cmath>
using namespace std;

int d, c[29], s[409][29], p[409], cp[29], rs;
set<int> st[29];

int cc()
{
	for (int i = 0; i < 26; i++)
		cp[i] = 0;
	int ans = 0;
	for (int i = 1; i <= d; i++) {
		for (int j = 0; j < 26; j++) {
			if (p[i] == j) {
				cp[j] = i;
				ans += s[i][j];
			}
			else
				ans -= (i - cp[j]) * c[j];
		}
	}
	return ans;
}

void rm(int n, int k)
{
	auto pi = st[k].find(n);
	auto l = pi; l--;
	auto r = pi; r++;
	int pl = (n - (*l) - 1), pr = ((*r) - n - 1), plr = ((*r) - (*l) - 1);
	st[k].erase(n);
	rs -= s[n][k];
	rs += pl * (pl + 1) / 2 * c[k]; rs += pr * (pr + 1) / 2 * c[k];
	rs -= plr * (plr + 1) / 2 * c[k];
}

void ins(int n, int k)
{
	auto r = st[k].lower_bound(n);
	auto l = r; l--;
	int pl = (n - (*l) - 1), pr = ((*r) - n - 1), plr = ((*r) - (*l) - 1);
	st[k].insert(n);
	rs += s[n][k];
	rs -= pl * (pl + 1) / 2 * c[k]; rs -= pr * (pr + 1) / 2 * c[k];
	rs += plr * (plr + 1) / 2 * c[k];
}

void up(int n, int k)
{
	rm(n, p[n]);
	p[n] = k;
	ins(n, p[n]);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> d;
	for (int i = 0; i < 26; i++) {
		cin >> c[i];
		st[i].insert(0); st[i].insert(d + 1);
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 0; j < 26; j++)
			cin >> s[i][j];
		p[i] = rand() % 26;
		st[p[i]].insert(i);
	}
	rs = cc();
	double k = 300, sc = 270, kt = 0.99915;
	for (int i = 0; i < 4000000; i++) {
		double e1 = rs;
		int n = (rand() % d) + 1, kp = (rand() % 25) + 1;
		int hk = p[n], tk = (hk + kp) % 26;
		up(n, tk);
		int e2 = rs;
		double pb = exp((e2 - e1) / (k * sc));
		if (pb < rand() / (double)RAND_MAX)
			up(n, hk);
		k *= kt;
	}
	for (int i = 1; i <= d; i++)
		cout << p[i] + 1 << '\n';
	return 0;
}

Measured memory_bytes: 4336
import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val (n, d) = jin.readLine().split(" ").map { it.toLong() }
    var answer = 0
    for (j in 1..n) {
        val (x, y) = jin.readLine().split(" ").map { it.toLong() }
        if ((x * x) + (y * y) <= d * d) {
            answer++
        }
    }
    println(answer)
}

Measured memory_bytes: 55896
#define _USE_MATH_DEFINES
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <cmath>

inline double to_degree(double rad) noexcept {
  return rad * 180.0 / M_PI;
}

int main() {
  double a, b, x;
  std::cin >> a >> b >> x;

  const auto y = x / a;
  const auto ab = a * b;

  double result = 0.0;
  if (y < ab / 2.0) {
    // 底が見える場合
    const auto b2 = b * b;
    const auto rad = atan2(b * b, 2.0 * y);
    result = to_degree(rad);
  } else {
    // 底が見えない場合
    const auto rad = atan2(2.0 * (ab - y), a * a);
    result = to_degree(rad);
  }

  //result = std::min(result, 90.0);
  //result = std::max(result, 0.0);
  std::cout << std::setprecision(20) << result;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  a--,b--,c--,d--;
  string s;
  cin >> s;
  if(c > d){
    bool ok = false;
    REP(i,b,d + 1){
      int cnt = 0;
      rep(j,3)if(s[i + (j - 1)] == '.')cnt++;
      if(cnt == 3)ok = true; 
    }
    if(!ok){
      cout << "No" << endl;
      return 0;
    }
  }
  bool ok = true;
  REP(i,b,d){
   int cnt = 0;
   rep(j,2)if(s[i + j] == '#')cnt++;
   if(cnt == 2)ok = false;
  }
  REP(i,a,c){
    int cnt = 0;
    rep(j,2)if(s[i + j] == '#')cnt++;
    if(cnt == 2)ok = false;
  }
  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3708
import 'dart:io';

void main(List<String> args) {
  List<String> input = stdin.readLineSync().split(" ");
  int s = int.parse(input[0]);
  int w = int.parse(input[1]);
  if (s > w) {
  	print('safe');
  } else {
  	print('unsafe');
  }
}

Measured memory_bytes: 13156
# Consider sardines as vectors in 2D plane,
# and grouping them by their tangent(B[i] / A[i]).
Mod = 1000000007
N = gets.to_i
zs = 0 # count of zero vectors
X = []
Y = []
(0...N).each{ 
  a,b = gets.split.map &:to_i
  if a == 0 && b == 0
    zs += 1; next
  end

  # limitate arg into [0,pi)
  if b < 0
    a = -a; b = -b;
  end
  if b == 0 && a < 0
    a = -a
  end
  if a > 0
    # arg in [0,pi/2)
    g = b > 0 ? a.gcd(b) : 1
    a /= g; b /= g
    X << b.to_r / a
  else
    # arg in [pi/2,pi)
    # -> rotate -pi/2
    a,b = b,-a
    g = b > 0 ? a.gcd(b) : 1
    a /= g; b /= g
    Y << b.to_r / a
  end
}

xh = {} # count of finite-positive tangents
yh = {} # count of infinite or negative tangents
args = {} # all tangents
X.each{ |arg| args[arg] = 1; xh[arg] = (xh[arg] || 0) + 1 }
Y.each{ |arg| args[arg] = 1; yh[arg] = (yh[arg] || 0) + 1 }

bins = [1] # bins[i] = 2^i
(N+1).times{ bins << ((bins[-1] * 2) % Mod) }

ans = args.keys.reduce(1){ |s,arg|
  x = xh[arg] || 0
  y = yh[arg] || 0
  s = s * (bins[x] + bins[y] - 1)
  s % Mod
} + zs - 1
p ans % Mod


Measured memory_bytes: 46916
n = int(input())
li = list(map(int, input().split()))

check = 0
ans = 0
for i in range(n):
    if i == 0:
        check = li[0]
        continue
    
    if check >= li[i]:
        ans += check - li[i]
    else:
        check = li[i]
        
print(ans)

Measured memory_bytes: 32240
#include<stdio.h>
void insertionSort(int A[],int N);
int main(void){
  int N,i;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d",A[i]);
  printf("\n");
  insertionSort(A,N);
  return 0;
}

void insertionSort(int A[],int N){
  int i,v,j,k;
  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;
      for(k = 0;k<N-1;k++){
        printf("%d ",A[k]);
      }
      printf("%d",A[k]);

       printf("\n");
     
  }
}



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

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  // n m + m * (m + 1) / 2 = b
  // 2n m + m m + m = 2b
  // ->
  // n + 1 ~ n + m
  while(1) {
    int b;
    cin >> b;
    if(b == 0) break;
    int an = -1, am;
    for(int m = 1; m * m + m <= 2 * b; m++) {
      int nm2 = 2 * b - (m * m + m);
      int n;
      if(nm2 % (2 * m) == 0) n = nm2 / 2 / m;
      else continue;
      an = n;
      am = m;
    }

    assert(an != -1);
    cout << an + 1 << " " << am << "\n";
  }
}



Measured memory_bytes: 3120
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll n, k; cin >> n >> k;
	vector<ll> a(n), f(n);
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> f[i];
	sort(all(a));
	sort(all(f), greater<ll>());
	ll ok = 1e12 + 1, ng = -1;
	while (abs(ok - ng) > 1)
	{
		ll mid = abs(ok + ng) / 2;
		ll cnt = 0;
		rep(i, n)cnt += max(0LL, a[i] - mid / f[i]);
		if (cnt <= k)ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}


Measured memory_bytes: 3328
a,b,x,y=list(map(int, input().split()))
ans=0

while ans==0:
	x=x-b
	if x<1:
		ans=1
	if ans==0:
		a=a-y
	if a<1:
		ans=1

if a<1:
	print('No')
else:
	print('Yes')

Measured memory_bytes: 9184
#line 2 "/home/toof/working/library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 3 "/home/toof/working/library/union_find.hpp"

struct UnionFind {
  struct Node {
    ll parent;
    ll size;
  };
  vector<Node> tree;

  UnionFind(ll size) : tree(size) {
    rep(i, size) {
      tree[i].parent = i;
      tree[i].size = 1;
    }
  }

  ll find(ll x) {
    while (tree[x].parent != x) {
      ll p = tree[x].parent;
      tree[x].parent = tree[p].parent;
      x = p;
    }
    return x;
  }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (tree[x].size < tree[y].size) swap(x, y);
    tree[y].parent = x;
    tree[x].size += tree[y].size;
  }

  bool same(ll x, ll y) {
    return find(x) == find(y);
  }
};
#line 3 "c.cpp"

int main() {
  ll n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    uf.unite(a-1, b-1);
  }

  set<ll> s;
  rep(i, n) {
    s.insert(uf.find(i));
  }
  cout << s.size()-1 << el;
}


Measured memory_bytes: 8348
s = input()
n = len(s)
base = int(s)
for i in range(n-2):
    ans = int(s[i])*100 + int(s[i+1])*10 + int(s[i+2])
    if abs(753-base) > abs(753 - ans):
        base = ans
print(abs(753-base))

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int ar[100];

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

  ar[0] = a%b;

  for(int i=2;i<100;i++){
    ar[i-1] = (a*i) % b;
  }

  //for(int i=0;i<100;i++) printf("-%d-",ar[i]);
  int f = 0;
  for(int j=0;j<100;j++){
    if(c == ar[j]){
        f = 1;
        break;
    }
  }
  if(f) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
        cout << it << " ";        \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define deb3a(v)                               \
    cout << #v << "-->" << endl;               \
    for (auto it : v)                          \
    {                                          \
        cout << it.fi << " " << it.se << endl; \
    }
#define mod 1000000007
#define so(v) sort(v.begin(), v.end())
#define fi first
#define se second
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int mI(int a, int m)
{
    return power(a, m - 2, m);
}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};

void solve()
{
    int n, x, t;
    cin >> n >> x >> t;
    int val = ceil(n * 1.0 / x);
    val *= t;
    cout << val;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    srand(time(0));

    // FILE *fin = freopen("ip.txt","r",stdin);
    // FILE *fout = freopen("op.txt","w",stdout);
    int t = 1, nn = 1;
    //cin >> t;
    while (t--)
    {
        // cout << "Case #" << nn << ":"
        //      << " ";
        // nn++;
        solve();
    }
}

Measured memory_bytes: 3744
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()



int main(void) {
	string str, str2; cin >> str >> str2;
	bool x = 0;
	rep(i, str2.length()) {
		if (str == str2) { x = 1; break; }
		str2.insert(str2.begin(), *(str2.end() - 1));
		str2.pop_back();
	}
	cout << (x ? "Yes" : "No") << endl;
	return 0;
}

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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main(){
	int n,ans=0;
	cin>>n;
	int s[n];
	for(int i=0;i<n;i++){
		cin>>s[i];
		ans+=s[i];
	}
	sort(s,s+n);
	if(ans%10==0){
		for(int i=0;i<n;i++){
			if(s[i]%10!=0){
				ans-=s[i];
				cout << ans<<endl;
				return 0;
			}
		}
		cout << 0<<endl;
	}
	else{
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll INF=1e18;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>> a(n,vector<ll>(3));
    rep(i,n){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    
    ll ans=-INF;
    for(ll i=0;i<(1<<3);i++){
        vector<ll> sum(n);
        ll tot=0;
        rep(j,3){
            if((i>>j)%2==1){
                rep(k,n){
                    a[k][j]*=-1;
                }
            }
        }
        rep(j,n){
            rep(k,3){
                sum[j]+=a[j][k];
            }
        }
        sort(sum.rbegin(),sum.rend());
        rep(j,m){
            tot+=sum[j];
        }
        ans=max(ans,tot);
        rep(j,3){
            if((i>>j)%2==1){
                rep(k,n){
                    a[k][j]*=-1;
                }
            }
        }
    }
    cout << ans << endl;
} 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明

// vector の使い方
// 宣言：
// vector<int> v;
// vector<int> v(N);
// 初期化:
// vector<int> v(10, 5); 要素数10，全ての要素の値5．
// vector<int> v = {1, 2, 3};
// 代入：
// v[0] = 3;
// sort:
// sort(v.begin(), v.end());
//

// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) {
		a_powered *= a;
	}
	return a_powered;
}

int main(int argc, char *argv[]){
    int A, B;
    cin >> A >> B;
    if (B%A == 0){
        cout << A+B << endl;
    } else {
        cout << B-A << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while(true){

            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();

            if(op.equals("?"))break;

            int ans = 0;

            if (op.equals("+"))
                ans = a + b;
            else if (op.equals("-"))
                ans = a - b;
            else if (op.equals("*"))
                ans = a * b;
            else
                ans = a / b;

            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 26256
import java.util.*;

class Queue {
    static int top = 0;
    static int time = 0;
    static int n, q;
    static String[] label;
    static int[] value;
    public static void main() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt()-1;
        q = sc.nextInt();
        label = new String[1000000];
        value = new int[1000000];
        for (int i = 0; i <= n; i++) {
            label[i] = sc.next();
            value[i] = sc.nextInt();
        }
        sc.close();
        process();   
    }

    static void process() {
        while (top <= n) {
            int topItem = pop();
            if (topItem <= q) {
                time += topItem;
                System.out.println(label[top-1] + " " + time);
            } else {
                time += q;
                push(topItem - q);
            }
        }
    }
    
    static int pop() {
        return value[top++];
    }

    static void push(int x) {
        label[++n] = label[top-1];
        value[n] = x;
    }
}

public class Main {
    public static void main(String[] args) {
        Queue que = new Queue();
        que.main();
    }
}


Measured memory_bytes: 87852
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i * 2 < n; ++i)
        ++ans;
    cout << ans << endl;

}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
const int N = 100000;
const int INF = 0x3f3f3f3f;
int n, m, x, a[N];
signed main(void) {
  memset(a, 0x3f, sizeof(a));
  for(cin >> n, m = n; m; m--)
    cin >> x, *lower_bound(a, a + n, x) = x;
  cout << lower_bound(a, a + n, INF) - a << endl;
}

Measured memory_bytes: 1560
N = int(input())
Ws = [int(i) for i in input().split()]

ans = 1145141919

S1 = Ws[0]
S2 = 0
for i in range(1, N):
    S2 += Ws[i]

for i in range(1, N - 1):
    S1 += Ws[i]
    S2 -= Ws[i]
    ans = min(abs(S1 - S2), ans)

print(ans)

Measured memory_bytes: 38384
#include <cstdio>
#include <string>
#include <algorithm>
#include <list>

int main() {
  std::list<std::string> lines;
  while (true) {
    char buf[32];
    fgets(buf, sizeof buf, stdin);
    std::string line=buf;
    if (line == "END_OF_TEXT\n")
      break;

    lines.emplace_back(line);
  }

  auto it=lines.begin();
  size_t cc=0;
  std::string kbuf="";
  while (true) {
    char op;
    scanf(" %c", &op);

    switch (op) {
    case '-': {
      for (const auto &line: lines)
        printf("%s", line.c_str());
      return 0;
    }

    case 'a':
      cc = 0;
      break;

    case 'e':
      cc = it->size()-1;
      break;

    case 'p':
      cc = 0;
      if (it != lines.begin())
        --it;
      break;

    case 'n':
      cc = 0;
      if (std::next(it) != lines.end())
        ++it;
      break;

    case 'f':
      if ((*it)[cc] != '\n') {
        ++cc;
      } else if (std::next(it) != lines.end()) {
        ++it;
        cc = 0;
      }
      break;

    case 'b':
      if (cc > 0) {
        --cc;
      } else if (it != lines.begin()) {
        --it;
        cc = it->size()-1;
      }
      break;

    case 'd':
      if ((*it)[cc] != '\n') {
        *it = it->substr(0, cc) + it->substr(cc+1);
      } else if (std::next(it) != lines.end()) {
        it->pop_back();
        auto tmp=std::next(it);
        *it += *tmp;
        lines.erase(tmp);
      }
      break;

    case 'k':
      if ((*it)[cc] != '\n') {
        kbuf = it->substr(cc);
        kbuf.pop_back();
        *it = it->substr(0, cc) + "\n";
      } else if (std::next(it) != lines.end()) {
        kbuf = "\n";
        it->pop_back();
        auto tmp=std::next(it);
        *it += *tmp;
        lines.erase(tmp);
      }
      break;

    case 'y':
      if (kbuf.empty()) {
        // no-op;
      } else if (kbuf == "\n") {
        std::string s=it->substr(cc);
        *it = it->substr(0, cc) + "\n";
        auto tmp=std::next(it);
        lines.emplace(tmp, s);
        ++it;
        cc = 0;
      } else {
        *it = it->substr(0, cc) + kbuf + it->substr(cc);
        cc += kbuf.length();
      }
      break;
    }

    // fprintf(stderr,
    //         "[%c] / L%td C%zu\n", op, std::distance(lines.begin(), it), cc);
    // for (const auto &line: lines)
    //   fprintf(stderr, "%s", line.c_str());
  }
}



Measured memory_bytes: 2780
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){
    int n,y;
    cin >> n >> y;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=n; j++){
            if(i+j>n)break;
            if(10000*i + 5000*j + 1000*(n-i-j) == y){
                cout << i << " " << j << " " << (n-i-j) << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, D;
    cin >> N >> D;
    vec d(N);
    readvec(d);
    int Q;
    cin >> Q;
    vec q(Q);
    readvec(q);

    vec pos(N);
    pos[N - 1] = 1;
    IFOR(i, 1, N){
        if(d[i] <= 2 * pos[i] - 1){
            pos[i - 1] = pos[i] + d[i];
        }else{
            pos[i - 1] = pos[i];
        }
    }


    vector<bool> ans(N, false);
    REP(i, N){
        //cout << D << " " << pos[i] << endl;
        if(D >= pos[i]) ans[i] = true;
        if(d[i] < 2 * D) D = llabs(D - d[i]);
    }

    REP(i, Q){
        if(ans[q[i] - 1]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 13696
import java.util.*;

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

        int ans = c-(a-b);
        System.out.println(ans < 0 ?0:ans);
        
    }
}

Measured memory_bytes: 21844
n,m=map(int,input().split())
AC=[0]*n
WA=[0]*n
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if s=="WA":
    if AC[p]==0:
      WA[p]+=1
  else:
    AC[p]=1

ac=sum(AC)
wa=0
for i in range(n):
  if AC[i]==1:
    wa+=WA[i]
print(ac,wa)

Measured memory_bytes: 4596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        List<Integer>[] incoming = new List[n];
        int[] outcoming = new int[n];
        for (int i = 0; i < n; i++) incoming[i] = new LinkedList<>();

        for (int i = 0; i < m; i++) {
            int u = scanner.nextInt()-1;
            int v = scanner.nextInt()-1;
            outcoming[u]++;
            incoming[v].add(u);
        }

        int[] dp = new int[n];
        Queue<Integer> queue = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            if(outcoming[i]==0) queue.add(i);
        }

        while (!queue.isEmpty()){
            Integer poll = queue.poll();
            int curVal = dp[poll];
            for (Integer neighbor : incoming[poll]) {
                outcoming[neighbor]--;
                dp[neighbor] = Math.max(dp[neighbor], curVal+1);
                if(outcoming[neighbor]==0) queue.add(neighbor);
                
            }
        }
        int ans = 0;
        for (int a : dp) ans = Math.max(ans, a);
        System.out.println(ans);
    }
}


Measured memory_bytes: 67060