akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner Num = new Scanner(System.in);
        int a = Num.nextInt();
        int b = Num.nextInt();
        if(a > b){
            System.out.println("a > b");
        }else if(a < b){
             System.out.println("a < b");
        }else if(a == b){
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26200
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.next());
        int b = Integer.parseInt(scanner.next());
        System.out.println((a*b) + " " + (2*a + 2*b));
    }
}


Measured memory_bytes: 26076
n, k = map(int, input().split())
a = list(map(int, input().split()))

dp = [False]*(k+1)
for j in range(1,k+1):
    tmp = False
    for i in range(n):
        if a[i] > j:
            continue
        if not dp[j-a[i]]:
            tmp = True
    dp[j] = tmp

if dp[-1]:
    print("First")
else:
    print("Second")

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> a(N);
  for(int &x: a) cin>>x;
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int ans=0;
  for(int i=0;i<K;i++) ans+=a[i];
  cout<<ans<<endl;
}
  
  

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] asrgs) {
        print(countingSort(read()));
    }

    private static int[] read() {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = Integer.parseInt(scanner.next());
        return a;
    }

    private static int[] countingSort(int[] a) {

        int n = a.length;

        int max = a[0];
        for (int i = 1; i < n; i++) max = Math.max(max, a[i]);

        int[] count = new int[max + 1];

        for (int i = 0; i < n; i++)
            count[a[i]]++;

        for (int i = 1; i <= max; i++)
            count[i] += count[i-1];

        int[] result = new int[n];

        for (int i = n - 1; i >= 0; i--) {
            result[count[a[i]]-1] = a[i];
            count[a[i]]--;
        }

        return result;
    }

    private static void print(int[] a) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < a.length; i++) {
            sb.append(a[i] + " ");
        }
        System.out.println(sb.toString().trim());
    }
}



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

typedef long long int lli;
typedef long double ld;

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        int a,b;
        char c;
        cin>>a>>c>>b;
        if(c=='+'){
            cout<<a+b;
        }
        else
            cout<<a-b;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int maxn = 100005;
ll cost[maxn],dp[maxn];
 
int N;
 
int main(){
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%lld", &cost[i]);
        dp[i] = maxn*10000;
    }
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        if(i-1 >= 0){
            dp[i] = min(dp[i],dp[i-1] + abs(cost[i] - cost[i-1]));
        }
        if(i-2 >= 0){
            dp[i] = min(dp[i], dp[i-2] + abs(cost[i] - cost[i-2]));
        }
    }
    printf("%lld", dp[N-1]);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string.h>
#include<queue>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define MAX 105
using namespace std;
int N;
//int M[MAX][MAX];
vector<int> V[MAX];
int D[MAX];
void BFS(int u)
{
	queue<int> Q;
	Q.push(u);
	D[u]=0;
	while(!Q.empty())
	{
		int i=Q.front();
		Q.pop();
		/*FOR(j,1,N)
			if(M[i][j]&&D[j]==MAX)
			{
				Q.push(j);
				D[j]=D[i]+1;
			}
		*/
		for(int j=0;j<V[i].size();j++)
			if(D[V[i][j]]==MAX)
			{
				Q.push(V[i][j]);
				D[V[i][j]]=D[i]+1;
			}
	}
	FOR(i,1,N)
		printf("%d %d\n",i,(D[i]==MAX)?-1:D[i]);
		//cout<<i<<" "<<((D[i]==MAX)?(-1):D[i])<<"\n";
}
int main()
{
	//memset(M,0,sizeof(M));
	scanf("%d",&N);
	FOR(i,1,N)
		D[i]=MAX;
	int u,k,v;
	FOR(i,1,N)
	{
		scanf("%d %d",&u,&k);
		FOR(j,1,k)
		{
			scanf("%d",&v);
			V[u].push_back(v);
		}
	}
	BFS(1);
	return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

vector<pair<ll, ll>> vp;
int main(void)
{
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        ll A, B;
        cin >> A >> B;
        vp.push_back({A, B});
    }

    ll cnt = 0;

    for (int i = N - 1; i >= 0; --i)
    {
        vp[i].first += cnt;
        if (vp[i].first % vp[i].second != 0)
            cnt += vp[i].second - vp[i].first % vp[i].second;
    }

    cout << cnt << endl;
    return 0;
}

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

#define ALL(x) (x).begin(), (x).end()
#define EB emplace_back

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

const int INF = 0x3f3f3f3f;

struct Cmd {
    char c;
    int a, b;
};

struct Sector {
    Sector(){}
    Sector(int _b, int _e, int _l) : b(_b), e(_e), l(_l) {}
    int b, e, l;
    bool operator < (const Sector &s) const {
        return b < s.b;
    }
};

int N;

vector<Cmd> cmds;

void dump(vector<Sector> &ss) {
    VI ts(10, -1);
    cout << "---" << endl;
    for (auto &s : ss) {
        cout << s.b << " " << s.e << " " << s.l << endl;
        for (int i = s.b; i < s.e; i++) {
            ts[i] = s.l;
        }
    }
    for (auto t : ts) cout << t << " ";
    cout << endl;
    cout << "/---" << endl;
}

void cmd_write(vector<Sector> &ss, int l, int size) {
    int begin = 0;
    
    for (auto &s : ss) {
        if (begin < s.b) {
            int end = min(s.b, begin + size);
            ss.EB(begin, end, l);

            size -= end - begin;

            if (size == 0) {
                break;
            }
        }

        begin = s.e;
    }

    if (size) {
        int end = begin + size;
        ss.EB(begin, end, l);
    }

    sort(ALL(ss));

}

void cmd_delete(vector<Sector> &ss, int l) {
    for (int i = 0; i < (int)ss.size(); i++) {
        if (ss[i].l == l) {
            ss.erase(ss.begin() + i);
            --i; // ???????????????????????´
        }
    }
}

int cmd_reference(vector<Sector> &ss, int p) {
    for (auto &s : ss) {
        if (s.b <= p && p < s.e) {
            return s.l;
        } else if (p < s.b) {
            return -1;
        }
    }

    return -1;
}

void solve() {
    vector<Sector> ss;

    for (int i = 0; i < N; i++) {
        if (cmds[i].c == 'W') {
            cmd_write(ss, cmds[i].a, cmds[i].b);
        } else if (cmds[i].c == 'D') {
            cmd_delete(ss, cmds[i].a);
        } else if (cmds[i].c == 'R') {
            cout << cmd_reference(ss, cmds[i].a) << endl;
        }
//        dump(ss);
    }

}

int main(void) {
    while (cin >> N, N) {
        cmds.clear();
        cmds.resize(N);

        for (int i = 0; i < N; i++) {
            cin >> cmds[i].c;

            if (cmds[i].c == 'W') {
                cin >> cmds[i].a >> cmds[i].b;
            } else {
                cin >> cmds[i].a;
            }
        }

        solve();
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1400
#include<cstdio>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<=0&&b>=0){
		printf("Zero\n");
	}else if(a>0&&b>0){
		printf("Positive\n");
	}else if(a<0&&b<0){
		if((b-a+1)%2==1){
			printf("Negative\n");
		}else{
			printf("Positive\n");
		}
	}
	return 0;
}

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

using namespace std;

#define rep(i , n) for(int i=0 ; i<n ; i++)
#define rep1(i , n) for(int i=1 ; i<=n ; i++)

typedef long long int ll;


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

	int a[20],b[20],c[20];
	int n;
	cin >> n;
	rep(i , n)
		cin >> a[i];
	rep(i , n)
		cin >> b[i];
	rep(i , n)
		cin >> c[i];

	int sum = 0;int prev = -1;
	for(int i=0 ; i<n ; i++)
	{
		int index = a[i];
		sum += b[index-1];
		if(index >= 2 && prev == index-2)
			sum += c[index-2];
		prev = index-1;
	}
	cout << sum;

	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  vector<lli> v(3);
  lli k;
  while (cin >> v[0] >> v[1] >> v[2] >> k) {
    sort(v.begin(), v.end());
    v.back() *= 1LL << k;
    cout << accumulate(v.begin(), v.end(), 0LL) << endl;
  }
  
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a), end(a)

int main(void) {
	string S;
  	cin >> S;
  	bool c = false;
  	bool f = false;
  	REP(i,S.size()){
      	if (!c && S[i] == 'C'){
          	c = true;
        }
      	else if (c && S[i] == 'F') {
          	f = true;
        }
    }
  	if (c && f) cout << "Yes" << endl;
  	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>
#include <cassert>

using ll = long long;
using ull = unsigned long long;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll NOT_SPECIFIED_VALUE_MIN = INT64_MIN;
constexpr ll NOT_SPECIFIED_VALUE_MAX = INT64_MAX;

int main() {
	ll n;
	cin >> n;
	vector<ll> edgeList;
	for (ll i = 0; i < n; i++) {
		ll tmp;
		cin >> tmp;
		edgeList.push_back(tmp);
	}
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = i + 1; j < n; j++) {
			for (ll k = j + 1; k < n; k++) {
				if (edgeList[i] == edgeList[j] || edgeList[j] == edgeList[k] || edgeList[k] == edgeList[i]) {
					continue;
				}
				ll lengthSum = edgeList[i] + edgeList[j] + edgeList[k];
				ll maxLength = max(max(edgeList[i], edgeList[j]), edgeList[k]);
				if (lengthSum - maxLength > maxLength) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3604
#include<cstdio>
int n,a[233],flg=1;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n&&flg;i++)
        if(a[i]%2==0&&a[i]%3&&a[i]%5)flg=0;
    puts(flg?"APPROVED":"DENIED");
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)

	nums := make([]int, 0, n)
	for i := 0; i < n; i++ {
		var num int
		fmt.Scanf("%d", &num)
		nums = append(nums, num)
	}

	count := 0
	for isAllEven(nums) {
		for i := 0; i < n; i++ {
			nums[i] /= 2
		}
		count++
	}

	fmt.Println(count)
}

func isAllEven(arr []int) bool {
	for _, v := range arr {
		if v%2 != 0 {
			return false
		}
	}
	return true
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
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;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

  ll a = input();
  ll b = input();
  ll c = input();

  swap(a,b);
  swap(a,c);

  cout << a << " " << b << " " << c << endl; 
 
  return 0;
}


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

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');

            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);

            if (a == 1 && b == 1)
            {
                Console.WriteLine("Draw");
            }
            else if (a == 1)
            {
                Console.WriteLine("Alice");
            }
            else if (b == 1)
            {
                Console.WriteLine("Bob");
            }
            else if (a == b)
            {
                Console.WriteLine("Draw");

            }
            else if (a > b)
            {
                Console.WriteLine("Alice");
            }
            else
            {
                Console.WriteLine("Bob");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	int n;
	string s, t;
	vector<char> v;
	cin >> n >> s >> t;
	for (int i = 0; i < n; i++) {
		v.push_back(s[i]);
		v.push_back(t[i]);
	}
	for (int i = 0; i < 2*n; i++) {
		cout << v[i];
	}
	cout << endl;
	return 0;
}

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

int main(){
 int a,b,c;
 cin >> a >> b >> c;
 bool ok=false;
 for(int i=1;i<b;i++){
   if((a*i)%b==c)ok=true;
 }
 if(ok)cout << "YES" << endl;
 else cout << "NO" << endl;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    sort(A, A+N);
    ll zero = 0;
    rep(i,0,N){
        if(A[i] == 0) zero++;
    }
    vector<ll> plus, minus;
    rep(i,0,N){
        if(A[i] > 0) plus.push_back(A[i]);
        else if(A[i] < 0) minus.push_back(A[i]);
    }
    ll zero_cnt = N*(N-1)/2 - (N-zero) * (N-zero-1) / 2;
    ll lv = -1e18+1, rv = 1e18+1;
    ll nplus = plus.size(), nminus = minus.size();
    while(rv - lv > 1){
        ll mid = (rv + lv) / 2;
        ll res = 0, res2 = 0;
        rep(i,0,nplus){
            ll v = plus[i];
            if(mid >= 0){
                ll v2 = mid / v;
                ll ps = upper_bound(plus.begin(), plus.end(), v2) - plus.begin();
                res += max(0LL, ps - (i+1));
            }
            if(mid >= 0){
                res2 += nminus;
            }else{
                ll v2 = - (-mid + v - 1) / v;
                ll ps = upper_bound(minus.begin(), minus.end(), v2) - minus.begin();
                res2 += ps;
            }
        }

        rep(i,0,nminus){
            ll v = minus[i];
            if(mid >= 0){
                ll v2 = (-1) * (mid / -v);
                ll ps = lower_bound(minus.begin(), minus.end(), v2) - minus.begin();
                res += min(nminus-ps, nminus - i - 1);
            }
            if(mid >= 0){
                res2 += nplus;
            }else{
                ll v2 = (-mid + abs(v) - 1) / abs(v);
                ll ps = lower_bound(plus.begin(), plus.end(), v2) - plus.begin();
                res2 += nplus - ps;
            }

        }

        res += res2 / 2;
        if(mid >= 0) res += zero_cnt;

        if(res >= K){
            rv = mid;
        }else{
            lv = mid;
        }
    }
    print(rv);

}

Measured memory_bytes: 4084
import java.util.*;
class Main{
    static long INF = 1001001001001001001L;
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] x = new long[n];
        int k = scanner.nextInt();
        long min = Long.MAX_VALUE;
        for(int i = 0; i < n; i++){
            x[i] = scanner.nextInt();
        }
        for(int i = 0; i < n-k + 1; i++){
            int l = i;
            int r = i+k-1;
            long cur = Math.min(Math.abs(x[l]) + Math.abs(x[r]-x[l]), Math.abs(x[r]) + Math.abs(x[r]-x[l]));
            min = Math.min(cur, min);
        }
        if(min == Long.MAX_VALUE){System.out.println(0);return;}
        System.out.println(min);
    }
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.pb(i);
      if(i * i != n) ret.pb(n / i);
    }
  }
  sort(All(ret));
  return (ret);
}

int divisorNum(ll n) {
  vector<ll> ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.pb(i);
      if(i * i != n) ret.pb(n / i);
    }
  }
  return (ret.size());
}

set<ll> S;

void decompositPrime(ll n)
{
    // 割る数の初期値
    ll a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            S.insert(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    S.insert(n);
}


int main() {
  ll A, B;
  cin >> A >> B;
  ll gcd = __gcd(A, B);
  S.insert(1);

  decompositPrime(gcd);

  cout << S.size() << endl;

};


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;

int main() {
	int R;
	string next;
	cin >> R;
	if (R < 1200) {
		next = "ABC";
	}
	else if (R < 2800) {
		next = "ARC";
	}
	else {
		next = "AGC";
	}
	cout << next << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(void){
  int n,a,b,c; 

  while(cin>>n && n){
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;

      double me = (a + b) / 2.0;
      double avg = (a + b + c) / 3.0;

      if(a==100 || b==100 || c==100 || me >= 90 || avg >= 80)
        cout<<"A\n";
      else if(avg >= 70 || avg >= 50 && (a >= 80 || b >= 80))
        cout<<"B\n";
      else
        cout<<"C\n";
    }
  }

  return 0;
}

Measured memory_bytes: 1124
#include<bits/stdc++.h>
#define ii long int
using namespace std;
ii funk(ii i,ii n,ii m,vector <ii> v[],int start[],ii dp[])
{
	if(v[i].empty())
	return 0;
	vector <ii> :: iterator it;
	ii max=-1;
	for(it=v[i].begin();it!=v[i].end();it++)
	{
		if(dp[*it]==-1)
		dp[*it]=funk(*it,n,m,v,start,dp);
		if(dp[*it]>max)
		max=dp[*it];
	}
	return dp[i]=max+1;
}
int main()
{
	ii n,m,x,y,i;
	cin>>n>>m;
	vector <ii> v[n+1];
	int start[n+1];
	ii dp[n+1];
	for(i=0;i<=n;i++)
	{
		dp[i]=-1;
		start[i]=-1;
	}
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		start[y]=1;
		v[x].push_back(y);
	}
	ii max=-1,temp;
	for(i=0;i<=n;i++)
	{
		if(start[i]==-1)
		{
			temp=funk(i,n,m,v,start,dp);
			if(temp>max)
			max=temp;
		}
	}
	cout<<max;
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, a[114514], ki;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (a[i] % 2)ki++;
	}
	if (ki % 2)cout << "NO" << endl;
	else cout << "YES" << endl;
	endre;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

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

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }


int main() {
  long long n, k; cin>>n>>k;
  vector<int> a(n+1);
  rep(i, n) cin>>a[i+1];

  vector<bool> visited(n+1, false);
  int cur = 1;
  while (visited[cur] == false) {
    visited[cur] = true;
    cur = a[cur];
  }
  int loopstart = cur;
  int firstcnt = 0;
  cur = 1;
  while (cur != loopstart) {
    ++firstcnt;
    cur = a[cur];
  }
  int loopcnt = 0;
  cur = loopstart;
  do {
    ++loopcnt;
    cur = a[cur];
  } while (cur != loopstart);

  if (k <= (long long)firstcnt) {
    int ans = 1;
    rep(i, (int)k) ans = a[ans];
    print(ans);
  } else {
    long long rem = (k - firstcnt) % loopcnt;
    int ans = 1;
    rep(i, firstcnt) ans = a[ans];
    rep(i, rem) ans = a[ans];
    print(ans);
  }

  return 0;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,m,a[N],f[N];
priority_queue<int,vector<int>,greater<int> >q[N];
int getf(int x){return f[x]==x?x:f[x]=getf(f[x]);}
priority_queue<int,vector<int>,greater<int> >s;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) f[i]=i;
    while(m--)
    {
        int u,v;scanf("%d%d",&u,&v);
        u++;v++;
        f[getf(u)]=getf(v);
    }
    for(int i=1;i<=n;i++) q[getf(i)].push(a[i]);
    int tot=0,sum;
    for(int i=1;i<=n;i++)
        if(f[i]==i) tot++;
    if(tot==1){printf("0\n");return 0;}
    sum=(tot-1)*2;
    ll ans=0;
    for(int i=1;i<=n;i++)
        if(f[i]==i)
    {
        ans+=q[i].top(),q[i].pop();
        while(!q[i].empty())
            s.push(q[i].top()),q[i].pop();
        sum--;
    }
    while(sum&&!s.empty())
    {
        sum--;ans+=s.top();s.pop();
    }
    if(sum) printf("Impossible\n");
    else printf("%lld\n",ans);
}


Measured memory_bytes: 7296
N = int(input())
S=[]
for _ in range(N):
    D = list(map(int, input().split()))
    S.append(D)
S.sort(key=lambda x:x[1])

now=0
for job in S:
    now+=job[0]

    if now > job[1]:
        print("No")
        exit()

print("Yes")

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

// Description: ??°??????????????????(?????????????°??????¨???)
// Verifyed: Many Diffrent Problem 

//Appropriately Changed
using edge=struct{int to;};
using G=vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph,int from,int to){ 
	graph[from].push_back({to});
}

// Description: ????????°????????????????????¢?????? 
// TimeComplexity: $ \mathcal{O}(V + E) $
// Verifyed: AOJ GRL_3_A 


auto articulation_point(const G& graph){
    int n=graph.size(),k=0;
    vector<int> par(n),ord(n,-1),low(n),root(n,0);


    auto dfs=[&](int v,int p,int &k){
	    auto func=[&](int v,int p,int &k,auto func)->void{
	        ord[v]=k++,low[v]=ord[v],par[v]=p;
	        
	        for(auto &e:graph[v]){
	            if(e.to==p) continue;
	            if(ord[e.to]==-1)
	                func(e.to,v,k,func),chmin(low[v],low[e.to]);
	            else
	                chmin(low[v],ord[e.to]);
	        }
	    };
	    return func(v,p,k,func);
	};

    rep(v,n) if(ord[v]==-1) dfs(v,-1,k),root[v]=1;

    vector<int> res;
    rep(v,n){
        if(root[v]){
        	int degree=0;
        	for(auto &e:graph[v]) if(v==par[e.to]) degree++;
            if(degree>=2) res.push_back(v);
        }else{
            for(auto &e:graph[v]){
                if(v==par[e.to]&&ord[v]<=low[e.to]){
                    res.push_back(v);
                    break;
                }
            }
        }
    }
    return res;      
}

int main(void){
	int v,e;
	cin >> v >> e;
	G graph(v);
	rep(i,e){
		int a,b;
		cin >> a >> b;
		add_edge(graph,a,b);
		add_edge(graph,b,a);
	}

	auto res=articulation_point(graph);
	for(auto &it:res) cout << it << endl; 
	return 0;
}

Measured memory_bytes: 4544
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (((ll)1<<31)-1)
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie acos(-1)
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
string s;
map<string,int> mp;
signed main(){
	int maw=0;
	string mw;
	while(cin>>s){
		mp[s]++;
		if(s.size()>maw){
			mw=s;
			maw=s.size();
		}
	}
	int ofw=0;
	string ow;
	for(pair<string,int> p:mp){
		if(p.second>ofw){
			ofw=p.second;
			ow=p.first;
		}
	}
	cout<<ow<<" "<<mw<<endl;
	return 0;
}


Measured memory_bytes: 3028
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
            res = res * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main () {

  ll h; cin >> h;

  ll ans = 0;
  ll dep = 0;

  while (h > 0) {
    ans += mod_pow(2, dep, INFLL);
    h /= 2;
    dep++;
  }

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




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <vector>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))

int main() {
	char a[5];
	scanf("%s", a);
	for (int i = 0; i < 3; i++) {
		if (a[i] == '1')a[i] = '9';
		else if (a[i] == '9')a[i] = '1';
	}
	printf("%s", a);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include  <cassert>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

signed main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n, 0);
	rep(i, n) cin >> a[i];
	int odd = 0;
	rep(i, n) {
		if (a[i] % 2 != 0) odd++;
	}
	if (odd % 2 != 0) {
		cout << "NO\n";
	}
	else {
		cout << "YES\n";
	}
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

    int mod = (int)1e9 + 7;
    int l = S.length();
    int c = 13;
    int mul = 1;

    vector<vector<int>> dp(l + 1, vector<int>(c, 0));
    dp[0][0] = 1;

    for (int i = l - 1; i >= 0; i--)
    {
        if (S[i] == '?')
        {
            for (int j = 0; j < 10; j++)
            {
                for (int k = 0; k < c; k++)
                {
                    dp[l - i][(mul * j + k) % c] += dp[l - i - 1][k];
                    dp[l - i][(mul * j + k) % c] %= mod;
                }
            }
        }

        else
        {
            int j = S[i] - '0';
            for (int k = 0; k < c; k++)
            {
                dp[l - i][(mul * j + k) % c] += dp[l - i - 1][k];
                dp[l - i][(mul * j + k) % c] %= mod;
            }
        }
        
        mul = mul * 10 % c;
    }
    
    cout << dp[l][5] << endl;
    return 0;
}

Measured memory_bytes: 8960
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   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) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int N = 22, MOD = (int)1e9 + 7;

int dp[1 << N];
int ar[N][N];
int n;

inline int add (int a, int b) { return ((a%MOD) + (b%MOD)) % MOD; };

void solve() {
   dp[0] = 0;

   for (int k = 0; k < n; ++k) {
      if (ar[1][k+1]) dp[1 << k] = 1;
   }

   for (int i = 2; i <= n; ++i) {
      for (int j = (1 << n)-1; j >= 1; --j) {
         if (__builtin_popcount(j) != i) continue;
         for (int k = 0; k < n; ++k) {
            if (ar[i][k+1] && (j & (1 << k))) dp[j] = add(dp[j], dp[j - (1 << k)]);
         }
      }
   }
   int total = dp[(1 << n)-1];
   cout << total << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n;
   for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
         cin >> ar[i][j];
   solve();

   return EXIT_SUCCESS;
}




Measured memory_bytes: 10496
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long a, b, c, d, e, f = 0, g = 0, k = 0;
	cin >> a >> b >> c;
	for (int h = 1; h <= a; h++) {
		cin >> d;
		if (d <= b) {
			f++;
		}
		else if (d > c) {
			k++;
		}
		else {
			g++;
		}
	}
	cout << min(f, min(g, k)) << endl;
	cin >> e;
}

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

int main() {
  std::string s;
  std::cin >> s;
  int ans = 0;
  int m = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'R') {
      ans++;
      m = std::max(ans, m);
    }
    else
      ans = 0;
  }
  printf("%d\n", m);
}


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n;
    cin>>n;
    if(n%10==3)
        cout<<"bon"<<endl;
    else if((n%10==8) || (n%10==6) || (n%10==1) || (n%10==0))
        cout<<"pon"<<endl;
    else{
        cout<<"hon"<<endl;
    }
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3528
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                Map hs = new HashMap();
                PrintWriter ou = new PrintWriter(System.out);
                long a = Long.parseLong(sc.next());
                long b = Long.parseLong(sc.next());
                long k = Long.parseLong(sc.next());
                k = Long.parseLong(sc.next());
                sc.close();
                if(k % 2 == 0) k = 1;
                else k = -1;
                ou.print((long)((a - b) * k) + "\n");
                ou.flush();
        }
}

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

using namespace std;

int main() {

	long n, k, q;
	cin >> n >> k >> q;

	vector<long> a(n + 1, 0);
	long aa;
	for (long i = 1; i <= q; i++) {
		cin >> aa;
		a[aa]++;
	}

	for (long i = 1; i <= n; i++) {

		cout << (a[i]+k-q>0? "Yes" : "No") << endl;

	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

struct init{
    init(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
} init;

class DisjointSet {
  public:
    VI rank; // height of tree
    VI p; // parent of each node

    DisjointSet(int size) {
      rank.resize(size, 0);
      p.resize(size, 0);
      REP0(i,size) makeSet(i);
    }

    void makeSet(int x){ // x の単元集合
      p[x] = x;
      rank[x] = 0;
    }

    bool same(int x, int y){
      return findSet(x) == findSet(y);
    }

    void unite(int x, int y){
      link(findSet(x), findSet(y));
    }

    void link(int x, int y){  // root同士であることを前提に, 親の挿げ替え
      if ( rank[x] > rank[y] ) {
        p[y] = x; // set y's parent to x
      }else{
        p[x] = y;
        if (rank[x] == rank[y] ){
          rank[y]++;
        }
      }
    }

    int findSet(int x){ // root's parent is itself
      if ( x != p[x] ){ // recursively get root of tree including x
        p[x] = findSet(p[x]);
      }
      return p[x];
    }
};


int main(int argc, char const *argv[]) {
  int n, q;
  std::cin >> n >> q;
  DisjointSet ds = DisjointSet(n);
  REP0(i,q){
    int com, x, y;
    std::cin >> com >> x >> y;
    if ( com == 0 ) ds.unite(x, y);
    else if( com == 1 ){
      std::cout << ds.same(x, y) << '\n';
    }
  }

  return 0;
}



Measured memory_bytes: 3264
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define _ << " " <<
#define all(v) v.begin(), v.end()

using namespace std;
using ll = long long;

const int mod = 1000000007;

struct edge {
	int v, x;
};

vector<edge> g[101000];
bool used[101000];
int ans[101000];

void dfs(int v, ll len) {
	if (!used[v]) {
		used[v] = true;
		if (len % 2) ans[v] = 1;
		for (edge i : g[v]) dfs(i.v, len + i.x);
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v, x;
		cin >> u >> v >> x;
		g[u].push_back({ v, x });
		g[v].push_back({ u, x });
	}
	int t = 0;
	for (int i = 1; i <= n; i++) {
		if (g[i].size() == 1) {
			t = i;
			break;
		}
	}
	dfs(t, 0);
	for (int i = 1; i <= n; i++) cout << ans[i] << "\n";
	return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
    int N;
    string s;
    cin>>N>>s;
    int fa=0;
    int la=0;
    int c=0;
    REP(i,s.size()){
        if(s[i]=='('){
           c++;
        }else{
           if(c==0){
              fa++;
           }else{
              c--;
           }
        }
    }
    la=c;
    string ans="";
    REP(i,fa){
        ans.push_back('(');
    }
    REP(i,s.size()){
        ans.push_back(s[i]);
    }
    REP(i,la){
        ans.push_back(')');
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>

using namespace std;

int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    int aa=0,bb=0,cc=0,abc=1;
    for(int i=0;i>-1;i++){
        if(abc==1){
            if(a[0]=='a'){
                abc=1;
            }
            else if(a[0]=='b'){
                abc=2;
            }
            else if(a[0]=='c'){
                abc=3;
            }
            else{
                cout<<"A"<<endl;
                return 0;
            }
            a.erase(0,1);
        }
        else if(abc==2){
            if(b[0]=='a'){
                abc=1;
            }
            else if(b[0]=='b'){
                abc=2;
            }
            else if(b[0]=='c'){
                abc=3;
            }
            else{
                cout<<"B"<<endl;
                return 0;
            }
            b.erase(0,1);
        }
        else if(abc==3){
            if(c[0]=='a'){
                abc=1;
            }
            else if(c[0]=='b'){
                abc=2;
            }
            else if(c[0]=='c'){
                abc=3;
            }
            else{
                cout<<"C"<<endl;
                return 0;
            }
            c.erase(0,1);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
//T1 C2 A3 G4
int dp[5][5][5][110];
int mod = 1000000007;
signed main() {
	int n; cin >> n;
	dp[1][1][1][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int p = 1; p <= 4; p++) {
			for (int q = 1; q <= 4; q++) {
				for (int r = 1; r <= 4; r++) {
					for (int s = 1; s <= 4; s++) {
						if (q == 3 && r == 4 && s == 2);
						else if (p == 3 && (q == 4 || r == 4) && s == 2);
						else if (q == 4 && r == 3 && s == 2);
						else if (q == 3 && r == 2 && s == 4);
						else dp[q][r][s][i] += dp[p][q][r][i - 1];
						dp[q][r][s][i] %= mod;
					}
				}
			}
		}
	}
	int ans = 0;
	for (int p = 1; p <= 4; p++) for (int q = 1; q <= 4; q++) for (int r = 1; r <= 4; r++) {
		ans += dp[p][q][r][n]; ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
use std::collections::HashMap;
use std::collections::HashSet;
 
const MOD : u64 = 1_000_000_000 + 7;
 
fn main() {
    
    let n = read::<String>();
    //let a = (0..n).map(|_| { (0..n-1).map(|_| { read::<usize>() - 1 }).collect::<Vec<_>>() }).collect::<Vec<_>>();
    
    let length = n.len();
    
    let ans : usize = n.chars().enumerate().filter(|&(index, x)|
        if index % 2 == 0 {
            match x {
                'R' | 'U' | 'D' => true,
                _ => false,
            }
        } else {
            match x {
                'L' | 'U' | 'D' => true,
                _ => false
            }
        }
    ).map(|_| 1usize).sum();
    
    if ans == length  { println!("Yes"); }
    else { println!("No"); }
}

Measured memory_bytes: 4352
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

struct Edge{
	int to;
  	int cost;
};

vector<vector<Edge>> g;	// 頂点数 n のグラフ（木）
vll dist;				// 頂点 k からの距離

void dfs(int v, int p=-1){
	for(auto e: g[v]){
      	if(e.to == p) continue;
    	dist[e.to] = dist[v] + e.cost;
      	// cout << v << "->" << e.to << endl;
      	dfs(e.to, v);
    }
}

void Main()
{
	int n;
  	cin >> n;
  	g.resize(n);
	rep(i,n-1){
    	int a, b, c;
      	cin >> a >> b >> c;
      	a--; b--;
      	g[a].eb(Edge{b,c});
      	g[b].eb(Edge{a,c});
    }
  	
    dist.resize(n,0);
  	int q, k;
  	cin >> q >> k;
  	k--;
  	dfs(k);
  	rep(i,q){
    	int x, y;
      	cin >> x >> y;
      	x--; y--;
      	cout << dist[x]+dist[y] << endl;
    }
	return;
}

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

Measured memory_bytes: 12800
#include<iostream>
#include<string>
#include<cstdlib>


using namespace std;

int main(){
	long double c;
	long double d;
	cin>>c;
	cin>>d;
	if(c > d){
		cout<<"GREATER"<<endl;
	}
	else if(c < d){
		cout<<"LESS"<<endl;
	}
	else{
		cout<<"EQUAL"<<endl;
	}
	
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 504