akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <iostream>
#include <vector>

using namespace std;

/*
 * 'from' depends 'to', which means 'to' must be done before 'from'.
 */
class Edge {
    public:
        int from;
        int to;
        int cost;
};

enum VisitStatus {
    NOT_VISITED,
    VISITING,
    VISITED
};

void print_edges(const vector<vector<Edge> > &edges) {
    for (int i = 0; i < (int) edges.size(); i++) {
        cout << i << ": ";
        for (int j = 0; j < (int) edges[i].size(); j++) {
            cout << edges[i][j].to << " ";
        }
        cout << endl;
    }
}

const int MAX_V = 10000;
const int MAX_E = 100000;

/*
 * edges: edges represented by adjacent list
 * n: number of vertices
 * v: current verticle
 * sorted: sorted vertices
 */
bool do_topological_sort(const vector<vector<Edge> > &edges, const int n, const int v, vector<VisitStatus> &visited, vector<int> &sorted) {
    for (int i = 0; i < (int) edges[v].size(); i++) {
        const Edge edge = edges[v][i];
        if (visited[edge.to] == VISITING) {
            // detect cyclization
            return false;
        } else if (visited[edge.to] == NOT_VISITED) {
            visited[edge.to] = VISITING;
            if (!do_topological_sort(edges, n, edge.to, visited, sorted)) {
                return false;
            }
        }
    }

    sorted.push_back(v);
    visited[v] = VISITED;
    return true;
}

/*
 * Return false if the given graph is not DAG.
 *
 * Assume that ids of vertices starts from 0.
 */
bool topological_sort(const vector<vector<Edge> > &edges, const int n, vector<VisitStatus> &visited, vector<int> &sorted) {
    assert((int) visited.size() == n);

    for (int i = 0; i < n; i++) {
        if (visited[i] != VISITED) {
            visited[i] = VISITING;
            if (!do_topological_sort(edges, n, i, visited, sorted)) {
                return false;
            }
        }
    }

    return true;
}

/*
 * ref. http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B
 */
int main(void) {
    int v, e;
    cin >> v >> e;

    vector<vector<Edge> > edges(v);
    vector<VisitStatus> visited(v);

    for (int i = 0; i < e; i++) {
        int s, t, cost;
        cin >> s >> t;
        cost = 1;
        edges[t].push_back({t, s, cost});
    }

    // print_edges(edges);

    vector<int> answer;
    if (!topological_sort(edges, v, visited, answer)) {
        cerr << "Failed to perform topological sort due to cyclization" << endl;
        return 1;
    }

    for (int i = 0; i < (int) answer.size(); i++) {
        cout << answer[i] << endl;
    }

    return 0;
}




Measured memory_bytes: 4356
<?php
$n = intval(trim(fgets(STDIN)));
$a = array_map("intval", explode(" ", trim(fgets(STDIN))));
$sum = 0;
$mod = 10**9+7;
for($i = 0; $i <= 60; $i++){
  $c = 0;
  foreach($a as $b){
    $c += ($b >> $i) & 1; 
  }
  $c %= $mod;
  $c *= $n-$c;
  $c %= $mod;
  $c *= (1<<$i) % $mod;
  $c %= $mod;
  $sum += $c;
  $sum %= $mod;
}
echo $sum;


Measured memory_bytes: 40936
#include <bits/stdc++.h>
#include <string>
using namespace std;
int intinput() {
	int x;
	cin >> x;
	return x;
}
vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int n;
	n = intinput();
	if(n % 1000 == 0){
		cout << 0 << endl;
	}else{
		cout << 1000 - n % 1000 << endl;
	}
}

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

class tree{
public:
	int n;
	vector<vector<int>> g;
	tree(int _n){
		n = _n;
		g.resize(n, vector<int>());
	}

	void add_edge(int v, int w){
		g[v].push_back(w);
		g[w].push_back(v);
	}
};
class rooted_tree : public tree{
public:
	using tree::tree;
	int r;
	int ln = 1;
	vector<vector<int>> parent;
	vector<int> depth;
	void set_root(int _r){
		r = _r;
		while((1<<ln) <= n) ++ln;
		parent.resize(n, vector<int>(ln, -1));
		depth.resize(n);
		queue<pair<int, int>> q;
		q.push(make_pair(r, -2));
		depth[r] = 0;
		while(!q.empty()){
			pair<int, int> p = q.front(); q.pop();
			int v = p.first, pr = p.second;
			for(int i=0; i<(int)g[v].size(); ++i){
				int to = g[v][i];
				if(to != pr){
					parent[to][0] = v;
					depth[to] = depth[v]+1;
					q.push(make_pair(to, v));
				}
			}
		}
	}

	void doubling(){
		for(int i=0; i+1<ln; ++i){
			for(int j=0; j<n; ++j){
				if(parent[j][i] < 0) parent[j][i+1] = -1;
				else parent[j][i+1] = parent[parent[j][i]][i];
			}
		}
	}

	int lowest_common_ancestor(int u, int v){
		if(depth[u] > depth[v]) swap(u, v);
		for(int i=0; i<ln; ++i)
			if((depth[v] - depth[u]) >> i & 1)
				v = parent[v][i];
		if(u == v) return u;
		for(int i=ln-1; i>=0; --i){
			if(parent[u][i] != parent[v][i]){
				u = parent[u][i];
				v = parent[v][i];
			}
		}
		return parent[u][0];
	}
};

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	rooted_tree rt(n);
	for(int i=0; i<n; ++i){
		int k;
		cin >> k;
		for(int j=0; j<k; ++j){
			int c;
			cin >> c;
			rt.add_edge(i, c);
		}
	}
	rt.set_root(0);
	rt.doubling();
/*	for(int i=0; i<n; ++i)
		for(int j=0; (1<<j)<=n; ++j)
			cout << rt.parent[i][j] << " \n"[(1<<(j+1))>n];
*/	int q;
	cin >> q;
	while(q--){
		int u, v;
		cin >> u >> v;
		cout << rt.lowest_common_ancestor(u, v) << "\n";
	}
}


Measured memory_bytes: 19988
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = Integer.parseInt(sc.nextLine());

		Main main = new Main();

		System.out.println(main.solve(num));
	}

	public int solve(int num) {
		if (num == 4 || num == 2 || num == 1) {
			return 4;
		}

		int con = 1;
		while (true) {
			if (num % 2 == 0) {
				num = num / 2;
			} else {
				num = num * 3 + 1;
			}
			con++;
			if (num == 1) {
				break;
			}
		}
		return con + 1;
	}
}

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

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    double pi = acos(-1);
    int n;
    cin >> n;
    double ans = 2 * pi * n;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long answer = 0;
		if(a > b) {
			answer = getMinimumValue(a,b);
		}else {
			answer = getMinimumValue(b,a);
		}
		System.out.println(answer);
	}

	private static long getMinimumValue(long big, long small) {
		long answer = small;
		long counter = 1;
		while(true) {
			answer = small * counter;
			if(answer % big ==0) {
				break;
			}
			counter++;
		}
		return answer;
	}
}

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


int main(){


    int n, a, i;

    int t = 0;

    int k = 1000000000;

 
    cin >> n;


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> a;

         while( a % 2 == 0 ){

                a = a / 2;

                t += 1;

                }

         k = min(k, t);

         t = 0;

         }


    cout << k << endl;


    return 0;


    }

Measured memory_bytes: 256
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n=int(arr_data[0][0])
t=int(arr_data[0][1])

arr = [int(arr_data[x][0]) for x in range(1,1+n) if int(arr_data[x][1]) <=t]

if len(arr)==0:
    
    print("TLE")
    
else:

    print(min(arr))

Measured memory_bytes: 3064
#include <stdio.h>

insertionSort(int A[], int N)
{
    int i, j, v;

    for (i = 1; i < N; i++) {
		for ( j = 0; j < N; j++){
            printf("%d", A[j]);
            if ( j != N-1)
                printf(" ");
            else
                printf("\n");
        }
        
        v = A[i];
        j = i-1;
        
        while (j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }

    A[j+1] = v;
    }
}

int main(){
    int N, i, j;
    int A[100];

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

    insertionSort(A, N);

    for (j = 0; j < N; j++) {
        printf("%d", A[j]);
        if ( j != N-1)
            printf(" ");
        else
            printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 1992
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	int s;
	int min = 10000;
	int max = 0;
	int sum = 0;
	vector<int> results;
	while(cin>>n){
		if(n==0){
			break;
		}
		for(int j = 0;j<n;j++){
                    cin>>s;
		    sum+=s;
		    if(s>max)
                       max = s;
                    if(s<min)
                       min = s;
		}
		sum = (sum-max-min)/(n-2);
                results.push_back(sum);
                min = 10000;
                max = 0;
                sum = 0;
	}
	int size = results.size();
	for(int i = 0;i<size;i++){
		cout<<results[i]<<endl;
	}
}



Measured memory_bytes: 3024
import java.util.*;


class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        Map<String, Integer> dic = new TreeMap<>();
        int N = sc.nextInt();
        sc.nextLine();
        int max = 0;

        for (int i = 0; i < N; i++) {
            String tmp = sc.nextLine();
            if (dic.get(tmp) == null){
                dic.put(tmp, 1);
            } else {
                int x = dic.get(tmp)+1;
                dic.put(tmp, x);
            }
        }

        for (int i : dic.values()){
            if (max < i){
                max = i;
            }
        }

        for (String s : dic.keySet()){
            if(dic.get(s) == max) {
                System.out.println(s);
            }
        }
    }
}

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

struct Mod
{
    static const auto P = int(1e9+7);
    long long k;

    Mod() = default;
    Mod(const long long k) : k(k%P) {}
};

Mod operator*(const Mod a, const Mod b) { return a.k * b.k; }
Mod& operator*=(Mod& a, const Mod b) { return a = a*b; }
Mod power(const Mod a, const int k)
{
    if (k == 0) return 1;
    else if (k % 2 == 0) return power(a*a, k/2);
    else return a * power(a*a, k/2);
}
Mod inverse(const Mod a) { return power(a, Mod::P-2); }

int main()
{
    int N, X, Y; cin >> N >> X >> Y;

    struct Ball { int index, color, weight; };
    auto balls = vector<Ball>(N);
    for (auto i = 0; i < N; i++)
    {
        int c, w; cin >> c >> w;
        balls[i] = {i, c, w};
    }

    const auto infinity = numeric_limits<int>::max();
    auto global_min_weight = infinity, global_second_weight = infinity;
    auto global_min_color = 0;

    auto by_color = map<int, vector<Ball>>();
    for (auto i = 0; i < N; i++)
        by_color[balls[i].color].push_back(balls[i]);
    for (auto& kv : by_color)
    {
        auto min_weight = infinity;
        for (const auto b : kv.second)
            min_weight = min(min_weight, b.weight);

        for (const auto b : kv.second)
            if (min_weight + b.weight <= X)
                balls[b.index].weight = min_weight;

        if (min_weight < global_min_weight)
        {
            global_second_weight = global_min_weight;
            global_min_weight = min_weight;
            global_min_color = kv.first;
        }
        else if (min_weight < global_second_weight)
            global_second_weight = min_weight;
    }

    auto counts = map<int, int>();
    auto total = 0;
    for (const auto b : balls)
    {
        const auto x = b.color == global_min_color ? global_second_weight : global_min_weight;
        if (b.weight + x <= Y)
        {
            counts[b.color]++;
            total++;
        }
    }

    auto factorials = vector<Mod>(total+1);
    factorials[0] = 1;
    for (auto n = 1; n <= total; n++)
        factorials[n] = n * factorials[n-1];

    auto inverse_factorials = vector<Mod>(total+1);
    inverse_factorials[total] = inverse(factorials[total]);
    for (auto n = total; n >= 1; n--)
        inverse_factorials[n-1] = n * inverse_factorials[n];

    auto result = factorials[total];
    for (auto kv : counts) result *= inverse_factorials[kv.second];
    cout << result.k << endl;
}


Measured memory_bytes: 26496
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define max(a,b)(a>b?a:b)
char S[80005];
int i,j,k,l,r,I[80005],C[80005][2],p,q;

int set(int p,int n)
{
	int i;
	for(i=0;i<q;i++)
		if(C[i][0]==p)
		{
			C[i][1]+=n;
			return C[i][1];
		}
	C[q][0]=p;
	C[q][1]=n;
	q++;
	return n;
}

int cnt(int p)
{
	int i,r=0;
	for(i=0;i<q;i++)
		if((p-C[i][0])%11==0)
			r+=C[i][1];
	return r;
}

int main()
{
	for(;gets(S),S[0]!='0';)
	{
		r=p=q=0;
		memset(C,-1,sizeof(C));
		l=strlen(S);
		for(i=0,j=l-1;i<=j;i++,j--){k=S[i]-'0';S[i]=S[j]-'0';S[j]=k;}
		set(0,1);
		for(i=1,k=1;i<=l;i++,k*=-1)
		{
			I[i]=I[i-1]+S[i-1]*k;
			if(S[i-1]!=0)
				r+=cnt(I[i]);
			set(I[i],1);
			
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define digit(x) floor(log10(x))+1
#define mod 1000000007
#define endl "\n"
#define int long long
#define matrix vector<vector<int> >
#define vi vector<int>
#define pii pair<int,int>
#define vs vector<string>
#define vp vector<pii>
#define test() int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int sz = 100005;
//=================================================================//
int *weight, *prices;
int n, capacity;
int dp[101][sz];    //n * (profit) // total profit could be n * given profit


int knapsack2(int mx_profit) {
    int inf = 1e11;
    for(int N=0;N<=n;N++) {
        for(int profit=0;profit<=mx_profit;profit++) {
            if(N==0 and profit==0) dp[N][profit] = 0;
            else if(N==0) dp[N][profit] = inf;
            else if(prices[N-1]<=profit) {
                dp[N][profit] = min(weight[N-1] + dp[N-1][profit-prices[N-1]], dp[N-1][profit]);
            } else {
                dp[N][profit] = dp[N-1][profit];
            }
        }
    }
    int ans = 0;
    for(int profit=0;profit<=mx_profit;profit++) {
        if(dp[n][profit]<=capacity) ans = profit;
    }
    return ans;
}


int32_t main(){
    fast;
    cin>>n>>capacity;
    weight = new int[n];
    prices = new int[n];
    int mx_profit = 0;
    for(int i=0;i<n;i++) {
        cin>>weight[i]>>prices[i];
        mx_profit += prices[i];    
    }
    
    cout<<knapsack2(mx_profit);
    return 0;
}

Measured memory_bytes: 82512
import java.util.Scanner;

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

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        if(b > a){
            if(c > b){
                System.out.printf("%d %d %d\n", a, b, c);
            }else if(c > a){
                System.out.printf("%d %d %d\n", a, c, b);
            }else{
                System.out.printf("%d %d %d\n", c, a, b);
            } 
        }
        if(a > b){
            if(c > a){
                System.out.printf("%d %d %d\n", b, a, c);
            }else if(c > b){
                System.out.printf("%d %d %d\n", b, c, a);
            }else{
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }

    }
}


Measured memory_bytes: 26352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    //long long sum(0);
    long long sum=0;
    for(int i=1; i<=n; ++i)
    {
        for(int j=1; j<=n; ++j)
        {
            for(int k=1; k<=n; ++k)
            {
                sum= sum+ __gcd(__gcd(i,j), k);
            }
        }
    }
    cout<<sum;
    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &e : a) cin >> e;

    vector<int> count(n);
    for (auto e : a) ++count[e - 1];

    int64_t all = 0;
    for (auto e : count) all += int64_t(e) * (e - 1) / 2;

    for (auto e : a) {
        --e;
        cout << (all - (count[e] * (count[e] - 1) / 2) + ((count[e] - 1) * (count[e] - 2) / 2)) << endl;
    }
}



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

int t = 0;
vector<int> edge[101];
bool back_edge[101];

pair<int, int> visit_time[101];

void dfs(int cur)
{
    t += 1;
    visit_time[cur].first = t;

    for (int i = 0; i < (int)edge[cur].size(); i++) // cur から行ける頂点について
    {
        if (back_edge[edge[cur][i]] == false)
        {
            back_edge[edge[cur][i]] = true;
            dfs(edge[cur][i]);
        }
    }

    t += 1;
    visit_time[cur].second = t;
}

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

    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        back_edge[u] = false;
        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            edge[u].push_back(v);
        }
    }

    for (int i = 1; i < n; i++)
        if (back_edge[i] == false)
        {
            back_edge[i] = true;
            dfs(i);
        }

    for (int i = 1; i <= n; i++)
    {
        cout << i
             << " " << visit_time[i].first
             << " " << visit_time[i].second << endl;
    }
}


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

int main() {
  int N, A, B, C, D;
  cin >> N;
  A = N / 1000;
  B = N / 100 - A * 10;
  C = N / 10 - A * 100 - B * 10;
  D = N - A * 1000 - B * 100 - C * 10;
  
   if (A == B && B == C){
      cout << "Yes" << endl;
  }
  else if (B == C && C == D){
      cout << "Yes" << endl;
  }
  else {
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
pt,px,py=0,0,0
for _ in range(n):
    t,x,y=map(int,input().split())
    if t-pt<abs(x-px)+abs(y-py) or (t-pt)%2!=(abs(x-px)+abs(y-py))%2:
        print("No")
        exit()
    pt=t
    px=x
    py=y
print("Yes")

Measured memory_bytes: 9192
import sys
import numpy as np

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

D = ri()
c = np.array(rl())
s = np.array([np.array(rl()) for _ in range(D)])
li = np.zeros(26)
li_one = np.ones(26)
c_sum = sum(c)
for lis in s:
  idx_list = np.argsort(lis**2/c)[:-15:-1]
  li += li_one
  max_idx = 0
  max_score = -10**10
  for i in idx_list:
    tmp = li
    li[i] = 0
    sum_c_li = np.sum(c*li)
    score = lis[i] - sum_c_li
    if score >= max_score:
      max_idx = i
      max_score = score
    li = tmp
  print(max_idx + 1)


  

Measured memory_bytes: 27556
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
vector<int> vec(3);
cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
set<int> se;
rep(i,3) se.insert(vec.at(i));

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

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a;
	int b;
	int c;
	
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	
	if(a<b && b<c){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}
	

	return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int ,int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N, K;
	cin >> N >> K;
	int sum = 0;
	rep(i,0,N){
		int input;
		cin >> input;
		sum += min(abs(input), abs(input-K)) << 1;
	}
	cout << sum << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
const int MAXN = 1e3+2;
int d[MAXN<<1][MAXN<<1];
int dis[MAXN<<1];
int main(){
	int n,x,y;
	cin >> n >> x >> y;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			d[i][j] = abs(i-j);
		}
	}
	
	d[x-1][y-1] = 1;
	d[y-1][x-1] = 1;
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
            {
                d[i][j] =min(min(d[i][x-1] +1 +d[y-1][j],d[i][j]),d[i][y-1]+1+d[x-1][j]) ;
            }
    for(int i = 0;i < n;i++){
    	for(int j = 0;j < n;j++){
    		if(i!=j)
    		++dis[d[i][j]];
		}
	}

	 
	for(int i = 1;i <= n-1;i++)
	cout << dis[i] /2<< endl;
	return 0;
}

Measured memory_bytes: 15872
# doubly Linked listの設計
from sys import stdin


class DoublyLinkedList():

    class Cell():
        def __init__(self, value):
            self.value = value
            self.next = None
            self.previous = None

    def __init__(self):
        self.head = DoublyLinkedList.Cell(None)
        self.tail = DoublyLinkedList.Cell(None)
        self.head.next = self.tail
        self.tail.previous = self.head

    def insert(self, v):
        new_cell = DoublyLinkedList.Cell(v)
        new_cell.next = self.head.next
        new_cell.previous = self.head
        self.head.next.previous = new_cell
        self.head.next = new_cell

    def delete(self, v):
        tmp_cell = self.head.next
        while tmp_cell.value is not None:
            if tmp_cell.value == v:
                tmp_cell_next = tmp_cell.next
                tmp_cell_previous = tmp_cell.previous
                tmp_cell_previous.next = tmp_cell_next
                tmp_cell_next.previous = tmp_cell_previous
                break
            tmp_cell = tmp_cell.next

    def deleteFirst(self):
        self.head.next = self.head.next.next
        self.head.next.previous = self.head

    def deleteLast(self):
        self.tail.previous = self.tail.previous.previous
        self.tail.previous.next = self.tail


def print_res(dl):
    res = []
    cur = dl.head.next
    while cur.next is not None:
        res.append(cur.value)
        cur = cur.next
    print(" ".join(res))


def main():
    dl = DoublyLinkedList()
    line_num = int(stdin.readline())
    for i in range(line_num):
        command = stdin.readline().strip()
        if command == "deleteFirst":
            dl.deleteFirst()
        elif command == "deleteLast":
            dl.deleteLast()
        elif command.startswith("insert"):
            dl.insert(command.split(" ")[1].strip())
        else:
            dl.delete(command.split(" ")[1].strip())
    print_res(dl)


if __name__ == '__main__':
    main()



Measured memory_bytes: 227600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,r;
    cin>>a>>b>>c;

    if(((a+b)==c)||((a+c)==b)||((b+c)==a)){
        cout<<"Yes"<<endl;
    }
    else{
       cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
 
int main() {
	std::string s;
	std::cin >> s;
	std::string t;
	t = "CODEFESTIVAL2016";
	int nSum = 0;
	for (int i = 0;i < s.size();i++) {
		if (s[i] != t[i]) {
			nSum += 1;
		}
	}
	std::cout << nSum << std::endl;
	return 0;
}

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

int Partition(vector<int> &a, int p, int r) {
  int x = a.at(r);
  int i = p-1;
  for (int j = p; j < r; j++)
  {
    if (a.at(j) <= x) {
      i++;
      swap(a.at(j), a.at(i));
    }
  }
  swap(a.at(i+1), a.at(r));
  return i+1;
}
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) 
    cin >> a.at(i);

  int x = Partition(a, 0, n-1);
  for (int i = 0; i < n; i++) {
    if (i == x)
    cout << "[";
    cout << a.at(i);
    if (i == x)
    cout << "]";
    if (i != n-1)
    cout << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3112
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		if ( (sc.nextInt() + sc.nextInt() + sc.nextInt()) > 21 )
			out.println("bust");
		else 
			out.println("win");
		
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define BIT(x) (1LL<<(x))

using namespace std;
typedef long long ll;
char s[20];
ll v[20];

int main()
{
    //freopen("in.in", "r", stdin);
    //freopen("out.out", "w", stdout);
    cin >> s;
    int n = strlen(s);
    int lg = 1;
    v[0] = BIT(n - 1);
    ll res = 0;
    for(int i = 0; i < n; i++)
    {
        ll ap = 0, pw = 1;
        for(int j = 0; j < lg; j++)
        {
            ap += v[j] * pw;
            pw *= 10;
        }
        res += ap * (s[n - i - 1] - '0');
        v[lg - 1] /= 2;
        v[lg] = v[lg - 1];
        lg++;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 	// #ifndef ONLINE_JUDGE
 	// freopen("input.in","r" ,stdin);
 	// #endif
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll ans = 1e18;
  for(int i = 0 ; i <=1e5 * 3;i+=2){
  	ll r = i*c;
  	ll h = i/2;
  	ll xx  = max(0LL , (x - h) * a);
  	ll yy  = max(0LL , (y - h) * b);
  	ans = min(ans , xx + yy + r);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define int long long
const int mod=1e9+7;
const int N=3e3+2;
using namespace std;
int dp[N][N],ar[N];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,q,m,ans=0,damn=1,prob=(mod+1)/2;
	cin>>n>>q;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(ar[i]>ar[j]){
				dp[i][j]=1;
			}
		}
	}
	for(i=1;i<=q;i++){
		damn*=2;
		if(damn>=mod){
			damn-=mod;
		}
		cin>>j>>k;
		for(l=1;l<=n;l++){
			if(j!=l&&k!=l){
				m=dp[j][l];
				dp[j][l]=(dp[j][l]+dp[k][l])*prob;
				dp[j][l]%=mod;
				dp[k][l]=(m+dp[k][l])*prob;
				dp[k][l]%=mod;
				m=dp[l][k];
				dp[l][k]=(dp[l][k]+dp[l][j])*prob;
				dp[l][j]=(m+dp[l][j])*prob;
				dp[l][k]%=mod;
				dp[l][j]%=mod;
			}	
		}
		dp[j][k]=dp[k][j]=(dp[j][k]+dp[k][j])*prob;
		dp[j][k]%=mod;
		dp[k][j]%=mod;
	}
	//cout<<dp[1][3]<<endl;
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			//cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
			ans+=dp[i][j];
			if(ans>=mod){
				ans-=mod;
			}
		}
	}
	cout<<(ans*damn)%mod;
}

Measured memory_bytes: 70656
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int array1[] = new int[n];
    int array2[] = new int[n];
    int min = 0;
    for(int i = 0; i<n; i++){
      array1[i] = sc.nextInt();
    }
    for(int i = 0; i<n; i++){
      array2[array1[i]-1] = i + 1;  
    }
    for(int i = 0; i< n; i++)
      System.out.print(array2[i] + " ");
  }
}

Measured memory_bytes: 60952
#include <bits/stdc++.h>
#define N 500006 
using namespace std;
int n,a,b;long long ans;
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	if(a>b)return puts("0"),0;
	if(n==1&&a!=b)return puts("0"),0;
	ans=1LL*(n-2)*(b-a)+1LL;
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
//TINY_OUNCE911666
// You are not prepared!

#include <bits/stdc++.h>
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;

const int INF = 1e9+7;

int32_t main() {
	_upgrade
	
	int n, k;
	cin >> n;
	
	vector<int> a(n), dp(n, INF);
	for (int& x : a) {
		cin >> x;
	}
	
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j <= i+2; j++) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(a[i]-a[j]));
			}
		}
	}
	
	cout << dp[n-1] << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    string s;
    int y, m, d;
    cin >> s;
    if (s == "#")
      break;
    cin >> y >> m >> d;
    if (y > 31) {
      y -= 30;
      s = "?";
    } else if (y == 31 && m >= 5) {
      y -= 30;
      s = "?";
    }
    cout << s << " " << y << " " << m << " " << d << endl;
  }
  return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve(){
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for(int i = 0; i < n; ++i) cin >> a[i];
	ll sum = 0;
	for (int x : a) sum += x;
	int good = 0;
	for (int x : a) if (x * 4ll * m >= sum) good++;
	cout << (good >= m ? "Yes" : "No");
}

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

	solve();
    
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h> 

int main() {
  int n,x;
  int b,i,j,k,a;

  while(1) {
    scanf("%d %d",&n,&x);   
    b = 0;
    if( n == 0 && x == 0){
      break;
    }
    for(k = 1; k <= n ; k++) {


      for(j = 1; j <= n ; j++) {

	for(i = 1; i <= n; i++) {
	  
	  if(i == j || j == k || i ==k) {
	    
	  }else{
	    a = i + j + k;
	    if(a == x) {
	     
	      b += 1;
 
	    }
	  }
	  
	}//i
	
      }//j

    }//k
    printf("%d\n",b/6);
  }


  return 0;
}  


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

void dfs(int v, vvi &G, vb &seen){
  if(seen[v]) return;
  seen[v] = true;
  for(auto nv : G[v]) {
    dfs(nv, G, seen);
  }
}

int main(){
  int n,m,p; cin >> n >> m >> p;
  vi a(m),b(m),c(m);
  vvi G(n),rG(n);
  rep(i,m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    G[a[i]].pb(b[i]);
    rG[b[i]].pb(a[i]);
    c[i] -= p;
    c[i] = -c[i];
  }

  vb seen1(n,false),seen2(n,false),ok(n);
  dfs(0,G,seen1); dfs(n-1,rG,seen2);
  rep(i,n) ok[i] = seen1[i]&seen2[i];
  
  vi d(n,1e9);
  d[0] = 0;
  int step = 0;
  bool upd = true;
  while(upd){
    upd = false;
    rep(i,m) {
      if(!ok[a[i]] || !ok[b[i]]) continue;
      if(chmin(d[b[i]], d[a[i]] + c[i])) upd = true;
    }
    step++;
    if(step > n){
      cout << -1 << endl;
      return 0;
    }
  }

  cout << max(-d[n-1],0) << endl;
}


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

int main(){

    int n;
    cin >> n;

    vector<int> v(n);
    vector<int> v_sort(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
        v_sort[i] = v[i];
    }

    sort(v_sort.begin(), v_sort.end());
    int med = v_sort[n / 2];

    for(int i = 0; i < n; i++){
        if(v[i] < med){
            cout << med << endl;
        }
        else{
            cout << v_sort[n / 2 - 1] << endl;
        }
    }


}

Measured memory_bytes: 3712
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    int cost, coinNum;
    cin >> cost >> coinNum;

    int coins[coinNum];
    rep(i, coinNum) {
        cin >> coins[i];
    }

    int dp[coinNum + 1][cost + 1];

    rep(i, cost+1) {
        dp[0][i] = 100000000;
    }
    dp[0][0] = 0;

    rep(i, coinNum) {
        //cout << coins[i] << "円\t";
        rep(c, cost + 1) {
            if (c >= coins[i]) {
                dp[i + 1][c] = std::min(dp[i + 1][c - coins[i]] + 1, dp[i][c]);
            } else {
                dp[i + 1][c] = dp[i][c];
            }
            //cout << dp[i + 1][c] << " ";
        }
        //cout << endl;
    }

    cout << dp[coinNum][cost] << endl;
}


Measured memory_bytes: 7216
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

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

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

char mozi[53];
int main(){
	while(1){
		int n;
		int ikey[110] = {0};
		cin>>n;
		if(n==0)break;
		rep(i,n){
			cin>>ikey[i];
		}
		int tmp=0;
		rep(i,52){
			if(i==26) tmp+=6;
			mozi[i]='A'+i+tmp;
			// cout<<mozi[i];
		}
		string skey;
		vi spos;
		cin>>skey;
		string ans = "";
		rep(i,skey.size()){
			spos.pb(int(char(skey[i])-'A'));
			if(char(skey[i])>='a'){
				spos[i]-=6;
			}
			ans += mozi[(spos[i]-ikey[i%n]+52)%52];
		}
		cout<<ans<<endl;

	}
	return 0;
}

Measured memory_bytes: 3072
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Camel Train
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;
typedef pair<int,int> pii;

/* global variables */

pii lps[MAX_N], rps[MAX_N];
priority_queue<int> q;

/* subroutines */

/* main */

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

  while (tn--) {
    int n;
    scanf("%d", &n);

    ll sum = 0;
    int lpn = 0, rpn = 0;
    for (int i = 0; i < n; i++) {
      int k, l, r;
      scanf("%d%d%d", &k, &l, &r);
      sum += min(l, r);
      if (l > r) lps[lpn++] = pii(k, l - r);
      else if (l < r) rps[rpn++] = pii(n - k, r - l);
    }
    sort(lps, lps + lpn);
    sort(rps, rps + rpn);

    for (int i = 0; i < lpn; i++) {
      int ki = lps[i].first, di = lps[i].second;
      q.push(-di);
      while (q.size() > ki) q.pop();
    }
    while (! q.empty()) sum += -q.top(), q.pop();

    for (int i = 0; i < rpn; i++) {
      int ki = rps[i].first, di = rps[i].second;
      q.push(-di);
      while (q.size() > ki) q.pop();
    }
    while (! q.empty()) sum += -q.top(), q.pop();

    printf("%lld\n", sum);
  }
  return 0;
}


Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
int main(){int n;cin>>n;vector<int> d(n);for(int i=0;i<n;i++)cin>>d[i];sort(d.begin(),d.end());int mid1=(n-1)/2,mid2=mid1+1;cout<<d[mid2]-d[mid1];}


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

int main () {
  int N ;
  cin >> N ;
  if (N%1110 < 10) {
    cout << "Yes" << endl;
  }
  else if ( (N-N/1000*1000)%111 == 0 ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main(){
    long long L, R;
    cin >> L >> R;

    long long min_mod = 2019;
    for(long long i=L;i<=min(R, L+2019);i++){
        for(long long j=i+1;j<=min(R, L+2019);j++){
            min_mod = min(min_mod, i*j % 2019);
        }
    }
    cout << min_mod << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, m, k;
	cin >> n >> m >> k;
	vector<string> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int ans = inf;
	for (int mask = 0; mask < (1 << (n - 1)); ++mask) {
		vector<int> classes(n);
		for (int i = 0; i < n - 1; ++i) {
			if ((mask >> i) & 1) {
				classes[i + 1] = classes[i] + 1;
			} else {
				classes[i + 1] = classes[i];
			}
		}
		vector<int> cnt(n);
		int answer = __builtin_popcount(mask);
		for (int j = 0; j < m; ++j) {
			vector<int> old = cnt;
			bool ok = true;
			for (int i = 0; i < n; ++i) {
				cnt[classes[i]] += a[i][j] - '0';
				if (cnt[classes[i]] > k) {
					ok = false;
				}
			}
			for (int i = 0; i < n; ++i) {
				if (cnt[i] - old[i] > k) {
					answer = inf;
					goto there;
				}
			}
			if (!ok) {
				for (int i = 0; i < n; ++i) {
					cnt[i] -= old[i];
				}
				++answer;
			}
		}
		there:;
		ans = min(ans, answer);
	}
	cout << ans << '\n';
 	return 0;
}


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

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n,m;
    cin>>n>>m;
    ll int dp[n+1] = {0};
    dp[0] = 1;
    for(ll int i=0;i<m;i++){
        ll int x;
        cin>>x;
        dp[x] = -1;
    }
    // cout<<dp[0]<<endl;
    for(ll int i=1;i<=n;i++){
        if(dp[i]!=-1){
            dp[i] = 0;
            if(dp[(i-1)]!=-1)
                dp[i] += dp[(i-1)];
            if(i>=2 && dp[(i-2)]!=-1)
                dp[i] += dp[(i-2)];
            dp[i] = dp[i]%(1000000007);
        }
        // cout<<dp[i]<<endl;
    }
    cout<<dp[n];
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <vector>
using namespace std;
typedef long long int ll;
const int MOD = 1000000007;

int main(){
  ll N,X;
  ll ans = 0;
  cin >> N >> X;
  ans += N;
  ll a = X;
  ll b = N-X;
  while(b%a != 0){
    ans += (b/a)*a*2;
    ll tmp = b;
    b = a;
    a = tmp%a;
  }
  cout << ans+(b*2)-a << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 13
using namespace std;
int n;
long long a[szxb]={2,1};
signed main()
{
	scanf("%d",&n);
	if(!(n-1)){putchar(49);goto endreturn;}
	for(register int i(3);i<=(n+1);i++){a[2]=(a[1]+a[0]),a[0]=a[1],a[1]=a[2];}
	printf("%lld",a[2]);
	endreturn:return putchar(10),0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
string s;
signed main(){
    cin>>s;
    int n=s.size();
    string a=s.substr(0,(n-1)/2);
    string b=a;
    reverse(all(b));
    string c=s.substr((n+1)/2,(n-1)/2);
    string d=c;
    reverse(all(d));
    string t=s;
    reverse(all(t));
    if(a==b&&c==d&&s==t)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
num_inputs = int(input())
inputs = [int(st) for st in input().split()]
rnges = [(0,9)]
lf = 0
rg = 0
su = 0
score = 0
while rg < num_inputs:
    if su & inputs[rg] == 0:
        su += inputs[rg]
        if rnges[len(rnges)-1][0] == lf:
            rnges[len(rnges)-1] = (lf, rg+1)
        else:
            rnges.append((lf, rg+1))
        rg += 1
    else:
        # score += (rg-lf+1)*(rg-lf)//2
        su -= inputs[lf]
        lf += 1

# rnges.append((lf, rg))
# score += (rg-lf+1)*(rg-lf)//2
tmp_lf = 0
tmp_rg = 0

for lf, rg in rnges:
    score += (rg-lf+1)*(rg-lf)//2
    if lf < tmp_rg:
        score -= ((tmp_rg-lf+1)*(tmp_rg-lf)//2)
    tmp_rg = rg

# print(rnges)
print(score)


Measured memory_bytes: 37800
#include<bits/stdc++.h>
using namespace std;
 #define SPEED ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(0)
int main() 
{
	SPEED; 
	long long n,k,count=0;
    cin>>n>>k;
    long a[n];
    for(int i=0;i<n;i++){
      cin>>a[i];
      }
  sort(a,a+n);

  if(k!=0){
  for(int j=0;j<n-k;j++)
    count=count+a[j];
  }
  else{
   for(int j=0;j<n;j++)
    count=count+a[j];
  }
  cout<<count;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (true) {
		int n, k; cin >> n >> k;
		if (n == 0 && k == 0)break;
		vector<int> f(n + 1, false);
		bool white = false;
		for (int i = 0; i < k;i++) {
			int x; cin >> x;
			if (x == 0) white = true;
			else {
				f[x] = true;
			}
		}
		int ans = 0;
		if (!white) {
			int len = 0;
			for (int i = 1; i <= n;i++) {
				if (!f[i]) {
					ans = max(ans, len);
					len = 0;
				}
				else {
					len++;
				}
			}
			cout << ans << endl;
		}
		else {
			int len = 0, pre_len = 0;
			int space = 0;
			for (int i = 1; i <= n;i++) {
				if (!f[i]) {
					if (len != 0) {
						if (space == 1) {
							ans = max(ans, pre_len + 1 + len);
							space = 0;
						}
						else {
							ans = max(ans, len + 1);
						}
						pre_len = len;
						len = 0;
					}
					space++;
				}
				else {
					if (space > 1) space = 0;
					len++;
				}
			}
			if (space == 1) {
				ans = max(ans, pre_len + 1 + len);
			}
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 3412
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

int N;
ll T[100];

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

    return gcd(b, a%b);
}

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

void solve()
{
    if(N == 1) {
        cout << T[0] << "\n";
        return;
    }

    ll m = lcm(T[0], T[1]);
    FOR(i, 2, N) {
        m = lcm(T[i], m);
    }
    cout << m << "\n";
}

int main()
{
    cin >> N;
    REP(i, N) {
        cin >> T[i];
    }

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
void chmin(ll &x, ll y) { x = min(x, y); }
void chmax(ll &x, ll y) { x = max(x, y); }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
    int a, b;
    cin >> a >> b;
    int ans = max(a-2*b, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void){
    // Here your code !
    int a, b, c;
    int count = 0;
    scanf("%d %d %d", &a, &b, &c);
    for (int i = a; i <= b; i++){
        if (c % i == 0){
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

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

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

Measured memory_bytes: 1152
#include <cstdio>

using namespace std;

int main() {
    int x, a, b;
    scanf("%d", &x);
    scanf("%d", &a);
    scanf("%d", &b);
    if (b - a > x) {
        printf("dangerous\n");
    }
    else if (b - a > 0) {
        printf("safe\n");
    }
    else {
        printf("delicious\n");
    }
}

Measured memory_bytes: 128