akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

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

    for (int i = 0; i < n; i++) {
      data[i] = sc.nextInt();
    }

    Arrays.sort(data);
    int sum = data[n-1] / 2;

    for (int i = 0; i < n-1; i++) {
      sum += data[i];
    }

    System.out.println(sum);

  }

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N,K,Q; cin >> N >> K >> Q;
	V<int> a(N);
	rep(_,Q){
		int x; cin >> x; x--;
		a[x]++;
	}
	rep(i,N){
		cout << (K > Q-a[i] ? "Yes" : "No") << endl;
	}
}


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

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

double dist(vector<int> x, vector<int> y, int i, int j)
{
	return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
}

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i <= n - 3; i++)
	{
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int main()
{
	int N = 0, ans = 0;
	scanf("%d", &N);

	ans = N%10;
	switch (ans) {
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		printf("hon\n");
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		printf("pon\n");
		break;
	case 3:
		printf("bon\n");
		break;
	};
	//yesno(ans);
	//okng(ans);
	//printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1644
import sys
from collections import Counter
readline = sys.stdin.buffer.readline

n,m = map(int,readline().split())
s = readline().rstrip().decode('utf-8')

lst1 = [0]*len(s)
res = ""
for i in range(n):
    res = int(str(res)+s[i])
    res %= m
    lst1[i] = res

ans = 0

if m == 2 or m == 5:
    for i in range(n):
        if lst1[i] == 0:
            ans += i+1


else:
    s = s[::-1]
    dig = 1
    lst1 = [0]*n
    for i in range(n):
        if i == 0:
          lst1[i] = int(s[i])%m
          continue
          
        dig *= 10
        dig %= m
        lst1[i] = lst1[i-1] + dig*int(s[i])
        lst1[i] %= m
    c = Counter(lst1)
    #zero sum range
    for i in c.values():
        #余りがその値だった時の個数iについて、割った値が0になる状態数はi*(i-1)//2
        ans += i*(i-1)//2
    ans += c[0]#割った余りが0の時はもちろん条件を満たす
print(ans)

    

Measured memory_bytes: 47176
N,T=map(int, input().split())
ct=[list(map(int, input().split())) for _ in range(N)]
ct=list(sorted(ct,  key=lambda x: x[0]))

for i in range(len(ct)):
    if ct[i][1]>T:
        continue
    else:
        print(ct[i][0])
        exit(0)
print('TLE')


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

int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int cost, m = 2 * C * 100000;
  for(int i = 0; i <= 100000; i++){
    cost = 2 * C * i + max(0, X - i) * A + max(0, Y - i) * B;
    m = min(m, cost);
  }
  cout << m << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int X, A;
    cin >> X >> A;
    if (X < A) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from math import gcd


class Eratosthenes(): # エラトステネスの篩
    def __init__(self, N): # 素数リスト生成 O(n*log(log n))
        self.fact = [i for i in range(N + 1)]
        for i in range(2, int(N**0.5) + 1):
            if self.fact[i] < i:
                continue
            for j in range(i ** 2, N + 1, i):
                self.fact[j] = i


    def factor(self, NUM): # 高速素因数分解 O(log num)
        PRIME = set()
        while NUM > 1:
            PRIME.add(self.fact[NUM])
            NUM //= self.fact[NUM]
        return PRIME


n = int(input())
a = list(map(int, input().split()))

ans = 0
for ai in a:
    ans = gcd(ans, ai)
if ans != 1:
    print('not coprime')
    exit()

era = Eratosthenes(max(a))
num = set()
for ai in a:
    prime = era.factor(ai)
    if len(prime & num) > 0:
        print('setwise coprime')
        break
    num |= prime
else:
    print('pairwise coprime')


Measured memory_bytes: 217404
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, K = map(int, input().split())
A = list(map(int, input().split()))

K = min(100, K)

for i in range(K):
    B = [0] * (N + 1)
    for j in range(N):
        l, r = max(0, j - A[j]), min(N, j + A[j] + 1)
        B[l] += 1
        B[r] -= 1

    for j in range(1, N):
        B[j] += B[j - 1]
    A = B[:-1]

print(*A)

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

int n;

int main(){
  int m;
  cin >> n >> m;
  int graph[n+1][n+1];
  //memset(graph,0,sizeof(graph));
  for(int i=0;i<n+1;i++){
    for(int j=0;j<n+1;j++){
      graph[i][j] = 1000000;
    }
  }

  for(int i=0;i<m;i++){
    int a,b,c,d;
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    graph[a][b] = c;
    graph[b][a] = d;
  }

  for(int k=0;k<=n;k++){
    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){      
	graph[i][j] = min( graph[i][j], graph[i][k] + graph[k][j]);
      }
    }
  }

  int city1,city2,money,hasira;
  scanf("%d,%d,%d,%d",&city1,&city2,&money,&hasira);
  //city1--;city2--;
  //cout << "行きの代金 : " << graph[city1][city2] << endl;
  money -= graph[city1][city2];
  //cout << "帰りの代金 : " << graph[city2][city1] << endl;
  money -= graph[city2][city1];
  money -= hasira;

  cout << money << endl;
}

Measured memory_bytes: 1240
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))


ll getval(ll a[],ll N,ll val){
    ll num=0;
    for(int j=0;j<N;j++){
        num+=abs(a[j]-val-(j+1));
    }
    return num;
}


int main(){
    ll ans=1000000000,ans2=1000000000,N;
    cin >>N;
    ll A[N];
    ll hi=0,lo=-1000000000;
    for(int i=0;i<N;i++){
        cin >>A[i];
        //if(A[i]<lo)lo=A[i];
        if(A[i]>hi)hi=A[i];
    }
    dbg cout <<lo <<" "<<hi<<endl;
    
    while(hi-lo>1){
        ll mid=(lo+hi)/2;
        ll v1=getval(A,N,mid);
        ll v2=getval(A,N,mid+1);
        dbg cout <<mid<<":"<<v1<<" "<<v2<<endl;
        if(v1>v2)lo=mid;
        else hi=mid;
        ans=min(v1,v2);
    }


    cout <<ans<<endl;

    return 0;

}

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


int main() {
    int64_t n, m;
    cin >> n >> m;
    vector<vector<int64_t>> xyz(n, vector<int64_t>(3));
    for (auto& e : xyz) for (auto& f : e) cin >> f;

    int64_t ans = 0;
    for (int s = 0; s < 8; s++) {
        vector<pair<int64_t, int64_t>> sum(n);
        for (int i = 0; i < n; i++) {
            sum[i].second = i;
            for (int j = 0; j < 3; j++) sum[i].first += xyz[i][j] * ((s & (1 << j)) ? 1 : -1);
        }
        sort(begin(sum), end(sum), greater<>());

        vector<int64_t> can(3);
        for (int64_t i = 0; i < 3; i++) {
            for (int64_t j = 0; j < m; j++) can[i] += xyz[sum[j].second][i];
        }

        ans = max(ans, abs(can[0]) + abs(can[1]) + abs(can[2]));
    }

    cout << ans << endl;
}


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

int main(){
    int sum=0;
    int x,y;cin>>x>>y;
    for(int i=0;i<y;i++){
        int temp=0;cin>>temp;
        sum+=temp;
    }
    if(sum>=x)cout <<"Yes";
    else cout<<"No";
}


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

int main() {
    int N;  cin >> N;
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < N; ++i) cin >> B[i];
    for (int i = 0; i < N; ++i) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += (lower_bound(A.begin(), A.end(), B[i]) - A.begin()) * (C.end() - upper_bound(C.begin(), C.end(), B[i]));
    }

    cout << ans << endl;
}


Measured memory_bytes: 1408
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 100000;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int dp[50][3010];
signed main(void)
{
  while(true) {
    int n, m, s;
    cin >> n >> m >> s;
    if(!n) break;
    n *= n;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    // ??°??????????????§???????´????i
    FOR(i, 1, m+1) {
      // j???????????§??§????¨????k?????¨???????????????
      for(int j=n; j>=1; --j) FOR(k, i, s+1) {
        (dp[j][k] += dp[j-1][k-i]) %= MOD;
      }
    }
    cout << dp[n][s] << endl;
  }

  return 0;
}

Measured memory_bytes: 3664
n, m = map(int, input().split())
L = [[0, 0] for _ in range(m)]
g = [[] for _ in range(n)]
for j in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    L[j][0] = a
    L[j][1] = b

from collections import deque

ans = 0
for i in range(m):
    g = [[] for _ in range(n)]
    for j in range(m):
        if j == i:
            continue
        a = L[j][0]
        b = L[j][1]
        g[a].append(b)
        g[b].append(a)
    #print(g)
    s = deque()
    s.append(0)
    visit = [-1]*n
    visit[0] = 0
    while s:
        x = s.pop()
        for new_x in g[x]:
            if visit[new_x] == -1:
                visit[new_x] = visit[x] + 1
                s.append(new_x)
    if min(visit) == -1:
        ans += 1
print(ans)

Measured memory_bytes: 40304
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
	int x;
	scanf("%d", &x);
	while (1) {
		bool flag = 0;
		for (int i = 2; i < x; i++) {
			if (x % i == 0) {
				flag = 1;
				break;
			}
		}
			if (flag == 0) {
				printf("%d", x);
				return 0;
			}
			x++;
	}
}


Measured memory_bytes: 1732
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<list>
#include<string>
#include<algorithm>
#define ll long long

using namespace std;

struct edge {
  int to;
  ll cost;
};

vector<edge> tree[100010];
ll cost_k[100010];

void dfs(int v,int par,ll dist){
  cost_k[v] = dist;

  for(int i=0;i<(int)tree[v].size();i++){
    if(tree[v][i].to == par) continue;
    dfs(tree[v][i].to, v, dist + tree[v][i].cost);
  }
}

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

  for(int i=0;i<N-1;i++){
    int a,b,c;
    cin >> a >> b >> c;
    tree[a].push_back({b,c});
    tree[b].push_back({a,c});
  }

  int Q,K;
  cin >> Q >> K;

  dfs(K,-1,0);

  for(int i=0;i<Q;i++){
    int x,y;
    cin >> x >> y;
    cout << cost_k[x] + cost_k[y] << endl;
  }
}

Measured memory_bytes: 17408
# coding: utf-8
# Your code here!

r, c = map(int,input().split())
a = [[0]*(c+1) for i in range(r+1)]

for i in range(r):
    b = list(map(int,input().split()))
    for j in range(c):
        a[i][j] = b[j]
for i in range(r):
    for j in range(0,c):
        a[i][c] += a[i][j]
for i in range(0,c+1):
    for j in range(0,r):
        a[r][i] += a[j][i]
for i in range(0,r+1):
    print(a[i][0], end = "")
    for j in range(1,c+1):
        print("", a[i][j], end = "")
    print()


Measured memory_bytes: 6736
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int n=0,x=0;
	while (true) {
		scanf("%d %d", &n, &x);
		if (n == 0) {
			break;
		}
		int count = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) {
						count++;
					}
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 2672
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
int n, m;
vector<int> c;
vector<vector<int> > T;
int main() {
    cin >> n >> m;
    c.resize(m+1);
    for (int i = 0; i < m; ++i) {
        cin >> c[i];
    }
    T.resize(m);
    for (int j = 0; j < m; ++j) {
        T[j].resize(n+1);
    }

    for (int k = 0; k < m; ++k) {
        T[k][0] = 0;
    }
    for (int j = 0; j <= n; ++j) {
        for (int i = 0; i < m; ++i) {
            int pp;
            if (j==0) pp = 0;
            else if(j - c[i] < 0) pp = INT_MAX;
            else pp = T[i][j-c[i]]+1;
            int qq;
            if(i < 1) qq = INT_MAX;
            else qq = T[i-1][j];
            T[i][j] = min(qq, pp);
        }
    }
    cout << T[m-1][n] << endl;



    return 0;
}



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

int main(){
//
   int s;
   cin>>s;
   int tmp = s;
   int count=1;
   for(int i=0;i<1000010;++i){
     if(tmp==4)break;
     if(tmp==2)break;
     if(tmp==1)break;
     if(tmp%2==0){
       tmp = tmp/2;
     }
     else{
       tmp = 3*tmp+1;
     }
     count += 1;
     if(tmp==4){break;}
   }
cout<<count+3<<endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = sorted([list(map(int,input().split()))for n in range(N)])
ans = float("inf")

for i in range(N-K+1):
  for j in range(i+K-1,N):
    P = A[j][0]-A[i][0]
    C = sorted([a[1] for a in A[i:j+1]])
    for k in range(j-i-K+2):
      Q = C[k+K-1]-C[k]
      ans = min(ans,P*Q)

print(ans)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using i64 = int64_t;
using u64 = uint64_t;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

constexpr int64_t MOD = 1'000'000'007LL;

#define INT(NAME) int NAME; cin>>NAME;
#define INT64(NAME) int64_t NAME; cin>>NAME;
#define VECTOR(NAME, TYPE, SIZE) std::vector<TYPE> NAME((SIZE));\
    for(int xxxx_i=0; xxxx_i<SIZE; xxxx_i++) cin>>NAME[xxxx_i];
#define VECTOR_INT(NAME, SIZE) VECTOR(NAME, int, SIZE)
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)    
#define HAS_KEY(CONTAINER, KEY) ((CONTAINER).find((KEY)) != ((CONTAINER)).end())

void solve() {
    INT(N) 
    vector<int> deg(N);
    vector<vector<int>> graph(N);
    vector<pair<int,int>> edges;
    map<pair<int,int>,int> etoi;  // edge to index
    REP(i, N-1) {
        INT(a)
        INT(b)
        a-=1;
        b-=1;
        graph[a].push_back(b);
        graph[b].push_back(a);
        edges.emplace_back(a, b);
        etoi[make_pair(a, b)] = etoi[make_pair(b, a)] = i;
    }
    map<pair<int,int>, int> colors;   // color of edges
    vector<int> NG(N, -1);         // NG colors for nodes
    vector<int> visited(N, 0);
    queue<int> q;
    visited[0] = true;
    q.emplace(0);
    int K=0;

    // BFS
    while (!q.empty()) {
        int u = q.front(); q.pop();

        int color = 1;
        for (int v : graph[u]) {
            if (visited[v]) continue;
            if (NG[u] == color) ++color;
            K = max(K, color);
            NG[v] = colors[make_pair(u,v)] = colors[make_pair(v,u)] = color++;
            visited[v] = true;
            q.push(v);
        }
    }

    cout<<K<<endl;
    for (auto& e : edges) {
        cout<<colors[e]<<endl;
    }
}

int main() {
    solve();
    return 0;
}


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

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(N: int, A: "List[int]"):
    Aset = set(A)
    if len(Aset) < N:
        print(NO)
    else:
        print(YES)


# 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: 40384
fun c75(args: Array<String>) {
    val (n, m) = args[0].split(" ").map { it.toInt() }
    val edgeList = args.drop(1).map { edge -> edge.split(" ").map { it.toInt() } }
    val edgeMap = Array(n) { mutableListOf<Int>() }
    edgeList.forEach {
        edgeMap[it[0] - 1].add(it[1] - 1)
        edgeMap[it[1] - 1].add(it[0] - 1)
    }

    var ans = 0
    for (unusedEdge in edgeList) {
        val visited = Array(n) { false }
        fun dfs(curr: Int) {
            if (visited[curr]) {
                return
            }
            visited[curr] = true
            edgeMap[curr]
                    .filter { next -> !((curr == unusedEdge[0] - 1 && next == unusedEdge[1] - 1) || (curr == unusedEdge[1] - 1 && next == unusedEdge[0] - 1)) }
                    .forEach { next -> dfs(next) }
        }
        dfs(0)
        val split = visited.any { !it }
        if (split) {
            ans++
        }
    }

    println(ans)
}

fun main(args: Array<String>) {
    c75(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 38204
def main():
    n, m = map(int, input().split(" "))
    s = [0] * m
    c = [0] * m
    for i in range(m):
        s[i], c[i] = map(int, input().split(" "))
    ans = [-1] * n
    for i in range(m):
        if ans[s[i]-1] != -1 and ans[s[i]-1] != c[i]:
            print(-1)
            return
        ans[s[i]-1] = c[i]
    if ans[0] == 0:
        if n == 1:
            print(0)
            return
        print(-1)
        return
    for i in range(n):
        if ans[i] == -1:
            if i == 0:
                if n == 1:
                    print(0)
                    return
                print(1, end="")
            else:
                print(0, end = "")
        else:
            print(ans[i], end ="")
    print()
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9212
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	int n, l; cin >> n >> l;
	int a[210];
	int sum = 0;
	for (int i = 1; i <= n; ++i) {
		a[i] = l + i - 1;
		sum += a[i];
	}
	int dif = INF;
	int key;
	for (int i = 1; i <= n; ++i) {
		int d = abs(a[i]);
		if (d < dif) {
			dif = d;
			key = i;
		}
	}
	int ans = sum - a[key];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll a(n);
  ll ans=0;
  ans-=n;
  rep(i,n){
    cin>>a[i];
    ans+=a[i];
  }
  COUT(ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

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

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<ll>a(n+1);
    vector<ll>b(n+1);
    rep(i,n){
        if(s[i]=='<'){
            a[i+1] = a[i]+1;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='>'){
            b[i] = b[i+1]+1;
        }
    }
    vector<ll>res(n+1);
    ll sm = 0;
    rep(i,n+1){
        res[i] = max(a[i],b[i]);
        sm += res[i];
        // cerr << res[i] << " ";   
    }
    // cerr << endl;
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 12664
#include <bits/stdc++.h>
using namespace std;
#define int 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 itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    vector <int> p(n); 
    rep(i,n) cin>>p[i];
    vector <int> a(n);
    vector <int> b(n);
    a[0] = 20000;
    rep(i,n){
        if(i==0) continue;
        a[i] = a[i-1] + 20000;
    }
    b[n-1] = 20000;
    rrep(i,n){
        if(i==n-1) continue;
        b[i] = b[i+1] + 20000;
    }
    
    rep(i,n){
        a[p[i]-1] += i;
    }
    rep(i,n) cout<<a[i]<<' ';
    cout<<endl;
    rep(o,n) cout<<b[o]<<' ';
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n; cin >> n;
	ll a[n+1]; rep(i, 1, n){cin >> a[i];}
	
	if(n%2 == 0){
		ll dp[n+1][2];
		rep(i, 1, n){
			rep(j, 0, 1){
				dp[i][j] = -INF;
			}
		}
		dp[1][0] = a[1];
		dp[2][1] = a[2];
		
		rep(i, 1, n){
			if(i-2 > 0){
				dp[i][0] = max(dp[i][0], dp[i-2][0]+a[i]);
				dp[i][1] = max(dp[i][1], dp[i-2][1]+a[i]);
			}
			if(i-3 > 0){
				dp[i][1] = max(dp[i][1], dp[i-3][0]+a[i]);
			}
		}
		print(max(dp[n-1][0], dp[n][1]))
	}
	else{
		ll dp[n+1][3];
		rep(i, 1, n){
			rep(j, 0, 2){
				dp[i][j] = -INF;
			}
		}
		dp[1][0] = a[1];
		dp[2][1] = a[2];
		dp[3][2] = a[3];
		
		rep(i, 1, n){
			if(i-2 > 0){
				dp[i][0] = max(dp[i][0], dp[i-2][0]+a[i]);
				dp[i][1] = max(dp[i][1], dp[i-2][1]+a[i]);
				dp[i][2] = max(dp[i][2], dp[i-2][2]+a[i]);
			}
			if(i-3 > 0){
				dp[i][1] = max(dp[i][1], dp[i-3][0]+a[i]);
				dp[i][2] = max(dp[i][2], dp[i-3][1]+a[i]);
			}
			if(i-4 > 0){
				dp[i][2] = max(dp[i][2], dp[i-4][0]+a[i]);
			}
			//cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl;
		}
		print(max(dp[n-2][0], max(dp[n-1][1], dp[n][2])))
	}
	return 0;
}

Measured memory_bytes: 9900
import sys
sys.setrecursionlimit(10 ** 6)


N = int(input())
ans = set()
a = ord('a')


def f(c, A, done):
    global N, a
    B = list(A)
    done = set(done)
    for i in range(N):
        if i not in done:
            B[i] = c
            done.add(i)
            break
    if len(done) == N:
        ans.add(''.join(B))
    else:
        for i in range(2 ** (N - len(done)) - 1, -1, -1):
            k = i
            C = B[:]
            tDone = set(x for x in range(N))
            nDone = set(x for x in done)
            for t in done:
                tDone.remove(t)
            while k > 0:
                y = min(tDone)
                if k & 1 == 1:
                    C[y] = c
                    nDone.add(y)
                tDone.remove(y)
                k >>= 1
            f(chr(ord(c) + 1), tuple(C), tuple(nDone))


A = [0] * N
f('a', tuple(A), ())
ans = list(ans)
ans.sort()
print(*ans, sep='\n')


Measured memory_bytes: 15404
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<ll,P>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main(){
    vector<string> ls = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;
    for(int i=0;i<7;i++){
        if(ls[i] == s){
            cout << 7-i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
a=["" for i in range(N)]
data=[0]*N
for i in range(N):
    a[i]=input()
    data[i]=a[i].count("#")

if sum(data)==0:
    print(-1)
elif sum(data)==N**2:
    print(0)
else:
    data2=[0 for i in range(N)]
    for i in range(N):
        for j in range(N):
            data2[j]+=(a[i][j]=="#")
    count=0
    for i in range(N):
        if data2[i]!=N:
            count+=1
    ans=10**10
    for i in range(N):
        test=(N-data[i])+count+(data2[i]==0)
        ans=min(ans,test)

    print(ans)


Measured memory_bytes: 40048
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	vector<long long> a(n), b(n);
	rep(i,n){
		cin >> a[i];
	}
	rep(i,n){
		cin >> b[i];
	}

	long long plus = 0, minus = 0;
	rep(i,n){
		long long tmp = a[i] - b[i];
		if(tmp > 0LL) plus += tmp;
		else minus += tmp / 2;
	}
	cout << (plus <= -minus ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var k = sc.intarr;
        int n = k[0];
        var s = sc.chararr;
        bool han = false;
        
        foreach(var x in s)
        {
            if (x == 'Y')
            {
                han = true;
            }
        }

        if (han) wr.wri("Four");
        else wr.wri("Three");
    }

}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => strarr.Select(char.Parse).ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	ll a, b, x; cin >> a >> b >> x;
	if (a == 0)cout << b / x+1 << endl;
	else {
		a--; cout << b / x - a / x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  var input = scala.io.StdIn.readLine()
  val abcArray =  input.split(" ").map(_.toInt)
  val divide = abcArray(1) / abcArray(0)
  if (divide > abcArray(2)) {
    print(abcArray(2))
  } else {
    print(divide)
  }
}

Measured memory_bytes: 25388
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> points(N + 5, 0);
    for (int i = 0; i < Q; i++) {
        int temp;
        cin >> temp;
        points[temp]++;
    }
    for (int i = 1; i <= N; i++) {
        if (K - Q + points[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
let rec factorize acc i n =
  if n <= 1 then acc
  else if n < i * i then n :: acc
  else if n mod i = 0 then factorize (i :: acc) i (n / i)
  else factorize acc (i + 1) n
let factorize n =
  match factorize [] 2 n with
  | [] -> []
  | p :: ps ->
      let (acc, p, n) = List.fold_left (fun (acc, p, n) q ->
        if p = q
        then (acc, p, n + 1)
        else ((p, n) :: acc, q, 1)) ([], p, 1) ps in
      (p, n) :: acc

let rec power ( * ) e m = function
  | 0 -> e
  | n when n mod 2 = 0 ->
      power ( * ) e (m * m) (n / 2)
  | n ->
      power ( * ) (m * e) m (n - 1)
let power = power ( * ) 1

let () = Scanf.scanf "%d %d" @@ fun n p ->
  Printf.printf "%d\n" @@
  List.fold_left ( * ) 1 @@
  List.map (fun (p, m) -> power p (m / n)) @@
  factorize p



Measured memory_bytes: 384
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!
function main(input) {
    var x = input.split('\n');
    var a = parseInt(x[0]);
    var b = parseInt(x[1]);
    var sum = a * a;
    var num = sum - b;
    console.log(num);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> n;
  rep(i,0,n){
    cin >> s;
    d[s[0]-'A']++;
  }
  l = 0;
  rep(i,0,30){
    if(d[i] != 0)l++;
  }
  if(l == 3)puts("Three");
  else puts("Four");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
using ll=long long int;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

int main() {
	
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++)cin >> d[i];

	sort(d.begin(), d.end());

	int k = d[n / 2] - d[n / 2 - 1] ;

	cout << k << endl;

	return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    while (true) {
        val inStr = readLine()
        val (h, w) = inStr?.split(' ')?.map { s -> s.toInt() } ?: return

        if ((h == 0) && (w == 0)) {
            return
        }
        printFrame(h, w)
        println()
    }
}

fun printFrame(height:Int, width:Int) {
    val verticalEdge = "#".repeat(width)
    var bodyLine = "#" + ".".repeat(width - 2) + "#"

    println(verticalEdge)
    (1..(height - 2)).map { _ -> println(bodyLine) }
    println(verticalEdge)
}



Measured memory_bytes: 32912
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
vector<char> ans(0, 0);

void apply(ll *a, ll *b, char c){
  (*a)++;
  (*b)--;
  ans.push_back(c);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N; cin>>N;
  map<char, ll> M; cin >> M['A'] >> M['B'] >> M['C'];
  vector<string> S(N, "");
  rep(i, N) cin >> S[i];
  rep(i, N){
    char c1, c2, n1, n2;
    c1 = S[i][0];
    c2 = S[i][1];
    if (i < N-1){
      n1 = S[i+1][0];
      n2 = S[i+1][1];
    }
    if (M[c1] == 0 && M[c2] == 0){
      cout << "No" << endl;
      return 0;
    }
    if (M[c1] > M[c2])
      apply(&M[c2], &M[c1], c2);
    else if (M[c1] < M[c2])
      apply(&M[c1], &M[c2], c1);
    else if (M[c1] == M[c2] && i < N-1){
      if (c1 == n1 || c1 == n2)
        apply(&M[c1], &M[c2], c1);
      else
        apply(&M[c2], &M[c1], c2);
    }
    else
      apply(&M[c1], &M[c2], c1);      
  }
  cout << "Yes" << endl;
  rep(i, N) cout<< ans[i] << endl;
}


Measured memory_bytes: 6628
use std::io::*;
const INF: u64 = 1u64 << 60;

fn rec(l: usize, r: usize, sum: &Vec<u64>, memo: &mut Vec<Vec<u64>>) -> u64 {
    if memo[l][r] != INF {
        return memo[l][r];
    }
    if l == r {
        return 0;
    }
    let mut res = INF;
    for i in l..r {
        res = std::cmp::min(res, rec(l, i, &sum, memo) + rec(i + 1, r, &sum, memo));
    }
    res += sum[r + 1] - sum[l];
    memo[l][r] = res;
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<u64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let mut sum: Vec<u64> = vec![0; n + 1];
    let mut memo: Vec<Vec<u64>> = vec![vec![INF; n + 1]; n + 1];
    for i in 0..n {
        sum[i + 1] = sum[i] + a[i];
    }
    println!("{}", rec(0, n - 1, &sum, &mut memo))
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    int abc, a, b, c;
    Scanner sc = new Scanner(System.in);
    abc = sc.nextInt();
    a = abc / 100;
    b = (abc - (a*100)) / 10;
    c = abc - ((a * 100) + (b * 10));
    System.out.println(a + b + c);
    
  }
}

Measured memory_bytes: 22996
#include <iostream>

using namespace std;

int main()
{
	int A, B, C, X;
	cin >> A >> B >> C >> X;

	int count = 0;
	for (int a = 0; a <= A; a++) {
		for (int b = 0; b <= B; b++) {
			for (int c = 0; c <= C; c++) {
				if (a*500 + b*100 + c*50 == X) {
					count++;
				}
			}
		}
	}

	cout << count << endl;



}




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


int n, m;
ll ans = 0;
Graph G;


void dfs(vector<bool> &visited, int &ans, int s){
  bool fin = true;
  rep(i,visited.size()){
    if(!visited[i] && i != s) fin = false;
  }
  if(fin){
    ans++;
    return;
  }
  visited[s] = true;
  for(auto g : G[s]){
    if(visited[g]) continue;
    dfs(visited,ans, g);
  }
  visited[s] = false;
}

int main() {
  cin >> n >> m;
  G.assign(n, vector<int>());
  vector<bool> visited(n, false);
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = 0;
  dfs(visited, ans, 0);
  cout << ans << endl;
}

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

int main() {
    int k, x;
    int ans;
    cin >> k >> x;
    for(int i=-k+1; i<= k-1; i++){
        cout << x + i;
        if (i!=k) cout << " ";
    }

    cout << endl;
}

Measured memory_bytes: 256
// Creat time: 2019-08-21  15:59:09
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cstdio>
#define N 300005
#define rint register int
#define PII pair<int, int>
using namespace std;
typedef long long ll;

int w, h, n;
PII p[N];

ll mx[N << 2], tag[N << 2];

inline void add(int pos, int val) { mx[pos] += val, tag[pos] += val;}

inline void pushdown(int pos) {
    if (!tag[pos]) return ;
    add(pos << 1, tag[pos]);
    add(pos << 1 | 1, tag[pos]);
    tag[pos] = 0;
}

void Modify(int l, int r, int L, int R, int val, int pos) {
    if (L <= l && r <= R) { add(pos, val); return ;}
    int mid = (l + r) >> 1; pushdown(pos);
    if (L <= mid) Modify(l, mid, L, R, val, pos << 1);
    if (mid < R) Modify(mid + 1, r, L, R, val, pos << 1 | 1);
    mx[pos] = max(mx[pos << 1], mx[pos << 1 | 1]);
}

PII sta[N], stb[N];

inline ll solve() {
    ll res = 0;
    memset(mx, 0, sizeof mx);
    memset(tag, 0, sizeof tag);
    sort(p + 1, p + n + 1);
    int tpa = 0, tpb = 0;
    for (rint i = 1; i < n; ++i) {
        if (p[i].second <= h / 2) {
            int nxt = i - 1;
            while (tpa && sta[tpa].second < p[i].second) {
                Modify(1, n, sta[tpa].first, nxt, sta[tpa].second - p[i].second, 1);
                nxt = sta[tpa].first - 1; --tpa;
            }
            if (nxt != i - 1) sta[++tpa] = make_pair(nxt + 1, p[i].second);
        } else {
            int nxt = i - 1;
            while (tpb && stb[tpb].second > p[i].second) {
                Modify(1, n, stb[tpb].first, nxt, p[i].second - stb[tpb].second, 1);
                nxt = stb[tpb].first - 1; --tpb;
            }
            if (nxt != i - 1) stb[++tpb] = make_pair(nxt + 1, p[i].second);
        }
        sta[++tpa] = make_pair(i, 0);
        stb[++tpb] = make_pair(i, h);
        Modify(1, n, i, i, h - p[i].first, 1);
        res = max(res, mx[1] + p[i + 1].first);
    }
    return res;
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> w >> h >> n;
    for (int i = 1, x, y; i <= n; ++i)
        scanf("%d%d", &x, &y),
        p[i] = make_pair(x, y);
    p[++n] = make_pair(0, 0), p[++n] = make_pair(w, h);
    ll ans = solve();
    for (rint i = 1; i <= n; ++i)
        swap(p[i].first, p[i].second);
    swap(w, h);
    ans = max(ans, solve());
    cout << (ans << 1);
    return 0;
}


Measured memory_bytes: 24960
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb(x) push_back(x)

typedef pair<ll,ll> pp;
int lcm(int a, int b)
{
    int lar = max(a, b);
    int small = min(a, b);
    for (int i = lar; ; i += lar) {
        if (i % small == 0)
            return i;
    }
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b) {
    return (a.second < b.second);
}

ll power(ll x, unsigned ll y, ll p){
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
char a[21][21];
ll h, w;
bool vis[21][21];
ll dist[21][21];

ll bfs(queue<pp> &q, pp x){
    pp t = q.front();
    vis[t.ff][t.ss] = true;
    while(!q.empty()){
        t = q.front();
        q.pop();
        if(t.ff == x.ff && t.ss == x.ss)
        {
            return dist[t.ff][t.ss];
        }
        if(t.ff > 0 && a[t.ff-1][t.ss] == '.' && !vis[t.ff-1][t.ss]){
            dist[t.ff-1][t.ss] = dist[t.ff][t.ss]+1;
            q.push({t.ff-1,t.ss});
            vis[t.ff-1][t.ss] = true;
        }
        if(t.ff < h-1 && a[t.ff+1][t.ss] == '.' && !vis[t.ff+1][t.ss]){
            dist[t.ff+1][t.ss] = dist[t.ff][t.ss]+1;
            q.push({t.ff+1,t.ss});
            vis[t.ff+1][t.ss] = true;
        }
        if(t.ss > 0 && a[t.ff][t.ss-1] == '.' && !vis[t.ff][t.ss-1]){
            dist[t.ff][t.ss-1] = dist[t.ff][t.ss]+1;
            q.push({t.ff,t.ss-1});
            vis[t.ff][t.ss-1] = true;
        }
        if(t.ss < w-1 && a[t.ff][t.ss+1] == '.' && !vis[t.ff][t.ss+1]){
            dist[t.ff][t.ss+1] = dist[t.ff][t.ss]+1;
            q.push({t.ff,t.ss+1});
            vis[t.ff][t.ss+1] = true;
        }
    }
    return -1;
}

void solve(){
    
    cin >> h >> w;
    vector<pp> p;
    for(ll i = 0;i < h;i++){
        for(ll j = 0;j < w;j++){
            cin >> a[i][j];
            if(a[i][j] == '.'){
                p.push_back({i, j});
            }
        }
    }
    ll mx = 0;
    for(ll i = 0;i < p.size();i++){
        for(ll j = i;j < p.size();j++){
            memset(vis, false, sizeof(vis));
            memset(dist, 0, sizeof(dist));
            queue<pp> q;
            q.push(p[i]);
            
            ll x = bfs(q, p[j]);
            mx = max(mx, x);
        }
    }
    cout << mx << endl;
}

int main()
{
    //ll t; cin >> t; while(t--)
        solve();
}


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

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int  long long

int32_t main()
{
    IOS
    int n;
    cin >> n;
    int a[n];
    int x = 0;
    for(int i = 0; i < n; i++) cin >> a[i], x ^= a[i];
    for(int i = 0; i < n; i++)
    {
    	cout << (int)(x ^ a[i]) << " ";
    }
    return 0;
}

Measured memory_bytes: 5164