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

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

    int n,k,d,aux;

    cin >> n >> k;

    vector<int> v(n);

    for (int i=0;i<k;i++){
        cin >> d;
        for (int j=0;j<d;j++){
            cin >> aux;
            v[aux-1]++;
        }
    }

    cout << count (v.begin(), v.end(), 0) << endl;

    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

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

		boolean left_init = false;
		int cur = 0;

		while(true){
			String in = sc.next();


			if("=".equals(in)){
				System.out.println(cur);
				break;
			}else if("+".equals(in)){
				int next = sc.nextInt();

				cur += next;
			}else if("-".equals(in)){
				int next = sc.nextInt();

				cur -= next;
			}else if("*".equals(in)){
				int next = sc.nextInt();

				cur *= next;
			}else if("/".equals(in)){
				int next = sc.nextInt();

				cur /= next;
			}else{
				int input = Integer.parseInt(in);
				if(!left_init){
					cur = input;
					left_init = true;
				}
			}
		}
	}

}



Measured memory_bytes: 26284
n, a, b = map(int,input().split())
if (b-a) % 2 == 0:
    print((b-a) // 2)
else:
    lb = a-1
    ub = n-b
    if lb <= ub:
        loc = a - (2 * lb + 1)
        print((b-loc) // 2)
    else:
        loc = b + (2 * ub + 1)
        print((loc-a) // 2)


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

using namespace std;

signed main() {
    long long n;
    cin >> n;
    long long c[n], dp0[n + 1], dp1[n + 1];
    for (int i = 0; i < n; i++)
        cin >> c[i];
    dp0[0] = dp1[0] = 0;
    dp0[1] = c[0]; dp0[2] = c[0] + c[1]; dp1[1] = 0; dp1[2] = -c[0] - c[1];
    for (int i = 3; i <= n; i++) {
        dp0[i] = max(dp0[i - 1], dp1[i - 1]) + c[i - 1];
        dp1[i] = max(dp0[i - 1] - 2 * c[i - 2], dp1[i - 1] + 2 * c[i - 2]) - c[i - 1];
    }
    cout << max(dp0[n], dp1[n]);
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>
#define len 100000

typedef struct pc{
  char name[11];
  int t;
}p;

p Queue[len];
int head,tail,n;

void enqueue(p);
p dequeue();

int min(int,int);

int main(){
  int i,q;
  p u;
  int elaps = 0,c;

  scanf("%d%d",&n,&q);

  for(i=1; i<=n; i++){
    scanf("%s",Queue[i].name);
    scanf("%d",&Queue[i].t);
  }
  head = 1;
  tail = n+1;

  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0) enqueue(u);
    else printf("%s %d\n",u.name,elaps);
  }

  return 0;
}

void enqueue(p x)
{
  Queue[tail] = x;
  tail = (tail + 1) % len;
}

p dequeue()
{
  p x = Queue[head];
  head = (head + 1) % len;
  return x;
}

int min(int a,int b)
{
  return a < b ? a : b;
}


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

int main() {
    int x,y;
    char cell[60][60];
    bool r=true;
    for(int i=1;i<=2;i++){
        for(int j=1;j<=3;j++){
            cin >> cell[i][j];
        }
    }
    for(int j=1,k=3;j<=3,k>0;j++,k--){
        if(cell[1][j]!=cell[2][k]){
            r=false;
        }
    }
    if(r==false){
        cout << "NO" << endl;
    }else if(r==true){
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 3584
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, M = MI()
A = LMI()

print(max(-1, N - sum(A)))

Measured memory_bytes: 68164
use std::io::{Read, stdin};
use std::str::FromStr;

fn main(){
    let s :String = read();
    let mut rets = String::new();
    for i in s.as_str().chars() {
        if i == 'B' { rets.pop();}
        if i == '0' { rets.push('0');}
        if i == '1' { rets.push('1');}
    }
    println!("{}", rets);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

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

const int maxn = 10e5+10;
int n, mina=maxn, maxa=0, ans;
int countN[maxn];

int main() {
	cin >> n;

	for(int i=0, a; i<n; i++){
		cin >> a;
		mina = min(mina, a);
		maxa = max(maxa, a);
		countN[a]++;
	}

	for(int i=mina; i<=maxa; i++){
		ans = max(ans, countN[i-1] + countN[i] + countN[i+1]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector> 
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	if(n%10==9||n/10==9) printf("Yes\n");
	else printf("No\n");
	return 0;
} 

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AGC012
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = int.Parse(Console.ReadLine());
            long[] a = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();

            long i = 0;
            long l = a.Length - 2;

            long sum = 0;
            while (i < l)
            {
                sum += a[l];
                l = l - 2;
                i++;
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 55692
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

    ll N , M ;
    cin >>  N >> M ;

    vector<ll> food(M);

    rep(i, N){
        ll K ; cin >> K ;
        rep(j, K ){
            ll inp; cin >> inp;
            food[inp-1] ++;
        }
    }
    ll ans = 0;
    rep(i, M){
        if(food[i] == N) ans ++;
    }

    cout << ans << endl;


    //cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_N = 1e6 + 50, INF = 1e15, MOD = 1e9 + 7;
ll N, heights[max_N];
int DP[max_N];

int min_cost(ll pos)
{
    if (pos == N - 1)
        return 0;
    if (pos == N - 2)
        return abs(heights[N - 1] - heights[N - 2]);
    int &res = DP[pos];
    if (res != -1)
        return res;
    int opt1 = abs(heights[pos] - heights[pos + 1]) + min_cost(pos + 1);
    int opt2 = abs(heights[pos] - heights[pos + 2]) + min_cost(pos + 2);
    return res = min(opt1, opt2);
}

int main()
{
    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> heights[i];
    memset(DP, -1, sizeof(DP));
    cout << min_cost(0) << "\n";
    return 0;
}

Measured memory_bytes: 12948
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 998244353;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

class mint {
public:
    long long x;
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    //mint operator-() const{ return mint(-x);}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

};

int main(){
  int N, S; cin >> N >> S;
  vector<int> A(N); rep(i, N) cin >> A[i];

  vector<mint> f(S + 1, 0);
  vector<mint> F(S + 1, 0);
  for (int a: A){
    F[0] += 1;
    vector<mint> next(S + 1, 0);
    rep(i, S + 1){
      next[i] += F[i];
      if (i + a <= S) next[i + a] += F[i];
    }
    swap(next, F);
    rep(i, S + 1){
      f[i] += F[i];
    }
  }
  cout << f[S].x << endl;
}


Measured memory_bytes: 384
#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 << "Left" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
bl=list(map(int,input().split()))
al=[list(map(int,input().split())) for i in range(n)]

count=0
for i in range(n):
  total=0
  temp=al[i]
  for j in range(m):
    total+=temp[j]*bl[j]
  if total+c>0:
    count+=1
print(count)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
  int ticket[4];
  int t,n;

  for(int i=0;i<4;i++){
    scanf("%d %d",&t,&n);
    switch (t) {
      case 1:
        ticket[i]=6000*n;
        break;
      case 2:
        ticket[i]=4000*n;
        break;
      case 3:
        ticket[i]=3000*n;
        break;
      case 4:
        ticket[i]=2000*n;
        break;
      default:
        break;
    }

  }
  for(int i=0;i<4;i++){
    printf("%d\n",ticket[i]);
  }

  return 0;
}



Measured memory_bytes: 2100
import sys

nS = [0 for i in range(3)]
nA = [0 for i in range(3)]
nB = [0 for i in range(3)]
nC = [0 for i in range(3)]

N = 3

nS  = input().rstrip().split(' ')
for i in range(N):
    nA[i] = int(nS[i])

nS  = input().rstrip().split(' ')
for i in range(N):
    nB[i] = int(nS[i])

nS  = input().rstrip().split(' ')
for i in range(N):
    nC[i] = int(nS[i])

Tmp = nC[0]-nA[0]
nTmp = nC[1]-nA[1]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nC[2]-nA[2]
if Tmp != nTmp:
    print('No')
    sys.exit()

Tmp = nB[0]-nA[0]
nTmp = nB[1]-nA[1]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nB[2]-nA[2]
if Tmp != nTmp:
    print('No')
    sys.exit()


Tmp = nA[1]-nA[0]
nTmp = nB[1]-nB[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nC[1]-nC[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

Tmp = nA[2]-nA[0]
nTmp = nB[2]-nB[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

nTmp = nC[2]-nC[0]
if Tmp != nTmp:
    print('No')
    sys.exit()

Tmp = nA[0]+ nC[2]
nTmp = nA[2]+ nC[0]
if Tmp != nTmp:
    print('No')
    sys.exit()
    
print('Yes')


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,X;cin >> N >> X;
    vector<int> L(N);
    rep(i,N)cin >> L[i];
    int res = 1,bound=0;
    for(int i=0;i<N;i++){
        bound+=L[i];
        if(bound<=X)res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int L,R,d,ans = 0;
    cin >> L >> R  >> d;
    for (int i = L; i < R + 1; ++i){
        if ( i % d == 0){
        ++ans;
        }
    } 
    cout << ans << endl;
}

Measured memory_bytes: 3572
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
S = input()

# 初期状態でOKなものを数えておく
is_ok = [0] * N
for i in range(N):
    if S[i] == 'L':
        if i != 0 and S[i-1] == 'L':
            is_ok[i] = 1
    else:
        if i != N-1 and S[i+1] == 'R':
            is_ok[i] = 1

# LかRが連続する区間毎にまとめる
A = []
st = 0
for i in range(1, N):
    if S[i] != S[i-1]:
        A.append((st, i, S[i-1]))
        st = i
A.append((st, N, S[-1]))

# その区間を逆にしたらいくつ増やせるかを格納するLR
LR = {'L': [], 'R': []}
# ずっとLかRだけなら何も増やせない
if len(A) >= 2:
    for st, end, d in A:
        # 先頭と末尾だけは+1
        if st == 0 or end == N:
            LR[d].append(1)
        # 他の場所は+2できる
        else:
            LR[d].append(2)

LR['L'].sort(reverse=True)
LR['R'].sort(reverse=True)
# 大きい値から貪欲にK回変えてみて、Lを変えるとRを変えるの良い方
ans = sum(is_ok) + max(sum(LR['L'][:K]), sum(LR['R'][:K]))
print(ans)


Measured memory_bytes: 16472
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val ab = mutableListOf<Pair<Int, Int>>()
    for (i in 1..m) {
        val (a, b) = readLine()!!.split(' ').map(String::toInt)
        ab.add(Pair(a, b))
    }

    val a = Permutation((2..n).toList().toTypedArray())
    var count = 0
    do {
        val list = a.target!!.toMutableList()
        list.add(0, 1)

        var containFlg = true
        for (i in 1 until n) {
            containFlg = ab.any {
                (list[i - 1] == it.first && list[i] == it.second)
                        || (list[i - 1] == it.second && list[i] == it.first)
            }
            if (!containFlg) break
        }
        if (containFlg) count++
    } while (a.next())

    println(count)
}

class Permutation<T> private constructor(private val baseIndex: Int, private var index: Int, val target: Array<T>?) {
    private var subPermutation: Permutation<T>? = null

    constructor(objs: Array<T>) : this(0, 0, objs.clone())

    init {
        if (target == null || target.isEmpty()) {
            throw IllegalArgumentException()
        }

        if (this.index < this.target.size - 1) {
            this.subPermutation = Permutation(this.baseIndex + 1, this.index + 1, this.target)
        }
    }

    operator fun next(): Boolean {
        if (this.subPermutation == null) {
            return false
        }
        val result = this.subPermutation!!.next()
        if (result) {
            return true
        }
        this.swap(this.baseIndex, this.index)
        ++this.index
        if (this.target!!.size <= this.index) {
            this.index = this.baseIndex
            return false
        }
        this.swap(this.index, this.baseIndex)
        return true
    }

    private fun swap(index1: Int, index2: Int) {
        val tmp = this.target!![index1]
        this.target[index1] = this.target[index2]
        this.target[index2] = tmp
    }
}

Measured memory_bytes: 41460
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long 
#define pb push_back
#define fo(i,N) for(int i = 0 ; i < N ; i++)
#define foo(i,x,N) for (int i = x; i < N ; i++)
#define fill(a,val) memset(a,val,sizeof(a))
#define fastio()  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define MAX 1234567
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define inf 1e9+1
#define all(a) a.begin(),a.end()


vector <int> p(3001);
int n,k;
ll dp[3001][3001];

ll solve(int i,int j)
{
   if ( i > j )
    return 0;

   if (dp[i][j] != -1)
    return dp[i][j];

   ll op1 = p[i] + min(solve(i+2,j),solve(i+1,j-1));
   ll op2 = p[j] + min(solve(i,j-2),solve(i+1,j-1));

   return dp[i][j] = max(op1,op2);
 



}

int main()
{  
   cin >> n;
   ll tot = 0;
   fo(i,n)
   { 
    cin >> p[i];
    tot += p[i];
   }
  fill(dp,-1);


  cout << 1ll*2*solve(0,n-1)-tot << endl;
  
}



Measured memory_bytes: 70784
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n;
  std::vector<std::array<long, 2>> xs;
  Solver() {
    S002 r;
    r >= n >n>= xs;
  }
  void solve() {
    long x = xs[0][0], y = xs[0][1];
    for(long i = 1; i < n; ++i) {
      x = (x + (xs[i][0] - 1)) / xs[i][0] * xs[i][0];
      y = (y + (xs[i][1] - 1)) / xs[i][1] * xs[i][1];
      long x2 = std::max(x, y / xs[i][1] * xs[i][0]);
      long y2 = std::max(y, x / xs[i][0] * xs[i][1]);
      x = x2;
      y = y2;
    }
    printf("%ld\n", x + y);
    
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
l=[]
for i in range(int(input())):
    s=input()
    l.append(s)
a=l.count('AC')
b=l.count('WA')
c=l.count('TLE')
d=l.count('RE')
print('AC','x',a)
print('WA','x',b)
print('TLE','x',c)
print('RE','x',d)


Measured memory_bytes: 16148
dp = [[0] * 1100 for u in xrange(10)]
dp[0][0] = 1
for i in xrange(101):
    for ii in xrange(9,0,-1):
        for iii in xrange(i,1000):
            dp[ii][iii] += dp[ii-1][iii-i]
while True:
    n,s = map(int,raw_input().split())
    if (n,s) == (0,0):
        break
    print dp[n][s]

Measured memory_bytes: 4328
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll a, b, c, d; cin >> a >> b >> c >> d;

    ll ans = -INF;

    ans = max(ans, min(a,b)*min(c,d));
    ans = max(ans, min(a,b)*max(c,d));
    ans = max(ans, max(a,b)*min(c,d));
    ans = max(ans, max(a,b)*max(c,d));

    cout << ans << endl;
}

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

typedef long double ld;

ld memo[3000][3000];
bool vis[3000][3000];
ld p[3000];
int tot;

ld COINS(int n, int h)
{
	if(!n)
	{
		if(tot > 2*h)
		return 0;
		else return 1;	
	}
	if(vis[n][h])
	return memo[n][h];
	ld ans = 0;
	ans = (p[n] * COINS(n-1, h+1)) + ((1 - p[n]) * COINS(n-1, h));
	vis[n][h] = 1;
	memo[n][h] = ans;
	return ans;	
}

int main(void)
{
	memset(vis, 0, sizeof(vis));
	int n;
	scanf("%d", &n);
	tot = n;
	for(int i=1;i<=n;i++)
	scanf("%Lf", &p[i]);
	ld ans = COINS(n, 0);	
	printf("%.15Lf\n", ans);
	return 0;
}

Measured memory_bytes: 148096
S = list(input())
N = len(S)
count=0
count_10=0
count_00=0
num=0
if (N%2)!=0:
    NS=N-1
    a=1
else:
    NS =N
    a=0
    
count=0
for i in range(0,NS,2):
    num=int(S[i]+S[i+1])
    if num==10:
        count=count+1
        #print(num)
    elif num==1:
        count_10=count_10 + 1
        #print(num)
    else:
        count_00=count_00+1

count=min(count,count_10)
count=count*2
count=count+count_00
if a==1:
   if S[0]!=S[N-1]:
       count=count+1

print(count)


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int sum(int input) {
    int sum = 0;
    for (char &c : to_string(input)) {
        sum += int(c) - 48;
    }
    return sum;
}

int main() {
    int n;
    cin >> n;
    int ans = 45;
    for (int a = 1; a < n; a++) {
        int b = n - a;
        int current = sum(a) + sum(b);
        ans = current < ans ? current : ans;
    }
    cout << ans;
    return 0;
}



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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)
#define	INF (1<<29)
//536870912

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	if (1==N) {
		cout <<1 <<endl;
		return 0;
	}
	vector<vector<int>> p(N, vector<int> (2, 0));
	for (int i=0; i<N; i++)
		cin >>p.at(i).at(0) >>p.at(i).at(1);
	sort(p.begin(), p.end());
	vector<vector<int>> d;
	for (int i=0; i<N-1; i++)
		for (int j=i+1; j<N; j++)
			d.push_back({p.at(j).at(0)-p.at(i).at(0), p.at(j).at(1)-p.at(i).at(1)});
	sort(d.begin(), d.end());
	int S=1;
	int SS=1;
	for (int i=1; i<d.size(); i++) {
		if (d.at(i)==d.at(i-1)) {
			SS++;
			S=max(S, SS);
		} else
			SS=1;
	}
	cout <<N-S <<endl;
	return 0;
}



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


int main() {
    int N,K;
    cin>>N>>K;
    int a[N];
    vector<int>data(N,-100);
    int count=0;
    rep(i,N){
        cin>>a[i];
        if(data[a[i]-1]==-100){
            data[a[i]-1]=1;
            count++;
        }
        else data[a[i]-1]++;
    }
    if(count<=K){
        cout<<0<<endl;
        return 0;
    }

    sort(data.begin(),data.end());
    reverse(data.begin(),data.end());
    int sum=0;
    for(int i=0;i<K;i++){
        sum += data[i];
    }
    cout << N-sum <<endl;
} 

Measured memory_bytes: 1792
#include <iostream>
#include <complex>

using namespace std;

typedef complex<double> P;

#define  EPS (1e-11)
#define  EQ(a, b)  (abs((a) - (b)) < EPS)
#define  EQV(a, b)  (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))

double cross(P a, P b) 
{
    return (a.real() * b.imag() - a.imag() * b.real());
}

int main()
{
    double x1, y1, x2, y2, x3, y3, xp, yp;

    while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
        P a = P(x1, y1);
        P b = P(x2, y2);
        P c = P(x3, y3);
        P x = P(xp, yp);

        if ((cross(b - a, x - a) > EPS &&
             cross(c - b, x - b) > EPS &&
             cross(a - c, x - c) > EPS) ||
            (cross(b - a, x - a) < -EPS &&
             cross(c - b, x - b) < -EPS &&
             cross(a - c, x - c) < -EPS))
            cout << "YES\n";
        else
            cout << "NO\n";
    }

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main()
{
    int c[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    int b[3] = {c[0][0], c[0][1], c[0][2]};
    int a[3] = {0, c[1][0] - b[0], c[2][0] - b[0]};
    for (int i = 1; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (a[i] + b[j] != c[i][j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

int main(){

    int N,K,Y,X,sum=0;
    cin >> N >> K >> X >> Y;

    if(N<=K) sum = X*N;
    else sum = X*K + Y *(N-K);

    cout << sum << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int64_t> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  vector<int> idx(N);
  iota(idx.begin(), idx.end(), 0);

  auto comp= [&](int i, int j){
    return data.at(i) > data.at(j);
  };
  sort(idx.begin(), idx.end(), comp);

  vector<int64_t> dp(N+1);
  vector<int64_t> buf(N+1);
  for(int n_perm=1; n_perm<= N; n_perm++){
    int i0= idx.at(n_perm-1);
    int64_t a0= data.at(i0);
    for(int n_left=0; n_left <= n_perm; n_left++){
      int n_right= n_perm- n_left;
      int i_left = n_left- 1;
      int i_right= N- n_right;

      buf.at(n_left)= (n_left ==0) ? dp.at(n_left)+ a0* abs(i_right- i0)
                     :(n_right==0) ? dp.at(n_left- 1)+ a0* abs(i_left- i0)
                                   : max(dp.at(n_left)+ a0* abs(i_right- i0), dp.at(n_left- 1)+ a0* abs(i_left- i0));
    }

    dp= buf;
  }

  int64_t ans= 0;
  for(auto elem:dp){
    ans= max(ans, elem);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3676
#include <iostream>

#define ll long long

const ll int lim = 1e9 + 7;
int H, N, tmp, a[1000], b[1000], out[10001];
 
void solve() {
    std::cin >> H >> N;
    for (int i=0; i<N; ++i)
        std::cin >> a[i] >> b[i];
    for (int i=0; i<10001; ++i)
        out[i] = lim*2;
    out[0] = 0;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<H; ++j) {
            tmp = std::min(H, j + a[i]);
            if (out[tmp] > (out[j] + b[i]))
                out[tmp] = out[j] + b[i];
        }
    }
    std::cout << out[H] << std::endl;
}
 
int main() {
    std::ios_base::sync_with_stdio(0);
    solve();
    return 0;
}


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

int main() {
  int n,ans;
  bool flag;
  long long cnt=0;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  if (v[0] == 1) cout << "-1" << endl;
  else {
    ans = v[0];
    while (true) {
      cnt++;
      if (ans == 2) {
        cout << cnt << endl;
        break;
      }
      else if (cnt > 100000) {
       cout << "-1" << endl;
        break;
      }
      else {
        ans = v[ans-1];
      }
    }
  }
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    string original = s;
    reverse(s.begin(), s.end());
    int needToBeChanged = 0;
    for (int i = 0; i < s.size() / 2; i++)
    {
        if (original[i] != s[i]) {
            needToBeChanged++;
        }
    }

    cout << needToBeChanged << endl;
    return 0;
}



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 FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;






int main() {

	string s;
	cin >> s;
	int a = 15 - s.size();
	REP(i, s.size()) {
		if (s[i] == 'o')a++;
	}

	if (a > 7) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

	
}

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

long long f(long long n){
    long long res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

double g(long long n){
    return (double)(n)/f(n);
}

int main(){
    vector<long long> res;
    long long base = 1;

    //候補を全列挙
    for(int i=0; i<15; ++i){
        for(int j=1; j<150; ++j){
            res.push_back(base * (j+1) -1);
        }
        base *= 10;
    }

    sort(res.begin(), res.end());
    // unique(res.begin(), res.end())は被っているやつの最初のポインタを返すので、結局被っているやつを全てeraseする
    res.erase(unique(res.begin(), res.end()), res.end());

    for(long long i=0; i < res.size(); ++i){
        for(long long j=i+1; j < res.size(); ++j){
            if(g(res[i]) > g(res[j])){
                res.erase(res.begin() + i--);
                break;
            }
        }
    }

    long long K;
    cin >> K;
    for(long long i=0; i<K; ++i){
        cout << res[i] << endl;
    }
}


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


int main()
{
    string s, t;
    int n;
    cin >> n;
    cin >> s >> t;

    string ans;

    for (int i = 0; i < n; i++)
    {
        ans += s[i];
        ans += t[i];
    
    }
    

    cout << ans << endl;

    return 0;
    
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  map<int, int> m;
  for (int i = 0; i < N; ++i) {
    int a; scanf("%d", &a);
    ++m[a];
  }
  int ans = 0, kinds = m.size();
  if (kinds > K) {
    vector<pair<int, int>> v;
    for (map<int, int>::iterator iter = m.begin(); iter != m.end(); ++iter) {
      // (freq, number)
      v.push_back(make_pair(iter->second, iter->first));
    }
    sort(v.begin(), v.end());
    int diff = v.size() - K;
    for (int i = 0; i < diff; ++i) {
      ans += v[i].first;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 11768
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;
import java.util.Map;
import java.util.HashMap;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int count;
		int max = 0;
		for(int i=0; i<N-1; i++){
			ArrayList<Character> list = new ArrayList<Character>();
			count = 0;
			for(int j=0; j<=i; j++){
				for(int k=i+1; k<N; k++){
					if(S.charAt(j)==S.charAt(k)){
						if(list.contains(S.charAt(j))){
							break;
						}else{
							list.add(S.charAt(j));
							count ++;
						}
					}
				}
			}
			max = Math.max(max,count);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 23764
import java.util.Scanner;

/**
 * 木の巡回
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_C&lang=ja">ALDS1_7_C</a>
 */
public class Main {

	private static int sibling[] = new int[100005];
	private static int degree[] = new int[100005];
	private static int depth[] = new int[100005];
	private static int height[] = new int[100005];
	private static Node t[] = new Node[100005];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		for (int i = 0; i < n; i++) {
			t[i] = new Node();
		}

		for (int i = 0; i < n; i++) {
			int id = sc.nextInt();
			t[id].left = sc.nextInt();
			t[id].right = sc.nextInt();
			if (t[id].left != -1) {
				t[t[id].left].parent = id;
			}
			if (t[id].right != -1) {
				t[t[id].right].parent = id;
			}
		}

		int root = 0;
		for (int i = 0; i < n; i++) {
			if (t[i].parent == -1) root = i;
		}

		System.out.println("Preorder");
		preParse(root);
		System.out.println();
		System.out.println("Inorder");
		inParse(root);
		System.out.println();
		System.out.println("Postorder");
		postParse(root);
		System.out.println();


		sc.close();
	}

	private static void preParse(int u) {
		if (u == -1) return;
		System.out.print(" " + u);
		preParse(t[u].left);
		preParse(t[u].right);
	}

	private static void inParse(int u) {
		if (u == -1) return;
		inParse(t[u].left);
		System.out.print(" " + u);
		inParse(t[u].right);
	}

	private static void postParse(int u) {
		if (u == -1) return;
		postParse(t[u].left);
		postParse(t[u].right);
		System.out.print(" " + u);
	}

}

class Node {
	int parent;
	int left;
	int right;

	Node() {
		this.parent = -1;
		this.left = -1;
		this.right = -1;
	}
}


Measured memory_bytes: 28260
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String S = sc.nextLine();
    int s = S.length();
    int ans = 0;
    a : for(int i = 0; i < 10; i++){
      int a = 0;
      while(S.charAt(a) != '0'+i){
        a++;
        if(a >= s){
          continue a;
        }
      }
      b : for(int j = 0; j < 10; j++){
        int b = a+1;
        if(b >= s){
            continue a;
          }
        while(S.charAt(b) != '0'+j){
          b++;
          if(b >= s){
            continue b;
          }
        }
        c : for(int k = 0; k < 10; k++){
          int c = b+1;
          if(c >= s){
            continue b;
          }
          while(S.charAt(c) != '0'+k){
          c++;
            if(c >= s){
              continue c;
            }
          }
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 24544
import math

a , b , x = map(int,input().split())

if b >= 2 * (b - (x / (a * a))):
    print(math.degrees(math.atan((2 * (b - (x / (a * a)))) / a)))
else:
    print(math.degrees(math.atan((a * b * b) / (2 * x))))

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n >> s;
	vector<int> ABC;
	int max = 0;
	for (int i = 1; i <= n - 1; ++i) {
		ABC = vector<int>(26, 0);
		string a = s.substr(0, i);
		string b = s.substr(i);
		for (auto itr = a.begin(); itr != a.end(); ++itr) {
			if (ABC[*itr - 'a'] == 0) {
				for (auto jtr = b.begin(); jtr != b.end(); ++jtr) {
					if (*itr == *jtr) {
						ABC[*itr - 'a'] = 1;
						break;
					}
				}
			}
		}
		int counter = 0;
		for (int j = 0; j < 26; ++j) {
			if (ABC[j])counter++;
		}
		if (max < counter) max = counter;
	}
	cout << max;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    string S;
    cin >> S;
    ll w;
    cin >> w;
    for (int i = 0; i < S.size(); i += w) {
        cout << S[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mid ((s + e) / 2)
#define makefast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define comp(x, y) (lower_bound(vec.begin(), vec.end(), make_pair(x, y)) - vec.begin())
#define lc (v * 2)
#define rc (v * 2 + 1)
long long M = 1e9 + 7;
//>>>>>>>>>>>>>>>>>>>

#define int long long

const int N = 1e5 + 7;

int a[N];

int32_t main() {
	makefast;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	if (n == 1) {
		cout << "Second";
		return 0;
	}
	int t = 1;
	while (1) {
		int odd = 0, eve = 0, one = 0;
		for (int i = 1; i <= n; i++) {
			if (a[i] % 2)
				odd++;
			else
				eve++;
			if (a[i] == 1)
				one = 1;
		}
		if (one) {
			if ((odd % 2 != n % 2 && t == 1) || (odd % 2 == n % 2 && t == 2))
			   cout << "First";
			else
			cout << "Second";
		return 0;	
		}
		if (odd % 2 != n % 2) {
			if (t == 1)
				cout << "First";
			else
				cout << "Second";
			return 0;
		}
		if (odd != 1) {
			if (t == 2)
				cout << "First";
			else
				cout << "Second";
			return 0;
		}
		for (int i = 1; i <= n; i++)
			if (a[i] % 2)
				a[i]--;
		int g = a[1];
		for (int i = 2; i <= n; i++)
			g = __gcd(a[i], g);
		for (int i = 1; i <= n; i++) {
			a[i] /= g;
		}
		t = 3 - t;
	}

}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) V vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin>>n;
  VP adj[n];
  rep(i,n-1){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    adj[a].p_p(b,c);
    adj[b].p_p(a,c);
  }

  queue<ll> que;
  Vec<bool> ans(n,true);
  Vec<bool> visited(n,false);
  ans[0]=false;
  visited[0]=true;
  for(auto&ver:adj[0]){
    que.push(ver.fi);
    if(ver.se%2==0)ans[ver.fi]=false;
    else ans[ver.fi]=!ans[0];
  }

  while(!que.empty()){
    ll now=que.front(); que.pop();
    visited[now]=true;
    for(auto&ver:adj[now]){
      if(visited[ver.fi])continue;
      que.push(ver.fi);
      if(ver.se%2==0)ans[ver.fi]=ans[now];
      else ans[ver.fi]=!ans[now];
    }
  }
  rep(i,n)cout<<ans[i]<<"\n";
  
  
  return 0;
}



Measured memory_bytes: 7936
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0] == '9' || s[1] == '9'){
        print("Yes");
    }else{
        print("No");
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        int sum = a + b;
        int sumsum = a + c;
        int sumsumsum = b + c;

        if(sum <= sumsum && sum <= sumsumsum){
            System.out.println(sum);   
        }else if(sumsum <= sum && sumsum <= sumsumsum){
            System.out.println(sumsum);
        }else if(sumsumsum <= sum && sumsumsum <= sumsum){ 
            System.out.println(sumsumsum);
        }


    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {

    ll N;
    cin >> N;

    ll a, b;
    vector<pair<ll, ll>> p(1e5+9);
    vector<ll> node(1e5+9);
    vector<vector<ll>> v(1e5+9);
    for (int i = 0; i < N-1; i++) {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
        node[a]++;
        node[b]++;
        p[i] = make_pair(a, b);
    }

    ll root;
    ll K;
    vector<ll>::iterator itr = max_element(node.begin(), node.end());
    root = distance(node.begin(), itr);
    K = *itr;

    map<pair<ll, ll>, ll> color;
    ll c;
    ll n;
    queue<ll> q;
    set<ll> s;
    set<ll> visit;
    q.push(root);
    while(!q.empty()) {
        n = q.front();
        q.pop();
        c = 1;
        visit.insert(n);
        s.clear();
        for (ll i : v[n]) {
            if (visit.find(i) != visit.end()) {
                s.insert(color[make_pair(n, i)]);
                s.insert(color[make_pair(i, n)]);
            }
        }
        for (ll i : v[n]) {
            if (visit.find(i) != visit.end()) continue;
            if (s.find(c) != s.end()) c++;
            s.insert(c);
            color[make_pair(n, i)] = c;
            color[make_pair(i, n)] = c;
            c++;
            q.push(i);
        }
    }

    cout << K << endl;
    for (int i = 0; i < N-1; i++) {
        cout << color[p[i]] << endl;
    }


    return 0;
}


Measured memory_bytes: 26112
n,k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
(n-k).times do |i|
  if a[k+i].to_f / a[i].to_f  > 1.0
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 35900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> p;
    rep(i, 0, n) {
        ll a, b;
        cin >> a >> b;
        p.emplace_back(a, b);
    }
    sort(p.begin(), p.end());
    ll cnt = 0;
    rep(i, 0, n) {
        cnt += p[i].second;
        if (cnt >= k) {
            cout << p[i].first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 2420
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#define MN 500
#define pa pair<int,int>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,a[MN*MN+5];
priority_queue<pa,vector<pa>,greater<pa> >q;
int main()
{
    n=read();
    for(int i=1;i<=n;++i)
    {
        int p=read();a[p]=i;
        if(p<i) return 0*puts("No");
        for(int j=1;j<i;++j) q.push(make_pair(p-j,i));
    }
    for(int i=1;i<=n*n;++i)
    {
        if(q.size()&&q.top().first<i) return 0*puts("No");
        if(a[i])
        {
            for(int j=a[i]+1;j<=n;++j) q.push(make_pair(n*n,a[i]));
            continue;
        }
        if(!q.size()) return 0*puts("No");
        a[i]=q.top().second,q.pop();
    }
    puts("Yes");
    for(int i=1;i<=n*n;++i) printf("%d ",a[i]);
    return 0;
}


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

    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i] -1;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256