akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
int main (){
char s[10]={0};
int shu=0,wa=0,ji[10]={0},i,j;
  scanf ("%s",s);
  for (i=0;i<strlen(s);i++){
   ji[i]= s[i]-'0';
  }
for (i=0;i<strlen(s);i++){
wa=wa+ji[i];
shu=shu+(ji[i]*pow(10,strlen(s)-i-1));
}
  if (shu%wa == 0){
  printf ("Yes");
  }
    else{
    printf ("No");
    }
   return 0; 
  }


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

from pprint import pprint
from collections import deque, defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float("inf")

k = int(input())
a, b = map(int, input().split())

res = 0
flag = False
while res <= b:
    res += k
    if a <= res <= b:
        flag = True

if flag:
    print("OK")
else:
    print("NG")


Measured memory_bytes: 68396
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+100;
int cnt[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=2;i<=n;++i)
    {
        int id;
        cin>>id;
        ++cnt[id];
    }
    for(int i=1;i<=n;++i)
    {
        cout<<cnt[i]<<endl;
    }
    return 0;
}


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


int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int c=1; c < n;c++) {
        for (int a=1; a*a <= n-c; a++) {
            if ((n-c)%a == 0) {
                cnt++;
                if (a*a != n-c) cnt++; 
            }
        }
    } 
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int a[n];
    int total = 0;

    rep(i, n) {
        cin >> a[i];
        total += a[i];
    }

    int target = total / (4 * m) + (total % (4 * m) > 0 ? 1 : 0);
    int count = 0;

    rep(i, n) {
        if (a[i] >= target) count++;
    }

    cout << (count >= m ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
n=int(input())
numlist=[int(i) for i in input().split()]
check=0
if len(numlist)==1:
    print("Yes")
else:

    a=numlist[0]
    b=numlist[1]
    if a-b>1:
        print("No")
    else:
        if a-b==1:
            numlist[0]=numlist[0]-1
        elif b-a>0:
            numlist[1]=numlist[1]-1
        elif b==a:
            numlist[1]=numlist[1]-1
            numlist[0]=numlist[0]-1


        for i in range(1,n-1):
            a=numlist[i]
            b=numlist[i+1]
            if a-b>=1:
                print("No")
                check+=1
                break
            elif b-a>0:
                numlist[i+1]=numlist[i+1]-1
        if check==0:        
            print("Yes")



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

using namespace std;

const int P = 1e9+7;
const int maxn = 1e6+1;
long long inv[maxn];
int cnt[maxn];
bool prime[1000];

int gcd(int a, int b){
    return b==0 ? a : gcd(b, a%b);
}

long long fp(int a, int n){
    if(n==0)
        return 1;
    long long h = fp(a, n/2);

    return n & 1 ? h * h % P * a % P : h * h % P;
}

int main(){
    int n;

    cin >>n;
    vector<int> v(n);
    vector<int> p;
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    memset(prime, 1, sizeof(prime));

    inv[1] = 1;
    for(int i=2;i<maxn;i++){
        inv[i] = fp(i, P - 2);
    }

    for(int i=2;i*i<1000;i++){
        if(prime[i]){
            for(int j=i*i;j<1000;j+=i){
                prime[j] = 0;
            }
        }
    }
    for(int i=2;i<1000;i++){
        if(prime[i])
            p.push_back(i);
    }


    for(int i=0;i<n;i++){
        int rec = v[i];
        for(int &j:p){
            if(j*j > v[i])
                break;

            int c = 0;
            while(v[i] % j == 0){
                c++;
                v[i]/=j;
            }
            cnt[j] = max(c, cnt[j]);
        }
        if(v[i] > 1){
            cnt[v[i]] = max(cnt[v[i]], 1);
        }
        v[i] = rec;
    }

    long long lcm = 1;
    for(int i=2;i<maxn;i++){
        lcm = lcm * fp(i, cnt[i]) % P;
    }

    int ans = 0;
    for(int i=0;i<n;i++){
        ans += lcm * inv[v[i]] % P;
        ans %= P;
    }
    cout << ans;
}


Measured memory_bytes: 11776
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using ll = long long;
using ld = long double;
using Pa = std::pair<ll, ll>;
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n,ll mod) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow(((x * x)%mod), n / 2,mod));
	else
		return ((x%mod) * pow(x, n - 1,mod));
}
vector<ll>primess(ll n) {
	vector<ll>a;
	while (n % 2 == 0)n /= 2, a.push_back(2);
	ll sosuu = 3;
	while (n != 1) {
		if (n % sosuu == 0)n /= sosuu, a.push_back(sosuu);
		else if (sosuu > sqrt(n) + 2) {
			a.push_back(n);
			break;
		}
		else sosuu += 2;
	}
	return a;
}
bool prime(int n) {
	int i = 2;
	if (n == 2)return true;
	else if(n <= 1)return false;
	if (n % i == 0)return false;
	i = 3;
	while (i <= sqrt(n)) {
		if (n % i == 0)return false;
		i += 2;
	}
	return true;
}
int main() {
	int n; cin >> n;
	string s; cin >> s;
	rip(i, s.size()) {
		int num = s[i] - 'A';
		num = (num + n) % 26;
		s[i] ='A'+ num;
	}
	cout << s << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define SIZE 200005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int to[SIZE];
int L[SIZE],R[SIZE];
int main()
{
	int a,b;
	scanf("%d",&a);
  scanf("%d",&b);

  //vector <int> a(b);
  //vector <int> b(a);

  if(a <= b){
    for(int i=0;i<b;i++){
      printf("%d", a);
    }
    printf("\n");
  }else{
    for(int i=0;i<a;i++){
      printf("%d", b);
    }
    printf("\n");
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
int a,b,c,d,e,f;
double A[2][2];
double B[2];
double inv_A[2][2];
while(~scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)){
int det = a*e-b*d;
A[0][0]=a; A[0][1] = b;
A[1][0]=d; A[1][1] = e;
B[0] = c;
B[1] = f; 

inv_A[0][0]=A[1][1]; inv_A[0][1]=-A[0][1];
inv_A[1][0]=-A[1][0]; inv_A[1][1]=A[0][0];

double res[2];
res[0]=0;
res[1]=0;


for(int j=0;j<2;j++){
for(int k=0;k<2;k++){
res[j]+=1.0/(double)det *inv_A[j][k]*B[k];
}
}

printf("%.3f %.3f\n",res[0],res[1]);
}
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  string ans = "";
  if (a <= b) {
    rep(i, b) {
      ans += to_string(a);
    }
  } else {
    rep(i, a) {
      ans += to_string(b);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n, a, b, c = map(int, input().split())
l = [int(input()) for i in range(n)]
def dfs(cur, q, w, e):
    if cur == n:
        return abs(a-q)+abs(b-w)+abs(c-e)-30 if min(q, w, e) != 0 else 10**18
    return min(
        dfs(cur+1, q+l[cur], w, e)+10,
        dfs(cur+1, q, w+l[cur], e)+10,
        dfs(cur+1, q, w, e+l[cur])+10,
        dfs(cur+1, q, w, e),
    )
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
struct UnionFind{
  vector<int> p;
  int g;
  void init(int n){
    p = vector<int>(n, -1);
    g = n;
  }
  int find(int a){
    return p[a] < 0 ? a : p[a] = find(p[a]);
  }
  bool merge(int a, int b){
    a = find(a);
    b = find(b);
    if(a == b) return 0;
    g--;
    if(p[a] > p[b]) swap(a, b);
    p[a] += p[b];
    p[b] = a;
    return 1;
  }
} uf;

int n, z;
map<int, V<int>> m;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> z;
  FOR(i, 0, n){
    int k;
    cin >> k;
    FOR(_, 0, k){
      int l;
      cin >> l;
      m[l].pb(i);
    }
  }
  uf.init(n);
  each(itr, m) for(int a:itr->se) uf.merge((itr->se)[0], a);
  cout << (uf.g==1 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 7168
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;

int main() {
    string s;
    cin >> s;
    ll sc=0,nc=0,wc=0,ec=0;
    rep(i, 0, s.size()){
        switch (s[i]) {
            case 'S':
                sc++;
                break;
            case 'N':
                nc++;
                break;
            case 'W':
                wc++;
                break;
            case 'E':
                ec++;
                break;
            default:
                break;
        }
    }
    if(sc>=1 && nc>=1 && wc>=1 && ec>=1) {cout << "Yes" << endl;return 0;}
    if(sc>=1 && nc>=1 && wc==0 && ec==0) {cout << "Yes" << endl;return 0;}
    if(sc==0 && nc==0 && wc>=1 && ec>=1) {cout << "Yes" << endl;return 0;}
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<double> a(n), b(n);
  for (auto &e : a)
    cin >> e;
  for (auto &e : b)
    cin >> e;
  for (int i = 1; i <= 3; ++i)
  {
    double sum = 0;
    for (int j = 0; j < n; ++j)
    {
      sum += pow(fabs(a[j] - b[j]), i);
    }
    sum = pow(sum, 1.0 / i);
    cout << fixed << setprecision(10) << sum << endl;
  }
  double nmin = 0.0;
  for (int i = 0; i < n; ++i)
    nmin = max(nmin, fabs(a[i] - b[i]));
  cout << fixed << setprecision(10) << nmin << endl;

  return 0;
}



Measured memory_bytes: 3432
import java.util.Scanner;

class Main {

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

	int x[] = new int[5];
	int y[] = new int[5];
	for (int i = 0; i < 5; i++) {
	    x[i] = sc.nextInt();
	    y[i] = x[i] % 10;
	}

	for (int i = 0; i < 4; i++) {
            for (int j = 4; j > i; j--) {
		if (y[j - 1] < y[j]) {
		    int tmp_x = x[j - 1];
		    x[j - 1] = x[j];
		    x[j] = tmp_x;

		    int tmp_y = y[j - 1];
		    y[j - 1] = y[j];
		    y[j] = tmp_y;
		}
	    }
	}

	int count = 0;
	int z = 4;
	while (y[z] == 0) {
	    count += x[z];
	    z--;
	    if (z == -1)
		break;
	}
	
	int k;
	for (k = 0; k < z; k++)
	    count += (x[k] - y[k]) + 10;

	if (z != -1)
	    System.out.println(count + x[z]);
	else
	    System.out.println(count);
    }
}

Measured memory_bytes: 21844
//Tsundoku
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
#include <stack>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    unsigned long long N,M,K;
    cin >> N >> M >> K;
    vector<long long> A(N);
    vector<long long> accA(N+1,0);
    //stack<int>A;
    
    // 累積和をつくる
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        accA[i+1] = accA[i] + A[i];
    }
    vector<long long> B(M);
    vector<long long> accB(M+1,0);
    //stack<int> B;
    for (int j = 0; j < M; j++) {
        cin >> B[j];
        accB[j+1] = accB[j] + B[j];
    }
    long long ans = 0;
    for (int i = 0; i <= N; i++) {
        //cout << "i=" << i << endl;
        long long tmp = K - accA[i];
        if (tmp < 0) {
            break;
        }
        //cout << "tmp=" << tmp << endl;
        long long result = 0;
        long long l,r;
        l = 0;
        r = M;

        auto it = upper_bound(accB.begin(), accB.end(), tmp);
        long long n = it - accB.begin();
        ans = max(ans, i + n-1);
        /*
        while (r>l) {
            long long mid = (r-l) / 2;
            //cout << "mid=" << mid << endl;
            if (tmp > accB[mid]) {
                l = mid + 1;
                //cout << "l=" << l << endl;
                //cout << "r=" << r << endl;
            }
            else {
                r = mid - 1;
                //cout << "l=" << l << endl;
                //cout << "r=" << r << endl;
            }        
        }
        result = i + l;
        //cout << "result=" << result << endl;
        ans = max(ans,result);
        */
    }


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


Measured memory_bytes: 9192
package main

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

func min(nums []int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	s := nextMega()
	cnt := make([]int, 2)
	for i := range s {
		cnt[s[i]-'0']++
	}
	puts(min(cnt) * 2)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 1024
function main(input) {
  const [houseW, curtainW] = input.split(' ');
  console.log( eval(houseW - eval(curtainW * 2)) > 0 ? eval(houseW - (curtainW * 2)) : 0 );
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
 
using namespace std ;
 
typedef tree<pair<pll,lli>,null_type,less<pair<pll,lli>>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
 
#define MAXN 200000

int main () 
{
/////////////////////////////////////
    
 
/////////////////////////////////////  
	
		lli k,x;
		cin>>k>>x;

		if(k*500 >= x) cout<<"Yes";
		else cout<<"No";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()
	
int N;
vector<ll> A;

int main(){
	cin >> N;
	A.resize(N);
	for(auto &a : A) cin >> a;

	vector<ll> dp(N+1, 0);
	dp[0] = 1000;
	dp[1] = 1000;

	for(int i=2;i<=N;i++) {
		dp[i] = dp[0];
		for (int j=1;j<i;j++) {
			dp[i] = max(dp[j], (dp[j] / A[j-1]) * A[i-1] + (dp[j] % A[j-1]));
		}
	}

	cout << dp[N] << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1]%d7 + C[i - 1][j]%d7)%d7;}}}
    return C[n][k]%d7;
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    
    ll n,k;
    cin>>n>>k;
    
    if(n==1||k==1){cout<<1;}
    else{
    if(n%2==0&&k%2==0){cout<<(n*(k/2));}
    if(n%2==0&&k%2==1){cout<<(n*(k/2))+n/2;}
    if(n%2==1&&k%2==0){cout<<(n*(k/2));}
    if(n%2==1&&k%2==1){cout<<(n*((k-1)/2))+(n+1)/2;}
   
    }
    
//code ends
    return 0;
}


Measured memory_bytes: 256
# C
n = int(input())
cond = []
for _ in range(n-1):
    c = list(map(int, input().split()))
    cond.append(c)

for i in range(n):
    if i == n-1:
        print(0)
    else:
        ela = 0

        for j in range(i, n-1):
            if j == i:
                # noru
                ela += cond[j][1]
            elif j != i:
                # noru
                if ela <= cond[j][1]:
                    ela = cond[j][1]
                elif ela > cond[j][1]:
                    k = cond[j][2]
                    if ela%k == 0:
                        pass
                    else:
                        ela = ela + (k-(ela%k))               
            # susumu
            ela += cond[j][0]
        print(ela)

Measured memory_bytes: 3188
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
ans=0
(N/1.08).floor.upto(N) do|i|
    if (i*1.08).floor==N
        ans=i
        break
    end
end
if ans.zero?
    puts ":("
else
    puts ans
end

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

int main() {
  ll deposit = 100;
  ll X;
  cin >> X;

  ll n = 0;
  while (true) {
    deposit = deposit * 1.01;
    n++;
    if (deposit >= X) break;
  }

  cout << n << endl;
  return 0;
}


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

int main() {
  int n, i;
  while (cin >> n, n) {
    int s = -n;
    for (i = 1; i * i <= n; i++) {
      if (n % i == 0) s += i + n / i;
    }
    i--;
    if (i * i == n) s -= i;
    cout << (s == n ? "perfect" : s > n ? "abundant" : "deficient") << " number" << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  string s;
  cin>>s;
  int a=0,b=0,c=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0')a++;
    else b++;
    if(a>0&&b>0){
      c+=2;
      a--,b--;
    }
  }
  cout<<c;
}

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

typedef long long ll;

ll digit(ll n){
  ll ret = 0;
  while(n >0){
    ret += n % 10;
    n = n / 10;
  }
  return ret;
}

int main(){
  ll N;
  cin >> N;
  ll x = digit(N);
  string ans = N%x==0 ? "Yes" : "No";
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

from itertools import accumulate

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n, w = li()
value = {i: [] for i in range(4)}

for i in range(n):
    wei, val = li()

    if i == 0:
        w0 = wei

    value[wei - w0].append(val)

for i in range(4):
    value[i].sort(reverse=True)

    value[i] = [0] + list(accumulate(value[i]))


ans = 0

for i in range(len(value[0])):
    for j in range(len(value[1])):
        for k in range(len(value[2])):
            rest = w - i*w0 - j*(w0+1) - k*(w0+2)
            x = rest // (w0+3)

            if x < 0:
                continue
            else:
                ans = max(ans, value[0][i] + value[1][j] + value[2][k] + value[3][min(len(value[3])-1, x)])

print(ans)


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    // ostr << p.first << ", " << p.second;
    ostr << "(" << p.first << ", " << p.second << ")";
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll v(n); v[i]=x;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll v(m,vll(n)); v[i][j]=x;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll v(n); v[i]=make_pair(x,y); v[i].first/second;
// v.front() : v[0]
// v.back()  : v[v.size()-1]

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF ((ll)1e+12)
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<=(b); i++)
#define FORR(i,a,b) for(ll i=(b); i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v){return accumulate(all(v), (T)0);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    ll x, y=0, a=100;
    cin >> x;
    while(a<x){
        a = a * 1.01;
        y++;
    }
    cout << y << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 10000000000LL
#define rep(i,n) for(i=0;i<n;i++)

typedef pair<int,int> pii;

char a[1005][1005];
int used[1005][1005]={};
int h,w;
pii place[10];

int search(int sx,int sy,int gx,int gy){
    int i,j;
    int dx[4]={-1,0,1,0};
    int dy[4]={0,-1,0,1};
    rep(i,h)rep(j,w)used[i][j]=0;
    int ans=0;
    used[sx][sy]++;
    queue<pii> q1,q2;
    q1.push(pii(sx,sy));
    while(1){
        bool f=false;
        while(q1.size()){
            int x=q1.front().first;
            int y=q1.front().second;
            if(x==gx && y==gy){
                f=true;
                break;
            }
            rep(i,4){
                int nx=x+dx[i];//next
                int ny=y+dy[i];//next
                if(nx<0 || nx>=h || ny<0 || ny>=w)continue;
                if(a[nx][ny]!='X' && used[nx][ny]==0){
                    used[nx][ny]++;
                    q2.push(pii(nx,ny));
                }
            }
            q1.pop();
        }

        if(f)break;

        while(q2.size()){
            q1.push(pii(q2.front().first,q2.front().second));
            q2.pop();
        }
        ans++;
    }
    return ans;
}

int main(void) {
    int n,i,j;
    cin>>h>>w>>n;
    rep(i,h){
        cin>>a[i];
        rep(j,w)
            if(a[i][j]=='S'){
                place[0].first=i;
                place[0].second=j;
            }else if(a[i][j]>'0' && a[i][j]<='n'){
                place[a[i][j]-'0'].first=i;
                place[a[i][j]-'0'].second=j;
            }
    }
    
    int ans=0;
    rep(i,n)
        ans+=search(place[i].first,place[i].second,place[i+1].first,place[i+1].second);
        
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8076
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    lint n, m;
    cin >> n >> m;
    vector<pll> v(n);
    repeat (i, n) cin >> v[i].fst >> v[i].snd;
    sort(v.begin(), v.end(), [](pll a, pll b) -> bool {return a.fst < b.fst;});
    
    lint sum = 0;
    lint price = 0;
    repeat (i, v.size()) {
        if (sum == m) break;
        lint p = v[i].fst;
        lint k = v[i].snd;
        k = min(k, m-sum);
        sum += k;
        price += (k * p);
    }
    cout << price << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char s[10];
	cin >> s;
	if (strcmp(s, "ABC") == 0)
		cout << "ARC" << endl;
	else if (strcmp(s, "ARC") == 0)
		cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 3588
N,K = map(int, input().split())
H = list(map(int, input().split()))

table = [0]*N

for i in range(1, N):
    if i < K:
        table[i] = min(
            [table[i1] + abs(H[i1]-H[i]) for i1 in range(0, i)])
#         print(table)
    else:
        table[i] = min(
            [table[i-k] + abs(H[i-k]-H[i]) for k in range(1, K+1)]
        )
#     print(table)

print(table[-1])

Measured memory_bytes: 52448
#![allow(non_snake_case)]

use proconio::input;
use std::cmp::min;

fn main() {
    input! {
        N: usize,
        H: [isize; N],
    }

    let mut cost_list = vec![0; N + 10];
    cost_list[1] = (H[1] - H[0]).abs();
    for i in 2..N {
        let x = (H[i] - H[i - 2]).abs();
        let y = (H[i] - H[i - 1]).abs();
        cost_list[i] = min(cost_list[i -2] + x, cost_list[i- 1] + y);
    }
    println!("{}", cost_list[N - 1]);
}


Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,c,sum,cn=0;
    cin>>n>>m>>c;
    int a[m];
    int i,j;
    for(i=0; i<m; i++)
        cin>>a[i];
    int b[n][m];
    for(i=0; i<n; i++)
        for(j=0; j<m; j++)
            cin>>b[i][j];

     for(i=0;i<n;i++)
     {
         sum=c;
         for(j=0;j<m;j++)
         {
             sum=sum+(a[j]*b[i][j]);

         }
         if(sum>0) cn++;
     }
     cout<<cn<<endl;
     return 0;



}


Measured memory_bytes: 256
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
    check = True
    for j in range(m):
        light = 0
        for k in range(1, len(l[j])):
            if ((i >> l[j][k] - 1) & 1):
                light += 1
        if light % 2 != p[j]:
            check = False
    if check:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>

using namespace std;

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

int main(){
    long int w, h, x, y;
    cin >> w >> h >> x >> y;
    double area = (double)(w * h);
    area = area / 2;
    if (w == x + x && h == y + y) {
        printf("%.11lf %d", area, 1);
        // cout << area << " 1" << endl;
    }else{
        printf("%.11lf %d", area, 0);
        // cout << area << " 0" << endl;
    }
    
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  for(int i=0;i<x.size();i++){
    cin >> x.at(i);
  }
  int ans = 0;
  for(int i=0;i<x.size();i++){
    ans +=  2*min(x.at(i),K-x.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;

typedef struct {
    int parent;
    int left_child;
    int right_child;
    int num_children;
    int depth;
    int height;
    string type;
} Node;

int calcDepthHeight( int id, int depth );
void print( int id );

#define MAX_N (30)
#define NIL (-1)
Node node[MAX_N];
int n;
int root_id;

int main()
{

    scanf("%d", &n);

    // ?????????
    for ( int i = 0; i < n; i++ ) {
	node[i].parent = NIL;
	node[i].type = "internal node";
	node[i].height = NIL;
    }
    
    for ( int i = 0; i < n; i++ ) {
	int id, left, right;
	int num_children = 0;
	scanf("%d %d %d", &id, &left, &right);

	node[id].left_child = left;
	node[id].right_child = right;
	if ( left != NIL ) {
	    node[left].parent = id;
	    num_children++;
	}
	if ( right != NIL ) {
	    node[right].parent = id;
	    num_children++;
	}
	node[id].num_children = num_children;
	if ( num_children == 0 ) { // ???
	    node[id].type = "leaf";
	    node[id].height = 0;
	}
    }

    // ????????¢???
    for ( int i = 0; i < n; i++ ) {
	if ( node[i].parent == NIL ) {
	    root_id = i;
	    node[i].type = "root";
	    break;
	}
    }

    calcDepthHeight( root_id, 0 );

    for ( int i = 0; i < n; i++ ) {
	print( i );
    }

    return 0;
}


int calcDepthHeight( int id, int depth )
{
    node[id].depth = depth;
    if ( node[id].height != NIL ) {
	return node[id].height;
    }
    else {			// ??????height????±????????????????
	int height = 0;
	if ( node[id].left_child != NIL ) {
	    height = max( height, 1 + calcDepthHeight( node[id].left_child, depth + 1 ) );
	}
	if ( node[id].right_child != NIL ) {
	    height = max( height, 1 + calcDepthHeight( node[id].right_child, depth + 1 ) );
	}
	node[id].height = height;

	return height;
    }
}


void print( int id )
{
    printf("node %d: ", id);
    printf("parent = %d, ", node[id].parent);
    if ( node[id].parent != NIL && node[ node[id].parent ].num_children > 1 ) {
	if ( node[node[id].parent].left_child == id ) {
	    printf("sibling = %d, ", node[node[id].parent].right_child);
	}
	else {
	    printf("sibling = %d, ", node[node[id].parent].left_child);
	}
    }
    else {
	printf("sibling = -1, ");
    }
    printf("degree = %d, ", node[id].num_children);
    printf("depth = %d, ", node[id].depth);
    printf("height = %d, ", node[id].height);
    printf("%s\n", node[id].type.c_str());
}

Measured memory_bytes: 1068
s = int(input())
d = {s:1}
def func(n,i):
    tmp = 0
    if n%2 == 0:
        tmp = n//2
    else:
        tmp = 3*n + 1
    if tmp in d:
        return i+1
    else:
        d[tmp] = 1
        return func(tmp,i+1)
print(func(s,1))

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
using namespace std;
using namespace __gnu_cxx;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;

int n,a[200007];
vector<int> b,c;

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if((n-i)%2==0) c.push_back(a[i]);
		else b.push_back(a[i]);
	}
	for(int i=SZ(b)-1;i>=0;i--)
		printf("%d ",b[i]);
	for(int i=0;i<SZ(c);i++)
		printf("%d%c",c[i],i==SZ(c)-1?'\n':' ');
	return 0;
}


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

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

int main()
{
    fastIO();

    long long n, k, nd = 0;
    cin >> n >> k;
    while(n!= 0){
        n/=k;
        nd++;
    }
    cout << nd << '\n';
    return 0;
}


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

using namespace std;

int main() {
    set<pair<long long,int>> q;
    vector<long long> ans;
    for (int t = 1; t < 10; ++t) {
        q.emplace(1LL * t, t);
    }
    while (!q.empty()) {
        auto p = *q.begin(); q.erase(q.begin());
        ans.push_back(p.first);
        // cout << p.first << endl;
        if (ans.size() > 200000) break;
        int lst = p.second;
        if (lst > 0) {
            q.emplace(p.first * 10 + (lst - 1), lst - 1);
        }
        q.emplace(p.first * 10 + lst, lst);
        if (lst < 9) {
            q.emplace(p.first * 10 + lst + 1, lst + 1);
        }
    }
    int k;
    cin >> k;
    cout << ans[k - 1] << '\n';
}

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

#define mp make_pair
#define fi first
#define se second
#define forn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) forn(i, 0, (n))
#define all(x) x.begin(), x.end()
#define len(x) (int)x.size()
#define endl '\n'

#define ld long double
#define vc vector
#define pq priority_queue
#define uset unordered_set
#define umap unordered_map
#define vi vc<int>
#define pii pair<int, int>
#define vii vc<pii>

inline void FASTIO(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void solve(){
    return;
}

signed main(){
    FASTIO();
    int n; cin >> n;
    set<string> a;
    rep(i, n){
        string x;
        cin >> x;
        a.insert(x);
    }
    cout << len(a);
}


Measured memory_bytes: 19288
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ss  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element) != container.end())
#define ss  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(c) c.begin(), c.end()
#define pb push_back
#define mp make_pair
#define mod (1000000000 + 7)
#define inf (1e18+9)
#define fi first
#define se second
#define MAXN   1000001 
typedef long long ll;
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_set;

long long fastpow(long long n, long long x, long long m){
	
    long long ret = 1;
    
    while(x){
    if(x&1) (ret*=n)%=m;
    x>>=1;
    (n*=n)%=m;
    }
  
 return ret;
}
ll add(ll a,ll b){
	return((a%mod)+(b%mod))%mod;
}
ll prod(ll a,ll b){
	a%=mod;
	b%=mod;
	return ((a%mod)*(b%mod)%mod);
}
ll dp[100005]={0};
int main()
{
    int n,q,w;
    ll ans=0;
    	cin>>n>>w;
    	vector< pair<int,int> > v(n);
    	for(int i=0;i<n;i++){
    		 cin>>v[i].fi>>v[i].se;
		}
    	  for(int j=0;j<n;j++){
    	  	for(int i=w-v[j].fi;i>=0;i--){
    	  		dp[i+v[j].fi]=max(dp[i+v[j].fi],dp[i]+v[j].se);
    	  		ans=max(ans,dp[i+v[j].fi]);
			  }
		 }
		// ans=max(ans,dp[i]);


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


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


void solve(long long N, std::vector<std::string> S){
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;

    for (int i = 0;i < S.size(); i++) {
        if (S[i] == "AC") {
            ac++;
        }
        if (S[i] == "WA") {
            wa++;
        }
        if (S[i] == "TLE") {
            tle++;
        }
        if (S[i] == "RE") {
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

// ===============================================================================

int main() {
  int n;
  cin >> n;
  int ans = 0;
  while (n) {
    ans += n % 10;
    n /= 10;
  }
  cout << ((ans == 1) ? 10 : ans) << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use rand::random;
use std::time::{Duration, Instant};


#[fastout]
fn main() {
    input! {
    d: usize,
    c: [i64; 26],
    s: [[i64; 26]; d]
    }
    let start = Instant::now();
    let mut t = vec![0; d];
        for i in 0..d {
            t[i] = random::<usize>() % 26
        }
    let mut end = start.elapsed();
    let mut cur_s = score(&t, &c, &s);
    while end.as_nanos() < 1_500_000_000 {
        let k = random::<usize>() % d;
        let prev_k = t[k];
        t[k] = random::<usize>() % 26;
        let next_s = score(&t, &c, &s);
        if cur_s > next_s {
            t[k] = prev_k;
        } else {
            cur_s = next_s;
        }
        end = start.elapsed();
    }
    for i in 0..d {
        println!("{}",t[i] + 1);
    }
}

fn score(t: &Vec<usize>, c: &Vec<i64>, s: &Vec<Vec<i64>>) -> i64 {
    let mut last = vec![0; 26];
    let mut score = 0;
    for i in 0..t.len() {
        score += s[i][t[i]] - (0..26).fold(0, |acc, x| acc + (i as i64 + 1 - last[x]) * c[x]);
        last[t[i]] = i as i64;
    }
    score
}


Measured memory_bytes: 2764
N, M = gets.split.map(&:to_i)
MOD = 1e9.to_i + 7

require 'prime'

def comb(a, b)
  b = a - b if b > a - b
  return 1 if b == 0
  return a if b == 1
  ns = [*a - b + 1 .. a]
  ds = [*1 .. b]
  (2 .. b).each do |p|
    if (pi = ds[p - 1]) > 1
      of = (a - b) % p
      (p - 1).step(b - 1, p) do |k|
        ns[k - of] /= pi
        ds[k] /= pi
      end
    end
  end
  ns.reject{|n| n == 1}.inject{|r, n| r*n % MOD}
end

puts M.prime_division.inject(1){|r, (p, q)| r*comb(N + q - 1, q) % MOD}

Measured memory_bytes: 2172
#include <iostream>

int main(){
   std::string S;
   std::cin >> S;

   for(char ch='a'; ch<='z'; ++ch){
      bool flag = true;
      for(int i=0; i<S.size(); ++i){
	 if(ch==S[i]){
	    flag = false;
	    break;
	 }
      }
      if(flag){
	 std::cout << ch << std::endl;
	 return 0;
      }
   }
   std::cout << "None" << std::endl;
   return 0;
}


Measured memory_bytes: 512
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
constexpr ld PI = acos(-1);

vector<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

#ifdef LOCAL
#else
#endif

constexpr int MOD = 1e9 + 7;

int pw(int a, int b) {
    int ans = 1;
    while (b) {
        if (b & 1) {
            ans *= a;
            ans %= MOD;
        }
        a *= a;
        a %= MOD;
        b >>= 1;
    }
    return ans;
}

void run() {
    int n;
    cin >> n;
    map<pair<int, int>, int> cnts;
    int cnt_z = 0;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        int gc;
        if (x == 0 && y == 0) {
            cnt_z++;
            continue;
        } else {
            gc = gcd(abs(x), abs(y));
        }
        cnts[{x / gc, y / gc}]++;
    }
    int ans = 1;
    set<pair<int, int>> usd;
    for (auto [vec, cnt] : cnts) {
        auto [x, y] = vec;
        if (usd.count({x, y}))
            continue;
        usd.insert({x, y});
        usd.insert({-x, -y});
        usd.insert({-y, x});
        usd.insert({y, -x});
        int cans1 = (ans * pw(2, cnts[{x, y}] + cnts[{-x, -y}]) - ans + MOD) % MOD;
        int cans2 = (ans * pw(2, cnts[{-y, x}] + cnts[{y, -x}]) - ans + MOD) % MOD;
        ans = (ans + cans1 + cans2) % MOD;
    }
    cout << (ans - 1 + MOD + cnt_z) % MOD << '\n';
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    cout << fixed << setprecision(20);
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 103620
#include                        <bits/stdc++.h>
#define   lli                   unsigned long long int
#define   ll                    long long int
#define   PI                    acos(-1.0)
#define   UNIQUE(V)             (V).erase(unique(ALL(V), (V).end()) //vector/string etc must need to be sorted
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define   ALL(V)                (V).begin(), (V).end()
#define   MEMSET(a, val)        memset(a, val, sizeof(a))
using     namespace             std;


template  <class T> T GCD(T a, T b) { return (b != 0 ? GCD <T> (b, a%b) : a); }
template  <class T> T LCM(T a, T b) { return ((a*b)  / GCD <T> (a, b)); }


int main()
{
//  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    //timesave;

    //while(1){

    int n, k, val;
    cin >> n >> k;

    double total = 0.0, sum;

    for(int i = 1; i <= n; i++){
        sum = 1.0/(double) n; val = i;

        while(val < k){
            sum *= 0.5;
            val *= 2;
        }

        total += sum;
    }

    cout << fixed << setprecision(12) << total << endl;

    //}

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans = 1;
		long max = 1000000000000000000L;
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextLong();
		    if (arr[i] == 0) {
		        System.out.println(0);
		        return;
		    }
		}
		for (int i = 0; i < n; i++) {
		    long x = arr[i];
		    if (max / ans < x) {
		        System.out.println(-1);
		        return;
		    }
		    ans *= x;
		}
		if (ans > max) {
		    System.out.println(-1);
		} else {
		    System.out.println(ans);
		}
	}
}


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

int main()
{
    int dp[100001][3]={0};
    int h[100001][3];
    int n;
    cin>>n;

    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>h[i][j];
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k){
                    dp[i+1][k]=max(dp[i+1][k],dp[i][j]+h[i][k]);
                  //  printf("dp[%d][%d]=%d\n",i+1,k,dp[i+1][k]);
                }
            }
        }
    }
    int v=0;
    for(int i=0;i<3;i++)
        v=max(v,dp[n][i]);
    cout<<v<<endl;
}

Measured memory_bytes: 2560