akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
const int N=200005;
int n;
vector<int>G[N];
int dep[N];
vector<int>pos[2];
void dfs(int u,int father)
{
	dep[u]=dep[father]+1;
	pos[dep[u]&1].push_back(u);
	for(int v:G[u])
	{
		if(v==father) continue;
		dfs(v,u);
	}
	return;
}
vector<int>col[3];
int ans[N];
int main()
{
	scanf("%d",&n);
	int num[3]={n/3,(n+2)/3,(n+1)/3};
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(1,0);
	int x=pos[0].size(),y=pos[1].size();
	if(x<=num[0])
	{
		for(int u:pos[0])
			col[0].push_back(u),num[0]--;
		for(int u:pos[1])
		{
			if(num[0]>0) col[0].push_back(u),num[0]--;
			else if(num[1]>0) col[1].push_back(u),num[1]--;
			else if(num[2]>0) col[2].push_back(u),num[2]--;
		}
	}
	else if(y<=num[0])
	{
		for(int u:pos[1])
			col[0].push_back(u),num[0]--;
		for(int u:pos[0])
		{
			if(num[0]>0) col[0].push_back(u),num[0]--;
			else if(num[1]>0) col[1].push_back(u),num[1]--;
			else if(num[2]>0) col[2].push_back(u),num[2]--;
		}
	}
	else
	{
		for(int u:pos[0])
		{
			if(num[1]>0) col[1].push_back(u),num[1]--;
			else if(num[0]>0) col[0].push_back(u),num[0]--;
		}
		for(int u:pos[1])
		{
			if(num[2]>0) col[2].push_back(u),num[2]--;
			else if(num[0]>0) col[0].push_back(u),num[0]--;
		}
	}
	int now=1;
	for(int u:col[1])
		ans[u]=now,now+=3;
	now=2;
	for(int u:col[2])
		ans[u]=now,now+=3;
	now=3;
	for(int u:col[0])
		ans[u]=now,now+=3;
	for(int i=1;i<=n;i++)
		printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 22736
#include<iostream>
using namespace std;
int a[50],n;
bool pd(int i,int k){
	if(k==0) return 1;
	if(i>=n) return 0;
	int res=pd(i+1,k)||pd(i+1,k-a[i]);
	return res;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	int q,k;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>k;
		if(pd(0,k)) cout<<"yes"<<endl;
		else cout<<"no"<<endl; 
	} 
	return 0;
}



Measured memory_bytes: 3104
import numpy as np
MOD = 1000000007

n = int(input())
a = np.array(list(map(int, input().split())))
tails = np.full((3,), -1)
ind = np.arange(3)
res = 1
for aa in a:
    filt = tails == (aa-1)
    s = filt.sum()
    if s == 0:
        print(0)
        exit(0)
    res *= s
    res %= MOD
    i = ind[filt][0]
    tails[i] = aa
print(res)


Measured memory_bytes: 23372
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	if(a<b)
		swap(a,b);
	if(b==0)
		return a;
	return gcd(b,a%b);
}
class seg_tree{
public:
	seg_tree(int n_){
		n=1;
		while(n<n_)
			n*=2;
		node.resize(n*2-1);
	};
	void update(int x,int val){
		x+=n-1;
		node[x]=val;
		while(x>0){
			x=(x-1)/2;
			node[x]=gcd(node[2*x+1],node[2*x+2]);
		}
	};
	int getgcd(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0)
			r=n;
		if(r<=a||b<=l)
			return 0;
		if(a<=l&&r<=b)
			return node[k];
		return gcd(getgcd(a,b,2*k+1,l,(l+r)/2),getgcd(a,b,2*k+2,(l+r)/2,r));
	};
private:
	int n;
	vector<int> node;
};
int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	seg_tree st(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		st.update(i,a[i]);
	}
	int ans=0;
	for(int i=0;i<n;i++)
		ans=max(ans,gcd(st.getgcd(0,i),st.getgcd(i+1,n)));
	cout<<ans<<endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

map<int, int> mp;

int main() {
    int s;
    cin >> s;
    for (int i = 1;; i++) {
        // cout << s << endl;
        if (mp.count(s)) {
            cout << i << endl;
            return 0;
        }
        mp[s] = i;
        if (s % 2 == 0) {
            s /= 2;
        } else {
            s = 3 * s + 1;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
 
int pow10(int k){
    int ret = 1;
    for(int i = 0; i < k; i++) ret *= 10;
    return ret;
}
 
int sum10(int N){
    int k = 0;
    int sum = 0;
    while(N >= pow10(k)){
        int n = (N % pow10(k+1))/pow10(k);
        sum += n;
        k++;
    }
   
    return sum;
}
 
int N,A,B;
int main(){
    scanf("%d %d %d",&N,&A,&B);
    
    long long total = 0;
    for(int i = 1; i <= N; i++){
        int sum = sum10(i);
        if( A <= sum && sum <= B) total += i;
    }
 
 
    printf("%lld\n",total);
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const long MOD = 1000000007;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }

  while (a % b != 0) {
    ll tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

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

int N;
vector<ll> T;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  T.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }

  ll ans = T[0];
  for (int i = 1; i < N; i++) {
    ans = lcm(ans, T[i]);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type susi struct {
	t int
	d int
}

type sushi []susi

func (s sushi) Len() int {
	return len(s)
}

func (s sushi) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sushi) Less(i, j int) bool {
	return s[i].d < s[j].d
}

func maxInt(a, b int) int {
	switch {
	case a > b:
		return a
	default:
		return b
	}
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()

	var sushi sushi = make([]susi, n)
	for i := range sushi {
		sushi[i].t, sushi[i].d = nextInt(), nextInt()
	}
	sort.Sort(sort.Reverse(sushi))

	pointD := 0
	typeNum := 0
	types := make([]int, n+1)
	for i := 0; i < k; i++ {
		pointD += sushi[i].d
		types[sushi[i].t]++
		if types[sushi[i].t] == 1 {
			typeNum++
		}
	}
	pointSum := pointD + (typeNum * typeNum)

	iRemove := k - 1
	iAdd := k
	for typeNum < k {
		for ; iRemove > 0; iRemove-- {
			if types[sushi[iRemove].t] > 1 {
				pointD -= sushi[iRemove].d
				types[sushi[iRemove].t]--
				break
			}
		}
		if iRemove == 0 {
			break
		}
		iRemove--

		for ; iAdd < n; iAdd++ {
			if types[sushi[iAdd].t] == 0 {
				pointD += sushi[iAdd].d
				types[sushi[iAdd].t]++
				typeNum++
				break
			}
		}
		if iAdd == n {
			break
		}
		iAdd++

		pointSum = maxInt(pointSum, pointD+(typeNum*typeNum))
	}
	fmt.Println(pointSum)
}


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

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
	}

	static void solve() {
		int n = in.nextInt();
		int k = in.nextInt();
		int[] arr = in.readarr(n);
		int[] dp = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		
		for(int i = 0; i < n; i++)
		{
			for(int j = 1; j <= k; j++)
			{
				if(i + j >= n) break;
				dp[i + j] = Math.min(dp[i] + Math.abs(arr[i] - arr[i + j]), dp[i + j]);
			}
		}
		System.out.println(dp[n - 1]);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int[] readarr(int abc) {
			int[] temp = new int[abc];
			for (int i = 0; i < abc; i++)
				temp[i] = nextInt();
			return temp;
		}
	}
}


Measured memory_bytes: 39376
var
        x,s,i,n,m,y:longint;
        a:array[1..10000]of longint;
begin
        readln(n);
        for i:=1 to n do
        begin
                read(a[i]);
                s:=s+a[i];
        end;
        readln(m);
        for i:=1 to m do
        begin
                readln(x,y);
                writeln(s-a[x]+y); 
        end;
end.


Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<map>
#include<math.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long int s;
	cin >> s;
	map<long long int, int>a;
	a[s]++;
	for (long long int i = 2; i <= 10000000; i++) {
		if (s % 2)s = s * 3 + 1;
		else s/= 2;
		if (a[s]) {
			cout << i << endl;
			return 0;
		}
		a[s]++;
	}
}

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

struct Edge{int to, id;};

vector<vector<Edge>> g;
vector<int> ans;

void dfs (int v, int c = -1,int p =-1){
  int k = 1;
  rep(i, g.at(v).size()){
  int u = g.at(v).at(i).to, ei =g.at(v).at(i).id;
    if(u == p) continue;
    if(k == c) k++;
    ans.at(ei) = k; k++;
    dfs(u,ans.at(ei), v);
  }
}

int main(){
  int n;
  cin >> n;
  g.resize(n);
  ans = vector<int>(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    g.at(a).push_back((Edge){b,i});
    g.at(b).push_back((Edge){a,i});
  }
  dfs(0);
  int mx = 0;
  rep(i,n) mx = max(mx, int(g.at(i).size()));
  cout << mx << endl;
  rep(i,n-1){
    cout << ans.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 8320
import java.util.*
import kotlin.*

import java.io.InputStream
import java.lang.NumberFormatException
import java.lang.StringBuilder


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = FastScanner()
        val x = sc.next()
        val stack = Stack<Char>()
        for (i in x.indices) {
            if (stack.size > 0 && stack.peek() == 'S' && x[i] == 'T') {
                stack.pop()
            } else {
                stack.add(x[i])
            }
        }
        println(stack.size)
    }
}


class FastScanner {
    companion object {
        val input: InputStream = System.`in`
        val buffer = ByteArray(1024) { 0 }
        fun isPrintableChar(c: Int): Boolean = c in 33..126
    }

    var ptr = 0
    var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = input.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextDouble(): Double = next().toDouble()
}


Measured memory_bytes: 33436
def main():
    import collections
    N, K = map(int, input().split())
    G = [set() for i in range(N)]

    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].add(b)
        G[b].add(a)

    q = collections.deque()
    q.append((0))
    ans = K
    mod = 10**9+7
    r = [True]*N
    r[0] = False
    while(q):
        x = q.popleft()
        tmp = K - 1
        if x > 0:
            tmp -= 1
        for y in G[x]:
            if r[y]:
                r[y] = False
                q.append(y)
                ans *= tmp
                tmp -= 1
                ans %= mod
    print(ans)


main()


Measured memory_bytes: 38388
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,max=0;
    cin>>a;
    if(a==1){cout<<1<<endl;return 0;}
    for(int i=2;i<=sqrt(a);i++){
        b=i;
        while(b*i<=a)b*=i;
        if(max<b)max=b;
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def isEmpty(S):
  if len(S) == 0:
    return True

def isFull(S):
  if len(S) >= 100000:
    return True

def enqueue(x):
  if isFull(x_list_list):
    print 'Error'
  x_list_list.append(x)

def dequeue(x_list_list):
  if isEmpty(x_list_list):
    print 'Error'
  del_list = x_list_list[0]
  x_list_list.pop(0)
  return(del_list)

y = sys.stdin.readline()
a, b = y.split(" ")
a = int(a)
b = int(b)

S = []
x_list_list = []
run_time = 0

for i in range(a):
  text = raw_input()
  x_list = text.split()
  x_list[1] = int(x_list[1])
  x_list.append(0)
  x_list_list.append(x_list)

flag = a
while flag != 0:
  if x_list_list[0][1] > b:
    x_list_list[0][1] -= int(b)
    run_time += b
    del_list = dequeue(x_list_list)
    enqueue(del_list)
  else:
    run_time += x_list_list[0][1]
    x_list_list[0][2] = run_time
    x_list_list[0][1] = 0
    flag -= 1
    print x_list_list[0][0],x_list_list[0][2]
    dequeue(x_list_list)
    

Measured memory_bytes: 19528
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n;    
		vi cost(n,0),dp(n,inf);
		rep(i,0,n)cin>>cost[i];
		dp[0]=0;
		rep(i,1,n)
		{
			if(i-2>=0)
			{
				dp[i]=min(dp[i],dp[i-2]+abs(cost[i]-cost[i-2]));
			}

			dp[i]=min(dp[i],dp[i-1]+abs(cost[i]-cost[i-1]));
		}

		cout<<dp[n-1]<<endl;
    }
    return 0;
        
}

Measured memory_bytes: 1792
//https://atcoder.jp/contests/dp/tasks/dp_r
#include <iostream>
#include <vector>
using namespace std;
int const mod = 1e9 + 7;

int mul(int a, int b)
{
    return (long long)a * b % mod;
}
void add_self(int&a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}

class Matrix
{
   
    int size;

public:
    vector<vector<int>> mat;
    Matrix(int n)
    {
        size = n;
        mat.assign(size, vector<int>(size));
    }
    void makeit_identical_matrix()
    {
        for (int x = 0; x < size; ++x)
                mat[x][x] = 1;
    }
    Matrix operator*(Matrix const &obj)
    {
        Matrix answer(size);
        for (int i = 0; i < size; ++i)
            for (int j = 0; j < size; ++j)
                for (int k = 0; k < size; ++k)
                   answer.mat[i][k] = (answer.mat[i][k]%mod + mul(mat[i][j], obj.mat[j][k]))%mod;

        return answer;
    }
};

Matrix binary_exponential_mul(Matrix  &mat, long long k, int size)
{
    Matrix answer(size);
    answer.makeit_identical_matrix();
    while (k > 0)
    {
        if (k & 1)
            answer = answer * mat;
            
        mat = mat * mat;
        k = k / 2;
    }
    return answer;
}

int main()
{
    int n;
    long long k;
    cin >> n >>k;
    Matrix m(n);
    for(int i=0; i<n;++i)
      for(int j=0;j<n;++j)
        cin >> m.mat[i][j];
    Matrix result = binary_exponential_mul(m, k, n);
    
    int  answer = 0;
    for(int i=0; i<n;++i)
      for(int j=0;j<n;++j)
        answer = (answer%mod + result.mat[i][j]%mod)%mod;
    
    cout << answer <<endl;
        
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int arr[1000000],i,j,k,n,d=0,d2=0;
    scanf("%d%d",&k,&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    d=abs(arr[n-1]-arr[0]);
    for(j=0;j<n-1;j++)
    {
        d2=k-(arr[j+1]-arr[j]);
        if(d>d2)
        {
            d=d2;
        }
    }
    printf("%d\n",d);
    
    return 0;
}

Measured memory_bytes: 2944
'use strict';                                                               
 (function(stdin) {
     var lines = stdin.toString().split('\n');
     var param = lines[0].split(' ').map(Number);
     var a = param[0];
     var b = param[1];
     console.log(
       a * b , a * 2 + b * 2);
 }(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

Measured memory_bytes: 2816
using System;

namespace abc147A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            if ((A + B + C) >= 22)
                Console.WriteLine("bust");
            else
                Console.WriteLine("win");
        }
    }
}


Measured memory_bytes: 11348
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  void solve()
  {

int x;
cin>>x;
cout<<(1-x);
  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


Measured memory_bytes: 3632
#include <cmath>
#include <iostream>
#include <limits>
#include <vector>

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

    std::vector<int> W;
    W.reserve(N);
    {
        int w;
        for(int i = 0; i < N; ++i) {
            std::cin >> w;
            W.push_back(w);
        }
    }

    int ret = std::numeric_limits<int>::max();
    for (int i = 0; i < N - 1; ++i) {
        int sum = 0;
        for (int j = 0; j <= i; ++j) {
            sum += W[j];
        }
        for (int j = i + 1; j < N; ++j) {
            sum -= W[j];
        }

        ret = std::min(ret, std::abs(sum));
    }
    
    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <complex>
#include <iterator>
#include <random>
#include <time.h>
#include <tuple>
#include <functional>
#include <list>
#include <limits.h>
#define mp make_pair
#define ni(x) scanf("%d", &(x))
#define nii(x,y) scanf("%d%d",&(x),&(y))
#define mul(x,y) ((ll)(x)*(y)%mod)
#define mtp make_tuple
#define F(i,n) for(int i = 0; i < (n); i++)
#define FF(i,n) for(int i = 1; i <= (n); i++)
#define FE(i,n) for(int i = 0; i <= (n); i++)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int mod = 1000000007;
const int inf = 2012345678;
const ll infl = 9012345678901234567;
const double pi = 3.1415926535897932384626433832795;
//----------------------------------------------------------------------------//

const int N = 100000;
int a[N];
ll b[N];
int main() {
#ifndef __GNUG__
	freopen("input.txt", "r", stdin);
#endif
	int n; ni(n);
	F(i, n)ni(a[i]);
	ll sum = 0;
	F(i, n)sum += a[i];
	ll n2 = (ll)n*(n + 1) / 2;
	if (sum%n2 != 0) {
		puts("NO"); return 0;
	}
	ll K = sum / n2;
	F(i, n) {
		ll dif = a[(i + 1) % n] - a[i];
		ll NX = K - dif;
		if (NX < 0) {
			puts("NO"); return 0;
		}
		if (NX%n != 0) {
			puts("NO"); return 0;
		}
		b[i] = NX / n;
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 1408
N=int(input())
c=input()
left=0
right=N-1
ans=0
if all(c[i]=='R' for i in range(N)):
    print('0')
    exit()
if all(c[i]=='W'for i in range(N)):
    print('0')
    exit()
while left<right:
    if c[left]=='R':#これより左に白石なし
        left+=1
    if c[right]=='W':#これより右に赤石なし
        right-=1
    if c[left]=='W' and c[right]=='R':
        left+=1
        right-=1
        ans+=1
print(ans)

Measured memory_bytes: 67968
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pll = pair<ll, ll>;
 
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair

void solve() {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(max(a*c, a*d), max(b*c, b*d));  
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
}

Measured memory_bytes: 3652
N = int(input())
A = [int(i) for i in input().split()]
for i in range(N):
    A[i] -= i+1
A.sort()
len_A = len(A)
Sum = 0
for i in range(len_A//2):
    Sum += A[len_A-1-i] - A[i]
print(Sum)

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    ll i,n,k,p,sum=0;
    sll(n,k);
    vector<ll>vec;
    rep0(i,n)
    {
        sl(p);
        vec.pb(p);
    }
    sort(all(vec),greater<>());
    for(i=k;i<n;i++)
        sum+=vec[i];
    cout<<sum;
}


Measured memory_bytes: 2420
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;


int main() {

	int N;
	cin >> N;
	vector<int> h(N);
	rep(i, N) cin >> h.at(i);

	ll a1 = 0;
	ll a2 = abs(h.at(0) - h.at(1));
	ll x = a2;

	if (N > 2) {
		for (int i = 2; i < N; i++) {
			x = min(a1 + abs(h.at(i) - h.at(i - 2)), a2 + abs(h.at(i) - h.at(i - 1)));
			a1 = a2;
			a2 = x;
		}
	}
	

	cout << x << endl;

	
	return 0;
}

Measured memory_bytes: 640
from sys import exit
def gcd(a,b):#greatest common divisor
    if (a<b):
        a,b = b,a
    while(b>0):
        a,b = b ,a%b
    return a
N = int(input())
A = [int(n) for n in input().split()]
straight = [0]*N
straight[0] = gcd(A[0],A[0])
for i in range(1,len(A)):
    straight[i] = gcd(straight[i-1], A[i])

A = A[::-1]
back = [0]*N
back[0] = gcd(A[0],A[0])
for i in range(1,len(A)):
    back[i] = gcd(back[i-1], A[i])

back = back[::-1]
# print(straight)
# print(back)
ans = straight[-2]
for i in range(N-2):
    ans = max(ans, gcd(straight[i], back[i+2]))
    # print(straight[i],back[i+2])
    # print(gcd(straight[i], back[i+2]))
ans = max(ans, back[1])
print(ans)


Measured memory_bytes: 14400
#include <array>
#include <numeric>
#include <iostream>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::array;
using std::for_each;
using std::accumulate;

int main() {
	array<int,5> score;
	for_each(score.begin(),score.end(),[](int &s){
		cin >> s;
		if (s < 40) {
			s = 40;
		}
	});
	cout << accumulate(score.begin(),score.end(),0)/5 << endl;
}

Measured memory_bytes: 3100
n = gets.to_i
a = gets.split.map(&:to_i)
p = []
n.pred.downto(0) do |i|
  unless a[i].zero?
    p << i + 1
    u = 1
    v = i + 1
    while u * u <= v
      if v % u == 0
        a[u - 1] ^= 1
        unless u == v / u
          a[v / u - 1] ^= 1
        end
      end
      u += 1
    end
  end
end
if p.size > 0
  puts p.size
  puts p.join(' ')
else
  puts '0'
end

Measured memory_bytes: 30968
#include <iostream>
#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    double t;
    double x;
    double ans;
    cin >> t >> x;
    ans = t/x;
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 101001;//ここを問題の制約を見ながらいじる．配列の確保に使う．
ll X[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．

       // Main program
void solve() {
    ll  N,M;
    cin >> N;
    cin >> M;

    if (N == M) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

       
    return;

}

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







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200],maxn,tmp,n;
string s;
int main(){
	cin>>n;
	cin>>s;
	tmp = maxn = 0;
	for (int i=0;i<s.length();i++){
		if (s[i] == 'I') tmp++;
		else tmp--;
		maxn = max(maxn,tmp);
	}
	cout<<maxn<<endl;
	return 0;
}

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

int main(){
    ll x, y; cin >> x >> y;

    ll ans = 0;
    while(x <= y){
        x *= 2;
        ans++;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;


double calculate(int m, int n, int k) {
	int cnt = 0;
	while (m < k) {
		cnt++;
		m *= 2;
	}

	return (1.0 / n) * pow(0.5, cnt);
}
int main() {
	int n, k;
	cin >> n >> k;

	double ans = 0.0;
	for (int i = 1; i <= n; i++) {
		ans += calculate(i, n, k);
	}
	printf("%.14f\n", ans);
	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j,p;
    int n, m, l, k, a, h;
    while(cin >> n >> m >> l >> k >> a >> h, n){
        vi x(l); // 冷凍施設がある町
        rep(i,l) cin >> x[i];

        int dp[100][100];
        rep(i,100)rep(j,100)
            if(i == j) dp[i][j] = 0;
            else dp[i][j] = INF;
        rep(i,k){
            int p,q,r;
            cin >> p >> q >> r;
            if(r > m)continue;
            dp[p][q] = r;
            dp[q][p] = r;
        }

        rep(p,100)rep(i,100)rep(j,100)
            dp[i][j] = min(dp[i][j], dp[i][p] + dp[p][j]);


        x.push_back(a);
        x.push_back(h);
        l += 2;

        int v[100][100];
        rep(i,100)rep(j,100)
            if(i == j) v[i][j] = 0;
            else v[i][j] = INF;

        rep(i,l)rep(j,l){
            if(dp[x[i]][x[j]] > m)continue;
            v[x[i]][x[j]] = dp[x[i]][x[j]];
        }

        rep(p,100)rep(i,100)rep(j,100)
            v[i][j] = min(v[i][j], v[i][p] + v[p][j]);

        int ans = v[a][h];

        if(ans == INF){
            cout << "Help!" << endl;
        }else{
            if(m - ans >= 0)
                cout << ans << endl;
            else
                cout << ans + (ans - m) << endl;
        }
    }
}



Measured memory_bytes: 3068
// {{{ Templates
#include <bits/stdc++.h>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

// }}}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    vector<ll> B = A;
    reverse(B.begin(), B.end());
    B.erase(unique(B.begin(), B.end()), B.end());
    ll maxi1 = 0;
    ll maxi2 = 0;
    for (const ll p : B) {
        const int num = upper_bound(A.begin(), A.end(), p) - lower_bound(A.begin(), A.end(), p);
        if (num < 2) {
            continue;
        }
        if (num >= 4) {
            if (maxi1 == 0) {
                maxi1 = p;
            }
            maxi2 = p;
            break;
        } else {
            if (maxi1 != 0) {
                maxi2 = p;
                break;
            } else {
                maxi1 = p;
            }
        }
    }
    cout << maxi1 * maxi2 << endl;

    return 0;
}


Measured memory_bytes: 1792
require 'set'
require 'bigdecimal'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, K = get_ints
P = get_ints

set = P.to_set
hash = {}
set.each do |p|
  hash[p] = (p+1)/BigDecimal(2) if hash[p].nil?
end

px = P.map { |p| hash[p] }

max = 0
i = 0
sum = 0
while i < px.length
  if i < K - 1
    sum += px[i]
  elsif i == K - 1
    sum += px[i]
    max = sum
  else
    sum -= px[i-K]
    sum += px[i]
    max = sum if max < sum
  end
  i += 1
end

puts max.to_f


Measured memory_bytes: 41204
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

char buf[301],right_buf[301],ans[301];
int dp[301][301],memo[301][301];

void func(){

	int length,right_length;
	for(length = 0; buf[length] != '\0'; length++){
		right_buf[length] = buf[length];
	}

	int ans_length = 0,right_start;

	for(int left_length = 1; left_length <= length-1; left_length++){

		right_length = length - left_length;
		right_start = left_length;

		if(left_length <= ans_length || right_length <= ans_length)continue;

		for(int a = 0; a <= max(right_length,left_length); a++){
			for(int b = 0; b <= max(right_length,left_length); b++)dp[a][b] = 0;
		}

		for(int i = 0; i < left_length; i++){
			for(int k = 0; k < right_length; k++){
				if(buf[i] == right_buf[right_start+k]){
					dp[i+1][k+1] = dp[i][k]+1;
					memo[i+1][k+1] = 0;
				}else{
					if(dp[i][k+1] >= dp[i+1][k]){
						dp[i+1][k+1] = dp[i][k+1];
						memo[i+1][k+1] = 1;
					}else{
						dp[i+1][k+1] = dp[i+1][k];
						memo[i+1][k+1] = -1;
					}
				}
			}
		}


		if(ans_length < dp[left_length][right_length]){
			ans_length = dp[left_length][right_length];

			stack<char> S;

			for(int i = left_length,k = right_length; i > 0 && k > 0;){

				if(memo[i][k] == 1){
					i--;
				}else if(memo[i][k] == -1){
					k--;
				}else{ //memo[i][k] == 0
					S.push(buf[i-1]);
					i--;
					k--;
				}
			}

			int index = 0;
			while(!S.empty()){
				ans[index++] = S.top();
				S.pop();
			}
		}
	}

	for(int i = 0; i < ans_length; i++)printf("%c",ans[i]);
	printf("\n");
}

int main(){

	while(true){
		scanf("%s",buf);
		if(buf[0] == '#')break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
using namespace std;
typedef long long ll;

int n,m;
vector<int> g[100005];
int c[100005];

bool dfs(int x){
	bool r=true;
	for(auto y:g[x]){
		if(c[y]==c[x])r=false;
		if(c[y]<0){
			c[y]=1-c[x];
			if(!dfs(y))r=false;
		}
	}
	return r;
}

int main(){
	scanf("%d%d",&n,&m);
	while(m--){
		int x,y;
		scanf("%d%d",&x,&y);x--;y--;
		g[x].pb(y);g[y].pb(x);
	}
	memset(c,-1,sizeof(c));
	int na=0,nb=0,nc=0;
	fore(x,0,n){
		if(c[x]>=0)continue;
		if(!g[x].size())na++;
		else {
			c[x]=0;
			if(dfs(x))nb++;
			else nc++;
		}
	}
	ll r=2*nb+na+nc;
	r+=1LL*nb*(2*(nb-1)+nc);
	r+=1LL*nc*(nb+nc-1);
	r+=2LL*na*(n-1)-1LL*na*(na-1);
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 9984
from collections import defaultdict
N, M = map(int, input().split())

connection = {}
for i in range(M):
    line = list(map(int, input().split()))
    s = line[1:]
    connection[i] = s

P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    isSwitchOn = [0 for _ in range(N)]
    for j in range(N):
        if (i >> j) & 1:
            isSwitchOn[j] = 1

    onBulbs = 0
    for j in range(M):
        count = 0
        for switch in connection[j]:
            if isSwitchOn[switch-1]:
                count += 1

        if count % 2 == P[j]:
            onBulbs += 1

    if onBulbs == M:
        ans += 1

print(ans)


Measured memory_bytes: 74680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
const int p = 43;
int N = p * p + p + 1;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << N << " " << p + 1 << endl;
    for(int delta = 0; delta <= p - 1; delta++) {
        for(int start = 1; start <= p; start++) {
            cout << p * p + 1 + delta;
            int now = start;
            for(int j = 0; j < p; j++) {
                cout << " " << now + j * p;
                now += delta;
                now %= p;
                if(now == 0) now += p;
            }
            cout << endl;
        }
    }
    for(int i = 0; i <= p; i++) {
        cout << N;
        for(int j = i * p + 1; j <= (i + 1) * p; j++) {
            cout << " " << j;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 1; i < n; i ++) {
    int t; cin >> t;
    t --;
    a[t] ++;
  }

  for (int i = 0; i < n; i ++) {
    cout << a[i] << endl;
  }
}


Measured memory_bytes: 4036
#!/usr/bin/env python3


def solv(n, h):
    top = 0
    ans = 0
    for hi in h:
        if top <= hi:
            top = hi
            ans += 1
    return ans


if __name__ == '__main__':

    n = int(input())
    h = map(int, input().split())

    ans = solv(n, h)

    print(ans)


Measured memory_bytes: 2940
from collections import OrderedDict
from collections import deque
N = int(input())
G = [[] for _ in range(N)]
od = OrderedDict()

for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
    od[(a,b)] = 0 ## ここに色を入れてく

used = [False]*N # 親ノードは考えない
parent2colors = [0]*N ## その頂点をインデックスとしたと親との辺の色のリスト
que = deque()
que.append(0)
used[0] = True
colors = 0

while len(que) != 0:
    v = que.popleft()
    colors = max(colors,len(G[v]))
    cur_color = 1
    for nv in G[v]:
        if used[nv]:continue # 親への辺は無視
        if cur_color == parent2colors[v]:
            cur_color += 1

        if (v,nv) in od.keys():
            od[(v,nv)] = cur_color
        else:
            od[(nv,v)] = cur_color
        parent2colors[nv] = cur_color
        cur_color += 1
        used[nv] = True
        que.append(nv)

print(colors)
for edge_clr in od.values():
    print(edge_clr)





Measured memory_bytes: 57972
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
H = LIST()

total = 0
for i in H:
	if i >= K:
		total += 1

print(total)

Measured memory_bytes: 72556
import java.util.*;

class Main{
public static void main(String args[]) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
  	int b = sc.nextInt();
	int sum = 0;
  	
  	if (a > b){
    sum += a;
    a--;
    }else{
    sum += b;
    b--;
    }
  	if (a > b){
    sum += a;
    a--;
    }else{
    sum += b;
    b--;
    }
  
  	System.out.println(sum);
  
  	
}
}

Measured memory_bytes: 21204
i = list(map(int, input().split()))

if i[1] == 0:
    print(0)

else:
    j = i[0] // (i[1] + i[2])
    k = j * i[1]

    l = j * (i[1]+i[2])
    l_max = min(l + i[1], i[0])

    k = k + (l_max - l)
  
    print(k)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  // input
  long long n,k; cin >> n >> k;
 
  // compute
  long long ans;
 
  if(n < k){
    ans = min(n, k - n);
  }else{
    ans = min(n % k, k - (n % k));
  }
 
  // output  
  cout << ans << endl;
  
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V, string sep = " ", string end_ = "endl") {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << sep;
    }
    if(end_ == "endl")
        cout << endl;
    else
        cout << end_;
}

template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N = in(), p;
    vector<int> v(N);
    rep(i, N) {
        cin >> p;
        v[p - 1] = i + 1;
    }
    vecout(v);
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1][3];
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>a[i][j];
	    }
	}
	int dp[n+1][3];
	
    dp[1][0]=a[1][0];
	dp[1][1]=a[1][1];
    dp[1][2]=a[1][2];
	
	for(int i=2;i<=n;i++)
	{
		dp[i][0]=a[i][0]+ max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=a[i][1]+ max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=a[i][2]+ max(dp[i-1][0],dp[i-1][1]);

	}
	
	cout<<max(dp[n][0], max(dp[n][1],dp[n][2]));
	
	
}

Measured memory_bytes: 2560
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        //[マルバツ][自分][一つ前]
        int[][][] q =
        {
            //◯
            new int[][]
            {
                //羊
                new int[]{0,1},
                //狼
                new int[]{1,0}
            },
            //×
            new int[][]
            {
                //羊
                new int[]{1,0},
                //狼
                new int[]{0,1}
            }
        };
        int n = int.Parse(Console.ReadLine());
        int[] s = Console.ReadLine().Select(x => x == 'o' ? 0 : 1).ToArray();
        for (int i = 0; i <= 1; i++)
        {
            for (int j = 0; j <= 1; j++)
            {
                int[] a = new int[n];
                a[0] = i;
                a[1] = j;
                for (int k = 2; k < n; k++)
                {
                    a[k] = q[s[k - 1]][a[k - 1]][a[k - 2]];
                }
                if (q[s[n - 1]][a[n - 1]][a[n - 2]] == a[0] && q[s[0]][a[0]][a[n - 1]] == a[1])
                {
                    Console.WriteLine(string.Join("", a.Select(x => x == 0 ? "S" : "W").ToArray()));
                    return;
                }
            }
        }
        Console.WriteLine(-1);
    }
}

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

vector<int> z_algorithm(const string &s) {
  int n = s.size();
  vector<int> res(n);
  res.at(0) = n;
  int i = 1, j = 0;
  while (i < n) {
    while (i + j < n && s.at(j) == s.at(i + j)) j++;
    res.at(i) = j;
    if (j == 0) {
      i++;
      continue;
    }
    int k = 1;
    while (i + k < n && k + res.at(k) < j) res.at(i + k) = res.at(k), k++;
    i += k, j -= k;
  }
  return res;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    string tmp = S.substr(i);
    auto lcp = z_algorithm(tmp);
    for (int j = 0; j < (int) tmp.size(); j++) {
      int l = min(lcp.at(j), j);
      ans = max(ans, l);
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N = 100010,M = 0x3f3f3f3f;
//int n,num[N],m[N],dp[N][3],ans;
//char s[N];
int main(){
	string s;
	cin>>s;
	if(s.length()==2)
	    cout<<s;
	else
	    for(int i=s.length()-1;i>=0;i--)
		    cout<<s[i];
	printf("\n"); 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int fun(int arr[],int ind,int n,vector<int>&v,int k)
{
    if(ind==n-1)
        return 0;
    else if(v[ind]!=INT_MAX)
        return v[ind];
    {

        for(int i=1;i<=k;i++)
        {
            if(ind+i<n)
            {
                v[ind] = min(v[ind], abs(arr[ind]-arr[ind+i]) + fun(arr,ind+i,n,v,k));
            }
            else
                break;
        }
        return v[ind];
    }
}
int main()
{
 int n,k;
 cin>>n>>k;
 int arr[n];
 vector<int>v(2*n,INT_MAX);
 for(int i=0;i<n;i++)
    cin>>arr[i];
    fun(arr,0,n,v,k);

 cout<<v[0]<<endl;
}


Measured memory_bytes: 10752