akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> T(N + 5);
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &T[i]);
    total += T[i];
  }

  int M; scanf("%d", &M);

  int p, x;
  for (int i = 1; i <= M; ++i) {
    scanf("%d %d", &p, &x);
    int val = total - T[p] + x;
    printf("%d\n", val);
  }

  return 0;
}


Measured memory_bytes: 256
inpl = lambda: list(map(int,input().split()))
from math import sqrt, ceil
def divisors(n, sort=True, reverse=False):
    sqn = int(ceil(sqrt(n)))
    div_list = []
    if sqn*sqn == n:
        div_list.append(sqn)
    for i in range(1,sqn):
        if n % i == 0:
            div_list.append(i)
            div_list.append(n//i)
    if sort:
        div_list.sort(reverse=reverse)
    return div_list

X = int(input())
divs = divisors(X)
for y in divs:
    a, b = y, 0
    while a**5 - b**5 < X:
        a += 1
        b += 1
    if a**5 - b**5 == X:
        print(a, b)
        exit()
    
    for b in range(1, y//2 + 1):
        a = y - b
        if a**5 + b**5 == X:
            print(a, -b)
            exit()


Measured memory_bytes: 63216
/*
{By GWj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
const int N=1<<18;
struct segtree{
	int tree[N+N],lazy[N+N];
	void init(int num){
		fill(tree+1,tree+N+N,num);
		fill(lazy+1,lazy+N+N,num);
	}
	void push_down(int index){
		check_min(tree[index],lazy[index]);
		if(index<N){
			check_min(lazy[index<<1],lazy[index]);
			check_min(lazy[index<<1|1],lazy[index]);
		} 
	}
	void modify(int a,int b,int val,int now=1,int l=1,int r=N+1){
		push_down(now);
		if(r<=a||l>=b){
			return;
		}
		if(r<=b&&l>=a){
			check_min(lazy[now],val);
			push_down(now);
			return;
		}
		int mid=(l+r)>>1;
		modify(a,b,val,now<<1,l,mid);
		modify(a,b,val,now<<1|1,mid,r);
		tree[now]=min(tree[now<<1],tree[now<<1|1]);
	}
	int query(int a,int b,int now=1,int l=1,int r=N+1){
		push_down(now);
		if(r<=a||l>=b){
			return INF;
		}
		if(r<=b&&l>=a){
			return tree[now];
		}
		int mid=(l+r)>>1;
		return min(query(a,b,now<<1,l,mid),query(a,b,now<<1|1,mid,r));
	}
}t1,t2;
int n,q;
int main(){
	fastio;
	R2(n,q);
	n-=2;
	t1.init(n+1);
	t2.init(n+1);
	LL rest=1ll* n*n;
	rb(i,1,q){
		int ty;
		R(ty);
		int x;
		R(x);
		x--;
		if(ty==1){
			int bound=t2.query(x,x+1);
			rest-=bound-1;
//			cout<<bound<<endl;
			t1.modify(1,bound+1,x);
		}
		else{
			int bound=t1.query(x,x+1);
			rest-=bound-1;
//			cout<<bound<<endl;
			t2.modify(1,bound+1,x);
		}
	}
	cout<<rest<<endl;
	return 0;
}

Measured memory_bytes: 11640
#include<cstdio>
int main() {
	int n, a, b, i, x, xn;
	long long sum = 0;
	scanf("%d%d%d%d", &n, &a, &b, &x);
	for (i = 1; i < n; i++) {
		scanf("%d", &xn);
		sum += (long long)(xn - x)*a > b ? b : (long long)(xn - x)*a;
		x = xn;
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 128
import qualified Data.IntSet as IntSet
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  a <- map (read . BS.unpack) . BS.words <$> BS.getLine
  putStrLn $
    if n == IntSet.size (IntSet.fromList a)
      then "YES"
      else "NO"



Measured memory_bytes: 36220
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N = int(input())
H = list(map(int, input().split()))

dp = [float('inf')] * N
dp[0] = 0
dp[1] = abs(H[1]-H[0])

for i in range(2, N):
    l1 = dp[i-1] + abs(H[i]-H[i-1])
    l2 = dp[i-2] + abs(H[i]-H[i-2])
    dp[i] = min(l1, l2)

#print(dp)
print(dp[-1])

Measured memory_bytes: 13712
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, ans = 0;
  char s[200010];
  scanf("%s", s);
  for(i = 0; s[i]; ++i) {
    if(s[i] == s[i + 1]) {
      if(s[i + 2]) ans += 2, i += 2;
      else ans += 1, i++;
    } else ans += 1;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll N=1000000007;
//ll power(ll a,ll b,ll mod)
//{
//    ll result=1;
//    while(b>0)
//    {
//        if(b%2==1)
//            result=(result*a)%mod;
//        a=(a*a)%mod;
//        b=b/2;
//    }
//    return result;
//}
//ll d,x,y;
//void extendedEuclid(ll a,ll b)
//{
//    if(b==0)
//    {
//        d=a; x=1; y=0;
//    }
//    else
//    {
//        extendedEuclid(b,a%b);
//        ll temp=x; x=y; y=temp-(a/b)*y;
//    }
//}
//ll modInverse(ll a,ll m)
//{
//    extendedEuclid(a,m);
//    return (x%m+m)%m;
//}
//ll lcm(ll a,ll b)
//{
//    if(a==0||b==0)
//        return 0;
//    return (a*b)/(__gcd(a,b));
//}
//void sieve(ll n)
//{
//    bool isPrime[n+1];
//    isPrime[0]=false; isPrime[1]=false;
//    for(ll i=2;i<=n;i++)
//        isPrime[i]=true;
//    for(ll i=2;i*i<=n;i++)
//    {
//        if(isPrime[i]==true)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//                isPrime[j]=false;
//        }
//    }
//}
//bool isPowerOfTwo(ll n)
//{
//    return (n&&!(n&(n-1)));
//}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,k; cin>>a>>b>>c>>k;
    if(c>b&&b>a) cout<<"Yes";
    else{
        while(k>0&&(b<=a)){
            b=b*2; k--;
        }
        while(k>0&&(c<=b)){
            c=c*2; k--;
        }
        if(c>b&&b>a) cout<<"Yes";
        else cout<<"No";
    }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m, n, x, y, z;

int main()
{
    cin >> x >> y;

    ll ans = abs(abs(x) - abs(y));

    if(x < 0 && y < 0){
        if(y >= x) ans = y - x;
        else ans = 2 + abs(abs(x) - abs(y));
    }

    if(x >= 0 && y < 0){
        ans = 1 + abs(abs(x) - abs(y));

    }

    if(x < 0 && y >= 0){
        ans = 1 + abs(abs(x) - abs(y));
        if(y == 0) ans--;
    }

    if(x >= 0 && y >= 0){
        if(y >= x) ans = y - x;
        else {
            ans = 2 + abs(abs(x) - abs(y));
            if(y == 0) ans--;
        }

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(void)
{
  int n; cin >> n;
  map<int,int> cnt[2];

  for (int i = 0; i < n; ++i) {
    int x; cin >> x;
    ++cnt[i % 2][x];
  }

  vector<pair<int,int>> vec[2];
  for (int p = 0; p < 2; ++p) {
    auto& v = vec[p];
    for (auto it : cnt[p]) {
      v.push_back({it.second, it.first});
    }
    sort(v.rbegin(), v.rend());
    v.push_back({0, 1000000000});
  }

  int sol = n;
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      if (vec[0][i].second == vec[1][j].second) {
	continue;
      }
      auto csol = n - vec[0][i].first - vec[1][j].first;
      if (csol < sol) {
	sol = csol;
      }
    }
  }

  cout << sol << "\n";

  return 0;
}


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

typedef unsigned long long ull;
typedef unsigned int ui;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=2000+5,A=4e6+5;
int cnt[A];
ull a[A/64+5];int mx;
bool Count(int x)
{
	return a[x/64]&(1LL<<(x&63));
}
void move(int x)
{
	int u=mx/64;mx+=x;
	int du=x/64,di=x&63;
	if(!di)
	{
		for(int i=u;i>=0;--i)a[i+du]|=a[i];
		return ;
	}
	for(int i=u;i>=0;--i)
	{
		a[i+du+1]|=a[i]>>64-di;
		a[i+du]|=a[i]<<di;
	}
}
 
int main()
{
//	freopen("will.in","r",stdin);freopen("will.out","w",stdout);
	int n;
	cin>>n;
	int sum=0;
	rep(i,1,n)
	{
		int x;
		scanf("%d",&x);
		sum+=x;
		++cnt[x];
	}
	mx=0;a[0]=1;
	rep(i,1,sum)
	{
		while(cnt[i]>2){++cnt[i*2];cnt[i]-=2;}
		while(cnt[i]--)move(i);
	}
	int tot=0;
	rep(i,1,sum)
	if(Count(i))++tot;
	tot=(tot+1)/2;
	rep(i,1,sum)
	if(Count(i))
	{
		if(!--tot)
		{
			cout<<i;
			exit(0);
		}
	}
}


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

int main() {
  int n,x,t;

  cin >> n >> x >> t;

  int num =0;
  int ans =0;

  while (num<n){
    num+= x;
    ans+=t;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3616
#include<cstdio>
#include<algorithm>

using namespace std;

int main() {
    int n,maxn=-1000001,minn=1000001,tmp;
    long long sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
    	scanf("%d", &tmp);
    	minn=min(minn,tmp);
    	maxn=max(maxn,tmp);
    	sum+=tmp;
    }
    printf("%d %d %lld\n", minn,maxn,sum);
}





Measured memory_bytes: 2748
use std::io;
use std::io::{Read, BufReader};
use std::cmp;

fn next_token<R: Read>(reader: &mut R) -> Vec<u8> {
    let mut buf: [u8; 1] = [0];
    let mut read_chars = false;
    let mut ret: Vec<u8> = vec![];

    loop {
        if reader.read(&mut buf).unwrap() == 0 {
            break;
        } else {
            if buf[0] == '\r' as u8 || buf[0] == '\n' as u8 || buf[0] == ' ' as u8 {
                if read_chars {
                    break;
                }
            } else {
                read_chars = true;
                ret.push(buf[0]);
            }
        }
    };
    ret
}
fn next_i64<R: Read>(reader: &mut R) -> i64 {
    let token = next_token(reader);
    let mut ret: i64 = 0;
    let mut sgn = false;

    for c in token {
        if '0' as u8 <= c && c <= '9' as u8 {
            ret = ret * 10 + (c - ('0' as u8)) as i64;
        } else if '-' as u8 == c {
            sgn = true;
        }
    };
    ret * if sgn { -1 } else { 1 }
}
fn next_i32<R: Read>(reader: &mut R) -> i32 {
    next_i64(reader) as i32
}
static MOD: i64 = 1000000007;

fn solve_1d(x: & Vec<i64>) -> i64 {
    let mut ret = 0;
    for i in 1..x.len() {
        let d = x[i] - x[i - 1];
        ret = (ret + (d as i64) * (i as i64) % MOD * (x.len() - i) as i64) % MOD;
    }
    ret
}
fn main() {
    let buf = &mut BufReader::new(io::stdin());

    let n = next_i32(buf);
    let m = next_i32(buf);
    let mut x: Vec<i64> = vec![];
    let mut y: Vec<i64> = vec![];
    for _ in 0..n {
        x.push(next_i64(buf));
    }
    for _ in 0..m {
        y.push(next_i64(buf));
    }
    let ret = solve_1d(&x) * solve_1d(&y) % MOD;
    println!("{}", ret);
}


Measured memory_bytes: 6396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws IOException{


		// 読み込み
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] temp;

		line=br.readLine();
		temp=line.split(" ");

		int a = Integer.valueOf(temp[0]);
		int b = Integer.valueOf(temp[1]);
		int c = Integer.valueOf(temp[2]);
		int d = Integer.valueOf(temp[3]);

		if(a*b >= c*d){
			System.out.println(a*b);
		}else{
			System.out.println(c*d);
		}


	}
}


Measured memory_bytes: 22484
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



////////////////////////////////////////


int main(){
    int n,t;cin>>n>>t;
    int a[n];for(int i=0;i<=n-1;i++)cin>>a[i];
    ll ans=t;
    for(int i=1;i<=n-1;i++){
        ans+=min(a[i]-a[i-1],t);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [x,y,_] <- getIntList
    print $ div (x*y) 2

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

int main() {
  string S, T;
  cin >> S >> T;
  int N = S.length();
  int M = T.length();
  bool found{};
  for (int i{N - M}; i >= 0 && !found; --i) {
    found = true;
    for (int j{}; j < M; ++j) {
      if (S[i+j] != T[j] && S[i+j] != '?') {
        found = false;
        break;
      }
    }
    if (found) {
      S.replace(i, M, T);
    }
  }
  if (found) {
    for (int i{}; i < N; ++i) {
      if (S[i] == '?') S[i] = 'a';
    }
    cout << S << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, n;
    cin >> x >> n;
    int p[105];
    fill(p, p+105, 0);
    for(int i=0; i<n; i++){
        int a;
        cin>>a;
        p[a] = 1;
    }

    int ans;
    int diff = 1e9;
    for(int i=0; i<105; i++){
        if(diff > abs(i-x) && p[i]==0){
            ans =i;
            diff = abs(i-x);
        }
    }
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
b = list(map(int, input().split()))

res = 0
for i in range(a):
    if (i+1) % 2 == 0:
        continue
    if b[i] % 2  == 1:
        res = res + 1
        
        
print("{}".format(res))

Measured memory_bytes: 61756
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    s = inputs[0]
    count = 0
    for i, c in enumerate(s):
        if i == 0:
            first = c
        elif i == len(s) - 1:
            last = c
        else:
            count += 1
    return '{}{}{}'.format(first, count, last)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


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

int main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double x,y;
    x=h*30+m/2;
    y=m*6;
    double pi=acos(-1);
    double r=min(abs(x-y),360-abs(x-y));
    r*=pi/180;
    double len=a*a+b*b-2*a*b*cos(r);
    printf("%.15f",sqrt(len));
    return 0;
}


Measured memory_bytes: 4188
#include<iostream>
using namespace std;
int main() {
	char x, y, z, w;
	x = 'A'; y = 'C'; z = 'G'; w = 'T';
	char b;
	cin >> b;
	if (b == x) {
		cout << w;
	}
	else if (b == y) {
		cout << z;
	}
	else if (b == z) {
		cout << y;
	}
	else {
		cout << x;
	}
	return 0;
}

Measured memory_bytes: 888
from collections import deque

N = int(input())
tree = [[] for i in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)

d = deque([[0, -1]])
dist = [0] * N
while d:
  node, par = d.pop()
  children = tree[node]
  for child in children:
    if child == par:
      continue
    dist[child] = (dist[node] + 1) % 2
    d.appendleft([child, node])

count0 = dist.count(0)
count1 = N - count0
s = [set(), set(), set()]
for i in range(1, N+1):
  s[i%3].add(i)
if count0 > N//3:
  if count1 > N//3:
    for i in range(N):
      if dist[i]:
        if s[2]:
          dist[i] = s[2].pop()
        else:
          dist[i] = s[0].pop()
      else:
        if s[1]:
          dist[i] = s[1].pop()
        else:
          dist[i] = s[0].pop()
  else:
    for i in range(N):
      if dist[i]:
        dist[i] = s[0].pop()
      else:
        if s[2]:
          dist[i] = s[2].pop()
        elif s[1]:
          dist[i] = s[1].pop()
        else:
          dist[i] = s[0].pop()
else:
  for i in range(N):
    if dist[i]:
      if s[2]:
        dist[i] = s[2].pop()
      elif s[1]:
        dist[i] = s[1].pop()
      else:
        dist[i] = s[0].pop()
    else:
      dist[i] = s[0].pop()

print(*dist)

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

int main() {
  int a,i;
  int botan=1,nextbotan;
  int count=0;
  
  cin>>a;
  vector<int> c(a);
  
  for(i=0;i<a;i++){
    cin>>c.at(i);
  }
  
  
  
  while(1){
   nextbotan=c.at(botan-1);
   c.at(botan-1)=0;
   
   count++;
   
   if(nextbotan==2){
   	cout<<count;
    return 0;
   }
    
   if(c.at(nextbotan-1)==0){
    cout<<-1;
    return 0;
   }
   
   botan=nextbotan;
    
  }
  
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		long[][] map = new long[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				map[i][j] = i == j ? 0 : INF;
			}
		}
		for (int i = 0; i < m; i++) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			map[a][b] = c;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					map[j][k] = Math.min(map[j][k], map[j][i] + map[i][k]);
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (map[i][i] < 0) {
				System.out.println("NEGATIVE CYCLE");
				return;
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (map[i][j] >= INF/2)
					System.out.print("INF");
				else
					System.out.print(map[i][j]);
				System.out.print(j == n - 1 ? "\n" : ' ');
			}
		}

	}

	long INF = Long.MAX_VALUE / 2;

}

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

const int INF = 1001001001;

int main(){
    
    int n,m,x;
    cin >> n >> m >> x;
    
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int> (m));
    
    for(int i=0; i<n ; i++){
        cin >> c.at(i);
        for(int j=0; j<m; j++){
            cin >> a.at(i).at(j);
        }
    }
    
    int ans = INF;
    
    rep(s, 1<<n){//ビット演算
        
        int cost = 0;
        vector<int> d(m);
        rep(i,n){
            if(s>>i & 1){//ビット演算
                cost += c[i];
                rep(j,m) d[j] += a[i][j];
            }
        }
        
        bool ok = true;
        rep(j,m)if(d[j]<x)ok = false;
        
        if(ok) ans = min(ans, cost);
    }
    
    if(ans==INF)
        cout << "-1" << endl;
    else
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
"""

"""

import sys
sys.setrecursionlimit(1000000)


n,m=[int(i) for i in input().split()]
graph=[[] for i in range(n)]

for i in range(m):
    relation=[int(j) for j in input().split()]
    graph[relation[0]].append(relation[1])
    graph[relation[1]].append(relation[0])


check=[0 for i in range(n)]
rabel=0
stack=[]

#深さ優先探索
def dfs(graph,i):
    global stack
    global n
    global rabel

    if check[i]==0:

        #行った足跡をつける
        check[i]=rabel

        #今いる場所の情報
        now=graph[i]

        #スタックに入れる
        stack.append(now)

        #今いる場所から到達できる地点のうち、まだ行っていないとこ全部でdfs
        for j in now:
            if check[j]==0:
                dfs(graph,j)

        stack.pop()

for i in range(n):
    if check[i]==0:
        rabel+=1
        dfs(graph,i)
# print(check)



num=int(input())
for i in range(num):
    a,b=[int(j) for j in input().split()]
    if check[a]==check[b]:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 127776
import sys

n = int(sys.stdin.readline())
sys.stdin.readline()
l = range(1, n+1)

for line in sys.stdin:
  a,b = map(int, line.strip().split(','))
  l[a-1], l[b-1] = l[b-1], l[a-1]

for x in l:
  print x

Measured memory_bytes: 4208
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

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

using namespace std;
using ll = long long;

int main()
{
	int MAX = 100010;
	vector<int> is_prime(MAX, 1);
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i < MAX; ++i) {
		if (!is_prime[i])
			continue;
		for (int j = i * 2; j < MAX; j += i)
			is_prime[j] = 0;
	}

	vector<int> a(MAX, 0);
	for (int i = 0; i < MAX; ++i) {
		if (i % 2 == 0)
			continue;
		if (is_prime[i] && is_prime[(i+1)/2])
			a[i] = 1;
	}

	vector<int> s(MAX+1, 0);
	for (int i = 0; i < MAX; ++i)
		s[i + 1] = s[i] + a[i];

	int Q;
	cin >> Q;
	for (int q = 0; q < Q; ++q) {
		int l, r;
		cin >> l >> r;
		++r;

		cout << s[r] - s[l] << endl;
	}
}



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

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

const int N = 109;
const long long V = 100009;
const long long INF = 1LL << 60;

int main() {
	int n, w;
	cin >> n >> w;
	vector<long> weight;
	vector<int> value;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		weight.push_back(a);
		value.push_back(b);
	}

	long long dp[N][V];
	rep(i, N) rep(j, V) dp[i][j] = INF;
	dp[0][0] = 0;
	rep(i, n) {
		rep(j, V) {
			if (j - value[i] >= 0)
				chmin(dp[i + 1][j], dp[i][j - value[i]] + weight[i]);
			chmin(dp[i + 1][j], dp[i][j]);
		}
	}

	//rep(i, w + 1) cout << dp[n][i] << endl;
	long long ans = 0;
	rep(i, V) if (dp[n][i] <= w) ans = i;
	cout << ans << endl;
}

Measured memory_bytes: 85376
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define inlld2(x, y) scanf("%lld%lld", &x, &y)
#define inlld3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define ind2(x, y) scanf("%d%d", &x, &y)
#define ind3(x, y, z) scanf("%d%d%d", &x, &y, &z)

const int N=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
    ll a, b, c;
    inlld3(a, b, c);
    if(a==b && a!=c)
        printf("Yes\n");
    else if(a==c && a!=b)
        printf("Yes\n");
    else if(b==c && b!=a)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
a = list(map(int,input().split(" ")))
b = list()
c = list()
tmp = list()

for i in range(a[1]):
    tmp = list(map(int,input().split(" ")))
    b.append(tmp[0])
    b.append(tmp[1])

for i in range(a[0]):
    print(b.count(i + 1))



Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int countA,countB,sum=0;
		countA = sc.nextInt();
		int[] s = new int[countA];
		for(int i=0; i<countA; i++) {
			s[i] = sc.nextInt();
		}
		countB = sc.nextInt();


		for(int i=0; i<countB; i++) {
			int tmp = sc.nextInt();
			if(Arrays.binarySearch(s, tmp) > -1)
				sum++;
		}
		System.out.println(sum);
	}
}





Measured memory_bytes: 68060
#include<iostream>
using namespace std;
#define MOD 1000000007
long long fact[500000];
long long inv[500000];
long long factinv[500000];
long long ncr(int a,int b){
	if(b<0 || a<b)return 0;
	return 1LL*fact[a]*factinv[b]%MOD*factinv[a-b]%MOD; 
}
long long ktrn(int a,int b){
	return (ncr(a+b,b)-ncr(a+b,b-1)+MOD)%MOD;
}
int main(){
	fact[0]=1;inv[1]=1;factinv[0]=1;
	for(long long i=1;i<500000;i++){
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	for(long long i=2;i<500000;i++){
		inv[i]=1LL*inv[MOD%i]*(MOD-MOD/i)%MOD;
	}
	for(long long i=1;i<500000;i++){
		factinv[i]=1LL*factinv[i-1]*inv[i]%MOD;
	}
	int n,m,k;
	cin>>n>>m>>k;
	long long sum=0;
	for(int i=0;i<=k;i++){
		long long V=ncr(n+m+k*2,n+i*2)*ktrn(n+i,i);V%=MOD;
		V*=ktrn(m+k-i,k-i);sum+=V;sum%=MOD;
		//cout<<p[n+m+k*2][n+i*2]<<' '<<dp[n+i][i]<<' '<<dp[m+k-i][k-i]<<endl;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 12872
#include <iostream>

int main() {
    int A, B, C;
    std::cin >> A >> B >> C;

    if (B == C) {
        std::cout << A << std::endl;
    } else if (A == C) {
        std::cout << B << std::endl;
    } else {
        std::cout << C << std::endl;
    }
}


Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

get_numbers_2(0, _, []).
get_numbers_2(N1, N2, [X|Xs]) :- 
    get_numbers(N2, X), 
    N12 is N1 - 1, 
    get_numbers_2(N12, N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

get_i_to_x_rbtree0(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 0, T2, T).

get_i_to_x_rbtree1(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 1, T2, T).

get_i_to_x_rbtree(0, _, T, T).
get_i_to_x_rbtree(N, I, T2, T) :-
    get_number(X),
    rb_insert(T2, I, X, T3),    
    N2 is N - 1,
    I2 is I + 1,
    get_i_to_x_rbtree(N2, I2, T3, T).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)

    include(f, Xs, Ys) : filter f

    findall(使う変数のタプル, (hoge), hogeが通るタプルのリスト)
*/


f(N, X, C, C) :- N < X, !.
f(N, X, C, Z) :-
    Y is N div X,
    T is Y * (Y + 1) * X div 2,
    C2 is C + T,
    X2 is X + 1,
    f(N, X2, C2, Z).

main :-
    get_number(N),
    f(N, 1, 0, Z),
    writeln(Z).

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 8268
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<math.h>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const int N= 1e8;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int bitcount(ll a)
{
    int result = 0;
    while(a)
    {
        a /= 10;
        result++;
    }
    return result;
}
ll a[100005];
ll lim = 1e18;
int main()
{
    int n;
    ll sum = 1;
    cin >> n;
    for (int i = 0; i < n;i++)
    {
        cin >> a[i];
        if(a[i]==0)
            sum = 0;
    }

    if(sum)
    {
        for (int i = 0; i < n;i++)
        {
            if(lim/a[i]<sum)
            {
                    sum = -1;
                    break;
            }
            sum *= a[i];
        }
    }

    cout << sum;
    return 0;
}

Measured memory_bytes: 4416
import java.util.Scanner;

public class Main {

    static int N;
    static long K;
    static long[] A;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        K = sc.nextLong();
        A = new long[N + 1];
      long max2 = 0;

        for(int i = 0 ; i < N ; i++) {
        	A[i] = sc.nextLong();
        	max2 = Math.max(A[i],max2);
        }

        long max = max2;
        long min = 1l;
        if(K == 0) {
        	System.out.println(max);
        	return;
        }

        // 二分探索
        for (;;) {
            // mid
            long mid = (max + min) / 2;
            if (canSolve(mid)) {
                min = mid;
            } else {
                max = mid;
            }

            if (max - min <= 1) {
                // 終わり
                break;
            }
        }
        if(min == 1) {
        	long num = min;
        	int sum = 0;
        	for(int i = 0 ; i < N ; i++) {
    if((A[i] + num)% num != 0)
        		sum += A[i] / num;
    else
    sum += (A[i] / num ) - 1 ;
        	}
        	min = sum < K ? 0 : 1;
        }

        	 System.out.println(min + 1);


    }


    // 解けるかどうか
    static boolean canSolve(long num) {
    	int sum = 0;
    	for(int i = 0 ; i < N ; i++) {
if((A[i] + num)% num != 0)
    		sum += A[i] / num;
else
sum += (A[i] / num )- 1 ;
    	}
    	return sum > K ? true : false;

    }
    static boolean canSolve2(long num) {
    	int sum = 0;
    	for(int i = 0 ; i < N ; i++) {
    		sum += A[i] / num;
    	}
    	return sum == K ? true : false;

    }
}


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

using namespace std;

const int N=1e5+10;
const int INF=1e9+10;
int a[N];

int main()
{
    int n,s;

    while(scanf("%d %d",&n,&s)!=EOF)
    {
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }

        int Min=INF;
        int sum=0;

        for(int l=0,r=0;l<n;l++)
        {
            while(r<n&&sum<s)
            {
                sum+=a[r++];
            }
            if(sum>=s)
                Min=min(Min,r-l);
            sum-=a[l];
        }

        printf("%d\n",Min==INF?0:Min);
    }

    return 0;
}



Measured memory_bytes: 3620
let () =
    let rdint =
        let l = ref 0 in
        let i = ref 0 in
        let s = Bytes.create 1048576 in
        let refill () =
            let n = input stdin s 0 1048576 in
            i := 0;
            l := n
        in

        fun () ->
            let rec loop2 j k t =
                let fin j t =
                    i := j;
                    t
                in

                if j = k then (
                    refill ();
                    if !l > 0 then loop2 !i !l t else fin j t
                ) else if Bytes.get s j >= '0' && Bytes.get s j <= '9' then
                    loop2 (j + 1) k (t * 10 + int_of_char (Bytes.get s j) - 48)
                else fin j t
            in
            let rec loop1 j k =
                if j = k then (
                    refill ();
                    if !l > 0 then loop1 !i !l else 0
                ) else
                if Bytes.get s j >= '0' && Bytes.get s j <= '9' then loop2 (j + 1) k (int_of_char (Bytes.get s j) - 48) else
                    loop1 (j + 1) k
            in
            loop1 !i !l
    in
    let main () =
        let rr = rdint() in
        let cc = rdint() in
        let k = rdint() in
        let mat = Array.make_matrix rr cc 0 in
        for i = 1 to k do
            let r = rdint () - 1 in
            let c = rdint () - 1 in
            let v = rdint () in
            mat.(r).(c) <- v
        done;
        let max (a:int) (b:int) = if a < b then b else a in

        let prev = Array.make cc 0 in
        for y = 0 to rr - 1 do
            let m = mat.(y) in
            let rec loop x work0 work1 work2 work3 =
                if x < cc then (
                    let work0 = max work0 prev.(x) in
                    let v = m.(x) in
                    let work3 = max work3 (work2 + v) in
                    let work2 = max work2 (work1 + v) in
                    let work1 = max work1 (work0 + v) in
                    prev.(x) <- max (max work3 work2) (max work1 work0);
                    loop (x + 1) work0 work1 work2 work3
                )
            in
            loop 0 0 0 0 0
        done;
        Printf.printf "%d\n" (prev.(cc - 1))
    in
    main ()

Measured memory_bytes: 77052
#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

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

void Main(){
	int n, m;
	cin >> n >> m;
  	vi a(n);
  	int tot = 0;
	rep(i,n) {
      	cin >> a[i];
    	tot += a[i];
    }
  	sort(rall(a));
	if(a[m-1]*4*m >= tot) puts("Yes");
  	else puts("No");
	return;
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>

#define ing long long

using namespace std;
const int N = 1e5;
const int Mod = 1e9 + 7;

int dp[N][13];

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    string s;
    cin >> s;
    int l = s.length();
    s = ' ' + s;
    dp[0][0] = 1;
    for (int i = 1; i <= l; i++) {
        if (s[i] != '?') {
            int nu = s[i] - '0';
            for (int j = 0; j < 13; j++) {
                    int m =(j * 10 + nu) % 13 ;
                    dp[i][m] = (dp[i][m]+dp[i - 1][j])%Mod;
            }
        } else {
            for (int nu = 0; nu < 10; nu++) {
                for (int j = 0; j < 13; j++) {
                    int m =(j * 10 + nu) % 13 ;
                    dp[i][m] = (dp[i][m]+dp[i - 1][j])%Mod;
                    
                }
            }
        }
    }
    cout<<dp[l][5]<<endl;
    return 0;
}

Measured memory_bytes: 5484
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n;
vint v;
vint data;

main(){
	cin>>n;
	rep(i,n){
		int t;
		cin>>t;
		data.pb(t);
		v.pb(t);
	}
	sort(rall(v));
	rep(i,n){
		if(v[0]==data[i])dump(v[1]);
		else dump(v[0]);
	}
}


Measured memory_bytes: 4964
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)

const int mod = 1000000007;
long cnts[10];

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

  long h, w, n;
  cin >> h >> w >> n;

  map<P, bool> m;

  rep(i, n) {
    int x, y;
    cin >> x >> y;
    m.insert({{x, y}, true});
  }

  map<P, bool> looked;

  cnts[0] = (h-2)*(w-2);

  for(auto i: m) {
    for(int x = -1; x < 2; x++) {
      for(int y = -1; y < 2; y++) {
        int center_x = i.first.first+x;
        int center_y = i.first.second+y;
        if(
          center_x+1>h || 
          center_y+1>w || 
          center_x-1<1 || 
          center_y-1<1 ||  
          looked.count({i.first.first+x,i.first.second+y})) continue; 
        int cnt = 0;
        for(int xx = -1; xx < 2; xx++) {
          for(int yy = -1; yy < 2; yy++) {
            int xxx = x + xx;
            int yyy = y + yy;
            if(m.count({i.first.first+xxx,i.first.second+yyy})) {
              cnt++;
            }
          }
        }
        looked.insert({{i.first.first+x,i.first.second+y},true});
        cnts[0]--;
        cnts[cnt]++;
      }
    }
  }

  rep(i, 10) {
    cout << cnts[i] << endl;
  }
}


Measured memory_bytes: 62720
#include <bits/stdc++.h>
using namespace std;
using ll = __int128;
 __int128 r()
{
   int X=0,w=0; char ch=0;
   while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
   while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
   return w?-X:X;
}
void print(__int128 x)
{    
   if(x<0){putchar('-');x=-x;}
   if(x>9) print(x/10);
   putchar(x%10+'0');
}
int main()
  {
  	long long int n;
  	cin >> n;
  	static long long int date[1000000 + 110];
  	for (long long int i = 1;i <= n;i++)
  	  cin >> date[i];
  	sort(date + 1,date + 1 + n);
  //	cout <<"+ " << date[1] << " " << bool(date[1] == 0) << endl;
  	if (date[1] == 0)
  	  return puts("0") * 0;
  	ll ret = 1;
  	ll base = 1000000000ll * 1000000000ll;
  	for (ll i = 1;i <= n;i++)
  	  {
  	  	ll t = date[i];
  	  /*	print(ret * t);
  	  	puts("");*/
  	  	if (t * ret > base)
  	  	  return puts("-1") * 0;
  	  	else
  	  	  ret = ret * t;
		}
  	print(ret);
  }

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

int main()
{
    long long n,sum=0;
    cin >> n;
    for(int i=1;i<=n;i++){
        if((i%3)&&(i%5)&&(i%15)) sum+=i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3624
import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0 and k%2 ==1 :
  if zero >= 1:
    ans = 0
  else:
    minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)

Measured memory_bytes: 31740
#include <cstdio>


int main() {
    int N;
    scanf("%d",&N);
    int d[N], used[N], count=0;
    for (int i=0; i<N; i++) {
        scanf("%d",&d[i]);
        used[count] = d[i];
        count++;
        for (int j=0; j<count-1; j++) {
            if (d[i] == used[j]) {
                count--;
                used[count] = 0;
                break;
            }
        }
    }
    printf("%d\n",count);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cctype>
#include <utility>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int f(int n, int c) {
	if (n < 10)
		return c;
	int m = 0;
	for (int k = 10; n / k; k *= 10)
		m = max(m, (n / k) * (n % k));
	return f(m ,c + 1);
}

int main() {
	for (int Q = in(); Q; Q--)
		outl(f(in(), 0));
}


Measured memory_bytes: 2528
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int  r, g;
	cin >> r >> g;
	double b = 2 * g -r;
	cout << (int)b << endl;
}

Measured memory_bytes: 256
W,H,x,y,r = [int(i) for i in input().split()]

flg = 0

if x<r:
    flg+=1

if y<r:
    flg+=1

if W-r<x:
    flg+=1

if H-r<y:
    flg+=1

if flg==0:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 5604
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#include <bits/stdc++.h>
#define PI 3.141592
 
using namespace std;
 
int main(void) {
    ll n, m, sum = 0;
    cin >> n >> m;
    ll a[m];
    rep(i, m){
        cin >> a[i];
        sum += a[i];
    }
    if(n >= sum){
        cout << n - sum << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

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

void solve()
{
	int A,B,C,k;
	cin >> A >> B >> C;
	cin >> k;

	/* A = red B = Green C = blue */ 

	while ( B <= A){
		B = B << 1;
		k--;
	}

	while ( C <= B){
		C = C << 1;
		k--;
	}
	if ( k >=0 ){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}


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

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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	cout << r/d - (l - 1)/d << '\n';
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    static int n = 0;

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

        if (a.equals("ABC")) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}

Measured memory_bytes: 35540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

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

    int ans = 0;
    for ( int i = 1; i <= n; i++ ) {
        int cnt = 0;
        if ( i % 2 == 0 ) continue;
        for ( int j = 1; j <= i; j++ ) {
            if ( i % j == 0) cnt++; 
        }
        if ( cnt == 8 ) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;

    if(x-r<0){
        cout << "No" << endl;
    }else if(x+r>W){
        cout << "No" << endl;
    }else if(y-r<0){
        cout << "No" << endl;
    }else if(y+r>H){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3112