akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

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

	const int MOD = 1e9 + 7;
	std::vector<i64> fact(1e6 + 10, 1);
	for(i64 i = 0; i < fact.size() - 1; i++) fact[i + 1] = fact[i] * (i + 1) % MOD;

	auto inv = [&](i64 x) {
		i64 n = MOD - 2, ret = 1;
		while(n) {
			if(n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return ret;			
	};
	auto comb = [&](int n, int r) {
		return fact[n] * inv(fact[r]) % MOD * inv(fact[n - r]) % MOD;
	};

	int ans = 0;
	for(int i = 0; i <= x; i++) {
		if((x - i) & 1) continue;
		int j = (x - i) >> 1;
		if(2 * i + j != y) continue;

		(ans += comb(i + j, i)) %= MOD;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 8064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var S string
	fmt.Scan(&S)
	c := make([]int, 3)
	for _, r := range S {
		c[int(r-'a')]++
	}
	sort.Ints(c)
	if c[0] <= c[1] && c[1] <= c[2] && c[2] <= c[0]+1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 2580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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

    cout << h*w-h2*w-h*w2+h2*w2 << endl;


    return 0;
}


Measured memory_bytes: 256
"use strict";

function Main(input) {
  input = input.split("\n")
  let N = input[0];
  let d = input[1].split(" ");
  let result = 0;

  d.forEach((num) => {
    d = d.slice(1)

    d.forEach((num2) => {
      result += num * num2;
    })
  });


  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

#define PI 3.14159265358979323846
int main()
{
  int s, w;
  scanf("%d%d", &s, &w);
  puts(s <= w ? "unsafe" : "safe");
}

Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int nr, n, rez;
int v[101], fr[101];
int main()
{
    cin>> nr>> n;
    for(int i=1; i<=n; i++){
        cin>> v[i];
     fr[v[i]]++;
    }
    if(n== 0){
        cout<< nr;
        return 0;
    }
    else{
            int mini= 102;
        for(int i= -100; i<= 101; i++){
            if(fr[i]== 0){
                if(mini>abs(nr-i))
                {
                    mini= abs(nr- i);
                    rez= i;
                }
            }
        }
    }
    cout<< rez;
    return 0;
}


Measured memory_bytes: 3164
string = input()
q = int(input())

for i in range(q):
  order = input().split()
  if order[0] == "print":
    print(string[int(order[1]):int(order[2])+1])
  elif order[0] == "reverse":
    rev_b = int(order[1])
    rev_e = int(order[2])
    if rev_b == 0:
      string = string[rev_e::-1] + string[rev_e+1:]
    else:
      string = string[:rev_b] + string[rev_e:rev_b-1:-1] + string[rev_e+1:]
  elif order[0] == "replace":
    rep_b = int(order[1])
    rep_e = int(order[2])
    string = string[:rep_b] + order[3] + string[rep_e+1:]


Measured memory_bytes: 5616
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        int[] ary = new int[n];
        for(int i = 0; i < n; i++)  ary[i] = Integer.parseInt(line1[i]);
        int count = 0;
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                count += ary[i] * ary[j];
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define int long long
#define all(a) (a).begin(),(a).end()
using namespace std;

signed main(){
    ios_base::sync_with_stdio(0);
    int n,m,k;
    cin >> n >> m >> k; 
    vector<int>a(n+1),b(m);
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int& i:b) cin >> i;
    for(int i=1;i<=n;i++)
        a[i] += a[i-1];
    for(int i=1;i<m;i++)
        b[i] += b[i-1];
    int ans=0,cur=0;
    for(int i=0;i<=n;i++){
        if(a[i] > k) continue;
        cur = i;
        int targe = k - a[i];
        int lo = 0 , hi = m-1;
        while(lo<=hi){
            int mid = (lo+hi)/2;
            if(b[mid] > targe){
                hi = mid - 1;
            }else{
                lo = mid + 1;
            }
        }
        cur += lo ;
        ans = max(ans,cur);
    }
    cout << ans << endl;
    return 0;
}

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

int ncr(int n)
{
  int x=n*(n-1);
  x/=2;
  return x;
}

int main()
{
  int n,m;
  cin>>n>>m;
  int ans= ncr(n) + ncr(m);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <list>
using std::cout;
using std::cin;
using std::endl;
using std::cerr;
int pow(int base,int exponent){
  if(exponent==0){
    return 1;
  }
  int result=base;
  for(int i=1;i<exponent;i++){
    result*=base;
  }
  return result;
}
void solve(int e){
  int result=1000001;
  int x=0,y=0,z=0;
  for(y=0;pow(y,2)<1000001;y++) {
    for (z = 0; pow(z, 3) < 1000001; z++) {
      int x = e - pow(y, 2) - pow(z, 3);
      if (x < 0) continue;
      result = std::min(result, x + y + z);
    }
  }

  cout<<result<<endl;
}

int main(void){
  while(1){
    int e;
    cin>>e;
    if(e==0) break;
    solve(e);
  }
  return 0;
}



Measured memory_bytes: 3060
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
MOD = 10**9 + 7
memo = {}
for i in range(n+1):
    memo[i] = 1
for i in range(m):
    memo[a[i]] = 0

dp = [0] * (n+1)

dp[0] = 1
dp[1] = memo[1]

for i in range(0, n-1):
    if memo[i+2] == 0:
        dp[i+2] = 0
    else:
        dp[i+2] = dp[i+1] + dp[i]
    dp[i+2] %= MOD
print(dp[n])


Measured memory_bytes: 19108
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int Q;
    long A[100], B[100];
    long k;
    long ans;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        cin >> A[i] >> B[i];
    }
    for(int i = 0; i < Q; i++){
        long tmp = max(A[i], B[i]);
        k = (long)sqrt(A[i]*B[i]);
        if(k*(k+1) < A[i]*B[i]){
            ans = 2*k-1;
            if((2*k - tmp + 1)*(tmp+1) >= A[i]*B[i]) ans--;
        }else{
            if(A[i] == B[i]){
                ans = 2*(k-1);
            }else{
                ans = 2*(k-1);
                if(k*k == A[i]*B[i]) ans--;
                if((2*k - tmp)*(tmp+1) >= A[i]*B[i]) ans--;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<fstream>
#include<sstream>
#include<vector>
#include<set>
#include<deque>
#include<cstring>
#include<queue>
#include<stdio.h>
#include<set>
#include<stack>
#include<numeric>
#include<map>
#include<cstdio>
#include<bitset>
#include<array>
#include<list>
using namespace std;
#define ll long long 
const ll mod = 1e9 + 7;

ifstream f1;
ofstream f2;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	f1.open("INP.txt");
	f2.open("OUT.txt");
	ll n;
	cin >> n;
	cout << 3 * pow(n, 2) << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))

from collections import Counter
c=Counter(a)

max_a=max(a)
bls=[0]*(max_a+1)
for a_i in a:
    for j in range(a_i, max_a+1, a_i):
        bls[j]+=1
ans=0
for a_i in a:
    if bls[a_i]==1 and c[a_i]==1:
        ans+=1
print(ans)


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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(b-a==c-b){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;

const int Nmax = 5005;
const long long inf = (1LL<<62);

int i, j, n, k, curr;
struct interval
{
    int l, r, len;
    bool operator < (const interval &other) const
    {
        return len > other.len;
    }
} a[Nmax];
long long d[Nmax/2][Nmax/2][2], ans;

int main()
{
    //freopen("intervals.in", "r", stdin);
    //freopen("intervals.out", "w", stdout);

    scanf("%d", &n);
    for(i=1; i<=n; ++i) scanf("%d%d", &a[i].l, &a[i].r), a[i].len = a[i].l + a[i].r;

    if(n%2==0) ++n;
    sort(a+1, a+n+1);

    for(i=0; i<=n/2; ++i)
    for(j=0; j<=n/2; ++j)
        d[i][j][0] = d[i][j][1] = inf;

    d[0][0][0] = 0;

    for(i=0; i<=n/2; ++i)
    for(j=0; j<=n/2; ++j)
    for(k=0; k<=1; ++k)
    {
        curr = i+j+k+1;
        if(curr>n) continue;

        if(i<n/2) d[i+1][j][k] = min(d[i+1][j][k], d[i][j][k] + a[curr].r + 1LL*a[curr].len*i);
        if(j<n/2) d[i][j+1][k] = min(d[i][j+1][k], d[i][j][k] + a[curr].l + 1LL*a[curr].len*j);
        if(!k) d[i][j][1] = min(d[i][j][1], d[i][j][0] + 1LL*(n-1)/2*a[curr].len);
    }

    printf("%lld\n", d[n/2][n/2][1]);

    return 0;
}


Measured memory_bytes: 98048
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    int n,t;
    string buf;
    cin>>n;
    vector<vector<int>> l(n+1,vector<int>(26,0));
    for(int i=0;i<n;i++){
        cin>>buf;
        for(int j=0;j<buf.length();j++){
            l[i][buf[j]-'a']++;
        }
    }
    
    for(int i=0;i<26;i++){
        t=10000;
        for(int j=0;j<n;j++){
            if(t>l[j][i]) t=l[j][i];
        }
        for(int j=0;j<t;j++){
            cout<<(char)('a'+i);
        }
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

/* UnionFind：素集合系管理の構造体(union by size)
    isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
    unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
    treeSize(x): x を含む集合の要素数。
*/
struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) { return size[findRoot(x)]; }
};
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }

    map<int, ll> mp;
    vector<ll> cost;
    for (int i = 0; i < N; i++) {
        if (mp.count(uf.findRoot(i))) {
            if (mp[uf.findRoot(i)] > a[i]) {
                cost.push_back(mp[uf.findRoot(i)]);
                mp[uf.findRoot(i)] = a[i];
            } else {
                cost.push_back(a[i]);
            }
        } else {
            mp[uf.findRoot(i)] = a[i];
        }
    }
    sort(cost.begin(), cost.end());

    ll ans = 0;
    for (auto p : mp) {
        ans += p.second;
    }
    int n = mp.size();
    int en = n - 1;
    int use_vn = en * 2 - n;
    if (n == 1) {
        cout << 0 << endl;
    } else if (use_vn > (int)cost.size()) {
        cout << "Impossible" << endl;
    } else {
        ans += accumulate(cost.begin(), cost.begin() + use_vn, 0LL);
        cout << ans << endl;
    }
}


Measured memory_bytes: 10576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<P> red(n), blue(n);
  rep(i, n) cin >> red[i].first >> red[i].second;
  rep(i, n) cin >> blue[i].first >> blue[i].second;
  sort(red.begin(), red.end());
  sort(blue.begin(), blue.end());
  vector<int> used(n);

  int ans = 0;
  rep(i, n) {
    int maxRed = -1;
    rep(j, n) {
      if(blue[i].first <= red[j].first) break;
      if(blue[i].second > red[j].second && !used[j]) {
        if(maxRed == - 1) maxRed = j;
        else if(red[maxRed].second < red[j].second) maxRed = j;
      }
    }
    if(maxRed != -1) {
      used[maxRed] = true;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  ll candy[2]={};
  cin>>candy[0];
  ll ans=0;
  if(candy[0]>x){
    ans+=candy[0]-x;
    candy[0]=x;
  }
  for(int i=1;i<n;i++){
    cin>>candy[i%2];
    //cout<<candy[i%2]<<" "<<candy[(i+1)%2]<<endl;
    if(candy[i%2]+candy[(i+1)%2]>x){
      ll tmp=candy[i%2]+candy[(i+1)%2]-x;
      candy[i%2]-=tmp;
      ans+=tmp;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
int main()
{
	ios::sync_with_stdio(false);
	string a,b,c;
	char a1,b1,c1;
	cin>>a>>b>>c;
	a1=a[0];
	b1=b[0];
	c1=c[0];
	cout<<a1<<b1<<c1<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int gcd(int m, int n) {
    int r;
    while (0 != n) {
        r = m % n;
        m = n;
        n = r;
    }
    return m;
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        ans += a - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B, C, X;
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		X = sc.nextInt();

		int cnt = 0;
		for (int i = 0; i <= A; i++) {
			for (int j = 0; j <= B; j++) {
				for (int k = 0; k <= C; k++) {
					int sum = 500 * i + 100 * j + 50 * k;
					if(sum == X) cnt++;
				}
			}
		}

		System.out.print(cnt);
	}
}

Measured memory_bytes: 21844
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 07-Mar-20 1:26:10 PM
	flamers will **** you
*/
//#include<flamers.h>

#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define POB pop_back

using namespace std;

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	string s;
	cin>>s;
	int q;
	cin>>q;
	bool reversed = false;
	string b = "";
	while(q--) {
		int t;
		cin>>t;
		if(t == 1) {
			reversed = !reversed;
		} else {
			int f;
			cin>>f;
			char c;
			cin>>c;
			if(f == 1) {
				if(!reversed) b += c;
				else s += c;
			} else {
				if(!reversed) s += c;
				else b += c;
			}
		}
	}
	reverse(b.begin(), b.end());
	s = b + s;
	if(reversed) reverse(s.begin(), s.end());
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1196
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
import random
import time
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def scorei(ti, i, last, minus):
        k = [i for i in last]
        mi = minus-(i+1-last[ti])*c[ti]
        v = s[i][ti]-mi
        mi += sum_
        k[ti] = i+1
        return v, k, mi

    def score(t):
        n = 26
        v = 0
        minus = sum_ = sum(c)
        last = [0]*n
        for i in range(d):
            ti = t[i]-1
            minus -= (i+1-last[ti])*c[ti]
            v += s[i][ti]-minus
            minus += sum_
            last[ti] = i+1
        return v
    start = time.time()
    d = I()
    c = LI()
    s = LIR(d)
    n = 26
    m = 10000
    sum_ = sum(c)
    q = [(0, 0, [0]*n, sum_)]
    pre = [[None]*n for i in range(d)]
    sc = [[float("inf")]*n for i in range(d)]
    argmax = 0
    for i in range(d):
        nq = []
        for _ in range(m):
            if not q:
                break
            v, x, last, minus = heappop(q)
            if i > 0 and v > sc[i-1][x]:
                continue
            for ti in range(n):
                vi,nl,nm = scorei(ti,i,last,minus)
                nv = v-vi
                heappush(nq,(nv,ti,nl,nm))
                if sc[i][ti] > nv:
                    sc[i][ti] = nv
                    pre[i][ti] = x
        q = [i for i in nq]
    t = []
    argmax = 0
    m = sc[-1][0]
    for i in range(1,n):
        sci = sc[-1][i]
        if m > sci:
            m = sci
            argmax = i
    t.append(argmax)
    x = argmax
    for i in range(1,d)[::-1]:
        y = pre[i][x]
        t.append(y)
        x = y
    t = [i+1 for i in t[::-1]]
    v = score(t)
    i = 0
    while time.time() < 1.5+start:
        nt = [i for i in t]
        r = random.random()
        if r > 0.5:
            if nt[i] < n:
                nt[i] += 1
        else:
            if nt[i] > 1:
                nt[i] -= 1
        nv = score(nt)
        if v < nv:
            t = [i for i in nt]
            v = nv
        i += 1
        i %= d
    for i in t:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 119044
#include<stdio.h>
typedef struct{
    int won;
    int lost;
}Team;
Team team[9];
int n,m;
int cnt;
int map[9][9];
void init(){
    for(int i=0;i<n;i++){
        team[i].won=team[i].lost=0;
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i==j)
                map[i][j]=1;
            else
                map[i][j]=0;
        }
    }
}
void rec(int y, int x){
    if(x==n){
        y++; x=y+1;
    }
    
    
    if(team[y].won>(n/2));
    else if(team[y].lost>(n/2));
    else if(y==n-2 && x==n-1){
        cnt++;
    }
    else{
        if(map[y][x]!=0){
            rec(y,x+1);
        }
        else{
            if(team[y].won<(n/2)){
                team[y].won++;
                team[x].lost++;
                map[y][x]=map[x][y]=1;
                rec(y,x+1);
                map[y][x]=map[x][y]=0;
                team[y].won--;
                team[x].lost--;
            }
            
            if(team[y].lost<(n/2)){
                team[y].lost++;
                team[x].won++;
                map[y][x]=map[x][y]=1;
                rec(y,x+1);
                map[y][x]=map[x][y]=0;
                team[y].lost--;
                team[x].won--;
            }
        }
    }
}
int main(void){
    while(1){
        scanf("%d",&n); if(n==0) break;
        init();
        scanf("%d",&m);
        for(int i=0; i<m; i++){
            int x,y;
            scanf("%d %d",&x,&y);
            x--; y--;
            map[x][y]=1;
            map[y][x]=1;
            team[x].won++; team[y].lost++;
        }
        cnt=0;
        rec(0,0);
        printf("%d\n",cnt);
    }
}



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

#define ll long long
#define INF 99999999

int main() {
    vector<char> a;
    string b;
    int zero = 0;
    int one = 0;
    cin >> b;
    //copy(b.begin(),b.end(),back_inserter(a));
    if(a.size() ==1)
    {
        cout << "ee" << endl;
        cout << 0 << endl;
        return 1;
    }
    string tmp;
    for(int i = 0;i < b.size();i++)
    {
        tmp = b[i];
        if(tmp=="0") zero++;
        else one++;
    }
    if(zero > one) cout << one * 2 <<endl;
    else cout << zero * 2 << endl;
}



Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
using  namespace std;
const int MAXN = 105;
int n, sum, tmp;
int w[MAXN];
int main(){
	scanf("%d",&n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d",&w[i]);
		sum += w[i];
	}
	for (int i = 1; i <= n; ++i) {
		tmp += w[i];
		if ((tmp<<1) >= sum) {
			printf("%d", min ((tmp<<1) - sum, sum - ((tmp - w[i])<<1)));
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
while(1):
    [H,W]=[int(x) for x in raw_input().split()]
    if H==0:
        break
    else:
        field=[]
        fieldvisited=[[0 for i in range(W)] for y in range(H)]
        for i in range(H):
            field.append(raw_input())
        x=0
        y=0
        while(1):
            if fieldvisited[y][x]:
                print 'LOOP'
                break
            fieldvisited[y][x]=1
            if field[y][x]=='>':
                x+=1
            elif field[y][x]=='<':
                x-=1
            elif field[y][x]=='^':
                y-=1
            elif field[y][x]=='v':
                y+=1
            elif field[y][x]=='.':
                print x,y
                break

Measured memory_bytes: 4404
#include <stdio.h>
int main(void){
    int x,y;
    while(1){
           scanf("%d %d",&x,&y);
         if(x == 0 && y == 0)break;
        if( x >= y ){
            printf("%d %d\n",y,x);
        }
        else if( y >= x ){
            printf("%d %d\n",x,y);
        }
    }
    return 0;
}
        

Measured memory_bytes: 600
#C - Skip
N,X = map(int, input().split())
a =list(map(int, input().split()))
a.append(X)
a = sorted(a,reverse=True)
b =[]
for i in range(N):
    b.append(a[i]-a[i+1])

import fractions
ans = b[0]
for i in range(1, N):
    ans = fractions.gcd(ans, b[i])

print(ans)

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
string L;
ll Q, q[200010][4], num, X, Y, bit[200010];
vector<P> xcd;

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= num)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return po(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = po(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return po(x, mod - 2);
}

int main(void)
{
	cin >> Q;
	for (int i = 0; i < Q; i++)
	{
		cin >> q[i][0];
		if (q[i][0] == 1)
		{
			cin >> q[i][1] >> q[i][2];
			xcd.push_back(P(q[i][1], i));
		}
	}
	num = xcd.size();
	sort(xcd.begin(), xcd.end());
	for (int i = 0; i < num; i++)
	{
		q[xcd[i].second][3] = i + 1;
	}
	ll t = 1;
	for (int i = 0; i < Q; i++)
	{
		if (i == 0)
		{
			X = q[i][1], Y = q[i][2];
			add(q[i][3], 1);
			t++;
		}
		else if (q[i][0] == 1)
		{
			ll half = (t + 1) / 2;
			add(q[i][3], 1);
			ll lb = 0, ub = num;
			while (lb + 1 < ub)
			{
				ll mid = (lb + ub) / 2;
				if (sum(mid - 1) >= half)
				{
					ub = mid;
				}
				else
				{
					lb = mid;
				}
			}
			if (t % 2 == 0)
			{
				Y += abs(xcd[lb - 1].first - X) + q[i][2] + abs(q[i][1] - xcd[lb - 1].first);
			}
			else
			{
				Y += abs(q[i][1] - xcd[lb - 1].first) + q[i][2];
				if (q[i][1] < X)
				{
					Y += 2 * abs(X - xcd[lb - 1].first);
				}
			}
			X = xcd[lb - 1].first;
			t++;
		}
		else
		{
			cout << X << ' ' << Y << endl;
		}
	}
	int www;
	cin >> www;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    vector<pair<int,double>> a;
    rep(i,n){
        int p;
        cin >> p;
        a.emplace_back(p,(double)(1+p)/2);
    }
    vector<double> e(n);
    e.at(0) = a.at(0).second;
    cout << fixed << setprecision(10);
    for(int i = 1 ; i < n;i++){
        e.at(i) = e.at(i-1) + a.at(i).second;
    }
    double ans = e.at(k-1);
    for(int j = 0; j + k < n;j++){
        double t = e.at(j + k) - e.at(j);
        ans = max(ans,t);
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7848
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <set>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 100100;
const llint inf = 1e18;

int x[MAX];
llint f[MAX];

int main(void) {
  int N, E, T;
  scanf("%d %d %d", &N, &E, &T);
  REP(i, N) scanf("%d", &x[i]);
  
  f[0] = 0;
  multiset<llint> S2;
  S2.insert(f[0]);
  
  int j = 0;
  llint best = inf;
  for (int i = 1; i <= N; ++i) {
    while (2*(x[i-1] - x[j]) > T) {
      S2.erase(S2.find(f[j]));
      best = min(best, f[j] - 2*x[j]);
      j++;
    }

    f[i] = min(best + 2*x[i-1], *S2.begin() + T);
    S2.insert(f[i]);
  }

  llint ans = E + f[N];
  //printf("%lld\n", ans);
  cout << ans << endl;
  return 0;
}


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

const int N = 1e5 + 1e3;

vector<int> G[N]; queue<int> Q; int col[N], n;

int main () {

	File();

	n = read();

	For (i, 1, n - 1) {
		int u = read(), v = read();
		G[u].push_back(v); G[v].push_back(u);
	}
	col[1] = 1; col[n] = 2; Q.push(1); Q.push(n);

	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		for (int v : G[u]) if (!col[v])
			col[v] = col[u], Q.push(v);
	}
	
	int ans = 0;
	For (i, 1, n) 
		ans += col[i] == 1 ? 1 : -1;
	puts(ans > 0 ? "Fennec" : "Snuke");

	return 0;

}

Measured memory_bytes: 6272
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;

int main(){
  int N;
  int count;
  int root;
  int f;
  int xx,yy,xy;
  cin >> N;
  root=(int)sqrt(N);
  for(int n=1;n<=N;n++){
    count=0;
    for(int x=1;x<=root;x++){
      xx=x*x;
      if(xx>n)break;
      for(int y=1;y<=root;y++){
        yy=y*y;
        xy=x*y;
        if((xx+yy+xy)>n)break;
        for(int z=1;z<=root;z++){
          f=xx+yy+xy+(x+y+z)*z;
          if(f>n)break;
          if(f==n){
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }
  return(0);
}


Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#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 fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
#define int long long
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k; cin >> n >> k;
    vector<P> v;
    rep(i,n){
        int t,d; cin >> t >> d;
        t--;
        v.pb({d,t});
    }
    sort(ALL(v),greater<P>());
    vector<bool> used(n,0);
    priority_queue<int,vector<int>,greater<int>> pq;
    vector<ll> ans(n+1,0);
    ll res=0,hoge=0;
    rep(i,k){
        res+=v[i].fi;
        if(!used[v[i].se]){
            used[v[i].se]=1;
            hoge++;
        }else{
            pq.push(v[i].fi);
        }
    }
    ans[hoge]=res;
    for(int i=k;i<n;i++){
        if(pq.empty()) break;
        if(!used[v[i].se]){
            used[v[i].se]=1;
            hoge++;
            ans[hoge]=ans[hoge-1]+v[i].fi-pq.top();
            pq.pop();
        }
    }
    ll fuga=0;
    rep(i,n+1){
        if(ans[i]!=0) ans[i]+=i*i;
        chmax(fuga,ans[i]);
    }
    cout << fuga << endl;
}


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

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

	vector<int> a(N);

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

	int count = 0;
	for (int i = 0; i < N; i++) {
		if ((i + 1) % 2 != 0 && a.at(i) % 2 != 0) {
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3180
n, k = map(int, input().split())
result = 0
seq = []

for i in range(1,n+1):
    count = 0
    temp = i
    while temp < k:
        temp *= 2
        count += 1
    seq.append(count)

for i in range(n):
    result += 1/n * (0.5)**seq[i]
    
    
print(result)

Measured memory_bytes: 3864
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int s,w; cin >> s >> w;
  if(w>=s) cout << "unsafe";
  else cout << "safe";

  

  return 0;
}

Measured memory_bytes: 3608
import sys
import numpy as np

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


D = ini()
C = inl()
assert len(C) == 26
S = np.zeros((D, 26), dtype="int32")
for i in range(D):
    S[i, :] = inl()


def calc_score(sol):
    last = -np.ones((26, D + 1))
    score = 0
    for d in range(D):
        ct = sol[d]
        score += S[d, ct]
        for i in range(26):
            last[i, d + 1] = last[i, d]
        last[ct, d + 1] = d
        for i in range(26):
            score -= C[i] * (d - last[i, d + 1])
    return score, last


def main():
    sol = np.random.randint(0, 26, D)
    sol_bak = sol.copy()
    max_score, last = calc_score(sol)
    last_bak = last.copy()

    def update(d, before, after):
        score = max_score
        score -= S[d, before]
        score += S[d, after]
        lb = last[before, d]
        la = last[after, d]
        da = db = 0
        for x in range(d, D):
            if x > d and sol[x] == before:
                break
            last[before, x + 1] = lb
            db += 1
        score -= C[before] * (d - lb) * db
        for x in range(d, D):
            if x > d and sol[x] == after:
                break
            last[after, x + 1] = d
            da += 1
        score += C[after] * (d - la) * da
        sol[d] = after
        return score

    for i in range(3000):
        new_d = np.random.randint(0, D)
        c_before = sol[new_d]
        for c_after in range(26):
            if c_before == c_after:
                continue
            new_score = update(new_d, c_before, c_after)
            if max_score < new_score:
                max_score = new_score
                sol_bak = sol.copy()
                last_bak[c_before, :] = last[c_before, :].copy()
                last_bak[c_after, :] = last[c_after, :].copy()
            else:
                sol = sol_bak.copy()
                last[c_before, :] = last_bak[c_before, :].copy()
                last[c_after, :] = last_bak[c_after, :].copy()

    print(*(sol + 1), sep="\n")


main()


Measured memory_bytes: 27708
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  ll N,C,K; cin>>N>>C>>K;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  sort(ALL(A));
  ll ans=1,sum=1,memo=A[0];
  
  rep(i,1,N){
    if(sum==C||memo+K<A[i]){
      ans++;
      sum=1;
      memo=A[i];
    }
    else sum++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
int a[4];
using namespace std;
int main()
{
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+1+3);
	if(a[1]==5&&a[2]==5&&a[3]==7) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 3056
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        while (!s.equals("-")) {
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                int h = scanner.nextInt();
                String s1 = s.substring(0, h);
                String s2 = s.substring(h);
                s = s2 + s1;
            }
            System.out.println(s);
            s = scanner.next();
        }
    }
}


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

typedef long long ll;
typedef pair<ll,ll> P;

int dp[303][303][303];
string s;
int k;

int dfs(int K,int L,int R)
{
//	cout << K << ' ' << L << ' ' << R << endl;
	if(K < 0)return -100000000;
	if(L > R)return 0;
	if(dp[K][L][R] != 0)return dp[K][L][R];
	int ret = 0;
	if(s[L] == s[R])ret = max(ret,dfs(K,L+1,R-1)+2);
	else ret = max(ret,dfs(K-1,L+1,R-1)+2);
	ret = max(ret,dfs(K,L+1,R));
	ret = max(ret,dfs(K,L,R-1));
	
	return dp[K][L][R] = ret;
}


int main()
{
	cin >> s >> k;
	
	REP(K,303)REP(i,303)dp[K][i][i] = 1;
	cout << dfs(k,0,s.size()-1) << endl;
	
	return 0;
}


Measured memory_bytes: 109056
#include <iostream>
using namespace std;
int main( void )
{
	for ( int i = 1; i <= 9; i++ )
	{
		for ( int j = 1; j <= 9; j++ )
		{
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	double L;
	cin >> L, L /= 3;
	cout << fixed << setprecision(15);
	cout << L * L * L;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 2010;
int const M = 1001000;
int n, m;
struct edges{ int u, w, next; } e[M];
int p[N], idx;
void addedge(int u, int v) {
  e[idx].u = v, e[idx].next = p[u], e[idx].w = 1, p[u] = idx++;
}
void init() { idx = 0; clr(p, 0xff); }
priority_queue<pair<int, int> > Q;
int dis[N]; bool vis[N];
void dijkstra(int s) {
  int u, v, w;
  while (!Q.empty()) Q.pop(); clr(vis, 0), clr(dis, 0x3f);
  Q.push(make_pair(0, s)), dis[s] = 0;
  while (!Q.empty()) {
    pair<int, int> tmp = Q.top(); Q.pop();
    if (vis[u = tmp.second]) continue;
    else vis[u] = 1;
    for (int i = p[u]; ~i; i = e[i].next) {
      v = e[i].u, w = e[i].w;
      if (!vis[v] && dis[u] + w < dis[v]) {
        dis[v] = dis[u] + w;
        Q.push(make_pair(-dis[v], v));
      }
    }
  }
}
int dx[N], dy[N];
int ans[N];
int main() {
  int x, y; scanf("%d%d%d", &n, &x, &y);
  init();
  Rep(i, n - 1) {
    addedge(i, i + 1);
    addedge(i + 1, i);
  }
  addedge(x, y); addedge(y, x);
  dijkstra(x); Rep(i, n) dx[i] = dis[i];
  dijkstra(y); Rep(i, n) dy[i] = dis[i];
  
  
  Rep(i, n) {
    for (int j = i + 1; j <= n; ++j) {
      int d = min(j - i, dx[i] + dx[j]);
      d = min(d, dy[i] + dy[j]);
      ans[d]++;
      //printf("%d %d : %d\n", i, j, d);
    }
  }
  Rep(i, n - 1) printf("%d\n" ,ans[i]);
  return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <array>
#include <algorithm>
struct Dish{
    long long a;
    long long b;
    long long sum;
};
int main(){
    std::size_t n;
    std::cin >> n;
    std::array<Dish, 100000> dishVec;
    for(std::size_t i = 0; i < n; i++){
        std::cin >> dishVec[i].a >> dishVec[i].b;
        dishVec[i].sum = dishVec[i].a + dishVec[i].b;
    }
    std::sort(dishVec.begin(), dishVec.begin() + n, [](auto d1, auto d2){
        return d2.sum < d1.sum;
    });

    long long result = 0;
    for(std::size_t i = 0; i < n; i++){
        if(i%2 == 0)
            result += dishVec[i].a;
        else
            result -= dishVec[i].b;
    }

    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int count = 0;
    for(int i = 1;i <= b;i++){
      if(i%a == 0){
        if(count < c){
          count++;
        }
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 23252
#include <stdio.h>
 
int main(){
   int N, i, j;
   long int sum=0;
   scanf("%d", &N);
   long int a[N], s[N];
  //
   for(i=0; i<N; i++) scanf("%ld", &a[i]);
   s[0]=a[0];
  //
   for(i=1; i<N; i++) s[i]=s[i-1]+a[i];
   for(i=0; i<N-1; i++) sum=(sum+a[i]*((s[N-1]-s[i])%1000000007))%1000000007;
   printf("%ld", sum);
}

Measured memory_bytes: 4804
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=2e5+10;
const int inf=1e9;
int n,a[N],vis[N];
ll k;
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>k;
	rep(i,1,n) cin>>a[i];
	vector<int>q;
	int x=1,l=0;
	while(!vis[x]){
		vis[x]=++l;
		q.pb(x);
		x=a[x];
	}
	++k;
	int s=vis[a[q[l-1]]]-1,t=l-1;
	if(k<=s){
		cout<<q[k-1]<<endl;
	}else{
		k-=s+1;
		k%=(t-s+1);
		cout<<q[k+s]<<endl;
	}
	return 0;
}
/*
1 6 2 5 3 2
*/


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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int m = ni();
		int l = 1;
		int r = n;
		for(int i = 0; i < m; i++) {
			int tl = ni();
			int tr = ni();
			if(l < tl) {
				if(tl <= r) {
					l = tl;
				} else {
					System.out.println(0);
					return;
				}				
			}
			if(r > tr) {
				if(tr >= l) {
					r = tr;
				} else {
					System.out.println(0);
					return;
				}
			}

		}
		System.out.println(r - l + 1);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 40476
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int a , b , k , i;
    scanf("%d%d%d" , &a , &b , &k);
    for(i = min(a , b); i >= 1 && k > 0; i --)
        if(a % i == 0 && b % i == 0)
            k--;
    printf("%d" , i + 1);
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N =1000;

int lcs(string X,string Y){
  int c[N+1][N+1];
  int m=X.size();
  int n=Y.size();
  int maxl=0;
  X=' '+X;
  Y=' '+Y;
  for(int i=0;i<=m;i++)c[i][0]=0;
  for(int j=1;j<=n;j++)c[0][j]=0;

  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i]==Y[j]){
        c[i][j]=c[i-1][j-1]+1;
      }else{
        c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
maxl=max(maxl,c[i][j]);
    }
  }
return maxl;
}

int main(){
  string s1,s2;
  int n;cin>>n;
  for(int i=0;i<n;i++){
    cin>>s1>>s2;
    cout<<lcs(s1,s2)<<endl;
  }
return 0;
}


Measured memory_bytes: 7040
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

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

    vector<vector<long long>> A(N, vector<long long>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }

    vector<vector<bool>> joined(N, vector<bool>(N, true));
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (A[i][k] + A[k][j] < A[i][j]) {
                    cout << -1 << endl;
                    return 0;
                } else if (k != i && k != j && A[i][k] + A[k][j] == A[i][j]) {
                    joined[i][j] = false;
                }
            }
        }
    }

    long long sum = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            if (joined[i][j]) {
                sum += A[i][j];
            }
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main () {
  char M;
  cin>>M;
  char ans='a';
  if (M=='A'||M=='B'||M=='C'||M=='D'||M=='E'||M=='F'||M=='G'||M=='H'||M=='I'||M=='J'||M=='K'||M=='L'||M=='M'||M=='N'||M=='O'||M=='P'||M=='Q'||M=='R'||M=='S'||M=='T'||M=='U'||M=='V'||M=='W'||M=='X'||M=='Y'||M=='Z')
    ans='A';
  cout<<ans<<endl;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,W;
    cin >> n >> W;
    vector<ll> w(n);
    vector<ll> v(n);
    for(i = 0;i < n;++i){
        cin >> w.at(i) >> v.at(i);
    }
    vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
    for(i = 1;i <= n;++i){
        rep(j, W+1){
            if(j < w.at(i-1)) dp.at(i).at(j) = dp.at(i-1).at(j);
            else dp.at(i).at(j) = max(dp.at(i-1).at(j), dp.at(i-1).at(j - w.at(i-1)) + v.at(i-1));
        }
    }
    cout << dp.at(n).at(W) << endl;
    return 0;
} 

Measured memory_bytes: 80256