akhauriyash/Code-Regression huggingface dataset:
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  double P = 3.141592653;
  int n;cin>>n;
  cout << fixed << setprecision(10) << n*2*P << endl;
}

Measured memory_bytes: 3800
#pragma GCC optimize(2)
#include<iostream>
using namespace std;
bool a[200005],b[200005];
int main(){
	int n,m;
	cin>>n>>m;
	int u1=0,u2=0;
	for(int i=0;i<m;i++){
		int q,w;
		cin>>q>>w;
		if(w==n&&q==1){
			cout<<"POSSIBLE";
			return 0;
		}
		if(q==1){
			a[w]=1;
		}
		if(w==n){
			b[q]=q;
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]==1&&b[i]==1){
			cout<<"POSSIBLE";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 640
// https://atcoder.jp/contests/abc154/tasks/abc154_c

#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;


    set<int> have;
    for(int i = 1; i <= N; i++) {
        int x;
        cin >> x;

        if(have.find(x) != have.end()) {
            cout << "NO" << endl;
            return 0;
        } else {
            have.emplace(x);
        }
    }

    cout << "YES" << endl;


}

Measured memory_bytes: 9600
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <fstream>

using namespace std;
int top, S[1000];

void push(int x){
    top++;
    S[top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){

    int a, b;
    top = 0;
    char s[100];

    while(cin >> s){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(b + a);
        } else if(s[0] == '-'){
            a = pop();
            b = pop();
            push(b - a);
        } else if(s[0] == '*'){
            a = pop();
            b = pop();
            push (b * a);
        } else {
            push (atoi(s));
        }
    }

    printf("%d\n", pop());

    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()


int n, m, r, d[205][205], ans = IINF;
vector<int> rs;

int main() {
    
    cin >> n >> m >> r;
    rs.resize(r);
    REP(i,r) cin >> rs[i];
    REP(i,n)fill(d[i],d[i]+n,IINF/2);
    REP(i,m){
        int a, b, c;
        cin >> a >> b >> c;
        a--,b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    
    REP(k,n)REP(i,n)REP(j,n){
        d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    }

    SORT(rs);
    while(1){
        int tmp = 0;
        REP(i,r-1){
            tmp += d[rs[i]-1][rs[i+1]-1];
        }
        ans = min(ans, tmp);
        if(!next_permutation(ALL(rs)))break;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int p_set,i; //p_set 最初の石の数　i 立候補者の数

	cin>>i>>p_set;
	while(i!=0 || p_set!=0){
		int n[50]={0},p=p_set;
		long int turn=0;
		while(1){
			if(p>0){
				n[turn%i]++;
				p--;
				if(p==0 && n[turn%i]==p_set){
					cout<<turn%i<<endl;
					break;
				}
			}else if(p==0){
				p=n[turn%i];
				n[turn%i]=0;
			}
			turn++;
		}
	cin>>i>>p_set;
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
int main(void){
    long n, a;
    long max, min, sum=0;
    scanf("%ld", &n);
    for(int i=1; i<=n; i++) {
        scanf("%ld", &a);
        if(i==1)
            max=min=a;
        if(max<a)
            max=a;
        else if(min>a)
            min=a;
        sum=sum+a;
    }
    printf("%ld %ld %ld\n",min, max, sum);
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Z, W;
  cin >> N >> Z >> W;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  if (N == 1) {
    cout << abs(A[0] - W) << '\n';
  } else {
    cout << max(abs(A[N - 1] - W), abs(A[N - 2] - A[N - 1])) << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ0100
{
    class Program
    {
        static void Main()
        {
            ReadInputs()
                .Select(
                    s =>
                        s.GroupBy(r => r.Id,
                            (id, records) => new {Id = id, Sales = records.Sum(r => r.UnitPrice*r.Quantity)})
                            .Where(t => t.Sales >= 1000000)
                            .Select(t => t.Id.ToString())
                            .DefaultIfEmpty("NA"))
                .ForEach(results => results.ForEach(Console.WriteLine));

        }

        private static IEnumerable<IEnumerable<Record>> ReadInputs()
        {
            
            IEnumerable<Record> dataSet;
            while ((dataSet = ReadDataSet()) != null)
            {
                yield return dataSet;
            }

        }

        private static IEnumerable<Record> ReadDataSet()
        {
            var count = int.Parse(Console.ReadLine() ?? "0");
            return count == 0 ? null : ReadDataSetImpl(count);
        }

        private static IEnumerable<Record> ReadDataSetImpl(int count)
        {
            while (count-- > 0)
            {
                // ReSharper disable once PossibleNullReferenceException
                var data = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
                yield return new Record {Id = data[0], UnitPrice = data[1], Quantity = data[2]};
            }
        }
    }

    class Record
    {
        public long Id { get; set; }
        public long UnitPrice { get; set; }
        public long Quantity { get; set; }
    }

    static class EnumerableExtensions
    {
        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
        }
    }
}

Measured memory_bytes: 10704
#include <stdio.h>

int main(void) {
	int i,x;
	i=0;
	for(i=0;i<10000;i++)
		while(1){
		scanf("%d",&x);
		if(x==0) break;
		i++;
		printf("Case %d: %d\n",i,x);
		}
	
	
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
int n,m;
int w[200002],t[200002];
int x[16],y[16];

int check(int idx,int mx,int *a){
  mx+=a[idx];
  int L=idx+1,R=m+1,M;
  while(L<R){
    M=(L+R)/2;
    if(a[M]>mx) R=M;
    else L=M+1;
  }
  return L-1;
}

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

  for(int i=1;i<=m;i++){
    cin>>w[i]>>t[i];
    w[i]+=w[i-1],t[i]+=t[i-1];
  }
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];

  int dp[1<<15]={};
  for(int i=0;i<(1<<n);i++)
    for(int j=0;j<n;j++){
      if((i&(1<<j)))continue;
      int res=min(check(dp[i],x[j],w),check(dp[i],y[j],t));
      dp[i|(1<<j)]=max(dp[i|(1<<j)],res);
    }
  cout << dp[(1<<n)-1]<<endl;
  return 0;
}

Measured memory_bytes: 2856
#include <bits/stdc++.h>
 
using namespace std;
#define sz(x) (int)(x).size()
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long
const int N=3e5+5,MOD=1e9+7;
 
int n,s;
int main()
{	
 	
 	scanf("%d %d",&n,&s);

 	std::vector<vector<ll>> dp(n,vector<ll>(s+1));
 	for(int i=0;i<n;i++){
 		int w,x;
 		scanf("%d %d",&w,&x);
 		if(i)
 			for(int j=0;j<=s;j++){
 				if(j-w>=0)
 					dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+x);
 				else 	
 					dp[i][j]=dp[i-1][j];
 			}
 		else
 			for(int j=w;j<=s;j++)dp[i][j]=x;
 	}

 	printf("%lld\n",dp[n-1][s]);
}
 

Measured memory_bytes: 79488
N = int(input())
L = [-1] * N
a = [int(i)-1 for i in input().split()]
for i in range(N+1):
    if L[a[i]] == -1:
        L[a[i]] = i
    else:
        x1, x2 = (min(L[a[i]], i), max(L[a[i]], i))
A = x1
B = x2-x1-1
C = N-x2

def power(a, b):
	if b == 0:
		return 1
	elif b == 1:
		return a % 1000000007
	elif b % 2 == 0:
		return (power(a, b//2) ** 2) % 1000000007
	else:
		return (power(a, b//2) ** 2 * a) % 1000000007
 
def divide(a, b):
	return (a * power(b, 1000000005)) % 1000000007


#階乗の逆元を求める
fac_lim = N
fac = [None]*(fac_lim+1)
fac[0] = 1
for i in range(fac_lim):
    fac[i+1] = fac[i] * (i+1)
    fac[i+1] = fac[i + 1] % 1000000007

fac_inv = [None]*(fac_lim+1)
fac_inv[fac_lim] = power(fac[fac_lim], 1000000005)
for i in range(fac_lim, 0, -1):
    fac_inv[i-1] = (fac_inv[i] * i)  % 1000000007

def conv(a, b):
    if a >= b:
        return (fac[a] * fac_inv[a-b] * fac_inv[b]) % 1000000007
    else:
        return 0

N1_conv = [0]*(N+2)
AC_conv = [0]*(N+2)
for i in range(N+2):
    N1_conv[i] = conv(N-1, i)
for i in range(N+2):
    AC_conv[i] = conv(A+C, i)
for K in range(1, N+2):
    ans = 0
    ans += N1_conv[K]
    if K>0:
        ans += AC_conv[K-1]
        ans += 2 * N1_conv[K-1]
        ans -= 2 * AC_conv[K-1]
    if K>1:
        ans += N1_conv[K-2]
    ans %= 1000000007
    print(ans)

Measured memory_bytes: 27872
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

ll encode(const vector<int> &vec){
  ll res = 0;
  for (int i = 0; i < 9; i++){
    res = res * 10 + vec[i];
  }
  return res;
}

void decode(ll code, vector<int> &vec){
  for (int i = 0; i < 9; i++){
    vec[8 - i] = code % 10;
    code /= 10;
  }
}

int main(){
  ios::sync_with_stdio(false);

  int ch, cv;
  while (cin >> ch >> cv && ch + cv){
    map<ll, int> dist;
    vector<int> start(9);
    vector<int> goal(9);
    vector<int> state(9);

    REP(i, 9) cin >> start[i];
    REP(i, 9) cin >> goal[i];
    
    priority_queue<pair<int, ll> > que;

    ll start_code = encode(start);
    que.push(make_pair(0, start_code));
    dist[start_code] = 0;

    while (!que.empty()){
      int c    = -que.top().first;
      ll  code = que.top().second;
      que.pop();

      decode(code, state);
      
      if (goal == state){
        cout << c << endl;
        break;
      }

      if (c > dist[code]){
        continue;
      }

      int p = find(ALL(state), 0) - state.begin();
      int d[] = {-3, -1, 1, 3};

      for (int i = 0; i < 4; i++){
        int nc = c + (abs(d[i]) == 1 ? ch : cv);
        int np = (p + d[i] + 9) % 9;

        swap(state[p], state[np]);

        ll next_code = encode(state);
        if (dist.count(next_code) == 0 || dist[next_code] > nc){
          dist[next_code] = nc;
          que.push(make_pair(-nc, next_code));
        }
        
        swap(state[np], state[p]);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 25680
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#include <iostream>

using namespace std;

int main(){

    int A, B, C;
    cin >> A >> B >> C;
    if(C >= A && C <= B){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
  // ここにプログラムを追記
  int a,b,c_int;
  double c_dou;
  cin >> a >> b;
  c_dou = (a + b) / 2.0 + 0.6;
  c_int = c_dou;
  
  cout << c_int << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a,ll b)
{
    if(a>b)swap(a,b);
    if(a==0)return b;
    return gcd(b%a,a);
}
const int N=1000005;
ll isp[N],p[N],tot;
void init()
{
    for(int i=2;i<N;++i)
    {
        if(isp[i]==0)
        {
            p[tot++]=i;
            for(int j=i+i;j<N;j+=i)isp[j]=i;
        }
    }
}
int main()
{
    init();
    ll a,b;
	scanf("%lld %lld",&a,&b);
	ll g=gcd(a,b);
	int ans=1;
	for(int i=0;i<tot;++i)
        if(g%p[i]==0)
        {
            ans++;
            while(g%p[i]==0)g/=p[i];
        }
    if(g>1)ans++;
    cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 10368
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <cmath>

#include <limits.h>

using namespace std;

typedef long long ll;

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

int main(void) {
    double R;
    cin >> R;

    double ans = 2 * R * M_PI;
    printf("%.3f\n", ans);
    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,K;
  cin>>N>>K;
  vector<int>p(N);
  for(int i=0;i<N;i++)cin>>p[i];
  sort(rng(p));
  int ans=0;
  for(int i=0;i<K;i++)ans+=p[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3656
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Tuple (swap)
import Data.List (sortBy)
import Data.Function (on)
import qualified Data.IntMap as IM

main :: IO ()
main = do
  [n, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    maxSP :: [(Int, Int)] -> Int
    maxSP dts = snd . snd . snd . foldr step ((cs0, l0), (sf, ((dp0, tp0), sp0))) $ pf
      where
        (pf, sf) = splitAt k dts :: ([(Int, Int)], [(Int, Int)])
        cs0 = IM.fromListWith (+) . map (flip (,) 1 . snd) $ pf :: IM.IntMap Int
        l0 = n - length pf :: Int
        dp0 = sum . map fst $ pf :: Int
        tp0 = IM.size cs0 :: Int
        sp0 = dp0 + tp0 ^ 2 :: Int
        step :: (Int, Int) -> ((IM.IntMap Int, Int), ([(Int, Int)], ((Int, Int), Int))) -> ((IM.IntMap Int, Int), ([(Int, Int)], ((Int, Int), Int)))
        step _ r@((_, 0), _)                                                        = r
        step (_, t) r@((cs, _), _) | cs IM.! t == 1                                 = r
        step dt ((cs, l), ((_, t') : dts', dptpsp)) | IM.findWithDefault 0 t' cs /= 0 = step dt ((cs, pred l), (dts', dptpsp))
        step (d, t) ((cs, l), ((d', t') : dts', ((dp, tp), sp)))                          = ((cs', pred l), (dts', ((dp', tp'), sp')))
          where
            cs' = IM.insert t' 1 . IM.adjust pred t $ cs :: IM.IntMap Int
            dp' = dp - d + d' :: Int
            tp' = succ tp :: Int
            sp' = max sp (dp' + tp' ^ 2) :: Int
  tds <- sequence . replicate n $ unsafeListToPair . map unsafeTextToInt . T.words <$> T.getLine :: IO [(Int, Int)]
  let
    dts = sortBy (flip compare `on` fst) . map swap $ tds :: [(Int, Int)]
  print . maxSP $ dts

unsafeListToPair :: [a] -> (a, a)
unsafeListToPair [x, y] = (x, y)

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


Measured memory_bytes: 58748
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

int main(){
	//my name is Veex
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	map<int,bool> mp;
	int sum=0;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		if(!mp[a]){
			mp[a]=true;
			sum++;
		}
	}
	if((n-sum)%2==0)
		cout<<sum;
	else
		cout<<sum-1;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse4")
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
 
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
 
typedef long long LL;
typedef pair<int, int> PII;

const int MAXN = 1 << 18;
const int MAXL = 1 << 20;

string s[MAXN];
vector<vector<int> > mask;
int t[MAXL][26], dp[MAXL][26];
int sz = 1;
int idxes[MAXN];
LL ans;

void add(int v, int idx, int pos)
{
	if(pos == SZ(s[idx]) - 1)
		ans += dp[v][s[idx][pos] - 'a'];
	FOR(j, 0, 26)
		dp[v][j] += (mask[idx][pos] >> j) & 1;
	int& to = t[v][s[idx][pos] - 'a'];
	if(to == 0)
		to = ++sz;
	if(pos + 1 < SZ(s[idx]))
		add(to, idx, pos + 1);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	mask.assign(n, vector<int>());
	FOR(i, 0, n)
	{
		cin >> s[i];
		reverse(ALL(s[i]));
		mask[i].assign(SZ(s[i]), 0);
		RFOR(j, SZ(s[i]), 0)
		{
			mask[i][j] = (j + 1 == SZ(s[i]) ? 0 : mask[i][j + 1]) | (1 << (s[i][j] - 'a'));
		}
	}
	iota(idxes, idxes + n, 0);
	sort(idxes, idxes + n, [=](int i, int j) {return SZ(s[i]) > SZ(s[j]);});
	FOR(i, 0, n)
	{
		add(1, idxes[i], 0);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 219520
ABCDE = [int(input()) for i in range(5)]
ABCDE.sort(key = lambda x : x % 10 if x % 10 != 0 else 10)

ans = 0
for i, element in enumerate(ABCDE):
    if i == 0:
        ans += element
    else:
        wait = 10 - element % 10 if element % 10 != 0 else 0
        ans += element + wait


print(ans)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(ll a, ll b){
    vector<bool> ok(3);
    ok[a - 1] = ok[b - 1] = true;
    rep(i,3) if(!ok[i]) cout<<i + 1<<endl;
}

int main(){
    ll a;
    scanf("%lld",&a);
    ll b;
    scanf("%lld",&b);
    solve(a, b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll x,res=0;
  cin>>x;
  ll temp1=x/500;
  ll mod1=x%500;
  res+=temp1*1000;
  ll temp2=mod1/5;
  res+=temp2*5;
  cout<<res;
}

Measured memory_bytes: 3584
#include<stdio.h>

int main(void)
{
  int n = 0;
  int a[100] = {0};
  int buffer = 0;
  int i, j;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &a[i]);

  //降順にソート
  for(i=0; i<n-1; i++){
    for(j=i+1; j<n; j++){
      if(a[i] < a[j]){
	        buffer = a[i];
	        a[i] = a[j];
          a[j] = buffer;
      }
    }
  }

  int ci = 0;//カレントインデックス
  int evenS = 0;
  int oddS = 0;

  while(ci <= n-1){
    if(ci%2 == 0){
      evenS += a[ci];
    }else{
      oddS += a[ci];
    }
    ci++;
  }

  printf("%d\n", evenS-oddS);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int h, w;
  cin >> h >> w;
  string a[h];
  for(int i=0; i<h; i++) cin >> a[i];
  
  string b[2*h];
   for(int i=0; i<h; i++){
     b[2*i] = a[i];
     b[2*i+1] = a[i];
   }
  
  
  for(int i=0; i<2*h; i++) cout << b[i] << endl;

}

Measured memory_bytes: 256
import math

N, A, B = map(int, input().split())
h = [int(input()) for i in range(N)]

def C(T):
    t = 0
    for i in range(N):
        if h[i] > B*T:
            t += math.ceil((h[i]-B*T)/(A-B))
    if t <= T:
        return True
    else:
        False
l, r = 0, 10**18
while r - l > 1:
    mid = (l+r) // 2
    if C(mid):
        r = mid
    else:
        l = mid


print(r)

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

// 自力で解けた。
const ll INF = 1e18;

int main() {
  int h, w;
  cin >> h >> w;

  vector<vector<ll> > C(10, vector<ll>(10, 0));
  rep(i, 10) rep(j, 10) cin >> C[i][j];

  vector<vector<int> > A(h, vector<int>(w, 0));
  rep(i, h) rep(j, w) cin >> A[i][j];

  rep(k, 10) {
    rep(i, 10) {
      rep(j, 10) {
        C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
      } 
    } 
  }

  ll ans = 0;
  rep(i, h) rep(j, w) {
    if (A[i][j] == -1) continue;
    ans += C[A[i][j]][1]; 
  }

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


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

int main()
{
  int n;
  cin >> n;
  int v[n],c[n];
  for (int i = 0; i < n; ++i)
  {
    cin >> v[i];
  }
  for (int i = 0; i < n; ++i)
  {
    cin >> c[i];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    if (0 < v[i] - c[i])
    {
      ans += v[i] - c[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int x,y,k,i,j,v;

  scanf("%d%d",&x, &y);


  if(x>=y){
    if(x==y) v=x;

    k=x%y;
      for(i=1;i<=k;i++){
	if(y%i==0 && k%i==0) v=i;
    }
  }
  
  else if(y>x){
    k= y%x;
    for(i=1;i<=k;i++){
      if(x%i==0 && k%i==0) v=i;
    }
  }

  printf("%d\n",v);

  return 0;
}



Measured memory_bytes: 2068
def main():
    n=int(input())
    xy = sorted([list(map(int, input().split())) for _ in range(n)])
    xy.sort()
    ans=n
    for i in range(n):
        [x1,y1]=xy[i]
        for j in range(n-1):
            [x2,y2]=xy[j]
            if i!=j:
                [p,q]=[x1-x2,y1-y2]
                cnt=0
                for k in range(n-1):
                    for l in range(k+1,n):
                        [x,y]=[ xy[k][0]-xy[l][0],xy[k][1]-xy[l][1] ]
                        if [x,y]==[p,q] or [x,y]==[-p,-q]:
                            cnt+=1
                ans=min(ans,n-cnt)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 43372
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int m=1e9+7;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fastio
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int x1[n];
    for(int i=0;i<n;++i) cin>>x1[i];
   	int y1[m];
   	for(int i=0;i<m;++i) cin >>y1[i];
   	sort(x1,x1+n);
   	sort(y1,y1+m);
   	if(x1[n-1]<y1[0] && x1[n-1]>x && x1[n-1]<y) cout<<"No War";
   	else cout<<"War";
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=1e5,MAX_M=1e5;
ll N,M,A[MAX_N];
typedef pair<ll,ll> P;
P card[MAX_M];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>M;
	REP(i,N)cin>>A[i];
	sort(A,A+N);
	REP(i,M){
		ll b,c;
		cin>>b>>c;
		card[i]=P(c,b);
	}
	sort(card,card+M);
	reverse(card,card+M);
	ll inx=0,j=0;
	while(inx<N && j<M){
		if(card[j].second==0){
			j++;
		}else if(card[j].first>A[inx]){
			A[inx]=card[j].first;
			card[j].second--;
			inx++;
		}else{
			break;
		}
	}
	ll ans=0;
	REP(i,N){
		ans+=A[i];
	}
	cout<<ans<<endl;
}	

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,a,b;
  cin>>n>>a>>b;
  vector<int> q;
  rep(i,n){
    int num;
    cin>>num;
    q.push_back(num);
  }
  sort(q.begin(),q.end() );
  int l=0,r=1000000000;
  int mid=(l+r)/2;
  while(l!=r){
    int cnt=0;
    int num=b*mid;
    rep(i,q.size() ){
      cnt+=max((int)0,((q[i]-num)+(a-b)-1)/(a-b));
    }
    if(cnt>mid) l=mid+1;
    else r=mid;
    mid=(l+r)/2;
  }
  
  cout<<mid<<endl;
  return 0;
}


Measured memory_bytes: 4248
#include <iostream>

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  if( N > M ) swap(N,M);
  if( N + 1 < M ){
    cout << 0 << endl;
    return 0;
  }
  unsigned long long c = 1;

  for( unsigned long long i = 1 ; i <= N ; ++i ){

    c = ( c * i*i  ) % 1000000007;
  }
  if( N < M ) c = c * M % 1000000007;
  else c = c * 2 % 1000000007; 
  cout << c << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools

def s_raw():
    return input().rstrip("\r")

def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return list(map(int, ss_raw()))


INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n,es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx]!=v_cost[idx] else v_cost[idx] for idx in range(n)]
    return v_cost
    
def ZAlgo(s):
    l = len(s)
    A = [0]*l
    i =1
    j =0
    A[0]=l
    while i<l:
        while i+j<l and s[j] == s[i+j]:
            j+=1
        if j==0:
            i+=1
            continue
        A[i]=j
        k=1
        while (i+k<l) and (k+A[k]<j):
            A[i+k] =A[k]
            k+=1
        i+=k
        j-=k
    return A


def main():
    A,B = ints_raw()
    if A>0 and A<10 and B>0 and B<10:
        return A*B
    else:
        return -1


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(a)  (a).begin(),(a).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n), b(n), c(n);
    REP(i, n) cin >> a[i]; 
    REP(i, n) cin >> b[i];
    REP(i, n) cin >> c[i];
    VSORT(a);
    VSORT(b);
    VSORT(c);
    vll ab(n), bc(n);
    REP(i, n) ab[i] = lower_bound(all(a), b[i]) - a.begin();
    REP(i, n) bc[i] = lower_bound(all(b), c[i]) - b.begin();

    vll s(n + 1, 0);
    REP(i, n) s[i + 1] = s[i] + ab[i];
    ll res = 0;
    REP(i, n) res += s[bc[i]];

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4992
N = int(input())
A = list(map(int, input().split()))

S = sum(A)
x1 = S - 2 * sum([A[i] for i in range(len(A)) if i % 2 == 1])
ansList = [x1]
for i in range(1, N):
    tmp = 2 * A[i-1] - ansList[-1]
    ansList.append(tmp)
ansList = [str(a) for a in ansList]
ans = ' '.join(ansList)
print(ans)

Measured memory_bytes: 18504
import java.util.*;

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

	while(sc.hasNext()){
	    String[] line = (sc.next()).split(",");
	    double[] x = new double[4];
	    double[] y = new double[4];
	    for(int i=0; i<4; i++){
		x[i] = Double.parseDouble(line[i*2]);
		y[i] = Double.parseDouble(line[i*2+1]);
	    }
	    
	    double sikaku = getMenseki(4,x,y);

	    double[] xx = new double[3];
	    double[] yy = new double[3];
	    int count = 0;
	    boolean hantei = true;
	    for(int i=0; i<4; i++){
		if(hantei){
		    xx = new double[3];
		    yy = new double[3];
		    count = 0;
		    for(int j=0; j<4; j++){
			if(j!=i){
			    xx[count] = x[j];
			    yy[count] = y[j];
			    count++;
			}
		    }
		    double sankaku = getMenseki(3,xx,yy);
		    //System.out.println(i+" "+sankaku+" "+sikaku);
		    if(sankaku>sikaku){hantei = false;}
		}
	    }
	    String ans = "NO";
	    if(hantei){ans = "YES";}
	    System.out.println(ans);
	}
    }
    
    public static double getMenseki(int n,double[] x, double[] y){
	double[] pro = new double[n];
	for(int i=0; i<n-1; i++){
	    pro[i] = (x[i]-x[i+1])*(y[i]+y[i+1]);
	}
	pro[n-1] = (x[n-1]-x[0])*(y[n-1]+y[0]);
	double ans = 0;
	for(int i=0; i<n; i++){
	    ans += pro[i];
	}
	if(ans<0){ans = (-1)*ans;}
	return (ans/2.0);	
    }
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&a==c){
    cout<<1<<endl;
    return 0;
  }else if(a==b||a==c||c==b){
    cout<<2<<endl;
    return 0;
  }
  cout << 3 <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define re register
using namespace std;
const int maxn=100+10;
const int maxV=1e6+10;
const int Mll=1e10+10;
template<typename T> void read(T &x){
	T f=1;x=0;
	char c=getchar();
	while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	x*=f;
}
ll n,W,V=100010;
ll w[maxn],v[maxn];
ll f[maxV];
int main(){
	read(n);read(W);
	for(re int i=1;i<=n;i++){
		read(w[i]);read(v[i]);
	}
	for(re int i=1;i<=V;i++) f[i]=Mll;
	f[0]=0;
	for(re int i=1;i<=n;i++){
		for(re int j=V;j>=v[i];j--){
			f[j]=min(f[j],f[j-v[i]]+w[i]);
		}
	}
	for(re int i=V;i>=1;i--){
		if(f[i]<=W){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
import Control.Monad
import Control.Applicative
import Data.List

main = do
  xs <- input read :: IO [Double]
  mapM_ print $ solve xs

solve :: [Double] -> [Double]
solve xs = map f xs
  where f x = x * 7.814814814814814

input :: (String -> a) -> IO [a]
input f = map f . lines <$> getContents 

Measured memory_bytes: 4328
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
using namespace std;



void solve(long long N, long long L){
    vector <long long> tastes;
    for(auto i=0ll; i<N; i++)tastes.push_back(L+i);
    auto rem = *min_element(tastes.begin(), tastes.end(), [](auto &a, auto &b){
       return abs(a) < abs(b);
    });

    cout << accumulate(tastes.begin(), tastes.end(), 0ll)-rem << endl;
}

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


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

void Main()
{
    long n;
    cin >> n;
    long a = 26;

    list<char> s;
    for (int i = 0; i < 12; i++)
    {
        n = n - 1;
        long m = n%a;
        s.push_front((char)('a'+m));
        n = n / a;
        if(n <= 0) break;
    }
    for(auto i: s)
        cout << i;
    cout << endl;

    // long r = 0;
    // for(auto i: s)
    // {
    //     r = r*a + (i - 'a' + 1);
    // }
    // cout << r << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
class LunLunNumber:string
{
public:
	LunLunNumber(int n)
	{
		string x=to_string(n);
		for(auto&i:x)i-='0';
		operator+=(x);
	}
	void next()
	{
		int i;
		for(i=size()-1;i;i--)
		{
			if(at(i-1)>=at(i)&&at(i)!=9)
			{
				break;
			}
		}
		if(i)
		{
			at(i)++;
			for(i++;i<size();i++)at(i)=max(0,at(i-1)-1);
		}
		else
		{
			if(at(i)==9)
			{
				fill(begin(),end(),0);
				operator+=((char)0);
				at(0)=1;
			}
			else
			{
				at(i)++;
				for(i++;i<size();i++)at(i)=max(0,at(i-1)-1);
			}
		}
	}
	friend ostream&operator<<(ostream&cout,const LunLunNumber&n);
};
ostream&operator<<(ostream&cout,const LunLunNumber&n)
{
	for(int i=0;i<n.size();i++)cout<<(char)(n[i]+'0');
	return cout;
}
int main()
{
	LunLunNumber x(0);
	int n;
	cin>>n;
	while(n--)x.next();
	cout<<x;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    int r4 = 0, r2 = 0, r = 0;
    rep(i, 0, n) {
        int a;
        cin >> a;
        if (a % 4 == 0)
            r4++;
        else if (a % 2 == 0)
            r2++;
        else
            r++;
    }
    if (r2 == 0) {
        cout << (r4 + 1 >= r ? "Yes" : "No") << endl;
    }
    else {
        cout << (r4 >= r ? "Yes" : "No") << endl;
    }

    

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int w = sc.nextInt();
      int[] a = new int[w+1];
      for(int i = 1; i < w+1; i++) a[i]=i;
      int n = sc.nextInt();
      for(int i = 0; i < n; i++){
          String[] s = sc.next().split(",");
          int l = Integer.parseInt(s[0]);
          int r = Integer.parseInt(s[1]);
          int exchange = a[l];
          a[l] = a[r];
          a[r] = exchange;
      }
      for(int i = 1; i < w+1; i++)System.out.println(a[i]);
  }
}

Measured memory_bytes: 26140
#include <cstdio>
#include <algorithm>
#include <queue>
#define maxn 805
#define INF 23333333
#define hh(x) (((x)>0)?((x)-1)/K+1:0)
using namespace std;

int ans=INF,sum,H,W,K,x1,y1,f[maxn][maxn][4];
int vis[maxn][maxn],fx[4][2]={{-1,0},{0,-1},{1,0},{0,1}};
int tmp,xxx,yyy,x,y,dep;
char map[maxn][maxn];

struct xx
{
	int x,y,dep;
};
queue <xx > q;
inline int check(int x,int y)
{
	return 1<=x&&x<=H&&
	       1<=y&&y<=W&&
		   map[x][y]!='#';
}

inline void bfs()
{
	q.push((xx){x1,y1,0});
	while (!q.empty())
	{
		xx now=q.front();q.pop();
		x=now.x,y=now.y,dep=now.dep;
		if (dep>K||vis[x][y]) continue;
		vis[x][y]=1;
		tmp=min(min(H-x,W-y),min(x-1,y-1));
		tmp=(tmp+K-1)/K;
		if (tmp+1>ans) continue;
		ans=min(ans,tmp+1);
	//printf("-- x:%d y:%d dep:%d tmp+1:%d\n--",x,y,dep,tmp+1);
		for (int i=0;i<4;++i)
		{
			xxx=x+fx[i][0];
			yyy=y+fx[i][1];
			if (check(xxx,yyy))
				  q.push((xx){xxx,yyy,dep+1});
		}
	}
	return ;
}

int main()
{
	scanf("%d%d%d",&H,&W,&K);
	for (int i=1;i<=H;++i) scanf("%s",map[i]+1);
	for (int i=1;i<=H;++i)
	  for (int j=1;j<=W;++j)
	  	  if ('S'==map[i][j]) x1=i,y1=j;
	if (x1==1||x1==H||y1==1||y1==W) ans=0;
	else bfs();
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
void PDF(double r)
{
    double pi = 3.1416;
    double area;
    area = 2 * pi * r;
    cout << area << endl;
}
int main()
{
    double n,i,j,l;
    cin >> n;
    PDF(n);
    return 0;
}


Measured memory_bytes: 3784
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
ctr = min(a[0], b[0])
b[0] -= ctr

for i in range(1, n):
    ctr += min(a[i], b[i - 1])
    a[i] -= min(a[i], b[i - 1])
    ctr += min(a[i], b[i])
    b[i] -= min(a[i], b[i])

ctr += min(a[n], b[n - 1])

print(ctr)

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

int main()
{
  int R, G, B, N, cnt = 0;
  cin >> R >> G >> B >> N;
  for (int r = 0; r <= N / R; r++)
  {
    for (int g = 0; g <= (N - r * R) / G; g++)
    {
      if ((N - (R * r + G * g)) % B == 0)
        cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		int n = Integer.parseInt(br.readLine());

		int c[] = new int[n - 1];
		int s[] = new int[n - 1];
		int f[] = new int[n - 1];

		for (int i = 0; i < n - 1; i++) {
			String str[] = br.readLine().split(" ");

			c[i] = Integer.parseInt(str[0]);
			s[i] = Integer.parseInt(str[1]);
			f[i] = Integer.parseInt(str[2]);
		}

		for (int i = 0; i < n; i++) {
			int t = 0;
			for (int j = i; j < n - 1; j++) {
				int k = (int) Math.max(0.0, Math.ceil((double) (t - s[j]) / f[j]));
				t = s[j] + k * f[j];
				t += c[j];
			}
			System.out.println(t);
		}
	}

}


Measured memory_bytes: 22596
import math

def is_prime(n):
    if(n == 1):
        return False
    
    for i in range(2, int(math.sqrt(n))+1):
        if(n%i == 0):
            return False
        
    return True

sosu = []
for i in range(1, 1001):
    if(is_prime(i)):
        sosu.append(i)    

N = int(input())
mod = 10**9+7
x = math.factorial(N)
a = 1

for i in range(len(sosu)):
    cnt = 0
    if(sosu[i] > x):
        break
    while (x%sosu[i]==0):
        x = x//sosu[i]
        cnt += 1
    if(cnt):
        a *= (cnt+1)
        a %= mod

print(a)

Measured memory_bytes: 9108
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <numeric>
#include <vector>
#include <math.h>
#include <string>
#include <queue>

using namespace std;


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

	int mnum = 0;
	int absmin = 1000000001;
	long long sum = 0;

	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;

		if (a < 0)
		{
			mnum++;
		}
		a = abs(a);
		absmin = min(absmin, a);

		sum += a;
	}

	if (mnum % 2 == 1)
	{
		sum -= 2 * absmin;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def S(): return sys.stdin.readline().rstrip()

N,T = map(int,S().split())
A = [0]
B = [0]
for i in range(N):
    a,b = LI()
    A.append(a)
    B.append(b)

dp1 = [[0]*(T+1) for i in range(N+1)]
# dp[i][j] = 1~i番目から選んでT分以内に食べるときの美味しさの和の最大値
dp2 = [[0]*(T+1) for i in range(N+2)]
# dp[i][j] = i~N番目から選んでT分以内に食べるときの美味しさの和の最大値

for i in range(1,N+1):
    for j in range(T+1):
        if j >= A[i]:
            dp1[i][j] = max(dp1[i-1][j],dp1[i-1][j-A[i]]+B[i])
        else:
            dp1[i][j] = dp1[i-1][j]
for i in range(N,0,-1):
    for j in range(T+1):
        if j >= A[i]:
            dp2[i][j] = max(dp2[i+1][j],dp2[i+1][j-A[i]]+B[i])
        else:
            dp2[i][j] = dp2[i+1][j]

ans = dp1[N][T]
for i in range(1,N+1):  # 最後にi番目の料理を食べる
    for j in range(T):
        ans = max(ans,dp1[i-1][j]+dp2[i+1][T-1-j]+B[i])

print(ans)

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

#define M_MAX 1000000000000000LL

int main() {

  while( true ) {

    long long int n, m, c, s, g;
    cin >> n >> m >> c >> s >> g;
    if ( n == 0 ) break;

    long long int d[101][101][21] = {};

    for ( long long int i = 0; i <= n; i++ ) {
      for ( long long int j = 0; j <= n; j++ ) {
	for ( long long int k = 0; k <= c; k++ ) {
	  d[i][j][k] = M_MAX;
	}
      }
    }
    for ( long long int i = 1; i <= n; i++ ) {
      for ( long long int k = 0; k <= c; k++ ) {
	d[i][i][k] = 0;
      }
    }
    
    for ( long long int i = 0; i < m; i++ ) {

      long long int x, y, in_d, in_c;
      cin >> x >> y >> in_d >> in_c;
      d[x][y][in_c] = min( d[x][y][in_c], in_d );
      d[y][x][in_c] = min( d[y][x][in_c], in_d );
      
    }

    vector< long long int > pp;
    for ( long long int i = 0; i < c; i++ ) {
      long long int in;
      cin >> in;
      pp.push_back( in );
    }

    vector< vector< long long int > > q, r;
    for ( long long int i = 0; i < c; i++ ) {
      vector< long long int > vq, vr;
      vq.push_back( 0 );
      for ( long long int j = 0; j < pp[i] - 1; j++ ) {
	long long int in;
	cin >> in;
	vq.push_back( in );
      }
      vq.push_back( M_MAX );
      for ( long long int j = 0; j < pp[i]; j++ ) {
	long long int in;
	cin >> in;
	vr.push_back( in );
      }
      q.push_back( vq );
      r.push_back( vr );
    }

    for ( long long int p = 1; p <= c; p++ ) {
      for ( long long int k = 1; k <= n; k++ ) {
	for ( long long int i = 1; i <= n; i++ ) {
	  for ( long long int j = 1; j <= n; j++ ) {
	    d[i][j][p] = min( d[i][j][p], d[i][k][p] + d[k][j][p] );
	  }
	}
      }
    }
    
    long long int mo[101][101][21] = {};
    for ( long long int p = 1; p <= c; p++ ) {
      for ( long long int i = 1; i <= n; i++ ) {
	for ( long long int j = 1; j <= n; j++ ) {
	  long long int k = 0;
	  for ( long long int u = 1; true; u++ ) {
	    if ( d[i][j][p] == 0 ) break;
	    if ( d[i][j][p] >= M_MAX ) {
	      k = M_MAX;
	      break;
	    }
	    if ( d[i][j][p] <= q[p-1][u] ) {
	      k += ( d[i][j][p] - q[p-1][u-1] ) * r[p-1][u-1];
	      break;
	    }else {
	      k += ( q[p-1][u] - q[p-1][u-1] ) * r[p-1][u-1];
	    }
	  }
	  mo[i][j][p] = k;
	}
      }
    }

    
    for ( long long int i = 1; i <= n; i++ ) {
      for ( long long int j = 1; j <= n; j++ ) {
	mo[i][j][0] = M_MAX;
	for ( long long int k = 1; k <= c; k++ ) {
	  mo[i][j][0] = min( mo[i][j][0], mo[i][j][k] );
	}
      }
    }

    for ( long long int k = 1; k <= n; k++ ) {
      for ( long long int i = 1; i <= n; i++ ) {
	for ( long long int j = 1; j <= n; j++ ) {
	  mo[i][j][0] = min( mo[i][j][0], mo[i][k][0] + mo[k][j][0] );
	}
      }
    }

    if ( mo[s][g][0] >= M_MAX ) {
      cout << -1 << endl;
    }else {
      cout << mo[s][g][0] << endl;
    }

  }
  
  return 0;
  
}

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

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

using namespace std;

int main(){
  int n,l;
  cin>>n>>l;
  vector<string> s;
  rep(i,n){
    string t;
    cin>>t;
    s.push_back(t);
  }
  sort(s.begin(),s.end());

  rep(i,n){
    cout<<s[i];
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define oo 381654729
using namespace std;
int N;
long long K;
int A[222222],Tag[222222];

int main(){
	// cout<<727202214173249351%3<<endl;
	cin>>N>>K;
	for(int i=1;i<=N;++i) cin>>A[i];
	set<int> Set;
	Set.insert(1);
	int idx=1;
	int skrg=1;
	int itung=0;
	int ukur=1;
	bool ok=0;
	vector<int> putar;
	while(idx<=N){
		if(idx<=K||idx>=K+2){
			if(Set.count(A[skrg])){
				ukur=Set.size();
				break;
			}
		} else {
			cout<<skrg<<endl;
			return 0;
		}
		skrg=A[skrg]; itung++; Set.insert(skrg);
		++idx;
	}
	idx=1; itung++; K-=itung;
	int tmp=A[skrg]; skrg=1;
	while(idx<=N){
		if(skrg==tmp&&!ok) ok=1;
		else if(skrg==tmp&&ok) break;
		if(ok){
			putar.push_back(skrg);
		}
		skrg=A[skrg];
		++idx;
	}
	// while()
	// while(true){
	// 	if(Tag[Now]) break;
	// 	Tag[Now]=Piv;
	// 	Now=A[Now];
	// 	Piv++;
	// }
	// Piv-=Tag[Now];
	// K%=Piv;
	// while(K<=N) K+=Piv;
	// Now=1;
	// while(K--){
	// 	Now=A[Now];
	// }
	cout<<putar[K%putar.size()]<<endl;
}

Measured memory_bytes: 12452
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int main() {
	cin>>N;

	cout<<48-N<<endl;

	return 0;
}


Measured memory_bytes: 256
/// You just can't beat the person who never gives up
/// ICPC next year

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

string a ,b ;
bool Never_give_up(){
    cin >> a >> b ;
    int ans = b.size() ;
    for(int i=0;i+b.size()<=a.size();++i){
        int cnt = 0 ;
        for(int j=0;j<b.size();++j) cnt += a[i+j]!=b[j] ;
        ans = min(ans ,cnt);
    }
    cout << ans << endl ;
    return 0;
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" ,"r" ,stdin);
    freopen("output.txt" ,"w" ,stdout);
#endif
    //std::ios::sync_with_stdio(0);
    //cin.tie(0) ,cout.tie(0);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
        Never_give_up();
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  V a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  dump(a[n-1]-a[0]);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
using namespace std;

string s, t;
int ans;
int main() {
	cin >> s >> t;
	int lengh = s.length();
	rep(i, 0, lengh) if(s[i] != t[i]) ans++;
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
N = int(input())
AB = []
for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))
    
works = AB[:]

works = sorted(works, key=lambda x: x[1])
#print('works', works)

total_amount = sum([w[0] for w in works])
#print(total_amount)

can_fin = True
for amount, deadline in reversed(works):
    if total_amount > deadline:
        can_fin = False
        break
    total_amount -= amount
    
if can_fin:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 89688
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  multiset<int>A;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(A.find(a)!=A.end()){
      A.erase(a);
    }else{
      A.insert(a);
    }
  }
  cout<<A.size()<<endl;
}


Measured memory_bytes: 4864
x1, y1, x2, y2 = gets.split.map(&:to_i)
x3 = x2 + y1 - y2
y3 = y2 - x1 + x2
x4 = x3 + y2 - y3
y4 = y3 - x2 + x3
puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 1788