akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



#define N 2000004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return po(mod(mod(i)*mod(i)),p/2);
    else  return mod(mod(i)*po(i,p-1));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    else if(n==0)return 1;
    else return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}
ll bunbo(ll n){
    return po(n,i_5);
}



 
int main(){fastio
    
    calc();
    
    ll x,y;cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;return 0;
    }
    ll n=(x+y)/3;
    x-=n;
    y-=n;
    if(x<0||y<0){
        cout<<0<<endl;return 0;
    }
    cout<<comb(x+y,x)<<endl;
    
    
    return 0;
}

Measured memory_bytes: 31616
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  l,r,d=LI()
  ans=0

  for i in range(l,r+1):
    if i%d==0:
      ans+=1

  return ans

# main()
print(main())


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

int main() {
  int a, b, c; cin >> a >> b >> c;
  if (a < b) swap(a, b);
  if (a < c) swap(a, c);
  int ans = 0;
  if (b%2 == c%2) ans = ((a-b) + (a-c))/2;
  else ans = (1 + (a-b+1) + (a-c+1))/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

int main()
{
	int a1,a2,a3,a4,a5;scanf("%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5);
	ll ans=ll(a1)/2*2+a2+a4/2*2+a5/2*2;
	if (a1%2==1&&a4%2==1&&a5%2==0&&a5) {ans-=2;a5++;}
	if (a1%2==1&&a4%2==0&&a5%2==1&&a4) {ans-=2;a4++;}
	if (a1%2==0&&a4%2==1&&a5%2==1&&a1) {ans-=2;a1++;}
	if (a1%2==1&&a4%2==1&&a5%2==1) ans+=3;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main() {
  int N, L; cin >> N >> L;
  int total = 0;
  for(int i = 0; i < N; i++) {
    total += L + i;
  }
  if(L >= 0) {
    total -= L;
  } else if(L + N <= 0) {
    total -= L + N - 1;
  }
  cout << total << endl;
}


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

using namespace std;

class P
{
public:
	int x,y;
	P(int X,int Y)
	{
		x=X;
		y=Y;
	}
};

int main()
{
	stack<P>st;
	int n,m;
	int numX[4]={0,1,0,-1};
	int numY[4]={1,0,-1,0};

	while(cin>>n>>m && n)
	{
		int flag[500][500]={};
		int count=0;
		string in;
		char set[500][500]={};

		for(int i=1;i<=m;i++)
		{
			for(int j=1;j<=n;j++)
			{
				cin >> set[i][j];
			}
		}

		for(int i=1;i<=m;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(set[i][j]=='@')
				{
					st.push(P(j,i));
					flag[i][j]=1;
				}
			}
		}

		int xx,yy;

		while(!st.empty())
		{
			count++;
			xx=st.top().x;
			yy=st.top().y;
			st.pop();
			for(int i=0;i<4;i++)
			{
				if(set[numY[i]+yy][numX[i]+xx]=='.' && flag[numY[i]+yy][numX[i]+xx]==0)
				{
					st.push(P(numX[i]+xx,numY[i]+yy));
					flag[numY[i]+yy][numX[i]+xx]=1;
				}
			}

		}
		cout << count << endl;
	}

    return 0;
}

Measured memory_bytes: 2428
// atcoder/abc055/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    cout << (n * 800) - ((n / 15) * 200) << endl;
  }

  return 0;
}


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

using namespace std;

typedef pair<bool,int> P; 

int main(){
  int N;
 
  while(cin >> N, N){
    vector<P> vec;
    bool in;
    for(int i = 0 ; i < N ; i++){
      int size = vec.size();
      
      cin >> in;
      if(((i+1) % 2) == 0){
        if(vec[size-1].first != in){
          for(int j = size-1 ; j >= 0 ; j--){
            if(vec[j].first == in){
              break;
            }else{
              vec[j].first = in;
            }
          }
        } 
      }
      if(i && vec[size-1].first == in){
        vec[size-1].second++;
      }else{
        vec.push_back(P(in,1));
      }
    }
    int ans = 0;
    for(int i = 0 ; i < (int)vec.size() ; i++){
      if(!vec[i].first){
        ans += vec[i].second;
      }
    }
    cout << ans << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long

  

int32_t main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int count=0;
    for(int i=1;i<=10000000;i++)
    {
		count=(count*10+7)%n;
		if(!count)
		{
		cout<<i;
		return 0;
	    }
	}   
	
	cout<<-1;
 
   

		
	
		  
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
    int m;
    int n;
    cin >>m>>n;
    int a[m][n];
    for (int j=0; j<m;j++){
        for (int i=0;i<n;i++){
           cin>>a[j][i];
       }
    }
    int b[n];
    for (int i=0;i<n;i++){
        cin>>b[i];
    }
    for (int j=0; j<m;j++){
        int c=0;
        for (int i=0;i<n;i++){
            
            c+=b[i]*a[j][i];
        }cout << c <<endl;
    }
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

class Flow {
public:
  struct edge {int to;long long cap;int rev;};
  static const int MAX_V=100000;
  static const long long  INF = 1e18;

  std::vector<edge> G[MAX_V];
  bool used[MAX_V];

  void add(int from,int to,long long cap){
    G[from].push_back((edge){to,cap,(int)G[to].size()});
    G[to].push_back((edge){from,0,(int)G[from].size()-1});
  }

  long long dfs(int v,int t,long long f){
    if(v==t) return f;
    used[v]=true;
    for(int i=0;i<G[v].size();i++){
      edge &e = G[v][i];
      if(!used[e.to] && e.cap > 0){
	long long d = dfs(e.to,t,min(f,e.cap));
	if(d>0){
	  e.cap -= d;
	  G[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }

  long long max_flow(int s,int t){
    long long flow = 0;
    while(true){
      memset(used,0,sizeof(used));
      long long f = dfs(s,t,INF);
      if(f == 0)return flow;
      flow+=f;
    }
  }
};


int h,w,s,t;
string st[100];

int main(){
  cin>>h>>w;
  Flow g;
  REP(i,h){
    cin>>st[i];
    REP(j,w){
      if(st[i][j]=='S'){s=i*w+j;g.add(0,1+i,g.INF);g.add(0,1+h+j,g.INF);}
      if(st[i][j]=='T'){t=i*w+j;g.add(1+i,1+h+w,g.INF);g.add(1+h+j,1+h+w,g.INF);}
      if(st[i][j]=='o'){g.add(1+i,1+h+j,1);g.add(1+h+j,1+i,1);}
    }
  }
  REP(i,h){
    REP(j,w){
      
    }
  }
  if((t/w==s/w) || (t%w==s%w)){cout<<-1<<endl;return 0;}
  cout<<g.max_flow(0,1+h+w)<<endl;
  return 0;
}


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

int main(){
    long long n, k;
    cin >> n >> k;
    long long ans = 0;
    ans += (n/k)*(n/k)*(n/k);//mod kが0

    if(k%2 == 0){
        long long x = n/(k/2) - (n/k);//mod kがk/2
        ans += x * x * x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_narrow_rectangle_easy(void) {
	int w, a, b;
	cin >> w >> a >> b;
	int a_end = a + w;
	int b_end = b + w;

	if (b >= a_end) cout << b - a_end << endl;
	else if (b_end <= a) cout << a - b_end << endl;
	else cout << 0 << endl;
}

int main()
{
	b_narrow_rectangle_easy();
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  REP(i,n) {
    int ax;
    cin >> ax;
    ax--;
    a[i] = ax;
  }

  REP(i,n) cin >> b[i];
  REP(i,n-1) cin >> c[i];

  ll sum = 0;
  REP(i,n){
    sum += b[a[i]];
    if(i == 0) continue;
    if(a[i] == a[i-1]+1){
      sum += c[a[i]-1];
    }
    debug(sum);
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3608
n, m = map(int, input().split())
xs = [0] * n
for i in range(n):
    a, b = map(int, input().split())
    xs[i] = [a, b]
xs.sort()

cnt = 0
ans = 0
for v in xs:
    if cnt + v[1] < m:
        ans += v[0] * v[1]
        cnt += v[1]
    else:
        print(ans + v[0] * (m - cnt))
        exit()


Measured memory_bytes: 85468
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> s(13,0);
    vector<int> h(13,0);
    vector<int> c(13,0);
    vector<int> d(13,0);

    char str;
    int i;

    while(n>0){
        cin >> str >>i;
        switch (str) {
            case 'S':
                s[i-1] = i;
                break;
            case 'H':
                h[i-1] = i;
                break;
            case 'C':
                c[i-1] = i;
                break;
            case 'D':
                d[i-1] = i;
                break;
        }
        n -= 1;
    }
    for(int i=0; i<13; i++){
        if(s[i]==0){
            cout << "S" << " " << i+1 << endl;
        }
    }
    for(int i=0; i<13; i++){
        if(h[i]==0){
            cout << "H" << " " << i+1 << endl;
        }
    }
    for(int i=0; i<13; i++){
        if(c[i]==0){
            cout << "C" << " " << i+1 << endl;
        }
    }
    for(int i=0; i<13; i++){
        if(d[i]==0){
            cout << "D" << " " << i+1 << endl;
        }
    }


    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll x,k,d;
    cin >> x >> k >> d;
    x=abs(x);
    if(x/d>=k){
        cout << x-k*d << "\n";
        return 0;
    }else{
        ll cnt=x/d;
        if((k-cnt)%2==0){
            cout << abs(x-(cnt*d)) << "\n";
            return 0;
        }else{
            cout << abs((x-(cnt*d)-d)) << "\n";
            return 0;
        }
    }
}   

Measured memory_bytes: 3660
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int cnt = 0;
    bool poison = false;
    for (;;){
        if (not poison and C > 0){
            C--;
            poison = true;
            cnt++;
        }
        if (poison){
            if (B > 0){
                B--;
                poison = false;
                cnt++;
            }
            else if (A > 0){
                A--;
                poison = false;
            }
            else {
                cout << cnt << endl;
                return 0;
            }
        }
        
        if (C == 0){
            cnt += B;
            cout << cnt << endl;
            return 0;
        }
    }
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vector<P> a(n);
  rep(i, n) {
    int x, l;
    cin >> x >> l;
    a[i].first = x - l;
    a[i].second = x + l;
  }
  sort(a.begin(), a.end());
  dump(a);
  int ans = 0;
  ll mn = LINF;
  rep(i, n) {
    if (mn <= a[i].first) {
      ans++;
      mn = LINF;
    }
    if (a[i].second < mn) {
      mn = a[i].second;
    }
  }
  cout << ans + 1 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }

int main(){
  int n,m; cin >> n >> m;
  vi x(m),y(m);
  rep(i,m){
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
  }

  vi cnt(n,1);
  set<int> st = {0};
  rep(i,m){
    if(st.count(x[i])) st.insert(y[i]);
    cnt[x[i]]--; cnt[y[i]]++;
    if(cnt[x[i]] == 0) st.erase(x[i]);
  }
  cout << st.size();
  cout << "\n";
  return 0;
}


Measured memory_bytes: 9048
tm = []
for i in range(5):
	tm.append(int(input()))
tm.sort()

t = 0
ord = 0
loss = []
for i in range(5):
	t2 = 0
	while t2 < tm[i]:
		t2 += 10
	t += t2
	loss.append(t2 - tm[i])

print(t-max(loss))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; 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, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    map<char,int> s;
    rep(i,4){
        char c;cin >> c;
        s[c]++;
    }

    if(s.size() == 2 && s.begin()->second == 2 && next(s.begin())->second == 2) cout << "Yes\n";
    else cout << "No\n";
    
}

Measured memory_bytes: 3608
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << max(0, a - 2 * b) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
monsters = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:  
        return a
    else:
        return gcd(b, a%b)
gcd(4,2)

def gcd_more(a):
    ans = a[0]
    for i in range(1,len(a)):
        ans = gcd(ans, a[i])
    return ans
print(gcd_more(monsters))

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


int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0;i<N;i++) cin >> S.at(i);
    sort(S.begin(),S.end());
    int a=N;
    for(int i=0;i<N-1;i++){
        if(S.at(i)==S.at(i+1)) a--;
    }
    cout << a << endl;
}

Measured memory_bytes: 9544
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
// use std::collections::HashMap;
// use std::collections::VecDeque;
// use std::cmp::max;
// use std::cmp::min;

fn main() {
    input! {
        A: i8,
        B: i8,
    }

    let ans = if A <= 9 && B <= 9 {
        format!("{}", A * B)
    } else {
        "-1".to_string()
    };
    println!("{}", ans);
}


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

int main() {

        int a,b,c,k,n,m;
        cin >> a >> b >> c >> k;

        n = k - a;
        m = n - b;
        c = m - c;

        if (a >= k) {
                a = k;
                b = 0;
                c = 0;
        }
        else {
                a = a;
                if (b >= k - a) {
                        b = k - a;
                        c = 0;
                }
                else {
                        b = b;
                        c = k - a - b;
                }
        }

        //int ans = (1 * n) + (0 * m) + ((-1) * c);

        int ans = (1 * a) + (0 * b) + ((-1) * c);

        cout << ans << endl;

        /*if (T == S) {
                cout << "Yes" << endl;
        }

        else {
                cout << "No" << endl;
        }*/

}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    ll n;
    cin >> n;
    ll ans = 1;
    ll a;
    bool flag = false, flag2 = false;
    rep(i,n) {
        cin >> a;
        if (a == 0){ flag2 = true; continue;}
        if (ans > 1000000000000000000 / a) {flag = true;}
        ans *= a;
    }
    if (flag2) {cout << 0 << endl; return 0;}
    else if (flag) {cout << -1 << endl; return 0;}
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
M=10**9+7
o=->a,n{n<1?1:a**n[0]*o[a,n/2]**2%M}
eval'N,A,B,C='+gets.split*?,
f=f=1,*(1..2*N).map{|i|f=f*i%M}
t=o[A+B,M-2]
A*=t
B*=t
a=o[A,N]
b=o[B,N]
z=0
N.times{|i|
	z+=(N+i)*f[N+i-1]*o[f[N-1]*f[i],M-2]*(a+b)
	z%=M
	a=a*B%M
	b=b*A%M
}
p z*100*o[100-C,M-2]%M


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int n,m,q;

int a[50],b[50], c[50],d[50];

vector<int> A(50);

set<vector<int>> st;

int dfs(int s, int length){
  int ret=0;

  A[length] = s;

  if(length < n-1){
    FOR(i,s,m+1){
      chmax(ret, dfs(i,length+1));
    }
  }else{
    int tmp = 0;
    REP(i,q){
      if(A[b[i]]-A[a[i]]==c[i])tmp += d[i];
    }
    chmax(ret,tmp);
  }
  return ret;
}


int main(){
  cin >> n >> m >> q;

  REP(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }


  int ans = 0;
  FOR(i,1,11)chmax(ans,dfs(i, 0));
  cout << ans << endl;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    bool ans = false;
    int cnt = 0;
    REP(i,n) {
        int a, b;
        cin >> a >> b;
        if (a == b) cnt++;
        else cnt = 0;
        if (cnt == 3) ans = true;
    }

    ATYN(ans)

    return 0;
}

Measured memory_bytes: 3644
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sort)

main :: IO ()
main = do
  (n : d : a : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    walk :: Int -> Int -> [(Int, Int)] -> [(Int, Int)] -> [(Int, Int)]
    walk _ _ [] _ = []
    walk 0 _ ((x, h) : xhs') yks = (x, k') : walk 1 k' xhs' yks
      where
        k' = (h + a - 1) `div` a
    walk l c xhs@((x, _) : _) ((y, k) : yks') | y + 2 * d < x = walk (pred l) (c - k) xhs yks'
    walk l c ((x, h) : xhs') yks = (x, k') : walk (succ l) (c + k') xhs' yks
      where
        k' = (max 0 (h - c * a) + a - 1) `div` a
  xhs <- sequence . replicate n $ unsafeListToTuple . map unsafeTextToInt . T.words <$> T.getLine :: IO [(Int, Int)]
  print . sum . map snd . fix . walk 0 0 . sort $ xhs

fix :: (a -> a) -> a
fix f = x
  where
    x = f x

unsafeListToTuple :: [Int] -> (Int, Int)
unsafeListToTuple (x : y : _) = (x, y)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 119164
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int n, m;
const int INF = 100000000;
vector<int> G[100000];
vector<int> D(100000, INF);
vector<int> P(100000, 0);

void bfs() {
  queue<int> Q;
  Q.push(0);
  D[0] = 0;
  while (Q.size()) {
    int p = Q.front(); Q.pop();
    for (auto && c: G[p]) {
      if (D[c] != INF) continue;
      D[c] = D[p] + 1;
      P[c] = p + 1;
      Q.push(c);
    }
  }
}

int main() {
  cin >> n >> m;
  loop(i,0,m) {
    int a, b; cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  bfs();
  cout << "Yes" << endl;
  loop(i,1,n) {
    cout << P[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 10644
const N,D,A=map(x->parse(Int,x),split(readline()))
function update(x,h,cnt,ans,id,sz,P)
	while id<sz&&P[id+1].first<x
		cnt-=P[id+1].second
		id+=1
	end
	h-=cnt*A
	if h>0
		t=div(h+A-1,A)
		ans+=t
		cnt+=t
		push!(P,x+D*2=>t)
		sz+=1
	end
	cnt,ans,id,sz
end
function main()
	H=Pair{Int,Int}[]
	for s=readlines()
		x,h=map(x->parse(Int,x),split(s))
		push!(H,x=>h)
	end
	sort!(H)
	cnt=ans=id=sz=0
	P=Pair{Int,Int}[]
	for (x,h)=H
		cnt,ans,id,sz=update(x,h,cnt,ans,id,sz,P)
	end
	println(ans)
end
main()

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

using namespace std;

int dp[200001];
long long int memo[2];
long long int mypow(long long int x,long long int n,long long int mod)
{
	long long int res = 1;
	while(n>0)
	{
		if(n%2==1)
		{
			res = ((x%mod)*(res%mod)%mod)%mod;
			res%=mod;
		}
		x = ((x%mod)*(x%mod)%mod);
		x%=mod;
		n/=2;
	}
	return res;
}

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

	int n,cnt = 0;
	string s;

	cin >> n;
	cin >> s;

	if(n==1)
	{
		if(s[0]=='0')
		{
			cout << 1 << '\n';
			return 0;
		}
		else
		{
			cout << 0 << '\n';
			return 0;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(s[i]=='1')
		{
			cnt++;
		}
	}

	dp[0] = 0;
	for(int i=1;i<=200000;i++)
	{
		int bitcnt = 0;
		int val = i;
		while(val > 0)
		{
			if(val%2==1)
			{
				bitcnt++;
			}
			val/=2;
		}
		dp[i] = dp[i%bitcnt] + 1;
	}

	if(cnt>1)
	{
		long long int temp = 0;
		for(int i=n-1;i>=0;i--)
		{
			int mod = cnt - 1;
			if(s[i]=='1')
			{
				temp = ((temp%mod) + (mypow(2,n-1-i,mod)%mod)%mod);
				temp%=mod;
			}
		}
		memo[0] = temp;
	}
	long long int temp = 0;
	for(int i=n-1;i>=0;i--)
	{
		int mod = cnt + 1;
		if(s[i]=='1')
		{
			temp = ((temp%mod) + (mypow(2,n-1-i,mod)%mod)%mod);
			temp%=mod;
		}
	}	
	memo[1] = temp;

	for(int i=0;i<n;i++)
	{
		if(s[i]=='0')
		{
			long long int value = memo[1];
			int mod = cnt+1;
			value = ((value%mod) + (mypow(2,n-1-i,mod)%mod)%mod);
			value%=mod;
			cout << dp[value] + 1 << '\n';
		}
		else
		{
			if(cnt==1)
			{
				cout << 0 << '\n';
			}
			else
			{
				long long int value = memo[0];
				int mod = cnt-1;
				value = ((value%mod) - (mypow(2,n-1-i,mod)%mod)%mod);
				value%=mod;
				if(value < 0)
				{
					value+=mod;
				}
				cout << dp[value] + 1 << '\n';
			}
		}
	}
	return 0;
}	

Measured memory_bytes: 4548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{
  int a,b,c;
  edge(int a,int b,int c) : a(a),b(b),c(c) {}
  edge(){}
  bool operator<(const edge &e ) const {
    return c < e.c;
  }

};
int N;
vector<edge> E[100005];

struct uni{
  int d[200005];
  void init(){ memset( d, -1, sizeof( d ) ); }
  int find( int a ) { return d[a]<0?a:(d[a]=find(d[a])); }
  bool merge(int a,int b){
    a = find(a); b = find(b);
    if( a == b ) return false;
    if( d[a]>d[b] ) swap( a, b );
    d[a] += d[b];
    d[b] = a;
  }
  int size(int a){ return -d[find(a)]; }
};
uni U;
int main(){
  U.init();
  cin >> N;
  for(int i=0;i<N-1;i++){
    int a,b,c;
    cin >> a >> b >> c;
    E[c].push_back( edge( a, b, c ) );
  }
  ll res = 0;
  for(int i=0;i<=100000;i++){
    for( edge e : E[i] ){
      res += (ll)U.size( e.a ) * (ll)U.size(e.b) * (ll)e.c;
      U.merge( e.a, e.b );
    }
  }
  cout << res << endl;

}

Measured memory_bytes: 10316
#include "bits/stdc++.h"
using namespace std;
int main(){
 int n;
 cin >> n;
 vector<int> a;
 while(n != 0){
  a.push_back(n % 3);
  n /=3;
}
string s;
  for(int i = 0;i < a.size();i++){
    if(a[i] == 3){
   a[i]= 0;
   if(a.size()-1 == i) a.push_back(0);
      a[i+1]++;
 }
    if(a[i] == 0) s.push_back('0');
    else if (a[i] == 1) s.push_back('+');
    else{
      s.push_back('-');
      if(a.size()-1 == i) a.push_back(0);
      a[i+1]++;
}
}
    reverse(s.begin(),s.end());
  cout << s << endl;
}


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

int main(){
  int N, k;
  cin >> N;
  map<int, int>nums;
  rep(i, N){
    cin >> k;
    nums[k]++;
  }
  int cnt = 0;
  for(auto k: nums){
    if(k.second > k.first)
      cnt += k.second - k.first;
    else if(k.first > k.second)
      cnt += k.second;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>

#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s, t;

	cin >> s >> t;

	ll ans = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}

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

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(26,INF);
  vector<string> s(n);rep(i,n)cin>>s[i];
  
  rep(i,n){
    vector<int> tmp(26,0);
    rep(j,s[i].size()){
      ++tmp[s[i][j]-'a'];
    }
    rep(j,26){
      a[j] = min(tmp[j],a[j]);
    }
  }

  string ans = "";
  rep(i,26){
    rep(j,a[i]){
      ans += 'a'+i;
    }
  }

  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int char2int(char c) {
  return int(c-'0');
}
int main() {
    ll n, p;
    string s;
    cin >> n >> p >> s;
    map<ll,ll> U;
    ll rem = 0;
    ll pow = 1;
    ll ans = 0;
    U[rem]++;
    if(p==2||p==5){
        rrep(i,n) 
            if (char2int(s[i])%p == 0) ans += i+1;
    } else {
        rrep(i,n){
            rem = (rem + char2int(s[i])*pow%p)%p;
            ans += U[rem];
            U[rem]++;
            pow = pow*10%p;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> cs(N);  // [0, i] の和
    REP(i, N) {
        cin >> A[i];
        if(i == 0) {
            cs[i] = A[i];
        }
        else {
            cs[i] = cs[i-1] + A[i];
        }
    }

    int ans = 0;
    map<int, int> cnt;  // 自分より右の値が key の個数
    for(int i = N - 1; i >= 0; --i) {
        int val = cs[i] - A[i];
        if(cnt.count(val) > 0) {
            ans += cnt[val];
        }
        if(A[i] == 0) { ans++; }
        cnt[cs[i]]++;
    }
    printf("%lld\n", ans);

    return 0;
}



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

int main(){
 int n, k, x, result=0;
 cin >> n >> k;
 
 for(int i=0;i<n;i++){
 	cin >> x;
   	if(x<k-x) result+=x*2;
    else result+=(k-x)*2;
 }
 
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

ll dp[100100] = {0};

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

  int N;
  cin >> N;
  vector<int> h(N);

  REP(i, N){
    cin >> h[i];
  }

  REP(i, N){
    dp[i] = 1<<30;
  }
  dp[0] = 0;

  REP(i, N){
    
    chmin(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
    chmin(dp[i+1], dp[i] + abs(h[i+1]-h[i]));
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1408
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long n = sc.nextLong();
    n = Math.min(b-1,n);
    long ans = a * n / b;
    System.out.println(ans);
  }
}


Measured memory_bytes: 35784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long a = sc.NextLong();
        long b = sc.NextLong();

        long[] x = sc.LongArray();

        long answer = 0;

        for (int i = 1; i < n; i++)
        {
            answer += Math.Min(a * (x[i] - x[i - 1]), b);
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

int n, m;
pair<int,int> sv[300001];
bool comp_r(pair<int,int> p1, pair<int,int> p2){
	return p1.second < p2.second;
}

void input(){
	scanf("%d %d", &n, &m);
	for(int i=1; i<=n; i++)
		scanf("%d %d", &sv[i].first, &sv[i].second);
}

struct MergeTree{
	vector<int> data[1<<18];
	const int base=1<<17;

	void update(int p, int v){
		for(p+=base-1; p; p/=2)
			data[p].push_back(v);
	}
	int query(int s, int e, int x){
		int ans=0;
		for(s+=base-1, e+=base-1; s<=e; s/=2, e/=2){
			if(s&1){
				ans += data[s].size() - (lower_bound(data[s].begin(), data[s].end(), x)-data[s].begin());
				s++;
			}
			if(!(e&1)){
				ans += data[e].size() - (lower_bound(data[e].begin(), data[e].end(), x)-data[e].begin());
				e--;
			}
		}
		return ans;
	}
} mt;

int query(int d){
	int ans=0;
	for(int now=d, bef=0; now<=m; now+=d, bef+=d){
		ans += mt.query(bef+1, now, now);
	}
	return ans;
}

int main(){
	input();

	sort(sv+1, sv+1+n, comp_r);
	for(int i=1; i<=n; i++)
		mt.update(sv[i].first, sv[i].second);

	for(int i=1; i<=m; i++)
		printf("%d\n", query(i));
	return 0;
}


Measured memory_bytes: 37364
#include <algorithm>
#include <cstdio>
#include <utility>
using namespace std;

int main ()
{
  int x, y;
  int count = 0;
  pair<int, int> data[3000];
  while (1) {
    scanf("%d", &x);
    scanf("%d", &y);
    if (x == 0 && y == 0) {
      break;
    }
    data[count].first = min(x, y);
    data[count].second = max(x, y);
    count++;
  }

  for (int i = 0; i < count; i++) {
    printf("%d %d\n", data[i].first, data[i].second);
  }

  return 0;
}

Measured memory_bytes: 2636
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  string result = "Yes";
  if (S.size() + 1 != T.size()) {
    result = "No";
  } else {
    for(int i = 0; i < S.size(); i++) {
  	  if (S[i] != T[i]) {
    	result = "No";
        break;
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+5;
typedef long long ll;
struct node{
    int u,v,nxt;
}edge[N*2];
int head[N],mcnt;
void add_edge(int u,int v){
    mcnt++;
    edge[mcnt].u=u;
    edge[mcnt].v=v;
    edge[mcnt].nxt=head[u];
    head[u]=mcnt;
}
int n;
int ans=0;
int bit[N];
int lb[N];
void dfs(int u,int fa){
    bit[u]=lb[u]=0;
    int z=0;
    bool leaf=true;
    for(int i=head[u];i;i=edge[i].nxt){
        int v=edge[i].v;
        if(v==fa)
            continue;
        leaf=false;
        dfs(v,u);
        z|=(bit[u]&bit[v]);
        bit[u]|=bit[v];
    }
    if(leaf){
        lb[u]=0;
        bit[u]=1;
    }
    else{
        while((1<<lb[u])<z||(1<<lb[u])&bit[u])
            lb[u]++;
        bit[u]>>=lb[u];
        bit[u]<<=lb[u];
        bit[u]|=1<<lb[u];
    }
    ans=max(ans,lb[u]);
}
int main()
{
    //freopen("uninity.in","r",stdin);
    //freopen("uninity.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    dfs(1,0);
    printf("%d\n",ans);
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	string s;cin>>s;
	//sort(s.begin(),s.end());
	bool a=(s[0]==s[1]&&s[1]==s[2]);
	bool b=(s[1]==s[2]&&s[2]==s[3]);
	if(a||b)cout<<"Yes"<<endl;
	else cout << "No" <<endl;
	return 0;
}

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

int main() {
	int a,b;
	
	cin>>a>>b;
	int j=a,i;
	int sum=a;
	if(b==1)
	{
	    cout<<"0";
	    exit(0);
	}

    if(a>=b)
	{cout<<"1";
	exit(0);
	}
	if(a==1)
	{
	    cout<<"0";
	    exit(0);
	}

	for(i=0;sum<b;i++)
	{
	    sum=a*i + j--;
	}
	
	cout<<i;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String[] SList = sc.next().split("");
        String[] TList = sc.next().split("");
        String r = "";
        for (int i = 0; i < N; i++) {
            r += SList[i];
            r += TList[i];
        }
        System.out.println(r);
    }
}

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

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int sq[n];
	for(int i=0; i<n; i++) cin >> sq[i];
	int suffix[n];
	memset(suffix, 0, sizeof(suffix));
	suffix[n-1] = 0;
	for(int i=n-2; i>=0; i--)
		suffix[i] = (sq[i] >= sq[i+1])? suffix[i+1]+1 : 0;
	int ans = -1;
	for(int i=0; i<n; i++)
		ans = max(ans, suffix[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
while true
  n, p_ = gets.chomp.split(" ").map(&:to_i)
  break if n == 0 && p_ == 0
  cand = Array.new(n, 0)
  stone = p_
  (0...n).cycle do |i|
    if stone > 0 then
      stone -= 1
      cand[i] += 1
      if cand[i] == p_ then
        puts i
        break
      end
    else
      if cand[i] > 0 then
        stone += cand[i]
        cand[i] = 0
      end
    end
  end
end

Measured memory_bytes: 8740
from datetime import date
import sys
for i in sys.stdin:
    y,m,d=list(map(int,i[:-1].split()))
    dt=lambda y,m,d:date(year=y,month=m,day=d)
    nd=dt(y,m,d)

    if nd < dt(1868,9,8):
        print("pre-meiji")
    elif dt(1868,9,8) <= nd <= dt(1912,7,29):
        print("meiji",y-1867,m,d)
    elif dt(1912,7,30) <= nd <= dt(1926,12,24):
        print("taisho",y-1911,m,d)
    elif dt(1926,12,25) <= nd <= dt(1989,1,7):
        print("showa",y-1925,m,d)
    else:
        print("heisei",y-1988,m,d)


Measured memory_bytes: 6040
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            N = N * N * N;

            Console.WriteLine(N);
        }
    }
}




Measured memory_bytes: 11092
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if((i+j)%2 == 0) printf("#");
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2616
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let a = line[0];
    let b = line[1];
    let ls: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut cur = 0;
    let mut ans = 1;
    for l in ls.iter() {
        cur += *l;
        if cur <= b {
            ans = ans + 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner =new Scanner(System.in);
		int N = scanner.nextInt(); //int Nに必要なものいれてね,
		
		//商品はどこであれ、1000円で割り切れるか確認したい。
		//1900円の場合、1000円で割り切れるか確認する
		//
		
		if (N % 1000 ==0) { //あまりが出る
			System.out.println(0);
		}else {
			System.out.println(1000-(N%1000));
		}
		
	}

}


Measured memory_bytes: 35808
#include<stdio.h>
int main(void)
{
  int a,b;
  scanf("%d %d",&a,&b);
  for(int i=a;i<=1010;i++){
    if((i*8)/100==a&&(i*10)/100==b){
      printf("%d\n",i);
      return 0;
    }
  }

  puts("-1");
  return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
nodes = [input().split() for _ in range(m)]

node_num = {str(i): 0 for i in range(1, n + 1)}
for node in nodes:
    node_num[node[0]] += 1
    node_num[node[1]] += 1

for i in range(1, n + 1):
    print(node_num[str(i)])


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

using namespace std;

int main(){
    int N, A, B, i;
    cin >> N >> A >> B;
    vector< int > P(N);
    vector< int > E(3);

    for (i=0; i<N; i++){
        cin >> P[i];
    }
    
    for (i=0; i<N; i++){
        if (P[i] <= A) E[0]++;
        else if (P[i] <= B) E[1]++;
        else E[2]++;
    }
    
    int min = *min_element(E.begin(), E.end());

    cout << min << '\n';
}

   

Measured memory_bytes: 256