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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

int isFound[100010];
int color[100010];

void dfs( int x, const vector< vector<pair<int,int>> >& edge )
{
	if( isFound[x] == 1 ) return;
	isFound[x] = 1;
	for( auto& e : edge[x] )
	{
		if( e.second % 2 == 0 ) color[e.first] = color[x];
		else color[e.first] = ( color[x] == 0 ? 1 : 0 );
		dfs( e.first, edge );
	}
}

int main()
{
	int n, m;
	cin >> n;
	
	vector< vector<pair<int,int>> > edge(n);
	REP( i, edge.size() )
	{
		int a, b, w;
		cin >> a >> b >> w;
		edge[a-1].push_back( pair<int,int>(b-1,w ) );
		edge[b-1].push_back( pair<int,int>(a-1,w ) );
	}
	
	memset( color, 0, sizeof( color ) );
	memset( isFound, 0, sizeof( isFound ) );
	dfs(0,edge);

	REP(i,n)
	{
		cout << color[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 8576
<?php
  fscanf(STDIN, "%d", $N);
 $arr = str_split($N);
 $num=strlen($N);
$num =$num-1;
if($arr[$num]=="3"){
  echo "bon";
}elseif($arr[$num]==0||$arr[$num]==1||$arr[$num]==6||$arr[$num]==8 ){
  echo "pon";
}else{
echo "hon";
}
?>

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int t = sc.nextInt();
        int[] a = new int[t];
        for (int i = 0 ; i < t; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(Math.max(0, k - (2 * (k - a[t - 1]) + 1)));
    }

}

Measured memory_bytes: 21972
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

S = X()
a = [0]
b = ["A","G","C","T"]

for i in range(len(S)):
    if S[i] in b:
        count += 1
        a.append(count)
    else:
        count = 0

print(max(a))


Measured memory_bytes: 9944
room = [[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]]
for i in range(4):
    for j in range(3):
        for k in range(10):
            room[i][j].append(0)
n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())
    room[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print(" "+" ".join(map(str, room[i][j])))
    if i != 3: print("#"*20)

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

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

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

	vector<int> c(n);
	vector<int> delta(n);
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> c.at(i);
		delta.at(i) = v.at(i) - c.at(i);
		if (0 < delta.at(i))
		{
			sum += delta.at(i);
		}
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
//////////////////////////
//      _        ____   //
//  U  /"\  u U /"___|  //
//   \/ _ \/  \| | u    //
//   / ___ \   | |/__   //
//  /_/   \_\   \____|  //
//   \\    >>  _// \\   //
//  (__)  (__)(__)(__)  //
//  Compro by NULL_CT©  //
//////////////////////////
// STL libs
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(I, LIM) for (int I = 0; I < (LIM); I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;

constexpr int MOD = 10000007;

vector<long> divisor(long n) {
  vector<long> head, tail;
  for (long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      head.push_back(i);
      if (i * i != n)
        tail.push_back(n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return (head);
}

void execute();

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  // cout<<fixed<<setprecision(20);

  execute();

  return (0);
}

void execute() {
  int n, m;
  cin >> n >> m;
  int mini = 0, maxi = INT_MAX;
  REP(i,m){
    int a, b;
    cin >> a >> b;
    mini = max(mini, a);
    maxi = min(maxi, b);
  }
  if(mini > maxi){
    cout << 0 << endl;
    return;
  }
  cout << maxi - mini + 1 << endl;
}


Measured memory_bytes: 3148
#include <iostream>
#include <list>
#include <algorithm>
#define F first
#define S second
using namespace std;

typedef pair<int,int> P;

P L[100000];
long long int dp[100001]={0};
int main(void){
	long long int time=0;
	int n,l,tmp;
	cin >> n >>l;
	for(int i=0;i<n;i++)
		cin >> tmp,L[i].F=l-tmp,L[i].S=i;	
	sort(L,L+n);
	for(int i=0;i<n;i++){
		dp[L[i].S+1]=L[i].F+max(dp[L[i].S],dp[L[i].S+2]);
		time=max(time,dp[L[i].S+1]);
	}
	cout << time << endl;
	return 0;
}

Measured memory_bytes: 2716
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

# dp[l][r] = [l:r)の区間から起こり得るX - Yの最大値
# [N - 区間の長さ] = 偶数のとき、次に取るのは先手

dp = [[0] * (N + 1) for i in range(N + 1)]

for k in range(1, N + 1): # 区間の長さ
  for i in range(N + 1 - k):
    if (N - k) % 2 == 0: # 先手番
      dp[i][i + k] = max(dp[i + 1][i + k] + A[i], dp[i][i + k - 1] + A[i + k - 1])
    else: # 後手番
      dp[i][i + k] = min(dp[i + 1][i + k] - A[i], dp[i][i + k - 1] - A[i + k - 1])

print(dp[0][N])

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

using namespace std;

struct odd : public unary_function<int, bool> { bool operator () (int x) const { return (x % 2) != 0; } };
void dis(int *Array, int N) { for(int i = 0; i < N; ++i) {std::cout.width(1); std::cout << Array[i];} std::cout << std::endl;}
signed fac(int n){return (n==1 || n==0) ? 1: n * fac(n - 1);}
bool V(char x) {return (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'); } 
template<typename T, typename U> inline signed  amin(T &x, U y) { if(y < x) x = y; return x;}
template<typename T, typename U> inline signed  amax(T &x, U y) { if(x < y) x = y; return x;}
//signed m(){long long T, pp,p,ppp, ct, nn, xx; cin >> p; cin.ignore(); for(int k=0;k<n;k++){for(int l=0;l<(k+1);l++){cin>>a[k][l];}}
#define inn freopen("input.txt", "r", stdin) 
#define outt freopen("output.txt", "w",stdout)
#define all(cont) cont.begin(), cont.end()
#define ll          long long
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)

ll n,E,E1,D=0,c,m,D1,k=0,arr[1000],a,b,d,e,f,flag=0,max2=0,l=0;

vector<int>fi,fi1;
string s;
std::vector<int>::iterator low1, low2;
//set <char> se;

int main () {
double max1=0,st;
cin>>n;
for(int i=1; i<=n; i++)
{
    if(i%2!=0)
    {
        max1++;
    }
}
st=max1/n;
cout<<st;

    


}


Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
import itertools
a=[list(i) for i in itertools.permutations(range(1,n+1))]
import bisect as bi
x=bi.bisect_right(a,p)
y=bi.bisect_right(a,q)
print(abs(x-y))

Measured memory_bytes: 47196
#include <cstdio>
using namespace std;
 
int main() {
  int ans;
  int n;
  scanf("%d", &n);
  if(n % 1000 == 0) {
    ans = 0;
  } else {
    ans = 1000 - n % 1000;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1700
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		int N=sc.nextInt();
		String S[]=new String[N];
		
		int v[]=new int[30];
		
		for(int i=0;i<N;i++) {
			S[i]=sc.next();
			int vv[]=new int[30];
			for(int a=0;a<S[i].length();a++) {
				vv[S[i].charAt(a)-97]++;
			}
			
			for(int c=0;c<30;c++) {
				v[c]=Math.min(v[c], vv[c]);
				if(i==0) {
					v[c]=vv[c];
				}
			}
			
			
		}
		StringBuffer str = new StringBuffer();
		for(int  i=0;i<30;i++) {
			
			for(int a=0;a<v[i];a++) {
				
				str.append((char)(i+97));
			}
		}
		p(str.toString());
		
		}
		
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


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

int main(void){
    int n,t;
    cin>>n>>t;
    vector<ll> s(n+1);
    ll cycle = 0;
    rep(i,n) {
        ll h;
        cin>>h;
        s[i+1] = s[i] + h;
        cycle = max(cycle, h);
        ll tt = t-s[i];
        ll res = tt/cycle + 1;
        if(tt%cycle >= h) res++;
        cout<<max(res,1LL)<<endl;
    }
}

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

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

Measured memory_bytes: 3640
//include
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <sstream>
#include <utility>
//マクロとか
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using ll = long long;

//自前の関数たち
//最大公約数
ll GCD(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

//最小公倍数
ll LCM(ll a, ll b)
{
    return (a * b) / GCD(a, b);
}

//namespace my
namespace my {
    //配列の最大値or最小値を数値で返す関数
    int max_element(std::vector<int> vec){
        std::sort(vec.begin(), vec.end());
        return vec.at(vec.size() - 1);
    }
    int min_element(std::vector<int> vec){
        std::sort(vec.begin(), vec.end());
        return vec.at(0);
    }
}

//yes,noを出力するやつ
void ans(bool qus)
{
    if (qus == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool qust)
{
    if (qust == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

//std名前空間を使用
using namespace std;

////////////////////////////////////////////////////////////////////////////////
//スタート


int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }

    

    for (int i = 1; i < n;i++){
      rep(i, n)
    {
        if (i < n - 1)
        {
            cout << vec[i] << ' ';
        }
        else
        {
            cout << vec[i] << endl;
        }
    }
      
        int v = vec[i];
        int j = i - 1;
        while(j>=0 && vec[j] > v){
            vec[j+1] = vec[j];
            j--;
            vec[j + 1] = v;
        }
    }
    rep(i, n)
        {
            if (i < n - 1)
            {
                cout << vec[i] << ' ';
            }
            else
            {
                cout << vec[i] << endl;
            }
        }

}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if(n%2==0){
        cout << n / 2 - 1 << endl;
    }
    else{
        cout << n / 2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
    double x1,x2,y1,y2;
    cin >> x1 >> x2 >> y1 >> y2;
    cout << setprecision(10) << sqrt((y1 - x1) * (y1 - x1) + (y2 - x2) * (y2 - x2)) << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if((a*100 + b*10 + c) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  string a,b;
  cin>>a>>b;
  string n=a+b;
  int x=stoi(n);
  bool f=false;
  for(int i=1;i<=x;i++){
    if(i*i==x) f=true;
  }
  if(f)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int A;
char S[12];
int main(){
  rd(A);
  rd(S);
  if(A >= 3200){
    wt_L(S);
    wt_L('\n');
  }
  else{
    wt_L("red");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190820-1

// --- original code ---
// int A; char S[12];
// {
//   rd(A,S);
//   wt(if[A >= 3200, S, "red"]);
// }


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<limits.h>
#include<assert.h>
#include<stdbool.h>
#include<stddef.h>
#include<stdint.h>
#include<string.h>
#include<unistd.h>
#include<stdlib.h>

#include<ctype.h>
#include<time.h>
typedef long long ll;
#define pi 3.14159
int main()
{ 
int x,flag=1;scanf("%d",&x);char c[x],d[x];scanf("%s",c);
scanf("%s",d);
for(int i=0;i<x;i++){
printf("%c%c",c[i],d[i]);}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef int data_t;
#define unit 0;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)

struct Segment_Tree{
    int N;
    data_t *datas;

    Segment_Tree(int n, data_t *original_date){
        // original_dataの長さはn, nは二べき (そうじゃなければ単位元でpadding)
        N = n;
        datas = new data_t[2*N];
        for(int i=0;i<N;i++) datas[i+N] = original_date[i];
        for(int i=N-1;i>0;i--) datas[i] = op(datas[i*2],datas[i*2+1]);
    }

    void clear(){
        delete[] datas;
    }

    data_t op(data_t x,data_t y){
        // 考えている演算. (e.g., Range Sum Query等を考えるときは和)
        return x|y;
    }

    void update(int id, data_t val){
        // idに対応する要素をvalに更新
        int pos = id + N;
        datas[pos] = val;

        while(pos!=0){
            pos = pos/2;
            datas[pos] = op(datas[2*pos], datas[2*pos+1]);
        }
    }

    int step(int s){
        s += N;
        int ans = 1;
        while(s%2==0){
            ans *= 2;
            s = s/2;
        }
        return ans;
    }

    data_t aggregate(int s,int t){
        // [s,t) (半開半閉区間)の集約を計算
        s += N;
        t += N;
        int origin_s = s;
        int move;
        data_t ans = unit;
        // 左から見ていって上がっている間のaggregate
        while(true){
            move = step(s);
            if(s + move > t) break;
            else {
                ans = op(ans, datas[s/move]);
                s += move;
            }
        }
        // 右から見ていって上がっている間のaggregate
        while(true){
            move = step(t);
            if(t - move < origin_s) break;
            else{
                t -= move;
                ans = op(ans, datas[t/move]);
            }
        }
        return ans;
    }
};

int count(int val){
    int ans=0;
    rep(i,30){
        ans += ((val>>i)&1);
    }
    return ans;
}

int main(){
    int N,Q;
    string S;
    int type,ind,l,r;
    string s;
    cin>>N>>S>>Q;
    int length = 1;
    int val;
    while(length<N) length = length*2;
    int data[524288];
    rep(i,length) data[i] = 0;
    rep(i,N){
        val = S[i]-'a' + 1;
        data[i] = (1<<val);
    }
    Segment_Tree T(length,data);
    rep(i,Q){
        cin>>type;
        if(type==1){
            cin>>ind>>s;
            val = s[0] - 'a' + 1;
            T.update(ind-1,(1<<val));
        }else{
            cin>>l>>r;
            val = T.aggregate(l-1,r);
            cout<<count(val)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7044
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
#define p push
const int MAX=2e5+5;
const int MAX2=1e6;
const int MAAX=2e18;
const int MOD=1e9+7;
in main()
{
    int n;
    cin>>n;
    int ans=n*(n+1)/2;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        if(s[i]=='7'&&s[i-2]!='/'&&s[i-1]!='/')
            cout<<"8";
        else
            cout<<s[i];
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())

G = [[] for _ in range(N + 1)]
m = map(int, read().split())
for a, b in zip(m, m):
    G[a].append(b)
    G[b].append(a)

par = [0] * (N + 1)
visited = [0] * (N + 1)
root = 1
visited[root] = 1
q = deque([root])
while q:
    v = q.popleft()
    for w in G[v]:
        if visited[w]:
            continue
        visited[w] = 1
        par[w] = v
        q.append(w)

print('Yes')
print(*par[2:], sep='\n')


Measured memory_bytes: 54756
#include<bits/stdc++.h>
#define MOD (1e9+7)
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};

using namespace std;

vector< pair <int , int > > ans;

void printProgression(int n,  vector<int> num)
{
    if(num.size() == 1){
        ans.push_back({n, 0});
    }
    else if(num.size() == 2){
        ans.push_back({n, num[1] - num[0]});
    }
    else{
        int diff = num[1] - num[0];
        for(int i = 2; i < num.size(); i++){
            if(diff != num[i] - num[i-1]) return;
        }
        ans.push_back({n, diff});
    }
}

void solve()
{
   int n, m;
   cin >> n >> m;
   cout << n*m;
    
}
//new line is printed in the main

int main()
{
    int t = 1;
        //cin >> t; // comment out if no test case is required
    int i = 1;
    while(t--){
        //cout << "Case " << i++ << ": ";
        solve();
        // printf("\n");
    }
    return 0;
}


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

using namespace std;

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

ll max(ll x, ll y){
    if(x>y)return x;
    return y;
}
ll x[1000], y[1000], z[1000];
ll xyz[8][1000];

int compare_int(const void *a, const void *b){
	ll *A = (ll *)a;
	ll *B = (ll *)b;
    if(*A < *B)return 1;
    if(*A > *B)return -1;
    return 0;
}

int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 0;i < n;i++){
        scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);
    }
    ll ans = 0;
    for(int k = 0;k < 8;k++){
        for(int i = 0;i < n;i++){
            xyz[k][i] = x[i] * (k/4*2-1) + y[i] * (k/2%2*2-1) + z[i] * (k%2*2-1);
        }
        qsort(xyz[k], n, sizeof(ll), compare_int);
        //for(int j = 0;j < n;j++){
        //    printf("%lld\n", xyz[k][j]);
        //}
        //printf("\n");
        ll ma = 0;
        for(int i = 0;i < m;i++){
            ma += xyz[k][i];
        }
        ans = max(ans, ma);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 380
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int dp[100005];
int h[100005];
int main(){
  int N,K;cin>>N>>K;
  int i,j,k,l;
  rep(i,N) cin>>h[i];
  dp[0]=0;
  rep(i,K){
    dp[i]=abs(h[0]-h[i]);
  }
  for(i=K;i<N;i++){
    dp[i]=INF;
    int tmp;
    repn(j,K){
      tmp=dp[i-j]+abs(h[i-j]-h[i]);
      dp[i]=min(tmp,dp[i]);
    }
  }
  cout<<dp[N-1]<<endl;

}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define cst first
#define dur second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e7 + 5, M = 2 * N + 5;

int main(){
    int n;
    cin >> n;
    int m = (n + 1) / 2;
    long double a = m, b = n;
    cout << fixed << setprecision(10) << a / b << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i = 0, j = 0;
	for(i = 1; i < 10; i++){
		for(j = 1; j < 10; j++){
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	
	return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }


signed main(void){
  string s;
  cin >> s;
  rep(i,12){
    if(i==4) cout << " ";
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <set>
#include <sstream>
#include <string>
#include <queue>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

//MOD//
const ll MOD = 1000000007;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

ll pow(ll n, int m){
  if(!m) return 1;
  ll ret = pow(n, m/2);
  ret *= ret;
  return (m&1) ? ret*n : ret;
}

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

int K;

int main(){
  scanf("%d",&K);
  if (K<=500) {
    cout << K << "\n";
    rep(i,K) {
      rep(j, K) cout << (i+1) << " ";
      cout << "\n";
    }
  } else {
    cout << "500\n";
    int ii;
    rep(i,500) {
      rep(j, 500) {
        ii = (i+j)%500;
        if (ii+500 < K) {
          cout << (ii+1+(j%2)*500) << " ";
        } else {
          cout << (ii+1) << " ";
        }
      }
      cout << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 1152
import numpy as np

n = int(input())

s1 = [0 for i in range(n)]
s2 = [0 for i in range(n)]

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

temp = 0
for i in range(n):
    temp += a[i]
    s1[i] = temp

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

temp = 0
for i in range(1,n+1):
    temp += a[-i]
    s2[-i] = temp

ans = 0

for i in range(n):
    u1 = s1[i]
    u2 = s2[i]
    if ans < (u1+u2):
        ans = u1+u2

print(ans)

Measured memory_bytes: 12396
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;

int main(void) {
    u64 N;
    cin >> N;

    vector<u64> A(N);
    bool zero = false;

    for(u64 i=0; i<N; i++) {
        cin >> A[i];
        zero |= (A[i] == 0);
    }

    if(zero) {
        cout << 0 << endl;
        return 0;
    }

    u64 prd = 1;
    for(u64 i=0; i<N; i++) {
        if(A[i] <= 1000000000000000000/prd) {
            prd *= A[i];
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << prd << endl;
    return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int ab(int a){
  return a>0 ? a : a*-1;
}

int main(){
  int n;
  cin >> n;
  vi h(n);
  vi dp(n,INT_MAX);
  rep(i,0,n) cin >> h[i];

  dp[0]= 0;
  dp[1]= ab(h[1]-h[0]);
  rep(i,2,n){
    dp[i]= min(dp[i-2]+ab(h[i]-h[i-2]), dp[i-1]+ab(h[i]-h[i-1]));
  }
  cout << dp[n-1];
}

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

signed main(){
    int N; cin >> N;
    
    vector<int> A(N), B(N);
    
    vector<P> List(N);
    
    for(int i = 0; i < N; ++i){
        cin >> A[i] >> B[i];
        List.push_back({B[i], A[i]});
    }
    
    sort(List.begin(), List.end(), greater<P>());
    int time = 1E10;
    
    for(int i = 0; i < N; ++i){
        time = min(time, List[i].first) - List[i].second;
    }
    
    if(time >= 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 11520
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (x, y) = get!(usize, usize);
    let (a, b) = if x < y { (x, y) } else { (y, x) };
    println!("{}", if b-a < 2 { "Brown" } else { "Alice" });
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

#define MAX 1300001

vector<int> vprimes;
bool *isPrime = new bool[MAX];

/* ツ素ツ青板青カツ青ャ O(n^2) */
void MakePrime(){
  isPrime[0]=false;
  isPrime[1]=false;
  isPrime[2]=true;
  for(int i = 2; i < MAX; ++i){
    isPrime[i] = true;
  }
  for(long long int i = 2; i < MAX; ++i){
    if( isPrime[i] ){
      for(long long int j = 2; i * j < MAX; ++j) {
	isPrime[i*j] = false;
      }
    }
  }
  for(int i = 0; i < MAX; ++i){
    if( isPrime[i] ){
      vprimes.push_back( i );
    }
  }
}

int main(){
  MakePrime();

  while(true){
    int k;
    cin >> k;
    if(k==0)break;

    int l=0;
    int lower=0,upper=0;
    int m,prem;
    bool inv=false;
    int r=vprimes.size();
    while(true){
      m=(l+r)/2;
      if(prem==m){
	if(vprimes[m]>k){
	  lower=m-1;
	  upper=m;
	}
	if(vprimes[m]<k){
	  lower=m;
	  upper=m+1;
	}
	break;
      }
      if(vprimes[m]>k)r=m;
      if(vprimes[m]<k)l=m;
      if(vprimes[m]==k){
	inv=true;
	break;
      }
      prem=m;
    }
    if(inv)lower=upper=1;
    cout << vprimes[upper]-vprimes[lower] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
def check(start, end):
    for i in range(start, end - 1):
        if s[i] == '#' and s[i + 1] == '#':
            return False
    return True


n, a, b, c, d = map(int, input().split())
s = input()
s = '#' + s + '#'

# a~c,b~d間で岩2連続は無理
if not check(a, c) or not check(b, d):
    print('No')
    exit()

# d<cなら飛び越え必要=b~d区間に3マス連続空きが必要
if d < c:
    for i in range(b, d + 1):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            print('Yes')
            exit()
    print('No')
else:
    print('Yes')


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

int main() {
  int n,W;
  cin >> n >> W;
  int64_t w[n],v[n];
  for(int i=0;i<n;i++) cin >> w[i] >> v[i];
  vector<vector<int64_t>> m(n,vector<int64_t>(W+1,0));
  for(int i=0;i<=W;i++) m[0][i] = (i<w[0] ? 0 : v[0]);
  for(int i=0;i<n-1;i++){
    for(int j=0;j<=W;j++){
      if(j-w[i+1] >= 0) m[i+1][j] = max(m[i][j],m[i][j-w[i+1]]+v[i+1]);
      else m[i+1][j] = max(m[i][j],m[i+1][j]);
    }
  }
  cout << m[n-1][W] << endl;
}


Measured memory_bytes: 79488
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         double x;
         cin>>x;
         x=x/3;
         cout<<fixed<<" "<<setprecision(10)<<(x*x*x)<<"\n";
         

      }
      






}



























Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
long long weishu=0;
int main(){
	long long i,j,k,n,l=0;
	cin>>n;
	for(i=sqrt(n);i>=1;i--){
		if(n%i==0){
			k=n/i;
			while(k>0){
				k/=10;
				weishu++;
			}
			cout<<weishu<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
N = input()
N1 = [2,4,5,7,9]
N2 = [0,1,6,8]
N3 = [3]
N0 = int(N[-1])
if N0 in N1:
    print('hon')
elif N0 in N2:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9024
n = gets.to_i
a = gets.split.map(&:to_i)

def partition(a, p, r)
  x = a[r]
  i = p - 1

  (p...r).each do |j|
    if a[j] <= x
      i += 1
      tmp = a[i]
      a[i] = a[j]
      a[j] = tmp
    end
  end

  tmp = a[i + 1]
  a[i + 1] = a[r]
  a[r] = tmp
  return i + 1
end

q = partition(a, 0, n - 1)
a[q] = "[#{a[q]}]"
puts a.join(' ')


Measured memory_bytes: 13944
package main

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

func main() {
	var K, X int
	fmt.Scanf("%d %d", &K, &X)

	var min, max int
	if X-K+1 > -1000000 {
		min = X - K + 1
	} else {
		min = -1000000
	}

	if X+K-1 < 1000000 {
		max = X + K - 1
	} else {
		max = 1000000
	}

	writer := bufio.NewWriter(os.Stdout)
	for i := min; i <= max; i++ {
		writer.WriteString(strconv.Itoa(i))
		if i != max {
			writer.WriteString(" ")
		}
	}
	writer.WriteString("\n")
	writer.Flush()
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;

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

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

int main() {
    int n,k;
    cin >> n >> k;
    if(k%2==1){
        ll a = n/k;
        cout << a*a*a << endl;
    }else{
        ll a = n/k;
        ll b = (n+k/2)/k;
        cout << a*a*a+b*b*b << endl;

    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define pi 3.141592653589793238462643383279502884197
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int dp[214514][2]; // 0: straight 1:reversed
signed main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	dp[1][0] = a[0] + a[1];
	dp[1][1] = - ( a[0] + a[1] );
	for(int i=2;i<n;i++){
		dp[i][0] = max( dp[i-1][0], dp[i-1][1] ) + a[i];
		dp[i][1] = max( dp[i-1][0] - 2*a[i-1] - a[i], dp[i-1][1] + 2*a[i-1] - a[i] );
		//cout<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<endl;
	}
	cout<<max( dp[n-1][0], dp[n-1][1] ) <<endl;
	return 0;
}

Measured memory_bytes: 2560
def main():
  N,M = map(int, input().split())
  num = [-1]*N
  for i in range(M):
    s,c = map(int,input().split())
    if num[s-1]>=0 and num[s-1]!=c:
      print(-1)
      return
    num[s-1] = c
  if N==1 and num[0]<0: num[0] = 0
  elif N>1 and num[0]==0:
    print(-1)
    return
  elif N>1 and num[0]<0: num[0] = 1
  
  print("".join([str(0 if i<0 else i) for i in num]))
main()

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

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

	int tp = 0, hp = 0;
	for( int i = 0; i < n; i++ ) {
		string tc, hc;
		cin >> tc >> hc;
		if( tc == hc ) {
			tp += 1;
			hp += 1;
		}
		if( tc > hc ) {
			tp += 3;
		}
		if( tc < hc ) {
			hp += 3;
		}
	}
	cout << tp << " " << hp << endl;
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  int win = 0;
  
  for (int i = 0; i < S.size(); i++){
    if (S.at(i) == 'o') {
      win++;
    }
  }
  
  if (win + 15 - S.size() < 8)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,q;
ll t;
ll d[600001];
ll sum[600001];

ll labs(ll x){
	if(x<0LL)return -x;
	return x;
}

bool res[600001];
ll cnt[600001];
vector<ll> vec;

int main(void){
	scanf("%d%lld",&n,&t);
	for(int i=0;i<n;i++){
		scanf("%lld",&d[i]);
		vec.push_back(d[i]);
	}
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	for(int i=0;i<n;i++){
		ll nex=d[i];
		if(sum[i]>t)nex=-d[i];
		if(labs(t-sum[i]-nex)<labs(t-sum[i])){
			sum[i+1]=sum[i]+nex;
		}else sum[i+1]=sum[i];
	}
	for(int i=0;i<n;i++){
		d[i]=lower_bound(vec.begin(),vec.end(),d[i])-vec.begin();
	}
	ll sums=0;
	ll len=1;
	for(int i=n-1;i>=0;i--){
		if(sum[i]==t){
			res[i]=false;
		}else{
			if(sum[n]!=t){
				res[i]=true;
			}else{
				if(vec[0]!=1LL){
					res[i]=true;
				}else{
					ll now=labs(t-sum[i]);
					if(now>sums){
						res[i]=true;
					}else{
						if(len>now){
							res[i]=false;
						}else res[i]=true;
					}
				}
			}
		}
		sums+=vec[d[i]];
		cnt[d[i]]++;
		if(len>=vec[d[i]]){
			len+=vec[d[i]];
		}else if(len<vec[d[i]] && len*2LL>vec[d[i]]){
			len+=vec[d[i]];
		}
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		int query;
		scanf("%d",&query);
		printf("%s\n",res[query-1]?"YES":"NO");
	}
	return 0;
}


Measured memory_bytes: 18156
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll fac(ll n){
	ll res=0;
	for(ll i=1;i<=(ll)sqrt(n);++i){
		if(n%i==0){
			if(n/i==i) ++res;
			else res+=2;
		}
	}
	return res;
}
int main(){
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	ll count=0;
	vector<ll>v(n+1,1);
	for(ll i=2;i<=n;++i){
		for(ll j=1;j<=n/i;++j) v[j*i]++;
	}
	for(ll i=1;i<=n;++i) count+=(i*v[i]);
	cout<<count;
	return 0;
}

Measured memory_bytes: 81340
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
int main() {
	ll N, M; cin >> N >> M;
	string S, T; cin >> S >> T;
	ll l = lcm(N, M);
	ll g = gcd(N, M);
	for (ll i = 0; i < g; ++i) {
		if (S[N*i / g] != T[M*i / g]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main() {
    int n; scanf("%d", &n);
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    printf("%lld", ans);
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int main(){
  long long ans=0;
  int a,b,c;
  cin>>a;
  for(int i=1;i<=a;i++) for(int j=1;j<=a;j++) for(int k=1;k<=a;k++)
    ans= ans+gcd(gcd(i,j),k);
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
//        ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define debug(x) cout<<#x<<": "<<x<<endl
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 
 
 
#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000000005
#define MOD 1000000007
                                  //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
vector<int> adj[200005];
int vis[200005];
int parent[200005];
void bfs(int start)
{
    queue<int> q;
    q.push(start);
    vis[start] = 1;
    while(!q.empty())
    {
        int x = q.front();
        q.pop();
        for(auto to : adj[x])
        {
            if(!vis[to])
            {
                parent[to] = x;
                vis[to] = 1;
                q.push(to);
            }
        }
    }
}
 
int main() {
    #ifdef sharma
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);      
    #endif
    fastio;
    int n, q;
    cin >> n >> q;
    int m = n-1;
    //int parent[n+1] = {0};
    parent[1] = -1;
    while(m--)
    {
        int u, v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);

    }
    int upd[n+1] = {0};
    while(q--)
    {
        int p, x;
        cin >> p >> x;
        upd[p] += x;
    }
    bfs(1);
    int mark[n+1] = {0};
    parent[1] = -1;
    int ans[n+1] = {0};
    fr(i, 2, n)
    {
        int y = i;
        while(y != -1)
        {
            if(mark[y] == 1)
            {
                ans[i] += ans[y];
                mark[i] = 1;
                break;
            }    
            ans[i] += upd[y];
            y = parent[y];
        }
        int prev = i;
        y = i;
        mark[i] = 1;
        while(y != -1)
        {
            y = parent[y];
            if(mark[y] == 1)
                break;
            ans[y] = ans[prev]-upd[prev];
            mark[y] = 1;
            prev = y;
        }
    }
    ans[1] = upd[1];
    fr(i, 1, n)
    cout << ans[i] << " ";



    return 0; 
}

Measured memory_bytes: 18676
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;

const int MAX_N = 5000, MAX_M = 100000;

int N, M, a[MAX_M], b[MAX_M];

int indeg[MAX_N];
vector<int> g[MAX_N];
int ans[MAX_N];
bool only = true;

void solve() {
	memset(indeg, 0, sizeof(indeg));

	for (int i = 0; i < M; i++) {
		g[a[i] - 1].push_back(b[i] - 1);
		indeg[b[i] - 1]++;
	}

	queue<int> q;
	vector<int> tsort;

	for (int i = 0; i < N; i++) {
		if (indeg[i] == 0) q.push(i);
	}

	while (!q.empty()) {
		int cur = q.front();
		only &= q.size() == 1;
		ans[tsort.size()] = cur;
		tsort.push_back(cur);
		q.pop();
		for (int i = 0; i < g[cur].size(); i++) {
			indeg[g[cur][i]]--;
			if (indeg[g[cur][i]] == 0) q.push(g[cur][i]);
		}
	}

	for (int i = 0; i < N; i++) {
		printf("%d\n", ans[i] + 1);
	}
	printf("%d\n", !only);
}

int main() {
	scanf("%d %d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &a[i], &b[i]);
	}

	solve();
}



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

using namespace std;

vector<int> ed[200000];

int dp[200000];
int dfs(int x)
{
  if(dp[x])return dp[x];
  dp[x]=0;for(int i=0;i<ed[x].size();i++)dp[x]=max(dp[x],dfs(ed[x][i])+1);
  return dp[x];
}

int main()
{
  int n=0,m=0;scanf("%d%d",&n,&m);for(int i=1,a=0,b=0;i<=m;i++){scanf("%d%d",&a,&b);ed[a].push_back(b);}
  for(int i=1;i<=n;i++)if(!dp[i])dfs(i);
  int maxn=0;for(int i=1;i<=n;i++)maxn=max(maxn,dp[i]);printf("%d",maxn);
  return 0;
}

Measured memory_bytes: 10496
n = int(input())
list = list(map(int, input().split()))

count = 0

for i in range(1, len(list)-1):
    num = list[i]
    if (num > list[i-1] and num < list[i+1]) or (num < list[i-1] and num > list[i+1]):
        count += 1

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long my(long long x,long long y){
  if(x<y)
    swap(x,y);
  while(y>0){
    long long z=y;
    y=x%z;
    x=z;
  }
  return x;
}

int main(){
  int n;
  cin >> n;
  vector<long long> mon(n);
  for(int i=0;i<n;i++)
    cin >> mon.at(i);
  long long x=mon.at(0);
  for(int i=1;i<n;i++)
      x=my(mon.at(i),x);
  cout << x << endl;
}

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

int main() {
	int A,B,C,D ;
	cin >> A >> B >> C >> D ;
	if (A + B < C + D) {
		cout << "Right" << endl;
	}
	else if (A + B == C + D) {
		cout << "Balanced" << endl;
	}
	else if (A + B > C + D) {
		cout << "Left" << endl;
	}
}


Measured memory_bytes: 256