akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

const INF = int.max / 8;

struct Edge {
    int from, to, cost, T;
}

void main() {
    int N, M, C, S, G;
    int[] P;
    int[][] Q, R;
    Edge[][] F;

    int calcCost(int T, int d, int ci = 0) {
        if (d < Q[T][ci + 1]) {
            return R[T][ci + 1] * (d - Q[T][ci]);
        } else {
            return R[T][ci + 1] * (Q[T][ci + 1] - Q[T][ci]) + calcCost(T, d, ci + 1);
        }
    }

    bool input() {
        scanf("%d %d %d %d %d\n", &N, &M, &C, &S, &G);
        if (N == 0) return false;
        S--; G--;
        F = new Edge[][N];
        foreach (i; 0 .. M) {
            int x, y, d, c; scanf("%d %d %d %d\n", &x, &y, &d, &c);
            x--; y--; c--;
            F[x] ~= Edge(x, y, d, c);
            F[y] ~= Edge(y, x, d, c);
        }
        P = readln.chomp.split(" ").map!(to!int).array;
        Q = new int[][C];
        R = new int[][C];
        foreach (i; 0 .. C) {
            auto buf = readln.chomp;
            if (!buf.empty) {
                Q[i] = buf.split(" ").map!(to!int).array;
            }
            Q[i] = [0] ~ Q[i] ~ [INF];
            buf = readln.chomp;
            R[i] = [0] ~ buf.split(" ").map!(to!int).array;
        }
        return true;
    }
    void solve() {
        auto X = new int[][](N, N);
        foreach (i; 0 .. N) X[i][] = INF;

        struct P {
            int v, cost;
        }
        foreach (s; 0 .. N) {
            foreach (c; 0 .. C) {
                BinaryHeap!(Array!P, "a.cost > b.cost") PQ;
                PQ.insert(P(s, 0));
                auto dist = new int[N];
                dist[] = INF;
                dist[s] = 0;
                while (!PQ.empty) {
                    auto cur = PQ.front; PQ.removeFront;
                    foreach (e; F[cur.v]) {
                        if (e.T != c) continue;
                        auto next = e.to;
                        auto ncost = cur.cost + e.cost;
                        if (dist[next] > ncost) {
                            dist[next] = ncost;
                            PQ.insert(P(next, ncost));
                        }
                    }
                }
                foreach (v; 0 .. N) {
                    if (dist[v] == INF) continue;
                    X[s][v] = min(X[s][v], calcCost(c, dist[v]));
                }
            }
        }
        //foreach (x; X) writeln(x);
        foreach (k; 0 .. N) foreach (i; 0 .. N) foreach (j; 0 .. N) {
            X[i][j] = min(X[i][j], X[i][k] + X[k][j]);
        }
        auto ans = X[S][G];
        writeln(ans == INF ? -1 : ans);
    }

    while (input) solve;
}

Measured memory_bytes: 2896
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test lli t;cin>>t;while(t--)
#define vll vector<lli>
#define mll map<lli,lli>
#define vvll vector<vector<lli>>
#define vpll vector<pair<lli,lli>>
#define vvpll vector<vector<pair<lli,lli>>>
#define mpll map<pair<lli,lli>,lli>
#define pll pair<lli,lli>
#define sll stack<lli>
#define qll queqe<lli>
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define mod 1000000007
#define ma 1000000000000000000
#define mi -1000000000000000000
int main()
{
  
  fastio
  lli a;
  cin>>a;
  cout<<a+a*a+a*a*a;
	return 0;
}


Measured memory_bytes: 3632
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	h := make([]int, n)
	for i := range h {
		h[i] = readInt()
	}

	var ans int
	var all bool
	for !all {
		all = true
		found := true
		for i := 0; i < n; i++ {
			if h[i] > 0 {
				all = false
				if found {
					found = false
					ans++
				}
				h[i]--
			} else {
				found = true
			}
		}
	}
	println(ans)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		int input[] = new int[n];
		int copy[] = new int[n];
		
		int max = 0;
		for(int i = 0; i < n ; i++){
			input[i] = Integer.parseInt(br.readLine());
			max = Math.max(max, input[i]);
			copy[i] = input[i];
		}
		
		//最大値の出現回数を調べる
//		int maxAppear = 0;
//		for(int i = 0; i < n; i++){
//			if(input[i] == max){
//				maxAppear++;
//			}
//		}
		
		Arrays.sort(copy);
		
		StringBuffer sb = new StringBuffer();
		for(int i = 0; i < n; i++){
			if(input[i] == copy[n - 1]){
				sb.append(copy[n - 2]+"\n");
			}
			else {
				sb.append(copy[n - 1] + "\n");
			}
		}
		System.out.print(sb);
	}

}


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

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n,t,l,b;
	srand(1);
	while(1){
		cin >> n >> t >> l >> b;
		if( !n || !t ) break;

		vector<int> v(n+1);

		map<int,int> mp;
		vector<vector<double>> loss(l,vector<double>(3,0));
		int idx = 0;
		while( l > 0 ){
			int a;
			cin >> a;
			v[a] = 1;
			mp[a] = idx++;
			l--;
		}

		while( b > 0 ){
			int a;
			cin >> a;
			v[a] = 2;
			b--;
		}

		double dp[101][2] = {};
		dp[0][0] = 1;
		double ans = 0;
		rep(i,0,t){
			rep(j,0,n){
				rep(k,1,7){
					int ba;
					if( j+k > n ) ba = n - (j+k-n);
					else ba = j+k;
					if( v[ba] == 1 ){
						loss[mp[ba]][0] += dp[j][0]*0.166666666666666666;
					}
					else if( v[ba] == 2 ) dp[0][1] += dp[j][0]*0.16666666666666666;
					else dp[ba][1] += dp[j][0]*0.1666666666666666666;
				}

				if( v[j] == 1 ){
					rep(k,1,7){
						int ba;
						if( j + k > n ) ba = n - ( j + k - n );
						else ba = j + k;
						if( v[ba] == 1 ) loss[mp[ba]][0] += loss[mp[j]][2]*0.1666666666666666;
						else if( v[ba] == 2 ) dp[0][1] += loss[mp[j]][2]*0.1666666666666666;
						else dp[ba][1] += loss[mp[j]][2]*0.1666666666666666;
					}
				}
			}

			/*
			cout << "b ";
			rep(j,0,n+1) cout << dp[j][0] << " ";
			cout << endl;
			cout << "a ";
			rep(j,0,n+1) cout << dp[j][1] << " ";
			cout << endl;
			cout << "l1 ";
			rep(j,0,loss.size()) cout << loss[j][0] << " ";
			cout << endl;
			cout << "l2 ";
			rep(j,0,loss.size()) cout << loss[j][1] << " ";
			cout << endl;
			cout << "l3 ";
			rep(j,0,loss.size()) cout << loss[j][2] << " ";
			cout << endl;
			*/
			ans += dp[n][1];
			dp[n][1]= 0;
			dp[n][0]= 0;
			rep(j,0,n){
				dp[j][0] = dp[j][1];
				dp[j][1] = 0;
			}
			rep(j,0,loss.size()){
				loss[j][2] = loss[j][1];
				loss[j][1] = loss[j][0];
				loss[j][0] = 0;
			}
		}

		printf("%.6f\n",ans);
	}
	ret 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
// ll mod=998244353;
ll INF=1e9;
int t[2000005];
void update(int v,int tl,int tr,int pos,int val)
{
	if(tl==tr)
	{
		t[v]=val;
		return;
	}
	int tm=(tl+tr)/2;
	if(pos<=tm)
	{
		update(2*v,tl,tm,pos,val);
	}
	else
	{
		update(2*v+1,tm+1,tr,pos,val);
	}
	t[v]=max(t[2*v],t[2*v+1]);
	return;
}
int ma(int v,int tl,int tr,int l,int r)
{
	if(l>r)
	{
		return 0;
	}
	if(tl==l && tr==r)
	{
		return t[v];
	}
	int tm=(tl+tr)/2;
	return max(ma(2*v,tl,tm,l,min(r,tm)),ma(2*v+1,tm+1,tr,max(l,tm+1),r));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("INPUT.txt", "r", stdin);
	freopen("OUTPUT.txt", "w", stdout);
	#endif
	int test=1;
	// cin>>test;
	while(test--)
	{
		int n,k;
		cin>>n>>k;
		int a[n];
		int ans=0,v;
		FOR(i,0,n)
		{
			cin>>a[i];
			v=ma(1,0,300000,max(a[i]-k,0),min(a[i]+k,300000));
			ans=max(ans,v+1);
			update(1,0,300000,a[i],v+1);
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 8932
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in",,"r",stdin);freopen(a".out","w",stdout)
#define int ll
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
	return f*sum;
}
int n,a[100010];
signed main(){
	n=gi();
	for(int i=1;i<=2*n;i++)a[i]=gi();
	sort(a+1,a+2*n+1);ll ans=0;
	for(int i=1;i<=n;i++)ans+=a[i*2-1];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  double ans=0,x,h,z;
  cin>>n>>z;
  rep(i,n){
    cin>>x>>h;
    ans=max(ans,h/x*z);
  }
  printf("%.9f\n",ans);
}

Measured memory_bytes: 3192
n = gets.strip.to_i
a = readlines.map {|line| line.strip.to_i }

max = a.sort.last

second_max = (a - [max]).sort.last
second_max = max if a.group_by {|e|e}[max].length>1

a.each do |e|
  if e==max
    p second_max
  else
    p max
  end
end



Measured memory_bytes: 61036
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [Int] -> Int
solve [] = 0
solve (x:xs)
    | isPrime x = 1 + solve xs
    | otherwise = solve xs where
        isPrime = iter (2:[3,5..])
        iter (d:ds) x
            | d*d > x = True
            | mod x d == 0 = False
            | otherwise = iter ds x

main :: IO() 
main = do
    n <- readLn
    l <- replicateM n readLn :: IO [Int]
    print (solve l)



Measured memory_bytes: 8244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
 
  if (a+b>c+d) {
  cout << "Left" << endl;
  }
  else if (a+b<c+d) {
  cout << "Right" << endl;
  }   
  
  else puts("Balanced");
}



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

using namespace std;

#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

int main(){
    fast;

    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        ll n,x,ans = 0,s;
        cin>>n>>x;
        int ip[n];
        for(int i = 0; i < n; i++) cin>>ip[i];
        for(int i = 1; i < n; i++) {
			s = ip[i] + ip[i-1];
			if(s > x) {
				if(ip[i] >= (s-x)) {
					ans += (s-x);
					ip[i] -= (s-x);
				}
				else {
					ans += (s-x);
					s -= ip[i];
					ip[i] = 0;
					ip[i-1] -= (s-x);
				}
			}
		}
		cout<<ans<<endl;
        
        
    }



return 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define MAX_N 100005
#define mm(a,b) memset(a,b,sizeof(a))
#define ll long long

char str1[MAX_N], str2[MAX_N];

int main() {
    scanf("%str1", str1);
    int flag=0, ans=0;
    int len=strlen(str1);
    do{
        for(int i=1;i<len-1;i++){
            if(str1[i]!='\0'){
                int x=i-1;
                while(str1[x]=='\0')   x--;
                if(str1[x]!=str1[i+1]){
                    str1[i] = '\0';
                    flag++;
                }
            }
        }
        if(flag==ans)
            break;
        int cnt=0;
        for(int i=0;i<len;i++)
            if(str1[i]!='\0')
                str2[cnt++]=str1[i];
        for(int i=0;i<len;i++)
            str1[i]=str2[i];
        len=cnt;
        ans=flag;
    }while(1);
    if(flag % 2 == 1)
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 384
n,k=map(int,input().split())
S=input()
if n==1:
    print(0)
    exit()
cnt=1
prev=S[0]
for s in S[1:]:
    if s!=prev:
        cnt+=1
    prev=s
if cnt-2*k<1:
    print(n-1)
else:
    print(n-cnt+2*k)

Measured memory_bytes: 39872
import java.util.Scanner;

public class Main {

	private static int min = Integer.MAX_VALUE;
	private static int N, A, B, C;
	private static int[] l;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		l = new int[N];
		for (int i=0;i<N;i++) {
			l[i]=sc.nextInt();
		}
		sc.close();
		func(0, 0, 0, 0, 0);
		System.out.println(min);
	}

	private static void func(int n, int a, int b, int c, int cost) {
		if(n == N) {
			if(a==0 || b==0 || c==0) {
				return;
			}else {
				cost += Math.abs(A-a) + Math.abs(B-b) + Math.abs(C-c) - 30;
				min = Math.min(min, cost);
				return;
			}
		}
		func(n+1,a,b,c,cost);
		func(n+1,a+l[n],b,c,cost+10);
		func(n+1,a,b+l[n],c,cost+10);
		func(n+1,a,b,c+l[n],cost+10);
	}
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    for (int i = 0; i < 5; i++) {
        int tmp;
        cin >> tmp;
        if (tmp == 0) { cout << i + 1 << endl; }
    }
    return 0;
}

Measured memory_bytes: 3588
n = int(input())
S = []
for i in range(n):
    S.append(input())

lst = [S.count('AC'), S.count('WA'), S.count('TLE'),
S.count('RE')]
 
print('AC x ' + str(lst[0]))
print('WA x ' + str(lst[1]))
print('TLE x ' + str(lst[2]))
print('RE x ' + str(lst[3]))

Measured memory_bytes: 16296
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll h,w,d; cin >> h >> w >> d;
    vpl point(h*w+1);
    rep(i,h){
        rep(j,w){
            ll a; cin >> a;
            point[a] = make_pair(i,j);
        }
    }
    vl sum(h*w+1,0);
    ll index = 1;
    while(index+d<=h*w){
        rep(i,d){
            if(index+d<=h*w){
                ll ax = point[index].first;
                ll ay = point[index].second;
                ll bx = point[index+d].first;
                ll by = point[index+d].second;
                sum[index+d] += sum[index] + abs(ax-bx) + abs(ay-by);
                index++;
            }else{
                break;
            }
        }
    }
    //rep(i,h*w+1) cout << sum[i] << " ";
    //cout << endl;
    ll q; cin >> q;
    rep(z,q){
        ll a,b; cin >> a >> b;
        cout << sum[b] - sum[a] << endl;
    }
}

Measured memory_bytes: 3200
#include<stdio.h>
int main(){
  int j,i,mini,n,a[100],v,cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i = 0;i<=n-1;i++){
    mini=i;
    for(j=i;j<=n-1;j++){
      if(a[j]<a[mini]){
	mini = j;
      }
    }
      if(i!=mini){
      	v = a[i];
	a[i]=a[mini];
	a[mini]=v;
	cnt++;
      }
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",cnt);
  return 0;
}

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

constexpr int INF = (1 << 30) - 1;

int memo[105][105];
int n; 
int r[105], c[105];

int dfs(int left, int right)
{
    int ret = INF;
    if ( left == right ) return ( 0 );
    if ( memo[left][right] != -1 ) return ( memo[left][right] );
    for ( int i = left; i < right; i++ ) { 
        ret = min(ret, dfs(left, i) + dfs(i + 1, right) + r[left] * c[right] * c[i]);
    }
    return ( memo[left][right] = ret );
}

int main()
{
    fill_n(*memo, 105 * 105, -1);

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

    cout << dfs(0, n - 1) << endl;

    return ( 0 );
}



Measured memory_bytes: 3168
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll dp[n+1];
  rep(i,n+1) dp[i]=MOD;
  dp[0]=0;
  rep(i,n-1){
    chmin(dp[i+1],dp[i]+abs(v[i+1]-v[i]));
    if(i>=1) chmin(dp[i+1],dp[i-1]+abs(v[i+1]-v[i-1]));
    
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
d[150][120];j,s,t,m,n,*p;main(i){for(;scanf("%d%d",&n,&m)*n;printf("%d\n",s)){for(memset(d,9,7e4);t=m--;d[i][j]=d[j][i]=s/100)scanf("%d,%d,%d",&i,&j,&s);for(s=i=1-n;i++;s+=d[n][t=m])for(d[j=m=n][t]=0;j--;*p&&d[n][m]>*p?m=j:0)p=d[n]+j,*p=fmin(*p,d[t][j]);}}

Measured memory_bytes: 0
#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() {
    int N;
    cin >> N;

    vector<int> dp(N + 1, MOD);

    dp[0] = 0;
    rep(i, N) {
        dp[i + 1] = min(dp[i + 1], dp[i] + 1);
        for (int j = 1; j + i <= N; j *= 6) {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
        for (int j = 1; j + i <= N; j *= 9) {
            dp[i + j] = min(dp[i + j], dp[i] + 1);
        }
    }
    cout << dp[N] << '\n';
}

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


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	private static final int MAX = 100000;
	private static int[][] map;

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

		while (true) {
			int cityNum = sc.nextInt();// 街の数
			int lim = sc.nextInt();// 制限時間
			int freezerNum = sc.nextInt();// 冷凍庫の数
			int edgeNum = sc.nextInt();// 道の数
			int S = sc.nextInt();// スタート
			int G = sc.nextInt();// ゴール
			if (cityNum == 0) {
				sc.close();
				break;
			}

			boolean[] isFreezer = new boolean[cityNum];
			isFreezer[S] = isFreezer[G] = true;
			for (int i = 0; i < freezerNum; i++) {
				isFreezer[sc.nextInt()] = true;
			}

			map = new int[cityNum][cityNum];
			for (int i = 0; i < edgeNum; i++) {
				int from = sc.nextInt();
				int to = sc.nextInt();
				int weight = sc.nextInt();
				map[from][to] = map[to][from] = weight;
			}

			// とりあえずワーシャルフロイト
			// ここでの目的は任意の2冷凍庫間の最小必要時間を出すこと
			WarshallFloyd();

			// 冷凍庫間で血液が死ぬ道は通れない
			for (int i = 0; i < cityNum; i++) {
				for (int j = 0; j < cityNum; j++) {
					if (!isFreezer[i] || !isFreezer[j] || map[i][j] > lim) {
						map[i][j] = MAX;
					}
				}
			}

			// 自明に通れない道を消し去ったので
			// スタートからゴールへの最短経路を求めるためにワーシャルフロイト
			WarshallFloyd();

			if (map[S][G] >= MAX) {
				System.out.println("Help!");
			} else if (map[S][G] < lim) {
				System.out.println(map[S][G]);
			} else {
				System.out.println(2 * map[S][G] - lim);
			}
		}
	}

	static void WarshallFloyd() {
		// 任意の2点間の最小時間を入れる
		int n = map.length;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (map[i][j] == 0) {
					map[i][j] = MAX;
				}
			}
		}

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (i != j) {
						map[i][j] = Math.min(map[i][j], map[i][k] + map[k][j]);
					}
				}
			}
		}
	}
}

Measured memory_bytes: 62328
import math

MAXN = 2 ** 17

ide_ele = 0

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

num = 2**(n-1).bit_length()
seg = [ide_ele] * 2 * num

def init(init_val):
    for i in range(n):
        seg[i+num-1] = init_val[i]
    for i in range(num-2 ,-1, -1) :
        seg[i] = math.gcd(seg[2*i+1],seg[2*i+2])
        
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = math.gcd(seg[k*2+1] , seg[k*2+2])

init(a)
ans = 0
for i in range(n):
    update(i,0)
    ans = max(ans,seg[0])
    update(i,a[i])
    
print(ans)

Measured memory_bytes: 88136
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    // Nodeのリスト
    static List<Node> nodes = new List<Node>();
    // 辿っているQueue
    static Queue<Node> queue = new Queue<Node>();

    // Node
    class Node
    {
        public int dist = -1;
        public List<int> adjacentIds;
    }

    static void Main(string[] args)
    {
    	// 行数を取得
        int n = int.Parse(Console.ReadLine().Split()[0]);

        // nodeを作成
        for (int i = 0; i < n; i++)
        {
            nodes.Add(new Node());
        }

        // nodeの中身設定
        for (int i = 0; i < n; i++)
        {
            List<int> nums = Console.ReadLine().Split().Select(str => int.Parse(str)).ToList();
            nodes[nums[0] - 1].adjacentIds = nums.GetRange(2, nums[1]).Select(id => id - 1).ToList();
        }

        // bfs
        
        Bfs(nodes[0]);

        // 出力
        for (int i = 0; i < n; i++)
        {
            System.Console.WriteLine(string.Format("{0} {1}", i + 1, nodes[i].dist));
        }
    }

    static void Bfs(Node start)
    {
        start.dist = 0;
        queue.Enqueue(start);
        while (queue.Count() > 0)
        {
            Node node = queue.Dequeue();
            foreach (var id in node.adjacentIds)
            {
                if (nodes[id].dist == -1)
                {
                    nodes[id].dist = node.dist + 1;
                    queue.Enqueue(nodes[id]);
                }
            }
        }
    }
}



Measured memory_bytes: 10652
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int       lint;
typedef vector<int>         vi;
typedef vector<lint>        vl;
typedef pair<int, int>      pii;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
 
#define pb(n)           push_back(n)
#define ALL(n)          (n.begin(), n.end())
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define M               10000000
#define MOD             10000007
#define INF             1e9+7
#define REP(i,a,b)      for(int i = int(a); i <= int(b); i++)
#define REPL(i,a,b)     for(lint i = lint(a); i <= lint(b); i++)
#define fastIO()        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    vl v(n);

    lint mini = LONG_LONG_MAX, maxi = LONG_LONG_MIN;

    REP(i, 0, n - 1){
        cin>>v[i];
        mini = min(mini, v[i]);
        maxi = max(maxi, v[i]);
    }

    lint ans = LONG_LONG_MAX;

    REP(i, mini, maxi){
        lint cost = 0;
        REP(j, 0, n - 1){
            cost += (v[j] - i) * (v[j] - i);
        }
        ans = min(ans, cost);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
 
lines = []
for _ in range(M):
	lines.append(list(map(lambda x: int(x) - 1, input().split())))
 
def root(x):
	if par[x] == x:
		return x
	
	par[x] = root(par[x])
	return par[x]
 
def unite(x, y):
	rx = root(x)
	ry = root(y)
	if rx != ry:
		par[rx] = ry
 
def same(x, y):
	rx = root(x)
	ry = root(y)
	return rx == ry
 
 
ans = 0
 
for i in range(M):
	par = [x for x in range(N)]
	
	for j in range(M):
		if i != j:
			unite(lines[j][0], lines[j][1])
	
	flag = True
	for j in range(1, N):
		if not same(0, j):
			flag = False
	if not flag:
		ans += 1
 
print(ans)

Measured memory_bytes: 47596
#include <iostream>
using namespace std;
int main(){
  int n, sum = 0; cin >> n;
  int a[50];
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      sum += a[i] * a[j];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
class Program{
  static void Main()
  {
    string weather = Console.ReadLine();
    List<Char> weatherList = new List<Char>{
      weather[0],
      weather[1],
      weather[2]
    };
    
    int rainyDays = weatherList.Count(n => n=='R');
    if(rainyDays != 2) {
      Console.WriteLine(rainyDays);
    }
    else if(weatherList[1] == 'S'){
      Console.WriteLine(1);
    }
    else{
      Console.WriteLine(2);
    }
  }
}


Measured memory_bytes: 26588
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int N;
int L[102];

int main()
{
    cin >> N;

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

    int max = *max_element(L, L+N);
    int sum = accumulate(L, L + N, 0);

    if (sum - max > max) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;
vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

int main()
{
	IOS
	int a,b,k;
	cin >> a >>b >> k;
	ll count = 0;
	for(int i = min(a,b);i >= 1; --i){
		if(a%i == 0 && b % i == 0)
			++count;
		if(count == k)
		{
			cout << i;
			return 0;
		}
	}
	return 0;
}

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

double d , t , s;
double c;
pair < int , int > p[110];
int main()
{
     bool k = 0;
    cin>>d >> t >>s;
   c = d/s;
  // cout << c;
    if ( c <= t )
    cout << "Yes";
    else cout << "No";
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 210;

template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }

int gcd_a[MAX_N][MAX_N];

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

    int K;
    cin >> K;
    int ans = 0;
    for(int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            gcd_a[a][b] = gcd(a, b);
        }
    }
    for(int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            for (int c = 1; c <= K; ++c) {
                ans += gcd(gcd_a[a][b], c);
            }
        }
    }

    printf("%lld\n", ans);

    return 0;
}


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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()-1){
		if(s.at(i) != s.at(i+1)) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1100;

ll a[maxn],n,all,f;
int main(){
  cin>>n;
  double ans=0;
  for(int i=1;i<=n;++i){
    cin>>a[i];
    ans+=1.0/a[i];
  }

    printf("%.7lf\n",1.0/ans);
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define bql 2147483647
#define ll long long
#define ull unsigned long long
using namespace std::tr1;
using namespace std;
const int N=2e5+5;
const int mod=998244353;
const int fx[5]={0,-1,0,1,0};
const int fy[5]={0,0,-1,0,1};
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0' && ch<='9'){x=(x<<3)+(x<<1);x+=(ch-'0');ch=getchar();}
    return x*f;
}

void write(int x)
{
    if (x<0) putchar('-'),x=-x;
    if (x>10) write(x/10);
    putchar(x%10+'0');
}

int main()
{
  fast;
  int n,r;
  cin>>n>>r;
  if (n>=10)
      cout<<r<<endl;
  else
      cout<<r+100*(10-n)<<endl;
  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


_ = int(input())
a = list(map(int, input().split()))
ans = 0

gcd = lcm_list(a)-1

for i in a:
    ans += gcd % i

print(ans)


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

using namespace std;

char s[20], t[20];
int len, len2;

int main(void)
{
	scanf("%s", s);
	scanf("%s", t);
	
	len = strlen(s);
	len2 = strlen(t);
	
	if(len + 1 != len2)
	{
		printf("No");
		return 0;
	}
	
	int ff = 0;
	
	for(int i = 0 ; i < len ; i++)
	{
		if(s[i] != t[i])
			ff = 1;
	}
	
	if(ff == 1)
	{
		printf("No");
		return 0;
	}
	
	printf("Yes");
	return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<string.h>
#include<math.h>
#include<vector>
#define pp pair<int, int>
using namespace std;


int main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i < n; i++){
        int temp = n-i;
        for(int j = 1; j*j <= temp; j++){
            int tt = 0;
            if(temp%j == 0){
                if(j != (temp/j))
                    tt = 2;
                else
                    tt = 1;
                ans += tt;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
const int MAX = 20;
int n,A[MAX];
bool slove(int i, int m)
{
	if (m == 0)
		return true;
	if (i >= n)
		return false;
	return (slove(i + 1, m) || slove(i + 1, m - A[i]));
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	int m;
	cin >> m;
	int *B = new int[m];
	for (int i = 0; i < m; i++)
		cin >> B[i];
	for (int i = 0; i < m; i++)
		cout << (slove(0, B[i]) ? "yes" : "no") << endl;
	delete[] B;
}


Measured memory_bytes: 3060
//配列を作ってi番目を対応する数番目の要素として代入していけば良い
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N ;
  cin >> N ;
  int a =0;
  vector<int> ans(120000);
  for(int i=1;i<=N;i++){
    cin >> a;
    ans[a] = i ;
  }
  
  for(int i=1;i<=N;i++){
    cout << ans[i] << ' ' ;
  }
}

  

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

class strongly_connected_components{
public:
	vector<vector<int> > G, rG;
	vector<int> used, vs;
	vector<int> cmp; //cmp[v] := ??????v?????????????????£??????????????????????????????????????????
	strongly_connected_components(int n): G(n), rG(n), cmp(n), used(n){}
	void add_edge(int from, int to){
		G[from].push_back(to);
		rG[to].push_back(from);
	}
	int scc(){
		fill(used.begin(), used.end(), 0);
		vs.clear();
		for (int i = 0; i < G.size(); ++i){
			if(!used[i]) dfs(i);
		}
		fill(used.begin(), used.end(), 0);

		int k = 0;
		for (int i = vs.size() - 1; i >= 0; --i){
			if(!used[vs[i]]){
				rdfs(vs[i], k++);
			}
		}
		return k; //scc?????°
	}
private:
	void dfs(int curr){
		used[curr] = true;
		for(auto next : G[curr]){
			if(!used[next]) dfs(next);
		}
		vs.push_back(curr);
	}
	void rdfs(int curr, int k){
		used[curr] = true;
		cmp[curr] = k;//??????v???????????????k????????¨?????£???????????§???????????¨??\??????
		for(auto next : rG[curr]){
			if(!used[next]) rdfs(next, k);
		}
	}
};

int main(void){
	int v, e; cin >> v >> e;
	strongly_connected_components scc(v);
	rep(i, e){
		int s, t; cin >> s >> t;
		scc.add_edge(s, t); // s->t
	}
	scc.scc();
	int q; cin >> q;

	rep(i, q){
		int u, v; cin >> u >> v;
		if(scc.cmp[u] == scc.cmp[v]){
			printf("1\n");
		}else{
			printf("0\n");
		}
	}
	return 0;
}

Measured memory_bytes: 4492
#include<bits/stdc++.h>
#define ll long long int
#define ii int
#define jmp cout<<"\n"
#define vl vector<ll>
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define printv(v) for(auto x:v) cout<<x<<" "; jmp;
#define endll "\n"
#define SORT(v) sort(v.begin(),v.end())
#define REV(x)  reverse(x.begin(),x.end())
#define UNI(a) a.erase( unique( a.begin(), a.end() ), a.end() )
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
using namespace std;
ll ctr, mx;
ll dp[100005];
ll dfs(vector<vector<ll>>&g, ll s)
{
	//cout << ctr << " ";
	if (dp[s] != -1)
		return dp[s];
	bool k = 0;
	ll ms = 0;
	for (auto x : g[s])
	{
		k = 0;
		ms = max(ms, dfs(g, x));

	}
	return dp[s] = (k) ? 0 : (1 + ms);
}
void solve()
{
	ll n, m, l, r;
	cin >> n >> m;
	vector<vector<ll> >adj(n + 1);
	for (ll i = 0; i < m; i++)
	{
		cin >> l >> r;
		adj[l].pb(r);
	}
	ll res = 0;
	memset(dp, -1, sizeof(dp));
	for (ll i = 1; i <= n; i++)
	{
		res = max(res, dfs(adj, i));
	}
	
	cout << res-1  << endll;

}
int main()
{
	fast;
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	// ll t;
	// cin >> t;
	// while (t--)
	solve();
	return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}   
     
int main()
{
      
  fast;
  string s;
  cin>>s;
  ll ans=0;

  for(int i=0;i<sz(s);i++)
  {
    ll m=s[i]-'0';
    ans+=m;
    ans%=9;
  }
  if(ans==0)
    cout<<"Yes\n";
  else cout<<"No\n";
    
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int INF=1e9;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  int n;
  cin >> n;
  vector<ll> s(n+1);
  s[0]=0;
  rep(i,n){
    ll a;
    cin >> a;
    s[i+1]=s[i]+a;
  }
  
  ll ans=1e18;
  ll l=1,r=3;
  for(int i=2;i<n-1;i++){
    if(r<=i)r=i+1;
    while(l+1<i && abs(s[i]-2*s[l+1])<=abs(s[i]-2*s[l])){
      l++;
    }
    while(r+1<n && abs(s[r+1]-s[i]-(s[n]-s[r+1]))<=abs(s[r]-s[i]-(s[n]-s[r]))){
      r++;
    }
    ll M = max({s[l],s[i]-s[l],s[r]-s[i],s[n]-s[r]});
    ll m = min({s[l],s[i]-s[l],s[r]-s[i],s[n]-s[r]});
    ans = min(ans,M-m);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
	int n[101][101] = {}, m[101] = {},l[101] = {}, i, j, a, b;
	scanf("%d %d", &a, &b);
	for(i = 0; i < a; i++){
		for(j = 0; j < b; j++){
			scanf("%d", &n[i][j]);
		}
	}
	for(i = 0; i < b; i++){
		scanf("%d", &m[i]);
	}
	for(i = 0; i < a; i++){
		for(j = 0; j < b; j++){
			l[i] += n[i][j] * m[j];
		}
	}
	for(i = 0; i < a; i++){
		printf("%d\n", l[i]);
	}
	return 0;
}

Measured memory_bytes: 648
// ABC 049 D 連結
#include <iostream>
#include <vector>
#include <map>

# define REP(i,n) for(int i=0; i<n;i++)
# define MAX_N 200005

using namespace std;

int par[2][MAX_N];
int rnk[2][MAX_N];

// 連結のない状態に初期化
void init(int n){
	REP(k,2){
		REP(i,n){
			par[k][i] = i;
			rnk[k][i] = 0;
		}
	}
}

// ノードxの親を探す
int find(int k, int x){
	if (par[k][x]==x){
		return x;
	}else{
		par[k][x] = find(k, par[k][x]);
		return par[k][x];
	}
}

// ノードxとyを連結させる
void unite(int k, int x, int y){
	x = find(k, x);
	y = find(k, y);
	
	if (x==y) return;
	if (rnk[k][x]>rnk[k][y]){
		par[k][y] = x;
	}else{
		par[k][x] = y;
		if (rnk[k][x]==rnk[k][y]) rnk[k][y]++;
	}
}

// ノードxとyが連結しているか (根が同じか) を判定する
bool same(int k, int x, int y){
	return (find(k, x)==find(k, y));
}

int main(){
	int N, K, L, p, q, r, s;
	map<pair<int, int>, int> mp;
	
	cin >> N >> K >> L;
	init(N);
	
	REP(i,K){
		cin >> p >> q;
		p--; q--;
		unite(0,p,q);
	}
	REP(i,L){
		cin >> r >> s;
		r--; s--;
		unite(1,r,s);
	}
	
	REP(i,N){
		mp[make_pair(find(0,i),find(1,i))]++;
	}
	
	REP(i,N) cout << mp[make_pair(find(0,i), find(1,i))] << " ";
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 15104
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

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

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

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

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

ll fast_exp(ll base, ll exp1) {
    base%=mod;
    ll res=1;
    while(exp1>0) {
       if(exp1&1) res=(res*base)%mod;
       base=(base*base)%mod;
       exp1/=2;
    }
    return res%mod;
} 

ll add(ll x,ll y)
{
    return (x+y+mod)%mod;
}

ll mul(ll x,ll y)
{
    return (x*y)%mod;
}

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt();
    vc<ll> v(n);
    generate(all(v),nxt);
    ll p=0;
    rep(a,0,n)
        p^=v[a];
    rep(a,0,n)
    {
        cout<<(v[a]^p)<<" ";
    }
    cout<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 4776