akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n,m=map(int,input().split())
uf=UnionFind(m)
L=[0]*m
for i in range(n):
  A=list(map(int,input().split()))
  for j in range(len(A)-1):
    if j<len(A)-2:
      uf.union(A[j+1]-1,A[j+2]-1)
    L[A[j+1]-1]+=1
LL=[]
for i in range(m):
  if L[i]==0:
    continue
  LL.append(uf.find(i))
if len(set(LL))==1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 15532
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <cmath>
#include <cassert>

#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, MOD = 1e9 + 7;

int N, M, dp[MN], out[MN], ret;
vector<int> adj[MN];

int dfs(int u) {
    if (~dp[u]) return dp[u];
    dp[u] = 0;
    for (int v : adj[u]) dp[u] = max(dp[u], dfs(v) + 1);
    ret = max(ret, dp[u]);
    return dp[u];
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> N >> M;
    for (int i = 0, x, y; i < M; i++) {
        cin >> x >> y;
        adj[x].push_back(y);
    }
    memset(dp, -1, sizeof(dp));
    for (int i = 1; i <= N; i++) dfs(i);
    cout << ret << '\n';
    return 0;
}


Measured memory_bytes: 7552
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL n,a[105];
LL mi = 0x3f3f3f3f3f3f3f3f,id = -1;

int main(){
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 1;i <= 100;i ++){
		LL tmp = 0;
		for(LL j = 1;j <= n;j ++) tmp += (a[j] - i) * (a[j] - i);
		mi = min(mi,tmp);
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

//#include <vector>
//#include <set>
//#include <map>
//#include <iostream>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000//10^12

//using namespace std;


int main(void)
{
	//変数の宣言
	int n,a,b,c;
	int l[10];
	int cost;
	int sum[2][500];

	//よく使う変数
	int i,j,k;
	int flag=0;
	int ans=0;
	int cnt=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	//int sum=0;



	//データの読み込み


	scanf("%d %d %d %d",&a,&b,&c,&k);
//	scanf_s("%d %d %d %d",&a,&b,&c,&k);

/*	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
		scanf_s("%d",&l[i]);
	}
	*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理
	
	if(k%2==0){
		ans=a-b;
	}else{
		ans=b-a;
	}

	//	printf("計算部分終了\n");

	//出力

	printf("%d",ans);

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    ll n, k;
    cin >> n >> k;
    vl x(n);
    rep(i, n) cin >> x[i];
    ll ans = 1e18;
    rep(i, n-k+1) {
        ll s = x[i];
        ll t = x[i+k-1];
        ll tmp;
        if(s < 0) {
            if(t <= 0) tmp = abs(s);
            else tmp = min(-s, t) * 2  + max(-s, t);
        }
        else tmp = t;
        ans = min(ans, tmp);
        // cout << s << " " << t << " " << tmp << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int s,a,b,n=0,x,c,d;
    scanf("%lld%lld%lld",&a,&b,&x);
    c=a/x;
    if(a>c*x){
        n++;
    }
    d=b/x;

    s=d-c-n+1;
    printf("%lld\n",s);

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	NAB := sc.nextInts()
	N := NAB[0]
	A := NAB[1]
	B := NAB[2]
	if N*A > B {
		fmt.Println(B)
	} else {
		fmt.Println(N * A)
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int kokunai = 0;
	int kaigai = 0;
	int num_of_b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'a') {
			if (kokunai + kaigai < a + b) {
				kokunai++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
		}
		else if (s[i] == 'b') {
			num_of_b++;
			if (kokunai + kaigai < a + b && num_of_b <= b) {
				kaigai++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
		}
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=1005;
typedef long long ll;

int n,m;
int a[maxn];
ll ans=1;

int main()
{
	int i,j,k,p;
	scanf("%d%d",&n,&p);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&j);
		if(j%2==0) a[2]++;
		else a[1]++;
	}
	
	if(p==1&&a[1]==0)
	{
		printf("0");
		return 0;
	}
	
	if(p==0&&a[1]==0) a[1]+=1;
	  
	k=a[2]+a[1]-1;
	printf("%lld",(ll)(1)<<k);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INF = 10000000;
 
int main() {
    
    string s;
    int r=700;
    int ans=0;
    int t;
    cin >> s;
    
    if(s[0]=='o') ans++;
    if(s[1]=='o') ans++;
    if(s[2]=='o') ans++;
    
    t = ans*100;
    
    cout << r + t <<endl;
    
    
    
    
    
  
  return 0;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    h = [int(x) for x in input().split()]

    dp = [-1]*N
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])

    for i in range(2,N):
        dp[i] = min(abs(h[i]-h[j]) + dp[j] for j in range(max(0,i-K),i))
    print(dp[N-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 13928
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,K; cin>>N>>K;
  vector<ll> x(N); rep(i,N) cin>>x[i];
  
  ll ans=INF;
  rep(i,N-K+1){
    ll sans=x[i+K-1]-x[i];
    sans+=min(abs(x[i]),abs(x[i+K-1]));
    chmin(ans,sans);
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 4000
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

root = None
def insert(z):
    global root
    y = None
    x = root
    while x:
        y = x
        x = x[z[2] >= x[2]]
    z[3] = y

    if not y:
        root = z
    else:
        y.__setitem__(z[2] >= y[2], z)

def find(k):
    x = root
    while x:
        if x[2] == k:
            return 1
        x = x[k >= x[2]]
    return 0

def __delete(x):
    global root
    if x[0] and x[1]:
        y = x[1]
        while y[0]:
            y = y[0]
        x[2] = y[2]
        __delete(y)
    elif not x[0] and not x[1]:
        if x[3]:
            p = x[3]
            p.__setitem__(p[1] is x, None)
        else:
            root = None
        del x
    else:
        y = x[0] or x[1]

        if x[3]:
            p = x[3]

            y[3] = p
            p[p[1] is x] = y
        else:
            y[3] = None
            root = y
        del x

def delete(k):
    x = root
    while x:
        if x[2] == k:
            break
        x = x[k >= x[2]]
    if not x:
        return
    __delete(x)

def debug():
    s0 = [""]
    s1 = [""]

    def dfs(nd):
        v = str(nd[2])
        s0.append(v)
        if nd[0]:
            dfs(nd[0])
        s1.append(v)
        if nd[1]:
            dfs(nd[1])
    dfs(root)
    return " ".join(s1), " ".join(s0)


M = int(readline())
ans = []
for m in range(M):
    cmd, *V, = readline().split()
    if cmd == "print":
        ans.extend(debug())
    elif cmd == "find":
        ans.append("yes" if find(int(V[0])) else "no")
    elif cmd == "delete":
        delete(int(V[0]))
    else:
        insert([None, None, int(V[0]), None])
write("\n".join(ans))
write("\n")



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

using namespace std;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i += 2){
		if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') continue;
		else{
			cout << "No";
			return 0;
		}
	}	

	for(int i = 1; i < s.length(); i += 2){
		if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D') continue;
		else{
			cout << "No";
			return 0;
		}
	}	

	cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N;
long long arr [100], dp [100];

int main(){
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N; dp[0] = 1000;
    for(int i = 1; i <= N; i++){
        cin >> arr[i];
        dp[i] = dp[i-1];
        for(int j = 1; j < i; j++){
            dp[i] = max(dp[i], (dp[j]/arr[j])*(arr[i]-arr[j])+dp[j]);
        }
    }
    cout << dp[N] << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n, W;
    cin >> n >> W;

    vl w(n), v(n);
    rep(i, n) {
        cin >> w[i] >> v[i];
    }

    vvl dp(n+1, vl(W+1));  // dp[i][j] : i個目の品物までで重さの総和がj以下のときの価値の総和の最大値
    rep(i, n) {
        exrep(j, 0, W) {
            chmax(dp[i+1][j], dp[i][j]);
            if(j + w[i] <= W) {
                chmax(dp[i+1][j + w[i]], dp[i][j] + v[i]);
            }
        }
    }

    out(dp[n][W]);
    re0;
}

Measured memory_bytes: 83012
import java.util.Scanner;
import java.math.BigInteger;

public class Main
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in).useDelimiter("=|\\+|\\s+");

		String tmp,str[];
		BigInteger num[];
		
		str = new String[3];
		num = new BigInteger[3];
		
		while(cin.hasNext())
		{
			for(int i=0; i<3; i++)
			{
				str[i] = cin.next();
			}
			
			char ch;
			for(ch='0'; ch<='9'; ch++)
			{
				boolean isLZ = false;
				for(int i=0; i<3; i++)
				{
					tmp    = str[i].replace('X', ch);
					num[i] = new BigInteger(tmp);
					
					if(tmp.charAt(0)=='0' && tmp.length()>1)
					{
						isLZ = true;
					}
				}
				if(isLZ)
				{
					continue;
				}
				
				if(num[0].add(num[1]).compareTo(num[2]) == 0)
				{
					break;
				}
			}
			
			if(ch<='9')
				System.out.println(ch);
			else
				System.out.println("NA");				
		}
	}
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string T = "";
            //Console.WriteLine(str.Substring(T.Length, 5) + "\n" + str.Substring(T.Length + 5, 5));
            char[] work = str.ToCharArray();
            Array.Reverse(work);
            str = new string(work);
            while (true)
            {
                if (str == T)
                {
                    Console.WriteLine("YES");
                    break;
                }
                try
                {
                    if (str.Substring(T.Length, 5) == "maerd" || str.Substring(T.Length, 5) == "esare")
                    {
                        T += str.Substring(T.Length, 5);
                    }
                    else if (str.Substring(T.Length, 6) == "resare")
                    {
                        T += "resare";
                    }

                    else if (str.Substring(T.Length, 7) == "remaerd")
                    {
                        T += "remaerd";
                    }
                    else
                    {
                        Console.WriteLine("NO");
                        break;
                    }
                }
                catch
                {
                    Console.WriteLine("NO");
                    break;
                }
            }
        }// End_function
    }// End_class
}


Measured memory_bytes: 24200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
  
struct Node{
  int key;

  struct Node *right;

  struct Node *left;

  struct Node *parent;
};
  
struct Node *root,*NIL;

struct Node* treeGet(struct Node *,int );

void treeInsert(int);

void inorder(struct Node *);

void preorder(struct Node *);

int main(){

  int n,i,x;
  
  char com[7];

  struct Node *t;

  scanf("%d",&n);

  for(i = 0;i < n;i ++)
    {

      scanf("%s",com);
      
      if(strcmp(com,"find") == 0)
	{
	  scanf("%d",&x);
	  
	  t = treeGet(root,x);
	  
	  if(t != NIL)
	    {
	      printf("yes\n");
	    }
	  else{
	    printf("no\n");
	  }
	}
      else if(strcmp(com,"insert") == 0)
	{
	  scanf("%d",&x);
	  treeInsert(x);
	}
      else if(strcmp(com,"print") == 0)
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}
    }
  return 0;
}

struct Node* treeGet(struct Node *u,int k){

  while(u != NIL && k != u -> key)
    {
      if(k < u -> key)
	{
	u = u -> left;
	}
      else {
	u = u -> right;
      }
    }
  return u;
}

void treeInsert(int k){

  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;
  
  z = (struct Node*)malloc(sizeof(struct Node));
  
  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;

  while(x != NIL)
    {
      y = x;
      if(z -> key < x -> key)
	{
	  x = x -> left;
	}
      else{
	x = x -> right;
      }
    }
  z -> parent = y;
  if(y == NIL)
    {
      root= z;
    }
  else{
    if(z -> key < y -> key)
      {
	y -> left = z;
      }
    else{
      y -> right = z;
    }
  }
}

void inorder(struct Node *u){

  if(u == NIL)return ;
  inorder(u -> left);
  printf(" %d",u -> key);
  inorder(u -> right);
}
  
void preorder(struct Node *u){

  if(u == NIL) return ;
  printf(" %d",u -> key);
  preorder(u -> left);
  preorder(u -> right);
}

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >> P[i];
    P[i] *= -1;
  }
  
  priority_queue<int> Q;
  int ans=0;
  for(int i=0;i<N;i++){
    Q.push(P[i]);
    if(P[i]<Q.top()) continue;
    ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a;i < b;i++)
#define rrep(i,a,b) for(int i = a;i >= b;i--)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << #x << ": " << x << endl;
typedef long long ll;
using namespace std;

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

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

   int a,b;
   cin >> a >> b;
   cout << (a == 2 || b == 2 ? "No" : "Yes") << endl;

   return 0;
}

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

int main(){
    string S,T;
    cin >> S >> T;
    bool ans = false;
    for(int i = 0; i < S.size(); i++){
        if(S==T){
            ans = true;
            break;
        }
        S = S.back() + S.substr(0, S.size()-1);//rotation
    }
    if(ans){
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    REP(i, A) cin >> a[i];
    vector<int> b(B);
    REP(i, B) cin >> b[i];
    int minA = 1e9;
    REP(i, A) {
        if(a[i] < minA) minA = a[i];
    }
    int minB = 1e9;
    REP(i, B) {
        if(b[i] < minB) minB = b[i];
    }
    int min = minA + minB;
    REP(i, M) {
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        if(a[x] + b[y] - c < min) min = a[x] + b[y] - c;
    }
    cout << min << endl;
}

Measured memory_bytes: 1024
s = input().split()

s_1 = s[0]
s_2 = s[1]
s_3 = s[2]

S_1 = s_1[0]
S_2 = s_2[0]
S_3 = s_3[0]

print((S_1 + S_2 + S_3).upper())

Measured memory_bytes: 38384
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"3
4980
7980
6980
" => r"15950",

r"4
4320
4320
4320
4320
" => r"15120"
}

use std::cmp;
use std::collections::HashSet;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        s: [i32; n],
    }

    let mut ans = 0;
    let mut maximum = 0;
    for i in 0..n {
        let tmp = s[i];
        ans += tmp;
        maximum = cmp::max(maximum, tmp);
    }

    (ans - maximum / 2).to_string()
}


Measured memory_bytes: 4352
#include<stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include<cmath>
using namespace std;

int A[5], minr = 10, sum = 0;

int main() {
    for ( int i = 0; i < 5; i++ ) {
        scanf("%d", &A[i]);
        
        if ( A[i] % 10 == 0 ) {
            sum += A[i];
        } else {
            sum += A[i] / 10 * 10 + 10;
            if ( A[i] % 10 < minr ) {
                minr = A[i] % 10;
            }
        }
    }
    
    sum = sum - 10 + minr;
    
    printf("%d\n", sum);
}



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

int main() {
  int N;
  int result = 0;
  cin >> N;
  
  string data[200010];
  for(int i = 0; i < N; i++) cin >> data[i];
  sort(data, data + 200010);
  reverse(data, data+200010);
  
  for(int i = 0; i < N; i++) {
    if(data[i] != data[i + 1]) {
      result++;
    }
  }
  
  cout << result << endl;
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> B(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> B[i];
  }
  vector<int> A(N);
  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]);
  }
  int res = 0;
  for (int a : A) {
    res += a;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]

'''
選んだ数字(iで場所指定)より、左の数字が全て大きい。
'''
c = 0
MIN = p[0]
for i in range(n):
    if p[i] <= MIN:
        c += 1
        MIN = p[i]

print(c)

Measured memory_bytes: 75856
N,A,B = map(int,input().split())
S = input()

cnt = 0 # 予選通過人数
rank_f = 1 # 海外学生の順位
for i in range(N):
  if(S[i] == 'a'):
    if(cnt < A+B):
      print('Yes')
      cnt += 1
    else:
      print('No')
  elif(S[i] == 'b'):
    if((cnt < A+B)and(rank_f <= B)):
      print('Yes')
      rank_f += 1
      cnt += 1
    else:
      print('No')
  elif(S[i] == 'c'):
     print('No')
    

Measured memory_bytes: 4016
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
--
local N = read.nl()
local S = (read.l()):totable()
local t = {S[1]}
for i=2,N do
    local last = t[#t]
    if S[i] ~= last then
        table.insert(t, S[i])
    end
end
print(#t)


Measured memory_bytes: 4628
N = int(input())

N = N % 10

if N == 2 or N == 4 or N == 5 or N == 7 or N == 9:
    print('hon')
elif N == 0 or N == 1 or N == 6 or N == 8:
    print('pon')
else:
    print('bon')

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

int main() {
  int n;
  cin >> n;
  string x;
  vector<string> s(n);
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i];
  }
  cin >> x;
  int sum = 0;
  bool flg = false;
  for (int i = 0; i < n; i++) {
    if (flg) {
      sum += t[i];
    }
    if (s[i] == x) {
      flg = true;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    char s[13];
    int i=0;
    cin >> s;
    while(s[i]!='\0'){
        if(i==4) printf(" %c", s[i]);
        else printf("%c", s[i]);
        i++;
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <bits/stdc++.h>
#include <set>
#include <list> //list<???> a; a.push_back ,insert(追加したい要素),a.sort(),参照できない
#include <vector> //vector<???> a; a.push_back,sort(a.begin(),a.end());a[i]
//配列 int a[N];a[i]=追加したい要素;sort(a,a+N);a[i]
using namespace std;
typedef long  ll;
#define rep(i,n) for(int i=0;i<(n);i++)


//using namespace std;
//


int main(){
  int h,w;cin>>h>>w;
  string ans[h];


  for(int i=0;i<h;i++){
    string moji;cin>>moji;
    ans[i]=moji;
  }
  for(int i=0;i<h;i++){
    cout<<ans[i]<<endl;
    cout<<ans[i]<<endl;
  }

}

Measured memory_bytes: 256
x,k,d = map(int,input().split())

x = abs(x)

if x > k*d:
    print(x-k*d)
elif x == 0:
    if k%2 ==0:
        print(0)
    else:
        print(d)
else:
    x_r = x%d
    x_l = x%d - d
    t = 0
    while x >= 0:
        x -= d
        t += 1
    if (k - t)%2 == 0:
        print(abs(x_l))
    else:
        print(x_r)

Measured memory_bytes: 62772
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int keta(int a)
{
	if(a/1000000 >= 1)	return 7;
	else if(a/100000 >= 1)	return 6;
	else if(a/10000 >= 1)	return 5;
	else if(a/1000 >= 1)		return 4;
	else if(a/100 >= 1)		return 3;
	else if(a/10 >= 1)		return 2;
}

int main()
{
  int a,b,sum;
  while(scanf("%d %d",&a, &b)!=EOF){
    sum = a + b;
    cout << keta(sum) << endl;
  }
}

Measured memory_bytes: 1208
def main():
  L = str(input())
  dp = [[0, 0] for _ in range(len(L))]
  dp[0][0] = 1
  dp[0][1] = 2
  MOD = 10**9 + 7
  for i in range(1, len(L)):
    if L[i] == '1':
      dp[i][0] = 3*dp[i-1][0] + dp[i-1][1]
      dp[i][0] %= MOD
      dp[i][1] = 2*dp[i-1][1]
      dp[i][1] %= MOD
    else:
      dp[i][0] = 3*dp[i-1][0]
      dp[i][0] %= MOD
      dp[i][1] = dp[i-1][1]
  print((dp[-1][0] + dp[-1][1])%MOD)

if __name__ == "__main__":
  main()

Measured memory_bytes: 19652
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N, M = map(int, input().split())

    ac = [0] * N
    wa = [0] * N
    num_ac = 0
    num_pe = 0
    for i in range(M):
        P, S = input().split()
        P = int(P) - 1

        if S == "AC":
            if ac[P]:
                continue
            else:
                ac[P] = 1
                num_ac += 1
                num_pe += wa[P]
        else:
            if ac[P]:
                continue
            else:
                wa[P] += 1

    print(num_ac, num_pe)


def main():
    solve()


if __name__ == '__main__':
    main()


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

const int MAX_N = 10010;

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

  vector<int> v(MAX_N, 0);
  for (int x = 1; x * x <= MAX_N; ++x) {
    for (int y = 1; y * y <= MAX_N; ++y) {
      if (x * x + y * y > MAX_N) break;
      for (int z = 1; z * z <= MAX_N; ++z) {
        ll num = (ll)x * x +  y * y + z * z + x * y + y * z + z * x;
        if (num < MAX_N) v[num]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << v[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


int main(){
    for(;;){
        int n,m,a;
        cin >> n >> m >>a;
        if(!n)break;
        vector<int> tate(n);
        vector<pair<int, pair<int, int> > > yoko(m);
        rep(i,n) tate[i]=i+1;
        for (int i=0; i<m; i++) {
            int h,p,q;
            cin >> h >> p >>q;
            yoko[i]={h,{p,q}};
        }
        sort(yoko.begin(), yoko.end() );
        for (int i=m-1; i>=0; i--) {
            int temp=tate[yoko[i].second.first-1];
            tate[yoko[i].second.first-1] = tate[yoko[i].second.second-1];
            tate[yoko[i].second.second-1] = temp;
        }
        for (int i=0; i<n; i++) {
            if (tate[i]==a) {
                cout << i+1 <<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;
int n;
int a[N], tw = 1;
int cal() {
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (((n - 1)&i) == i)
			res ^= a[i];
	}
	return (res & 1);
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		char c;
		scanf(" %c", &c);
		a[i] = c - '1';
		if (a[i] == 1)tw = 0;
	}
	if (cal())puts("1");
	else {
		if (!tw)puts("0");
		else {
			for (int i = 0; i < n; i++)a[i] /= 2;
			if (cal())puts("2");
			else puts("0");
		}
	}
	return 0;
}

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

struct node{
    int c0 = -1, c1 = -1;
    int depth;
    bool dead = false;
    node(int d) : depth(d) {}
};

vector<node> nodes;
string s;

void grow_tree(int v, int p){
    nodes[v].dead = true;
    if(p == s.size()) return;
    if(nodes[v].c0 == -1){
        nodes.emplace_back(nodes[v].depth + 1);
        nodes.emplace_back(nodes[v].depth + 1);
        int c0 = nodes.size() - 2, c1 = nodes.size() - 1;
        nodes[v].c0 = c0;
        nodes[v].c1 = c1;
    }
    grow_tree(s[p] == '0' ? nodes[v].c0 : nodes[v].c1, p + 1);
}

ll grundy(ll h){
    ll p = 1;
    while(h % (p * 2) == 0) p *= 2;
    return p;
}

ll dfs(int v, ll h){
    if(!nodes[v].dead){
        return grundy(h);
    }
    if(nodes[v].c0 == -1){
        return 0;
    }
    ll ret = 0;
    ret ^= dfs(nodes[v].c0, h - 1);
    ret ^= dfs(nodes[v].c1, h - 1);
    return ret;
}

int main(){
    ll N, L;
    cin >> N >> L;

    nodes.emplace_back(0);
    for(int i=0;i<N;i++){
        cin >> s;
        grow_tree(0, 0);
    }

    if(dfs(0, L + 1)) cout << "Alice" << endl;
    else cout << "Bob" << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> ws(n);
  rep(i,n) cin >> ws[i];
  int ans = 1e9;
  for (int t = 1; t < n; t++) {
    int l = 0, r = 0;
    for (int j = 0; j < t; j++) l += ws[j];
    for (int j = t; j < n; j++) r += ws[j];
    ans = min(ans, abs(l-r));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;
int a[N][N];
void floyd(int n)
{
	for (int i = 1; i <= n; i++) a[i][i] = 0;
	for (int k = 1; k <= n; k++)
	{
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n; j++)
			{
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
			}
		}
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	vector<tuple<int, int, int>> vp;
	MEM(a, 0x3f);
	while (m--)
	{
		int x, y, w;
		cin >> x >> y >> w;
		vp.emplace_back(x, y, w);
		a[x][y] = a[y][x] = w;
	}
	floyd(n);
	int ans = vp.size();
	for (auto& p : vp)
	{
		int x, y, w;
		tie(x, y, w) = p;
		int flag = 0;
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n; j++)
			{
				if (a[i][j] == a[i][x] + w + a[y][j])
				{
					flag = 1;
					break;
				}
			}
			if (flag) break;
		}
		ans -= flag;
	}
	cout << ans << endl;
	return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string s1, s2, s3; cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[1] << s3[2] << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A)
{
    ll odd = 0;
    for (int i = 0; i < N; i++)
    {
        if (A[i] % 2 != 0)
            odd++;
    }
    if(odd%2!=0){
        cout << NO << endl;
    }else{
        cout << YES << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <deque>
#include <cstdlib>

using namespace std;
typedef long long int lli;

int main()
{
    // Input numbers
    int n;
    cin >> n;

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

    int min_cost[n];

    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            min_cost[i] = 0;
        } else if (i == 1) {
            min_cost[i] = abs(a[0] - a[1]);
        } else {
            min_cost[i] = min(abs(a[i] - a[i-1]) + min_cost[i-1], abs(a[i] - a[i-2]) + min_cost[i-2]);
        }
    }

    cout << min_cost[n-1] << endl;
    return 0;
}

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

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

using namespace std;

char s[13];

int main(){
	scanf("%s", s);
	rep(i, 12){
		if(i == 4){
			putchar(' ');
		}
		putchar(s[i]);
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
ll const MOD=1000000007;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin>>N>>M;
    ll x,y,z;
    vector<vector<ll>>value(8);
    for(ll i=0;i<N;i++){
        cin>>x>>y>>z;
        value[0].pb(x+y+z);
        value[1].pb(-x+y+z);
        value[2].pb(x-y+z);
        value[3].pb(-x-y+z);
        value[4].pb(x+y-z);
        value[5].pb(-x+y-z);
        value[6].pb(x-y-z);
        value[7].pb(-x-y-z);
    }
    for(ll i=0;i<8;i++){
        sort(ALL(value[i]),greater<ll>());
    }
    ll sum[8]{};
    for(ll i=0;i<M;i++){
        REP(j,8)sum[j]+=value[j][i];
    }
    ll sub=0;
    REP(i,8)sub=max(sub,sum[i]);
    cout<<sub<<endl;
}

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

using namespace std;
const int N = 1e6+100; 
struct node{
	long long t,d;
}s[N];
bool cmp(node a,node b){
	if(a.d==b.d) return a.t<b.t;
	return a.d<b.d;
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i].t>>s[i].d;
	sort(s+1,s+n+1,cmp);
	int now=0;
	for(int i=1;i<=n;i++){
		if(now+s[i].t>s[i].d){
			cout<<"No"<<endl;return 0;
		}
		now+=s[i].t;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

int main()
{
  char s[10001];
  int ret, N;
  int ptr, i;

  ret = scanf("%d", &N);
  ret = scanf("%s", s);

  if ( N == 26 )
    N = 0;
  for ( i=0; i<strlen(s); i++ ) {
    ptr = (int)(s[i] - 'A');
    ptr += N;
    if ( ptr > 25 )
      ptr -= 26;
    s[i] = (char)ptr + 'A';
  }
  printf("%s\n", s);
}


Measured memory_bytes: 128
fun main(args: Array<String>) = ABC166B.main()

object ABC166B {
    fun log(message: Any?) {
        println(message)// TODO: ←消す
    }

    fun main() {
        val (N, K) = readInts()
        val a = (1..K).map {
            val d = readInt()
            val A = readInts()
            d to A
        }
        val d = a.map { it.first }
        val A = a.map { it.second } //  [K,d]

        // いたずらを受ける=true
        val childs = (1..N).map { true }.toMutableList()
        A.forEach {
            it.forEach {
                childs[it-1] = false
            }
        }

        val ans = childs.filter { it }.size
        println(ans)
    }


    /*####################################################################################*/

    fun readString() = readLine()!!
    fun readStrings() = readLine()!!.split(" ")
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
    fun readLong() = readLine()!!.toLong()
    fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
    fun readMatrixRows(height: Int) = (1..height).map { readLine()!!.toList() }

    fun Boolean.yesOrNo() = if (this) "Yes" else "No"
    fun Double.toNaturalExpr() = println("%f".format(this))
}

Measured memory_bytes: 39412
var
 t,n,i,j,s:longint;
 a:array[0..1001] of longint;
begin
 readln(n);
 for i:=1 to 2*n do
  read(a[i]);
 for i:=1 to 2*n-1 do
  for j:=i+1 to 2*n do
   if a[i]<a[j] then begin
    t:=a[i]; a[i]:=a[j]; a[j]:=t; end;
 j:=1;
 for i:=1 to n do
  begin
   s:=s+a[j+1];
   j:=j+2;
  end;
 write(s);
end.

Measured memory_bytes: 128
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define INF 1050000000;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main() //input->compute->output
{
        int N, K;
        cin >> N >> K;
        vector<int> h(N);
        rep(i, N)
        {
                cin >> h[i];
        }

        int dp[100000 + 100];
        rep(i, 100100)
        {
                dp[i] = INF;
        }
        dp[0] = 0;
        rep2(i, 1, N)
        {
                rep2(j, 1, K + 1)
                {
                        if (i - j >= 0)
                        {
                                dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
                        }
                }
        }

        cout << dp[N - 1] << endl;
        return 0;
}

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

int main() {
    long long int n, ans = 0;
    cin >> n;
    vector<long long int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < 1145141919810; i++){
        int t = 0;
        for(int j = 0; j < n; j++){
            if(a[j] % 2 == 0){
                t++;
                a[j] /= 2;            
            }
        }
        if(t == 0){
            cout << ans << endl;
            return 0;
        }
        ans += t;
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	int a,b;
	char op;
	
	while (op != '?') {
		scanf("%d %c %d",&a,&op,&b);
		if (op == '+') {
			printf("%d\n",a+b);
		} else if (op == '-') {
			printf("%d\n",a-b);
		} else if (op == '*') {
			printf("%d\n",a*b);
		} else if (op == '/') {
			printf("%d\n",a/b);
		} else if (op == '?') break;
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    if(abs(a-c)<=d){
        cout<<"Yes"<<endl;
        return 0;
    }
    
    if((abs(a-b)<=d)&&(abs(b-c)<=d)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256