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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

string s;
int d;

bool vis[100000][100];
mint memo[100000][100];

mint dfs(int i,int sum,bool smaller){
	if(i==s.length()) return sum==0?1:0;

	if(smaller && vis[i][sum]) return memo[i][sum];
	vis[i][sum]=true;

	mint res;
	if(smaller){
		rep(a,10){
			res+=dfs(i+1,(sum+a)%d,true);
		}
	}
	else{
		rep(a,s[i]-'0'+1){
			res+=dfs(i+1,(sum+a)%d,a<s[i]-'0');
		}
	}
	if(smaller) memo[i][sum]=res;
	return res;
}

int main(){
	cin>>s>>d;
	cout<<dfs(0,0,false)-1<<'\n';
	return 0;
}


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

using namespace std;

#define int long long

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

int N, K;
vector<int> h;

signed main()
{

    cin >> N >> K;

    h.resize(N);
    rep(i, N)
    {
        cin >> h[i];
    }

    sort(all(h));

    int m = 1e9;

    for (int i = 0; i < N; i++)
    {
        if ((i + K - 1) == N)
        {
            break;
        }
        m = min(m, h[i + K - 1] - h[i]);
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, T;
  cin >> n >> T;
  vii a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a.begin(), a.end(), [&](auto a, auto b){return (a.first || b.first) ? (1 + a.second) * b.first < a.first * (1 + b.second) : a.second < b.second;});
  vl d(50, T + 1);
  d[0] = 0;
  int res = 0;
  for (int i = 0; i < a.size(); ++i) {
    if (a[i].first == 0) {
      for (int j = 0; j < d.size(); ++j) if (d[j] <= T) {
        int cand = j, t = d[j];
        for (int l = i; l < a.size(); ++l) if (t + 1 + a[l].second <= T) {
          assert(a[l].first == 0);
          t += 1 + a[l].second;
          ++cand;
        }
        res = max(res, cand);
      }
      break;
    }
    for (int j = (int)d.size() - 2; j >= 0; --j) if (d[j] <= T) {
      ll t = d[j];
      ++t;
      t += a[i].first * t + a[i].second;
//      cerr << a[i].first << ' ' << a[i].second << ' ' << t1 << ' ' << (t <= T) << endl;
      if (t <= T) {
        d[j + 1] = min(d[j + 1], t);
        res = max(res, j + 1);
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3456
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Comparator;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            FastScanner fs = new FastScanner();

            final int N = fs.nextInt();
            final int K = fs.nextInt();

            Integer[] l = new Integer[N];

            for (int i = 0; i < N; i++) l[i] = fs.nextInt();

            Arrays.sort(l, Comparator.reverseOrder());

            int ans = 0;
            for (int i = 0; i < K; i++) ans += l[i];

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

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22612
def solve()
  n = gets.to_i
  a = gets.split.map!(&:to_i)
  b = gets.split.map!(&:to_i)
  c = gets.split.map!(&:to_i)
  sum = 0
  n.times do |i|
    sum += b[a[i]-1]
  end
  (n-1).times do |i|
    if (a[i+1] - a[i]) == 1
      sum += c[a[i]-1]
    end
  end
  p sum
end
solve()

Measured memory_bytes: 1788
//
//  main.cpp
//  ABC155A
//
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int A,B,C;
    cin>>A>>B>>C;
    int c=0;
    if (A==B) {
        c++;
    }
    if(A==C){
        c++;
    }
    if(B==C){
        c++;
    }
    if(c==1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
 
class Main
{
	static class Pair
	{
		int first, second;
		public Pair(int f, int s)
		{
			first = f;
			second = s;
		}
		
		public String toString()
		{
			return first + " " + second;
		}
	}
	
	static class PairComparator implements Comparator <Pair>
	{
		public int compare(Pair p1, Pair p2)
		{
			if(p1.first < p2.first)
				return -1;
			if(p1.first > p2.first)
				return 1;
			if(p1.second < p2.second)
				return -1;
			if(p1.second > p2.second)
				return 1;
			return 0;
		}
	}
	
	static int log2(double a)
	{
		return (int)(Math.log(a) / Math.log(2));
	}
	
	static long gcd(long a, long b)
	{
		long r;
		while((r = a % b) > 0)
		{
			a = b;
			b = r;
		}
		return b;
	}
	
	static class TrieNode
	{
		TrieNode z, o;
		boolean end;
		long count;
		
		public TrieNode()
		{
			 z = null;
			 o = null;
			 count = 0;
			 end = false;
		}
		
		
	}
	
	public static void main(String[] args) throws IOException
	{
		int n = in.nextInt();
		long ans = 0;
		for(int i = 0; i < n; i ++)
		{
			int l = in.nextInt();
			int r = in.nextInt();
			ans += (r - l) + 1;
		}
		sop(ans);
	}
    
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
	
    static FastReader in = new FastReader();
  
    public static void sop(Object o)
    {
    	System.out.print(o);
    }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> to(N);
  for (int i = 0; i < M; ++i) {
    int s, t;
    cin >> s >> t;
    --s;
    --t;
    to[s].push_back(t);
  }
  vector<double> dp(N);
  for (int u = N - 2; u >= 0; --u) {
    int deg = to[u].size();
    for (int v : to[u]) { 
      dp[u] += (dp[v] + 1.0) / deg;
    }
  }

  double ans = dp[0];

  for (int i = 0; i < N - 1; ++i) {
    if (to[i].size() == 1) continue;
    int nj = to[i][0];
    for (int j : to[i]) {
      if (dp[j] > dp[nj]) nj = j;
    }

    dp[N - 1] = 0;
    for (int u = N - 2; u >= 0; --u) {
      dp[u] = 0;
      int deg = to[u].size();
      if (u == i) --deg;
      for (int v : to[u]) {
        if (u == i && v == nj) continue;
        dp[u] += (dp[v] + 1.0) / deg;
      }
    }

    ans = min(ans, dp[0]);
  }

  printf("%.10f\n", ans);
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

//powMod
ll powMod(ll k, ll n, ll mod) {
    ll x = 1;
    while (n > 0) {
        if (n & 1) {
            x = x * k % mod;
        }
        k = k * k % mod;
        n >>= 1;
    }
    return x;
}

// comb (一つのみ) O(r)
ll comb(ll n, ll r, ll mod) {
    ll ret = 1;
    while (true) {
        if (r == 0) break;
        ll N = n % mod;
        ll R = r % mod;
        if (N < R) return 0;
        for (int i = 0; i < R; i++)
        {
            ret = ret * (N - i) % mod;
        }
        ll imul = 1;
        for (int i = 0; i < R; i++)
        {
            imul = imul * (i + 1) % mod;
        }
        ret = ret * powMod(imul, mod - 2, mod) % mod;
        n /= mod; r /= mod;
    }
    return ret;
}

int main() {
    int x, y;
    cin >> x >> y;
    if ((2 * x - y) < 0 || (2 * y - x) < 0 || (2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    int a = (2 * x - y) / 3;
    int b = (2 * y - x) / 3;
    cout << comb(a + b, a, MOD) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <iostream>
#include <fstream>

using namespace std;

const int DIV = 1000000007;

void solve(int test, istream &in) {
    int n = 5;
    vector<int> a(n);
    int ans = 1;
    for (int i = 0; i < n; i++) {
        in >> a[i];
        if (a[i] != i + 1)
            ans = i + 1;
    }
    printf("%d", ans);
}

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
	//FILE *f = fopen("in.txt", "r");
    ifstream f("in.txt");
#else
	//FILE *f = stdin;
    istream &f = cin;
#endif
    int tests = 1;
    //f >> tests;
    for (int test = 0; test < tests; test++) {
        solve(test, f);
    }
	return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
    #include <ext/pb_ds/tree_policy.hpp> 
    #include <functional> // for less 
    using namespace __gnu_pbds; 
    using namespace std;
    //typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;    
    #define ll            long long
    #define pb            push_back
    #define ppb           pop_back
    #define si            set <ll>
    #define endl          '\n'
    #define fr            first
    #define sc            second
    #define mii           map<ll ,ll >
    #define msi           map<string,ll >
    #define mis           map<ll , string>
    #define rep(i,a,b)    for(ll  i=a;i<b;i++)
    #define all(v)        v.begin(),v.end()
    #define sort(v)       sort(all(v))
    #define pii           pair<ll ,ll >
    #define vi            vector<ll >
    #define vii           vector<pair<ll , ll >>
    #define vs            vector<string>
    #define sz(x)         (ll)x.size()
    #define M             1000000007
    #define bs            binary_search
    #define rev(a)        reverse(all(a));
    #define sp(n)         setprecision(n)
    #define spl           " "
    #define arr(a,n)      rep(i,0,n) cin>>a[i]
    #define mod           998244353
    #define show(a,n)     for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
    #define N             100000000
    #define debug(x)      cout << #x << " is " << x << endl;
    #define time          cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    #define INF           1ll<<31
    using namespace std;
    ll min(ll a,ll b)
    {
        return a>b?b:a;
    }
    ll max(ll a,ll b)
    {
        return a>b?a:b;
    }
    const ll maxn=2e5+500;
    void solve()
    {
      ll n;
      cin>>n;
      ll s=0;
      rep(i,1,n+1)
      {
        if(i%15 && i%3 && i%5) s+=i;
      }
      cout<<s<<endl;
    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //#ifndef ONLINE_JUDGE
       //freopen("input.txt","r",stdin);
       //freopen("output.txt","w",stdout);
        //#endif
        ll t=1;
        //cin>>t;
        while(t--) solve();
    }
    
/*
5 1
2 4 8 2 4
*/
   


Measured memory_bytes: 3628
N, K, L = [int(_) for _ in input().split()]
V1 = [[int(_) - 1 for _ in input().split()] for i in range(K)]
V2 = [[int(_) - 1 for _ in input().split()] for i in range(L)]


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


uf1 = UnionFind(N)
for p, q in V1:
    uf1.union(p, q)

uf2 = UnionFind(N)
for r, s in V2:
    uf2.union(r, s)

from collections import defaultdict
d = defaultdict(int)

for i in range(N):
    d[(uf1.find(i), uf2.find(i))] += 1

for i in range(N):
    print(d[(uf1.find(i), uf2.find(i))], end=' ')
print()


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

int main(){
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << h * w / 2 << " ";
  if (w/2.00 == x && h/2.00 == y){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}



Measured memory_bytes: 256
import copy
num = int(input())
base_list = list(input().split())
a = copy.copy(base_list)
b = copy.copy(base_list)

for i in range(num):
    for j in reversed(range(i+1,num)):
        if a[j][1] < a[j-1][1]:
            a[j],a[j-1] = a[j-1],a[j]

print(" ".join([str(i) for i in a]))
print('Stable')

for i in range(num):
    minj = i
    for j in range(i,num):
        if b[j][1] < b[minj][1]:
            minj = j
    b[i], b[minj] = b[minj],b[i]

print(" ".join([str(i) for i in b]))
flg = False
for bubble,sele in zip(a,b):
    if bubble != sele:
        flg = True
        break

if flg:
    print('Not stable')
else:
    print('Stable')



Measured memory_bytes: 6344
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int v[3] = {0, 1, 2};
string s[3];
int len[3], sl = 0;
vector<bool> vb[3][3];


int f(){
    int a = v[0];
    int b = v[1];
    int c = v[2];
    int sf = len[a] + len[c];
    int res = sl;
    for(int i=0;i<=sf;i++){
        if(!vb[a][b][i]) continue;
        int st = max(len[a]-i, len[b]);
        for(int j=0;j<=st;j++){
            if(!vb[b][c][j]) continue;
            if(!vb[a][c][i+j]) continue;
            int tmp = i + max(len[b], j+len[c]);
            if(tmp < len[a]) tmp = len[a];
            if(tmp < res){
                res = tmp;
                // cerr << res << endl;
                // cerr << s[a] << endl;
                // cerr << string(i, ' ') << s[b] << endl;
                // cerr << string(i+j, ' ') << s[c] << endl;
            }
        }
    }
    return res;
}

void cal(int a, int b){
    vb[a][b].assign(sl+2, true);
    int sf = len[a] + len[3-a-b];
    for(int sft=0;sft<sf;sft++){
        bool flg = true;
        int st = min(len[a], sft+len[b]);
        for(int i=sft;i<st;i++){
            char x = s[a][i];
            char y = s[b][i-sft];
            if(x != '?' && y != '?' && x != y){
                flg = false;
                break;
            }
        }
        vb[a][b][sft] = flg;
    }
}

int main(void){
    for(int i=0;i<3;i++){
        cin >> s[i];
        len[i] = s[i].length();
        sl += len[i];
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(i != j) cal(i, j);
        }
    }
    int ans = sl;
    do{
        int tmp = f();
        if(ans > tmp) ans = tmp;
    }while(next_permutation(v, v+3));
    cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  ll h[n];
  rep(i,n) cin >> h[i];
  ll l[n], r[n], st[n];
  ll t = 0;
  rep(i,n) {
    while(t > 0 && h[st[t-1]] >= h[i]) t--;
    l[i] = (t == 0 ? 0 : st[t-1]+1);
    st[t++] = i;
  }
  t = 0;
  for(int i = n-1; i >= 0; i--) {
    while(t > 0 && h[st[t-1]] >= h[i]) t--;
    r[i] = (t == 0 ? n : st[t-1]);
    st[t++] = i; 
  }
  ll ans = 0;
  rep(i,n) ans = max(ans,h[i]*(r[i]-l[i]));
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 6212
#include <bits/stdc++.h>
using namespace std;
#define forN(N) if(N >= 0)for(size_t i = 0;i < N;++i)
typedef unsigned long long ul ;

int main() {
  ul D;
  vector<int>c;
  vector<vector<int>>s;
  cin >> D;
  forN(26){
    int t;
    cin >> t;
    c.push_back(t);
  }
  forN(D){
    vector<int> tv;
    int maxI = 0;
    int maxN = -1;
    forN(26){
      int t;
      cin >> t;
      tv.push_back(t);
      if(maxN < t){
		maxN = t;
        maxI = i;
      }
    }
    cout << (maxI + 1) << endl;
    s.push_back(tv);
  }
  
  int sati = 0;
}


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


namespace ABC50
{
    class Program
    {
        static void Main(string[] args)
        {
            //
            B();
            Console.Read();

        }

        static void B()
        {
            int dammyN = int.Parse(Console.ReadLine());
            List<int> T = new List<int>(); T.Add(0);
            foreach (string s in Console.ReadLine().Split(' ')) T.Add(int.Parse(s));
            int dammyM = int.Parse(Console.ReadLine());
            List<int> P = new List<int>(); P.Add(0);
            List<int> X = new List<int>(); X.Add(0);

            for (int i = 1; i <= dammyM; i++)
            {
                string[] stemp = Console.ReadLine().Split(' ');
                P.Add(int.Parse(stemp[0]));
                X.Add(int.Parse(stemp[1]));
            }


            int RequiredTimeIfNoDrink = T.Sum();
            for(int i = 1; i <= dammyM; i++)
            {
                int tp = T[P[i]];
                int xi = X[i];
                int temp = RequiredTimeIfNoDrink - (T[P[i]] - X[i]);
                Console.WriteLine((temp).ToString());
            }

        }
        static void A()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[2]);
            string op = input[1];

            if (op == "+") Console.WriteLine((a + b).ToString());
            else if (op == "-") Console.WriteLine((a - b).ToString());
            else throw new ArgumentException();
        }
    }

}

Measured memory_bytes: 13268
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let n: usize = read_as_vec()[0];

    let mut stations: Vec<(u64, u64, u64)> = vec![];
    for _ in 0..n-1{
        let line: Vec<u64> = read_as_vec();
        stations.push((line[0], line[1], line[2]));
    }

    for start in 0..n-1{
        let mut cur_time = 0;

        for cur_pos in start..n-1{
            if cur_time <= stations[cur_pos].1{
                cur_time = stations[cur_pos].1;
            }else{
                cur_time = (cur_time + stations[cur_pos].2 -1)/stations[cur_pos].2 * stations[cur_pos].2;
            }
            cur_time += stations[cur_pos].0;
        }

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

    println!("0");
}


Measured memory_bytes: 4352
import math

N = int(input())
p, q, r = 1, 1, N
if N % 2 == 0:
    p = 2
    q = 3
n = int(math.sqrt(N))
while q <= n:
    if N % q == 0:
        p = q
    q += 1
num = str(max(p, N//p))

ans = len(num)
print(ans)

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n=in();
    int k=in();
    vector<int> a(n);
    REP(i,n){
        a[i]=in();
    }
    int sum=accumulate(a.begin(),a.end(),0);
    for(int t=sum;t>0;t--){
        if(sum%t==0){
            //debug(t);
            vector<int> r(n);
            REP(i,n){
                r[i]=a[i]%t;
            }
            sort(all(r));
            vector<ll> ruiseki;
            ruiseki.pb(0);
            REP(i,n){
                ruiseki.pb(ruiseki[i]+r[i]);
            }
            REP(i,n+1){
                if(ruiseki[i]<=k){
                    ll cnt;
                    cnt=ruiseki[i]-(t*(n-i)-(ruiseki[n]-ruiseki[i]));
                    if(cnt>=0&&cnt%t==0){
                        print(t);
                        return 0;
                    }
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
use std::cmp::min;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, p: [usize; n * n]);
    let mut board = vec![vec![0; n]; n];
    for i in 0..n {
        for j in 0..n {
            board[i][j] = min(min(i, n - i - 1), min(j, n - j - 1));
        }
    }
    let mut leaved = vec![vec![false; n]; n];
    let mut ret = 0;
    let dx = [1isize, 0, -1, 0];
    let dy = [0isize, 1, 0, -1];
    for i in 0..(n * n) {
        let x = (p[i] - 1) / n;
        let y = (p[i] - 1) % n;
        ret += board[x][y];

        let mut q = std::collections::VecDeque::new();
        q.push_back((x, y));
        leaved[x][y] = true;

        while let Some((x, y)) = q.pop_front() {
            let s = board[x][y];
            let ns = if leaved[x][y] { s } else { s + 1 };
            for i in 0..4 {
                let nx = x as isize + dx[i];
                let ny = y as isize + dy[i];
                if nx < 0 || nx >= n as isize || ny < 0 || ny >= n as isize {
                    continue;
                }
                let nx = nx as usize;
                let ny = ny as usize;
                if board[nx][ny] > ns {
                    q.push_back((nx, ny));
                    board[nx][ny] = ns;
                }
            }
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 7860
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000
#define MAXN 60

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

int n;
int cnts[26][MAXN];

int main() {
  cin >> n;
  memset(cnts, 0, sizeof cnts);

  FORN(i, n) {
    string str;
    cin >> str;

    FORN(j, str.size()) {
      int idx = str[j] - 'a';
      cnts[ idx ][i]++;
    }
  }

  vector<char> ans;
  FORN(j, 26) {
    int num = INF;
    char letter = (char)('a' + j);
    FORN(i, n) {
      num = min(num, cnts[j][i]);
    }
    if (num > 0) {
      FORN(k, num) ans.PB(letter);
    }
  }

  string ans2(ans.begin(), ans.end());
  cout << ans2 << "\n";
    
  return 0;
}

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

int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u==s) {
        a--;
    }else{
        b--;
    }
    
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
K=int(input())
def waru(K):
    a=[]
    if K%2==0 or K%5==0:
        print("-1")
        return
    a.append(7%K)
    for i in range(1,K):
        a.append((10*a[i-1]+7)%K)
    for i in range(K):
        if a[i]==0:
            print(i+1)
            return
    print(-1)
waru(K)

Measured memory_bytes: 48400
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int n;
string s;

signed main() {
	int i;
	
	cin >> n >> s;
	
	int level = 0, minLevel = 0;
	for (i = 0; i < s.length(); i++) {
		if (s[i] == '(') level++;
		else level--;
		minLevel = min(level, minLevel);
	}
	
	if (minLevel < 0) {
		string t;
		for (int i = 0; i < -minLevel; i++) t += '('; t += s;
		s = t;
	}
	
	int lastLevel = level - minLevel;
	if (lastLevel != 0) {
		for (int i = 0; i < lastLevel; i++) s += ')';
	}
	
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;


int main() {
	ll m1, m2, d1, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if (m1 >= 1 && m1 <= 12 && m2 >= 1 && m2 <= 12) {
		if (m1 == 2&&d1==28) {
			cout << 1 << endl;
		}
		else if((m1==4||m1==6||m1==9||m1==11)&&(d1==30)){
			cout << 1 << endl;
			//cout << 11 << endl;
		}
		else if(d1==31) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}

}


Measured memory_bytes: 256
/*
  "I knew I shouldn't have
   gotten out of bed today."
   - Squidward Q.Tentacles
*/
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<numeric>
#include<random>
#include<fstream>
#include<chrono>

#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define int          long long
#define ld           long double
#define pii          pair<int,int>
#define vi           vector<int>
#define maxpq        priority_queue<int>
#define minpq        priority_queue<int,vi,greater<int>>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define brep(i,s,e)  for(int i=s;i>=e;i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,y,sizeof(x))
#define milf(x)      x.reserve(1LL<<14LL); x.max_load_factor(0.25);
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define VR46         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937              rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9+7;
ld EPS = 1e-12;
const int INF32 = 0x3F3F3F3F;
const int INF = 0x3F3F3F3F3F3F3F3F;
const int crng = rng();

signed main()
{
    VR46 ifstream fin("input.txt"); ofstream fout("output.txt");
    // auto start = chrono::high_resolution_clock::now();

    // GANDU TEST CASE BNAKE TEST KRLE; CHECK BOUNDS;
    // int t; cin>>t; rep(test,1,t)
    {
        int h,a;
        cin>>h>>a;
        int ans = h/a;
        if( h%a!=0 ) ans++;
        cout<< ans <<endl;
    }

    // auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout<<"Time taken by function: "<<duration.count()<<" milliseconds"<<endl;

    // *( hsh.find_by_order(k) ) kth smallest, from 0
    // hsh.order_of_key(k) num of ele str less than k
    // change less to less_equal for multiset pbds
    // Create struct HASH; Use milf(x) for every hashmap; Use CRNG xor;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=3009;
	int mod;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y,int _mod=mod){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%_mod;
			x=1LL*x*x%_mod,y>>=1;
		}
		return ret;
	}

	int n,pw[N*N],S[N][N],C[N][N];
	int main(){
		n=read<int>(),mod=read<int>();

		C[0][0]=1;
		for(int i=1;i<=n+1;i++){
			C[i][0]=1;
			for(int j=1;j<=i;j++)
				C[i][j]=add(C[i-1][j-1],C[i-1][j]);
		}
		S[0][0]=1;
		for(int i=1;i<=n+1;i++){
			S[0][i]=0;
			for(int j=1;j<=i;j++)
				S[i][j]=(1LL*S[i-1][j]*j+S[i-1][j-1])%mod;
		}

		pw[0]=1;
		for(int i=1;i<=n*n;i++) pw[i]=2LL*pw[i-1]%mod;

		int ans=0;
		for(int i=0;i<=n;i++){
			int ret=0;
			for(int j=0;j<=i;j++)
				ret=(1LL*S[i+1][j+1]*pw[(n-i)*j]+ret)%mod;
			ret=1LL*ret*qpow(2,qpow(2,n-i,mod-1))%mod;
			if(i&1) ans=sub(ans,1LL*C[n][i]*ret%mod);
			else ans=add(ans,1LL*C[n][i]*ret%mod);
		}
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

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

int main(){
    string t; cin >> t;
    ll ans = 0;

    t.push_back('X');

    for(long long i = 0; i < t.size()-1; i++){
        if(t[i] == '?'){
            t[i] = 'D';
        }
    }

    for(long long i = 0; i < t.size()-1; i++){
        cout << t[i];
    }
    cout << endl;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int k = in();
  if(n == k) {
    cout << 0 << endl;
    return 0;
  }
  if(n%k == 0) {
    cout << 0 << endl;
    return 0;
  }
  int tmp = n % k;
  cout << min(k-tmp, n) << endl;
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
from bisect import bisect_left as bl


def f(v):
    v = str(v)
    return '0' * (6 - len(v)) + v


N, M = map(int, input().split())
dic = dict()
PY = []
for i in range(M):
    p, y = map(int, input().split())
    if dic.get(p, False):
        dic[p].append(y)
    else:
        dic[p] = [y]
    PY.append((p, y))

for i in range(1, N + 1):
    if dic.get(i, False):
        dic[i] = sorted(dic[i])

# print('dic', dic, PY)
for i in range(M):
    p, y = PY[i]
    # print('p y', p, y)
    l = dic[p]
    ans = f(p) + f(bl(l, y) + 1)
    print(ans)


Measured memory_bytes: 35904
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int shift4(int n, int k){
  for(int i=0; i<k; ++i) n /= 4;
  return n%4;
}

int main(){
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> bom(n);
  for(int i=0; i<n; ++i) cin >> bom[i];
  int n4 = 1;
  for(int i=0; i<n; ++i) n4 *= 4;
  
  int ans = INF;
  for(int i=0; i<n4; ++i){
    int nans = -30;
    vector<int> abc(4,0);
    for(int j=0; j<n; ++j){
      int x = shift4(i, j);
      if(x < 3) nans += 10;
      abc[x] += bom[j];
    }
    if(abc[0] == 0 || abc[1] == 0 || abc[2] == 0) continue;
    nans += abs(abc[0] - a);
    nans += abs(abc[1] - b);
    nans += abs(abc[2] - c);
    ans = min(ans, nans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
def flipping_signs(N: int, A: list)->int:
    # 負の数が偶数この場合は全部正にできる。
    # 奇数個の場合は必ず一つ正にできないので絶対値の一番小さいもの
    # を残して他は全部正にする。
    min_abs = float('inf')
    s = 0
    neg_n = 0
    for a in A:
        s += abs(a)
        if a < 0:
            neg_n += 1
        min_abs = min(abs(a), min_abs)

    # print(neg_n, min_abs)
    if neg_n & 1:
        return s - 2*min_abs
    return s


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]

    ans = flipping_signs(N, A)
    print(ans)


Measured memory_bytes: 14412
using System;

namespace Atc_0008
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            if (S.Contains(T))
            {
                Console.WriteLine(0);

                return;
            }

            int count = 0;
            int result = T.Length;
            int num = (S.Length - T.Length + 1);

            for (int i = 0; i < num; i++)
            {
                count = 0;

                for (int j = 0; j < T.Length; j++)
                {
                    if (S.Substring(i + j, 1) != T.Substring(j, 1))
                    {
                        count++;
                    }
                }

                if (count < result)
                {
                    result = count;
                }

                if (count == 1)
                {
                    break;
                }
            }

            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 32396
SA=str(input())+"f"
SB=str(input())+"f"
SC=str(input())+"f"
A,B,C=1,0,0
i=0
x=SA[0]

while i < len(SA + SB + SC):
    if x == "a":
        x = SA[A]
        A+=1
    elif x == "b":
        x = SB[B]
        B+=1
    elif x == "c":
        x = SC[C]
        C+=1
        
    if A==len(SA):
        ans="A"
        break
    elif B==len(SB):
        ans="B"
        break
    elif C==len(SC):
        ans="C"
        break
    i+=1
print(ans)

Measured memory_bytes: 9052
from bisect import bisect_right


def main():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    b = sorted(list(map(int, input().split())))
    c = sorted(list(map(int, input().split())))
    l = [0] * n
    for index, i in enumerate(b):
        l[index] = n - bisect_right(c, i)
    s = [l[-1]] * n
    for i in range(n - 2, -1, -1):
        s[i] = s[i + 1] + l[i]
    ans = 0
    for i in a:
        j = bisect_right(b, i)
        if j < n:
            ans += s[j]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25204
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<string> s(n);
  vec a(n);
  REP(i,n) cin >> s[i] >>a[i];

  string x; cin >> x;
  int ans = 0;

  bool flag = false;
  REP(i,n){
    
    if(flag) ans += a[i];if(x==s[i]) flag = true;
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
#define i(x) cin>>x
#define fr(n,x) for(ll n=0;n<x;n++)
#define pf(x) cout<<x
const ll mod=1e9+7 ;


int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    ll x,y;
    cin>>x>>y;
    if (y-x>=2019)
    {
        cout<<0;
        return 0;
    }
    ll res=INT_MAX;
    for(ll n=x;n<=y;n++)
    {
        for(ll k=n+1;k<=y;k++)
        {
            res=min(res,((n%2019)*(k%2019))%2019);
        }
    }
    cout<<res;
}

Measured memory_bytes: 3648
import java.util.*;
// Word by word ripped from editorial solution. 
// Completes first 100th incomplete atcoder ABC submission. 
// Atcoder is awesome.. 
public class Main {

	static int calc(int x) {
		int ret = 0;
		while (x%100==0) {
			x/=100;
			++ret;
		}
		return ret;
	}

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt(), N = sc.nextInt(), cnt=0, val=0;
		while (cnt<N) {
			++val;
			if (calc(val)==D) ++cnt;
		}
		System.out.println(val);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

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

int main() {
  int x, y; cin >> x >> y;
  set<int> s;
  s = {4, 6, 9, 11};
  if (x == 2 || y == 2) {
    cout << "No" << endl;
  }
  else if (s.count(x) == 1 && s.count(y) == 1) {
    cout << "Yes" << endl;
  }
  else if (s.count(x) == 0 && s.count(y) == 0) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i])
	}

	cnt := 0
	for i, x := range xs {
		if i == n-1 {
			break
		}
		next := a * (xs[i+1] - x)
		if next < b {
			cnt += next
		} else {
			cnt += b
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 7424
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i;
  int n,m,s;
  int *a;
  while(cin>>n>>m&&n+m){
    a=new int[n];
    for(i=0;i<n;i++)
      cin>>a[i];
    do{
      h=0;
      for(i=1;i<n;i++){
	if(a[i-1]<a[i]){
	  swap(a[i-1],a[i]);
	  h=1;
	}
      }
    }while(h);
    s=0;
    for(i=0;i<n;i++){
      if((i+1)%m)
	s+=a[i];
    }
    cout<<s<<endl;
    delete[]a;
  }
  return 0;
}

Measured memory_bytes: 908
#include <stdio.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define MED(a,b,c) ((a)<(b)?(a)>(c)?(a):(b)<(c)?(b):(c):(a)>(c)?(b)<(c)?(c):(b):(a))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXS(a,b) {if((a)<(b))(a)=(b);}
#define MINS(a,b) {if((a)>(b))(a)=(b);}
#define BEGINFOR(a,b,c,d,e,f,g,h,i) a;goto i##_6;i##_2:c;goto i##_6;i##_3:h;goto i##_7;i##_4:d;goto i##_8;i##_5:f;goto i##_8;i##_6:if(b)goto i##_4;else goto i##_9;i##_7:if(g)goto i##_5;else goto i##_1;i##_8:if(e)goto i##_2;else goto i##_3;i##_9:
#define CONTINUE(i) goto i##_3
#define BREAK(i) goto i##_1
#define ENDFOR(i) goto i##_3;i##_1:

int main(){
	int a, b;
	char s[16];
	scanf("%d%d%s", &a, &b, s);
	for(int i = 0; i < a; i++){
		if(!('0' <= s[i] && s[i] <= '9')){
			puts("No");
			return 0;
		}
	}
	if(s[a] != '-'){
		puts("No");
		return 0;
	}
	for(int i = 0; i < b; i++){
		if(!('0' <= s[a + i + 1] && s[a + i + 1] <= '9')){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 128