akhauriyash/Code-Regression huggingface dataset:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！

from math import factorial
def cmb(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)


def main():
    n=int(input())
    l=[cmb(i,2) for i in Counter(["".join(sorted(input()))for i in range(n)]).values() if i>1]
    print(sum(l))
                    
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 21676
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


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

using namespace std;
int n;
int a[1000000];
int b[1000000];
int c[1000000];
int ans;
int p,q,r;
vector<int> ans2;

int gcd(int a,int b){
  if(a>b) swap(a,b);
  if(a==0) return b;
  return gcd(b%a,a);
}

int main(){
  cin >> n;
  REP(i,n){
    cin >> a[i];
  }
  b[0] = a[0];
  for(int i=1;i<n;i++){
    b[i] = gcd(b[i-1],a[i]);
    //cout << b[i] << endl;
  }
  c[n-1] = a[n-1];
  for(int i=n-2;i>=0;i--){
    c[i] = gcd(c[i+1],a[i]);
    //cout << c[i] << endl;
  }
  int ans = 1;
  for(int i=1;i<n-1;i++){
    ans = max(ans,gcd(b[i-1],c[i+1]));
  }
  ans = max(ans,b[n-2]);
  ans = max(ans,c[1]);
  cout << ans <<endl;

  return 0;
}


Measured memory_bytes: 8832
fun main() {
    val (n, k) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val s = Array(n + 1) { 0 }
    repeat(k) {
        val d = readLine()?.toInt() ?: return
        val a = readLine()?.split(" ")?.map(String::toInt) ?: return
        0.until(d).forEach { i ->
            s[a[i]] += 1
        }
    }
    println((s.count { it == 0 } - 1).toString())
}

Measured memory_bytes: 39188
from fractions import gcd
def lcm(a, b):return a * b // gcd(a,b)
N = int(input())
A = [int(i) for i in input().split()]
B = lcm(A[0],A[1])
ans = 0
for i in A:
    B = lcm(B,i)
for i in A:
    ans += (B-1)%i
print(ans)

Measured memory_bytes: 5688
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define tlll tuple<lin, lin, lin>

bool comp (tlll t1, tlll t2)
{
    lin diff1 = get<2>(t1);
    lin diff2 = get<2>(t2);

    if(diff1 <= 0 && diff2 <= 0)
        return diff1 < diff2;

    if(diff1 <= 0)
        return true;

    if(diff2 <= 0)
        return false;

    return get<1>(t1) > get<1>(t2);
}

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

    tlll t[n];
    
    rep(i, n)
    {
        lin a, b;
        cin >> a >> b;
        lin diff = a - b;
        t[i] = make_tuple(a, b, diff);
    }

    sort(t, t + n, comp);

    if(get<2>(t[0]) == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    lin res = 0;

    rep(i, n - 1)
    {
        lin b = get<1>(t[i]);
        res += b;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>










char s[8];
int a[8],sum;




void solve()
{
	cin>>s;
	for(int i=0;i<4;i++)a[i]=s[i]-'0';
	for(int i=0;i<8;i++)
	{
		sum=a[0];
		for(int j=0;j<3;j++)
		{
			if((1<<j)&i)sum+=a[j+1];
			else sum-=a[j+1];
		}
		if(sum==7)
		{
			cout<<a[0];
			for(int j=0;j<3;j++)
			{
				if((1<<j)&i)cout<<"+"<<a[j+1];
				else cout<<"-"<<a[j+1];
			}
			cout<<"=7\n";
			return;
		}
	}
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
n,m = gets.split(' ').map{|x|x.to_i}

count = (0...n).map{|x|0}.to_a
m.times do
	a,b = gets.split(' ').map{|x|x.to_i}
	count[a-1] += 1
	count[b-1] += 1
end

count.each{|c| puts c}


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

#define N 3

int c[N][N];

int main()
{
	int n;
	int total = 0, d = 0, u = 0;
	int ans;

	for ( int i = 0; i < N; i++ ) {
		for ( int j = 0; j < N; j++ ) {
			cin >> c[i][j];
		}
	}

	for ( int i = 0; i < N; i++ ) {
		for ( int j = 0; j < N; j++ ) {
			total += c[i][j];
		}
	}
	for ( int i = 0; i < N; i++ ) {
		d += c[i][i];
		u += c[i][N - i - 1];
	}

	if( 3 * d == total && 3 * u == total ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int m,n;
  int A[100][100] = {0};
  int b[100] = {0};
  int c[100] = {0};
  cin >> n >> m;
  for(int y=0; y < n; ++y){
    for(int x=0; x < m; ++x){
      cin >> A[y][x];
    }
  }
  for(int y=0; y < m; ++y){
    cin >> b[y];
  }
  for(int y=0; y < n; ++y){
    for(int x=0; x < m; ++x){
      c[y] += (A[y][x] * b[x]); 
    }
  }
  for(int y=0; y < n; ++y){
    cout << c[y] << endl;
  }
  return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
#include <stdlib.h>

#define datatype long long int

datatype max(datatype a, datatype b){
	if(a > b){
		return a;
	}
	else{
		return b;
	}
}

datatype min(datatype a, datatype b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

int compare(datatype a, datatype b){
	if(a < b){
		return 1;
	}
	else if(a > b){
		return -1;
	}
	else{
		return 0;
	}
}

datatype *sort_sub(datatype *origin, int N){
	datatype *ans = (datatype *)malloc(sizeof(datatype) * N);
	if(N == 1){
		ans[0] = origin[0];
	}
	else{
		int N1 = N / 2;
		int N2 = (N + 1) / 2;
		datatype *sub1 = sort_sub(&origin[0] , N1);
		datatype *sub2 = sort_sub(&origin[N1], N2);
		int i, j, k;
		for(i = 0, j = 0, k = 0; i < N; i++){
			if((compare(sub1[j], sub2[k]) == -1 && j != N1) || (k == N2)){
				ans[i] = sub1[j];
				j++;
			}
			else{
				ans[i] = sub2[k];
				k++;
			}
		}
		free(sub1);
		free(sub2);
	}
	return ans;
}

datatype *sort(datatype *origin, int N){
	datatype *ans;
	if(N == 0){
		ans = NULL;
	}
	else{
		ans = sort_sub(origin, N);
	}
	free(origin);
	return ans;
}

int main(){
	int N, W, i, j, k, w1, wi;
	scanf("%d%d", &N, &W);
	datatype **v = (datatype **)malloc(sizeof(datatype *) * 4);
	int *vnum = (int *)malloc(sizeof(int) * 4);
	for(i = 0; i < 4; i++){
		v[i] = (datatype *)malloc(sizeof(datatype) * N);
		vnum[i] = 0;
	}
	scanf("%d%lld", &w1, &v[0][0]);
	vnum[0]++;
	for(i = 1; i < N; i++){
		scanf("%d", &wi);
		scanf("%lld", &v[wi - w1][vnum[wi - w1]]);
		vnum[wi - w1]++;
	}
	datatype **vsum = (datatype **)malloc(sizeof(datatype *) * 4);
	for(i = 0; i < 4; i++){
		v[i] = sort(v[i], vnum[i]);
		vsum[i] = (datatype *)malloc(sizeof(datatype) * (vnum[i] + 1));
		vsum[i][0] = 0;
		for(j = 0; j < vnum[i]; j++){
			vsum[i][j + 1] = vsum[i][j] + v[i][j];
		}
	}
	datatype ans = 0;
	for(i = 0; i <= vnum[3] && W - (w1 + 3) * i >= 0; i++){
		for(j = 0; j <= vnum[2] && W - (w1 + 3) * i - (w1 + 2) * j >= 0; j++){
			for(k = 0; k <= vnum[1] && W - (w1 + 3) * i - (w1 + 2) * j - (w1 + 1) * k >= 0; k++){
				ans = max(vsum[3][i] + vsum[2][j] + vsum[1][k] + vsum[0][min(vnum[0], (W - (w1 + 3) * i - (w1 + 2) * j - (w1 + 1) * k) / w1)], ans);
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
const long long mod = 1000000007;
long long pw[200200] = { 1 };

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

int main() {
  fastio;

	map<pair<ll, ll>, pair<int, int> > chk;

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

	ll a = mod - 1;
	int n; scanf ("%d", &n); while (n--){
	  ll x, y;
		scanf ("%lld %lld", &x, &y);
		if (x == 0 && y == 0){ a++; continue; }
		if (make_pair(x, y) < make_pair(0ll, 0ll)) x = -x, y = -y;
		ll g = gcd(abs(x), abs(y));
		x /= g; y /= g;
		if (y > 0) chk[{x, y}].first++;
		else chk[{-y, x}].second++;
	}

	ll r = 1;
	for (auto& p : chk) {
		r = r * (pw[p.second.first] + pw[p.second.second] - 1) % mod;
	}

	cout << (a + r) % mod << "\n";
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


Measured memory_bytes: 17632
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    int a,b;

    cin >> a >> b;

    //cout <<std::fixed<< setprecision(10) <<  ans << endl;

    map<int,int> aa;

    aa[a]=1;
    aa[b]=1;

    if(aa[1]==0){
        cout << 1 << endl;
        return 0;
    }
    if(aa[2]==0){
        cout << 2 << endl;
        return 0;
    }
    if(aa[3]==0){
        cout << 3<<endl;
        return 0;
    }


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, k, A, B, K;
	scanf("%d %d %d", &A, &B, &K);
	for (i = A, k = 0; i >= 1, k < K; i--) if (A % i == 0 && B % i == 0) k++;
	printf("%d\n", i + 1);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1704
#include<algorithm>
#include<iostream>
#include<string>

using namespace std;

int main(){
	string s;
	char atgc[4]={'A','T','G','C'};
	cin>>s;
	int ans=0;
	int temp=0;
	for(int i=0;i<s.length();i++){
		bool noatgc=true;
		for(int j=0;j<4;j++){
			if(s[i]==atgc[j]){
				noatgc=false;
				temp++;
			}
		}
		if(noatgc){
			ans=max(ans,temp);
			temp=0;
		}
	}
	ans=max(ans,temp);
	cout<<ans<<endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	string s, t;
	cin >> s >> t;
	Vec x(s.size() + 1), y(t.size() + 1);
	rep(i, s.size()){
		if (s[i] == 'A') x[i + 1] = x[i] + 1;
		else
			x[i + 1] = x[i] + 2;
	}
	rep(i, t.size()){
		if (t[i] == 'A') y[i + 1] = y[i] + 1;
		else
			y[i + 1] = y[i] + 2;
	}

	ll q;
	cin >> q;

	rep(i, q){
		ll a, b, c, d;
		cin >> a >> b >> c >> d;

		if ((x[b] - x[a - 1]) % 3 == (y[d] - y[c - 1]) % 3) puts("YES");
		else
			puts("NO");
	}

	return 0;
}


Measured memory_bytes: 5020
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vvl dp(10,vl(10,0));
  ll a,b;
  FOR(i,1,n+1){
    b=i%10;
    a=i;
    while(a>=10){
      a/=10;
    }
    dp[a][b]++;
  }
  ll ans=0;
  rep(i,10){
    rep(j,10){
      ans+=dp[i][j]*dp[j][i];
    }
  }
  cout << ans << endl;
}

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

namespace AtCoder_Cs
{
    public class Program
    {
        public static void Main()
        {
            var lst = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int res = 0;

            int min = lst[1];
            int max = lst[2];

            for (int i = 0;i <= lst[0]; i++)
            {
                int sum = 0;
                for (int j = 0;j < i.ToString().Length; j++)
                {
                    sum += int.Parse(i.ToString().Substring(j, 1));
                }

                if (max >= sum && sum >= min)
                {
                    res += i;
                }
            }

            Console.WriteLine($"{res}");
        }
    }
}


Measured memory_bytes: 15444
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> march(5);
	string stmp, m = "MARCH";
	for (int i = 0; i < N; i++) {
		cin >> stmp;
		for (int i = 0; i < 5; i++) {
			if (stmp[0] == m[i]) march[i]++;
		}
	}

	lint ans = 0;
	vector<int> use(5);
	fill(use.end() - 3, use.end(), 1);
	do {

		lint tmp = 1;
		for (int i = 0; i < 5; i++) {
			if (use[i]) tmp *= march[i];
		}
		ans += tmp;
	} while (next_permutation(use.begin(), use.end()));

	cout << ans << "\n";

	return 0;
}

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




int main(){
    int n;
    cin>>n;
   int  hanako=0,tarou=0;
    while(n>0){
        string hana,taro;
        cin>>hana>>taro;
        if(hana==taro){
            hanako++;
            tarou++;
        }else if(taro<hana){
            tarou+=3;
            
        }else{
            hanako+=3;
        }
        
        n--;
    }
    cout<<tarou<<' '<<hanako<<endl;
    
    return 0;
}



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

#define INFTY (1 << 30);
typedef long long ll;

int main(void) {
  int N, M, C;
  int A[30][30], B[30];
  cin >> N >> M >> C;
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }

  int counter = 0;
  int val = 0;
  for (int i = 0; i < N; i++) {
    val = 0;
    for (int j = 0; j < M; j++) {
      val += A[i][j]*B[j];
    }
    if (val+C > 0) {
      counter ++;
    }
  }
  cout << counter << endl;
  
  return 0;
}


Measured memory_bytes: 256
;; D - Bouquet

(defparameter *modulus* (+ (expt 10 9) 7))

(defun solve (n a b)
  "(n 1) + (n 2) + ... + (n n) (= 2 ** n - 1) - (n a) - (n b)"
  (mod+ (modulo-expt 2 n) -1
        (- (choose n a))
        (- (choose n b))))

(defun main ()
  (let ((n (read))
        (a (read))
        (b (read)))
    (princ (solve n a b))))

;; modulo addition/product/division

(defun mod+ (&rest rest)
  (mod (apply #'+ rest) *modulus*))

(defun mod* (&rest rest)
  (mod (apply #'* rest) *modulus*))

(defun mod/ (num &rest denom)
  (apply #'mod* (cons num (mapcar #'mod-inverse denom))))

(defun bit-sequence (v)
  "(bit-sequence 13) => (1 1 0 1)"
  (nreverse
    (loop for x = v then (ash x -1) while (plusp x)
          collect (logand x 1))))

(let ((modulus-2-bits (bit-sequence (- *modulus* 2))))
  ; Mが素数のとき，a^(M-2) ≡ a^(-1) mod M (フェルマーの小定理より)
  (defun mod-inverse (a) (mod-expt-bit-seq a modulus-2-bits)))

(defun modulo-expt (a n) (mod-expt-bit-seq a (bit-sequence n)))

(defun mod-expt-bit-seq (a bit-seq)
  (loop for b in bit-seq
        for e = a then (mod* e e (if (zerop b) 1 a))
        finally (return e)))

(defun choose (n k)
  (labels ((choose-r (n k acc)
              (if (zerop k) acc
                  (choose-r (1- n) (1- k) (mod* acc (mod/ n k))))))
    (if (or (< n k) (minusp k)) 0
        (choose-r n k 1))))

(main)


Measured memory_bytes: 57832
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
int n,k;
void ot(int u,int v){printf("%d %d\n",u,v);;}
int main(){
    scanf("%d",&n);while((1<<k+1)<=n) ++k;
    int m=1<<k;if(m==n) return puts("No"),0;puts("Yes");
    ot(1,3);ot(3,2);ot(2,n+1);ot(n+1,n+3);ot(n+3,n+2);
    rep(i,2,(n-1)/2) ot(1,2*i),ot(1,2*i+1),ot(2*i,2*i+1+n),ot(2*i+1,2*i+n);
    if(!(n&1)){
        int t=m^1^n;
        ot(m,n),ot(t,2*n);
    }
    return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	cin >> N;
	vector<int> C(N-1), S(N-1), F(N-1);
	for(int i=0;i<N-1;i++) cin >> C[i] >> S[i] >> F[i];
	
	vector<int> ans(N);
	for(int i=0;i<N;i++){
		int time = 0;
		for(int j=i;j<N-1;j++){
			if(time <= S[j]) time += S[j] - time;
			if(time % F[j] != 0) time += F[j] - (time % F[j]);
			time += C[j];
		}
		ans[i] = time;
	}
	
	for(auto n : ans) cout << n << endl;
	
	
	
	
    return 0;
}

Measured memory_bytes: 256
import math
import sys

A = int(input())
B = int(input())
if A == 1:
    if B == 2: 
        print(3)
    else:
        print(2)
elif A == 2:
    if B == 3: 
        print(1)
    else:
        print(3)
else:
    if B == 1: 
        print(2)
    else:
        print(1)

Measured memory_bytes: 3060
//#include "debug.h"
#include <assert.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

template<class T>
void printa(const T *a, int n) {
	cout << '[';
	for (int i=0; i<n; i++) {
		if (i) cout << ',';
		cout << a[i];
	}
	cout << ']' << endl;
}

template<class T>
void printa_nz(const T *a, int n) {
	cout << '[';
	for (int i=0, k=0; i<n; i++) {
		if (!(a[i]==0)) {
			if (k++) cout << ',';
			cout << i << ':' << a[i];
		}
	}
	cout << ']' << endl;
}

template<class T>
void printa_i(const T *a, int n) {
	cout << '[';
	for (int i=0; i<n; i++) {
		if (i) cout << ',';
		cout << i << ':' << a[i];
	}
	cout << ']' << endl;
}

template<class T1,class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &x) {
	return os<<'('<<x.first<<','<<x.second<<')';
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &a) {
	os << '[';
	int n = a.size();
	for (int i=0; i<n; i++) {
		if (i) os << ',';
		os << a[i];
	}
	os << ']';
	return os;
}

template<class K, class T>
ostream &operator<<(ostream &os, const map<K,T> &a) {
	os << '{';
	int i = 0;
	for (auto &x: a) {
		if (i) os << ',';
		i++;
		os << x.first << ':' << x.second;
	}
	return os << '}' << endl;
}


template<class T>
ostream &operator<<(ostream &os, const set<T> &a) {
	os << '{';
	int i = 0;
	for (auto &x: a) {
		if (i) os << ',';
		i++;
		os << x;
	}
	return os << '}';
}


template<class T>
ostream &operator<<(ostream &os, const multiset<T> &a) {
	os << '{';
	int i = 0;
	for (auto &x: a) {
		if (i) os << ',';
		i++;
		os << x;
	}
	return os << '}';
}
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 3000
typedef long long i64;

int n, t;
pair<int,int> a[MAXN];
int b[MAXN+1];
int dp[MAXN+1][MAXN];

int input() {
	if (scanf("%d %d", &n, &t) < 0) return 0;
	for (int i=0; i<n; i++) {
		scanf("%d %d", &a[i].first, &a[i].second);
	}
	return 1;
}

void init() {
	memset(dp, 0, sizeof(dp));
}

void maxit(int &a, int b) {
	if (b>a) a = b;
}

int solve() {
	sort(a, a+n);
	for (int i=1; i<=n; i++) {
		int dt = a[i-1].first, dw = a[i-1].second;
		for (int j=1; j<t; j++) {
			maxit(dp[i][j], dp[i][j-1]);
			maxit(dp[i][j], dp[i-1][j]);
			if (j>=dt)
				maxit(dp[i][j], dp[i-1][j-dt] + dw);
		}
	}
	b[n] = 0;

	//for (int i=1; i<=n; i++) printa(dp[i], t);

	for (int i=n-1; i>=0; i--)
		b[i] = max(b[i+1], a[i].second);
	//printa(b, n+1);

	int r = 0;
	for (int i=1; i<=n; i++) {
		int c = dp[i][t-1] + b[i];
		maxit(r, c);
	}
	return r;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




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

using namespace std;

typedef long long int ll;

const int N = 1e6 + 5;

vector < int > f (N);

int solve (int x, int y, int z) {
  return (x * x + y * y + z * z + x * y + y * z + z * x);
}

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

  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        f[solve (x, y, z)]++;
      }
    }
  }

  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cout << f[i] << '\n';
}


Measured memory_bytes: 7076
#include<bits/stdc++.h>
using namespace std;
vector<int> v[100];//省份中的餐厅编号 
vector<int> v2;//每个餐厅分数 
map<string,int> mp;//省份编号 
vector<string> v3; //省份名字
map<int,int> ma;
int main()
{
	string s;
	int n,p;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s>>p;
		if(mp.find(s)==mp.end())
		{
			v3.push_back(s);
			mp[s]=i; 
		}
		v[mp[s]].push_back(i);
		v2.push_back(p);
		ma[p]=i;
	}
	sort(v3.begin(),v3.end());
	for(int i=0;i<v3.size();i++)
	{
		vector<int> v4;
		for(int j=0;j<v[mp[v3[i]]].size();j++)
		{
			v4.push_back(v2[v[mp[v3[i]]][j]]); 
		}
		sort(v4.begin(),v4.end());
		for(int j=v4.size()-1;j>=0;j--)
		cout<<ma[v4[j]]+1<<endl; 
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
T, A = [], []
for _ in range(N):
    t, a = map(int, input().split())
    T.append(t)
    A.append(a)
t_pred, a_pred = 1, 1
for t, a in zip(T, A):
    if t_pred <= t and a_pred <= a:
        t_pred, a_pred = t, a
    else:
        times = max(-(-t_pred//t), -(-a_pred//a))
        t_pred, a_pred = times*t, times*a
print(t_pred + a_pred)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N; cin >> N;
    map<int, int> M;
    int len = 0;
    for(int i=0; i<N; i++){
        int p; cin >> p;
        p--;
        if(p==i) len++;
        else {
            M[len]++;
            len = 0;
        }
    }
    M[len] ++;
    
    int ans = 0;
    for(auto m:M){
        ans += (m.fs + 1)/2 * m.sc;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,R;cin>>N>>R;
        if(N==0&&R==0) return 0;
        
        vector<int> A(N);
        for(int i=0;i<N;i++) A[i]=N-i;
        
        while(R--){
            int X,Y;cin>>X>>Y;
            X--;
            vector<int> B(N);
            for(int i=0;i<Y;i++) B[i]=A[X+i];
            for(int i=0;i<X;i++) B[Y+i]=A[i];
            for(int i=X+Y;i<N;i++) B[i]=A[i];
            
            A=B;
        }
        
        cout<<A[0]<<endl;
    }
}



Measured memory_bytes: 3168
#include<cstdio>
int main(){
  int n,f,ans;
  while(scanf("%d",&n),n>=0){
    ans=0;
    f=1;
    while(n>=f*4) f*=4;
    while(f > 0){
      printf("%d",n/f);
      n %= f;
      f /= 4;
    }
    printf("\n");
  }
  return(0);
}



Measured memory_bytes: 2660
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define ushi int
#define tapu main
#define nichia (
#define kunn void
#define wara )

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main(){

	string s;
	scans(s);
	printf("%s\n", (s[0] != s[1] && s[1] != s[2] && s[2] != s[3]) ? "Good" : "Bad");

	Please AC;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace IO
{
	using namespace std;
	char buf[1<<22],Out[1<<22],*p1=buf,*p2=buf;
	int p3=-1,f=0;
	inline void file()
	{
		#ifdef NTFOrz
		freopen("file.in","r",stdin);
		#endif
	}
	inline char getchar()
	{
		return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
	}
	inline void flush(){fwrite(Out,1,p3+1,stdout),p3=-1;}
	inline void check(){if (p3>(1<<21)) flush();}
	inline void putchar(char a){Out[++p3]=a;check();}
	inline void putline(string s)
	{
		int tmp=p3;
		while (p3-tmp<s.size()) putchar(s[p3-tmp]);
		putchar('\n');
	}
	inline char gc()
	{
		char c=getchar();
		while (!c||c=='\n'||c==' ') c=getchar();
		return c;
	}
}
namespace my_std
{
	using namespace std;
	#pragma GCC optimize(2)
	#pragma GCC optimize(3) 
	#pragma GCC optimize("Ofast")
	#define getchar IO::getchar
	#define putchar IO::putchar
    #define Re register
    #define rep(i,a,b) for (Re int i=(a);i<=(b);i++)
    #define drep(i,a,b) for (Re int i=(a);i>=(b);i--)
    #define repv(i,v) if (v.size()) rep(i,0,v.size()-1)
    #define drepv(i,v) if (v.size()) drep(i,v.size()-1,0)
    #define go(u) for (Re int i=head[(u)];i;i=e[i].nxt)
    #define pf printf
    #define writesp(x) write(x),putchar(' '),IO::check()
    #define writeln(x) write(x),putchar('\n'),IO::check()
    #define mem(x,v) memset(x,v,sizeof(x))
    #define pb push_back
    #define NTF return
    #define AKIOI 0
    typedef long long ll;
    const int INF=0x7fffffff;
    inline int read()
    {
        int sum=0,f=0;char c=getchar();
        while (!isdigit(c)) f|=(c=='-'),c=getchar();
        while (isdigit(c)) sum=(sum<<1)+(sum<<3)+(c^48),c=getchar();
        return f?-sum:sum;
    }
    void write(int k)
    {
        if (k<0) putchar('-'),k=-k;
        if (k>=10) write(k/10);
        putchar(k%10+48);
    }
	#define templ template<typename T>
    templ inline void chkmax(T &x,T y){if (x<y) x=y;}
    templ inline void chkmin(T &x,T y){if (x>y) x=y;}
}
using namespace my_std;
const int N=1010;
int n,ans,a[N*N],dis[N][N],dlt[N][N];
int fx[5][2]={{0,1},{-1,0},{0,-1},{1,0}};
void dfs(int x,int y)
{
	rep(i,0,3)
	{
		int xx=x+fx[i][0],yy=y+fx[i][1];
		if (/*xx>=1&&xx<=n&&yy>=1&&yy<=n&&*/dis[x][y]+1-dlt[xx][yy]<dis[xx][yy])
		{
			chkmin(dis[xx][yy],dis[x][y]+1-dlt[xx][yy]);
			dfs(xx,yy);
		}
	}
}
int main()
{
	IO::file();
	n=read();
	rep(i,1,n*n) a[i]=read();
	rep(i,1,n) rep(j,1,n) dis[i][j]=min(min(i,n-i+1),min(j,n-j+1));
	rep(i,1,n*n)
	{
		int x=(a[i]-1)/n+1,y=a[i]-n*x+n;
		ans+=dis[x][y]-1;
		rep(j,0,3)
		{
			int xx=x+fx[j][0],yy=y+fx[j][1];
			if (/*xx>=1&&xx<=n&&yy>=1&&yy<=n&&*/dis[xx][yy]<dis[x][y])
			{
				dis[x][y]=dis[xx][yy];
			}
		}
		dlt[x][y]=1;
		dfs(x,y);
	}
	writeln(ans);
	IO::flush();
	return 0;
}

Measured memory_bytes: 25500
#include <stdio.h>
int main(void)
{
    char a[100];
    for(int i = 0; i< 100;i++)
    {
        a[i] = 0;
    }
    gets(a);
    if(a[5] != '0' || a[6] > '4')
    {
        puts("TBD");
    }
    else
    {
        puts("Heisei");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a;
	cin >>a;
  
  int s1 = a%10;  				//1
  int s2 = (a/10)%10;     //10
  int s3 = a/100; 				//100	
   cout <<s1+s2+s3<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>

using namespace std;

long long count(unordered_map<long long, long long> &um, long long target) {
    if (target == 1) {
        return 1;
    }
    if (um.find(target) != um.end()) {
        return um[target];
    }
    long long ret = 1 + count(um, target / 2) * 2;
    return um[target] = ret;
}

int main() {
    long long h;
    cin >> h;
    unordered_map<long long, long long> um;
    cout << count(um, h) << endl;
}


Measured memory_bytes: 256
N = int(input())
S = input()
ES, WS= [0]*(N+1), [0]*(N+1)
ES[0], WS[0] = 0, 0
for i in range(1, N+1):
  if S[i-1] == "E":
    ES[i] = ES[i-1] + 1
    WS[i] = WS[i-1]
  elif S[i-1] == "W":
    WS[i] = WS[i-1] + 1
    ES[i] = ES[i-1]
ans = 10**18
for i in range(1, N+1):
  ans = min(ans, WS[i-1] + ES[N] - ES[i])
print(ans)

Measured memory_bytes: 17552
#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 POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
vector<int>pt[100005];
vector<int>pt2[100005];

int par[100005],ran[100005];
void init(){ for(int i=0;i<100005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }

set<int>S[100005];
int cnt[100005];

int main(){
	scanf("%d",&n);
	rep(i,n){
		int x,y; scanf("%d%d",&x,&y);
		pt[x].pb(y);
		pt2[y].pb(x);
		
	}
	init();
	for(int i=0;i<100005;i++){
		for(int j=1;j<pt2[i].size();j++){
			unite(pt2[i][j-1],pt2[i][j]);
		}
	}
	for(int i=0;i<100005;i++){
		cnt[find(i)]++;
		for(int j=0;j<pt[i].size();j++) S[find(i)].insert(pt[i][j]);
	}
	ll ans = 0;
	for(int i=0;i<100005;i++) ans += 1LL*cnt[i]*S[i].size();
	cout<<ans-n<<endl;
}

Measured memory_bytes: 16256
#include<stdio.h>

#include<string.h>
int main(void){
  char S[101],T[11],U[11];
  int i,len;
    
    scanf("%s",S);
  	len=strlen(S);
  for(i=0;i<len;i++){
	S[i]='x';
  }
 printf("%s",S);
  
    return 0;
  
  
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	string s;
	map<string, long long> mp;
	for (int i = 0; i < n; i++) {
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	long long ans = 0;
	for (auto &p : mp) {
		ans += p.second * (p.second - 1) / 2;
	}
	cout << ans << endl;	

	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int TDN,MUR[999],TDKR[999];
	cin>>TDN;
	for(int KMR=0;KMR<TDN;KMR++){
		cin>>MUR[KMR]>>TDKR[KMR];
		if(MUR[KMR]%TDKR[KMR]!=0){
			cout<<MUR[KMR]%TDKR[KMR]<<endl;
			}
		else{
			cout<<TDKR[KMR]<<endl;
			}
		}
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
using namespace std;
long long a[3];
int main()
{
    cin>>a[0]>>a[1]>>a[2];
    if(!(a[0]&a[1]&a[2]&1)) cout<<"0";
    else
    {
        sort(a,a+3);
        cout<<1LL*a[0]*a[1]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
MOD=10**9+7
DP1=[0 for _ in range(N+3)]
DP2=[0 for _ in range(N+3)]
DP1[3]=1
DP2[3]=1
for i in range(4,N+1):
  DP1[i]=(DP2[i-3]+1)%MOD
  DP2[i]=(DP1[i]+DP2[i-1])%MOD
print(DP1[N])

Measured memory_bytes: 9148
#include <iostream>
using namespace std;
int main()
{
    int n, sum = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int avg = sum / n;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += ((a[i] - avg) * (a[i] - avg));
    }
    int minimum = ans;
    avg++;
    ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += ((a[i] - avg) * (a[i] - avg));
    }
    minimum = min(minimum, ans);
    cout << minimum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define alll(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define endl '\n'

int a[100005];
int cnt[100005],cnt2[100005];
int main()
{
    int n;
    cin>>n;
    ii cin>>a[i];
    for(int i=1;i<=n;i+=2) cnt[a[i]]++;
    for(int i=2;i<=n;i+=2) cnt2[a[i]]++;
    int mx1=0,mx2=0,mi1=0,mi2=0;
    for(int i=1;i<=100000;++i) {
        if(cnt[i] > mx1) {
            mx2 = mx1, mi2 = mi1;
            mx1 = cnt[i], mi1 = i;
        } else if(cnt[i] > mx2) {
            mx2 = cnt[i], mi2 = i;
        }
    }
    int mx12=0,mx22=0,mi12=0,mi22=0;
    for(int i=1;i<=100000;++i) {
        if(cnt2[i] > mx12) {
            mx22 = mx12, mi22 = mi12;
            mx12 = cnt2[i], mi12 = i;
        } else if(cnt2[i] > mx22) {
            mx22 = cnt2[i], mi22 = i;
        }
    }
    if(mi12 != mi1) cout << n - mx1 - mx12 << endl;
    else cout << min(n-mx1-mx22,n-mx2-mx12) << endl;
}

Measured memory_bytes: 1408
N = int(input())
lst = []
for _ in range(N):
    S = input()
    lst.append(S)


print(f'AC x {lst.count("AC")}')
print(f'WA x {lst.count("WA")}')
print(f'TLE x {lst.count("TLE")}')
print(f'RE x {lst.count("RE")}')

Measured memory_bytes: 16172
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

#define ll long long
#define PII pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size))           \
  scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name)
#define DEBUG(...) debug(__LINE__,__VA_ARGS__)
#define MOD 1000000007

using namespace std;

string to_string(string s) { return s; }

template <class T>
string to_string(vector<T> v) {
	string ret = "{";
	FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
	if (v.size() > 0) {
		ret += to_string(LAST(v));
	}
	ret += "}";
	return ret;
}

void debug_print() { cerr << endl; }

template <class Head, class... Tail>
void debug_print(Head head, Tail... tail) {
	cerr << to_string(head) << " ";
	debug_print(tail...);
}

template <class... T>
void debug(T... args) {
	debug_print(args...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
	cout << to_string(head) << " ";
	print(tail...);
}

int main() {
	GI(N);
	vector<ll> a(N);
	FOR(i,N)cin>>a[i];
	ll c=0;
	while(1){
		auto max=max_element(ALL(a));
		if(a[max-a.begin()]<N)break;
		ll diff=*max-N+1;
		ll ct=(diff+N-1)/N;
		a[max-a.begin()]-=ct*N;
		for(int i=0;i<N;++i){
			if(i==max-a.begin())continue;
			a[i]+=ct;
		}
		c+=ct;
	}
	print(c);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
if(a<b)
{
printf("a < b\n");
}
else if(a>b)
{
printf("a > b\n");
}
else if(a==b)
{
printf("a == b\n");
}
return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int dp[101000];

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

	int X;
	cin >> X;

	FOR(i, 100, X + 1) {
		if (i <= 105) {
			dp[i] = 1;
		}
		if (dp[i] == 1) {
			FOR(j, 100, 106) {
				dp[i + j] = 1;
			}
		}
	}

	cout << dp[X] << "\n";

	return 0;
}


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

using namespace std;

int n,i;
map <int, int> mp;

int main(){
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		int x;
		scanf("%d", &x);
		mp[x]++;
	}
	
	int res = 0;
	
	for(auto v : mp){
		if(v.second < v.first)
		res += v.second;
		else
		res += v.second - v.first;
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 4736
n = int(input())
if n % 2 == 0:
    print(n * ((n // 2) - 1))
    for i in range(1, n):
        for j in range(i+1, n + 1):
            if i + j != n + 1:
                print(i, j)    
else:
    print(((n - 2) * (n - 1) // 2) + (n // 2))
    for i in range(1, n):
        for j in range(i+1, n + 1):
            if i + j != n:
                print(i, j)

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

int main() {
	int D, T, S;
	cin >> D >> T >> S;
	float time = (float)D / (float)S;

	if (time <= T) {
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
  int n,d,x;
  cin>>n>>d>>x;
  int s=x;
  int p[d][n];
  for(int i=0;i<d;i++){
    for(int j=0;j<n;j++){
      cin>>p[i][j];
    }
  }
  for(int k=0;k<d-1;k++){
    int dp[n+10][x+10]={};
    for(int i=0;i<n;i++){
      int val=p[k+1][i]-p[k][i];
      int w=p[k][i];
      for(int j=0;j<=x;j++){
        if(j-w>=0&&x>=j-w) dp[i+1][j]=max(dp[i+1][j-w]+val,dp[i][j]);
        else {dp[i+1][j]=dp[i][j];}
      }
    }
    if(dp[n][x]>=0)x+=dp[n][x];
  }
  cout<<x<<endl;
  return 0;
}

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

template<typename T> struct Graph {
  struct Edge { int to; T cost; };
  vector<int> prev;
  vector<vector<Edge>> g;
  Graph(int n) : prev(n, -1), g(n) {}

  void addEdge(int u, int v, T w) {
    g[u].push_back({v, w});
    //g[v].push_back({u, w});
  }
  vector<T> dijkstra(int s) {
    vector<T> dist(g.size(), -1);
    using Node = pair<T, int>;
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    pq.push({dist[s] = 0, s});

    while (!pq.empty()) {
      auto d = pq.top().first;
      auto u = pq.top().second;
      pq.pop();
      if (dist[u] < d) continue;
      for (auto&& v : g[u]) {
        if (dist[v.to] < 0 || dist[v.to] > dist[u] + v.cost) {
          dist[v.to] = dist[u] + v.cost;
          prev[v.to] = u;
          pq.push({dist[v.to], v.to});
        }
      }
    }
    return dist;
  }
  vector<int> getPath(int t) {
    vector<int> path;
    for (; t != -1; t = prev[t]) path.push_back(t);
    reverse(begin(path), end(path));
    return path;
  }
};

int main() {
  int n; cin >> n;
  Graph<int> g(n);
  for (int i = 0; i < n; ++i) {
    int u, k; cin >> u >> k;
    for (int j = 0; j < k; ++j) {
      int v, c; cin >> v >> c;
      g.addEdge(u, v, c);
    }
  }
  vector<int> d = g.dijkstra(0);
  for (int i = 0; i < n; ++i) {
    cout << i << ' ' << d[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3164
class Dice():
    
    #入力
    def __init__(self,d1,d2,d3,d4,d5,d6):
        self.d1=d1
        self.d2=d2
        self.d3=d3
        self.d4=d4
        self.d5=d5
        self.d6=d6
    
    #回転
    def roll(self,c):
        if c=='N':
            self.d1,self.d5,self.d6,self.d2=self.d2,self.d1,self.d5,self.d6
        elif c=='S':
            self.d1,self.d5,self.d6,self.d2=self.d5,self.d6,self.d2,self.d1
        elif c=='E':
            self.d1,self.d3,self.d6,self.d4=self.d4,self.d1,self.d3,self.d6
        elif c=='W':
            self.d1,self.d3,self.d6,self.d4=self.d3,self.d6,self.d4,self.d1
        elif c=='R':
            self.d2,self.d3,self.d5,self.d4=self.d4,self.d2,self.d3,self.d5
        elif c=='L':
            self.d2,self.d3,self.d5,self.d4=self.d3,self.d5,self.d4,self.d2
    
    #上の面に来る最小値
    def minnum(self):
        return min(self.d1,self.d2,self.d3,self.d4,self.d5,self.d6)
    
    #前の面に来る2つめに小さい値
    def min2num(self):
        return min(self.d2,self.d3,self.d4,self.d5,self.d6)
    
    #2つめが下の面に来るときに前の面に来る3番目に小さい値
    def min3num(self):
        return min(self.d2,self.d3,self.d4,self.d5)
    
    #回転動作    
    def rolling(self):
        m=self.minnum()
        if m==self.d3:
            self.roll('W')
        elif m==self.d6:
            self.roll('E')
            self.roll('E')
        elif m==self.d4:
            self.roll('E')
        elif m==self.d2:
            self.roll('N')
        elif m==self.d5:
            self.roll('S')
        m=self.min2num()
        if m==self.d3:
            self.roll('L')
        elif m==self.d5:
            self.roll('L')
            self.roll('L')
        elif m==self.d4:
            self.roll('R')
        elif m==self.d6:
            m=self.min3num()
            if m==self.d3:
                self.roll('L')
            elif m==self.d5:
                self.roll('L')
                self.roll('L')
            elif m==self.d4:
                self.roll('R')
    
    #値をリストで返す        
    def returnlist(self):
        l=[self.d1,self.d2,self.d3,self.d4,self.d5,self.d6]
        return l


n=int(input())
check=True
l=[]

#ダイスの入力
for i in range(n):
    a,b,c,d,e,f=map(int,input().split())
    D=Dice(a,b,c,d,e,f)
    D.rolling()
    
    #今までのダイスと比較
    for dice in l:
        if dice==D.returnlist():
            check=False
    
    #リストに追加        
    l.append(D.returnlist())
    
if check:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5624
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
using namespace std;


int main(){
	int a,b;
	cin >> a>>b;
	if (a + b >= 10){
		cout << "error\n";
	}
	else{
		cout << a + b << "\n";
	}

	return 0;
}

Measured memory_bytes: 256