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

// using ll = long long;
#define int long long
#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> red(a);
  vector<int> green(b);
  vector<int> nocolor(c+x+y);
  REP(i,a) cin >> red[i];
  REP(i,b) cin >> green[i];
  REP(i,c) cin >> nocolor[i];
  SORTR(red);
  SORTR(green);
  nocolor.insert(nocolor.begin()+c, red.begin(), red.begin()+x);
  nocolor.insert(nocolor.begin()+c+x, green.begin(), green.begin()+y);
  SORTR(nocolor);
  int ans = 0;
  for(int i = 0; i < x+y; ++i) {
    ans += nocolor[i];
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 8064
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
using namespace std;
const int INF = 1 << 30;
int main(){
	int m,n;
	while (cin >>m >>n, n) {
		vector<int> a(n);
		for (int &x : a)cin >> x;
		int min = 0, max = 1500000;
		while (min != max) {
			int mid = (min + max) / 2;
			int dan = 0;
			int w = 0;
			for (int x : a) {
				w += x;
				if (w > mid) {
					if (x > mid) {
						dan = m;
						break;
					}
					dan++;
					w = x;
				}
			}
			if (dan < m)max = mid;
			else min = mid + 1;
		}
		cout << min << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e6+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	
	string s;
	cin >> s;
	vector<int> check(26,0);
	for(int i=0;i<s.size();i++){
		check[s[i]-'a']++;
	}
	
	bool all=true;
	int first=0;
	for(int i=0;i<26;i++){
		if(check[i]==0){
			first=i;
			all=false;
			break;
		}
	}
	
	if(!all){
		s+='a'+first;
		cout << s << endl;
		return 0;
	}
	
	string t=s;
	vector<string> v;
	if(all){
		if(t=="zyxwvutsrqponmlkjihgfedcba"){
			cout << -1 << endl;
			return 0;
		}else{
			do{
				v.push_back(t);
				if(v.size()==2)break;
			}while(next_permutation(t.begin(),t.end()));
		}
	}
	//cout << v[1] << endl;	
	string ans=v[1];
	for(int i=0;i<s.size();i++){
		if(s[i]==ans[i]){
			continue;
		}else{
			ans.erase(i+1,ans.size()-i-1);
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
unittest
{
	assert( [ "2", "1000000000 1000000000" ].parse.expand.solve == 1000000000000000000 );
	assert( [ "3", "101 9901 999999000001" ].parse.expand.solve == -1 );
	assert( [ "31", "4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0" ].parse.expand.solve == 0 );
	
	assert( [ "2", "1000000000000000000 1000000000000000000" ].parse.expand.solve == -1 );		// 追加ケース
}



import std.algorithm;
import std.bigint;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	const L = BigInt( 10L ^^ 18 );
	
	as.sort();
	if( as.front == 0 ) return 0;
	
	auto ans = BigInt( 1 );
	foreach( a; as )
	{
		ans *= a;
		if( L < ans ) return -1;
	}
	return ans.toLong;
}


Measured memory_bytes: 9496
n,m=map(int,input().split())
inf=float("inf")

data=[[inf]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
    data[i][i]=0
lst=[]
for u in range(m):
    a,b,c=map(int,input().split())
    data[a][b]=c
    data[b][a]=c
    lst.append([a,b,c])

for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            data[i][j]=min(data[i][j],data[i][k]+data[k][j])

ans=0
for u in lst:
    a,b,c=u
    if data[a][b]!=c:
        ans+=1

print(ans)

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

int main()
{
	int A, B; cin >> A >> B;
	vector<int> v;

	for (int i = A; i > 0; --i)
	{
		if (B%i == 0 && A%i == 0)
			v.push_back(i);
	}

	int K; cin >> K;

	cout << v[K-1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
typedef vector<int> vi;
set<string> cands;
int h,w,n;
char initfield[55][55];
char field[55][55];
int cnt=0;
bool del[55][55];
bool search()
{
  int sum=0;
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(field[i][j]!='.')sum++;
  while(sum){
    for(int j=0;j<w;j++)
    {
      for(int i=h-2;i>=0;i--)
      {
        if(field[i][j]!='.')
        {
          char ch=field[i][j];
          field[i][j]='.';
          for(int k=i;k<h;k++)
          {
            if(k+1==h||field[k+1][j]!='.')
            {
              field[k][j]=ch;
              break;
            }
          }
        }
      }
    }
    memset(del,false,sizeof(del));
    int dec=0;
    for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
      {
        if(field[i][j]=='.') continue;
        //tate
        int cnt=0;
        for(int k=i;k<h;k++)
        {
          if(field[i][j]==field[k][j])cnt++;
          else break;
        }
        if(cnt>=n)
        {
          for(int k=i;k<h;k++)
          {
            if(field[i][j]==field[k][j])del[k][j]=true;
            else break;
          }
        }
        //yoko
        cnt=0;
        for(int k=j;k<w;k++)
        {
          if(field[i][j]==field[i][k])cnt++;
          else break;
        }
        if(cnt>=n)
        {
          for(int k=j;k<w;k++)
          {
            if(field[i][j]==field[i][k])del[i][k]=true;
            else break;
          }
        }
      }
    }
    for(int i=0;i<h;i++)for(int j=0;j<w;j++) if(del[i][j])field[i][j]='.',dec++;
    if(dec==0) return false;
    sum-=dec;
  }
  return true;
}

int main()
{
    cin >> h >> w >> n;
    bool clear=false;
    for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
      {
        cin >> initfield[i][j];
      }
    }
    for(int i=0;i<h;i++)
    {
      for(int j=0;j<w-1;j++)
      {
        for(int k=0;k<h;k++) for(int l=0;l<w;l++) field[k][l]=initfield[k][l];
        cnt++;
        swap(field[i][j],field[i][j+1]);
        clear|=search();
        if(clear) break;
      }
      if(clear) break;
    }
    if(clear) cout << "YES" <<endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,1,0,-1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

const int dx2[] = {1,1,1,0,0,0,-1,-1,-1};
const int dy2[] = {1,0,-1,1,0,-1,1,0,-1};

int main(){
    while(true){
        const int FL = 500;
        int N;
        cin >> N;
        if(N==0) break;
        if(N==1){
            cout << 1 << " " << 1 << endl;
            continue;
        }
        vector<pair<int,int> > PS;
        PS.push_back(mp(250,250));
        for(int i=1;i<N;i++){
            int n,d;
            cin >> n >> d;
            pair<int,int> p = PS[n];
            p.first += dy[d];p.second += dx[d];
            PS.push_back(p);
        }
        int low = 250,high = 250;
        int le = 250, ri = 250;
        for(int i=0;i<PS.size();i++){
            int y = PS[i].first,x = PS[i].second;
            high = max(high,y);
            low = min(low,y);
            ri = max(ri,x);
            le = min(le,x);
        }
        cout << (ri-le+1) << " "  <<(high-low+1) << endl;

    }
    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <exception>
 
using namespace std;
 
int main () {
    string s;
    cin >> s;
 
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == ',') {
            s[i] = ' ';
        }
    }
 
    cout << s << endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int W = 5;
int H;
int field[15][6];

int f() {
    int now = 0;
    for(int h = 1; h <= H; h++) {
        //cerr << "h: " << h << endl;
        for(int delta = 5; delta >= 3; delta--) {
            //cerr << "delta : " << delta << endl;
            for(int w = 1; delta + w <= W + 1; w++) {
                //cerr << "w: " << w << endl;
                bool ok = true;
                for(int noww = w + 1; noww <= w + delta - 1; noww++) {
                    if(field[h][noww] != field[h][w]) ok = false;
                }
                if(ok) {
                    now += delta * field[h][w];
                    for(int noww = w; noww <= w + delta - 1; noww++) {
                        field[h][noww] = 0;
                    }
                }
            }
        }
    }
    return now;
}

void drop() {
    /*
    cerr << "before" << endl;
    for(int h = H; h >= 1; h--) {
        for(int w = 1; w <= W; w++) cerr << field[h][w] << " ";
        cerr << endl;
    }
    */
    for(int _ = 1; _ <= 15 * 15; _++) {
    for(int h = H; h >= 2; h--) {
        for(int w = 1; w <= W; w++) {
            if(field[h-1][w] == 0) {
                field[h-1][w] = field[h][w];
                field[h][w] = 0;
            }
        }
    }
    }
    /*
    cerr << "after" << endl;
    for(int h = H; h >= 1; h--) {
        for(int w = 1; w <= W; w++) cerr << field[h][w] << " ";
        cerr << endl;
    }
    */
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        cin >> H;
        if(H == 0) break;
        for(int h = H; h >= 1; h--) {
            for(int w = 1; w <= W; w++) cin >> field[h][w];
        }
        int score = 0;
        while(true) {
            int now = f();
            //cerr << score << " "<< now << endl;
            if(now == 0) break;
            score += now;
            drop();
        }
        cout << score << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
# cording: utf-8

num = []

while True:
    list = input().rstrip().split(" ")
    if str(list[1]) == "?":
        break
    num.append(list)

for i in range(len(num)):
    if str(num[i][1]) == "+":
        print(int(num[i][0]) + int(num[i][2]))
    elif str(num[i][1]) == "-":
        print(int(num[i][0]) - int(num[i][2]))
    elif str(num[i][1]) == "*":
        print(int(num[i][0]) * int(num[i][2]))
    else:
        print(int(num[i][0]) // int(num[i][2]))

Measured memory_bytes: 7620
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  while(true){
    int num,m;
    cin >> num >> m;
    if(num==0&&m==0)return;
    vector<int> ar(num),bs(m);
    for(int i=0;i<num;i++)
      cin >> ar[i];
    for(int i=0;i<m;i++)
      cin >> bs[i];
    for(int i=0;i<num;i++)
      for(int j=0;j<m;j++){
        int t=ar[i];
        ar[i]=bs[j];bs[j]=t;
        int suma=0,sumb=0;
        for(int i=0;i<num;i++)
          suma+=ar[i];
        for(int j=0;j<m;j++)
          sumb+=bs[j];
        if(suma==sumb){cout << bs[j] << " " << ar[i] << endl;goto END;}
        t=ar[i];
        ar[i]=bs[j];
        bs[j]=t;
      }
    cout << -1 << endl;
    END:;
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int roop=1;
  while(roop--)
    solve();
  return 0;
}



Measured memory_bytes: 3132
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using namespace std;
int n, x;
int a[105];
int main() {
	cin >> n >> x;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + n);
	cout << n + (x - sum) / a[0] << endl;
	return 0;
}

Measured memory_bytes: 384
import math
K = int(input())
count = 0
for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(1,K+1):
            if i != j:
                count += 2 * math.gcd(math.gcd(i,j),k)
            else:
                count += math.gcd(math.gcd(i,j),k)
print(count)

Measured memory_bytes: 9064
#
# abc047 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """BBBWW"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """WWWWWW"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """WBWBWBWBWB"""
        output = """9"""
        self.assertIO(input, output)


def resolve():
    S = list(input())

    i = 1
    while i < len(S):
        if S[i] == S[i-1]:
            del S[i]
        else:
            i += 1

    print(len(S)-1)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 17036
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, K;
vector<pii > s;
priority_queue<pii > que;
priority_queue<pii , vector<pii > , greater<pii > > sque;
int eat[100100];

signed main()
{
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        s.pb(mk(b, a));
    }
    sort(s.rbegin(), s.rend());
    int sum = 0;
    for(int i = 0; i < N; i++){
        if(i < K){
            sum += s[i].first;
            if(eat[s[i].second] > 0){
                sque.push(s[i]);
            }
            eat[s[i].second]++;
        }
        else {
            que.push(s[i]);
        }
    }
    int cnt = 0;
    for(int i = 0; i <= N; i++){
        if(eat[i]){
            cnt++;
        }
    }
    int ans = sum + cnt * cnt;
    for(int i = cnt + 1; i <= K; i++){
        while(sque.size() && eat[sque.top().second] <= 1){
            sque.pop();
            if(!sque.size()){
                break;
            }
        }
        if(!sque.size()){
            break;
        }
        while(que.size() && eat[que.top().second] >= 1){
            que.pop();
            if(!que.size()){
                break;
            }
        }
        if(!que.size()){
            break;
        }
        sum -= sque.top().first;
        sum += que.top().first;
        eat[que.top().second]++;
        sque.pop();
        que.pop();
        ans = max(ans, sum + i * i);
    }
    cout << ans << endl;

    return 0;
}
/*


*/




Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	for(string s;n--;){
		cin>>s;
		int pos=0,t=0;
		for(;pos+1<s.size();t++){
			int k=s[pos]+s[pos+1]-'0'-'0';
			s[pos]=(k/10)+'0';
			s[pos+1]=(k%10)+'0';
			if(s[pos]=='0')pos++;
		}
		cout<<(t%2?"Fabre wins.":"Audrey wins.")<<endl;
	}
	return 0;
}


Measured memory_bytes: 1196
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;
bool atari(string s, string t) {
	rep(i, 0, s.size()) {
		if (s[i] == '*' || t[i] == '*')continue;
		else if (s[i] != t[i])return false;
	}
	return true;
}
signed main() {
	int n, m;
	while (cin >> n >> m, n || m) {
		map<string, int>M;
		long long ans(0);
		rep(i, 0, n) {
			string s; int a; cin >> s >> a;
			M[s] = a;
		}
		rep(i, 0, m) {
			string s; cin >> s;
			each(it, M) {
				if (atari(it->first, s))ans += it->second;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    dp = [[0] * 4 if i != 3 else [1] * 4 for i in range(N+3)]
    MOD = int(1e9) + 7
    for i in range(4, N+3):
        sum_pre = sum(dp[i-1]) % MOD
        # A
        dp[i][0] = sum_pre
        # C
        dp[i][1] = (sum_pre - dp[i-2][0] - dp[i-2][2] - dp[i-3][0] * 3) % MOD
        # G
        dp[i][2] = (sum_pre - dp[i-2][0] + dp[i-3][2]) % MOD
        # T
        dp[i][3] = sum_pre
    print(sum(dp[-1]) % MOD)

if __name__ == "__main__":
    main()

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

const int MOD = 1e9 + 7;
const int N = 5005;

int dp[N][N];
string s;
int n;

int solve(int pos,int sisa) {
	if(sisa == 0) return pos == s.length();
	int &ret = dp[pos][sisa];
	if(ret != -1) return ret;
	ret = 0;
	ret = solve(pos+1,sisa-1);
	if(pos > 0) ret = (ret + 2ll * solve(pos-1,sisa-1)) % MOD;
	else ret = (ret + solve(pos,sisa-1)) % MOD;
	return ret;
}

int main() {
	cin >> n >> s;
	memset(dp,-1,sizeof dp);
	cout << solve(0,n) << endl;
	return 0;
}

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

int main()
{
	int a, b, c, k;
	std::cin >> a >> b >> c >> k;

	while (k > 0 && b <= a)
		b *= 2, k--;
	
	while (k > 0 && c <= b)
		c *= 2, k--;
	
	std::cout << (a < b && b < c ? "Yes" : "No");
}

Measured memory_bytes: 3632
dic={}

n=int(input())
for i in range(n):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=1

#print(dic)

maxa=0
for val in dic:
    maxa=max(dic[val],maxa)
ans=[]
for val in dic:
    if dic[val]==maxa:
        ans.append(val)
print("\n".join(sorted(ans)))

Measured memory_bytes: 34140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtcoderC
{
    class Program
    {
        /*static void Main(string[] args)
        {
        }*/
        //ABC132C
        //全探索法
        /*static void Main()
        {
            BigInteger N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int min = input.Min();
            int max = input.Max();
            int countARC = 0;
            int countABC = 0;
            int Answer = 0;
            for (int i = min; i <= max; i++)
            {
                countABC = 0;
                countARC = 0;
                foreach (int n in input)
                {
                    if (n > i)
                    {
                        countARC++;
                    }
                    else
                    {
                        countABC++;
                    }
                }
                if (countABC == countARC)
                {
                    Answer++;
                }
            }
            Console.WriteLine(Answer);
        }*/
        //2回目
        /*static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(input);
            int min = input[(N / 2) - 1];
            int max = input[N / 2];
            Console.WriteLine(max - min);
        }*/
        //ABC131C
        static void Main()
        {
            BigInteger[] input = Console.ReadLine().Split().Select(BigInteger.Parse).ToArray();
            BigInteger A = input[0];
            BigInteger B = input[1];
            BigInteger C = input[2];
            BigInteger D = input[3];
            BigInteger ans = (B / C) + (B / D);           
            //最小公倍数
            var ans2 = C * D / lcm(C, D);
            BigInteger ans3 = B / ans2;
            var BB = B - ans + ans3;
            ans = (A - 1) / C + (A - 1) / D;
            ans3 = (A - 1) / ans2;
            var AA = (A - 1) - ans + ans3;
            Console.WriteLine(BB - AA);
            
        }
        static public BigInteger lcm(BigInteger a, BigInteger b)
        {
            var r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }
    }
}


Measured memory_bytes: 13652
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int arr[5], i, count1;

   for(i=0; i<5; i++)
   {
       cin >> arr[i];

       if(arr[i] == 0)
       {
           count1 = i;
       }
   }

   cout << count1+1;

   return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0;
    int ans = 0;
    rep(i, n) {
        if (s[i] == 'I') x++;
        else x--;
        chmax(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;


int main(){
  ll n,k;cin>>n>>k;
  vll a(n);
  rep(i,0,n){
    cin>>a[i];
  }
  rep(i,0,min(45LL,k)){
    vll sum(n+1,0);
    rep(i,0,n){
      sum[max(i-a[i],0LL)]++;
      sum[min(n,i+a[i]+1)]--;
    }
    rep(i,1,n){
      sum[i]+=sum[i-1];
    }
    rep(i,0,n){
      a[i]=sum[i];
    }
  }
  rep(i,0,n){cout<<a[i]<<" ";}
  cout<<endl;
}



Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

int main()
{ 
    LL n;
    cin>>n;
    LL a[n+1];
    for(int i=0;i<=n;i++){
        cin>>a[i];
    }
    LL b[n+1];
    b[0]=1-a[0];
    if(b[0]<0){cout<<-1<<endl;return 0;}
    for(int i=1;i<=n;i++){
        b[i]=b[i-1]*2-a[i];
        if(b[i]>1000000000000000){b[i]=1000000000000000;}
        if(b[i]<0){cout<<-1<<endl;return 0;}
    }
    LL ans=0;
    LL cnt=0;
    for(int i=n;i>=0;i--){
        if(cnt>b[i]){cnt=b[i]+a[i];}
        else{cnt=cnt+a[i];}
        ans=ans+cnt;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5184
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	s := Scanner()
	n := len(s)
	ans := true
	for i := 0; i < n; i++ {
		if s[i] != s[n-i-1] {
			ans = false
		}
	}
	h1 := (n - 1) / 2
	h2 := (n+3)/2 - 1
	for i := 0; i < h1; i++ {
		if s[i] != s[h1-i-1] {
			ans = false
		}
	}
	for i := 0; i < n-h2; i++ {
		if s[i+h2] != s[n-i-1] {
			ans = false
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;


int main()
{
    string s;

    cin >> s;

    if ( (s[2] == s[3]) && (s[4] == s[5]) ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17

string to_binString(unsigned int val)
{
    if( !val )
        return std::string("0");
    std::string str;
    while( val != 0 ) {
        if( (val & 1) == 0 )  // val は偶数か？
            str.insert(str.begin(), '0');  //  偶数の場合
        else
            str.insert(str.begin(), '1');  //  奇数の場合
        val >>= 1;
    }
    return str;
}
int main(){
    ll n,k;cin>>n>>k;
    VI a(n),m(n+1);
    rep(i,n){
        cin>>a[i];
        m[i+1]=a[i];
    }
    rep(i,n)m[i+1]=max(m[i+1],m[i]);
    ll ans=INFTY;
    rep(bit,(1LL<<n)){
        VI list;
        rep(i,n)if(bit&(1LL<<i))list.push_back(i);
        if((ll)list.size()!=k)continue;
        ll maxH=0,res=0;
        rep(i,k){
            chmax(maxH,m[list[i]]);
            if(a[list[i]]<=maxH){
                maxH++;
                res+=maxH-a[list[i]];
            }
            else maxH=a[list[i]];
        }
        chmin(ans,res);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>

int main() {
  int N, K, Q;
  std::cin >> N >> K >> Q;
  
  std::vector<int> Points(N, 0);
  
  for (int i=0, temp; i<Q; ++i) {
    std::cin >> temp;
    ++Points.at(temp-1);
  }
  
  for (int i=0; i<N; ++i) {
    if (Q - Points.at(i) < K)
      std::cout << "Yes" << std::endl;
    else
      std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    int A[100000],B[100000];
    for(int i=0;i<M;i++){
        cin>>A[i]>>B[i];
        A[i]--; B[i]--;
    }
    vector<int> group[100000];
    int parent[100000];
    for(int i=0;i<N;i++){
        vector<int> v;
        v.push_back(i);
        group[i]=v;
        parent[i]=i;
    }
    long long ans[100000];
    ans[M-1]=(long long)N*(N-1)/2;
    for(int i=M-1;i>0;i--){
        //i番目の橋が建てられた時に起きる変化を考える
        ans[i-1]=ans[i];
        int x=parent[A[i]];
        int y=parent[B[i]];
        if(x != y){
            int xsize=group[x].size();
            int ysize=group[y].size();
            ans[i-1] -= (long long) xsize*ysize;
            //マージてく
            //size[y]の方が小さく，全体はxに統一
            if(xsize < ysize) swap(x,y);
            for(int z=0;z<group[y].size();z++){
                int k=(group[y])[z];
                parent[k]=x;
                group[x].push_back(k);
            }
            
        }
    }
    for(int i=0;i<M;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 12536
import sys

while 1:
  n=input()
  if n==0:break
  A=[' '*(n+1)]+[' '+raw_input() for i in range(n)]
  M=[[0]*(n+1) for i in range(n+1)]
  c=0
  for i in range(1,n+1):
    for j in range(1,n+1):
      if A[i][j]=='.': M[i][j]=min(M[i-1][j-1],M[i-1][j],M[i][j-1])+1
    c=max(c,max(M[i]))
  print c

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

#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)

const int nex[2][6][2] = {
	{{1,0},{0,1},{-1,0},{0,-1},{-1,-1},{1,-1}},
	{{1,0},{0,1},{-1,0},{0,-1},{-1,1},{1,1}}
};

int w,h,a[110][110],ret;
void dfs(int x,int y){
	if(a[x][y] == 0){
		a[x][y] = -1;
		rep(i,6)dfs(x + nex[x%2][i][0],y + nex[x%2][i][1]);
	}
}

int main(){
	rep(i,110)rep(j,110){a[i][j] = 0; if(i == 0 || i == 109 || j == 0 || j == 109)a[i][j] = -2;}
	cin >> w >> h;
	rep(i,h)rep(j,w)cin >> a[i+3][j+3];
	dfs(1,1);
	rep1(i,108)rep1(j,108)rep(k,6)if(a[i][j]*a[i+nex[i%2][k][0]][j+nex[i%2][k][1]] < 0)ret ++;
	cout << ret/2 << endl;
}

Measured memory_bytes: 1748
#include<iostream>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)

class Cube{
    public:
    int f[6];
    Cube(){}
    void roll_z(){ roll(1, 2, 4, 3);}
    void roll_y(){ roll(0, 2, 5, 3);}
    void roll_x(){ roll(0, 1, 5, 4);}
    void roll(int i, int j, int k, int l){
        int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t; 
    }
};

bool eq(Cube c1, Cube c2){
    rep(i, 6){
        if(c1.f[i]!=c2.f[i]) return false;
    }
    return true;
}

bool equal(Cube c1, Cube c2){
    rep(i, 6){
        rep(j, 4){
            if(eq(c1, c2)) return true;
            c1.roll_z();
        }
        if(i%2==0) c1.roll_y();
        else c1.roll_x();
    }
    return false;
}

Cube C[100]; int n;

bool check(){
    rep(i, n-1){
        for(int j=i+1;j<n;j++) if(equal(C[i], C[j])) return false;
    }
    return true;
}

int main(){
    cin>>n;
    rep(j, n){
        rep(i, 6) cin>>C[j].f[i];
    }

    if(check()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


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

int main(void) {
  int a, b;

  if(scanf("%d %d", &a, &b) == 1);

  if(b % a == 0) {
    printf("%d", a + b);
  } else {
    printf("%d", b - a);
  }

  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
inline char gc(){
	static char buf[1<<14],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<14,stdin),p1==p2)?EOF:*p1++;
}
inline ll read(ll &x){
	x=0;bool f=1;char c=gc();
	for(;!isdigit(c);c=gc()){if(c=='-')f^=1;if(c==-1)return-1;}
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);x=f?x:-x;
	return 1;
}
#define pc putchar
inline void wr(ll x){
	if(x<0)pc('-'),x=-x;
	if(x>9)wr(x/10);pc(x%10|48);
}
const ll N=2e5+10;
struct node{
	ll x,id;
	bool operator <(const node&res)const{
		return x==res.x?id<res.id:x>res.x;
	}
}a[N];
ll n,ans[N],j=1;
int main(){
	read(n);
	for (ll i=1;i<=n;++i) read(a[i].x),a[i].id=i;
	sort(a+1,a+1+n);
	for (ll i=2;i<=n;++i){
		for (;a[i].x==a[i-1].x;++i);
		ans[a[j].id]+=(a[j].x-a[i].x)*(i-1);
		if (a[i].id>a[j].id) a[j].x=a[i].x;
		else j=i;
	}
	ans[a[j].id]+=a[j].x*n;
	for (ll i=1;i<=n;++i,puts("")) wr(ans[i]);
	return 0;
}

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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define debug(x) cerr<<#x<<"="<<x<<'\n'

const int maxn=2e5+10;

int n,d,a;
pii mon[maxn];
int pos[maxn];
ll tree[maxn];

int lowbit(int x) {
	return x&(-x);
}

ll query(int pos) {
	ll res=0ll;
	while (pos) {
		res+=tree[pos];
		pos-=lowbit(pos);
	}
	return res;
}

void update(int pos,ll val) {
	while (pos<maxn) {
		tree[pos]+=val;
		pos+=lowbit(pos);
	}
}

int main(){
	scanf("%d%d%d",&n,&d,&a);
	d*=2;
	for (int i=1;i<=n;i++) scanf("%d%d",&mon[i].fi,&mon[i].se);
	sort(mon+1,mon+n+1);
	for (int i=1;i<=n;i++) {
		pos[i]=mon[i].fi;
		update(i,mon[i].se-mon[i-1].se);
	}
	ll ans=0;
	for (int i=1;i<=n;i++) {
		ll cur=query(i);
		if (cur<=0ll) continue;
		int cnt=(cur-1)/a+1;
		ans+=(ll)cnt;
		ll tmp=min((ll)pos[n],pos[i]+(ll)d);
		int rt=upper_bound(pos+i,pos+1+n,(int)tmp)-pos-1;
		if (rt>i) update(i+1,-a*cnt),update(rt+1,a*cnt);
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


typedef tuple<int,int,int> P;


int X,Y,Z,K;
int A[1145],B[1419],C[19810];

signed main(){
    auto les = [](const P F, const P G){
        int a=0,b=0;
        a=A[get<0>(F)]+B[get<1>(F)]+C[get<2>(F)];
        b=A[get<0>(G)]+B[get<1>(G)]+C[get<2>(G)];
        return a < b;
    };

    cin >> X >> Y >> Z >> K;
    REP(i,X){cin >> A[i];}sort(A,A+X,greater<>());
    REP(i,Y){cin >> B[i];}sort(B,B+Y,greater<>());
    REP(i,Z){cin >> C[i];}sort(C,C+Z,greater<>());

    priority_queue<P, vector<P>, decltype(les)> Q(les);
    Q.push(make_tuple(0,0,0));
    map<P,bool> al;
    al[make_tuple(0,0,0)]=1;


    int r;
    P p;
    REP(w,K){
        p=Q.top();
        Q.pop();
        int i,j,k;
        i=get<0>(p);
        j=get<1>(p);
        k=get<2>(p);
        r=A[i]+B[j]+C[k];
        //cout << i << " " << j << " " << k << " ";
        cout << r << endl;

        if(i!=X-1 && al[make_tuple(i+1,j,k)]==0){
            Q.push(make_tuple(i+1,j,k));
            //cout << i+1 << " " << j << " " << k << endl;
            al[make_tuple(i+1,j,k)]=1;
        }
        if(j!=Y-1 && al[make_tuple(i,j+1,k)]==0){
            Q.push(make_tuple(i,j+1,k));
            //cout << i << " " << j+1 << " " << k << endl;
            al[make_tuple(i,j+1,k)]=1;
        }
        if(k!=Z-1 && al[make_tuple(i,j,k+1)]==0){
            Q.push(make_tuple(i,j,k+1));
            //cout << i << " " << j << " " << k+1 << endl;
            al[make_tuple(i,j,k+1)]=1;
        }

    }

    return 0;
}


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

using namespace std;

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

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() { IO;
  int n, a, b;
  cin >> n >> a >> b;

  vector<int> v(3);
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;

    int type;
    if (p <= a) {
      type = 0;
    } else if (p <= b) {
      type = 1;
    } else {
      type = 2;
    }

    v[type]++;
  }

  int ans = *min_element(v.begin(), v.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
int const INF = 1001001001;

ll dp[55][55][2505];

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

int N,A;
cin >> N >> A;
vl x(N);
rep(i,N) cin >> x[i];

memset(dp, 0, sizeof(dp));
dp[0][0][0] = 1;

rep(i,N)rep(j,N)rep(k,2500){
    dp[i+1][j][k] += dp[i][j][k];
    dp[i+1][j+1][k+x[i]] += dp[i][j][k];
}
ll ans = 0;
rrep(i, N) {
    ans += dp[N][i][i*A];
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 59520
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;
    cin>>x>>y;
    ll ans = 1e18;
    if(-x<=y) ans=min(ans,y-(-x)+1);
    if(x<=y) ans=min(ans,y-x);
    if(x<=-y) ans=min(ans,-y-x+1);
    if(-x<=-y) ans=min(ans,-y+x+2);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
# copy
class Tree():
    def __init__(self):
        self.nodes = {}

    def add_node(self, id):
        if id not in self.nodes:
            self.nodes[id] = Node(id)

    def add_child(self, parent_id, child_id):
        self.add_node(parent_id)
        self.add_node(child_id)
        self.nodes[parent_id].add_child(self.nodes[child_id])


class Node():
    def __init__(self, id):
        self.id = id
        self.parent = None
        self.children = []
        self.depth = 0
        self.nodetype = 'root'

    def add_child(self, child):
        self.children.append(child)
        child.parent = self
        child.update_depth()
        child.update_nodetype()
        self.update_nodetype()
        if self.parent:
            self.parent.update_nodetype()

    def update_depth(self):
        depth = self.depth
        if self.parent:
            self.depth = self.parent.depth + 1
        if depth != self.depth:
            for child in self.children:
                child.update_depth()

    def update_nodetype(self):
        if self.parent:
            if len(self.children):
                self.nodetype = 'internal node'
            else:
                self.nodetype = 'leaf'
        else:
            self.nodetype = 'root'

    def walk(self):
        yield self
        for child in self.children:
            for node in child.walk():
                yield node

    def __str__(self):
        parent = self.parent.id if self.parent else -1
        children = ', '.join([str(node.id) for node in self.children])
        return 'node {}: parent = {}, depth = {}, {}, [{}]'.format(self.id,
                                                                   parent,
                                                                   self.depth,
                                                                   self.nodetype,
                                                                   children)


tree = Tree()

n = int(input())
for i in range(n):
    line = input().split()
    id = int(line[0])
    tree.add_node(id)
    for ci in map(int, line[2:]):
        tree.add_child(id, ci)

for id in sorted(tree.nodes):
    print(tree.nodes[id])


Measured memory_bytes: 45832
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int a, b;
    cin >> a >> b;

    int ans = a - 1;
    if (a <= b) {
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
shop = []
for _ in range(n):
    a, b = map(int, input().split())
    shop.append([a, b])
 
shop = sorted(shop) # 一番値段の小さいところから買えるだけ買っていく
ans, num = 0, 0
for i in range(n):
    a, b = shop[i]
    num += b
    ans += a*b
    if num>=m:
        ans -= (num-m)*a # 買うべき量を上回ったら、余計に買った分を減らす
        break
 
print(ans)

Measured memory_bytes: 20832
def 解():
    iN,iT = [int(_) for _ in input().split()]
    aA = [int(_) for _ in input().split()]

    aMaxD = [0]
    iMin = aA[0]
    iV = 0

    def checkMax(aMaxD,iMaxD):
        if aMaxD[0] < iMaxD:
            aMaxD = [iMaxD]
        elif aMaxD[0] == iMaxD:
            aMaxD.append(iMaxD)
        return aMaxD

    iB = aA[0]
    for iN in aA[1:]:
        if iB - iN > 0: #山
            if iV >= 0:
                aMaxD = checkMax(aMaxD,iB-iMin)
            iV = -1
        elif iB - iN < 0: #谷
            if iV <= 0:
                if iB < iMin : iMin = iB
            iV = 1
        iB = iN
    aMaxD = checkMax(aMaxD,aA[-1] - iMin)
    print( len(aMaxD) )
解()


Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <stack>
#include <sstream>
using namespace std;

namespace patch
{
	template < typename T > std::string to_string( const T& n )
	{
		std::ostringstream stm;
		stm << n;
		return stm.str();
	}
}


string calcOperand (int num1, int num2, string ope) {
	//cout << num1 << " " << num2 << " " << ope << endl;
	if (ope == "+") {
		return patch::to_string(num1 + num2);
	} else	if (ope == "-") {
		return patch::to_string(num1 - num2);
	} else	if (ope == "*") {
		return patch::to_string(num1 * num2);
	} else	if (ope == "/") {
		return patch::to_string(num1 / num2);
	}

	return "error";
}

int checkOperand (string str) {
	if (str == "+") {
		return 1;
	} else if (str == "-") {
		return 1;
	} else if (str == "*") {
		return 1;
	} else if (str == "/") {
		return 1;
	}
	return 0;
}

string reversePoland(stack<string> stk) {
	stack<string> tmpStack; 
	int calcFlag = 0;

	while(stk.size() != 0 || tmpStack.size() != 1) {
		if (tmpStack.size() > 2 && !checkOperand(tmpStack.top())) {
			string strNum1 = tmpStack.top();
			int num1;
			std::istringstream ss(strNum1);
			ss >> num1;
			tmpStack.pop();
			if (!checkOperand(tmpStack.top())) {
				string strNum2 = tmpStack.top();
				int num2;
				std::istringstream ss(strNum2);
				ss >> num2;
				tmpStack.pop();
				string ope = tmpStack.top();
				tmpStack.pop();
				tmpStack.push(calcOperand(num1, num2, ope));
				continue;
			} else {
				tmpStack.push(strNum1);
			}
		}
		if (stk.size() > 0) {
			tmpStack.push(stk.top());
			stk.pop();
		}
	}
	return tmpStack.top();
}

int main(int argc, char const* argv[])
{
	stack<string> myStack; 
	string tmpStr;

	getline(cin,tmpStr);
	while(tmpStr.find(" ") != -1){
		int sp=tmpStr.find(" ");
		string main_command=tmpStr.substr(0,sp);
		myStack.push(main_command);
		tmpStr=tmpStr.substr(sp+1,tmpStr.length());
	}
	myStack.push(tmpStr);

	cout << reversePoland(myStack) << endl;
	return 0;
}


Measured memory_bytes: 1260
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int N;
  cin >> N;
  vector<P> X(N), result(N);
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    X.at(i) = P(x, i);
  }
  sort(ALL(X));
  int med = (N-1)/2;
  for(int i = 0; i < N; i++){
    if(i <= med){
        result.at(i).second = X.at(med+1).first;
        result.at(i).first = X.at(i).second;
    }
    else{
      result.at(i).second = X.at(med).first;
      result.at(i).first = X.at(i).second;
    }
  }
  sort(ALL(result));
  for(int i = 0; i < N; i++){
    cout << result.at(i).second << endl;
  }
}

Measured memory_bytes: 5376