akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;
typedef long long ll;
#define MOD 1000000007

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main()
{
	ll n,k;
  	cin >> n >> k;
  	for(ll i = 1; i <= k; i++){
      	ll ans = 1;
    	for(ll j = 0; j < i-1; j++){
        	ans *= k-1-j;
          	ans %= MOD;
        }
      	for(ll j = 0; j < i-1; j++){
        	ans = ans * modinv(i-1-j, MOD) % MOD;
        }
        
  
      	for(ll j = 0; j < i; j++){
        	ans *= n-k+1-j;
          	ans %= MOD;
        }
      	for(ll j = 0; j < i; j++){
        	ans = ans*modinv(i-j, MOD) % MOD;
        }
    	cout << ans << endl;
    }
}

Measured memory_bytes: 256
n,m = map(int,input().split())
v = [0] * m
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(1,a[0]+1):
        v[a[j]-1] += 1
ans = 0
for i in range(m):
    if v[i] == n: ans += 1
print(ans)

Measured memory_bytes: 3064
N = int(input())
input_lis = [list(map(int,input().split())) for _ in range(N)]

can = True

for n in range(len(input_lis)):
    dis = 0
    t = 0
    if n == 0:
        dis = abs(input_lis[n][1]) + abs(input_lis[n][2])
        t = abs(input_lis[n][0])
    else:
        dis = abs(input_lis[n][1] - input_lis[n-1][1]) + abs(input_lis[n][2] - input_lis[n-1][2])
        t = abs(input_lis[n][0]) - abs(input_lis[n-1][0])
    
    if dis == t:
        continue
    if dis < t and ((t - dis) % 2) == 0:
        continue
    can = False
    break

if can:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 27324
fn main() {
    let n = read::<usize>();
    let v = read_vec::<u64>();
    let div: u64 = 1000000007;

    let mut dp = vec![0u64; n + 1];
    let mut kind = vec![0u64; 3];
    //let mut ans: u64 = 0;

    dp[0] = 1;
    for i in 1..n+1 {
        let count = kind.iter().filter(|&x| *x == v[i-1]).count();

        dp[i] = dp[i - 1] * (count as u64);
        dp[i] %= div;

        for k in 0..3 {
            if kind[k] == v[i-1] {
                kind[k] += 1;
                break;
            }
        }
    }

    /*
    let colors_count = kind.iter().filter(|&x| *x>0).count();
    if colors_count == 1 {
        ans = dp[n-1] * 3 % div;
    } else if colors_count == 2 {
        ans = dp[n-1] * 6 % div;
    } else if colors_count == 3 {
        ans = dp[n-1] * 6 % div;
    }
    */
    println!("{}", dp[n]);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 6396
#include <iostream>
using namespace std;
long long fibo(int n){
    int F[n];
    F[0] = F[1] = 1;
	for(int i = 2; i <= n; i++)
        F[i] = F[i-1]+F[i-2];
	return F[n];
}

int main(void){
    int n;
	cin >> n;
	cout << fibo(n) << endl;
	return 0;
}



Measured memory_bytes: 3116
#include <algorithm>
#include <functional>
#include <iostream>

using namespace std;

#define ALL(x) begin(x), end(x)

int main() {
  string s,t;
  cin >> s >> t;
  sort(ALL(s));
  sort(ALL(t),greater<>());
  cout << (s < t ? "Yes" : "No") << endl;
  return 0;
}


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

typedef long long ll;

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

    string s;
    cin >> s;
    int cnt1=0,cnt2=0;
    int size = s.size();
    for(int i=0;i<size;i++){
        if(i%2==0){
            if(s[i]=='R' || s[i]=='U' || s[i]=='D') cnt1++;
        }else{
            if(s[i]=='L' || s[i]=='U' || s[i]=='D') cnt2++;
        }
    }
    if(size%2==0){
        if(cnt1==size/2 && cnt2==size/2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        if(cnt1==size/2+1 && cnt2==size/2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    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;
	cin >> n;
	vector<tuple<string, int, int>> a;
	for(int i=0;i<n;i++) {
		string s;
		int p;
		cin >> s >> p;
		p = -p;
		a.push_back(tie(s, p, i));
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
			string s;
			int p;
			int id;
			tie(s, p, id) = a[i];
			cout << id+1 << endl;
	}


	return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	var pre rune
	num := 0
	for _, v := range s {
		if pre != v {
			num++
			pre = v
		}
	}
	fmt.Println(num)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H,N;
	cin >> H >> N;
	vector<int> vec(N);
	int sum=0;
	for (int i = 0; i < N; i++) {
  	cin >> vec.at(i);
    sum+=vec.at(i);
}

    if(sum<H){
  	cout << "No" << endl;
    }
    else{
  	cout << "Yes" << endl;
    }
}

Measured memory_bytes: 640
h, w = map(int, input().split())
costs = [list(map(int, input().split())) for _ in range(10)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j])

ans = 0
for _ in range(h):
    for n in map(int, input().split()):
        if n == -1:
            continue
        ans += costs[n][1]

print(ans)


Measured memory_bytes: 3064
n, m = map(int, input().split())

ac = [0] * n
wa = [0] * n
wa_total = 0
for _ in range(m):
    tmp_i, s = input().split()
    i = int(tmp_i) - 1
    if ac[i] == 1:
        continue
    if s == 'AC':
        ac[i] = 1
        wa_total += wa[i]
    else:
        wa[i] += 1

print(sum(ac), wa_total)


Measured memory_bytes: 4596
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val students = readLine.trim.split(' ').map(_.toInt)
  println(
    students.count(_ > m)
  )

  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


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

int main(){
	int n;
	cin>>n;
	int a[27];
	for(int i=1;i<=26;i++){
		a[i]=99999;
	}
	for(int i=1;i<=n;i++){
		string s;
		int b[27]={0};
		cin>>s;
		for(int i=0;i<s.size();i++){
			b[(s[i]-'a')+1]++;
		}
		for(int i=1;i<=26;i++){
			a[i]=min(a[i],b[i]);
		}
	}
	for(int i=1;i<=26;i++){
		for(int j=1;j<=a[i];j++){
			cout<<char(i+'a'-1);
		}
	}
	return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int anko = max({a,b,c});
  int maojini = a+b+c;
  if(maojini == 17 && anko == 7 && (maojini-anko)/2==5 ) cout << "YES";
  else cout << "NO";
  return 0;
}

Measured memory_bytes: 256
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2)
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial
from copy import deepcopy
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

#enumerate input

def main():
    n,m=map(int,input().split())
    py=[list(map(int,input().split()))+[i]for i in range(m)]
    py=sorted(sorted(py,key=lambda x:x[1]),key=lambda x:x[0])
    d=defaultdict(list)
    pre=py[0][0]
    num=1
    for p,_,i in py:
        if p==pre:
            d[i]=[p,num]
            num+=1
        else:
            num=2
            pre=p
            d[i]=[p,1]
#    print(d)
    for i in range(m):
        s,t=d[i]
        print(str(s).zfill(6)+str(t).zfill(6))

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 45360
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long a[n+1];
    long b[n];
    for(int i=0;i<=n;i++)cin >> a[i];
    for(int i=0;i<n;i++)cin >> b[i];

    long ans = 0;
    for(int i=0;i<n;i++){
        if(a[i] >= b[i])ans += b[i];
        else{
            ans += a[i];
            b[i] -= a[i];
            if(a[i+1] >= b[i]){
                a[i+1] -= b[i];
                ans += b[i];
            }else{
                ans += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e8;
typedef pair<int,int> P;

int main(){
  int N,n_max,n_max_2;cin>>N;
  vector<int> A(N),B(N);
  REP(i,0,N){
    cin>>A[i];
    B[i]=A[i];
  }
  sort(B.begin(),B.end(),greater<int>());
  n_max=B[0],n_max_2=B[1];
  REP(i,0,N)print((A[i]==n_max?n_max_2:n_max));
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
#define rep(i,n) for(int i=0; i<n; ++i)
using ll = long long;
const ll Inf = (1ULL << 62) -1;

void updatemax(ll& a, const ll& b) {
    if (a < b)
        a = b;
}

int main() {
    ll n;
    cin >> n;
    vector<array<ll,3>> h(n);
    rep(i,n) rep(j,3) cin >> h[i][j];

    vector<array<ll,3>> dp(n);
    rep(i,n) rep(j,3) dp[i][j] = 0;
    rep(i,3) dp[0][i] = h[0][i];

    for (int i=1; i<n; ++i) {
        rep(j,3)
            rep(k,3) {
                if (j != k)
                    updatemax(dp[i][k], dp[i-1][j] + h[i][k]);
            }
    }

    ll ans=0;
    rep(i,3)
        ans = max(ans, dp[n-1][i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7552
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>

int main() {
	double a, b, x, k;
	std::cin >> a >> b >> x;
	if (x > pow(a,2.0)*b/2.0){
		k = 2.0 * (a * b - x / a) / pow(a, 2.0);
		k = atan(k);
		k = k / M_PI * 180.0;
		printf("%20.20f", k);
	}
	else {
		k = a * pow(b, 2.0) / (2.0 * x);
		k = atan(k);
		k = k / M_PI * 180.0;
		printf("%20.20f", k);
	}
	
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define ll long long
#define mk make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
using namespace std;
const int MAXN=1e5+9;
const ll MOD=1e9+7;
inline ll fastexpo(ll base, ll expo, ll mod) {
	ll result=1;
	while(expo) {
		if(expo%2) {
			result=result*base;
			result%=mod;
		}
		base=base*base;
		base%=mod;
		expo=(expo/2ll);
	}
	return result;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	map<pll,ll> mp,rev_mp;
	for(int i=0;i<n;i++)
	{
		ll sign=1;
		ll x,y;
		cin>>x>>y;
		if(x<0)
		{
			sign*=-1;
		}
		if(y<0)
		{
			sign*=-1;
		}
		ll g;
		if(x==0&&y==0)
		{
			g=1;
		}
		else
		{
			g=__gcd(abs(x),abs(y));
		}
		x=x/g;
		y=y/g;
		y=abs(y);
		x=abs(x);
		x=sign*x;
		if(y==0)
		{
			x=abs(x);
		}
		mp[mk(x,y)]++;
	}
	ll fans=1;
	ll flag=0;
	ll glob=0;
	while(!mp.empty())
	{
		auto it=mp.begin();
		pll p=(it->first);
		ll num=p.first;
		ll den=p.second;
		swap(num,den);
		num=-num;
		ll sign=1;
		if(num<0)
		{
			sign=sign*-1;
		}
		if(den<0)
		{
			sign=sign*-1;
		}
		num=abs(num);
		den=abs(den);
		num=sign*num;
		if(den==0)
		{
			num=abs(num);
		}
		if(num==0&&den==0)
		{
			flag=mp[mk(num,den)];
		}
		else
		{
			if(mp.find(mk(num,den))!=mp.end())
			{
				ll ff=(it->second);
				ll ss=mp[mk(num,den)];
				fans=fans*((fastexpo(2,ff,MOD)+fastexpo(2,ss,MOD))-1)%MOD;
				fans%=MOD;
				if(fans<0)
				{
					fans+=MOD;
				}
				mp.erase(mp.find(mk(num,den)));
			}
			else
			{
				glob+=(it->second);
			}
		}
		mp.erase(it);
	}
	fans=fans*fastexpo(2,glob,MOD);
	fans%=MOD;
	fans+=flag;
	fans--;
	fans%=MOD;
	if(fans<0)
	{
		fans+=MOD;
	}
	fans%=MOD;
	cout<<fans<<endl;
	return 0;
}

Measured memory_bytes: 15976
using System;

namespace ALDS1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int element = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            int[] input = new int[element];
            for (int i=0; i<element; i++)
            {
                input[i] = int.Parse(str[i]);
            }

            int count = 0;
            for (int i=0; i<element; i++)
            {
                int minj = i;
                bool change = false;

                for (int j=i; j<element; j++)
                {
                    if (input[j] < input[minj])
                    {
                        minj = j;
                        change = true;
                    }
                }

                if (change == true)
                {
                    int tmp = input[minj];
                    input[minj] = input[i];
                    input[i] = tmp;
                    count++;
                }

            }

            for (int i=0; i<element; i++)
            {
                if (i != (element - 1))
                {
                    Console.Write("{0} ", input[i]);
                }
                else
                {
                    Console.Write(input[i]);
                }
            }
            Console.WriteLine();
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 9124
#include<stdio.h>

#define WHITE 0   // not visited yet.
#define GRAY 1    // visited, but not completed.
#define BLACK 2   // search completed.

int G[101][101];        // adjacency list.
int color[101];         // visited/completed sign.
int n;                  // size.
int d[101], f[101], t;  // first visit time/complete time.

void search_loop(int i) 
{
    int next;
    d[i] = ++t;
    color[i] = GRAY;  // first visited.

    for(next = 1; next <= n; next++){
        if(i == next && G[i][i] > 0) break;   // if self-looped, through.
        if(G[i][next] > 0 && color[next] == WHITE){  // if not visited yet, visit.
            search_loop(next);
        }
    }
    f[i] = ++t;
    color[i] = BLACK;  // completed. 

    return;
}

void dfs()
{
    int i;
    for(i = 1; i <= n; i++) color[i] = WHITE;  // initialize.
    t = 0;

    for(i = 1; i <= n; i++) if(color[i] == WHITE) search_loop(i);

    for(i = 1; i <= n; i++) printf("%d %d %d\n", i, d[i], f[i]);

    return ;
}

int main()
{
    int i, j, k, e;
    scanf("%d", &n);
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){ G[i][j] = 0; } }

    do{
        scanf("%d %d", &i, &e);
        for(j = 1; j <= e; j++){
            scanf("%d", &k);
            G[i][k] = 1;
        }
    }while(i < n);

    dfs();
    return 0;
}

Measured memory_bytes: 1068
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int main()
{
	int i;
	int a;
	vector<int> num;
	
	for(i=0;i<10;i++)
	{
		cin >> a ;
		num.push_back(a);
	}
	
	sort(num.begin(),num.end(),greater<int>());
	
	for(i=0;i<3;i++)
		cout << num[i] << endl;
}

Measured memory_bytes: 0
import java.util.Scanner;

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

        // 入力
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            System.out.print(a[i]);
            if (i == n - 1)
                break;
            System.out.print(" ");
        }
        System.out.println();

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

            // ソート
            int temp = a[i];
            int j = i - 1;
            while (j >= 0 && a[j] > temp) {
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = temp;

            // 出力
            for (int t = 0; t < n; t++) {
                System.out.print(a[t]);
                if (t == n - 1)
                    break;
                System.out.print(" ");
            }
            System.out.println();
        }
        sc.close();
    }
}


Measured memory_bytes: 33860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    int n;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        Set<String> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            set.add(s);
        }
        if (set.size() == 3) {
            System.out.println("Three");
        } else {
            System.out.println("Four");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


Measured memory_bytes: 22484
#include <iostream>
#include <string>
using namespace std;
int main()
{   
    string a,b;
    cin >> a >> b;
    if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]){
        cout <<"YES" <<endl;

    }
else{cout<<"NO"<<endl;}


    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split('\n');

    const N = parseInt(input[0], 10);
    const blue: string[] = input.slice(1, N + 1);
    const red: string[] = input.slice(N + 1, input.length + 1);

    const check = (str: string) => {
        const p = blue.filter(x => x == str).length;
        const m = red.filter(x => x == str).length;
        return p - m;
    }

    let result = 0;
    for (const str of blue.concat(red)) {
        const r = check(str);
        if (result < r)
            result = r;
    }
    console.log(result);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	ll res = 0;
	FOR(a,1,n) {
		ll bmax = (n-1)/a;
		res += bmax;
	}
	cout << res << endl;
}



Measured memory_bytes: 3656
#include <cstdio>

using namespace std;

int p, q, s, t, y, M;

int main(void) {
  scanf("%d%d%d%d%d%d", &s, &t, &p, &q, &M, &y);
  printf("%d\n", (t^s^y));
  return 0;
}



Measured memory_bytes: 2708
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n, a[101], x[100][101], y[101][101];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		for(int j = 0; j < a[i]; j++){
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	
	int ans = 0;
	for(int k = 1; k < (1 << n); k++){
		bool b = 0;
		for(int i = 0; i < n; i++){
			if((k >> i) & 1){
				for(int j = 0; j < a[i]; j++){
					if(y[i][j] == 0){
						if((k >> x[i][j]) & 1){
							b = 1;
						}
						if(b) break;
					}
					if(y[i][j] == 1){
						if(!((k >> x[i][j]) & 1)){
							b = 1;
						}
						if(b) break;
					}
				}
			}
			if(b) break;
		}
		if(!b){
			int cnt = 0;
			for(int i = 0; i < n; i++){
				if((k >> i) & 1){
					cnt++;
				}
			}
			ans = max(ans, cnt);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := oneInt()
	as := scanNums(n)
	ans := calc(n, as)
	fmt.Println(ans)

}

func calc(n int, as []int) int {
	L := make([]int, n+1)
	for i := 0; i < n; i++ {
		L[i+1] = gcd(L[i], as[i])
	}

	R := make([]int, n+1)
	for i := n - 1; i >= 0; i-- {
		R[i] = gcd(R[i+1], as[i])
	}

	ans := 0

	for i := 0; i < n; i++ {
		ans = max(ans, gcd(L[i], R[i+1]))
	}
	return ans
}

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

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 6912
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int a;
	string s;
	cin >> a;
	cin >> s;

	if (3200 <= a)
	{
		cout << s;
	}
	else
	{
		cout << "red";
	}
	cout << endl;

}

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

int main(){
    int h,w;
    cin >> h >> w;
    char s[h+2][w+2];
    char ans[h][w];
    for(int i=0;i<w+2;i++){
        s[0][i] = '.';
        s[h+1][i] = '.';
    }
    for(int i=0;i<h+2;i++){
        s[i][0] = '.';
        s[i][w+1] = '.';
    }
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){
        cin >> s[i][j];
        }
    }
    for(int i=1;i<h+1;i++){
        for(int j=1;j<w+1;j++){
            if(s[i][j] == '#'){
                ans[i-1][j-1] = '#';
                continue;
            }
            int tmp = 0;
            for(int k = -1;k<2;k++){
                for(int l = -1;l<2;l++){
                    if(s[i+k][j+l] == '#'){
                        tmp ++;
                    }
                }
            }
            ans[i-1][j-1] = tmp+'0';
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

int main(){
    llong n,k;
    vector<llong> A(100000);
    vector<llong> S(100000, 0);
    llong temp;
    llong maxv;

    while(1){
        cin >> n >> k;
        if(n==0  && k==0){
            break;
        }
        for(int i=0; i<n; i++){
                cin >> A[i];
        }
        maxv = INF*-1;
        for(int i=0; i<n; i++){
            S[i+1] = S[i] + A[i];
        }
        for(int i=0; i<n-k+1; i++){
            maxv = max(maxv, S[i+k]-S[i]);
        }
        cout << maxv << endl;
    }
    return 0;
}

//00:81 s


Measured memory_bytes: 4112
import fractions

n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]//=2

max=[0]*n

for i in range(n):
    wari=a[i]
    for j in range(100):
        if(wari%2==0):
            max[i]+=1
            wari//=2
        else:
            break

kanou=True
for i in range(1,n):
    if(max[i]!=max[0]):
        kanou=False
        break

if(not kanou):
    print(0)
else:
    kobai=a[0]
    for i in range(1,n):
        kobai=kobai*a[i]//fractions.gcd(kobai,a[i])
        if(kobai>m):
            break
    ans=1+((m-kobai)//(kobai*2))
    print(ans)

Measured memory_bytes: 16320
#include <iostream>
#include<algorithm>
#include<vector>
#define MAX 100000
using namespace std;

int main()
{
    int m,n,k;
    vector<int> x;
    vector<int> sum;
    int dis[MAX]={0};
    cin>>m;
    sum.resize(m,0);
    for(int i=0;i<m;i++)
    {
        cin>>n>>k;
        x.resize(n,0);
      
        for(int j=0;j<n;j++)
        {
            cin>>x[j];
            if(j>0)
                dis[j-1]=x[j]-x[j-1];
        }
        sort(dis,dis+n-1);
        for(int p=0;p<n-k;p++)
        {
            sum[i]+=dis[p];
        }
       // cout<<sum<<endl;
    }
    for(int i=0;i<m;i++)
        cout<<sum[i]<<endl;
    return 0;
}



Measured memory_bytes: 3928
#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 REP(i,n) for(int i=n-1;i>=(0);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 eall(v) unique(all(v), 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;
const ll INFF = 1e18;

#define WHITE 0
#define BLACK 1

vector<int> g[100010];
ll dp[100010][2];

int dfs(int u, int p, int color) {
	if (dp[u][color] != -1) return dp[u][color];

	ll cnt = 1;
	for (auto v : g[u]) {
		if (p == v) continue;
		ll cntw = dfs(v, u, WHITE);
		ll cntb = dfs(v, u, BLACK);
		if (color == WHITE) cnt *= (cntw + cntb);
		else cnt *= cntw;
		cnt %= MOD;
	}
	return dp[u][color] = cnt;
}

int main(int argc, char const *argv[])
{
	int n; cin >> n;

	vector<int> x(n - 1), y(n - 1); {
		rep(i, n - 1) {
			cin >> x[i] >> y[i];
			x[i]--, y[i]--;
			g[x[i]].pb(y[i]); g[y[i]].pb(x[i]);
		}
	}

	rep(i, 100010)rep(j, 2) dp[i][j] = -1;
	ll ans = dfs(0, -1, WHITE) + dfs(0, -1, BLACK);

	printf("%lld\n", ans % MOD);
	return 0;
}

Measured memory_bytes: 14976
#include<stdio.h>
int see(int inns[], int i, int n){
        for(int x=i; x>=0;x--){
            if(inns[i]<inns[x])return 0;
        }
    return 1;
}
int main(){
    int n;
    int inns[20];
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%d", &inns[i]);
    }
    int sum= 0;
    for(int i=0;i<n;i++){
        sum += see(inns, i, n);
        
    }
    printf("%d\n", sum);
    return 0;
} 

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  int time=0,d=0,t=0,s=0;
  scanf("%d %d %d",&d,&t,&s);
  time=d/s;
  if(d%s>0){
      time++;
    }
  if(time<=t){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1736
import sys
sys.setrecursionlimit(4100000)

from collections import Counter

N, M, K = map(int, input().split())

to = [[] for i in range(N)]
block = [[] for i in range(N)]
sets = []

is_visited = [False] * N
graph_g = [None] * N
graph_cnt = -1

def dfs(s, g):
    global graph_cnt
    if is_visited[s]:
        return 0

    is_visited[s] = True
    if g == None:
        graph_cnt += 1
        graph_g[s] = graph_cnt
    else:
        graph_g[s] = g

    for edge in to[s]:
        if graph_g[edge] == None:
            dfs(edge, graph_cnt)


for i in range(M):
    A, B = map(int, input().split())
    to[A-1].append(B-1)
    to[B-1].append(A-1)

for i in range(N):
    if is_visited[i]:
        continue
    dfs(i, None)

for i in range(K):
    C, D = map(int, input().split())
    if graph_g[C-1] == graph_g[D-1]:
        block[C-1].append(D-1)
        block[D-1].append(C-1)

ct = Counter(graph_g)

ret = []
for i in range(N):
    cand = ct[graph_g[i]]
    fri = len(to[i])
    tmp_block = len(block[i])

    tmp_ret = cand - fri - tmp_block - 1
    ret.append(tmp_ret)

print(*ret)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

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

	sort(a,a+n);
	int flag=0;
	if(n%2==0){
		rep(i,n-1){
			if(a[i]==i+1 && a[i+1]==i+1)i++;
			else {
				flag=1;
				break;
			}
		}
	}
	else {
		if(a[0]!=0)flag=1;
		for(int i=1;i<n-1;i++){
			if(a[i]==i+1 && a[i+1]==i+1)i++;
			else {
				flag=1;
				break;
			}
		}
	}

	if(flag==1){
		cout<<0<<endl;
		return 0;
	}

	int ans=1;
	rep(i,n/2){
		ans*=2;
		ans=ans%mod;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main() 
{
    arena
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll cnt=0;
    for(ll i=0;i<=s.size()-3;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = []
con= 0
for _ in range(D):
    S.append(list(map(int, input().split())))
#print(S)
t = []
for _ in range(D):
    t.append(int(input()))

last = [0]*26

for i in range(D):#1日ごと
    con += S[i][t[i]-1]
    #print(S[i][t[i]])
    last[t[i]-1] = i+1
    for j in range(26): #減少量の計算 #問題ごと
        con -= C[j]*(i-last[j]+1)
    
    
    print(con)

Measured memory_bytes: 74300
#include <stdio.h>
#define  MAX 100
#define FIRST 0
#define MIDDLE 1
#define END 2

int n,M[MAX][MAX];
int point[MAX],d[MAX],f[MAX],t;

void dfs_visit(int u){
    int v;
    point[u]=MIDDLE;
    d[u]=++t;
    for(v=0;v<n;v++){
        if(M[u][v]==0)continue;
        if(point[v]==FIRST){
            dfs_visit(v);
        }
    }
    point[u]=END;
    f[u]=++t;
}
void dfs(){
    int u;

    for(u=0;u<n;u++)point[u]=FIRST;
    t=0;

    for(u=0;u<n;u++){
        if(point[u]==FIRST)dfs_visit(u);
    }
    
    for(u=0;u<n;u++)printf("%d %d %d\n",u+1,d[u],f[u]);
}

int main(){
    int u,v,k,i,j;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++)M[i][j]=0;
    }
    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        u--;
        for(j=0;j<k;j++){
            scanf("%d",&v);
            v--;
            M[u][v]=1;
        }
    }
    dfs();
    
    return 0;
}


Measured memory_bytes: 2760
def submit():
    n, w = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(n)]
    
    if items[0][0] > w:
        print(0) # 1個も選べない
        return

    if sum([e[0] for e in items]) <=  w:
        print(sum([e[1] for e in items])) # 全部選べる
        return

    # 以降、必ず1個は選ぶ
    # かつbase_weight <= W < all_weight
    base_weight = items[0][0]
    
    # dp[i][j][k] : i番目までのアイテムのうち、j個を選んだ時、weight kで最大価値
    # weightはbase_weightからの差分をカウントする
    # dp[i + 1][j][k] = 
    #   dp[i][j][k], dp[i][j - 1][k - (w - base_weight)]
    # j * base_weight + k <= wの範囲で計算する
    
    dp = [[[0 for _ in range(3 * n + 1)] for _ in range(n + 1)] for _ in range(n + 1)]
    for i in range(1, n + 1):
        rw = items[i - 1][0] - base_weight
        v = items[i - 1][1]
        for j in range(i + 1):
            for k in range(3 * n + 1):
                if j * base_weight + k <= w:
                    if j - 1 >= 0 and k - rw >= 0:
                        dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][j - 1][k - rw] + v)
                    else:
                        dp[i][j][k] = dp[i - 1][j][k]
                else:
                    break

    ans = 0
    for j in range(n + 1):
        for k in range(3 * n + 1):
            ans = max(ans, dp[n][j][k])
    print(ans)

submit()

Measured memory_bytes: 68316
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC ZZZZZZ.
        01 C PIC 9(15).
      	01 t PIC 9(15).
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT A.
      		COMPUTE A = A * A * A.
      		MOVE A to B.
      		DISPLAY B.
		STOP RUN.

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main(){
int a[]={0,1,3,1,0,1,0,1,1,0,1,0,1};
int x,y;
cin>>x >>y;
if (a[x]==a[y]){
	cout<<"Yes"<<endl;
}
else{
	cout<<"No"<<endl;
}
	
return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> r;
  vector<int> g;
  vector<int> b;
  rep(i, n) {
    if (s[i] == 'R') r.push_back(i);
    if (s[i] == 'G') g.push_back(i);
    if (s[i] == 'B') b.push_back(i);
  }
  ll cnt = 0;
  for (int i = 0; i < r.size(); ++i) {
    for (int j = 0; j < g.size(); ++j) {
          int diff = g[j] - r[i];
          auto result = find(b.begin(), b.end(), g[j] + diff);
          auto result2 = find(b.begin(), b.end(), r[i] - diff);
          if((r[i] + g[j]) % 2 == 0) {
            auto result3 = find(b.begin(), b.end(), (r[i] + g[j])/2);
            if(result3 != b.end()) cnt--;
          }
          if(result != b.end()) cnt--;
          if(result2 != b.end()) cnt--;
          cnt += b.size();
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3668
import bisect

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

a.sort()
b.sort()
c.sort()

ans=0

for i in range(n):
    x=bisect.bisect_right(a,b[i]-1)
    y=n-bisect.bisect_left(c,b[i]+1)

    ans+=x*y

print(ans)

Measured memory_bytes: 23232
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll min(ll x, ll y){
    if(x < y)return x;
    else return y;
}

int main(void){
    int n, ma, mb;
    scanf("%d %d %d", &n, &ma, &mb);
    int ab[n], c[n];
    for(int i = 0;i < n;i++){
        int a, b;
        scanf("%d %d %d", &a, &b, &c[i]);
        //理想の比からのずれだけを記録
        ab[i] = b * ma - a * mb;
    }
    //i番目までの薬品でabの合計をj-4000にする
    //ために必要なコストがdp[i][j]
    int dp[n][8000];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 8000;j++){
            //初期値は十分大きい値
            dp[i][j] = mod;
        }
    }
    dp[0][4000+ab[0]] = c[0];
    for(int i = 1;i < n;i++){
        for(int j = 0;j < 8000;j++){
            if(dp[i-1][j]!=mod || j == 4000){
                //i番目は使わない
                dp[i][j] = min(dp[i-1][j], dp[i][j]);
                int plus;
                if(j==4000)plus = c[i];
                else plus = dp[i-1][j] + c[i];
                //i番目を使う
                dp[i][j + ab[i]] = min(dp[i][j + ab[i]], plus);
            }
        }
    }
    //n-1番目のコストが更新されていればそれを出力
    if(dp[n-1][4000] != mod)printf("%d\n", dp[n-1][4000]);
    else printf("-1\n");
    return 0;
}

Measured memory_bytes: 1408
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    K = int(input())
    A, B = iim()

    a, b = divmod(A, K)

    print("OK" if b == 0 or (a+1)*K <= B else "NG")

if __name__ == "__main__":
    resolve()


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef pair<double, double> P;

void print_line(vector<int> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

};


int main() {
    int n, m;
    cin >> n >> m;

    UnionFind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        uf.connect(a, b);
    }

    int q;
    cin >> q;

    rep(i, q) {
        int a, b;
        cin >> a >> b;

        cout << (uf.root(a) == uf.root(b) ? "yes" : "no") << endl;

    }

}




Measured memory_bytes: 3120
#include <cstdio>
#include <algorithm>
#include <vector>

#define fin stdin
#define fout stdout

using namespace std;

//FILE *fin = fopen("x.in", "r"), *fout = fopen("x.out", "w");

typedef long long i64;

const int nmax = 2e5;
int v[nmax + 1];

int main() {
    int n;
    fscanf(fin, "%d", &n);

    long long sum = 0, ans = (1LL << 60);
    for (int i = 1; i <= n; ++ i) {
        fscanf(fin, "%d", &v[ i ]);
        sum += v[ i ];
    }

    long long s = 0;
    for (int i = 1; i <= n - 1; ++ i) {
        s += v[ i ];
        sum -= v[ i ];

        ans = min(ans, abs(s - sum));
    }

    fprintf(fout, "%lld\n", ans);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

#include <atcoder/dsu>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



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

   int N, Q;
   cin >> N >> Q;

   atcoder::dsu d(N);

   REP(q, Q) {
      int t, u, v;
      cin >> t >> u >> v;
      if (t == 0)
         d.merge(u, v);
      else
         cout << d.same(u, v) << '\n';
   }

   return 0;
}


Measured memory_bytes: 3940
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List
import Data.Maybe

base = 10 ^ 9 + 7

mmul x y = (x * y) `mod` base
mpow x 0 = 1
mpow x y
  | odd y  = mmul x $ mmul t t
  | even y = mmul t t
  where
    t = mpow x $ div y 2

minv = flip mpow (base - 2)

c n k
  | k == 0 || k==n   = 1
  | k<0 || k > n     = 0
  | otherwise        = mmul (foldl1 mmul [n-k+1..n]) (minv $ foldl1 mmul [1..k])

f n k i = mmul (c (k-1) (i-1)) (c (n-k+1) (i))

main = map read . words <$> getLine >>= \[n, k] -> mapM_ (print . f n k) [1..k]


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ( A+B == C+D ){
    cout << "Balanced" << endl;
  }
  if ( A+B < C+D ){
    cout << "Right" << endl;
  }
  if ( A+B > C+D ){
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<set>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vb vector<bool>
#define vc vector<char>
#define vvll vector<vector<long long int> >
#define sll set<long long int>
#define mll map<long long int,long long int>
#define sllit set<long long int>::iterator
#define pll pair<long long int,long long int>
#define vpll vector<pair<long long int,long long int> >
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli mpower(lli a,lli b,lli m){lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli gcd(lli a,lli b){if(b==0) return a;if(a==0) return b;if(a>=b) return gcd(b,a%b);else return gcd(a,b%a);}
lli lcm(lli a,lli b){lli p=a*b;return p/gcd(a,b);}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}


/******************************START********************************/
int main()
{
	char ch1,ch2,ch3;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,t,d,n,m,sum=0,ans=0,temp;
    cin >> n;
    sll se;
    rep(i,0,n){
    	cin >> a;
    	se.insert(a);
	}
	if(se.size()==n)	cout << "YES" << endl;
	else	cout << "NO" << endl;
    
    
    
    
    return 0;
}





















/* UJJWAL KESHRI */

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

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int gcd(int a,int b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

int N;

int main()
{
	cin >> N;
	int Y;
	cin >> Y;

	int M = (Y - 1000 * N) / 4000;

	REP(i,M+1){
		if((Y - 1000 * N-4000*i)%9000==0){
			int x = (Y - 1000 * N - 4000 * i) / 9000;
			int y = i;
			int z = N - x - y;
			if(x>=0&&z>=0){
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=1e15;
const ll ms=(2e5) +5;

ll ar[ms][2];

int main()
{
    idfc;
    int n;
    cin>>n;
    int i;
    ll m;
    cin>>m;
    int br[ms];
    for( i=1;i<=n;i++)cin>>br[i]; sort(br+1,br+n+1, greater<int>());
    for(i=1;i<=n;i++)
    {
        ar[i][0]=br[i];
    }

for (i=1;i<=n;i++)cin>>br[i];  sort(br+1, br+n+1);
    
    for(i=1;i<=n;i++)ar[i][1]=br[i];
    ll l=0;
    ll r=1e13;
    ll mid;
    ll ans=1e15;
    ll a,b,c; ll pp,tt;
    ll ss=0;
    ll two=2;
    while(l<=r)
    {
        mid=(l+r)/two;
        ss=0;
        // fl=0;
        for(i=1;i<=n;i++)
        {
            if(ar[i][1]==0||ar[i][0]==0)continue;
            pp=mid/ar[i][1];
            //if(pp==0)fl=1;
            tt=ar[i][0];
//            if(mid==231)
//            cout<<tt<<" "<<pp<<endl;
            ss+=max(0ll,tt-pp);
        }
        if(ss<=m)
        {
            ans=min(ans,mid);
            r=mid-1;
        }
        else{
            l=mid+1;
        }
       //  cout<<l<<" "<<r<<" "<<mid<<" "<<ss<<endl;
        //cout<<ss<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4224