akhauriyash/Code-Regression huggingface dataset:
n,q = map(int, input().split())
a = list(map(int, input().split()))

query=[]
for i in range(q):
    query.append(input())
ide_ele = 0

def segfunc(x, y):
    return x + y

class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        # param k: index(0-index)
        # param x: update value
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1
    def query(self, l, r): #[l, r) 0-index
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

al = [a[i] for i in range(n)]
seg = SegTree(al, segfunc, ide_ele)

for q in query:
    que,a,b=q.split()

    if que == "0":
        now=seg.query(int(a),int(a)+1)
        seg.update(int(a),now+int(b))
    else:
        ret=seg.query(int(a),int(b))
        print(ret)

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

const int INF = 1001001001;

int a[12][12];

int main(){
	int n, m, x;
  	cin >> n >> m >> x;
  	vector<int> c(n);
  	rep(i, n){
      cin >> c[i];
      rep(j, m) cin >> a[i][j];
	}
  
  	int ans = INF;
  	rep(s, 1<<n){
      	int cost = 0;
      	vector<int> d(m);
    	rep(i, n){
        	if(s>>i&1){
            	cost += c[i];
              	rep(j, m) d[j] += a[i][j];
            }
        }
      	
      	bool ok = true;
      	rep(j, m) if(d[j] < x) ok = false;
      	if(ok) ans = min(ans, cost);
    }
  
  	if(ans == INF) ans = -1;
  	cout << ans << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll w,h;
  cin >> h >> w;
  if(h % 3 == 0 || w % 3 == 0){
    cout << 0 << endl;
    return 0;
  }
  ll ans = inf;
  REP(i,1,w){
    ll A = (w-i) * h,B = i * (h/2),C = i * (h - h/2),D = h * (i/2),E = h * (i - i/2);
    ans = min(ans,min(max(A,max(B,C))-min(A,min(B,C)),max(A,max(D,E)) - min(A,min(D,E)) ));
  }
  swap(h,w);
  REP(i,1,w){
    ll A = (w-i) * h,B = i * (h/2),C = i * (h - h/2),D = h * (i/2),E = h * (i - i/2);
    ans = min(ans,min(max(A,max(B,C))-min(A,min(B,C)),max(A,max(D,E)) - min(A,min(D,E)) ));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0);cout<<fixed<<setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}

#define pii pair<int,int>
#define ff first
#define ss second
#define endll '\n'

using ll = long long int;
using intt = long long int;

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


Measured memory_bytes: 3652
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
using namespace std;
using ll = long long;
const ll INF = 100100100100100;

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;
	ll ans = 0;
	if ((B - A) % 2 == 0) ans = (B - A) / 2;
	else {
		ans = min(N - B, A - 1) + 1 +(B-A-1)/2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())


flag = False
for x in range(N+1):
  for y in range(N+1): 
    z =(N - x - y)
    if z >=0 and 10000 * x + 5000 * y + 1000 * z == Y:
      print("{} {} {}".format(x,y,z))
      flag = True
      break
  if flag:
    break

if flag == False:
  print("-1 -1 -1")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
    using namespace std;
     
    using ll = long long;
    using P = pair<ll, ll>;
     
    const ll MOD = 1e9+7;
    // const ll MOD = 998244353;
    const ll INF = 1ll<<60;
     
    #define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
    #define REP(i,n) FOR(i,0,n)
    #define ALL(v) (v).begin(),(v).end()
    #define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
    //#define DEBUG(x) ;
     
    ll N, K;
     
    int main(int argc, char **argv)
    {
    	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
     
    	cin >> N >> K;
     
    	if (K > (N-1)*(N-2)/2)
    	{
    		std::cout << -1 << std::endl;
    		return 0;
    	}
     
    	vector<pair<ll, ll>> res;
    	for (ll i = 2; i <= N; ++i)
    		res.push_back(pair<ll, ll>(1, i));
     
    	ll cnt{0};
    	for (ll i = 2; i < N; ++i)
    	{
    		for (ll j = i+1; j <= N; ++j)
    		{
              	if (cnt == (N-2)*(N-1)/2 - K) goto end;
    			res.push_back(pair<ll, ll>(i, j));
    			++cnt;
    		}
    	}
     
     
     end:
    	std::cout << res.size() << std::endl;
    	for (auto &nv : res)
    	{
    		std::cout << nv.first << " " << nv.second << std::endl;
    	}
    	
    	return 0;
    }

Measured memory_bytes: 3660
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long double a, b, h, m, dist, a_h, a_m, x_h, y_h, x_m, y_m;
  long double pie = 3.1415926535897932;
  cin >> a >> b >> h >> m;
  
  a_h = ((360 / 12) * h) + (0.5 * m);
  a_m = (360 / 60) * m;
  
  a_h *= (pie / 180);
  a_m *= (pie / 180);
  
  x_h = a * cosl(a_h);
  y_h = a * sinl(a_h);
  
  x_m = b * cosl(a_m);
  y_m = b * sinl(a_m);
  
  dist = ((x_h - x_m) * (x_h - x_m)) + ((y_h - y_m) * (y_h - y_m));
  dist = sqrtl(dist);
  
  cout << setprecision(16) << dist << endl;
  
  return 0;
}


Measured memory_bytes: 4184
#include <stdio.h>
#include <math.h>
#include <cmath>
 
using namespace std;
 
int main(){
    int n;
    double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
    for(int i = 0; i < n; i++) scanf("%lf",&y[i]);
 
    for(int i = 0; i < n; i++){
        p_1 += abs(x[i] - y[i]);
        p_2 += (x[i] - y[i])*(x[i] - y[i]);
        p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
        p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
    }
    printf("%.6lf\n",p_1);
    printf("%.6lf\n",sqrt(p_2));
    printf("%.6f\n",cbrt(p_3));
    printf("%.6lf\n",p_infinity);
 
}



Measured memory_bytes: 2924
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int mod = 1000000000 + 7;
int dp[101][4][4][4];
int main()
{
        //input->compute->output//
        vector<int> Time(5), nextTime(5);
        for (int i = 0; i < 5; i++)
        {
                cin >> Time[i];
        }

        for (int i = 0; i < 5; i++)
        {
                nextTime[i] = (Time[i] + 9) / 10 * 10;
        }

        int ans = (int)1e9;
        for (int i = 0; i < 5; i++)
        {
                int res = 0;

                for (int j = 0; j < 5; j++)
                {
                        if (i == j)
                        {
                                res += Time[j];
                        }
                        else
                        {
                                res += nextTime[j];
                        }
                }
                ans = min(ans, res);
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,i,d;
	d=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
			if(c % i==0){
				d++;
			}
		}
	printf("%d\n",d);
	return 0;
}

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

int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    rep(i, N) cin >> x[i];
    rep(i, M) cin >> y[i];

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    if (x[N-1] < y[0] && X < y[0] && Y > x[N - 1] && X < Y) {
        cout << "No War" << endl;
    }
    else {
        cout << "War" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <stdlib.h>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <stdio.h>
using namespace std;
const double PI = 3.14159265358979323846;


int main() {
    long long int N, K;
    cin >> N >> K;

    vector<int> dists;
    vector<int> loop, straight;
    map<int, bool> alreadyVisit;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        
        dists.push_back(A-1);
        alreadyVisit[i] = false;
    }

    
    alreadyVisit[0] = true;
    straight.push_back(0);
    int loopStartPosition = 0;
    auto loopStart = straight.begin();
    long long int pDist = 0;
    for (int i = 0; i < N; i++) {
        long long int dist = dists[pDist];
        //cout << "dist:" << dist << endl;
        if (alreadyVisit[dist]) {
            loopStart = find(straight.begin(), straight.end(), dist);

            for (auto itr = loopStart; itr != straight.end(); itr++) {
                //cout << "loop:" << *itr << endl;
                loop.push_back(*itr);
            }

            loopStartPosition = distance(straight.begin(), loopStart);
            break;
        }
        else {
            straight.push_back(dist);
            alreadyVisit[dist] = true;
            pDist = dist;
            if (i == K - 1) {
                cout << dist + 1 << endl;
                return 0;
            }
        }
    }

    //cout << loop[(K - loopStartPosition) % loop.size()] + 1 << endl;
    //cout << loop.size() << endl;
    //cout << K - loopStartPosition << endl;
    //cout << *loopStart << endl;
    cout << *(loopStart + ((K - loopStartPosition) % loop.size())) + 1 << endl;
    return 0;
}

Measured memory_bytes: 15272
#include<stdio.h>
 
int main(){
  int N, D, X[10][10];
  int i, j, k, count = 0, cal;
  
  scanf("%d %d", &N, &D);
  for(i = 0; i < N; i++){
    for(j = 0; j < D; j++){
      scanf("%d", &X[i][j]);
    }
  }
  
  for(i = 0; i < N; i++){
    for(j = i+1; j < N; j++){
      cal = 0;
      for(k = 0; k < D; k++){
        cal += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      for(k = 1; k*k <= cal; k++){
        if(k*k == cal){
          count++;
          break;
        }
      }
    }
  }
  
  printf("%d", count);
  
  return 0;
}

Measured memory_bytes: 128
n = list(map(str,input()))
n_length=len(n)


for i in range(n_length):
    if n[i]=='1':
        n[i]='9'
    elif n[i]=='9':
        n[i]='1'
    else:
        pass
n_new=''.join(n)
print(str(n_new))
    

Measured memory_bytes: 2940
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if((b-a)==(c-b)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }

}


Measured memory_bytes: 23636
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String S = sc.next();
            if(S.equals("-")) break;
            int m = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < m; i++) {
                sum += sc.nextInt();
            }
            int result = sum % S.length();
            System.out.println(S.substring(result)+S.substring(0, result));
        }
    }
}


Measured memory_bytes: 26348
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeSet<Integer> t = new TreeSet<Integer>();
        for (int i = 1; i <= n; i++) {
            t.add(sc.nextInt());
        }
        System.out.println(t.size());
    }
}


Measured memory_bytes: 36084
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep2(i, j, n) for (LL i = j; i <= n; ++i)
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define boost cin.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 110;

int n, m;
int dp[N][N];
char s[N][N];

int main() {
	scanf ("%d%d", &n, &m);
	rep(i, 1, n) scanf ("%s", s[i] + 1);
	dp[1][1] = (s[1][1] == '#');
	rep(i, 1, n) rep(j, 1, m) {
		if (i != 1 || j != 1) dp[i][j] = 1000000;
		if (i > 1) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (s[i][j] != s[i - 1][j] && s[i][j] == '#'));
		if (j > 1) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (s[i][j] != s[i][j - 1] && s[i][j] == '#'));
	}
	printf ("%d\n", dp[n][m]);
	
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a;
	int b;
	int c;
	int d;
	int e;
	int k;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	scanf("%d",&k);
    
    if(e-a>k){
    	printf(":(");
    }else{
    	printf("Yay!");
    }

    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
	string S;
	int a;
	cin>>S;
	a=0;
	if( S[0]=='+' ){
	    a+=1;
	}else{                                                            // 変更点
	    a-=1;
	}

	if( S[1]=='+' ){
	    a+=1;
	}else{                                                            // 変更点
	    a-=1;
	}

	if( S[2]=='+' ){
	    a+=1;
	}else{                                                            // 変更点
	    a-=1;
	}

	if( S[3]=='+' ){
	    a+=1;
	}else{                                                            // 変更点
	    a-=1;
	}

	cout<<a<<endl;
 // prints !!!Hello World!!!
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = long.Parse(input.ReadLine());

        long max = 1;
        for(long i=2; i<=(long)Math.Sqrt(n); i += 1) {
            if(n % i == 0)
                max = Math.Max(max, i);
        }
        var a = max;
        var b = n/max;

        return Math.Max(a.ToString().Length, b.ToString().Length);
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11092
n,c,k = map(int,input().split())
t = []
for i in range(n):
    t.append(int(input()))
    
t = sorted(t)
bus = []
ans = 1
for i in range(n):
    if len(bus) < c: #バスの定員に余裕があるとき
        if not bus:#バスに誰も乗っていなかったらバスに人を乗せる
            bus.append(t[i])
        elif t[i] <= bus[0] + k:#バスに初めて人が乗った時刻にkを足して、それよりt[i]が小さければバスに乗せる
            bus.append(t[i])
        else:#上記のelifを満たさない場合
            ans +=1
            bus = []
            bus.append(t[i])
    elif len(bus) == c:
        ans +=1
        bus = []
        bus.append(t[i])
    else:
        ans +=1
        bus = []
print(ans)

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

int main(){
    int X, K = 1, fac;
    scanf("%d", &X);
    
    fac = X;
    while(fac % 360){
        ++K;
        fac += X;
    }
    
    printf("%d\n", K);
    return 0;
}

Measured memory_bytes: 3756
#include<stdio.h>
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	long long int a[100005];
	int i;
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	long long int r[100005], l[100005];
	l[0] = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] > 0)
			l[i + 1] = l[i] + a[i];
		else
			l[i + 1] = l[i];
	}
	r[n] = 0;
	for (i = n - 1; i >= 0; i--)
	{
		if (a[i] > 0)
			r[i] = r[i + 1] + a[i];
		else
			r[i] = r[i + 1];
	}
	long long int ans = 0, v = 0;
	for (i = 0; i < k; i++)
		v += a[i];
	a[n] = 0;
	for (i = 0; i <= n - k; i++)
	{
		if (v > 0)
		{
			if (ans < v + l[i] + r[i + k])
				ans = v + l[i] + r[i + k];
		}
		else
		{
			if (ans < l[i] + r[i + k])
				ans = l[i] + r[i + k];
		}
		v -= a[i];
		v += a[i + k];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
# coding: utf-8
# Your code here!
s = list(input())
K = int(input())
K -= 1
for i in range(int(len(s))):
    if int(i) == K:
        print(s[int(i)])
        break
    if s[int(i)] == '1': continue
    else:
        print(s[int(i)])
        break
    
    

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> e[n]; //to,weight
    for(int k=0; k<n-1; k++){
        int i,j,w;
        cin >> i >> j >> w;
        pair <int,int> edge1(j-1,w);
        e[i-1].push_back(edge1);
        pair <int,int> edge2(i-1,w);
        e[j-1].push_back(edge2);
    }
    int ans[n]={0};
    queue<pair<int,int>> que;  //from,now pos
    pair<int,int> start(0,0);
    que.push(start);
    while(!que.empty()){
        pair<int,int> now = que.front();
        que.pop();
        for(auto p = e[now.second].begin();
                p != e[now.second].end(); p++){
            if((*p).first != now.first){
                if((*p).second % 2 == 0) ans[(*p).first] =ans[now.second];
                else if(ans[now.second]==0) ans[(*p).first] = 1;
                else ans[(*p).first] = 0;
                pair<int,int> next(now.second,(*p).first);
                que.push(next);
            }
        }
    }
    for(int i=0; i<n; i++){
        cout << ans[i] << endl;;
    }
    return 0;
}


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

int N,M;
int S,T;
vector<pair<int,ll>> g[100010];
ll dist[100010];
#define INF 1e16

void dijkstra(){
    priority_queue<pair<ll,int>> PQ;
    for(int i=0;i<N;i++) dist[i]=INF;
    dist[S]=0;
    PQ.push(make_pair(0,S));
    
    while(PQ.size()){
        pair<ll,int> tp=PQ.top();
        PQ.pop();
        int now=tp.second;
        if(dist[now]<tp.first*(-1)) continue;

        for(int i=0;i<g[now].size();i++){
            int next=g[now][i].first;

            if(dist[now]+g[now][i].second<dist[next]){
                dist[next]=dist[now]+g[now][i].second;
                PQ.push(make_pair(dist[next]*(-1),next));
            }
        }
    }
    return;
}

int main(){
  cin>>N>>M;
  cin>>S>>T;
  S--;
  T--;
  for(int i=0;i<M;i++){
      int u,v,d;
      cin>>u>>v>>d;
      u--;
      v--;
      g[u].push_back(make_pair(v,d));
      g[v].push_back(make_pair(u,d)); 
  }

  dijkstra();
  vector<pair<ll,int>> d;
  for(int i=0;i<N;i++){
      if(dist[i]>dist[T]) continue;
      d.push_back(make_pair(dist[i],i));
  }
  sort(d.begin(),d.end());

  ll dp1[N+1]={},dp2[N+1]={};
  dp1[S]=1;
  dp2[T]=1;
  for(int i=0;i<d.size();i++){
      int now=d[i].second;
      for(int j=0;j<g[now].size();j++){
          int next=g[now][j].first;
          if(dist[now]+g[now][j].second==dist[next]){
              dp1[next]=(dp1[next]+dp1[now])%MOD;
          }
      }
  }

  reverse(d.begin(),d.end());
  for(int i=0;i<d.size();i++){
      int now=d[i].second;
      for(int j=0;j<g[now].size();j++){
          int back=g[now][j].first;
          if(dist[now]==g[now][j].second+dist[back]){
              dp2[back]=(dp2[back]+dp2[now])%MOD;
          }
      }
  }

  ll ans=(dp1[T]*dp1[T])%MOD;
  for(int i=0;i<N;i++){
      if(dist[i]*2==dist[T]){
          ll dec=dp1[i]*dp1[i]%MOD*dp2[i]%MOD*dp2[i]%MOD;
          ans=ans-dec;
          ans=(ans+MOD)%MOD;
      }
  }

  for(int i=0;i<N;i++){
      for(int j=0;j<g[i].size();j++){
          int next=g[i][j].first;
          if(dist[i]*2<dist[T]&&dist[next]*2>dist[T]){
              if(dist[i]+g[i][j].second!=dist[next]) continue;
              ll dec=dp1[i]*dp1[i]%MOD*dp2[next]%MOD*dp2[next]%MOD;
              ans=ans-dec;
              ans=(ans+MOD)%MOD;
          }
      }
  }
  cout<<(ans+MOD)%MOD<<endl;


  return 0;
}


Measured memory_bytes: 17064
#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 ALL(v) v.begin(), v.end()
 
using namespace std;
 
auto main() -> int
{
   int N;  cin >> N;
   vector<int> A(N);
   
   REP(i, N) cin >> A[i]; 
   sort(A.begin(), A.end());
   
   if(unique(A.begin(), A.end()) == A.end())  cout << "YES" << endl;
   else cout << "NO" << endl;
   
   
   
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<int> cnt(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		cnt[u] ^= 1;
		cnt[v] ^= 1;
	}
	int ok = 1;
	for (auto t : cnt) {
		ok &= (!t);
	}
	if (ok) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
}

Measured memory_bytes: 3148
package main

import "fmt"

func main() {
	var n int
	var s1, s2, ans string
	fmt.Scan(&n)
	fmt.Scan(&s1)
	fmt.Scan(&s2)
	for i := 0; i < n; i++ {
		var string1 = string(s1[i])
		var string2 = string(s2[i])
		ans += string1 + string2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const int mod = 1e9+7;
const int mx = 1e5+7;
int n,K,a[mx];
LL fk[mx],pre[mx];
LL qpow(LL a, LL n){
    LL ret = 1;
    while(n > 0){
        if(n&1) ret = ret*a%mod;
        a = a*a%mod;
        n >>= 1;
    }
    return ret;
}

inline LL inv(LL x){
    return qpow(x,mod-2);
}


void init(int K){
    fk[K] = 1;
    for(int i = K+1; i <= n; i++)
        fk[i] = fk[i-1]*i%mod*inv(i-K)%mod;
}

LL suf_pre(int x){
    return  (((pre[n] - pre[n-x]) - pre[x])%mod + mod)%mod;
}
int main(){
    scanf("%d%d",&n,&K);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+n);
    for(int i = 1; i <= n; i++) pre[i] = (pre[i-1] + a[i])%mod;
    if(K == 1){
        printf("0\n");
        return 0;
    }

    init(K-2);
    LL ans = 0;
    for(int i = K; i <= n; i++){
        ans += fk[i-2]*suf_pre(n-i+1)%mod;
        ans %= mod;
    }
    printf("%lld\n",ans);
    return 0;
}


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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef rsd511
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    #endif
    #ifndef rsd511
    #define trace(...) {}
    #define cotra(...) {}
    #endif
} 

// Code Here

int main()
{
    Fast_IO();
    ll n; cin >> n;
    if(n % 1000 == 0) cout << 0;
    else {
    	ll pay = (n / 1000 + 1) * 1000;
    	cout << pay - n;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(void){
	int n,m,x;
	scanf("%d %d %d",&n,&m,&x);
	int i=0;
	int a[101]={0};
	for(i=0;i<m;i++){
		int temp;
		scanf("%d",&temp);
		a[temp] = 1;
	}
	int ans1 = 0;
	int ans2 = 0;
	//xから左に向かう場合
	for(i=x;i>0;i--){
		if( a[i] ==1){
			ans1++;
		}
	}
	for(i=x;i<n;i++){
		if(a[i] ==1){
			ans2++;
		}
	}
	if(ans1>ans2){
		printf("%d",ans2);
		return 0;
	}else{
		printf("%d",ans1);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

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

    LL n;
    cin >> n;

    vector<LL> vec(n);

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

    LL bai4 = 0;
    LL bai2 = 0;
    LL notbai = 0;

    for(int i = 0; i < n; i++){
        if(vec[i]%4 == 0){
            bai4++;
        }else if(vec[i]%2 == 0){
            bai2++;
        }else{
            notbai++;
        }
    }
    
    if(bai2 == 0){
        if(notbai <= bai4 + 1){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        if(notbai <= bai4){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define ll long long int
#include <queue>
#include <vector>
#include <iostream>
using namespace std;

int main(){
  int n,k,tinggi,count;
  count=0;
cin>>n>>k;
for(int i=n;i>0;i--){
cin>>tinggi;
if(tinggi>=k)
count+=1;

}
cout<<count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B,X;
  cin >> N >> A >> B;
  X = N * A;
  
  if ( X > B){
    cout << B << endl;
  }
  else if ( X < B ){
    cout << X << endl;
  }
  else{
    cout << B << endl;
  }
}

Measured memory_bytes: 3620
#include <cstdio>
#include <map>
#include <vector>
#include <queue>
#include <utility>
#include <cstring>
using namespace std;
typedef pair<int, int> pii;

const int S = 1000;
int sx[60], sy[60], tx[60], ty[60];
int board[S+10][S+10], used[S+10][S+10];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int main() {
    while(1) {
        memset(used, 0, sizeof(used));
        memset(board, 0, sizeof(board));
        int N; scanf("%d", &N);
        if(!N) break;

        map<int, int> mpx, mpy;
        for(int i=0; i<N; i++) {
            scanf("%d%d%d%d", &sx[i], &sy[i], &tx[i], &ty[i]);
            swap(sy[i], ty[i]);
            sx[i] *= 2, sy[i] *= 2, tx[i] *= 2, ty[i] *= 2;
            for(int k=-1; k<=1; k++) {
                int ssx = sx[i] + k, ssy = sy[i] + k;
                int ttx = tx[i] + k, tty = ty[i] + k;
                mpx[ssx]++; mpy[ssy]++;
                mpx[ttx]++; mpy[tty]++;
            }
        }

        int idx = 0, idy = 0;
        for(auto &x : mpx) {
            x.second = idx++;
        }
        for(auto &y : mpy) {
            y.second = idy++;
        }

        for(int i=0; i<N; i++) {
            int ux = mpx[sx[i]], uy = mpy[sy[i]];
            int vx = mpx[tx[i]], vy = mpy[ty[i]];
            for(int x=ux; x<=vx; x++) {
                board[x][uy] = board[x][vy] = 1;
            }
            for(int y=uy; y<=vy; y++) {
                board[ux][y] = board[vx][y] = 1;
            }
        }

        long long int ans = 0;
        for(int i=0; i<idx; i++) {
            for(int j=0; j<idy; j++) {
                if(used[i][j] || board[i][j] == 1) continue;
                ans++;
                used[i][j] = true;

                queue<pii> que;
                que.push(make_pair(i, j));

                while(que.size()) {
                    pii cur = que.front(); que.pop();
                    int x = cur.first, y = cur.second;
                    for(int k=0; k<4; k++) {
                        int nx = x + dx[k], ny = y + dy[k];
                        if(nx < 0 || nx >= idx || ny < 0 || ny >= idy) continue;
                        if(board[nx][ny] == 1 || used[nx][ny]) continue;
                        used[nx][ny] = true;
                        que.push(make_pair(nx, ny));
                    }
                }
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int t, a, b; cin >> a >> b >> t;
    cout << (t / a) * b << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

char str[100005];
char bg[200005], ed[200005];

void output(char a[], int n, int op)
{
    if(op)
    {
        for(int i = n - 1; i >= 0; i--) putchar(a[i]);
    }
    else
    {
        for(int i = 0; i < n; i++) putchar(a[i]);
    }
    
}

int main()
{
    //freopen("a.in", "r", stdin);

    int q, bg_p = 0, ed_p = 0, reversed = 0;
    scanf("%s", str);
    scanf("%d", &q);
    while(q--)
    {
        int t, f; char c;
        scanf("%d", &t);
        if(t == 1)
        {
            reversed ^= 1;
            continue;
        }
        scanf("%d %c", &f, &c);
        if(reversed ^ (f - 1)) ed[ed_p++] = c;
        else bg[bg_p++] = c;
    }

    if(reversed)
    {
        output(ed, ed_p, 1);
        output(str, strlen(str), 1);
        output(bg, bg_p, 0);
    }
    else
    {
        output(bg, bg_p, 1);
        printf("%s", str);
        output(ed, ed_p, 0);
    }
    
    
    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

ll gcd (ll a, ll b){ return b == 0? a : gcd(b, a % b); }
ll lcm (ll a, ll b){ return a * (b / gcd(a, b));}

int main(){
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }

    ll ans = a[0];
    for(ll i=1; i< n; i++){
        ans = lcm(a[i], ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 1e9 + 5; 
int main(){
	int n;
scanf("%d", &n);
	vector<int>dp(3);
	for(int d=0;d<n;d++){
		vector<int>a(3);
		vector<int>new_dp(3,0);
		for(int i=0;i<3;i++){
			scanf("%d",&a[i]);
		}
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(i!=j){
					new_dp[j]=max(new_dp[j],dp[i]+a[j]);
				}
			}
		}
		dp=new_dp;
	}
	printf("%d\n", max({dp[0], dp[1], dp[2]}));
	
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int N,M,X;
    cin >> N >> M >> X;
    int left=0,right=0;
    for(int i=0; i<M; i++){
        int tmp;
        cin >> tmp;
        if(tmp<X) left++;
        else right++;
    }
    cout << min(right, left);


    return 0;
}

Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut a = vec![];
	let mut b = vec![];
	for _ in 0..n {
		let ai: i32 = s.next().unwrap().parse().unwrap();
		let bi: i32 = s.next().unwrap().parse().unwrap();
		a.push(ai);
		b.push(bi);
	}
	a.sort();
	b.sort();
	let (l, r) = if n % 2 == 0 {
		(a[n / 2 - 1] + a[n / 2], b[n / 2 - 1] + b[n / 2])
	} else {
		(a[n / 2], b[n / 2])
	};
	println!("{}", r - l + 1);
}


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

using namespace std;

void solve() {
  int n;
  cin >> n;

  unordered_map<string, int> counts;
  int max_count = 0;

  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    max_count = max(max_count, ++counts[s]);
  }

  set<string> words;
  for (auto&& p : counts) {
    if (p.second == max_count) {
      words.emplace(p.first);
    }
  }

  for (auto&& word : words) {
    cout << word << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}



Measured memory_bytes: 32072
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	long a = read.to!long;
	long b = read.to!long;
	long c = read.to!long;
	
	long ans;
	if(c > a + b + 1) ans = b + (a + b + 1);
	else ans = b + c;
	
	ans.writeln;
	
	
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

int main() {
	string S; cin >> S;
	vector<int> list;
	for(char c: S) {
		if(c == 'B') {
			if(list.size() > 0) list.pop_back();
		}else{
			list.push_back(c-'0');
		}
	}
	for(int x: list) printf("%d", x);
	puts("");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n,v=1<<16;
  cin>>n;
  int h[n],w[n],dp[v],used[v];
  for(int i=0;i<n;i++) cin>>h[i]>>w[i];
  string s[4],c="RGB";;
  for(int i=0;i<4;i++) cin>>s[i];
  memset(dp,-1,sizeof(dp));
  memset(used,0,sizeof(used));
  queue<P> q;
  q.push(P(0,0));
  while(!q.empty()){
    int bit=q.front().first,d=q.front().second;
    q.pop();
    if(~dp[bit]) continue;
    dp[bit]=d;
    for(int i=0;i<n;i++)
      for(int j=-h[i]+1;j<4;j++)
	for(int k=-w[i]+1;k<4;k++)
	  for(int l=0;l<3;l++){
	    int z=bit;
	    for(int a=max(0,-j);a<min(h[i],4-j);a++){
	      for(int b=max(0,-k);b<min(w[i],4-k);b++){
		int y=j+a,x=k+b;
		if(s[y][x]==c[l]) z|=1<<(y*4+x);
		else z&=v-1-(1<<(y*4+x));
	      }
	    }
	    if(dp[z]<0&&!used[z]) q.push(P(z,d+1)),used[z]=1;
	  }
  }
  cout<<dp[v-1]<<endl;
  return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
#include<string.h>

int a[200001];
int b[200001];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=2;i<=n;i++) scanf("%d",&a[i]);
    for(int i=2;i<=n;i++) b[a[i]]++;
    for(int i=1;i<=n;i++) printf("%d\n",b[i]);
}

Measured memory_bytes: 3236
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<ArrayList<Integer>> graph = new ArrayList<>();
		for (int i = 0; i < n; i++) {
		    graph.add(new ArrayList<>());
		}
		for (int i = 0; i < m; i++) {
		    graph.get(sc.nextInt() - 1).add(sc.nextInt() - 1);
		}
		double[] dp = new double[n];
		for (int i = n - 2; i >= 0; i--) {
		    for (int x : graph.get(i)) {
		        dp[i] += (dp[x] + 1) / graph.get(i).size();
		    }
		}
		double min = dp[0];
		for (int i = 0; i < n; i++) {
		    if (graph.get(i).size() <= 1) {
		        continue;
		    }
		    dp[i] = 0;
		    double max = 0;
		    for (int x : graph.get(i)) {
		        max = Math.max(max, dp[x] + 1);
		        dp[i] += dp[x] + 1;
		    }
		    dp[i] -= max;
		    dp[i] /= graph.get(i).size() - 1;
		    for (int j = i - 1; j >= 0; j--) {
		        dp[j] = 0;
		        for (int x : graph.get(j)) {
		            dp[j] += (dp[x] + 1) / graph.get(j).size();
		        }
		    }
		    min = Math.min(min, dp[0]);
		}
		System.out.println(min);
    }
}


Measured memory_bytes: 63440
p=[11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451, 1471, 1481, 1511, 1531, 1571, 1601, 1621, 1721, 1741, 1801, 1811, 1831, 1861, 1871, 1901, 1931, 1951, 2011, 2081, 2111, 2131, 2141, 2161, 2221, 2251, 2281, 2311, 2341, 2351, 2371, 2381, 2411, 2441, 2521, 2531, 2551, 2591, 2621, 2671, 2711, 2731, 2741, 2791, 2801, 2851, 2861, 2971, 3001, 3011, 3041, 3061, 3121, 3181, 3191, 3221, 3251, 3271, 3301, 3331, 3361, 3371, 3391, 3461, 3491, 3511, 3541, 3571, 3581, 3631, 3671, 3691, 3701, 3761, 3821, 3851, 3881, 3911, 3931, 4001, 4021, 4051, 4091, 4111, 4201, 4211, 4231, 4241, 4261, 4271, 4391, 4421, 4441, 4451, 4481, 4561, 4591, 4621, 4651, 4691, 4721, 4751, 4801, 4831, 4861, 4871, 4931, 4951, 5011, 5021, 5051, 5081, 5101, 5171, 5231, 5261, 5281, 5351, 5381, 5431, 5441, 5471, 5501, 5521, 5531, 5581, 5591, 5641, 5651, 5701, 5711, 5741, 5791, 5801, 5821, 5851, 5861, 5881, 5981, 6011, 6091, 6101, 6121, 6131, 6151, 6211, 6221, 6271, 6301, 6311, 6361, 6421, 6451, 6481, 6491, 6521, 6551, 6571, 6581, 6661, 6691, 6701, 6761, 6781, 6791, 6841, 6871, 6911, 6961, 6971, 6991, 7001, 7121, 7151, 7211, 7321, 7331, 7351, 7411, 7451, 7481, 7541, 7561, 7591, 7621, 7681, 7691, 7741, 7841, 7901, 7951, 8011, 8081, 8101, 8111, 8161, 8171, 8191, 8221, 8231, 8291, 8311, 8431, 8461, 8501, 8521, 8581, 8641, 8681, 8731, 8741, 8761, 8821, 8831, 8861, 8941, 8951, 8971, 9001, 9011, 9041, 9091, 9151, 9161, 9181, 9221, 9241, 9281, 9311, 9341, 9371, 9391, 9421, 9431, 9461, 9491, 9511, 9521, 9551, 9601, 9631, 9661, 9721, 9781, 9791, 9811, 9851, 9871, 9901, 9931, 9941]
n=gets.to_i
for k in 0...n-1
print("#{p[k]} ")
end
print("#{p[n]}")

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int n,pa[100005],k,ans;
vector<int>g[100005];
int dfs(int v,int p){
    int d=0;
    for(int i=0;i<g[v].size();i++){
        int u=g[v][i];
        if(u!=p){
            d=max(d,dfs(u,v)+1);
        }
    }
    if(v==0)return 0;
    if((d==k-1&&pa[v]!=0)||(pa[v]==0&&d==k)){
        ans++;
        return -1;
    }else return d;
}
int main(void){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",pa+i);
        pa[i]--;
        if(i==0){
            if(pa[i]!=0)ans++;
        }else g[pa[i]].push_back(i);
    }
    dfs(0,-1);
    printf("%d\n",ans);
}

Measured memory_bytes: 13952
#include<iostream>

using namespace std;

int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  while(op != '?'){
    if(op == '+'){
      cout << a + b << endl;
    }else if(op == '-'){
      cout << a - b << endl;
    }else if(op == '*'){
      cout << a * b << endl;
    }else{
      cout << a / b << endl;
    }
    cin >> a >> op >> b;
  }
  return 0;
}



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

int main(){
    map<string,int>M;
    string in,ma,ma2;
    while(cin>>in){
        M[in]++;
        if(ma.size()<in.size())ma=in;
    }
    int ma3=0;
    for(map<string,int>::iterator it=M.begin();it!=M.end();it++){
        if(ma3<it->second){
            ma3=it->second;
            ma2=it->first;
        }
    }
    cout<<ma2<<" "<<ma<<endl;

    return 0;
}

Measured memory_bytes: 1196
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    h1, m1, h2, m2, k = [int(x) for x in input().strip().split()]
    t1 = 60 * h1 + m1
    t2 = 60 * h2 + m2
    if t2 < t1:
        t2 = 60 * (h2 + 24) + m2
    print(t2 - t1 - k)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
#include <iostream>
#include <map>
#include <cmath>

using namespace std;

#define L 998244353

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  long long d[N];
  for (int i = 0; i < N; ++i)
    cin >> d[i];

  if (d[0] != 0) {
    cout << "0" << endl;
    return 0;
  }


  map<long long, long long> m;
  long long max_v = 0;
  for (int i = 0; i < N; ++i) {
    if (m.find(d[i]) == m.end())
      m[d[i]] = 0;
    ++m[d[i]];
    max_v = max(d[i], max_v);
  }

  if (m[0] > 1) {
    cout << 0 << endl;
    return 0;
  }

  long long ret = 1;
  for (long long i = 1; i <= max_v; ++i) {
    if (m.find(i) == m.end()) {
      cout << 0 << endl;
      return 0;
    }
    for (int j = 0; j < m[i]; ++j) {
      ret *= m[i - 1];
      ret %= 998244353;
    }
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 7296
fun main(args: Array<String>) {
    val (a, b, c) = readLine()!!.split(" ")
    val result = if (a == b) {
        if (b == c) 1 else 2
    } else if (b == c || c == a) {
        2
    } else {
        3
    }
    println(result)
}


Measured memory_bytes: 36056
// ctrl+shift+b
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, T, A; cin >> N >> T >> A;
    double ans = (double) INF;
    ll ind = -1;
    rep(i, N){
        ll h; cin >> h;
        double tmp = abs(T - 0.006 * h - A);
        if (tmp < ans){ans = tmp; ind = (i + 1);}
    }
    cout << ind << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3532