akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#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>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

void insertion_sort(vi &a) {
    int n = sz(a);
    rep(k, n) cout << a[k] << (k == n-1 ? '\n' : ' ');    
    for (int i = 1; i < n; ++i) {
        int v = a[i];
        int j = i-1;
        while (j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        rep(k, n) cout << a[k] << (k == n-1 ? '\n' : ' ');
    }
}

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

    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    insertion_sort(a);
}



Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define pb push_back
#define mp make_pair
#define INF 9999999999
#define LINF 9999999999999999
#define SINF "%"
#define uint unsigned int
#define msn(a,v) memset(a,v,sizeof(a))
#define ms(a) msn(a,0)
#define NONE -1
#define ll long long
#define ull unsigned ll
#define uchar unsigned char
#define sint short int
#define usint unsigned sint
#define xsize(a) sizeof(a)/1024/1024
#define fr(aaaaa,bbbbb) for(aaaaa = 1;aaaaa <= bbbbb;aaaaa++)
#define frr(aaaaa,bbbbb,ccccc) for(aaaaa = ccccc;aaaaa <= bbbbb;aaaaa++)
using namespace std;
#define MAXN 100100

ll n;
ll a[MAXN],b[MAXN];
ll ans = 0;


int main(){
	//freopen("A.txt","r",stdin);
	
	scanf("%lld",&n);
	for(int i = 1;i <= n;i++)
		scanf("%lld %lld",&a[i],&b[i]);
	
	
	for(int i = n;i >= 1;i--){
		a[i] += ans;
		if(a[i] % b[i] == 0) continue;
		else ans += (a[i] / b[i] + 1)*b[i] - a[i];
	}
	
	printf("%lld\n",ans);
	
	return 0;
}

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

int main(){
  int N,M;
  long long X;
  cin >> N >> M >> X;
  vector<vector<int> >CA(12,vector<int>(13,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<M+1;j++){
      cin >> CA.at(i).at(j);
    }
  }
  long long min=10000000;
  for(int i1=0;i1<2;i1++){
    for(int i2=0;i2<2;i2++){
      for(int i3=0;i3<2;i3++){
        for(int i4=0;i4<2;i4++){
          for(int i5=0;i5<2;i5++){
            for(int i6=0;i6<2;i6++){
              for(int i7=0;i7<2;i7++){
                for(int i8=0;i8<2;i8++){
                  for(int i9=0;i9<2;i9++){
                    for(int i10=0;i10<2;i10++){
                      for(int i11=0;i11<2;i11++){
                        for(int i12=0;i12<2;i12++){
                          vector<int>A;
                          A .push_back(i1);
                          A .push_back(i2);
                          A .push_back(i3);
                          A .push_back(i4);
                          A .push_back(i5);
                          A .push_back(i6);
                          A .push_back(i7);
                          A .push_back(i8);
                          A .push_back(i9);
                          A .push_back(i10);
                          A.push_back(i11);
                          A.push_back(i12);
                          vector<int>score(13);
                          for(int i=0;i<12;i++){
                            if(A.at(i)){
                              for(int j=0;j<13;j++){
                                score.at(j) += CA.at(i).at(j);
                              }
                            }
                          }
                          bool flag = true;
                          for(int i=1;i<=M;i++){
                            if(score.at(i)<X) flag = false;
                          }
                          if(flag && min>score.at(0)){
                            min = score.at(0);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  if(min==10000000) cout << "-1" << endl;
  else cout << min << endl;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(){
	int N, M;
	cin >> N >> M;
	
	int card[100000] = {0};

	for (int i = 0; i < M; i++){
		int L, R;
		cin >> L >> R;
		card[L - 1]++;
		card[R]--;
	}

	int sum = 0, ans = 0;
	for (int i = 0; i < N; i++){
		sum += card[i];
		if(sum == M){
			ans++;
		}
	}

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define PER(i,n,a) for(ll i=n;i>a;i--)
#define REP1(i,a,n) for(ll i=a;i<=n;i++)
#define forit(it,x) for(auto it=(x).begin();it!=(x).end();++it)
#define ull unsigned long long int
#define ld long double
#define prec(n) fixed<<setprecision(n)
#define test ll t; cin>>t; while(t--)
#define re return 0
#define pb push_back
#define PI 3.1415926535897932384626
#define MOD (ll)1000000007
#define fi first
#define se second
#define eb emplace_back
#define vll vector<ll>
#define vi  vector<int>
#define mpll map<ll,ll>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
const ll MAXI = (ll)1e9+7;
int main(){
    IOS;
//    test{
        int n1,n2;
        cin>>n1>>n2;
/*        int ar[n];
        REP(i,a,n){
           cin>>ar[i];
        }
        */
       if(n1==3 || n2==3){
           cout<<max(n1,n2)-min(n1,n2)<<"\n";
       }else{
           cout<<n1+n2<<"\n";
       }
       
//    }
re;
}


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


struct UnionFind {
    vector<int> par;

    explicit UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int find_root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = find_root(par[x]);
    }

    bool is_same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    bool unite(int x, int y) {
        int root_x = find_root(x);
        int root_y = find_root(y);
        if (root_x == root_y) return false;
        if (par[root_x] > par[root_y]) swap(root_x, root_y); // unite technique
        par[root_x] += par[root_y];
        par[root_y] = root_x;
        return true;
    }

    int size(int x) {
        return -par[find_root(x)];
    }
};

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

    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    for (int i = 0; i < M; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        uf.unite(--x, --y);
        // if (z % 2 == 0) {
        // }
    }

    int count = 0;
    set<int> s;
    for (int i = 0; i < N; ++i) {
        s.insert(uf.find_root(i));
        // count += uf.size(i) == 1;
    }

    cout << s.size() << '\n';
    // if (count > 1) {
    // } else {
    //     cout << count - 1 << '\n';
    // }
    // cout << count << '\n';


    return 0;
}


Measured memory_bytes: 5376
package main

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

func solve(sc *scanner, wr *bufio.Writer) {
	n, y := sc.getInt2()

	ans := "-1 -1 -1"
	for i := 0; i <= n; i++ {
		for j := 0; j+i <= n; j++ {
			k := n - (i + j)
			if k < 0 {
				continue
			}
			if sum := 10000*i + 5000*j + 1000*k; sum != y {
				continue
			}

			ans = fmt.Sprintf("%d %d %d", i, j, k)
		}
	}

	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
 int main() {
   int A, B, C;
   cin >> A >>B >>C;
   bool ans = false;
   if(A==B&&A!=C) ans=true;
   if(A==C&&A!=B) ans=true;
   if(B==C&&A!=B) ans=true;
   if(ans) cout << "Yes" << endl;
   else cout << "No" << endl;
 }

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vld vector < ld >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < long , long >
# define pDD pair < D , D >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

string vow = "aeiou";

void solve ( int test_case )
{
    int n ; cin >> n ;
    vi v ( n ) ;

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

    int i=0 ;

    int ans = 0 ;
    for ( ; i < n ; )
    {
        int j = i ;
        for ( ; i < n-1 && v[i] >= v[i+1] ; i++ ) ;

        ans = max ( i - j , ans ) ;
        i++ ;
    }

    cout << ans ; line
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#define eol '\n';
#define INT_BIG 1000000000;
using namespace std;

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

  int n,m;
  cin >> n >> m;
  int* c = new int[m];
  for (int i = 0; i < m; i++) {
    cin >> c[i];
  }

  int* dp = new int[n+1];
  for (int i = 1; i <= n; i++) {
    dp[i] = INT_BIG;
  }
  dp[0] = 0;

  for (int i = 0; i < m; i++) {
    for (int j = 0; j <= n; j++) {
      if (j + c[i] <= n) {
        dp[j+c[i]] = min(dp[j+c[i]], dp[j] + 1);
      }
    }
  }
  cout << dp[n] << eol;
  return 0;
}

Measured memory_bytes: 1392
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);
  int a[101][2];
  rep(i, 0, 2) {
    rep(j, 0, n) {
      scanf("%d", &a[j][i]);
    }
  }

  int sz[101], st[101];
  sz[0] = st[0] = 0;
  rep(i, 0, n) {
    sz[i+1] = sz[i] + a[i][0];
    st[i+1] = st[i] + a[i][1];
  }

  int ans = 0;
  rep(i, 0, n) {
    ans = max(ans, sz[i+1] + st[n] - st[i]);
  }


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


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;
const int MAX_N=10000;

signed main(){
    int n;cin>>n;
    vector<int>G[n];
    REP(i,n-1){
        int a,b;cin>>a>>b;a--;b--;
        G[a].eb(b);
        G[b].eb(a);
    }
    vector<int>c(n);
    int sum=0;
    REP(i,n){
        cin>>c[i];
        sum+=c[i];
    }
    sort(c.rbegin(),c.rend());
    sum-=c[0];
    cout<<sum<<endl;
    int t[n];
    REP(i,n)t[i]=INF;
    t[0]=c[0];
    queue<int>q;
    q.push(0);
    int i=1;
    while(!q.empty()){
        int d=q.front();q.pop();
        for(auto v:G[d]){
            if(t[v]!=INF)continue;
            t[v]=c[i];
            q.push(v);
            i++;
        }
    }
    REP(i,n)cout<<t[i]<<" ";
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    string part;
    char kiridashi;
    cin >> s;
    long long nagasa,ans,start;
    ans = 0;
    long long temp1,temp2,temp3;
    long long mod[2019];
    for(int i = 0;i < 2019; i++){
        mod[i] = 0;
    }
  mod[0] = 1;
  nagasa = s.length();
  //mod[(int)(s.substr(nagasa-1,1))] += 1;
  //kiridashi = s.substr(nagasa-1,1);
  kiridashi = s[nagasa-1];
  temp1 = kiridashi - '0';
  //temp2 = (int)(s.substr(nagasa-1,1));
  mod[temp1] += 1;
  temp2 =1;
  //printf("最初のtemp2は%d\n",temp2);
  //printf("最初のtemp1は%d\n",temp1);
    for(int i = 1;i < nagasa; i++){
      //cout << temp2 << endl;
      temp3 =temp2;
        temp2 = (temp3 * 10) % 2019;
        temp1 = (temp1 + (s[nagasa-i-1]-'0')*temp2) % 2019;
        mod[temp1]+=1;
      //printf("私は%d\n",temp1);
    }
    for(int i = 0; i < 2019; i++){
        ans += mod[i] * (mod[i]-1) / 2;
      //cout << mod[i] << endl;
    }
	//printf("%d\n",nagasa);
    cout << ans << endl;
}

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

using namespace std;
const int N = 1e5+10;
int main()
{
    string a,b;
    cin >> a >> b;
    map<string,int>mp;
    int x,y;
    cin >> x >> y;
    mp[a] = x;
    mp[b] = y;
    string k;
    cin >> k;
    if(mp[k] > 0)mp[k]--;
    cout << mp[a] <<' '<<mp[b];

    return 0;
}

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

using namespace std;
using ll = long long;
const int N = 55;
const int mod = 1e9+7;
int add(int a, int b) {
	return a + b >= mod ? a + b - mod : a + b;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}
int fexp(int b, int e = mod - 2) {
	int ans = 1;
	while(e) {
		if(e & 1) ans = mul(ans, b);
		b = mul(b, b);
		e /= 2;
	}
	return ans;
}

int dp[N][N][N*N];

int f(int i, int j, int k) {
	if(k < 0 or j < 0) return 0;
	if(i == 0) return j == 0 and k == 0;
	int &ans = dp[i][j][k];
	if(~ans) return ans;
	ans = 0;
	ans = add(ans, f(i - 1, j, k - 2 * j));
	ans = add(ans, mul(j, f(i - 1, j, k - 2 * j)));
	ans = add(ans, mul(j, f(i - 1, j, k - 2 * j)));
	ans = add(ans, mul(j, mul(j, f(i - 1, j - 1, k - 2*(j-1)))));
	ans = add(ans, f(i - 1, j + 1, k - 2 * (j + 1)));
	return ans;
}

int main() {
	memset(dp, -1, sizeof dp);
	int n, k;
	scanf("%d %d", &n, &k);
	printf("%d\n", f(n, 0, k));
}


Measured memory_bytes: 39544
#include<iostream>

using namespace std;

const int inf=1<<28;

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

int n,m;
int c[16];
int x[20010];
int dp[20010][256];


int main(void){
	
	while(cin >> n >> m,n|m){
		rep(i,n+1)rep(j,256) dp[i][j]=inf;
		rep(i,m) cin >> c[i];
		rep(i,n) cin >> x[i];
		dp[0][128]=0;			
		rep(i,n)rep(j,256)rep(k,m){
			int next=j+c[k];
			if(next<0)next=0;
			if(next>255) next=255;
			dp[i+1][next]=min(dp[i+1][next],dp[i][j]+(next-x[i])*(next-x[i]));
		}
		int ans=inf;
		rep(i,256) ans=min(ans,dp[n][i]);
		cout << ans << endl;
	}
	return 0;

}

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


int main()
{
    string s1, s2;
    cin>>s1>>s2;
    if(s1 == s2) cout<<"EQUAL"<<endl;
    int l1 = int(s1.size()), l2 = int(s2.size());
    if(l1 > l2) cout<<"GREATER"<<endl;
    else if(l1 < l2) cout<<"LESS"<<endl;
    else if (l1 == l2)
    {
        for(int i = 0; i<l1; i++)
        {
            if(s1[i] > s2[i])
            {
                cout<<"GREATER"<<endl;
                break;
            }
            if(s1[i] < s2[i])
            {
                cout<<"LESS"<<endl;
                break;
            }

        }
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	cout << (n % [](ll n) {ll ans = 0; while (n > 0) { ans += n % 10; n /= 10; } return ans; }(n) == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n, max = -1;
	int i;
	int a[200000];
	int maxlist[2] = { 0 };
	int j, maxi = 0, k, flag, up = 0, kaku=-1;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i < 2; i++) {
		max = 0;
		for (j = 0; j < n; j++) {
			if (kaku == j) {
				continue;
			}
			if (max < a[j]) {
				max = a[j];
			}
		}
		if (maxi < 2) {
			maxlist[maxi++] = max;
			for (k = 0; k < n; k++) {
				if (a[k] == max) {
					kaku = k;
					break;
				}
			}
		}
	}
	for (i = 0; i < n; i++) {
		if (maxlist[0] != a[i]) {
			printf("%d\n", maxlist[0]);
		}
		else {
			printf("%d\n", maxlist[1]);
		}
	}
	return 0;
}

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

using namespace std;

int main(){
    string S;
    int K,count=1,si;
    cin >> S >> K;
    vector<string> vec;
    si = S.size();
    for(int i=0;i<S.size();i++){
        string s = "";
        for(int j=0;j<min(5,si-i);j++){
            s += S[i+j];
            vec.push_back(s);
        }
    }

    sort(vec.begin(),vec.end());

    for(int i=0;;i++){
        if(K==count){
            cout << vec[i] << endl;;
            break;
        }
        if(vec[i]!=vec[i+1]){
            count++;
        }
    }
}

Measured memory_bytes: 1660
#!/usr/bin/env python3

import enum


EPS = 1e-10


class LinesRelation(enum.Enum):
    other = 0
    orthogonal = 1
    parallel = 2


def inner_product(v1, v2):
    return v1.real * v2.real + v1.imag * v2.imag


def outer_product(v1, v2):
    return v1.real * v2.imag - v1.imag * v2.real


def judge_lines_relation(l1_start, l1_end, l2_start, l2_end):
    v1 = l1_end - l1_start
    v2 = l2_end - l2_start
    if abs(outer_product(v1, v2)) < EPS:
        return LinesRelation.parallel
    elif abs(inner_product(v1, v2)) < EPS:
        return LinesRelation.orthogonal
    else:
        return LinesRelation.other


def main():
    q = int(input())
    for _ in range(q):
        xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3 = map(int, input().split())
        l1_start = complex(xp0, yp0)
        l1_end = complex(xp1, yp1)
        l2_start = complex(xp2, yp2)
        l2_end = complex(xp3, yp3)
        print(judge_lines_relation(l1_start, l1_end, l2_start, l2_end).value)


if __name__ == '__main__':
    main()

Measured memory_bytes: 8168
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int K = scan.nextInt();
        int X = scan.nextInt();
        for(int i = X - (K - 1); i < X + K; i++){
            System.out.print(i);
            System.out.print(" ");
        }
        
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;cin>>A>>B>>C>>D;
  for(int i=0;i<D-B;i++)cout<<'U';
  for(int i=0;i<C-A;i++)cout<<'R';
  for(int i=0;i<D-B;i++)cout<<'D';
  for(int i=0;i<C-A;i++)cout<<'L';
  cout<<'L';
  for(int i=0;i<D-B+1;i++)cout<<'U';
  for(int i=0;i<C-A+1;i++)cout<<'R';
  cout<<'D';
  cout<<'R';
  for(int i=0;i<D-B+1;i++)cout<<'D';
  for(int i=0;i<C-A+1;i++)cout<<'L';
  cout<<'U'<<endl;
}

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

namespace ABC105
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(nk[0] % nk[1] == 0 ? 0 : 1);
        }
    }
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	llint H,W,N;
	cin >> H >> W >> N;
	
	//SOLVE
	llint ans=0;
	llint hw;
	if (H<W) {
		hw = W;
	} else {
		hw = H;
	}
	
	ans = N/hw;
	if (N%hw == 0) {
	} else {
		ans++;
	}
	
	//OUTPUT
	cout << ans << endl;
	
	return 0;
}






Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]

ans = 0
for i in range(N):
    if B[i] >= A[i]:
        ans += A[i]
        B[i] -= A[i]
    else:
        ans += B[i]
        continue
    if B[i] > A[i+1]:
        ans += A[i+1]
        A[i+1] = 0
    else:
        ans += B[i]
        A[i+1] -= B[i]
print(ans)

Measured memory_bytes: 18624
def f(a):
    for x in ['b','w']:
        if a[0::4].count(x)==3 or a[2:7:2].count(x)==3:return x
        for i in range(3):
            if a[i*3:i*3+3].count(x)==3 or a[i::3].count(x)==3:return x
    return 'NA'

while 1:
    a=input()
    if a=='0':break
    a+=input()+input()
    print(f(list(a)))

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  vector<long> pos, neg;
  long a;
  for(int i = 0;i < N; i++){
    cin >> a;
    if(a < 0)neg.push_back(a);
    else pos.push_back(a);
  }
  sort(neg.begin(), neg.end());
  sort(pos.begin(), pos.end());
  vector<pair<long, long>> ans;
  long sub;
  if(pos.size() == 0){
    for(int i = 0; i < N - 1; i++){
      ans.push_back(make_pair(neg.at(N - 1), neg.at(i)));
      neg.at(N - 1) -= neg.at(i);
    }
    cout << neg.at(N - 1) << endl;
  } else if(neg.size() == 0){
    sub = pos.at(0);
    for(int i = 1; i < N - 1; i++){
      ans.push_back(make_pair(sub, pos.at(i)));
      sub -= pos.at(i);
    }
    ans.push_back(make_pair(pos.at(N - 1), sub));
    sub = pos.at(N - 1) - sub;
    cout << sub << endl;
  } else {
    for(int i = 0; i < pos.size() - 1; i++){
      ans.push_back(make_pair(neg.at(0), pos.at(i)));
      neg.at(0) -= pos.at(i);
    }
    for(int i = 0; i < neg.size(); i++){
      ans.push_back(make_pair(pos.at(pos.size() - 1), neg.at(i)));
      pos.at(pos.size() - 1) -= neg.at(i);
    }
    cout << pos.at(pos.size() - 1) << endl;
  }
  for(int i = 0; i < ans.size(); i++){
    cout << ans.at(i).first << ' ' << ans.at(i).second << endl;
  }
  return 0;
}

Measured memory_bytes: 5104
import sys

N, K = map(int, input().split())

res = 0

for i in range(1, N+1):
    if i >= K:
        res += 1 / N
        continue

    p = 1
    while i < K:
        i *= 2
        p *= 0.5
    res += (1 / N) * p

print(res)

Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CTravelingSalesmanAroundLake {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int K, N;
        cin >> K >> N;
        vector<int> A(N), d(N);
        REP(i, N) cin >> A[i];
        A.push_back(K + A[0]);
        REP(i, N) {
            d[i] = A[(i+1)] - A[i];
        }

        int res = INT_MAX;
        REP(i, d.size()) {
            res = min(res, K - d[i]);
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CTravelingSalesmanAroundLake solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 40;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N; cin >> N;
    vector<ll> a,b;
    int x;
    FOR(i,0,N){
        cin >> x;
        if(i%2==0){
            a.push_back(x);
        }else{
            b.push_back(x);
        }
    }
    reverse(b.begin(),b.end());
    FOR(i,0,a.size()) b.push_back(a[i]);
    if(N%2==1) reverse(b.begin(),b.end());

    FOR(i,0,N){
        if(i!=0) cout << " ";
        cout << b[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4712
#include <stdio.h>

int main(void){
  int A,B,C,X;
  int count=0;
  scanf("%d %d %d %d",&A,&B,&C,&X);
  for(int i=0;i<=A;i++){
    for(int j=0;j<=B;j++){
      for(int k=0;k<=C;k++){
        if(500*i+100*j+50*k==X){
          count++;
        }
      }
    }
  }
  printf("%d",count);

}


Measured memory_bytes: 128
from collections import defaultdict
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=[0]*(n+1)
for i in range(n):
    x[a[i]]+=1
y=[]
for i in range(n+1):
    if x[i]>0: y.append(x[i])
y.sort()
print(sum(y[:-k]) if len(y)>k else 0)

Measured memory_bytes: 26500
#!/usr/bin/ruby
while true do
	l=gets.chomp
	if l=='' then next end
	if l[0..0]=='-' then break end
	a=l.to_f*16;
	if a!=(a=a.to_i)||a>4095 then puts 'NA';next end
	puts sprintf('%08b.%04b',a/16,a%16)
end

Measured memory_bytes: 9868
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i,n) R a[i];
  ll cnt=0;
  rep(i,n) if(!a[i]) cnt++;
  sort(all(a));
  a.erase(remove(all(a),0),a.end());
  n=a.size();
  ll l=-MAXL,r=MAXL;
  while(l+1<r) {
    ll mm=(l+r)/2,sum=0;
    rep(i,n) {
      if(a[i]<0) {
        ll l2=-1,r2=i;
        while(l2+1<r2) {
          ll m2=(l2+r2)/2;
          if(a[i]*a[m2]>mm) l2=m2;
          else r2=m2;
        }
        sum+=abs(r2-i);
      } else {
        ll l2=-1,r2=i;
        while(l2+1<r2) {
          ll m2=(l2+r2)/2;
          if(a[i]*a[m2]>mm) r2=m2;
          else l2=m2;
        }
        sum+=r2;
      }
    }
    if(mm>=0) sum+=cnt*a.size()+cnt*(cnt-1)/2;
    if(sum>=m) r=mm;
    else l=mm;
  }
  pr(r);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

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

    if(k % 2 == 0) cout << a - b << endl;
    if(k % 2 == 1) cout << b - a << endl;
    return 0;
}

Measured memory_bytes: 3532
//  Created by conan1024hao on 2019/11/18.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
#define MAX 10000
struct Node{int p,l,r;};
struct Node T[MAX];
int a[100],b[100];
int n;
int cnt=0;
void postparse(int u){
    if(T[u].l!=-1)
        postparse(T[u].l);
    if(T[u].r!=-1)
        postparse(T[u].r);
    if(cnt<n-1)
        printf("%d ",u);
    else
        printf("%d\n",u);
    cnt++;
    
}
void reconstruction(int c,int in){
    if(c==in){
        cout<<"error"<<endl;
        return;
    }
    int cnt1=0,cnt2=0;
    
    for(int i=1;i<=n;i++){
        if(c==b[i])
            cnt1=i;
        if(in==b[i])
            cnt2=i;
    }
    if(cnt1<cnt2&&T[in].l==-1){
        T[in].l=c;
        T[c].p=in;
    }
    else if(cnt1>cnt2&&T[in].r==-1){
        T[in].r=c;
        T[c].p=in;
    }
    else if(cnt1<cnt2&&T[in].l!=-1)
        reconstruction(c,T[in].l);
    else if(cnt1>cnt2&&T[in].r!=-1)
        reconstruction(c,T[in].r);
    return;
}
//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<=n;i++){
        T[i].p=-1;
        T[i].l=-1;
        T[i].r=-1;
    }
    if(n==1){
        cout<<a[1]<<endl;
        return 0;
    }
    int root=a[1];
    T[a[2]].p=a[1];
    //T[b[1]].p=b[2];
    //T[b[2]].l=b[1];
    for(int i=2;i<=n;i++){
            reconstruction(a[i],root);
    }
    postparse(root);
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
int yeah(string s){
    s+="#";
    int cnt=0;
    rep(i,s.size()-1){
        if(s.at(i)!=s.at(i+1)){
            cnt++;
        }
    }
    return cnt;
}
signed main(){
    string s; cin>>s;
    cout<<yeah(s)-1<<endl;
}

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


void solve(long long N, long long K){
    long long ans = 1;
    for(long long i = 0; i < N; ++i){
        ans = min(ans * 2, ans + K);
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


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

int main() {
	
	ios_base::sync_with_stdio(false);
	
	long n;
	cin >> n;

	long long cnt, maxA, minB;

	cnt = maxA = minB = 0;

	while(n--)
	{
		long long a, b;
		
		cin >> a >> b;


		if(maxA < a)
		{
			maxA = a;
			minB = b;
		}

	}


	if(minB > 0)
	{
		cnt += minB;
	}

	cnt += maxA;

	cout << cnt;


	return 0;
}

Measured memory_bytes: 256
Option Explicit On
Option Strict On

Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim S As String = tmp(0)
        Dim T As String = tmp(1)
        Dim itmp As String() = Split(Console.ReadLine(), " ")
        Dim A As Integer = CInt(itmp(0))
        Dim B As Integer = CInt(itmp(1))
        Dim U As String = Console.ReadLine()

        If S = U Then
            A -= 1
        End If
        If T = U Then
            B -= 1
        End If

        Console.WriteLine(CStr(A) & " " & CStr(B))

        Console.ReadLine()

    End Sub

End Module


Measured memory_bytes: 22352
#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;


bool check(int a[15][15],int n){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i][j]==0)return true;
		}
	}
	return false;
}
int main(){
	int n;
	int data[15][15];
	while(cin >> n , n ){
		memset(data,0,15*15*4);
		int x = n/2;
		int y = n/2+1;
		data[x][y] = 1;
		int cnt=2;
		while(check(data,n)){
			int nx,ny;
			nx = (x+n+1)%n;
			ny = (y+1)%n;
			if(data[nx][ny]!=0){
				do{
					nx = (nx+n-1)%n;
					ny = (ny+1)%n;
				}while(data[nx][ny]!=0);
				data[nx][ny]=cnt++;
			}else{
				data[nx][ny]=cnt++;
			}
			x = nx;
			y = ny;
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				printf("%4d",data[j][i]);
			}
			puts("");
		}
	}
}

Measured memory_bytes: 0
#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;
}

int main(int argc, char *argv[])
{
  int n;
  while (cin >> n) {
    vector<int> v;
    for (int i = 0; i < 2 * n; ++i) {
      int m;
      cin >> m;
      v.push_back(m);
    }
    sort(v.begin(), v.end());
    int sum = 0;
    for (int i = 0; i < v.size(); i += 2) {
      sum += v[i];
    }
    cout << sum << endl;
  }
  return 0;
}


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

int main() {
    int n, cnt=0, mi=999, sum=0;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        sum += a;
        if(a%2){
            cnt++;
            mi = min(mi, a);
        }
    }
    if(cnt%2) sum -= mi;
    cout << sum/2 << endl;
    return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
signed main(){
    int n;
    cin>>n;
    vp vec(n);
    REP(i,n){
        cin>>vec[i].fi>>vec[i].se;
    }
    int ans=0;
    REPR(i,n-1){
        vec[i].fi+=ans;
        ans+=(vec[i].fi+vec[i].se-1)/vec[i].se*vec[i].se-vec[i].fi;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;

    cin >> n;

    map<ll, ll> m;

    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
        {
            for (int z = 1; z <= 100; z++)
            {
                m[x * x + y * y + z * z + x * y + y * z + z * x]++;
            }
        }
    }

    for (int i = 1; i <= n; i++)
    {
        cout << m[i] << endl;
    }
}


Measured memory_bytes: 5980
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main()
{
  fastio;
  string s;
  cin>>s;
  int md=2019;
  int n=s.length();
  map<int,int> count_suffix;
  ll ans=0;
  ll pot=1;
  ll suffix=0;
  count_suffix[suffix]++;
  for(int i=n-1;i>=0;i--)
  {
    int digit=s[i]-'0';
    suffix=(suffix + digit*pot)%md;
    pot=pot*10%md;
    ans+=count_suffix[suffix];
    count_suffix[suffix]++;
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 3736
A,B = map(int,input().split())
S = input().strip()
Num = [str(i) for i in range(10)]
if S[A]=="-":
    flag = 0
    for i in range(A+B+1):
        if i!=A and S[i] not in Num:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 61736
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
    if(a>b){
        a = b; return true;
    }
    else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
    if(a<b){
        a = b; return true;
    }
    else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
    cout << a << " " << b << " " << c << "\n";
}
const ll mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll l,r,d; cin >> l >> r >> d;
    ll ans = r / d - (l-1) / d;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();
 
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    
    let ans = m * (m - 1) / 2 + n * (n - 1) / 2;
    println!("{}", ans);
}

Measured memory_bytes: 4352
using System;

namespace MixingExp
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, Ma, Mb;
            string[] vals = Console.ReadLine().Split(' ');
            N = int.Parse(vals[0]);
            Ma = int.Parse(vals[1]);
            Mb = int.Parse(vals[2]);
            int[,] med = new int[N+1, 3];
            for(int i=1; i<= N; i++)
            {
                vals = Console.ReadLine().Split(' ');
                med[i, 0] = int.Parse(vals[0]);
                med[i, 1] = int.Parse(vals[1]);
                med[i, 2] = int.Parse(vals[2]);
            }

            int[,,] dp = new int[N+1, 10 * N + 1, 10 * N + 1];
            for(int i=0; i<= N; i++)
                for (int a = 0; a <= 10 * N; a++)
                    for (int b = 0; b <= 10 * N; b++)
                        dp[i, a, b] = int.MaxValue;
            dp[0, 0, 0] = 0;
            for(int i=1; i<=N; i++)
            {
                Console.WriteLine();
                for(int a=0; a<=10* N; a++)
                {
                    for(int b=0; b<=10* N; b++)
                    {
                        if(dp[i-1, a,b] != int.MaxValue)
                        {
                            dp[i, a, b] = Math.Min(dp[i, a, b], dp[i - 1, a, b]);
                            if(a + med[i, 0] <= 10*N && b + med[i,1] <= 10*N)
                            {
                                dp[i, a + med[i, 0], b + med[i, 1]] = Math.Min(dp[i-1, a + med[i, 0], b + med[i, 1]], dp[i-1, a, b] + med[i, 2]);
                            }
                        }
                    }
                }

                /*
                for (int a = 0; a <= 10 * N; a++)
                {
                    for (int b = 0; b <= 10 * N; b++)
                    {
                        if (dp[i, a, b] == int.MaxValue)
                            Console.Write("-1 ");
                        else
                            Console.Write(dp[i, a, b] + " ");
                    }
                    Console.WriteLine();
                }
                */

            }

            int minCost = int.MaxValue;
            int n = 1;
            while(Ma * n <= 10*N && Mb*n <= 10*N)
            {
                minCost = Math.Min(minCost, dp[N, Ma * n, Mb * n]);
                n++;
            }
            if (minCost == int.MaxValue)
                Console.WriteLine(-1);
            else
                Console.WriteLine(minCost);
        }
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;

#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define ROF(i, a, b) for(int i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define FILL(x, n, v) fill(x, x+n, v);
#define ALL(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MAXN = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int main(){
    FAST
    string ss;
    cin >> ss;
    ll n = ss.length();

    string s1 = ss.substr(0,n-1);
    string s2 = ss.substr(0,n-1);
    reverse(ALL(s2));
    
    bool valid=1;
    vector<ii> ans;
    if (s1 != s2) valid=0;
    else if (ss[n-1]=='1' || ss[0]=='0') valid=0;
    else {
        ll curnode=1, nextnode=2;

        FOR(i,0,n-2){
            if (s1[i] == '1'){
                ans.eb(curnode, nextnode);
                curnode = nextnode++;
            } else {
                ans.eb(curnode, nextnode);
                nextnode++;
            }
        }
    }
    if (valid){
        FOR(i,1,n-1){
            cout << ans[i-1].f << " " << ans[i-1].s << '\n';
        }
    } else cout << "-1";
}

Measured memory_bytes: 3392