akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int N; cin >> N;
	int L; cin >> L;
	vector<int>data(N);
	for (int i = 0; i < N; i++){
		data[i] = L + i;
	}

	if (L >= 0){
		data[0] = 0;
		int sum = 0;
		for (int i = 0; i < N; i++){
			sum += data[i];
		}
		cout << sum << endl;
	}

	else if (L < 0 && L*-1 <= N-1){
		int sum = 0;
		for (int i = 0; i < N; i++){
			sum += data[i];
		}
		cout << sum << endl;
	}

	else if (L<0 && L*-1>N - 1){
		data[N - 1] = 0;
		int sum = 0;
		for (int i = 0; i < N; i++){
			sum += data[i];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char s[11];
    int i,j,len;
    long g=0;
    scanf("%s",s);
    len=strlen(s);
    for(i=0;i<(1<<(len-1));i++){
        char siki[20]={'\0'};
        siki[0]=s[0];
        for(j=0;j<len-1;j++){
            if(i&(1<<j))
                sprintf(siki,"%s%c%c",siki,'+',s[j+1]);
            else
                sprintf(siki,"%s%c",siki,s[j+1]);
        }
        long tmp=0;
        for(j=0;siki[j]!='\0';j++){
            if(siki[j]!='+')
                tmp = tmp*10+(siki[j]-'0');
            else{
                g+=tmp;
                tmp=0;
            }
        }
        g+=tmp;
    }
    printf("%ld\n",g);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#define R register
#define MN 20005
inline int read(){
	R int x; R bool f; R char c;
	for (f=0; (c=getchar())<'0'||c>'9'; f=c=='-');
	for (x=c^'0'; (c=getchar())>='0'&&c<='9'; x=(x<<1)+(x<<3)+(c^'0'));
	return f?-x:x;
}
int n,ans[MN];
int main(){
	n=read();
	for (R int i=1,x; i<=n; ++i) ans[x=read()]=i;
	for (R int i=1; i<=n; ++i) printf("%d ",i*30000);puts("");
	for (R int i=1; i<=n; ++i) printf("%d ",ans[i]+(n-i)*30000);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
int n;
char c[2001];
vector<int>adj[2001];
int v[2001];
int mi[2001],ma[2001];
int cc[2001];
void dfs(int id,int p){
	cc[id]=c[id]-48;
	mi[id]=ma[id]=0;
	for(auto cur:adj[id]){
		if(cur==p) continue;
		dfs(cur,id);
		mi[cur]+=cc[cur];ma[cur]+=cc[cur];
		cc[id]+=cc[cur];ma[id]+=ma[cur];
	}
	if(adj[id].size()==1 && p!=0) return;
	int bc=0;
	for(auto cur:adj[id]){
		if(cur==p) continue;
		if(mi[cur]>=mi[bc]) bc=cur;
	}
	for(auto cur:adj[id]){
		if(cur==p) continue;
		if(cur!=bc) mi[id]-=ma[cur];
		else mi[id]+=mi[bc];
	}
	if(mi[id]<0){
		mi[id]%=2;
		if(mi[id]==-1) mi[id]=1;
	}
}
int solve(int id){
	dfs(id,0);
	if(mi[id]==0) return ma[id]/2;
	else return 1e9;
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n;for(int i=1; i<=n ;i++) cin >> c[i];
	for(int i=1; i<n ;i++){
		int u,v;cin >> u >> v;
		adj[u].pb(v);adj[v].pb(u);
	}
	int ans=0,best=1e9;
	for(int i=1; i<=n ;i++){
		best=min(best,solve(i));
	}
	//cout << solve(1) << endl;
	if(best==1e9) cout << "-1\n";
	else cout << best << endl;
}

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


int main(){
  bool OK=true;
  int N;cin>>N;
  string s;cin>>s;
  if(N%2==0){
    for(int i=0;i<N/2;i++){
      if(s.at(i)!=s.at(i+N/2))
         OK=false;
    }
  }else{
    OK=false;
  }
  if(OK)
    cout<<"Yes";
  else
    cout<<"No";
}
         

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
#define ll long long int
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
ll A[200000+1];

int main()
{
    fastio();
    ll n,d,a,i,b,c,j,ne=0,de=0,ans=0,l,r,mid;
    cin >> n >> d >> a;
  // cout << n << d << a;
    pair<ll,ll>v[200000+1];
    
        for (i=1; i<=n; i++) 
            {   cin >> v[i].first >> v[i].second;
            }
        sort(v+1,v+1+n);
        //cout << v[3].first;
        //cout << v[0].second;
        // de=0;
        for(i=1;i<=n;i++)
        {
            v[i].second-=de;
            //cout << v[i].second;
            if(v[i].second>0)
            {
                ne=(v[i].second+a-1)/a;
                de+=ne*a;
                //cout << ne ;
                ans+=ne;
                l=i,r=n+1;
                //cout << l << r;
                while(l<r-1)
                {
                   mid=(l+r)/2;
                   //cout << mid;
                   if(v[mid].first<=2*d+v[i].first)
                        l=mid;
                   else
                        r=mid;
                }
               // cout << l;
                A[l]+=ne*a;
            }
            de=de-A[i];
            //cout << A[2]<<endl;;
            //cout << v[1].second<<endl;
        }
        cout << ans;
}

        
         
            
          

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}

vector<vector<int> >adj;
string a;
int vis[200005][4];
vector<pair<int,int> >temp;
char arr[4]={'A','A','B','B'};
bool flag=false;
void dfs(int ver,int x)
{
    if(flag)
        return ;
    vis[ver][x]=1;
    temp.push_back({ver,x});
    for(auto i:adj[ver])
    {
        if(vis[i][(x+1)%4]==0)
        {
            if(a[i]==arr[(x+1)%4])
            {
                dfs(i,(x+1)%4);
            }
        }
        else if(vis[i][(x+1)%4]==1)
        {
            if(a[i]==arr[(x+1)%4])
            {
                flag=true;
                return ;
            }
        }
    }
    vis[ver][x]=2;
    if(flag)
        return ;
}

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  


    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    cin>>a;
    int x,y;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        x--;
        y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }    
    for(int i=0;i<n;i++)
    {
        if(vis[i][0]==0 && a[i]=='A')
        {
            temp.clear();
            dfs(i,0);
            for(auto j:temp)
                vis[j.first][j.second]=2;
        }   
    }
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";


} 
    


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

int a[33], b[33];
int n,c;
int dp[33][66666];
int pcnt[66666];


int solve(){
    rep(i,33)rep(rem, 1<<16) dp[i][rem] = -1e8;
    dp[0][0] = 0;
    rep(i,n){
        rep(rem,1<<16){
            int on = rem | a[i];
            rep(j,c){
                int score = pcnt[on & b[j]];
                int nx = on & ~b[j];
                dp[i+1][nx] = max(dp[i+1][nx], dp[i][rem] + score);
            }
        }
    }
    int ans = 0;
    rep(i, 1<<16) ans = max(ans, dp[n][i]);
    return ans;
}

int main(){
    pcnt[0] = 0;
    for(int i = 1; i < 66666; i++){
        pcnt[i] = pcnt[i/2] + i%2;
    }
    while(cin >> n >> c && n){
        rep(i,n){
            a[i] = 0;
            rep(j,16){
                int x; cin >> x;
                a[i] |= (x&1)<<j;
            }
        }
        rep(i,c){
            b[i] = 0;
            rep(j,16){
                int x; cin >> x;
                b[i] |= (x&1)<<j;
            }
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 10008
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
typedef unsigned long long ll;
using namespace std;
ll len[55],p[55];//分别存放Burger的长度和肉饼的个数  
ll slove(ll n,ll x)
{
	if(n==0) return x;
	else if(x==0||x==1) return 0;
	else if(x==len[n]) return p[n];
	else if(x<=len[n-1]+1) return slove(n-1,x-1);
	else if(x<=len[n]-1) return 1+p[n-1]+slove(n-1,x-2-len[n-1]);
}
int main()
{
	len[1]=5;
	p[1]=3;
	for(int i=2;i<=51;i++) 
	{
		len[i]=2*len[i-1]+3;
		p[i]=2*p[i-1]+1;
	}
	ll n,x;
	cin>>n>>x;
	cout<<slove(n,x)<<endl;
	return 0;
}
/*
BPPPB  1级   5  3

B[BPPPB]P[BPPPB]B 2级  2*5+3   13  7

B[BBPPPBPBPPPBB]P[BBPPPBPBPPPBB]B 3级    2*(2*5+3)+3   29  15

BBBBPPPBPBPPPBBPBBPPPBPBPPPBBBPBBBPPPBPBPPPBBPBBPPPBPBPPPBBBB 4级  2*29+3   31
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
int dist[200][200];
main(){
    int N,M,R,rr,A,B,C;
    vector<int> r;
    cin >> N >> M >> R;
    for(int i = 0;i < R;i++){cin >> rr;r.push_back(rr-1);}
    fill(dist[0],dist[200],INF);
    for(int i = 0;i < N;i++)dist[i][i] = 0;
    for(int i = 0;i < M;i++){
        cin >> A >> B >> C;
        dist[A-1][B-1] = min(dist[A-1][B-1],C);
        dist[B-1][A-1] = min(dist[B-1][A-1],C);
    }
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            for(int k = 0;k < N;k++){
                dist[j][k] = min(dist[j][k],dist[j][i]+dist[i][k]);
            }
        }
    }/*
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            printf("%d%c",dist[i][j],j==N-1?'\n':' ');
        }
    }
    */
    sort(r.begin(),r.end());
    ll minc = INF;
    do{
        ll cost = 0;
        for(int i = 0;i < R-1;i++){
            cost += dist[r[i]][r[i+1]];
        }
        minc = min(minc,cost);
    }while(next_permutation(r.begin(),r.end()));
    cout << minc << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int main() {
    int n; cin >> n;
    vector<double> p(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0));
    dp[0][0] = 1.0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i + 1][j + 1] += dp[i][j] * p[i + 1]; //表が出る
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i + 1]); //裏が出る
        }
    }

    double ans = 0.0;
    for (int j = n / 2 + 1; j <= n; j++) {
        ans += dp[n][j];
    }
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

using Graph = vector<vector<ll>>;
Graph G;
ll d[110], f[110];

void DFS(ll v, ll &t)
{
	if (d[v] != -1) return;
	d[v] = t;

	++t;
	for (auto &nv : G[v])
	{
		DFS(nv, t);
	}
	f[v] = t;
	++t;
}

int main(int argc, char **argv)
{
	ll N; cin >> N;
	G.resize(N);
	for (ll i = 0; i < N; ++i)
	{
		ll n, k; cin >> n >> k;
		--n;
		for (ll j = 0; j < k; ++j)
		{
			ll v; cin >> v;
			--v;
			G[n].push_back(v);
		}
		sort(G[n].begin(), G[n].end());
	}
	fill(d, d+110, -1);
	fill(f, f+110, -1);

	ll t = 1;
	for (ll v = 0; v < N; ++v)
	{
		if (d[v] == -1)
			DFS(v, t);
	}

	for (ll i = 0; i < N; ++i)
	{
		std::cout << i + 1 << " " << d[i] << " " << f[i] << std::endl;
	}
}



Measured memory_bytes: 3164
package main

import "fmt"

func main() {
	var n, max_height, ans int
	fmt.Scan(&n)
	hs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&hs[i])
		if i == 0 {
			max_height = hs[i]
		}
		if hs[i] >= max_height {
			max_height = hs[i]
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  int n;
  cin>>n;
  int a[n+2];
  rep(i,1,n+1) cin>>a[i];
  a[0]=0;
  a[n+1]=0;
  // int mn=*min_element(a,a+n),mx=*max_element(a,a+n);
  int v1[n+1],pref[n+1];
  rep(i,0,n+1) v1[i]=abs(a[i+1]-a[i]);//a[i+1]*a[i]>=0?abs(a[i+1]-a[i]):abs(a[i+1]-a[i])*2;
  pref[0]=v1[0];
  rep(i,1,n+1) pref[i]=pref[i-1]+v1[i];
  rep(i,1,n+1){
    ll ans=abs(a[i+1]-a[i-1])-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+pref[n];
    cout<<ans<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 4820
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		boolean[] arg = null;
		int length=0,out=0;
        int i=0,rou=0,store=1;
        boolean first=true;
        List<Integer> score=new ArrayList<Integer>();
        int[] dice=new int[3];
        boolean[] rui=new boolean[3];

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null ) {
            	if(line.equals("0")){
                	break;
                }
            	if(first){
            		length=Integer.parseInt(line);
            		for(int k=0;k<3;k++){
            			dice[k]=k+1;
            		}
            		first=false;
            	}else{
            		if(line.equals("North")){
            			int w=dice[0];
            			dice[0]=dice[1];
            			dice[1]=7-w;
            		}else if(line.equals("East")){
            			int w=dice[2];
            			dice[2]=dice[0];
            			dice[0]=7-w;
            		}else if(line.equals("West")){
            			int w=dice[0];
            			dice[0]=dice[2];
            			dice[2]=7-w;
            		}else if(line.equals("South")){
            			int w=dice[1];
            			dice[1]=dice[0];
            			dice[0]=7-w;
            		}else if(line.equals("Left")){
            			int w=dice[2];
            			dice[2]=dice[1];
            			dice[1]=7-w;
            		}else if(line.equals("Right")){
            			int w=dice[1];
            			dice[1]=dice[2];
            			dice[2]=7-w;
            		}
            		store+=dice[0];
            		i++;
            	}
            	if(length==i){
            		i=0;
            		rou++;
            		score.add(store);
            		store=1;
            		first=true;
            	}

            }
            for(int k=0;k<score.size();k++){
            	System.out.println(score.get(k));
            }
		}
	}

}

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

int main(){
	int n,k,ans=0;
	cin>>n>>k;
	while(n!=0){
		n/=k;
		ans++;
	}
	cout<<ans<<endl;
}


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

 int main()
 {
 	int n, t, a[100010];
 	cin >> n >> t;
 	for (int i = 0; i < n; i++) cin >> a[i];
     
     int p[100010] = {}, mi = 1 << 30;
     for (int i = 0; i < n; i++) {
     	mi = min(mi, a[i]);
     	p[i] = a[i] - mi;
     }
     
     sort(p, p + n);
     reverse(p, p + n);
     int cnt = 0;
     for (int i = 0; i < n && p[i] == p[0]; i++, cnt++);
     cout << cnt << endl;
     
     return 0;
  }

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
  int N,Q,a,b,count=0;
  string S;
  cin>>N>>S;
  int k=0;
  for (int i=0; i<N; i++){
  if(S.at(i)=='I'){
  count++;}
  else{
  count--;}
  k=max(k,count);}
  cout<<k<<endl;}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
using namespace std;
typedef long long ll;
int dp[30][30][30];
int yaku(int x) {
	int cnt = 0;
	for (int i = 3; i <= x/2; i++) {
		if (x % i == 0)cnt++;
	}
	return cnt + 2;
}
int main() {
	int n,cnt=0;
	cin >> n;
	for (int i = 1; i <= n; i += 2) {
		if (yaku(i) == 8) {
			cnt++;
		}
	}
	cout << cnt << endl;
	system("PAUSE");
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define md 1000000007
#define mem(arr, x) memset(arr, x, sizeof(arr))
#define fio()                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define pb push_back
#define vi vector<lli>
#define vvi vi<vi>
typedef long long int lli;
typedef float fl;
int main()
{
    fio();
    lli t;
    //cin >> t;
    //while (t--)
    {
        lli n;
        cin >> n;
        n-- ; 
        lli root = sqrt(n);
        lli ans = 0;

        for (int i = 1; i * i <= n ; i++)
            ans += ( n / i ) ;

        cout << 2 * ans - (root * root);
    }
}

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

using namespace std;

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

int solve(int A, int B, int K) {
  vector<int> D;
  for (int i {1}; i <= min(A, B); ++i) {
    if (A % i == 0 && B % i == 0) {
      D.emplace_back(i);
    }
  }
  return D[D.size() - K];
}

int main(int argc, char* argv[]) {
  int A, B, K;
  cin >> A >> B >> K;
  cout << solve(A, B, K) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i = 1;
	int j = 1;
	
	for(i = 1; i < 10; i++){
		for(j = 1; j < 10; j++){
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	
	return 0;
	
}

Measured memory_bytes: 0
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a < b && b < c) {
			System.out.printf("Yes\n");
		}else {
			System.out.printf("No\n");
		}

	}

}


Measured memory_bytes: 26112
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#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)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  P d[n];
  rep(i,n)cin >> d[i].first >> d[i].second;
  rep(i,n-2){
    if(d[i].first==d[i].second){
      if(d[i+1].first==d[i+1].second){
        if(d[i+2].first==d[i+2].second){
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

/*てんぷれぞーん！*/
//static const int INF = 2147483647;
static const int INF = 1000000000;
static const long long llINF = 9223372000000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
typedef long long ll;
typedef pair<int,int> P;
struct edge {int to,cost;};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
/* t y p o っ て 知 っ て る ゥ ！ ？ */
#define itn int
#define scnaf scanf
#define reutnr return
/*必要に応じて使ってね*/
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll
//#define INF llINF

void debug(){
    //puts("unko\n");
}

signed main(){
	int n,m;
    scanf("%d%d",&n,&m);
	if (n == 2) {
		puts(m ? "1" : "0");
		return 0;
	}
    bool Tokyo[n][n];
    vector<int> K;
    for(int i=0;i<n;i++){   //初期化ループ
        if(i!=0) K.pb(i);
        for(int j=0;j<n;j++){
            Tokyo[i][j] = false;
        }
    }

    debug();

    for(int i=0;i<m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        a--,b--;
        Tokyo[a][b] = Tokyo[b][a] = true;
    }

    debug();

    int ans = 0;

    if(Tokyo[0][K[0]]){
        for(int i=0;i<n-2;i++){
            if(!Tokyo[K[i]][K[i+1]]) break;
            else if(i == n-3) ans++;
        }
    }

    while(np(all(K))){
        if(Tokyo[0][K[0]]){
            for(int i=0;i<n-2;i++){
                if(!Tokyo[K[i]][K[i+1]]) break;
                else if(i == n-3) ans++;
            }
        }
    }
    debug();

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

Measured memory_bytes: 256
//
// B - Between a and b ...
//

#include <iostream>

using namespace std;
using LL = long long;

int main() {
    LL a, b, x, ans;
    cin >> a >> b >> x;
    ans = b / x - a / x;
    if (a % x == 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T; cin >> S >> T;

    char s[S.length()];
    char t[T.length()];

    rep(i, S.length()) s[i] = S[i];
    rep(i, T.length()) t[i] = T[i];

    sort(s, s + S.length());
    sort(t, t + T.length(), greater<int>());

    rep(i, S.length()) {
        if (s[i] > t[i]) {
            cout << "No" << endl;
            return 0;
        }
        if (s[i] < t[i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (S.length() >= T.length())
        cout << "No" << endl;
    else cout << "Yes" << endl;



    return 0;
}


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 205;
const int   mod = 1e9 + 7;

typedef pair<ll,ll> pll;

ll  a[N];

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int k;  cin >> k;
    int n;  cin >> n;

    if (k % 2 == 0) {
        cout << k / 2 << " ";
        for(int i = 1 ; i < n ; ++i)
            cout << k << " ";
        
        return  0;
    }
    vector<int> ans(n,(k + 1) / 2);

    for(int i = 0 ; i < n / 2 ; ++i)    {
        if (ans.back() == 1)
            ans.pop_back();
        else    {
            ans.back()--;
            while (ans.size() != n)
                ans.push_back(k);
        }
    }
    for(int x : ans)
        cout << x << " ";
}

Measured memory_bytes: 4360
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;

const int INF = 100000000;
typedef pair<int ,int> P;

char maze[55][55];
int n,m;
int sx,sy;
int gx,gy;

int d[55][55];

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

int bfs()
{
    queue<P> que;
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<m;j++)
        {
            d[i][j] = INF;
        }
    }
    que.push(P(sx,sy));
    d[sx][sy] = 0;

    while(que.size())
    {
        P p = que.front();
        que.pop();
        if(p.first == gx && p.second == gy)
            break;
        for(int i = 0;i<4;i++)
        {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(nx>=0 && nx<=n && ny>=0 && ny<=m && maze[nx][ny] != '#' &&d [nx][ny] == INF)
            {
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[gx][gy];
}
int main()
{
    cin>>n>>m;
    int sum1 = 0;
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<m;j++)
        {
            cin>>maze[i][j];
            if(maze[i][j]=='.')sum1++;
        }
    }
    sx=0;
    sy=0;
    gx=n-1;
    gy=m-1;
    int resourt = bfs();
    if(resourt==INF)cout<<"-1"<<endl;
    else cout<<sum1-resourt-1<<endl;
    return 0;
}


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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int ra = a % 10;
  int rb = b % 10;
  int rc = c % 10;
  int rd = d % 10;
  int re = e % 10;
  vector<int> r(5);
  r.at(0) = ra;
  r.at(1) = rb;
  r.at(2) = rc;
  r.at(3) = rd;
  r.at(4) = re;
  sort(r.begin(), r.end());
  int rm = 0;
  int cntz = 0;
  for (int i : r) {
    if (i == 0) {
      cntz++;
    }
    else {
      rm = i;
      break;
    }
  }
  int res = a + b + c + d + e;
  res = res + 10 * (5 - cntz) - ra - rb - rc - rd - re;
  if (rm != 0) {  
    res = res - 10 + rm;
  }
  cout << res << endl;
}




Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}

	ans := 0
	for i := range a {
		if i+1 == a[a[i]-1] {
			ans++
		}
	}
	fmt.Println(ans / 2)
}


Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

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

int  main()
{
	long long n,m;
	cin >> n >> m;
	string s,t;
	cin >> s >> t;

	long long g=gcd(n,m);
	long long len=n*m/g;
	long long a=len/m;
	long long b=len/n;
	bool flag=true;

	for(long long i=0;i<g;i++)
	{
		if(s[i*a]!=t[i*b])flag=false;

//cout << s[i*a] << " " << t[i*b] << endl;

	}

	cout << (flag ? len:-1) << endl;
}


Measured memory_bytes: 512
def main():
    N, M, K = map(int, input().split())
    ns = list(map(int, input().split()))
    ms = list(map(int, input().split()))
    ns_accum, ms_accum = [0], [0]
    n_accum_tmp, m_accum_tmp, num_books = 0, 0, 0
    for i in range(len(ns)):
        n_accum_tmp += ns[i]
        ns_accum.append(n_accum_tmp)

    for i in range(len(ms)):
        m_accum_tmp += ms[i]
        ms_accum.append(m_accum_tmp)

    for i in range(len(ns_accum)):
        time_left = K - ns_accum[i]
        if time_left >= 0:
            num_book_m = max(0, binary_search(ms_accum, time_left))
            num_books = max(num_books, i+num_book_m)

    print(num_books)


def binary_search(A, x):
    ok = -1
    ng = len(A)
    while (abs(ok - ng) > 1):
        mid = (ng+ok) // 2
        if A[mid] <= x:
            ok = mid
        else:
            ng = mid

    return ok


if __name__ == '__main__':
    main()


Measured memory_bytes: 132712
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// Binary Index Treeは長さnの数列に対して
// 1. 区間[a,b)に値xを加算する
// 2. 区間[a,b)の総和を求める
// という操作をO(log(n))で処理できる

// 区間加算にも対応したBinary Index Tree(1-indexで使うことに気をつける)
template <class Abel> struct BIT {
    
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;
    
    BIT(ll n) { 
        init(n);
    }

    void init(ll n) { 
        for(ll iter = 0; iter < 2; ++iter) {
            dat[iter].assign(n + 1, UNITY_SUM); 
        }
    }
    
    inline void sub_add(ll p, ll a, Abel x) {
        for(ll i = a; i < (ll)dat[p].size(); i += i & -i) {
            dat[p][i] = dat[p][i] + x;
        }
    }
    // 区間[a,b)にxを加算する(a,bは1-index)
    inline void add(ll a, ll b, Abel x) {
        sub_add(0, a, x * -(a - 1)); 
        sub_add(1, a, x);
        sub_add(0, b, x * (b - 1));
        sub_add(1, b, x * (-1));
    }
    
    inline Abel sub_sum(ll p, ll a) {
        Abel res = UNITY_SUM;
        for(ll i = a; i > 0; i -= i & -i) {
            res = res + dat[p][i];
        } 
        return res;
    }
    // 区間[a,b)の総和を計算する(a, bは1-index)
    inline Abel getsum(ll a, ll b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
};

int main() {
    ll n, d, a;
    cin >> n >> d >> a;

    vector<P> p(n);
    rep(i, n) {
        ll x, h;
        cin >> x >> h;
        p[i] = make_pair(x, h);
    }
    sort(all(p));

    vl x(n), h(n);
    rep(i, n) {
        x[i] = p[i].first;
        h[i] = p[i].second;
    }
    
    BIT<ll> bit(n+10);
    rep(i, n) {
        bit.add(i+1, i+2, h[i]);  // bit[i]をh[i]で初期化
    }
    
    ll ans = 0;
    exrep(i, 1, n) {  // BITは1-indexで使う
        ll hp_i = bit.getsum(i, i+1);  // モンスタiの体力
        if(hp_i <= 0) {  // モンスタiの体力が0以下の場合
            continue;  // モンスタiはおしまい
        }
        ll cnt = (hp_i + a - 1)/a;  // モンスタiを倒すのに必要な操作回数
        //　モンスタiのいる座標を左端とした爆発が届く範囲を求める
        ll right = x[i-1] + 2*d;  // 爆発が届く右端の座標
        ll id = upper_bound(all(x), right) - x.begin();  // 爆発が届かないモンスタの中で最も左にいるモンスタの番号 
        id++;
        bit.add(i, id, -a*cnt);  // モンスタiからモンスタid-1の体力をa*need減らす
        ans += cnt;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 9600
import sys
n = int(input())
s = list(map(int, input().split()))
c = 0
a = 'a'
def merge(A, left, mid, right):
    global c
    L = A[left:mid]
    R = A[mid:right]
    L.append(sys.maxsize)
    R.append(sys.maxsize)
    i = 0
    j = 0
    for k in range(left, right):
        c += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergesort(A, left, right):
    if left+1 < right:
        mid = (left+right)//2
        mergesort(A, left, mid)
        mergesort(A, mid, right)
        merge(A, left, mid, right)

mergesort(s, 0, n)

for i in range(n-1):
    print(s[i], end=' ')
print(s[n-1])
print(c)


Measured memory_bytes: 63700
#include <bits/stdc++.h>
#include <cstddef>
#include <type_traits>

// lib/pow2.hpp
#ifndef POW2_HPP
#define POW2_HPP

/*
usage:

tools::pow2(5) => 32
*/


namespace tools {
  template <typename T, typename std::enable_if<std::is_unsigned<T>::value, std::nullptr_t>::type = nullptr>
  constexpr T pow2(const T x) {
    return static_cast<T>(1) << x;
  }

  template <typename T, typename std::enable_if<std::is_signed<T>::value, std::nullptr_t>::type = nullptr>
  constexpr T pow2(const T x) {
    return static_cast<T>(static_cast<typename std::make_unsigned<T>::type>(1) << static_cast<typename std::make_unsigned<T>::type>(x));
  }
}

#endif

// main.cpp

std::uint32_t bitcount(std::uint32_t x) {
  x = (x & 0x55555555u) + (x >> 1 & 0x55555555u);
  x = (x & 0x33333333u) + (x >> 2 & 0x33333333u);
  x = (x & 0x0f0f0f0fu) + (x >> 4 & 0x0f0f0f0fu);
  x = (x & 0x00ff00ffu) + (x >> 8 & 0x00ff00ffu);
  return (x & 0x0000ffffu) + (x >> 16 & 0x0000ffffu);
}

int main() {
  std::int_fast64_t n;
  std::cin >> n;
  std::vector<std::uint32_t> f;
  f.reserve(n);
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::uint32_t f_i = 0;
    for (std::int_fast64_t j = 0; j < 10; ++j) {
      std::uint32_t f_ijk;
      std::cin >> f_ijk;
      f_i = (f_i << 1) + f_ijk;
    }
    f.push_back(f_i);
  }
  std::vector<std::array<std::int_fast64_t, 11>> p;
  p.reserve(n);
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::array<std::int_fast64_t, 11> p_i;
    std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), 11, p_i.begin());
    p.push_back(p_i);
  }

  std::int_fast64_t answer = std::numeric_limits<std::int_fast64_t>::min();
  for (std::uint32_t pattern = 1; pattern < tools::pow2<std::uint32_t>(10); ++pattern) {
    std::int_fast64_t sum = 0;
    for (std::int_fast64_t i = 0; i < n; ++i) {
      sum += p[i][bitcount(pattern & f[i])];
    }
    answer = std::max(answer, sum);
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)


class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        res = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                res = f(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = f(dat[r], res)
            l >>= 1
            r >>= 1
        return res


N, K = [int(_) for _ in input().split()]
P = [int(_) for _ in input().split()]

STmax = SegmentTree(array=P, f=max, ti=-float('inf'))
STmin = SegmentTree(array=P, f=min, ti=float('inf'))

size = N - K + 1
UF = list(range(size))
SIZE = [1] * size  # 0-indexed


def find(x):
    stack = [x]
    while True:
        y = stack[-1]
        if UF[y] != y:
            stack += [UF[y]]
        else:
            break
    for s in stack:
        UF[s] = y
    return y


def unite(x, y):
    if not is_same(x, y):
        X, Y = find(x), find(y)
        SX, SY = SIZE[X], SIZE[Y]
        if SX > SY:
            m = UF[X] = Y
        else:
            m = UF[Y] = X
        SIZE[m] = SX + SY
        SIZE[X + Y - m] = 0


def is_same(x, y):
    return find(x) == find(y)


def scan_uf():
    length = len(UF)
    for i in range(length):
        find(i)


for i in range(N - K):
    if P[i] == STmin.query(i, i + K) and P[i + K] == STmax.query(
            i + 1, i + K + 1):
        unite(i, i + 1)

inc = 0
incK = []
for i in range(N - 2, -1, -1):
    if P[i] <= P[i + 1]:
        inc += 1
        if inc >= K - 1:
            incK += [i]
    else:
        inc = 0
for i in incK:
    unite(incK[0], i)

scan_uf()
print(len(set(UF)))


Measured memory_bytes: 126620
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb       push_back
#define sz(x)    ((int)(x.size()))
#define all(x)   x.begin(),x.end()
#define clr(x)   memset(x,0,sizeof x)
const int inf = (1953125 << 9);
const int maxn = 2 * 1e5 + 5;



int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//	freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);

	int a,b;
	cin>>a>>b;
	if(a <= 8 && b <= 8)return cout<<"Yay!", 0;
	cout<<":(";
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

int main(){

    ll N;
    cin >> N;

    map<ll, ll > mp;
    for(ll i = 0; i < N; i++){
        ll t = 0; cin >> t;
        mp[t]++;
    }

    ll n = 0;
    if(N % 2 == 0){
        n = 1;
    }

    ll ans = 1;

    auto begin = mp.begin(), end = mp.end();
    for (auto iter = begin; iter != end; iter++) {
        ll k = iter->first;
        ll h = iter->second;
        //cout << k << " " << h << endl;
        if(N % 2 == 0){
            if(k == n && h == 2){
                ans *= 2;
                ans %= MOD;
            }else{
                cout << 0 << endl;
                return 0;
            }
        }else if(N % 2 == 1){
            if(k == n){
                if(n == 0 && h != 1 || n > 0 && h != 2){
                    cout << 0 << endl;
                    return 0;
                }else{
                    if(n != 0){
                        ans *= 2;
                        ans %= MOD;
                    }
                }
            }
        }       
        n += 2;
    }

    cout << ans << endl;


}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define pai 3.14159265
using namespace std;

int main(void){
    int N;cin>>N;
    string S;cin>>S;
    int ans=0;
    int tmp=0;
    for(int i=0;i<N;i++){
        if(S[i]=='I'){
            tmp++;
        }
        if(S[i]=='D'){
            tmp--;
        }
        ans=max(ans,tmp);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
for index in range(N):
    x[index],y[index],h[index] = map(int,input().split())
for i in range(101):
   for j in range(101):
      result = []
      for index in range(N):
         result_H = h[index]+ abs(x[index]- i)+abs(y[index]-j)
         if result_H-abs(x[index]- i)-abs(y[index]-j) > 0:
            result.append(result_H)
      tmp = result[0]
      if all(tmp==num for num in result) == True:
         check = []
         for check_index in range(N):
            check.append((tmp - abs(x[check_index]- i) - abs(y[check_index]-j))-h[check_index])
         if all(z <= 0 for z in check) == True:
            print(i,' ',j,' ',tmp)
            break
   else:
      continue
   break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  rep(i, N) {
    cin >> A[i] >> B[i];
  }
  reverse(all(A));
  reverse(all(B));
  ll sum = 0;
  ll ans = 0;
  rep(i, N) {
    A[i] += sum;
    ll push = A[i] % B[i];
    if (push != 0)
      push = B[i] - push;
    ans += push;
    sum += push;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

#define NOTHING (-1)

main :: IO ()
main = do
    [n, m] <- map read.words <$> getLine :: IO [Int]
    digits <- V.unfoldrN m (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve n digits

solve :: Int -> V.Vector Int -> Integer
solve n digits = memoFix (n + 1) `flip` n $ \memo ->
    \case
        0 -> 0
        i -> V.maximum . flip V.map digits $ \digit ->
            if  | cost U.! digit <= i -> case memo (i - cost U.! digit) of
                    NOTHING -> NOTHING
                    x -> 10 * x + fromIntegral digit
                | otherwise -> NOTHING

cost :: U.Vector Int
cost = U.fromList [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

memoFix :: Int -> ((Int -> a) -> (Int -> a)) -> Int -> a
memoFix size f = (memo V.!)
  where
    memo = V.generate size (f (memo V.!))


Measured memory_bytes: 16764
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static int N, M, i;
        static bool[, ] connect;
        static bool[] reached;
        static int count = 0, length = 0;
        static void Main (string[] args)
        {
            string[] str1 = Console.ReadLine ().Split (' ');
            N = int.Parse (str1[0]);
            M = int.Parse (str1[1]);

            reached = new bool[N];
            connect = new bool[N, N];

            //辺の読み込み
            for (i = 0; i < M; i++)
            {
                string[] str2 = Console.ReadLine ().Split (' ');
                connect[int.Parse (str2[0]) - 1, int.Parse (str2[1]) - 1] = true;
                connect[int.Parse (str2[1]) - 1, int.Parse (str2[0]) - 1] = true;
            }
            reached[0] = true;
            Search (0);

            Console.WriteLine (count);

        }

        static void Search (int n)
        {

            for (int k = 0; k < N; k++)
            {
                if (connect[n, k] == true && reached[k] == false)
                {
                    length++;
                    reached[k] = true;
                    Search (k);

                    reached[k] = false;
                }

            }

            if (length == N - 1)
            {
                count++;
            }
            length--;
        }

    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

/*---------------------------------------------------*/

int prime[150000];
bool is_prime[150000];
vector<ll> v;

void sieve(){
  int p=0;
  rep(i,150000)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  REP(i,2,150000){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=2*i;j<150000;j+=i)is_prime[j]=false;
    }
  }
  //rep(i,50)cout<<"DEBUG "<<prime[i]<<endl;
}

void solve(int n,int p){
  ll data[11000];
  int x=0;
  while(prime[x]<=n){
    //cout<<x<<" "<<prime[x]<<endl;
    x++;
  }
  int cnt=0;
  REP(i,x,x+p){
    REP(j,i,x+p){
      data[cnt]=(prime[i]+prime[j]);
      cnt++;
    }
  }
  sort(data,data+cnt);
  //rep(i,p)cout<<i+1<<" "<<v[i]<<endl;
  cout<<data[p-1]<<endl;
}

int main(){
  int n,p;
  sieve();
  while(cin>>n>>p){
    if(n==-1&&p==-1)break;
    solve(n,p);
  }
  return 0;
}

Measured memory_bytes: 3344
D,N = list(map(int,input().split()))

if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(N*100)
elif D == 2:
    if N == 100:
        print(1010000)
    else:
        print(N*10000)


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

int main() {
	int m, d, d_, _d, ans = 0;
  	cin >> m >> d;
    for(int i = m; i > 1; --i) {
        for(int j = 22; j <= d; ++j) {
            d_ = j/10; _d = j%10;
            if(i == _d*d_ && _d >= 2) {
                ans++;
            } 
        }
    }
  	cout << ans << '\n';
}


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

int main(){

    int n, cnt = 0;

    cin >> n;

    vector<int> v, c;

    for (int i = 0; i < n; i++)
    {
        v.push_back(0);
        cin >> v[i];
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = i; j < n; j++)
        {
            for (int k = j; k < n; k++)
            {
                if (v[i] + v[j] > v[k] && v[i] + v[k] > v[j] && v[j] + v[k] > v[i]){
                    if (v[i] != v[j] && v[i] != v[k] && v[j] != v[k]){
                        cnt++;
                    }
                }
            }
            
        }
        
    }

    cout << cnt << endl;
    
    return 0; 
}

Measured memory_bytes: 3636
#include<stdio.h>
#define N 1000
int main() {
  int a,b,i,x = 0;
  scanf("%d %d",&a,&b);
  for (i = 1;i <= N;i ++) {
    int abai = i * 0.08;
    int bbai = i * 0.1;
    if ((int)abai == a && (int)bbai == b) {
      x = i;
      //printf("%d\n",b);
      break;
      }
  }
  if (x == 0) {
    x = -1;
  }
  printf("%d",x);
}


Measured memory_bytes: 128