akhauriyash/Code-Regression huggingface dataset:
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
import sys
input = sys.stdin.readline

def main():
    INF = float("Inf")
    n,m,l = map(int, input().split())
    G = [[INF]*n for i in range(n)]
    for i in range(n):
        G[i][i] = 0
    for i in range(m):
        a,b,c = map(int, input().split())
        a,b = a-1,b-1
        if c <= l:
            G[a][b] = G[b][a] = c
    G = floyd_warshall(G, directed=False)
    G = np.where(G <=l, 1, INF)
    for i in range(n):
        G[i][i] = 0
    GG = floyd_warshall(G, directed=False)

    q = int(input())
    ans = []
    for i in range(q):
        s,t = map(int, input().split())
        a = GG[s-1][t-1]
        if a == INF:
            a = 0
        else:
            a = int(a)
        ans.append(a-1)
    print(*ans, sep="\n")

if __name__ == "__main__":
    main()

Measured memory_bytes: 18860
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;

    vector<int> block(n);
    for(int i = 0;i < n;i++){
        cin >> block.at(i);
    }

    int count=0;
    int num = 1;
    for(int i = 0; i < n;i++){
        if(num == block.at(i)){
            count++;
            num++;
        }
    }

    if(count == 0){
        cout << "-1" << endl;
    }else{
        cout << n-count << endl;
    }
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define qwq (cerr<<"qwq"<<endl)
#define orz(x) (cerr<<#x": "<<x<<endl)
#define orzarr(a,n) {cerr<<#a": "; repeat(__,0,n)cerr<<(a)[__]<<" "; cerr<<endl;}
#define orzeach(a) {cerr<<#a": "; for(auto __:a)cerr<<__<<" "; cerr<<endl;}
#define fi first
#define se second
typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;}
typedef double lf; typedef long double llf; const lf err=1e-11; const lf pi=acos(-1); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;}
typedef pair<int,int> pii; template<typename A,typename B> ostream &operator<<(ostream &o,const pair<A,B> &x){return o<<'('<<x.fi<<','<<x.se<<')';}
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010;
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
//#define int ll
int n,m;
ll a[N],cnt[N];
ll ans=0;
void add(int x,int d){
	ans-=cnt[x]*(cnt[x]-1)/2;
	cnt[x]+=d;
	ans+=cnt[x]*(cnt[x]-1)/2;
}
signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	repeat(i,0,n)cin>>a[i],add(a[i],1);
	repeat(i,0,n){
		add(a[i],-1);
		cout<<ans<<endl;
		add(a[i],1);
	}
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstdlib>
using namespace std;
typedef long long ll;
int main(){
  int N,M;
  cin >> N >> M;
  vector<ll> A(N);
  for(int i = 0;i < N;i++)cin >> A[i];

  vector<pair<ll,ll>> op(M);

  for(int i = 0;i < M;i++){
    ll B,C;
    cin >> B >> C;
    op[i] = make_pair(C,B);
  }

  sort(A.begin(),A.end());
  sort(op.begin(),op.end(),greater<pair<ll,ll>>());

  ll ans = 0;
  ll now_pos = 0;
  for(int i = 0;i < M;i++){
    auto lb = lower_bound(A.begin()+now_pos,A.end(),op[i].first);
    ll num_of_lower = lb - (A.begin()+now_pos);
    now_pos += min(op[i].second,num_of_lower);
    ans += min(op[i].second,num_of_lower) * op[i].first;
  }

  for(int i = now_pos;i < N;i++)ans += A[i];

  cout << ans << endl;


}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<queue>
#define MAX 10000
int INF=(1<<20), WH=0, GR=1, BL=2;
int n;
std::vector<std::pair<int,int> > adj[MAX];
void dij(void);
int main(){
  int k, u, v, c;
  std::cin >> n;
  for(int i=0; i<n; i++){
    std::cin >> u >> k;
    for(int j=0; j<k; j++){
      std::cin >> v >> c;
      adj[u].push_back(std::make_pair(v,c));
    }
  }
  dij();
  return 0;
}
void dij(void){
  std::priority_queue<std::pair<int,int> > PQ;
  int color[MAX], d[MAX];
  for(int i=0; i<n; i++) d[i] = INF, color[i] = WH;
  d[0] = 0;
  PQ.push(std::make_pair(0,0));
  color[0] = GR;
  while(!PQ.empty()){
    std::pair<int,int> f=PQ.top(); PQ.pop();
    int u=f.second;
    color[u] = BL;
    if(d[u] < f.first * (-1)) continue;
    for(int j=0; j<adj[u].size(); j++){
      int v=adj[u][j].first;
      if(color[v] == BL) continue;
      if(d[v] > d[u] + adj[u][j].second){
	d[v] = d[u] + adj[u][j].second;
	PQ.push(std::make_pair(d[v]*(-1),v));
      }
    }
  }
  for(int i=0; i<n; i++) std::cout << i << " " << (d[i] == INF ? -1 : d[i]) << std::endl;
}

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

int main(){
    string s;
    cin >> s;
    int si = (int)s.size();
    if(si % 2 == 1) cout << "No" << endl;
    else{
        for(int i = 0; i < si; i+=2){
            if(s[i] != 'h' || s[i+1] != 'i'){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var: ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        mut a: [i64; 5],
        k: i64,
    }
    a.sort();
    let ans = if (a[4] - a[0]) <= k { "Yay!" } else { ":(" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
int nums[200004],numt[200004];
string s,t;
int mojis[40],mojit[40];
int main(){
	cin>>s>>t;
	int c=1;
	for(int i=0;i<s.size();i++){
		if(!mojis[s[i]-'a']){
			mojis[s[i]-'a']=c;
			c++;
		}
		nums[i]=mojis[s[i]-'a'];
	}
	c=1;
	for(int i=0;i<s.size();i++){
		if(!mojit[t[i]-'a']){
			mojit[t[i]-'a']=c;
			c++;
		}
		numt[i]=mojit[t[i]-'a'];
	}
	for(int i=0;i<s.size();i++){
		if(nums[i]!=numt[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}




Measured memory_bytes: 2312
#include<stdio.h>
int main(){
	int n;
	int a[1000];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int count=0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[k]+a[i]>a[j] && a[i]!=a[j] &&a[i]!=a[k] && a[j]!=a[k]){
					count++;
//					printf("%d  %d  %d\n",a[i],a[j],a[k]);
				}
			}
		}
	}
	printf("%d\n",count);
}

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

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	int ans=0;
	while (n>0)
	{
		n/=k;
		++ans;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#include<string.h>
#include<math.h>
int main()
{
    ll a,b,c,d,i,test,j,k;
    cin>>a;
    for(i=a;i<=10000000;i++)
    {
        b=i;
        c=0;
        for(j=2;j<=sqrt(b);j++)
        {
            if(b%j==0){c=1;break;}
        }
        if(c==0){cout<<b<<endl;break;}
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> x,y;
    for(int i = 0;i < n;i++)
    {
        int t;
        cin >> t;
        x.push_back(t);
    }
    for(int i = 0;i < n;i++)
    {
        int t;
        cin >> t;
        y.push_back(t);
    }
    double d1 = 0;
    double d2 = 0;
    double d3 = 0;
    int d4 = 0;
    for(int i = 0;i < n;i++)
    {
        d1 += abs(x[i] - y[i]);
        d2 += abs(x[i] - y[i]) * abs(x[i] - y[i]);
        d3 += abs(x[i] - y[i]) * abs(x[i] - y[i]) * abs(x[i] - y[i]);
        if(abs(x[i] - y[i]) > d4)
        {
            d4 = abs(x[i] - y[i]);
        }
    }
    cout << fixed << setprecision(8) << d1 << endl << sqrt(d2) << endl << cbrt(d3) << endl << (double)d4 << endl;
}

Measured memory_bytes: 1308
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
    int a, b;
    cin >> a >> b;
    if(a == b){
        puts("0");
    }else if((a + b) % 2 == 0){
        cout << (a + b) / 2 << endl;
    }else{
        puts("IMPOSSIBLE");
    }
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, int> pi;
typedef long long lint;
const int MAXN = 100005;

int n;
int cnt[16], arr[MAXN];
int dp[MAXN];

int bfs(int msk){
	for(int i=1; i<(1<<16); i++){
		int ans = 0;
		dp[i] = -1e9;
		for(int j=0; j<16; j++){
			if((i >> j) & 1) ans ^= j;
		}
		if(ans == 0) dp[i] = 1;
		for(int j=i; j>0; j=(j-1)&i){
			dp[i] = max(dp[j] + dp[i^j], dp[i]);
		}
	}
	int ans = 0;
	for(int i=0; i<16; i++) if((msk >> i) & 1) ans++;
	return ans - dp[msk];
}

int main(){
	scanf("%d",&n);
	for(int i=0; i<n-1; i++){
		int s, e, x;
		scanf("%d %d %d",&s,&e,&x);
		arr[s] ^= x;
		arr[e] ^= x;
	}
	for(int i=0; i<n; i++) cnt[arr[i]]++;// printf("%d\n", arr[i]);
	int msk = 0, ans = 0;
	for(int i=1; i<16; i++){
		ans += cnt[i] / 2;
		if(cnt[i] & 1) msk |= (1 << i);
	}
	cout << ans + bfs(msk) << endl;
}


Measured memory_bytes: 1024
def resolve():
    N,M = map(int,input().split())
    AB = []
    for i in range(N):
        a = list(map(int,input().split()))
        AB.append(a)
    AB.sort()
    yen,sum = 0,0
    for i in range(N):
        tmp = min(AB[i][1],M-sum)
        yen += tmp*AB[i][0]
        sum += tmp
        if (sum>=M):
            break
    print(yen)
resolve()


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

int main(){
    vector<int> A(9);
    int i, j, k;
    for(i=0;i<9;i++){
            cin >> A[i];
    };
    int N;
    cin >> N;
    vector<int> B(N);
    for(i=0;i<N;i++){
        cin >> B[i];
        for(j=0;j<9;j++){
            if(A[j] == B[i])
                A[j] = 0;
        }
    }
    if((A[0]==A[1] && A[1] == A[2]) || (A[3] == A[4] && A[4] == A[5]) || (A[6] == A[7] && A[7] == A[8]))
        cout << "Yes";
    else if((A[0] == A[3] && A[3]== A[6]) ||( A[1] == A[4] && A[4] == A[7]) || (A[2] == A[5] && A[5] == A[8]))
        cout << "Yes";
    else if((A[0] == A[4] && A[4] == A[8]) || A[2] == A[4] && A[4] == A[6])
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
maxPowerLow :: Int -> Int -> Int
maxPowerLow x b
  | b == 1    = 1
  | otherwise = last $ takeWhile (<= x) $ map (\y -> b^y) [2..]

bs :: Int -> [Int]
bs x = takeWhile (\b -> b^2 <= x) [1..]

solve :: Int -> Int
solve x = maximum $ map (maxPowerLow x) $ bs x

main :: IO ()
main = do
  x <- readLn
  print $ solve x

Measured memory_bytes: 508
#include <stdio.h>

int main()
{
	int N, M, s[6], c[6];
	scanf ("%d %d", &N, &M);
	for (int i = 0; i < M; i++) scanf ("%d %d", &s[i], &c[i]);

	int p = 1;
	for (int i = 1; i < N; i++) p *= 10;
	for (int d = p - (N == 1); d < p * 10; d++){
		char S[10];
		sprintf(S, "%d", d);
		int g = 0;
		for (int k = 0; k < M; k++){
			if (S[s[k] - 1] == c[k] + '0') g++;
		}
		if (g == M){
			puts(S);
			return 0;
		}
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 3216
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

bool solve() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    A.sort();
    auto a_min = A[0];
    auto a_max = A[$-1];
    auto cnt = new int[](110);
    foreach (a; A) cnt[a] += 1; 

    if (N == 2) return a_min == 1 && a_max == 1;
    if (a_min != a_max/2 + a_max%2) return false;
    if (cnt[a_max] < 2) return false;

    if (a_max % 2 == 0 && cnt[a_min] != 1) return false;
    if (a_max % 2 == 1 && cnt[a_min] != 2) return false;

    foreach (i; a_min+1..a_max) {
        if (cnt[i] < 2) return false;
    }

    
    return true;
}

void main() {
    writeln(solve ? "Possible" : "Impossible");
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	static int cnt;
	static char[][] map = new char[21][21];
	static int w,h;
	static int dfs(int y, int x, char[][] v){
		  int my[] = {-1,0,1,0};
		  int mx[] = {0,-1,0,1};
		  int ret = 1;
		  for(int i=0;i<4;i++){
			    int ny = y + my[i], nx = x + mx[i];
			    if(0<=ny&&ny<h&&0<=nx&&nx<w && v[ny][nx] == '.'){
			      v[ny][nx] = '#';
			      ret += dfs(ny, nx, v);
			    }
		  }
		  return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w+h==0)break;
			String[] str = new String[h];
			for(int i=0;i<h;i++){
				str[i] = sc.next();
				for(int j=0;j<w;j++){
					map[i][j] =str[i].charAt(j);
				}					
			}
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(map[i][j]=='@')System.out.println(dfs(i,j,map));
				}
			}
		}
		
	}

}

Measured memory_bytes: 29196
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	ll A,B,K;

	scanf("%lld %lld %lld",&A,&B,&K);

	if(A >= K){

		printf("%lld %lld\n",A-K,B);
	}else{

		K -= A;

		if(B > K){

			printf("0 %lld\n",B-K);
		}else{

			printf("0 0\n");
		}
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long ans = 0;
        if((a+b)%2 == 1){
            long min1 = Math.min(a-1,b-1);
            long max1 = Math.max(a-1,b-1);
            long minN = Math.min(n-a,n-b);
            long maxN = Math.max(n-a,n-b);
            ans = Math.min(min1 + (max1 - min1)/2 + (max1 - min1)%2 ,minN + (maxN - minN)/2 + (maxN - minN)%2);
        }else{
            ans = Math.abs((a-b)/2);
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 22868
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	fmt.Println(monster(a))
}

func monster(a []int) int {
	g := gcd(a[0], a[1])
	for i := 2; i < len(a); i++ {
		g = gcd(g, a[i])
	}
	return g
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


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

using namespace std;

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

	int32_t N;
	cin >> N;
	int32_t res = (N + 1) >> 1;
	cout << res << "\n";

	return 0;
}


Measured memory_bytes: 256
fn main(){
    let mut c1 = String::new();
    let mut c2 = String::new();
    let mut c3 = String::new();

    std::io::stdin().read_line(&mut c1);
    std::io::stdin().read_line(&mut c2);
    std::io::stdin().read_line(&mut c3);

    println!("{}{}{}",c1.remove(0),c2.remove(1),c3.remove(2));
}

Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int max = 1;
		int k = Math.min(a, b);
		
	for ( int i = 1; i <= k ;i++) {
		if(a % i == 0 && b % i == 0) 
			max = i;
	     }
	
	    if(c % max == 0) 
	    	System.out.println("YES");
	    else
	    	System.out.println("NO");
	    }
		
	
	}




Measured memory_bytes: 23508
#include <stdio.h>
int main(void){
    // Your code here!
   int N;
   int p[21],cp[21];
   int i,j,k;
   int memory,tmp;
   int count=0;
   scanf("%d\n",&N);
   
   for(i=1;N>=i;i++){
       scanf("%d",&p[i]);
        cp[i] = p[i];
   }
   
   for(j=1+1;N-1>=j;j++){
       p[j-1]=cp[j-1]; p[j]=cp[j]; p[j+1]=cp[j+1];
       memory = p[j];
       for(k=j;j+1>=k;k++){
           if(p[k-1]>p[k]){
               tmp = p[k-1];
               p[k-1] = p[k];
               p[k] = tmp;
           }
       }
       if(p[j-1]>p[j]){
            tmp = p[j-1];
            p[j-1] = p[j];
            p[j] = tmp;
       }
      // printf("%d:%d %d %d\n",j,p[j-1],p[j],p[j+1]);
       if(memory==p[j]) count++;
    }
    
    printf("%d\n",count);
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define SZ(x) ((int)(x).size())
#define PB push_back
template <typename T>
void Puts(T x) {
    cout << x << endl;
}
struct Node {
    vector<int> parents;
    vector<int> children;
    int value;
};
int main() {
    int n, m;
    cin >> n >> m;
    auto nodes = vector<Node>(n, Node{
                                     vector<int>(0),
                                     vector<int>(0),
                                     -1});
    rep(i, n - 1 + m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        nodes[a].children.PB(b);
        nodes[b].parents.PB(a);
    }
    auto current = 0;
    function<void(int)> dfs = [&](auto index) {
        auto &node = nodes[index];
        if (node.value != -1) return;
        for (auto &childIndex : node.children) {
            auto &child = nodes[childIndex];
            if (child.value == -1) {
                dfs(childIndex);
            }
        }
        node.value = current;
        current++;
    };
    rep(i, n) {
        dfs(i);
    };
    rep(i, n) {
        auto &node = nodes[i];
        auto &parents = node.parents;
        if (SZ(parents) == 0) {
            puts("0");
            continue;
        }
        auto minValue = INT_MAX;
        auto ans = 0;
        for (auto &parentIndex : parents) {
            auto &parent = nodes[parentIndex];
            if (parent.value < minValue) {
                ans = parentIndex + 1;
                minValue = parent.value;
            }
        }
        Puts(ans);
    }
}


Measured memory_bytes: 16768
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング


// func declaration
template <class T> void calcVec(vector<T>&, int, char);

void printVec(vector<int> &vec) {
    int N = vec.size();
    REP(i, N) {
        cout << vec.at(i);
        if (i < N - 1) cout << " ";
    }
    cout << endl;
}

int BubbleSort(vector<int> &vec) {
    int N = vec.size();
    int end = N - 1;
    int count = 0;
    REP(i, N) {
        for (int j = end; i + 1 <= j; --j) {
            if (vec.at(j - 1) > vec.at(j)) {
                swap(vec.at(j - 1), vec.at(j));
                // printVec(vec);
                count++;
            }
        }
    }
    return count;
}

int main() {
    // input
    int N;
    cin >> N;
    vector<int> vec(N);
    REP(i, N) cin >> vec.at(i);
    
    // output
    int count = BubbleSort(vec);
    printVec(vec);
    cout << count << endl;

    return 0;
}


// function
template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}



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

typedef long long ll;
const ll inf = 1e15;
const int len = 1e5;
int cost[20][20];
ll sum[len], dp[len];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            scanf("%d", &cost[i][j]);

    for (int bit = 0; bit < (1<<n); bit++){
        for (int i = 0; i < n; i++)
            for (int j = i+1; j < n; j++)
                if ((bit&(1<<i)) && (bit&(1<<j)))
                    sum[bit] += cost[i][j];
    }

    dp[0] = 0;
    for (int bit = 1; bit < (1<<n); bit++){
        dp[bit] = -inf;
        for (int cur = bit; cur > 0; cur = (cur-1)&bit)
            dp[bit] = max(dp[bit], dp[bit^cur]+sum[cur]);
    }

    printf("%lld\n", dp[(1<<n)-1]);
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
#define ll long long
ll s1[N],s2[N];
int main (){
	int n,k;scanf ("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		int x;scanf ("%d",&x);
		s1[i]=s1[i-1],s2[i]=s2[i-1];
		if (x>0) s1[i]+=x;else s2[i]-=x;
	}
	ll ans=s1[n],mn=1ll<<60ll;
	for (int i=1;i+k-1<=n;i++)
		mn=min(mn,min(s1[i+k-1]-s1[i-1],s2[i+k-1]-s2[i-1]));
	printf ("%lld",ans-mn);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

int a, b;

int main(){
    cin >> a >> b;

    if(a % 3 && b % 3 && (a + b) % 3){
        cout << "Impossible" << endl;
    }
    else {
        cout << "Possible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a, T b){return (a < b ? a = b, true : false);}
template<typename T>inline bool chmin(T &a, T b){return (a > b ? a = b, true : false);}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

const int MAX = 100010;
int N, C, K;
int T[MAX];

int main() {
    scanf("%d%d%d", &N, &C, &K);
    REP(i, N) {
        scanf("%d", T + i);
    }
    sort(T, T + N);
    int cnt = 0;
    int st = T[0];
    int noru = 1;
    FOR(i, 1, N) {
        if (T[i] > st + K || noru >= C) {
            ++cnt;
            st = T[i];
            noru = 1;
        } else {
            noru++;
        }
    }
    ++cnt;
    printf("%d\n", cnt);
}


Measured memory_bytes: 640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;



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

	string s;
	cin >> s;
	string t;
	long long int box = -1;
	long long int ten = pow(10, s.size());
	t = "0123456789";
	string ans;
	do {
		auto u = t.substr(0, s.size());
		long long int dif = min((long long int)abs(stoll(s) - stoll(u)), ten - abs(stoll(s) - stoll(u)));
	//	cout << dif << endl;
		if (dif > box) {
			box = dif;
			ans = u;
		}
	} while (next_permutation(t.begin(), t.end()));
	cout << ans << endl;
}


Measured memory_bytes: 3348
import java.util.Scanner;
public class Main {
		
		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			String s  = sc.next();
			int number = s.length();
			String abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
			for(int i = 0;i<number;i++) {
				int index = abc.indexOf(s.charAt(i));
				System.out.print(abc.charAt(index+n));
			}
			sc.close();
			}
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 25812
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ans(a,b) ((a)<(b)?(a):(b))

typedef struct seller{
    int a,b;
} seller;

int asc(const void *a, const void *b){
    return ((seller *)a)->a - ((seller *)b)->a;
}

int main(){
    int n,m;
    int i;
    long long int ans=0;
    scanf("%d%d",&n,&m);
    seller *p=(seller *)calloc(n,sizeof(seller));
    for(i=0;i<n;i++)scanf("%d%d",&p[i].a,&p[i].b);
    qsort(p,n,sizeof(seller),asc);
    for(i=0;m>0;i++){
        ans+=(long long int)ans(m,p[i].b)*p[i].a;
        m-=p[i].b;
    }
    printf("%lld\n",ans);
    free(p);
    return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long A,B,C,K;
    cin >> A >> B >> C >> K;
    
    if(K%2==0){
        cout << A-B << endl;
    }else{
        cout << B-A << endl;
    }
    return 0;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        int[] p = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = Integer.parseInt(scan.next());
            p[i]--;
        }
        for (int i = 0; i < n; i++) {
            c[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        long ans = Long.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            int cur = i;
            List<Integer> cList = new ArrayList<Integer>();
            long total = 0;
            while (true) {
                cur = p[cur];
                cList.add(c[cur]);
                total += c[cur];
                if (cur == i) {
                    break;
                }
            }

            if (k <= cList.size()) {
                long sum = 0;
                for (int j = 0; j < k; j++) {
                    sum += cList.get(j);
                    ans = Math.max(ans, sum);
                }
                continue;
            }

            if (total <= 0) {
                long sum = 0;
                for (int j : cList) {
                    sum += j;
                    ans = Math.max(ans, sum);
                }
            } else {
                int loopCount = k / cList.size();
                int amari = k % cList.size();
                if (amari == 0) {
                    loopCount--;
                    amari = cList.size();
                }

                long sum = total * loopCount;
                ans = Math.max(ans, sum);
                for (int j = 0; j < amari; j++) {
                    sum += cList.get(j);
                    ans = Math.max(ans, sum);
                }
            }
        }

        System.out.println(ans);
    }
}


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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int n, m, q;
  while (cin >> n >> m >> q, n) {
    vector<string> s(q), b(q);
    for (int i = 0; i < q; i++) {
      cin >> s[i] >> b[i];
    }

    vector<int> on(n, 0);
    vector<vector<int>> cor(n, vector<int>(m, 1));
    for (int i = 0; i < q; i++) {
      for (int j = 0; j < n; j++) {
        on[j] ^= (s[i][j] == '1');
        for (int k = 0; k < m; k++) {
          if (!cor[j][k]) continue;
          if (s[i][j] == '1') {
            if (on[j]) cor[j][k] = (b[i][k] == '1' && (i == 0 || b[i - 1][k] == '0'));
            else cor[j][k] = (b[i][k] == '0' && (i != 0 && b[i - 1][k] == '1'));
          } else {
            if (on[j]) cor[j][k] = (b[i][k] == '1' && (i != 0 && b[i - 1][k] == '1'));
            else cor[j][k] = (b[i][k] == '0' && (i == 0 || b[i - 1][k] == '0'));
          }
        }
      }
    }

    for (int j = 0; j < m; j++) {
      int ans = -1;
      for (int i = 0; i < n; i++) {
        if (cor[i][j] && ans != -2) ans = ans < 0 ? i : -2;
      }
      cout << (char)(ans == -2 ? '?' : ans < 10 ? ans + '0' : ans - 10 + 'A');
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 4468
#include<iostream>
using namespace std;
int main(){
int s;
cin >> s;
if(s<60) cout << "0:0:" << s << endl;
if(s>=60&&s<3600) cout << "0:" << s/60 << ":" << s%60 << endl;
if(s>=3600) cout << s/3600 << ":" << s%3600/60 << ":" << s%3600%60 << endl;
return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  vector<long>A(N),B(N);
  vector<pair<long,long>>D(N);long ans=0;
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
    D[i]=pair<long,long>(A[i]+B[i],i);
  }
  sort(D.begin(),D.end(),greater<pair<long,long>>());
  for(int i=0;i<N;i++){
    if(i%2==0)ans+=A[D[i].second];
    else ans-=B[D[i].second];
  }
  cout<<ans;
}


  

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,k,s,i;
	cin>>a>>b>>k;
	for(i=1;i<=k;i++){
	    if(i%2==1){
	        if(a%2==1){
	            a=a-1;
	            b+=(a/2);
	            a=a/2;
	        }
	        else{
	            b+=(a/2);
	            a=a/2;
	        }
	    }
	    else{
	        if(b%2==1){
	            b=b-1;
	            a+=(b/2);
	            b=b/2;
	        }
	        else{
	            a+=(b/2);
	            b=b/2;
	        }
	    }
	}
	cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if(a > b){
		cout << "a > b" << endl;
	}
	if(a < b){
		cout << "a < b" << endl;
	}
	if(a == b){
		cout << "a == b" << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s,t="";
	cin >> s;
	rep(i,SIZE(s)-1){
		if(s[i]=='B' && s[i+1]=='C'){
			t+='D';
			i++;
		}
		else t+=s[i];
	}
	vs tt;
	string tmp="";
	rep(i,SIZE(t)+1){
		if(t[i]=='B' || t[i]=='C' || i==SIZE(t)){
			tt.pb(tmp);
			tmp="";
		}
		else tmp+=t[i];
	}
	ll ans=0;
	for(auto&& e:tt){
		ll cnt=0;
		rep(i,SIZE(e)){
			if(e[i]=='D'){
				ans+=i-cnt;
				cnt++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5500
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

	string s;
	vector<string> ans;

	ans.emplace_back(string(w + 2, '#'));
	for (int i = 0; i < h; i++) {
		cin >> s;
		s = "#" + s + "#";
		ans.emplace_back(s);
	}
	ans.emplace_back(string(w + 2, '#'));

	for (auto t : ans) {
		cout << t << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp putchar(' ')
#define en putchar('\n')
#define MOD(x) ((((x)%Mod)+Mod)%Mod)
const int MAXN = 500005 ;
using namespace std ;
int64_t s[MAXN],a[MAXN] ;
int64_t Mod = 1000000007 ;
int n ;
int main()
{
    ios::sync_with_stdio(false) ;
    while(cin >> n) {

        for(int i = 1;i <= n; ++ i) {
            int64_t buff ;
            cin >> a[i] ;
        }
        s[0] = 0 ;
        int64_t ans = 0 ;
        for(int i = 1;i <= n;++i) {
            s[i] = MOD(s[i - 1] + a[i]) ;
            ans = MOD(ans + MOD(s[i - 1] * a[i])) ;
        }
        cout << ans << endl ;
    }
}


Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
cin >> N;
vector<int> vec(N);
for (int i = 0;i < N;i++) cin >> vec.at(i);
int mini = INF;
for (int i = 0;i < N;i++) {
    int S1 = 0,S2 = 0;
    for (int j = 0;j < N;j++) {
        if (j <= i) S1 += vec.at(j);
        else S2 += vec.at(j);
    }
    if (abs(S1-S2) < mini) mini = abs(S1-S2);
}
cout << mini << endl;

return 0;
}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, pair<int , pair<int , int> > > pppi;

bool cmp(const pppi &a, const pppi &b){
  if(a.S.S.F != b.S.S.F) return a.S.S.F > b.S.S.F;
  if(a.S.S.S != b.S.S.S) return a.S.S.S < b.S.S.S;
  return a.F < b.F;
}

int main(){
  int n;
  while(scanf("%d", &n) && n){

    vector<pppi> re(n);

    int l, u, a, p;
    rep(i, n){

      scanf("%d%d%d%d", &l, &u, &a, &p); l--; u--;
      re[i] = make_pair(l, make_pair(u, make_pair(a, p)));
    }

    sort(re.begin(), re.end(), cmp);

    vector<int>j(1000, 0);
    int all = 0;
    rep(i, n){
      if((all < 10 && j[re[i].S.F] < 3) || (all < 20 && j[re[i].S.F] < 2) || (all < 26 && j[re[i].S.F] < 1)){
	printf("%d\n", re[i].F+1);
	j[re[i].S.F]++;
	all++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1196
<?php
fscanf(STDIN, "%s", $S);
fscanf(STDIN, "%s", $T);

if (substr($S, 0, 1) === substr($T, 0, 1)) {
    $result_1 = 1;
} else {
    $result_1 = 0;
}
if (substr($S, 1, 1) === substr($T, 1, 1)) {
    $result_2 = 1;
} else {
    $result_2 = 0;
}
if (substr($S, 2, 1) === substr($T, 2, 1)) {
    $result_3 = 1;
} else {
    $result_3 = 0;
}
echo $result_1 + $result_2 + $result_3;


Measured memory_bytes: 16096
using System;
using System.Linq;
using System.Text;   
class Program
    {
        static void Main(string[] args)
        {
            //入力
            int xMaxInput = int.Parse(Console.ReadLine());
            string[] xInputStrings = new string[xMaxInput];
            for (int i = 0; i < xMaxInput; ++i)
            {
                xInputStrings[i] = Console.ReadLine();
            }
            //出力
            Console.WriteLine(string.Join("", Calu(xInputStrings).Reverse())) ;
        }

        static string Calu(string[] t)
        {
            char c = 'a';
            StringBuilder g = new StringBuilder();
            for (int i = 1; i < 27; i++)
            {
                int a = int.MaxValue;
                foreach (var s in t)
                {
                    int Count = s.Length - s.Replace(c.ToString(), "").Length;
                    if (Count < a)
                    {
                        a = Count;
                    }
                }
                g.Insert(0, c.ToString(), a);
                c = Convert.ToChar(c + 1);
            }
            return g.ToString();
        }
    }

Measured memory_bytes: 13396
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap |> sort
	c = zeros(Int,10^6)
	ans = 0
	for i in 1:n
		x = 1
		f = 0
		if i<n
			if a[i]==a[i+1]
				f = 1
			end
		end
		while x*x<a[i]
			if a[i]%x==0
				if c[x]==1||c[div(a[i],x)]==1
					f = 1
					break
				end
			end
			x += 1
		end
		if x*x==a[i]&&c[x]==1
			f = 1
		end
		if f == 0
			ans += 1
		end
		c[a[i]]=1
	end
	println(ans)
end

main()

Measured memory_bytes: 202932
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 212345
#define met(a, b) memset(a, b, sizeof(a))
class UMS
{
public:
    int f[maxn];
    UMS()
    {
        for(int i = 0; i < maxn; i++)
        {
            f[i] = i;
        }
    }
    int getf(int u)
    {
        if(u == f[u])
            return f[u];
        else
        {
            f[u] = getf(f[u]);
            return f[u];
        }
    }
    void Merge(int u, int v)
    {
        int f1 = getf(u);
        int f2 = getf(v);
        if(f1 != f2)
        {
            f[f1] = f2;
        }
    }
};
vector<int> vec[maxn];
map<int, int> q;
int main()
{
    UMS u1, u2;
    int n, k, l, u, v;
    scanf("%d%d%d", &n, &k, &l);
    while(k--)
    {
        scanf("%d %d", &u, &v);
        u1.Merge(u, v);
    }
    while(l--)
    {
        scanf("%d %d", &u, &v);
        u2.Merge(u, v);
    }
    int vis[maxn];
    met(vis, 0);
    for(int i = 1; i <= n; i++)
    {
        int fa = u1.getf(i);
        vec[fa].push_back(i);
    }
    for(int i = 1; i <= n; i++)
    {
        q.clear();
        for(int j = 0; j < vec[i].size(); j++)
        {
            q[u2.getf(vec[i][j])] ++;
        }
        for(int j = 0; j < vec[i].size(); j++)
        {
            vis[vec[i][j]] += q[u2.getf(vec[i][j])];
        }

    }
    for(int i = 1; i <= n; i++)
    {
        printf("%d", vis[i]);
        if(i == n) printf("\n");
        else printf(" ");
    }
    return 0;
}


Measured memory_bytes: 14456
#include <iostream>
#include <stack>

int main(){
	
	std::stack<int> train;
	int num;
	
	while(std::cin >> num){
		if(num == 0){
			std::cout << train.top() << std::endl;
			train.pop();
		}else{
			train.push(num);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <queue>
#include <stack>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

class Graph{
public:

Graph(long long int o_size){
    graph_size=o_size;
    node.resize(graph_size,0);
    edge.resize(graph_size);
}

long long int add_edge(long long int a,long long int b){
    edge[a].push_back(b);
    edge[b].push_back(a);
        
    return a+b;
}

long long int node_add(long long int i,long long int a){
    node[i]+=a;
    return node[i];
}

void dfs(long long int start){
    stack<pair<long long int,long long int>> st;
    st.push(make_pair(-1,start));
    while(st.size()){
        long long int where = st.top().second,pre_where=st.top().first;
        //cout << "Unko" << endl;
        st.pop();
        for(auto x:edge[where]){
            if(x!=pre_where){
                st.push(make_pair(where, x));
                node[x] += node[where];
            }
        }
        
    }

}

void print(){
    REP(i,graph_size-1){
        cout << node[i] << " ";
    }
    cout << node[graph_size - 1] << endl;
}


private:
vector<vector<long long int>> edge;
vector<long long int> node;
long long int graph_size;

};

int main(){

    long long int n,q,tmpa,tmpb;
    cin>>n>>q;
    Graph graph(n);
    REP(i,n-1){
        cin>>tmpa>>tmpb;
        graph.add_edge(tmpa-1,tmpb-1);
    }
    REP(i,q){
        cin>>tmpa>>tmpb;
        graph.node_add(tmpa - 1, tmpb) ;
    
    }
    graph.dfs(0);
    graph.print();

    return 0;
}


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

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

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


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;


int main() {
    string S, T; cin >> S >> T;

    i64 cnt = 0;
    REP(i, S.length()) {
        if (S[i] != T[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3780