akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll inf = 2e15;
const int N = 18;
int n, a[N];
map <ll, map <ll, ll> > dp[N][N];

// dp[l][r][xl][xr]

ll rec(int l, int r, ll xl, ll xr) {
    if(l + 1 >= r)
        return 0;
    if(dp[l][r].find(xl) != dp[l][r].end() && dp[l][r][xl].find(xr) != dp[l][r][xl].end())
        return dp[l][r][xl][xr];
    dp[l][r][xl][xr] = inf;
    for(int i = l + 1; i < r; ++i)
        dp[l][r][xl][xr] = min(dp[l][r][xl][xr], rec(l, i, xl, xl + xr) + rec(i, r, xl + xr, xr) + (xl + xr) * a[i]);
    return dp[l][r][xl][xr];
}

main() {
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    cout << rec(0, n - 1, 1, 1) + a[0] + a[n-1] << endl;
    return 0;
}

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

int main() {
  
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  vector<int> area(2);
  area = {A*B, C*D};
  
  if(A*B != C*D){
    cout << max(A*B, C*D) << endl;
  }
  else{
    cout << A*B << endl;
  }
  
}


Measured memory_bytes: 256
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    A = []
    input_raw = read_func().strip().split()
    for i in range(N * 3):
        A.append(int(input_raw[i]))
    A.sort(reverse = True)
    s = 0L
    for i in range(N):
        s += A[2*i + 1]
    print s


if __name__ == '__main__':
    main()

Measured memory_bytes: 40424
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){ll n,m,q;
  cin >> n >> m >> q;
  ll array[n][n+1];
  ll sum[n][n+1];
  fill(array[0],array[n],0);
  REP(i,m){
    ll l,r;
    cin >> l >> r;
    l--, r--;
    for(ll k = 0; k <= l; k++){
      array[k][r]++;
      array[k][n]--;
    }
  }
  ll val = 0;
  REP(i,n){
    REP(j,n+1){
      val += array[i][j];
      sum[i][j] = val;
    }
  }
  REP(i,q){
    ll p,q;
    cin >> p >> q;
    p--, q--;
    cout << sum[p][q] << endl;
  }
  return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  sort(v.begin(), v.end());
  ll res = INF;
  for (ll i = 0; i+k-1 < n; i++) {
    chmin(res, v.at(i+k-1)-v.at(i));
  }
  cout << res << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
signed main(){
    int n,vec;
    long long b,sum=0;
    vector <long long> a;
    cin>>n;
    for(int i=0;i<n+1;i++){
        cin>>vec;
        a.push_back(vec);
    }
    for(int i=0;i<n;i++){
        cin>>b;
        if(b-a[i]<0){
            sum+=b;
            b=0;
        }
        else{
            sum+=b-(b-a[i]);
            b-=a[i];
        }
        if(b-a[i+1]<0){
            sum+=b;
            a[i+1]-=b;
        }
        else{
            sum+=b-(b-a[i+1]);
            a[i+1]=0;
        }
    }
    cout<<sum<<'\n';
    return(0);
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
  
  	private final static Scanner sc = new Scanner(System.in);
  
  	public static void main (String [] args) {
      String today = sc.next();
      if(today.equals("Sunny")) {
        System.out.println("Cloudy");
      } else if (today.equals("Cloudy")) {
        System.out.println("Rainy");
      } else {
        System.out.println("Sunny");
      }
   }
}

Measured memory_bytes: 19668
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.OptionalInt;
import java.io.UncheckedIOException;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CTakahashisInformation solver = new CTakahashisInformation();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTakahashisInformation {
        private static final String YES = "Yes";
        private static final String NO = "No";

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int[][] c = in.ints(3, 3);
            for (int i = 0; i < 3; i++) {
                int min = IntMath.min(c[i]);
                for (int j = 0; j < 3; j++) {
                    c[i][j] -= min;
                }
            }
            for (int i = 0; i < 3; i++) {
                if (c[0][i] != c[1][i] || c[1][i] != c[2][i]) {
                    out.println(NO);
                    return;
                }
            }
            out.println(YES);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

        public int[][] ints(int height, int width) {
            return IntStream.range(0, height).mapToObj(x -> ints(width)).toArray(int[][]::new);
        }

    }

    static final class IntMath {
        private IntMath() {
        }

        public static int min(int... v) {
            return Arrays.stream(v).min().orElseThrow(NoSuchElementException::new);
        }

    }
}



Measured memory_bytes: 27732
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back

int abs(int a){
    return ( a>0 ? a : -a );
}
int main(){
    int n;
    cin >> n;
    vector<int> a;
    if(n==0){
        cout << 0 << endl;
        return 0;
    }
    while(n!=0){
        if(abs(n)%2==0){
            a.pb(0);
            n /= -2;
        }else{
            a.pb(1);
            n = (n-1)/(-2);
        }
    }
    reverse(a);
    rp(i,a.size()){
        cout << a.at(i);
    }
    cout << endl;
    
}






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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c,d;
            //a = int.Parse(Console.ReadLine()); //標準入力
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            b = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
            c = int.Parse(str[1]);
            d = int.Parse(str[2]);

            string re = "NO";

            if(b<=d)
            {
                if(b+c >=d)
                {
                    re = "YES";
                }
            }
            Console.Write(re);

            //Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            //Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
int n, s[105];
bool dp[10005];
/**********************************************/

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

    cin >> n;
    REP(i, n) cin >> s[i];

    REP(i, 10005) dp[i] = false;
    dp[0] = true;
    REP(i, n){
        for(int j = 10000; j >= 0; j--){
            if(dp[j]) dp[j+s[i]] = true;
        }
    }
    int ans = 0;
    REP(i, 10005){
        if(i % 10 != 0 && dp[i]) ans = i;
    }
    cout << ans << endl;
}


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

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	int a , b , c;
	
	cin >> a >> b >> c;
	
	cout << (a^b^c);
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3592
import sys
import numpy as np

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')

    @cc.export('is_ok', '(i8[:],i8[:],i8,i8)')
    def is_ok(A, F, x, k):
        y = A - x // F
        tmp = y[y > 0].sum()
        return tmp <= k

    cc.compile()
    exit(0)

from my_module import is_ok
n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

A = np.sort(A)
F = np.sort(F)[::-1]

ok = 10 ** 16
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    y = A - mid // F
    if is_ok(A, F, mid, k):
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 53568
import java.util.*;

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

        HashSet<Integer> set = new HashSet<Integer>();

        set.add(a);
        set.add(b);
        set.add(c);

        System.out.println(set.size() == 2 ? "Yes" : "No");
    }
}


Measured memory_bytes: 21204
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int H, W, A, B;
int s[1001][1001];

void output() {
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << s[i][j];
    }
    cout << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> H >> W >> A >> B;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j < A && i < B) {
        s[i][j] = 0;
      } else if (j >= A && i < B) {
        s[i][j] = 1;
      } else if (j < A && i >= B) {
        s[i][j] = 1;
      } else {
        s[i][j] = 0;
      }
    }
  }

  output();
  return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

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

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

/////////////////////////////////////////////////////////

void Main() {
  int H, W; cin >> H >> W;
  vector<string> A(H);
  rep(h, 0, H) cin >> A[h];
  queue<XY> que;
  int cnt = 0;
  rep(h, 0, H){
    rep(w, 0, W){
      if(A[h][w] == '#'){
        XY tmp(h, w);
        que.push(tmp);
        cnt++;
      }
    }
  }
  int res = 0;
  while(cnt != H * W){
    res++;
    queue<XY> que_;
    while(!que.empty()){
      XY tmp = que.front();
      que.pop();
      if(tmp.x > 0){
        if(A[tmp.x - 1][tmp.y] == '.'){
          A[tmp.x - 1][tmp.y] = '#';
          XY hoge(tmp.x - 1, tmp.y);
          que_.push(hoge);
          cnt++;
        }
      }
      if(tmp.x < H - 1){
        if(A[tmp.x + 1][tmp.y] == '.'){
          A[tmp.x + 1][tmp.y] = '#';
          XY hoge(tmp.x + 1, tmp.y);
          que_.push(hoge);
          cnt++;
        }
      }
      if(tmp.y > 0){
        if(A[tmp.x][tmp.y - 1] == '.'){
          A[tmp.x][tmp.y - 1] = '#';
          XY hoge(tmp.x, tmp.y - 1);
          que_.push(hoge);
          cnt++;
        }
      }
      if(tmp.y < W - 1){
        if(A[tmp.x][tmp.y + 1] == '.'){
          A[tmp.x][tmp.y + 1] = '#';
          XY hoge(tmp.x, tmp.y + 1);
          que_.push(hoge);
          cnt++;
        }
      }
    }
    que = que_;
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


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

using namespace std;

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

	set<int> st;

	for(int i=0;i<n;i++)
	{
		int a;
		cin >> a;
		auto it=st.find(a);
		if(it==st.end())st.insert(a);
		else st.erase(a);
	}

	cout << st.size() << endl;
		


	
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
vector<P>edge[1005];
int ans[200005][2];
bool used[1005],r[1005][1005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b; scanf("%d%d",&a,&b);
		edge[a].pb(mp(i,b));
		
	}
	repn(i,n) SORT(edge[i]);
	repn(i,n){
		memset(used,0,sizeof(used));
		used[i] = 1;
		queue<int>que;
		rep(j,edge[i].size()){
			if(used[edge[i][j].sc]){
				ans[edge[i][j].fi][0] = 1;
			}
			else{
				que.push(edge[i][j].sc);
				while(!que.empty()){
					int q = que.front(); que.pop(); 
					if(used[q]) continue;used[q] = 1;
					rep(k,edge[q].size()){
						int to = edge[q][k].sc;
						if(used[to]) continue;
						que.push(to);
					}
				}
			}
		}
	}
	repn(i,n) reverse(edge[i].begin(),edge[i].end());
	repn(i,n){
		memset(used,0,sizeof(used));
		used[i] = 1;
		queue<int>que;
		rep(j,edge[i].size()){
			if(used[edge[i][j].sc]){
				ans[edge[i][j].fi][0] = 1;
			}
			else{
				que.push(edge[i][j].sc);
				while(!que.empty()){
					int q = que.front(); que.pop();
					if(used[q]) continue;used[q] = 1;
					rep(k,edge[q].size()){
						int to = edge[q][k].sc;
						if(used[to]) continue;
						que.push(to);
					}
				}
			}
		}
	}
	repn(i,n){
		memset(used,0,sizeof(used));
		r[i][i] = 1;
		queue<int>que;
		rep(j,edge[i].size()){
			que.push(edge[i][j].sc);
		}
		while(!que.empty()){
			int q = que.front(); que.pop();
			if(used[q]) continue;used[q] = 1;
			r[i][q] = 1;
			rep(k,edge[q].size()){
				int to = edge[q][k].sc;
				if(used[to]) continue;
				que.push(to);
			}
		}
	}
	repn(i,n){
		rep(j,edge[i].size()){
			int u = edge[i][j].sc,v = i;
			ans[edge[i][j].fi][1] = r[u][v];
		}
	}
	rep(i,m) printf((ans[i][0]^ans[i][1])==1?"diff\n":"same\n");
}

Measured memory_bytes: 6848
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
struct SegTree {
	int size;
	LL *dat,*lazy;
	SegTree(int n) {
		size=1;
		while(size<n) size*=2;
		dat=(LL*)malloc(sizeof(LL)*(size*2-1));
		fill(dat,dat+(size*2-1),(1LL<<31)-1);
		lazy=(LL*)malloc(sizeof(LL)*(size*2-1));
		fill(lazy,lazy+(size*2-1),-1);
	}
	void eval(int k) {
		if(lazy[k]==-1) return;
		dat[k]=lazy[k];
		if(k<size-1) lazy[k*2+1]=lazy[k],lazy[k*2+2]=lazy[k];
		lazy[k]=-1;
	}
	void update(int a,int b,int  x,int k,int l,int r) {
		eval(k);
		if(r<=a||b<=l) return;
		if(a<=l&&r<=b) {
			lazy[k]=x;
			eval(k);
		}else {
			update(a,b,x,k*2+1,l,(l+r)/2);
			update(a,b,x,k*2+2,(l+r)/2,r);
			dat[k]=min(dat[k*2+1],dat[k*2+2]);
		}
	}
	LL getmin(int a,int b,int k,int l,int r) {
		eval(k);
		if(r<=a||b<=l) return (1LL<<31)-1;
		if(a<=l&&r<=b) return dat[k];
		return min(getmin(a,b,k*2+1,l,(l+r)/2),getmin(a,b,k*2+2,(l+r)/2,r));
	}
};
int main() {
	int n,q;
	scanf("%d %d",&n,&q);
	SegTree S(n);
	for(int i=0;i<q;i++) {
		int type,s,t,x;
		scanf("%d",&type);
		if(type==0) {
			scanf("%d %d %d",&s,&t,&x);t++;
			S.update(s,t,x,0,0,S.size);
		}else {
			scanf("%d %d",&s,&t);t++;
			printf("%lld\n",S.getmin(s,t,0,0,S.size));
		}
	}
}

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

struct StrKind{
  string s;
  int cnt;
};

vector<struct StrKind> hyoujunkei(int n) {
  vector<struct StrKind> v;
  if (n == 1) {
    struct StrKind SK;
    SK.s = "a";
    SK.cnt = 1;
    v.push_back(SK);
    return v;
  }
  if (n == 2) {
    struct StrKind SK;
    SK.s = "aa";
    SK.cnt = 1;
    v.push_back(SK);
    SK.s = "ab";
    SK.cnt = 2;
    v.push_back(SK); 
    return v;
  }
  vector<struct StrKind> v_prev = hyoujunkei(n-1);
  //cout << n-1 << endl;
  for (int i = 0; i < v_prev.size(); i++) {
    char c = 'a';
    int cnt = v_prev[i].cnt;
    for (int j = 0; j < cnt+1; j++) {
      struct StrKind SK;
      string vis = v_prev[i].s;
      vis.push_back(c+j);
      SK.s = vis;
      if (j == cnt) SK.cnt = cnt+1;
      else SK.cnt = cnt;
      v.push_back(SK);
      //cout << "v:" << v.size() << endl;
    }
  }
  return v;
}

int main (void) {
  int N; 
  cin >> N;
  vector<struct StrKind> v;
  v = hyoujunkei(N);
  //cout << "v_size" << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i].s << endl;
  }
  return 0;
}

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

int main(){
	string str;
	char cha1,cha2;
	int i,a = 0,b = 0;

	cin >> str;
	cha1 = str[0];
	a++;

	for(i = 1; i < 4; i++){
		if(str[i] == cha1){
			a++;
		}
		else if(b == 0){
			cha2 = str[i];
			b++;
		}
		else if(str[i] == cha2){
			b++;
		}
	}

	if((a == 2) && (b == 2)){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

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

long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int main(){
	int r, g, b;
	
	cin >> r >> g >> b;
	
	int sum = r*100+g*10+b;
	
	if (sum%4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    for(int i = k; i < n; i++) {
        if (arr[i] > arr[i-k]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4780
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N;
    ll answer = MAX_N;

    cin >> N;

    rep(i, N + 1){
        ll sum6 = i;
        ll sum9 = N - i;
        ll cnt = 0;
        
        while (sum6 > 0){
            cnt += sum6 % 6;
            sum6 /= 6;
        }
        while (sum9 > 0){
            cnt += sum9 % 9;
            sum9 /= 9;
        }
        answer = min(answer, cnt);
    }

    cout << answer << endl;

    return 0;
}

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

#define sz(x) (int)x.size()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

const ll MOD = 998244353;

ll n, s;
vector<ll> a;
//dp[i][j] = pos, sum
vector<vector<ll>> dp;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> s;
    a.assign(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    dp.assign(n + 1, vector<ll>(s + 1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= s; ++j){
            dp[i + 1][j] += 2 * dp[i][j];
            dp[i + 1][j] %= MOD;
            if(j + a[i] <= s){
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= MOD;
            }
        }
    }
    cout << dp[n][s];
    return 0;
}

Measured memory_bytes: 73688
from collections import Counter
n = int(input())
s = list(input())
l = [0]*3
for i in s:
	if i == "R":
		l[0]+=1
	elif i == "G":
		l[1]+=1
	else:
		l[2]+=1
su = l[0]*l[1]*l[2]
for i in range(1,n+1):
	for j in range(i+2,n+1,2):
		kk = (i+j)//2
		if s[i-1]!=s[j-1] and s[i-1]!=s[kk-1] and s[j-1]!=s[kk-1]:
			su-=1
print(su)

Measured memory_bytes: 9504
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n, ans = 0;
	std::cin >> n;

	vll a = { 3,5,7 };
	vector<pair<ll, map<ll, bool>>> s;
	rep(i, 0, a.size()) {
		map<ll, bool> m;
		m[a[i]] = true;
		s.push_back(make_pair(a[i], m));
	}
	ll d = 10;
	while (true) {
		vector<pair<ll, map<ll, bool>>> t;
		rep(i, 0, a.size()) {
			rep(j, 0, s.size()) {
				auto m = s[j].second;
				m[a[i]] = true;
				auto tmp = s[j].first;
				tmp += d * a[i];
				if (tmp <= n) {
					if (m[3] && m[5] && m[7]) {
						ans++;
					}
				}
				else {
					outn(ans);
					return 0;
				}
				t.push_back(make_pair(tmp, m));
			}
		}
		d *= 10;
		s = t;
	}

	return 0;
}

Measured memory_bytes: 11420
from collections import deque
N, X, Y = map(int, input().split())

# G[v]: 頂点vに隣接する頂点list
# N: 頂点数
G = [[] for i in range(N)]
G[X - 1].append(Y - 1)
for i in range(N - 1):
    G[i].append(i + 1)
    G[i + 1].append(i)
# print(G)


def bfs_graph(start):
    # 隣接リストを食わせる
    dist = [-1] * N
    que = deque([start])
    dist[start] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in G[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            que.append(w)
    return dist


ans = [0] * N

for i in range(N - 1):
    # print(bfs(i))
    for ele in bfs_graph(i)[i + 1:]:
        ans[ele] += 1
for a in ans[1:]:
    print(a)


Measured memory_bytes: 4212
def divisors(n, sort=False):
    """
    nの約数をO(√n)で列挙する
    """
    d = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            d.append(i)
            if i != n // i:
                d.append(n//i)
    if sort:
        d.sort()
    return d


N = int(input())

ans = float('inf')
d = divisors(N, sort=True)
for i in range(len(d)):
    x, y = d[i], d[-i - 1]
    dist = abs(x - 1) + abs(y - 1)
    ans = min(ans, dist)
print(ans)


Measured memory_bytes: 39408
#include<iostream>
#include<utility>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<cstring>
#define ma 3000
#define mod 1000000007
#define ll long long int
using namespace std;
long double dp[ma+2][ma+2];
int main(){
	ll n=0;
	cin >> n;
	double p[n];
	long double ans=0;
	for(int i=0;i<n;i++){
		cin >> p[i];
	}
	memset(dp,0,sizeof(dp));
	dp[1][0]=1-p[0];
	dp[1][1]=p[0];
	for(int i=2;i<=n;i++){
		dp[i][0]=dp[i-1][0]*(1-p[i-1]);
		for(int j=1;j<=i;j++){
			dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1];
//			printf("%.11Lf ",dp[i][j]);
		}
//		cout << "\n";
	}
	for(int i=(n+1)/2;i<=n;i++){
		ans+=dp[n][i];
	}
	printf("%.11Lf",ans);
	return 0;
}

Measured memory_bytes: 141056
import numpy as np
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for _ in range(N)]

dp=np.full(10**5+10,10**18,int)
dp[0]=0
for w,v in WV:
  np.minimum(dp[v:], dp[:-v].copy()+w, out=dp[v:])
print(np.where(dp<=W)[0][-1])

Measured memory_bytes: 14928
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000
#define PI 3.14159265359

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    ll diff_sum = 0, amari = 0, cnt = 0;
    vector<ll> amaris;
    rep(i, N) { cin >> A[i]; }

    rep(i, N) { cin >> B[i]; }

    rep(i, N) {
        if (B[i] > A[i]) {
            diff_sum += B[i] - A[i];
            cnt++;
        } else {
            amari += A[i] - B[i];
            amaris.push_back(A[i] - B[i]);
        }
    }

    if (amari >= diff_sum) {
        sort(all(amaris), greater<ll>());
        if (diff_sum == 0) {
            cout << cnt << endl;
            return 0;
        }
        rep(i, amaris.size()) {
            diff_sum -= amaris[i];
            cnt++;
            if (diff_sum <= 0) {
                break;
            }
        }

        cout << cnt << endl;
        return 0;
    } else {
        cout << -1 << endl;
        return 0;
    }
}

Measured memory_bytes: 2936
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include <iomanip>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
//回答が整数の場合
int ans;
//整数値の入力
int n,m;
cin >> n >> m;
//行列の入力
tuple<int, int, int> data[m];
//年、県、順番

for (int i = 0; i < m; ++i) {
     int p, y;
        cin >> p >> y;
        data[i] = make_tuple(y, p, i);
}

sort(data,data+m);


int cnt[n + 1];
fill(cnt, cnt + n + 1, 0);
// 各県に今属している市の数

pair<int, int> id[m];
// 各市の(属する県、県の中で誕生した順番)

for (int i = 0; i < m; ++i) {
    int y, p, idx;
    tie(y, p, idx) = data[i];
    ++cnt[p];
    id[idx] = make_pair(p, cnt[p]);
}

for (int i = 0; i < m; ++i) {
    // setwで文字数、setfillで埋める文字を指定
    // iomanipをincludeする必要があるので注意
    cout << setw(6) << setfill('0') << id[i].first;
    cout << setw(6) << setfill('0') << id[i].second << endl;
}
return 0;
}

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

int main(){
    int data;
    scanf("%d",&data);

        if (data==25){
            printf("Christmas");
        }
        if (data==24) {
            printf("Christmas Eve");
        }
            if (data==23){
                printf("Christmas Eve Eve");
            }
            if (data==22){
                printf("Christmas Eve Eve Eve");
            }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)1e15
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	ll N, M;
	cin >> N >> M;

	vector<P> ans;
	P ansOne;

	ll idxFront = 1;
	ll idxBack = M + 2;
	ll cnt = 0;
	for (ll i = M; i >= 1; i--, cnt++) {
		if (IsEven(cnt)) {
			ansOne = { idxFront, idxFront + i };
			idxFront++;
		} else {
			ansOne = { idxBack, idxBack + i };
			idxBack++;
		}
		ans.emplace_back(ansOne);
	}

	REP(i, M) {
		ansOne = ans[i];
		cout << ansOne.first << " " << ansOne.second << endl;
	}
	return 0;
}


Measured memory_bytes: 5264
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    a,b,c = cin()
    if a/c <= b:
      print("Yes")
    else:
      print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
N = int(input())
A = list(map(int,input().split()))
out = 1
flag = 0
for i in range(N):
    out = out*A[i]
    if A[i]==0:
        flag=2
    if out>10**18:
        flag = 1
        out = 0
if flag==2:
    print(0)
elif flag==1:
    print(-1)
else:
    print(out)

Measured memory_bytes: 84372
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);
		
		int in = scanner.nextInt(2);
		
		int t = in;
		int c = 0;
		while (t > 0) {
			if ((t & 1) == 1) {
				c++;
			}
			t = t >> 1;
		}
		
		System.out.println(c);

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long a,b,c; cin>>a>>b>>c;
    long long d;
    d=(c-a-b);
    if(d>0){
        if((d*d-4*a*b)>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else cout<<"No"<<endl;
    /*else{
        if((d*d-4*a*b)<0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }*/
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  // 「1 の個数」「0 の個数」を交互に記録していく
  vector<ll> nums;
  if (s[0] == '0') nums.push_back(0);
  for (int i = 0; i < s.size();) {
    int j = i;
    while (j < s.size() && s[i] == s[j]) j++;
    nums.push_back(j - i);
    i = j;
  }
  if (s.back() == '0') nums.push_back(0);

  vector<ll> sums(nums.size() + 1, 0);
  sums[0] = nums[0];
  for (int i = 0; i < nums.size(); ++i) sums[i + 1] = sums[i] + nums[i];

  ll ans = 0;
  for (int i = 0; i < sums.size(); i += 2) {
    int r = i + 2 * k + 1;
    if (r >= sums.size()) r = sums.size() - 1;
    ans = max(ans, sums[r] - sums[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 2164
#include<iostream>
using namespace std;
typedef long long ll;
ll a[200005];
int main(){
	ll n;while(cin>>n){
	a[0]=0;
	ll sum=0;
	bool flag=true;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[1]!=0||a[i]>a[i-1]+1){
			//cout<<"-1"<<endl;
			flag=false;//break;
		}
		else if(a[i-1]!=0&&a[i]==(a[i-1]+1)){
				sum+=1;//(a[i]-a[i-1]);
				}
		else sum+=a[i];}
		if(flag==true)
		cout<<sum<<endl;
	else cout<<"-1"<<endl;
	}
return 0;}


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

typedef long long ll;
typedef vector<vector<int>> Graph;

int main() {
	int n, x, y; cin >> n >> x >> y;

	Graph G(n);
	for (int i = 0; i < (n - 1); i++) {
		G[i].push_back(i + 1);
		G[i + 1].push_back(i);
	}
	G[x - 1].push_back(y - 1);
	G[y - 1].push_back(x - 1);
	vector<vector<int>> dist(n, vector<int>(n, -1));

	for (int i = 0; i < n; i++)  dist[i][i] = 0;

	for (int i = 0; i < n; i++) {
		queue<int> que;
		que.push(i); 

		while (!que.empty()) {
			int v = que.front(); 
			que.pop();

			for (int nv : G[v]) {
				if (dist[i][nv] != -1) continue; 

				dist[i][nv] = dist[i][v] + 1;
				que.push(nv);
			}
		}
	}
	vector<int> ans(n, 0);
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			ans[dist[i][j]]++;
		}
	}

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


Measured memory_bytes: 16128
a, b = map(int, input().split())

i = 1

table_a = []
table_b = []

while i * i <= a:
    if a % i == 0:
        table_a.append(i)
        table_a.append(a // i)
    i += 1
i = 1
while i * i <= b:
    if b % i == 0:
        table_b.append(i)
        table_b.append(b // i)
    i += 1
a_b_and = list(set(table_b) & set(table_a))
a_b_and.sort()
i = 0
while i < len(a_b_and) - 1:
    j = i + 1
    while j < len(a_b_and):
        temp1 = a_b_and[i]
        temp2 = a_b_and[j]
        while temp2:
            temp1, temp2 = temp2, temp1 % temp2
        if temp1 != 1:
            a_b_and.pop(j)
        else:
            j += 1
    i += 1
print(len(a_b_and))

Measured memory_bytes: 5248
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;

#define INF 987654321
#define ll long long

int N;

int main()
{
	scanf("%d", &N);
	ll M = N;
	for (int i = N; i >= 1; i--)
	{
		ll sum = (ll)i * (i + 1) / 2;
		if (M > sum - i)
		{
			printf("%d\n", i);
			M -= i;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a_lst = list(map(int, input().split()))
for i in range(k, n):
    # 共通する部分を取り除くと差異は先頭か後尾なのでそこの差を判断
    if a_lst[i - n-k] < a_lst[i]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 31520
#include <bits/stdc++.h>
using namespace std;
int d[4];
int main(){
    int a;
    while(scanf("%d",&a),a){
        if(a%1111==0){
            printf("NA\n");
            continue;
        }
        int count=0;
        while(a!=6174){
            for(int i=0;i<4;i++){
                d[i]=a%10;
                a/=10;
            }
            std::sort(d,d+4);
            int b=0;
            for(int i=0;i<4;i++){
                b*=10;
                b+=d[i];
            }
            int c=0;
            for(int i=3;i>=0;i--){
                c*=10;
                c+=d[i];
            }
            a=c-b;
            count++;
        }
        printf("%d\n",count);
    }
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;

vector<int> c,s,f;

int main(){
    cin >> N;
    c.resize(N - 1);
    s.resize(N - 1);
    f.resize(N - 1);

    rep(i,0,N - 2) cin >> c[i] >> s[i] >> f[i];

    rep(j,0,N - 1){
    int now = 0;
    rep(i,j,N - 2){
        if(now < s[i]){
            now = s[i];
        }
        if(now % f[i] > 0){
            now += f[i] - (now % f[i]);
        }

        now += c[i];
    }
    cout << now << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  cin >> n;
  vi a(n);
  vi ans(n);
  rep(i, n) {
    cin >> a[i];
    ans[a[i]-1] = i+1;
  }

  rep(i, n) {
    cout << ans[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >>a[i];
  }
  sort(a,a+n);

  for(int i=n;i>=1;i--){
    if(a[n-i]>=i){
      cout << i <<endl;
      break;
    }
  }
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC147A()
{
	int A, B, C;
	cin >> A >> B >> C;
	int D = A + B + C;
	if (D >= 22)
	{
		cout << "bust" << endl;
	}
	else
	{
		cout << "win" << endl;
	}
}
int main()
{
	ABC147A();
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }

int n;
vector<int> a;

int main() {
    scanf("%d", &n);
    a.resize(n);
    rep(i, n) scanf("%d", &a[i]);

    auto b = a;
    sort(a.begin(), a.end());
    int x = a[n / 2];
    for (int i : b) {
        if (i < x) printf("%d\n", x);
        else printf("%d\n", a[n/2-1]);
    }

    return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		double[] point = new double[6];
		int n = scan.nextInt();
		for(int i = 0;i < n;i++){
			for(int j = 0;j < 6;j++){
				point[j] = scan.nextDouble();
			}
			double l = len(point[0],point[1],point[3],point[4]);
			double r = point[2] + point[5];
			if(l-r > 0.00001){
				System.out.println(0);
			}else{
				double t = point[2] - point[5];
				if(t > l){
					System.out.println(2);
				}else if(t < -l){
					System.out.println(-2);
				}else{
					System.out.println(1);
				}
			}
		}
	}
	public static double len(double x1,double y1,double x2,double y2){
		return Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	}
}

Measured memory_bytes: 20512
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int K, N; cin >> K >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    ll max_dist = 0;

    REP(i,N){
        ll res;
        if(i==0){
            res = min(A[N-1]-A[0], K-A[N-1]+A[0]);
        }else{
            res = min(A[i]-A[i-1], K-A[i]+A[i-1]);
        }
        if(res>=max_dist) max_dist = res;
        //cout << max_dist << endl;
    }

    cout << K - max_dist << endl;

    return 0;
}


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

int gcd(int x, int y){
    int g = max(x, y);
    int l = min(x, y);
    int r = g % l;
    if(r != 0){
        gcd(l, r);
    }else{
        return l;
    }
}

int main(){
    int N;
    int A[100000] = {};
    bool eflag = false;
    bool oflag = false;
    int mini = 1000000000;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    int n = A[0];
    for(int i = 1; i < N; i++){
        n = gcd(n,A[i]);
    }
    cout << n << endl;
}


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

using namespace std;

int main(void){
//	int num[3001] = {0};
	int time, tmp, ans = 0;
	cin >> time;
	for(int i = 1; i <= time; i++){
		cin >> tmp;
		ans += tmp;
	}
//	for(int i = 1; i <= time; i++){
//		cout << num[i] << " ";
//	}
//	puts("");
//	int ans = 0, tmp;
//	for(int i = 1; i <= 10000000; i++){
//		tmp = 0;
//		for(int j = 1; j <= time; j++){
//			int a;
//			a = i % num[j];
////			cout <<i << " : "<<"a = " << a << endl;
//			tmp += a;
////			if(tmp == 90)cout << "f(" << i << ")" << endl;
//		}
//		if(tmp > ans)ans = tmp;
//	}
	cout << ans - time << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  int N;
  cin >> N;

   for (int i = 0; i < 25; i++){
        for (int j = 0; j < 14; j++){
            //cout << 4*i + 7*j << endl;
            if (N == 4*i + 7*j){
                cout << "Yes" <<endl;
                return 0;
            }
       }
   } 
    cout << "No" << endl;   
  
}


Measured memory_bytes: 256