akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s,t;
    R(s,t);
    if(t.substr(0,SZ(s))==s){
        W("Yes");
    }
    else W("No");
    return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define pi 3.141592653
using namespace std;

int main(){
    double k,m,n;
    cin>>k;
    cin>>m>>n;
    int x=ceil(m/k);
    if((k*x)>=m && (k*x)<=n ){
        cout<<"OK";
    }
    else{
        cout<<"NG";
    }
}





Measured memory_bytes: 3700
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int k,n;
    cin>>n>>k;
    if(k==1)    cout<<0<<endl;
    else        cout<<n-k<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	void run() {
		int n = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		long need = 0;
		int ans = 0;
		ArrayList<Integer> extras = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			b[i] = in.nextInt();
			if (a[i] < b[i]) {
				need += b[i] - a[i];
				ans++;
			} else if (a[i] > b[i]) {
				extras.add(a[i] - b[i]);
			}
		}
		Collections.sort(extras);
		while (need > 0) {
			if (extras.isEmpty()) {
				out.println(-1);
				return;
			}
			ans++;
			need -= extras.get(extras.size() - 1);
			extras.remove(extras.size() - 1);
		}
		out.println(ans);
	}

	static MyScanner in;
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		boolean stdStreams = true;
		String fileName = Main.class.getSimpleName().replaceFirst("_.*", "").toLowerCase();
		String inputFileName = fileName + ".in";
		String outputFileName = fileName + ".out";
		
		Locale.setDefault(Locale.US);
		BufferedReader br;
		if (stdStreams) {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			br = new BufferedReader(new FileReader(inputFileName));
			out = new PrintWriter(outputFileName);
		}
		in = new MyScanner(br);
		int tests = 1;//in.nextInt();
		for (int test = 0; test < tests; test++) {
			//out.print("Case #" + (test + 1) + ": ");
			new Main().run();
		}
		br.close();
		out.close();
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		MyScanner(BufferedReader br) {
			this.br = br;
		}
		
		void findToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		
		String next() {
			findToken();
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 49056
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, a[3003] = {}, p[3003] = {1};
    ll e[3003][3003] = {};
    for (int i = 1; i <= 3000; i++) p[i] = p[i - 1] * 2 % 998244353;
    cin >> n >> m;
    e[0][0] = 1;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            e[i][j] = e[i - 1][j] * 2 % 998244353;
            if (j >= a[i]) e[i][j] = (e[i][j] + e[i - 1][j - a[i]]) % 998244353;
            //cout << e[i][j] << " \n"[j == m];
        }
    }
    cout << e[n][m];
}


Measured memory_bytes: 74124
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,x;
    ll a[110];
    cin >> N >> x;
    rep(i,0,N){
        cin >> a[i];
    }
    sort(a, a+N);
    ll ans = 0;
    ll x_tmp = x;
    rep(i,0,N){
        if(x_tmp >= a[i] && i != N-1){
            ans++;
            x_tmp -= a[i];
        }else if(i == N-1 && x_tmp == a[i]){
            ans++;
        }
    }
    print(ans);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 

using namespace __gnu_pbds;
using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll k, n;
    cin >> k >> n;
    vll a(n);
    FOR(i, n) cin >> a[i];
    vector<pll> diffs(n);
    ll sum = 0;
    FOR(i, n)
    {
        if (i == n - 1) a[0] += k;
        diffs[i] = make_pair(a[(i + 1) % n] - a[i], i);
        sum += diffs[i].fi;
    }
    sort(all(diffs));
    reverse(all(diffs));
    cout << sum - diffs[0].fi << '\n';
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<string> w(n);
    vector<int> u(n);
    for(int i=0;i<n;i++){
        cin>>w[i];
        u[i]=w[i].size();
    }
    int count=0;
    for(int i=1;i<n;i++){
        if(w[i-1].at(u[i-1]-1)==w[i].at(0)){
            count++;
        }
    }
    sort(all(w));
    int dame=0;
    for(int i=1;i<n;i++){
        if(w[i]==w[i-1]){
            dame++;
        }
    }

    if(dame==0&&count==n-1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k) {
        cout << s << endl;
    } else {
        rep(i,k) {
            cout << s[i];
        }
        cout << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
	int c[6];
	int t;
	
	scanf("%d %d %d %d %d %d", &c[0], &c[1], &c[2], &c[3], &c[4], &c[5]);
	
	t = c[0] + (c[1] * 5) + (c[2] * 10) + (c[3] * 50) + (c[4] * 100) + (c[5] * 500);
	
	if (t >= 1000) {
		printf("1\n");
	}
	else {
		printf("0\n");
	}
	
	return (0);
}

Measured memory_bytes: 584
N = int(input())
A = [int(i) for i in input().split()]
num_minus = 0
A_abs = []
for a in A:
    if a < 0:
        num_minus += 1
    A_abs.append(abs(a))
A_abs.sort()
if num_minus % 2 == 0:
    print(sum(A_abs))
else:
    print(sum(A_abs) - 2 * A_abs[0])


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

int main() {
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N;
    cin >> N;
    for(unsigned long i = 0; i < N; ++i){
        for(unsigned long j = i + 1; j < N; ++j)cout << __builtin_ffsl(i ^ j) << " ";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 512
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int p[1000];

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

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

	sort(p, p+N);

	int ans = 0;

	for (int i=0; i<K; i++) {
		ans += p[i];
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<pii>v(N);
	rep(i, 0, N) {
		int a; cin >> a;
		v.at(i).first = a;
		v.at(i).second = i;
	}
	sort(all(v));

	rep(i, 0, N) {
		cout << v.at(i).second +1<< (i == N - 1 ? '\n' : ' ');
	}

	return 0;
}


Measured memory_bytes: 2432
x=int(input())

if x>=400 and x<=599:
    print('8')
if x>=600 and x<=799:
    print('7')
if x>=800 and x<=999:
    print('6')
if x>=1000 and x<=1199:
    print('5')
if x>=1200 and x<=1399:
    print('4')
if x>=1400 and x<=1599:
    print('3')
if x>=1600 and x<=1799:
    print('2')
if x>=1800 and x<=1999:
    print('1')

Measured memory_bytes: 61660
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 400005;
const int MM = 1000000007;

int D[MX];
int N, A, B;

int main()
{
	int s = 0, e = 1e9, m;
	scanf("%d%d%d", &N, &A, &B);
	for(int i = 1; i <= N; i++){
		scanf("%d", D+i);
	}
	while(s <= e){
		m = (s+e) / 2;
		ll tot = 0;
		for(int i = 1; i <= N; i++){
			ll rm = D[i] - (ll)m*B;
			tot += rm <= 0? 0 : (rm+(A-B-1)) / (A-B);
		}
		if( tot > m ) s = m+1;
		else e = m-1;
	}swap(s, e);
	printf("%d\n", e);
}


Measured memory_bytes: 640
#include <stdio.h>

int numofbits5(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main(void) {
	long w, n, i, c;
	while(scanf("%ld\n", &w)==1) {
		n = numofbits5(w);
		c = 0;
		for(i=0;i<=9;i++) {
			if(w & (1<<i)) {
				printf("%d", (1<<i));
				c++;
				if(c<n) {
					printf(" ");
				} else {
					printf("\n");
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 604
program main
  implicit none
  integer(8) i,N,K,b,s,j
  integer(8),allocatable :: A(:) 
  read(*, *) N, K
  allocate(A(N))
  read(*, *) (A(i), i = 1,N)
  b = 0
  s = 0
  do i = 1,N-1
    do j = i+1,N
      if (A(i) > A(j)) then
        b = b + 1
      elseif (A(i) < A(j)) then
        s = s + 1
      end if
    end do
  end do
  b = mod((mod(K*(K+1)/2,10**9+7))*b,10**9+7)
  s = mod((mod(K*(K-1)/2,10**9+7))*s,10**9+7)
  write(*, *) mod(b + s,10**9+7)
end program main


Measured memory_bytes: 768
#include <stdio.h>

#define PRE 0
#define MEIJI 1
#define TAISHO 2
#define SHOWA 3
#define HEISEI 4

int get_gengou(int year_west, int month, int day);

int main(void)
{
    int year_west, month, day;
    while ((scanf("%d %d %d", &year_west, &month, &day)) != EOF) {
        int gengou = get_gengou(year_west, month, day);
        int year_ja;

        switch (gengou) {
            case PRE:
                printf("pre-meiji\n");
                break;
            case MEIJI:
                printf("meiji ");
                year_ja = year_west - 1868 + 1;
                break;
            case TAISHO:
                printf("taisho ");
                year_ja = year_west - 1912 + 1;
                break;
            case SHOWA:
                printf("showa ");
                year_ja = year_west - 1926 + 1;
                break;
            case HEISEI:
                printf("heisei ");
                year_ja = year_west - 1989 + 1;
                break;
        }

        if (gengou != PRE) {
            printf("%d %d %d\n", year_ja, month, day);
        }
    }

    return 0;
}

int get_gengou(int year_west, int month, int day)
{
    int gengou;
    long yyyymmdd = 10000 * year_west + 100 * month + day;

    if (yyyymmdd < 18680908) {
        gengou = PRE;
    } else if (yyyymmdd < 19120730) {
        gengou = MEIJI;
    } else if (yyyymmdd < 19261225) {
        gengou = TAISHO;
    } else if (yyyymmdd < 19890108) {
        gengou = SHOWA;
    } else {
        gengou = HEISEI;
    }

    return gengou;
}

Measured memory_bytes: 608
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int mount[10];

    for (int i = 0; i < 10; i++)
        cin >> mount[i];
    sort(mount, mount + 10);

    for (int i = 9; i > 6; i--)
        cout << mount[i] << '\n';

    return 0;
}

Measured memory_bytes: 1176
require 'complex'
n, d = gets.split(" ").map(&:to_i)
dat = []
count = 0
pla = []

n.times do |i|
  dat << gets.split(" ").map(&:to_i)
end

for j in 0..(n-1) do 
  for k in j+1..(n-1) do
    if j != k
      for l in 0..(d-1) do
        pla << (dat[j][l]-dat[k][l])**2
      end
      #puts pla
      res = Math.sqrt(pla.inject(:+))
      #puts res
      if (/^[+-]?[0-9]*[\.]?[0]*$/ =~ res.to_s)
        count += 1
      end
      pla.slice!(0..d-1)
    end   
  end
end
puts count


Measured memory_bytes: 1788
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> s(n);
    int sumation=0;
    for(int i=0; i<n; i++){
        cin >> s[i];
        sumation+=s[i];
    }
    sort(s.begin(), s.end());
    int i;
    if(sumation%10!=0){
        cout << sumation << endl;
    }else{
        for(i=0; i<n; i++){
            if(s[i]%10!=0){
                sumation-=s[i];
                break;
            }
        }

        if(i==n){
            cout << 0 << endl;
        }else{
            cout << sumation << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
k = int(input())
 
while k % 10 == 0:
  if k != 10:
    k /= 10
  else:
    break
l = str(k) 
p = list(l)

al = 0
if k != 10: 
  for i in range(len(p)):
    al += int(p[i])
else:
  al = 10
print(al)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
  
   int n;
   cin >> n;
  
   
  
  
  if(n%2==0){
    cout << n << endl;
  }else{
     cout << n*2 << endl;
    
  }
  
  
  return 0;
}

Measured memory_bytes: 256
H, W, N = map(int, raw_input().split())
dx = [-1, 0, 1, -1, 0, 1, -1, 0, 1]
dy = [-1, -1, -1, 0, 0, 0, 1, 1, 1]
board = {}
 
for i in xrange(N):
    a, b = map(int, raw_input().split())
    for j in xrange(9):
        x, y = a+dx[j], b+dy[j]
        if x <= 1 or x >= H or y <= 1 or y >= W:
            continue
        if (x, y) in board:
            board[(x, y)] += 1
        else:
            board[(x, y)] = 1
ans = [0] * 10
for v in board.values():
    ans[v] += 1
ans[0] = (H-2)*(W-2)-sum(ans)
for a in ans:
    print a

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

int main(){
    int n;
    cin >> n;
    
    vector<int> spade;
    vector<int> heart;
    vector<int> clover;
    vector<int> diamond;
    
    rep(i,n){
        char s;
        int x;
        cin >> s >> x;
        
        if(s == 'S') spade.push_back(x);
        else if(s == 'H') heart.push_back(x);
        else if(s == 'C') clover.push_back(x);
        else if(s == 'D') diamond.push_back(x);
    }
    
    sort(spade.begin(), spade.end());
    sort(heart.begin(), heart.end());
    sort(clover.begin(), clover.end());
    sort(diamond.begin(), diamond.end());
    
    for(int i = 1; i <= 13; i++){
        if(!binary_search(spade.begin(), spade.end(), i)){
            cout << 'S' << " " << i << endl;
        }
    }
    
    for(int i = 1; i <= 13; i++){
        if(!binary_search(heart.begin(), heart.end(), i)){
            cout << 'H' << " " << i << endl;
        }
    }
    
    for(int i = 1; i <= 13; i++){
        if(!binary_search(clover.begin(), clover.end(), i)){
            cout << 'C' << " " << i << endl;
        }
    }
    
    for(int i = 1; i <= 13; i++){
        if(!binary_search(diamond.begin(), diamond.end(), i)){
            cout << 'D' << " " << i << endl;
        }
    }
}


Measured memory_bytes: 3144
def ss(S: str)->int:
    n = len(S)
    ret = 0
    for i in range((n-1)//2):
        if S[i+1:].startswith(S[:i+1]):
            ret = 2*(i+1)

    return ret


if __name__ == "__main__":
    S = input()
    ans = ss(S)
    print(ans)


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

ll arr[3010];
ll dp[3010][3010] = {0};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	while(t != 0) {
        int n;
        ll total = 0;
        cin >> n;
        for(int i = 1; i <= n; i++) {
            cin >> arr[i];
            total += arr[i];
        }
        for(int i = 1; i <= n; i++) {
            dp[i][i] = arr[i];
        }
        for(int i = 1; i <= n-1; i++) {
            dp[i][i+1] = max(arr[i], arr[i+1]);
        }

        for(int len = 3; len <= n; len++) {
            for(int i = 1; i <= n-len+1; i++) {
                int j = i + len - 1;

                dp[i][j] = max(arr[i] + min(dp[i+1][j-1], dp[i+2][j]), arr[j] + min(dp[i+1][j-1], dp[i][j-2]));
            }
        }
        // cout << "\n";
        // for(int i = 1; i <= n; i++) {
        //     for(int j = 1; j <= n; j++) {
        //         cout << dp[i][j] << " ";
        //     }
        //     cout << "\n";
        // }

        cout << 2*dp[1][n] - total << "\n";
	    t--;
	}
	return 0;
}


Measured memory_bytes: 70016
#include <vector>
#include <cstdio>
#include <stack>
#include <string>
using namespace std;
const int S = (1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=(x*10)+c-'0',c=Get();
    return x;
}
inline long long relo()
{
    long long x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=(x*10)+c-'0',c=Get();
    return x;
}
int main(){
    long long marxism = -10000000000000;
    vector<stack<int> > ms;
    vector<long long> cf;
    vector< vector<int> > tickets;
    int shop = read(),tic = read();
    cf.reserve(shop-1);
    tickets.assign(tic,vector<int>());
    ms.assign(tic,stack<int>());
    for (register int i = 1;i<shop;++i){
        long long temp = relo();
        cf.push_back(-temp);
    }
    for (register int i = 0;i<shop;++i){
        for (register int j = 0;j<tic;++j){
            int temp=read();
            tickets[j].push_back(temp);
        }
    }
    for (register int i = shop-1;i>=0;--i){
	long long result = 0;
        for (register int j = 0;j<ms.size();++j){
            int cur = tickets[j][i],prev = 0;
            while (!ms[j].empty()){
                if (cur>tickets[j][ms[j].top()]){
                    cf[ms[j].top()-1] -=(tickets[j][ms[j].top()]-prev);
                    prev = tickets[j][ms[j].top()];
                    ms[j].pop();
                }
                else{
                    cf[ms[j].top()-1] -=(cur-prev);
                    break;
                }
            }
	    result += cur;
	    if (i) cf[i-1] +=cur;
            ms[j].push(i);
        }
        marxism = max(marxism,result);
        for (register int j = i;j<shop-1;++j){
            result +=  cf[j];
            marxism = max(marxism,result);
        }
    }
    printf("%lld",marxism);
}


Measured memory_bytes: 7168
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            var A = cin.SplitReadL();
            var asum = new long[N + 1];
            asum[0] = 0;
            for (var i = 1; i < N + 1; i++)
            {
                asum[i] = asum[i - 1] + A[i - 1];
            }


            long ans = 0;
            Dictionary<long, int> map = new Dictionary<long, int>();
            for(var i = 0; i <= N; i++)
            {
                if (!map.ContainsKey(asum[i]))
                {
                    map[asum[i]] = 1;
                }
                else
                {
                    ans += map[asum[i]];
                    map[asum[i]]++;
                }
            }

            Console.WriteLine(ans);
            
            //Console.Out.Flush();
        }
        
    }
    
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }
}


Measured memory_bytes: 41884
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;


int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	string s;
	cin >> s;
	int res = 0;
	rep(i, len(s)) if(s[i] == '+') res ++;
	else res --;
	print(res);
	return 0;
}


Measured memory_bytes: 256
#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() {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll mn = min(a, min(b, min(c, min(d, e))));
  ll ans = (n + mn - 1) / mn + 4;
  cout << ans << endl;
  return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n);
    int t;
    REP(i,n){
        cin >> c[i];
        REP(j,m){
            cin >> t;
            a[i].push_back(t);
        }
    }
    ll ans = LINF;
    for(int bit=0;bit<(1<<n);bit++){
        ll kakaku = 0;
        vector<int> rikaido(m,0);
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                kakaku += c[i];
                for(int j=0;j<m;j++){
                    rikaido[j]+=a[i][j];
                }
            }
        }
        bool flag = true;
        REP(i,m){
            if(rikaido[i]<x)flag=false;
        }
        if(flag)ans = min(kakaku,ans);
    }
    if(ans!=LINF)COUT(ans);
    else COUT(-1);
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h> 
  
using namespace std; 
bool isPalindrome(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.length() - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            
            return false; 
        } 
    } 
    return true; 
}  
// Returns (a * b) % mod 
int main()
{ 
   string s;
   cin>>s;
   if(isPalindrome(s))
   {
   	string x="",y="";
   	int x_l = (s.length()-1)/2;
   	int y_l = (s.length()+3)/2;
   	y_l=y_l-1;
   	
   	for(int i=0;i<x_l;i++)
   	{
   		x = x+s[i];
   	}
   	//cout<<x<<endl;
   	for(int i=y_l;i<s.length();i++)
   	{
   		y = y+s[i];
   	}
   	//cout<<y<<endl;
   	if(isPalindrome(x) && isPalindrome(y))cout<<"Yes"<<endl;
   	else cout<<"No"<<endl;
   }
   else cout<<"No"<<endl;

    
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i, j, fi=1;
  scanf("%d", &j);
  int row[j+1];
  row[0]=row[1]=1;
  for(i=2;i<=j;i++) row[i]=row[i-1]+row[i-2];
  printf("%d\n", row[j]);
  return 0;
}



Measured memory_bytes: 2112
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll mod=1e9+7;

int main()
{
    string s;
    ll q;
    cin >> s >> q;
    ll cnt=0;
    string x="";
    string y="";
    while(q--){
        ll t;
        cin >> t;
        if(t==1){
            cnt++;
        }
        else{
            if(cnt%2==0){
                ll f;
                char c;
                cin >> f >> c;
                if(f==1){
                    x+=c;
                }
                else{
                    y+=c;
                }
            }
            else{
                ll f;
                char c;
                cin >> f >> c;
                if(f==1){
                    y+=c;
                }
                else{
                    x+=c;
                }
            }
        }
    }
    string r=""; //pかqを反転させるための置き場
    string w=""; //sを反転させる置き場
    string ans="";
    if(cnt%2==0){
        for(ll i=0;i<(ll)x.length();i++){
            r+=x[x.length()-1-i];
        }
        ans+=r+s+y;
    }
    else{
        for(ll i=0;i<(ll)y.length();i++){
            r+=y[y.length()-1-i];
        }
        for(ll i=0;i<(ll)s.length();i++){
            w+=s[s.length()-1-i];
        }
        ans+=r+w+x;
    }
    cout << ans << endl;
    return 0;
} 

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

int main(void)
{
    string s;
    cin >> s;
    int ans=0;
    if(s=="RRR")ans=3;
    else if(s=="RRS"||s=="SRR")ans=2;
    else if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR")
        ans = 1;
    else ans=0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#pragma warning(disable: 4996)
#include <iostream>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;

long long gcd(long long a, long long b) {
	long long tmp = a;

	if (a < b) {
		a = b;
		b = tmp;
	}
	if (b > 0) {
		return gcd(b, a % b);
	}
	else {
		return a;
	}
}

long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long A, B, C, D, X;
	cin >>A >> B >> C >> D;

	X = (A - 1);


	cout << (B - B / C - B / D + B/lcm(C, D))
		- (X - X / C - X / D + X/lcm(C, D)) << endl;


	return 0;
}


Measured memory_bytes: 888
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var H = NextInt();
		var W = NextInt();

		var a = new string[H];
		for (var i = 0; i < H; i++) {
			a[i] = ReadLine();
		}


		for (var i = -1; i <= H; i++) {
			Write("#");
			if (i == -1 || i == H) {
				Write(new string('#', W));
			} else {
				Write(a[i]);
			}
			WriteLine("#");
		}
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}


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

int countR_l(int n,char s[])
{
  int count=0;
  int i;
  for(i=0;i<n;i++){
    if(s[i]=='R')
      count++;
  }
  return count;
}

int countG_l(int n,char s[])
{
  int count=0;
  int i;
  for(i=0;i<n;i++){
    if(s[i]=='G')
      count++;
  }
  return count;
}

int countB_l(int n,char s[])
{
  int count=0;
  int i;
  for(i=0;i<n;i++){
    if(s[i]=='B')
      count++;
  }
  return count;
}

int countR_r(int n,char s[],int m)
{
  int count=0;
  int i;
  for(i=n+1;i<m;i++){
    if(s[i]=='R')
      count++;
  }
  return count;
}

int countG_r(int n,char s[],int m)
{
  int count=0;
  int i;
  for(i=n+1;i<m;i++){
    if(s[i]=='G')
      count++;
  }
  return count;
}

int countB_r(int n,char s[],int m)
{
  int count=0;
  int i;
  for(i=n+1;i<m;i++){
    if(s[i]=='B')
      count++;
  }
  return count;
}

int countB_G(int n,char s[],int m)
{
  int count=0;
  int i=1;
  while(n-i!=-1 && n+i!=m){
      if((s[n-i]=='B'&&s[n+i]=='G')||(s[n-i]=='G'&&s[n+i]=='B'))
        count++;
      i++;
  }
  return count;
}

int countR_G(int n,char s[],int m)
{
  int count=0;
  int i=1;
  while(n-i!=-1 && n+i!=m){
      if((s[n-i]=='R'&&s[n+i]=='G')||(s[n-i]=='G'&&s[n+i]=='R'))
        count++;
      i++;
  }
  return count;
}

int countR_B(int n,char s[],int m)
{
  int count=0;
  int i=1;
  while(n-i!=-1 && n+i!=m){
      if((s[n-i]=='B'&&s[n+i]=='R')||(s[n-i]=='R'&&s[n+i]=='B'))
        count++;
      i++;
  }
  return count;
}

int main(void)
{
  int i,n;
  long int ans=0;
  char s[4001];
  scanf("%d%s",&n,s);

  if(n<=3){
    printf("0");
    return 0;
  }

  for(i=1;i<n-1;i++){
    if(s[i]=='R'){
      ans+=countB_l(i,s)*countG_r(i,s,n);
      ans+=countG_l(i,s)*countB_r(i,s,n);
      ans-=countB_G(i,s,n);
/*      printf("R ans%d=%d\n",i,ans);*/
    }
    if(s[i]=='G'){
      ans+=countB_l(i,s)*countR_r(i,s,n);
      ans+=countR_l(i,s)*countB_r(i,s,n);
/*      printf("countB_l=%d  countR_r=%d countR_l=%d  countB_r=%d\n",countB_l(i,s),countR_r(i,s,n),countR_l(i,s),countB_r(i,s,n));
*/      ans-=countR_B(i,s,n);
/*      printf("G ans%d=%d\n",i,ans);*/
    }
    if(s[i]=='B'){
      ans+=countR_l(i,s)*countG_r(i,s,n);
      ans+=countG_l(i,s)*countR_r(i,s,n);
      ans-=countR_G(i,s,n);
/*      printf("B ans%d=%d\n",i,ans);*/
    }
  }
  printf("%ld",ans);
  return 0;

}


Measured memory_bytes: 1740
import java.util.*;
import java.io.*;
class Main
{
	static StringBuilder sb;
	public static final boolean ONLINE_JUDGE=false;
	public static void main(String []args)throws IOException
	{
		sb=new StringBuilder();
		Scanner sc=new Scanner(System.in);
		if(ONLINE_JUDGE)
		{
			File file=new File("output.txt");
			sc=new Scanner(new FileReader(new File("input.txt")));
			PrintStream ps=new PrintStream(file);
			System.setOut(ps);
		}
		int t=1;
		for(int tt=1;tt<=t;tt++)
		{
			int n=sc.nextInt();
			int a[]=new int[n];
			for(int i=0;i<n;i++)
				a[i]=sc.nextInt();
			int dp[]=new int[n];
			Arrays.fill(dp,Integer.MAX_VALUE);
			dp[0]=0;
			dp[1]=Math.abs(a[1]-a[0]);
			for(int i=2;i<n;i++)
			{
				for(int j=1;j<=2;j++)
				{
					dp[i]=Math.min(dp[i],dp[i-j]+Math.abs(a[i]-a[i-j]));
				}
			}
			System.out.println(dp[n-1]);
		}
	}
}

Measured memory_bytes: 51156
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, k;
    cin >> a >> b >> k;
    ll aa = a, bb = b;
    a = max(a - k, 0LL);
    k = max(k - aa, 0LL);
    b = max(b - k, 0LL);
    k = max(k - bb, 0LL);
    cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define f0(a,b) for(lli i=a;i<b;i++)
#define fn(b,a) for(lli i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define mp make_pair
#define sq(a) (a)*(a)
#define fs first
#define sc second
#define el "\n"
#define brk break
#define cont continue
#define all(a) a.begin(),a.end()
#define E9 1000000007
#define E5 100007
#define INF 1e18+7
typedef long long int lli;  //  e-18 to e18
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
typedef map<int,int> mii;
typedef vector<long long int> vll;
typedef pair<long long int,long long int> pll;
typedef vector<vector<long long int>> vvll;
lli a[2700];
lli n,k;
void solve(){
    cin >> n >> k; 
	for(lli i = 1; i <= n; i++) cin >> a[i]; 
	lli ans = 0, K = (k * (k + 1) / 2) % E9, KK = (k * (k - 1) / 2) % E9; 
	for(lli i = 1; i <= n; i++) {
		lli l = 0, r = 0; 
		for(lli j = 1; j < i; j++) l += (a[j] > a[i]); 
		for(lli j = i + 1; j <= n; j++) r += (a[j] > a[i]); 
		ans = (ans + l * K % E9 + r * KK % E9) % E9; 
	}
	cout << ans << el; 
}
int main(){
    fastIO();
    lli t(1);
    // cin>>t;
    while(t--) solve();
    ret 0; 
}

// compilation flags

// normal
//      g++ -std=c++17 -O2 -Wall a.cpp -o a
// fast running time
//      g++ -O2 -std=c++17 -Wno-unused-result -Wshadow -Wall -o a a.cpp
// check for mistakes
//      g++ -std=c++17 -Wshadow -Wall -o a a.cpp -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g

// use digit separator for better readbility e.g. 10000000 (base 10 - decimal) =  1'000'0'000' (separate at every 3 digits)
// 0b0101000 (base 2 - binary ) =  0b010'1000' (separate at every 4 digits-nibble)
// integer literals - suffixes and prefixes e.g. 0b1010 = binary - prefix for base of number
// 0x9A01 = hexadecimal
// 0733 = octal
// 153 = decimal
// 1645241684131 ll =  suffix for data type here long long int lly for others
// use M_PI for value of pi
// and check function defination for every new function used

// snippets

//     int n,k;
//     cin>>n>>k;
//     vi a(n);
//     f0(0,n) cin>>a[i];


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int M;

int X[10][10];

void MAIN() {
    scanf("%d", &M);


    LL ans = -1;
    LL sum = 0;

    REP (i, M) {
	int d;
	LL c;
	scanf("%d%lld", &d, &c);

	if (d == 0) {
	    ans += c;
	} else {
	    vector<pair<LL, LL> > s;
	    s.emplace_back(d, c);
	    while (!s.empty()) {
		pair<LL, LL> p = s.back();
		s.pop_back();
		//eprintf("%lld %lld, %lld\n", p.first, p.second, ans);
		if (p.second == 1) {
		    ans++;
		    sum += p.first;
		    if (sum >= 10) {
			ans++;
			sum = sum / 10 + sum % 10;
		    }
		} else {
		    if (p.second % 2 == 1) {
			p.second--;
			s.emplace_back(p.first, 1);
		    }
		    p.second /= 2;
		    ans += p.second;
		    p.first *= 2;
		    if (p.first >= 10) {
			ans += p.second;
			p.first = p.first / 10 + p.first % 10;
		    }
		    s.push_back(p);
		}
	    }
	}
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
int main(){
   VI a(3);
   int b;
   cin >> b;
   bool ans=false;
   REP(i,3){
       a[i]=b%10;
       b/=10;
       if(a[i]==7){
           ans=true;
           break;
       }
   }
   if(ans) cout << "Yes" << endl;
   else cout << "No" << endl;
}
    




Measured memory_bytes: 3616
#include <stdio.h>

int main(){
  int T[5];
  int time[5][5];
  int total[] = {0,0,0,0,0};
  int min = 1000;
  int ID;
  scanf("%d",&T[0]);
  scanf("%d",&T[1]);
  scanf("%d",&T[2]);
  scanf("%d",&T[3]);
  scanf("%d",&T[4]);

  for(int i = 0; i < 5; i ++){
    //printf("%d\t",T[i]);
  }
  //printf("\n\n");

  for(int j = 0; j < 5; j++){
    for(int k = 0; k < 5; k ++){
      if(j == k){
        time[j][k] = T[k];
        //printf("%d\t",time[j][k]);
      }else{
        time[j][k] = T[k] / 10 * 10;
        if(T[k] % 10 != 0){
          time[j][k] += 10;
        }
        //printf("%d\t",time[j][k]);
      }
    }
    //printf("\n");
  }
  //printf("\n");

  for(int l = 0; l < 5; l ++){
    for(int m = 0; m < 5; m ++){
      total[l] += time[l][m];
    }
    if(total[l] < min){
      min = total[l];
    }
    //printf("%d\t",total[l]);
  }

  printf("%d",min);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i =0; i < n ;i++)
using namespace std;
long long a[105];


int main()
{
    int N;
    cin >> N;
    long long ave=0;
    rep(i,N){
        cin >> a[i];
        ave += a[i];
        a[i] *= N;
    }

    long long ans = 99999999999999999;
    int ansinx =0;
    
    rep(i,N){
        //cout << ans << endl;
        if (ans > abs(a[i] - ave)){
            ans = abs(a[i] - ave);
            ansinx = i;
        }
    }

    cout << ansinx << endl;
    

    return 0;
}

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

using namespace std;

typedef long long ll;


const int INF = 1e9;
const ll MOD = 1e9 + 7;  

//チェスのコマは(i+1,i+2) ,(i+2,i+1) のどちらかを選んで移動可能

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

ll mod_comb(ll n , ll k , ll p){
    ll ans = 1;
    for(ll i = 1; i <= k ; i++){
        ans = ans * (n - i + 1) % p;
        ans = ans * mod_pow(i,p-2,p) % p;
    }
    return ans;
}

int main(){
    ll X,Y;
    cin >> X >> Y;
    if((X + Y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    ll n = (-X + 2*Y) / 3;
    ll m = (2*X - Y) / 3;
    if(n < 0 || m < 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << mod_comb(n+m,n,MOD) << endl;
    return 0;
}



Measured memory_bytes: 384