akhauriyash/Code-Regression huggingface dataset:
private class E {
    fun solve() {
        val n = nextInt()
        val a = IntArray(n) { nextInt() }
        var x1 = 0
        for (i in 1 until n) {
            x1 = x1 xor a[i]
        }
        val ans = IntArray(n) { 0 }
        ans[0] = x1
        val x = x1 xor a[0]
        for (i in 1 until n) {
            ans[i] = a[i] xor x
        }
        for (i in 0 until n ) {
            print("${ans[i]} ")
        }
     }

    var tokenBuffer = listOf<String>()
    var bufferPosition = 0

    private fun checkBuffer() {
        if (bufferPosition == tokenBuffer.size) {
            tokenBuffer = nextLine().split(" ")
            bufferPosition = 0
        }
    }

    fun nextLine() = readLine()!!
    fun nextInt(): Int {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toInt()
    }

    fun nextLong(): Long {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toLong()
    }

    fun nextDouble(): Double {
        checkBuffer()
        return tokenBuffer[bufferPosition++].toDouble()
    }

    fun nextToken(): String {
        checkBuffer()
        return tokenBuffer[bufferPosition++]
    }
}

fun main() {
    val reader = E().solve()

}


Measured memory_bytes: 69332
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    ll N,K;cin >> N >> K;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    ll res = 0;
    for(int d=60;d>=0;d--){
        if(!((K+1)&1LL<<d))continue;
        ll tmp = 0;
        
        for(int e=60;e>=0;e--){
            int num = 0;
            ll mask = 1LL<<e;
            rep(i,N)if(A[i]&mask)num++;
            if(e>d){
                if((K+1)&mask)tmp+=mask*(N-num);
                else tmp+=mask*num;
            }else if(e==d){
                tmp+=mask*num;
            }else{
                tmp+=max(mask*(N-num),mask*num);
            }
        }
        res = max(tmp,res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
import numpy as np

N, M = map(int, input().split())

X = []
Y = []
Z = []

for n in range(N):
    x, y, z = map(int, input().split())
    X.append(x)
    Y.append(y)
    Z.append(z)

# 1. Optimize + + +
def opt(px, py, pz):
    scores = []
    for n in range(N):
        s = 0
        if px:
            s += X[n]
        else:
            s -= X[n]
        if py:
            s += Y[n]
        else:
            s -= Y[n]
        if pz:
            s += Z[n]
        else:
            s -= Z[n]
        scores.append(s)
    s_scores = sorted(scores, reverse=True)
    tot = sum(s_scores[0:M])
    return tot

score = -1
score = max(score, opt(True, True, True))
# print(score)
score = max(score, opt(True, True, False))
score = max(score, opt(True, False, True))
score = max(score, opt(True, False, False))
score = max(score, opt(False, True, True))
score = max(score, opt(False, True, False))
score = max(score, opt(False, False, True))
score = max(score, opt(False, False, False))
print(score)


Measured memory_bytes: 12516
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    K = int(sys.stdin.readline())
    ans = 0
    for i in range(1, K + 1):
        for j in range(i + 1, K + 1):
            if i % 2 == 0:
                if j % 2 != 0:
                    ans += 1
            else:
                if j % 2 == 0:
                    ans += 1
    print(ans)

Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll x,a;
    cin >> x >> a;
    
    if (x>=a)cout << 10 << endl;
    else if (a>x)cout << 0 << endl;
    
   
    
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>

int dp[101][300];

int main()
{
	int n,m,w0,w,v,i,j;
	scanf("%d%d%d%d",&n,&m,&w0,dp[1]);
	while(--n)
	{
		scanf("%d%d",&w,&v);
		w-=w0;
		for(i=100;i;i--)
			for(j=w;j<300;j++)
				if(dp[i-1][j-w]+v>dp[i][j])
					dp[i][j]=dp[i-1][j-w]+v;
	}

	int ans=0;
	for(i=1;i<=100&&i*w0<=m;i++)
		for(j=0;j<300&&i*w0+j<=m;j++)
			if(dp[i][j]>ans)ans=dp[i][j];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int root[200];
int size[200];

int getRoot(int v){ return root[v]==-1 ? v : root[v] = getRoot(root[v]); }

int main(){
	int N, M;
	int height[200];
	while(cin >> N >> M && N){
		vector< vector< pair<int,int> > > g(N);
		vector< pair<int, int> > h;
		for(int i=0;i<N;i++){
			cin >> height[i];
			h.push_back(make_pair(height[i], i));
		}
		sort(h.rbegin(), h.rend());
		int lastIdx = h[0].second;
		int sep = h[0].first+1;
		for(int i=0;i<M;i++){
			int a, b, c; cin >> a >> b >> c;
			g[a-1].push_back(make_pair(b-1,c));
			g[b-1].push_back(make_pair(a-1,c));
		}
		memset(root, -1, sizeof(root));
		for(int i=0;i<N;i++) size[i] = 1;
		for(int i=0;i<N; ){
			int curTime = h[i].first;
			while(i<N && h[i].first == curTime){
				int idx = h[i].second;
				for(int j=0;j<g[idx].size();j++){
					if(height[g[idx][j].first] < curTime) continue;
					int p = getRoot(idx);
					int q = getRoot(g[idx][j].first);
					if(p!=q){
						size[p] += size[q];
						root[q] = p;
					}
				}
				i++;
			}
			if(size[getRoot(lastIdx)] != i) sep = curTime;
		}
		if(sep == h.back().first){
			cout << 0 << endl;
			continue;
		}
		int res = 0;
		memset(root, -1, sizeof(root));
		for(int i=0;i<N; ){
			vector< pair<int, pair<int,int> > > vp;
			while(i<N && h[i].first >= sep){
				int idx = h[i].second;
				for(int j=0;j<g[idx].size();j++)
					vp.push_back(make_pair(g[idx][j].second, make_pair(idx, g[idx][j].first)));
				i++;
			}
			int curTime = h[i].first;
			while(i<N && h[i].first == curTime){
				int idx = h[i].second;
				for(int j=0;j<g[idx].size();j++)
					vp.push_back(make_pair(g[idx][j].second, make_pair(idx, g[idx][j].first)));
				i++;
			}
			sort(vp.begin(), vp.end());
			for(int j=0;j<vp.size();j++){
				if(height[vp[j].second.second] < curTime) continue;
				int p = getRoot(vp[j].second.first);
				int q = getRoot(vp[j].second.second);
				if(p != q){
					res += vp[j].first;
					root[q] = p;
				}
			}
		}
		cout << res << endl;
	}
}

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

void bubbleSort(int A[3],int N){
  int flag = 1;
  int i = 0;
  for(; flag;){
    flag = 0;
    for(int j = N-1; j >= i+1; j--){
      if(A[j] < A[j-1]){
        swap(A[j],A[j-1]);
        flag = 1;
      }
    }
  }
  i++;

}


int main(){
  int A[3],N;
  N = 3;
  for(int i = 0; i < 3; i++) cin >> A[i];
  bubbleSort(A,N);
  cout << A[0] + A[1] << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    M=sum(A)/2
    l=0
    for i in range(N):
        o=l
        l+=A[i]
        if l>=M:
            break
    if (l-M) > (M-o):
        l=o
    print(int(abs(l-M)*2))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27748
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n';
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    REP(i, n) cin >> h[i];
    SORT(h);
    REV(h);
    ll ans = 0;
    FOR(i, k, n) {
        ans += h[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
//#define int long long  
signed main(){
    string S;
    cin >> S;
    int Ans=700;
    REP(i,3){
        if(S[i]=='o')Ans+=100;
    }
    cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline  # NOQA
sys.setrecursionlimit(10 ** 7)  # NOQA


def dfs(G, v, p, counter):
    """G: graph, v: vertex, p: parent"""
    # Loop for each child
    # counter_v = counter[v]
    for c in G[v]:
        if c == p:
            continue  # Avoid multiple access to parent
        # counter[c] += counter_v
        counter[c] += counter[v]
        dfs(G, c, v, counter)


def main():
    N, Q = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)

    counter = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    dfs(G, 0, -1, counter)
    print(*counter)


if __name__ == "__main__":
    main()


Measured memory_bytes: 230932
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N;
	int[] A;
	List<int[]> pairs;

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		A = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
	}

	void calc() {
		int min = 1000;
		int max = -1;
		pairs = new ArrayList<>();

		for (int i = 0; i < N; ++i) {
			if (min >= 1000) {
				// 買値を探している
				min = A[i];
			} else if (max < 0) {
				// 売値を探している or 買値の底を更新する
				if (min >= A[i]) {
					// 買値の底更新
					min = A[i];
				} else {
					// 売値更新
					max = A[i];
				}
			} else {
				// 下がるタイミングを探している
				// maxよりも価格が下がったらそれまでの価格で売る
				if (A[i] < max) {
					int[] array = new int[2];
					array[0] = min;
					array[1] = max;
					pairs.add(array);
					min = A[i];
					max = -1;
				} else {
					// 売値更新
					max = A[i];
				}
			}
		}

		if (min < max) {
			int[] array = new int[2];
			array[0] = min;
			array[1] = max;
			pairs.add(array);
		}

	}

	void showResult() {
		long result = 1000;
		for (int i = 0; i < pairs.size(); ++i) {
			int min = pairs.get(i)[0];
			int max = pairs.get(i)[1];
			long stockNum = result / (long) min;
			result %= (long) min;
			result += stockNum * (long) max;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 25400
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

using i64 = long long;
using pii = pair<int, int>;

const int N = 1 << 17;


vector<i64> chain_vals[N];
vector<pii> g[N];
int siz[N];

vector<int> centroids;
i64 ant;
int n, ptr;


void get_siz(int u, int far = 0) {
	siz[u] = 1;
	for (auto v: g[u]) if (v.x != far) {
		get_siz(v.x, u);
		siz[u]+= siz[v.x]; } }

void get_centroid(int u, int far = 0) {
	for (auto v: g[u]) if (v.x != far)
		get_centroid(v.x, u);
	
	int maxs(0);
	for (auto v: g[u]) if (v.x != far)
		maxs = max(maxs, siz[v.x]);
	
	if (maxs <= n / 2 && n - siz[u] <= n / 2)
		centroids.push_back(u); }

void get_chains(int u, i64 cost, int far) {
	chain_vals[ptr].push_back(cost);
	for (auto v: g[u]) if (v.x != far)
		get_chains(v.x, v.y + cost, u); }

void test(int u) {
	priority_queue<pii> pq;
	i64 sum;
	int min_drop;
	bool flag;

	ptr = 0;
	for (auto v: g[u]) {
		chain_vals[ptr].clear();
		get_chains(v.x, v.y, u);
		sort(chain_vals[ptr].rbegin(), chain_vals[ptr].rend());
		++ptr; }

	sum = 0;
	for (int i = 0; i < ptr; ++i)
		for (auto j: chain_vals[i])
			sum+= 2 * j; 

	flag = false;
	get_siz(u);
	for (auto v: g[u]) 
		if (siz[v.x] >= n - siz[v.x]) {
			flag = true;
			sum-= v.y;
			break; }

	if (!flag) {
		min_drop = 2e9;
		for (auto v: g[u])
			min_drop = min(min_drop, v.y); 
		sum-= min_drop; }

	ant = max(ant, sum); }


int main() {
#ifdef HOME
	freopen("agc018d.in", "r", stdin);
	freopen("agc018d.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int a, b, c;

	cin >> n;
	for (int i = 1; i < n; ++i) {
		cin >> a >> b >> c;
		g[a].emplace_back(b, c);
		g[b].emplace_back(a, c); }

	if (n == 2) {
		cout << g[1][0].y << endl;
		exit(0); }

	get_siz(1);
	get_centroid(1);

	for (auto i: centroids)
		test(i);

	cout << ant << endl;

	return 0; }



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

int main(){
    int n; cin >> n;
    ll total = 0;
    vector<ll> lis(n);
    for(int i = 0; i < n; i++){
        cin >> lis[i];
        total += lis[i];
    }
    ll mid1 = 0;
    ll mid2 = 0;
    for(int i = 0; i < n; i++){
        mid1 += lis[i];
        if(mid1 >= (total / 2)){
            break;
        }
        mid2 += lis[i];
    }
    ll a1 = total - mid1;
    ll a2 = total - mid2;
    cout << min(abs(a1 - mid1), abs(a2 - mid2)) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <ctime>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 10;
const int inf=0x3f3f3f3f;
#define pi acos(-1.0)

double a,b,h,m;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    double x=(60*h+m)*360/720;
    double y=m*360/60;
    double f;
    if( y>x ){
        if( y-x>(360-(y-x))) f=360-(y-x);
        else f=y-x;
    }
    else{
        if( x-y>(360-(x-y))) f=360-(x-y);
        else f=x-y;
    }

    if( f==90 ){
        double ans=sqrt(a*a+b*b);
        printf("%.10f\n",ans);
        return 0;
    }
    f=pi*f/180;
    double ans=sqrt(a*a+b*b-2*a*b*cos(f));
    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

ll dp[3000][3000][4];
ll val[3000][3000];

int main(){
    int r,c,n; cin >> r >> c >> n;
    rep(_, n){
        int i,j,v; cin >> i >> j >> v;
        val[i-1][j-1] = v;
    }

    rep(i,r){
        rep(j,c){
            rep(k,4){
                dp[i][j][k] = -1;
            }
        }
    }

    dp[0][0][0] = 0;
    if(val[0][0] > 0) dp[0][0][1] = val[0][0];

    rep(i,r){
        rep(j,c){
            rep(k,4){
                if(i < r-1){
                    chmax(dp[i+1][j][0], dp[i][j][k]);

                    chmax(dp[i+1][j][1], dp[i][j][k] + val[i+1][j]);
                }

                if(j < c-1){
                    chmax(dp[i][j+1][k], dp[i][j][k]);

                    if(k < 3) chmax(dp[i][j+1][k+1], dp[i][j][k] + val[i][j+1]);
                }
            }
        }
    }

    ll ans = -1;
    rep(k,4) chmax(ans, dp[r-1][c-1][k]);
    cout << ans << endl;
}


Measured memory_bytes: 354888
#include<bits/stdc++.h>
#define N 100001
using namespace std;

struct job
{
  char name[15];
  int time;
};

job J[N+1]={};
int head;
int tail;

int isEmpty();
int isFull(int);
void enqueue(job, const int);
job dequeue(const int);

int main()
{
  int n;
  int q;

  scanf("%d%d",&n,&q);
  
  for(int i=0;i < n;i++){
    scanf("%s%d",J[i].name, &J[i].time);
  }
  head = 0;
  tail = n;

  job process;
  int jobtime = 0;
  int t;
  
  while( !isEmpty() ){
    process = dequeue(n);
    t = min(process.time, q);
    process.time -= t;
    jobtime += t;
    
    if(process.time > 0){
      enqueue(process, n);
    }
    else{
      printf("%s %d\n", process.name, jobtime);
    }
  }
  return 0;
}

void enqueue(job j, const int n)
{
  /*if( isFull(n) == 1 ){
    printf("Error.\n");
    return;
    }*/
  J[tail] = j;
  tail = (++tail)%N;
}

job dequeue(const int n)
{
  job j = J[head];
  head = (++head)%N;
  return j;
}

int isFull(int n)
{
  return head == (tail+1)%N;
}

int isEmpty(){
  return head == tail;
}




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

using namespace std;

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

int N;
int X[510];
int R[510*510];
bool is_left_end[510];

bool solve(){
    memset(R,-1,sizeof(R));
    priority_queue<tpl, vector<tpl>, greater<tpl> > left_queue;
    for(int i = 0; i < N; i++){
        if(i != 0){
            left_queue.push(tpl(X[i] - i, i, i));
        }
        else{
            is_left_end[i] = true;
        }
        R[X[i]] = i;
    }
    queue<pii> right_queue;
    for(int i = 0; i < N * N; i++){
        // すでに決定済み
        if(R[i] != -1){
            const int idx = R[i];
            // この要素がまだleft_queueに残っている場合, NG
            if(!is_left_end[idx]) return false;
            // そうでない場合, right queueにいれておく
            if(N - idx - 1 > 0) right_queue.push(pii(N - idx - 1, idx));
        }
        else if(left_queue.size() == 0){
            // right queueで埋める
            if(right_queue.size() == 0) return false;
            const pii p = right_queue.front(); right_queue.pop();
            R[i] = p.second;
            if(p.first != 1) right_queue.push(pii(p.first-1,p.second));
        }
        else{
            // left_queueの要素を使って埋める
            const auto t = left_queue.top(); left_queue.pop();
            const int ccost = get<0>(t);
            const int cnt = get<1>(t);
            const int idx = get<2>(t);
            R[i] = idx;
            if(cnt - 1 > 0) left_queue.push(make_tuple(ccost+1, cnt-1, idx));
            else is_left_end[idx] = true;
        }
    }
    return true;
}

int main(){

    cin >> N;
    for(int i = 0; i < N; i++) cin >> X[i], X[i]--;
    if(!solve()){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        for(int i = 0; i < N * N; i++){
            cout << R[i] + 1;
            if(i == N*N-1) cout << endl;
            else cout << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <algorithm>
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n, m, k, ans;
pair<ll,ll> a[100005];
int main() {
	int i;
	cin>>n>>m;
	for(i=0; i<n; i++) scanf("%lld%lld", &a[i].F, &a[i].S);
	sort(a, a+n);
	for(i=0; m; i++) {
		k = min(m, a[i].S);
		ans +=  k * a[i].F;
		m -= k;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i=N-1; i >= 0; --i)
            ifact[i] = (ifact[i+1]*(i+1))%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    constexpr T comb(T n, T r) {
        return (((fact[n]*ifact[r])%M)*ifact[n-r])%M;
    }
};
 
ModFact<100000, ll, MOD> fact;

ll N, ans = 1;
ll cnt = 1;
char S[200000];

int main() {
    scanf("%lld\n", &N);
    fread_unlocked(S, 1, (N<<1), stdin);
    if(S[0] == 'B' && S[(N<<1)-1] == 'B') {
        size_t i;
        bool f = false;
        for(i = 1; i < (N<<1); i++) {
            if(S[i] == S[i-1]) f ^= true;
            if(f) {
                ans *= (cnt << 1) - i;
                if(ans > 1LL<<45) ans %= MOD;
            }
            else if(++cnt > N) break;
        }
        if(cnt != N) ans = 0;
        else ans = ((ans % MOD) * fact.fact[N]) % MOD;
    } else ans = 0;
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f1 f2 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1]))
  member this.Scan3 f1 f2 f3 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1], f3 a.[2]))
  member this.Scan4 f1 f2 f3 f4 = stream.ReadLine().Split() |> (fun a -> (f1 a.[0], f2 a.[1], f3 a.[2], f4 a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [ for i in 1..n -> stream.ReadLine().ToCharArray() ]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let N,M = util.Scan2 int int
let xs = util.ScanMatrix M int
let ps = util.ScanVecH int

// i番目の電球は状態nでついているか
let isON n i =
  let arr = Array.skip 1 xs.[i] // 最初のデータは要素数なので無視
  let count = arr |> Array.sumBy (fun j -> (n >>> (j-1)) &&& 1)
  (count + ps.[i]) % 2 = 0

[0..(pown 2 N)-1]
|> List.filter (fun n -> [0..M-1] |> List.forall (isON n))
|> List.length
|> printfn "%d"


Measured memory_bytes: 14172
//ABC101C
int main(void) {
  int n, k, i, one, a, tmp, le=0, ri=0;
  scanf(" %d %d", &n, &k);
  for(i=0; i<n; i++)
    scanf(" %d", &a);
  printf("%d", (n+k-2-1)/(k-1));
}

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

int main() {
  int nums;
  cin >> nums;
  vector<int> buttons(nums);
  
  for(int i=0; i < nums; i++) {
 	cin >> buttons.at(i);   
  }
  
  bool flag = false;
  int count = 0;
  int current = 0;
  for(int i=0; i < nums; i++) {
    count++;
    int tmp = buttons.at(current) -1;
    if(tmp == 1) {
     flag = true;
      break;
    }
    current = tmp ;
  }
  if(flag) {
    cout << count << endl;
  } else {
    cout << -1 << endl;
  }
  
}
    


Measured memory_bytes: 640
#include <stdio.h>
 
int main() {
 
char ch[2000] = {0};
char W[15] = {0};
int i,j,k,l,m,n,o,p; 
 
m=0;
while(1) {
 
scanf("%c" , &W[m]);
if(W[m] == '\n') {
break;
}
m = m+1;
}
 
n=0; 
while(1) {
 
scanf("%c",&ch[n]);

if(ch[n] =='T' && ch[n-1] == 'X' && ch[n-2] == 'E' && ch[n-3] == 'T' && ch[n-4] == '_' && ch [n-5] == 'F' && ch[n-6] == 'O' && ch[n-7] == '_' && ch[n-8] == 'D' && ch[n-9] == 'N' && ch[n-10] == 'E') {
break;
}
n +=1;
}
p=0;
for(i=0; i<n; i++){
if(W[0] == ch[i] || W[0] == ch[i]+32 || W[0] == ch[i]-32) {
if(ch[i+m] == ' ' || ch[i+m] == '\n' || W[0] == ch[0]  ) { 
if(ch[i-1] == ' ' || ch[i-1] == '\n' ||  W[0] == ch[0]+32 || W[0] == ch[0]-32){
o=o+1;

for(j=0;j<m; j++) {
if(W[j] == ch[i+j] || W[j] == ch[i+j]+32 || W[j] == ch[i+j]-32){
o=o+1;
}
}
}
}
 
if(o==m+1){
p=p+1;
}
o=0;
}
}
printf("%d\n",p);
return 0;
}


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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

int main() {
	ll a,b,c;
	cin >> a >> b >> c;
	if (a%2==0 || b%2==0 || c%2==0) {
		cout << 0 << endl;
		return 0;
	}
	ll cs[]{a,b,c};
	sort(cs,cs+3);
	cout << cs[0]*cs[1] <<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
sp=[None for i in range(m)]
for i in range(m):
  l,r=map(int,input().split())
  sp[i]=[l,r]
sp.sort(key=lambda x:x[1])
sp.sort(key=lambda x:x[0])
s=[sp[0]]
for i in sp:
  if i[0]!=s[-1][0]:
    s.append(i)
ans=1
c=s[0]
if len(s)==1:print(1)
else:
  for i in range(1,len(s)):
    if c[1]<=s[i][0]:
      ans+=1
      c=s[i]
    if c[1]>s[i][1]:
      c=s[i]
    else:
      c[0]=s[i][0]
  print(ans)


Measured memory_bytes: 21280
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
void solve() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return;
		int a = 0, b = 0;
		int ans = 1;
		REP(i, n) {
			string s;
			cin >> s;
			if (s == "lu") {
				a++;
			}
			else if (s == "ru") {
				b++;
			}
			else if (s == "ld") {
				a--;
			}
			else {
				b--;
			}
			if (a == ans % 2 && b == ans % 2) {
				ans++;
			}
		}
		cout << ans - 1 << endl;
	}
}
#undef int

int main() {
	init();
	solve();
}


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

int main(){
    int N,D;
    cin >> N >> D;
    if(N%(2*D+1) == 0){
        cout << N/(2*D+1) << endl;
    }else{
        cout << N/(2*D+1) + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  string s,t="CODEFESTIVAL2016";
  cin >> s;
  int a=0;
  rep(i,s.size()){
    if (s[i]!=t[i]) a++;
  }
  cout << a << endl;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



string s,t;
void solve(){
	cin >> s >> t;
	int n = s.size(), m = t.size();
	
	for(int i = n-m; i >= 0; i--){
		bool ok = 1;
		for(int j = 0; j < m; j++){
			if(s[i+j] == '?') continue;
			if(s[i+j] == t[j]) continue;
			ok = 0;
			break;
		}
		if(!ok) continue;
		for(int j = 0; j < m; j++){
			if(s[i+j] == '?') s[i+j] = t[j];
		}
		for(int j = 0; j < n; j++){
			if(s[j] == '?') s[j] = 'a';
		}
		cout << s << endl;
		return;
	}
	cout << "UNRESTORABLE" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
    char arr[3];
    int i,a1=0,b1=0,c1=0;
    scanf("%s",arr);
    for(i=0;i<3;i++){
        if(arr[i]=='a'){
            a1++;
        }
        if(arr[i]=='b'){
            b1++;
        }
        if(arr[i]=='c'){
            c1++;
        }
    }
    if(a1==1&&b1==1&&c1==1){
        printf("Yes\n");
    }
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;
struct node
{
    int l,r,s,d;
} t[2000005];

void pushup(int x) {
    t[x].s=t[x<<1].s+t[(x<<1)+1].s;
    return;
}

void pushdown(int x) {
    int mid=(t[x].l+t[x].r)>>1;
    int d=t[x].d;
    t[x<<1].d+=d;t[(x<<1)+1].d+=d;
    t[x<<1].s+=(mid-t[x].l+1)*d;
    t[(x<<1)+1].s+=(t[x].r-mid)*d;
    return;
}

void build(int i,int l,int r) {
    t[i].l=l;
    t[i].r=r;
    t[i].d=0;
    if (l==r)
    {
        t[i].s=0;
        return ;
    }
    
    int mid=l+r>>1;
    
    build(i<<1,l,mid);
    build((i<<1)+1,mid+1,r);
    
    pushup(i);
    return;    
}

int getsum(int i,int l,int r) {
    int mid=t[i].l+t[i].r>>1;
    if (l<=t[i].l&&t[i].r<=r)
    {
        return t[i].s;
    }
    int d=t[i].d;
    if (!d) pushdown(i);
    int ret=0;
    if (mid>=l) ret+=getsum(i<<1,l,r);
    if (mid<r) ret+=getsum((i<<1)+1,l,r);
    
    return ret;
}

void update(int i,int l,int r,int del) {
    if (t[i].l==t[i].r) 
    {
        t[i].d+=del;
        t[i].s+=(t[i].l-t[i].r+1)*del;
        return ;
    }
    
    int mid=t[i].l+t[i].r>>1;
    if (!t[i].d) pushdown(i);
    if (mid>=l) update(i<<1,l,r,del);
    if (mid<r) update((i<<1)+1,l,r,del); 
    pushup(i);
}

int main() {
	int n, q;
	cin >> n >> q;
	vector<int> vc(n + 1, 0);
	for (int i = 0; i < n; i++) {
		scanf("%d", &vc[i + 1]);
	}
	vector<pair<pair<int, int>, int>> vp;
	vector<int> res(q + 1, 0);
	for (int i = 0; i < q; i++) {
		int l, r;
		scanf("%d%d", &l, &r);
		vp.push_back(make_pair(make_pair(r, l), i + 1));
	}
	sort(vp.begin(), vp.end());
	build(1, 1, n);
	vector<int> last(n + 1, -1);
	int id = 1;
	for (int i = 0; i < q; i++) {
		int l = vp[i].first.second, r = vp[i].first.first;
		int index = vp[i].second;
		while (id <= r) {
			int c = vc[id];
			if (last[c] == -1) {
				last[c] = id;
				// update_tree(um, id, 1, 1, n);
				update(1, id, id, 1);
			} else {
				// update_tree(um, last[c], -1, 1, n);
				// update_tree(um, id, 1, 1, n);
				update(1, last[c], last[c], -1);
				update(1, id, id, 1);
				last[c] = id;
			}
			id++;
		}
		// res[index] = query_tree(um, l, r, 1, n);
		res[index] = getsum(1, l, r);
	}
	for (int i = 1; i <= q; i++) {
		printf("%d\n", res[i]);
	}
}


Measured memory_bytes: 31812
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)

int main(void){
    int n,m;
    cin >> n >> m;
    int ans = 0;
    ans = n*m-n-m+1;
    cout << ans << endl;
}

Measured memory_bytes: 256
N,X=map(int,input().split())
x=list(map(int,input().split()))

for i in range(1,N):
    x[i]+=x[i-1]
x=[0]+x

ans=float("inf")
for i in range(1,N+1):
    test=0
    val=5
    r=N-1
    l=N-i
    while l>-1 and r>=l:
        #test+=val*sum(x[j] for j in range(l,r+1))
        test+=val*(x[r+1]-x[l])
        if r!=N-1:
            val+=2
        r-=i
        l=max(0,l-i)
    #print(i,test+i*X)
    ans=min(ans,test+i*X)

print(ans+N*X)


Measured memory_bytes: 103708
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int a,b,c,d=0;
    cin>>a>>b>>c;
    vector<int>x;
    for(int i=1; i <=c;i++)
    {
            if(c%i==0){ x.emplace_back(i);}}
    
    for(int i=0; i <x.size();i++) if(x[i]>=a&&x[i]<=b){ d++; }
    cout << d<<endl;
}


Measured memory_bytes: 3152
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
int n,m;
bool a[20];
int k[10]={0,2,5,5,4,5,6,3,7,6};
int dp[120000];
int f[120000];
int pre[120000];

int x;
int main()
{
    cin>>n>>m;
    for (int i=0; i<m; ++i)
    {
        cin>>x;
        a[x]=1;
    }
    for (int i=1; i<=9; ++i)
        if (a[i])
            for (int j=0; j<=n; ++j)
                if (j==0 || dp[j])
                    if (dp[j]+1>=dp[j+k[i]])
                    {
                        dp[j+k[i]]=dp[j]+1;
                        f[j+k[i]]=i;
                        pre[j+k[i]]=j;
                    }
    for (int now=n; now;now=pre[now])
        printf("%d",f[now]);
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    vector<ll> v(3);
    REP(i,3)cin>>v[i];
    sort(ALL(v));
    cout<<v[0]+v[1]<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) scanf("%d",&argument)
#define prin(argument) printf("%d\n",argument)
#define eps 1e-15
typedef long long ll;
int main(){
	int n,m,d;
	long double heikin;
	scanf("%d %d %d",&n,&m,&d);
	if(d!=0) heikin=(long double)2.0*(n-d)*(m-1)/pow(n,2.0);
	else heikin=(long double)(n-d)*(m-1)/pow(n,2.0);
	printf("%.10Lf\n",heikin);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    
    for(int i = 0; i < s.size(); i++) {
        cout << "x";
    }
    
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
void solve() {
	int y, m, d;
	cin >> y >> m >> d;
	int count = 0;
	while (y != 1000 || m != 1 || d != 1) {
		d++;
		count++;
		if (y  % 3 == 0 || (m % 2 == 1)) {
			if (d == 21) {
				m++;
				d = 1;
			}
		}
		else {
			if (d == 20) {
				m++;
				d = 1;
			}
		}
		if (m == 11) {
			y++;
			m = 1;
		}
	}
	cout << count << endl;
}
int main () {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
  
//0003
int main(){
    int n;
    int a, b, c, a2, b2, c2;
    cin >> n;
    while(n--){
        cin >> a >> b >> c;
        a2 = a*a;
        b2 = b*b;
        c2 = c*c;
 
        if(a2==b2+c2 || b2==a2+c2 || c2==a2+b2){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
def sumOfEach(x):
    array = list(str(x))
    ret = 0
    for z in array:
        ret += int(z)
    return ret

n = int(input())
minOfsum = 10 ** 5
for a in range(1, int(n / 2) + 1):
    b = n - a
    #print(a, b)
    sumOfEachA = sumOfEach(a)
    sumOfEachB = sumOfEach(b)
    sumOfTwo = sumOfEachA + sumOfEachB
    #sumOfTwo = sumOfEach(a) + sumOfEach(b)
    if sumOfTwo < minOfsum:
        minOfsum = sumOfTwo
print(minOfsum)




Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }

    public static void WarshallFloyd(int[,] d, int v)
    {
	for (int k = 0; k < v; k++)
	    for (int i = 0; i < v; i++)
		for (int j = 0; j < v; j++)
		    d[i, j] = Math.Min(d[i, j], d[i, k] + d[k, j]);
    }
}

class Program
{
    public static void Main()
    {
	int M = 1000000;
	var tmp = ReadIntArray();
	int n = tmp[0], m = tmp[1];
	int[,] d = new int[n,n];

	for (int i = 0; i < n; i++)
	{
	    for (int j = 0; j < n; j++)
	    {
		if (i==j) d[i,j] = 0;
		else      d[i,j] = M;
	    }
	}

	List<Tuple<int,int,int>> e = new List<Tuple<int,int,int>>();
	for (int i = 0; i < m; i++)
	{
	    tmp = ReadIntArray();
	    int a = tmp[0], b = tmp[1], c = tmp[2];
	    e.Add(Tuple.Create(a-1, b-1, c));
	    d[a-1, b-1] = c;
	    d[b-1, a-1] = c;
	}

	WarshallFloyd(d, n);
	
	int ans = m;
	
	foreach (Tuple<int,int,int> t in e)
	{
	    int a = t.Item1, b = t.Item2, c = t.Item3;
	    for (int j = 0; j < n; j++)
	    {
		if (d[j,a] + c == d[j,b])
		{
		    ans--;
		    break;
		}
	    }
	}
	
	WriteLine(ans);
    }
}


Measured memory_bytes: 13360
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

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

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


int main(){
    string a, b, c;
    cin >> a >> b >> c;

    int ia = 0;
    int ib = 0;
    int ic = 0;

    char turn = a[ia];
    ia++;

    while (true) {
        if (turn == 'a') {
            if (a.size() == ia) {
                cout << "A" << endl;
                return 0;
            }
            turn = a[ia];
            ia++;
        } else if (turn == 'b') {
            if (b.size() == ib) {
                cout << "B" << endl;
                return 0;
            }
            turn = b[ib];
            ib++;
        } else if (turn == 'c'){
            if (c.size() == ic) {
                cout << "C" << endl;
                return 0;
            }
            turn = c[ic];
            ic++;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a[4],i,j,temp;
  for(i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<3;i++){
    for(j=2;j>i;j--){
      if(a[j]<a[j-1]){
	temp=a[j];
	a[j]=a[j-1];
	a[j-1]=temp;
      }
    }
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 305;
int N, M, L;
int C[MAX_N][MAX_N];
int Q;

int ANS[MAX_N][MAX_N];

signed main()
{
  cin >> N >> M >> L;

  REP(i,MAX_N) {
    REP(j,MAX_N) {
      C[i][j] = INF_LL;
    }
    C[i][i] = 0;
  }

  REP(m,M) {
    int a, b, c; cin >> a >> b >> c; a--; b--;
    C[a][b] = C[b][a] = c;
  }

 REP(k,N) {
    REP(i,N) {
      REP(j,N) {
        C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
      }
    }
  } 

  REP(n,N) {
    REP(nn,N) {
      ANS[n][nn] = INF_LL;
    }
    ANS[n][n] = 0;
  }

  REP(n,N) {
    queue<int> que;
    que.push(n);
    ANS[n][n] = -1;
    while(que.size()) {
      int pos = que.front(); que.pop();
      REP(next, N) {
        if(C[pos][next] <= L) {
          if(ANS[n][next] == INF_LL) {
            ANS[n][next] = ANS[n][pos] + 1;
            que.push(next);
          }
        }
      }
    }
    ANS[n][n] = 0;
  }

  cin >> Q;
  REP(q,Q) {
    int a, b;
    cin >> a >> b; a--; b--;
    if(ANS[a][b] == INF_LL) {
      cout << -1 << endl;
    } else {
      if(C[a][b] <= L) {
        cout << 0 << endl;
      } else {
        cout << ANS[a][b] << endl;
      }
    }
  }

  return 0;
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll n,a,b; cin>>n>>a>>b;
    vector<ll> x(3,0);
    rep(i,n){
        ll p; cin>>p;
        if(p<=a) x[0]++;
        else if(p<=b) x[1]++;
        else x[2]++;
    }
    cout << min({x[0],x[1],x[2]}) << endl;
    return 0;
}

Measured memory_bytes: 3632
n,m = map(int,input().split())
x = [0]*m
y = [0]*m
for i in range(m):
    x[i],y[i] = map(int,input().split())
l = [0]*n
for i in range(m):
    l[x[i]-1] += 1
    l[y[i]-1] += 1
for i in range(n):
    print(l[i])

Measured memory_bytes: 38384
fun main(args: Array<String>) {
  val input1 = readLine()!!.toInt()
  var result = 0L
  for (i in 1..input1) {
    when {
      i % 15 == 0 || i % 5 == 0 || i % 3 == 0 -> {
      }
      else -> {
        result += i.toLong()
      }
    }
  }
  println(result)
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll N;
    cin >> N;
    vll a(N);
    rep(i, N) cin >> a[i];

    ll total = 0;
    rep(i, N){
        if(i%2==0 && a[i]%2==1) ++total;
    }
    cout << total << endl;
}


Measured memory_bytes: 3636
use std::cmp::Reverse;
use std::cmp::max;
use std::collections::VecDeque;
use std::cmp::min;
use std::collections::BTreeSet;
use std::cmp::Ordering;
use std::fmt::Debug;

fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_lines<R, T: Fn(&str)->R> (count: usize, transformer: T) -> Vec<R> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(transformer(buffer.trim()));
        buffer.clear();
    }
    vec
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_tabulate<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.trim().parse().ok().expect("Can't Parse"));
        buffer.clear();
    }
    vec
}
macro_rules! freeze {
    ($($id:ident), *) => {
        $(let $id = $id;)*
    };
}
macro_rules! read {
    (mut $ident: ident: [$ty:ty]) => {
        let mut $ident = read_values::<$ty>();
    };
    ($ident: ident: [$ty:ty]) => {
        let $ident = read_values::<$ty>();
    };
    ($($token: tt)*) => {
        let mut iter = read_values::<String>().into_iter();
        read_from_iter!(iter; $($token)*);
    };
}
macro_rules! read_from_iter {
    ($iter:expr; mut $ident:ident:$ty:ty, $($rest:tt)*) => {
        let mut $ident = $iter.next().unwrap().parse::<$ty>().expect("Can't Parse");
        read_from_iter!($iter; $($rest)*);
    };
    ($iter:expr; $ident:ident:$ty:ty, $($rest:tt)*) => {
        let $ident = $iter.next().unwrap().parse::<$ty>().expect("Can't Parse");
        read_from_iter!($iter; $($rest)*);
    };
    ($iter:expr; mut $ident:ident:$ty:ty) => {
        let mut $ident = $iter.next().unwrap().parse::<$ty>().expect("Can't Parse");
    };
    ($iter:expr; $ident:ident:$ty:ty) => {
        let $ident = $iter.next().unwrap().parse::<$ty>().expect("Can't Parse");
    };
    ($iter: expr; ) => {};
}
struct KeyValue<K, V> {
    key: K,
    value: V
}
impl <K: PartialOrd, V> PartialEq for KeyValue<K, V> {
    fn eq(&self, other: &Self) -> bool {
        self.key.eq(&other.key)
    }
}
impl <K: PartialOrd, V> Eq for KeyValue<K, V> {}
impl <K: PartialOrd, V> PartialOrd for KeyValue<K, V> {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        self.key.partial_cmp(&other.key)
    }
}
impl <K: PartialOrd, V> Ord for KeyValue<K, V> {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.key.partial_cmp(&other.key).ok_or("Can't Compare").unwrap()
    }
}

const MOD: i64 = 1000000007;

fn main() {
    read!(n: i64, m: i64);
    let from_scc = min(n, m >> 1);
    let from_cccc = (m - (from_scc << 1)) >> 2;
    println!("{}", from_scc + from_cccc);
}


Measured memory_bytes: 2048