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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  string s;
  cin >> s;

  bool flag = true;
  if(s[0] != 'A') flag = false;
  int cnt = 0, cnt2 = 0;
  FOR(i, 2, s.size() - 1) {
    if(s[i] == 'C') cnt++;
    if(islower(s[i])) cnt2++;
  }
  if(cnt != 1 || cnt + cnt2 != s.size()-3) flag = false;
  if(!islower(s[1]) || !islower(s[s.size()-1])) flag = false;

  if(flag) cout << "AC" << endl;
  else cout << "WA" << endl;

  return 0;
}


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

typedef long long ll;
#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, m; cin >> n >> m;
	int tot = 0;
	for (int i = 0; i < m; ++i) {
		int a; cin >> a;
		tot += a;
	}
	if (tot > n) cout << -1;
	else cout << n - tot;
}


Measured memory_bytes: 3656
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <queue>


#define INF 2000000000
#define MOD 1000000007

using namespace std;

int main() {
	long long q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	h = min(h, 2 * q);
	s = min(s, 2 * h);
	d = min(d, 2 * s);
	cout << n / 2 * d + (n % 2) * s << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        String s = stdIn.next();
        char c[] = s.toCharArray();
        String t = stdIn.next();
        char d[] = t.toCharArray();
        int count = 0;
        
        for(int i = 0; i < 3; i++){
            if(c[i] == d[i]){
                count++;
            }
        }
        
        System.out.println(count);
    }
}


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

using namespace std;

int main()
{
    string S;
    cin >> S;
    int price = 700;
    for (const char ch : S)
    {
        if (ch == 'o')
        {
            price += 100;
        }
    }
    cout << price << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    int res = n * (n - 1) / 2 + m * (m - 1) / 2;
    cout << res << endl;

    return 0;
}

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

int A[15][15];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) A[i][j] = -1;
    }
    int a, x, y;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        for (int j = 0; j < a; ++j) {
            cin >> x >> y;
            A[i][x-1] = y;
        }
    }

    int ans = 0;
    for (int i = (1<<n)-1; i >= 0; --i) {
        bool flg = true;
        int s = 0;
        for (int j = 0; j < n; ++j) {
            if (!(i>>j&1)) continue;
            s++;
            for (int k = 0; k < n; ++k) {
                if (A[j][k]==1 && !(i>>k&1)) flg = false;
                else if (A[j][k]==0 && i>>k&1) flg = false;
            }
        }
        if (flg) {
            ans = max(ans, s);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

class Bridge:
    def __init__(self, nodeA, nodeB):
        self.edges = [BridgeEdge(nodeA), BridgeEdge(nodeB)]

class BridgeEdge:
    def __init__(self, node):
        self.node = node
        self.judge = 0

class Node:
    def __init__(self, id):
        self.id = id
        self.bridges = []
    def addEdge(self, bridgeEdge):
        self.bridges.append(bridgeEdge)


nodes = [Node(i) for i in range(N+1)]
bridges = []
for A, B in (map(int, input().split()) for _ in range(M)):
    b = Bridge(nodes[A], nodes[B])
    nodes[A].addEdge(b.edges[1])
    nodes[B].addEdge(b.edges[0])
    bridges.append(b)


s = [(None, nodes[1])]
idx = 0
while idx < len(s):
    pre, cur = s[idx]
    idx += 1

    for nxt in cur.bridges:
        if not pre is nxt.node and nxt.judge < 2:
            nxt.judge += 1
            s.append((cur, nxt.node))

cnt = 0
for bd in bridges:
    if sum(1 for b in bd.edges if b.judge <= 1) > 0:
        cnt += 1

print(cnt)


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

const int modulo=1000000000+7;

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

	vector<int> pattern(s+1);
	pattern[1]=0;
	pattern[2]=0;
	pattern[3]=1;
	pattern[4]=1;
	pattern[5]=1;

	uint64_t sum=1;
	for (int i=6;i<=s;++i)
	{
		sum+=pattern[i-3];
		sum%=modulo;
		pattern[i]=sum;
	}

	cout << pattern[s] << endl;
}





Measured memory_bytes: 3624
#include <stdio.h>

int main(){
	int a[100]={};
	int n;
	int i;
	while(scanf("%d", &n)!=EOF)
	{
		a[n]++;
	}
	int MAX=0;
	for(i=0;i<100;i++)
	{
		if(MAX<a[i])
		{
			MAX=a[i];
		}
	}
	for(i=0;i<100;i++)
	{
		if(a[i]==MAX)
		{
			printf("%d\n", i);
		}
	}
	return 0;
}

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

#define P 1000000007

long p(long a, long x){
	if(x==1){
		return a;
	}else if(x%2==0){
		long b = p(a, x/2);
		return (b*b)%P;
	}else{
		long b = p(a, x/2);
		return (((b*b)%P)*a)%P;
	}
}

long m(long a){
	return p(a, P-2);
}

long g(long a){
	long b=1;
	while(a>0){
		b = b*(a--)%P;
	}
	return b;
}

int main(void){
	int x, y, i, j;
	scanf("%d%d", &x, &y);
	if((x+y)%3!=0){
		puts("0");
	}else{
		int a = (x+y)/3;
		int b = (a+x-y)/2;
		int c = (a+y-x)/2;
		if(b<0 || c<0){
			puts("0");
		}else{
			printf("%d\n", g(a)*m(g(b))%P*m(g(c))%P);
		}
	}
}


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

// int n; cin >> n;
// cout << n << endl;
int main() {
  int n; cin >> n;
  int m; cin >> m;
  if (n==m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

//がんばってputintつくるかぁ
const int MAX = 10000;
const int dm = 1 << 17;
char dn[dm], * di = dn, * owad = dn + dm - 20;
class shuturyoku_unko {
public:
	char C[MAX * 4];
	shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 4) {
				C[i * 4 + 3 - j] = '0' + X % 10;
				X /= 10;
			}
		}
	}
	void putint(ll A) {
		if (owad < di) {
			fwrite(dn, 1, di - dn, stdout);
			di = dn;
		}
		int dig = 1;
		if (A >= 100000000) {
			if (A >= 10000000000) dig = 3;
			else if (A >= 1000000000) dig = 2;
			memcpy(di + 4 + dig, C + A % 10000 * 4, 4);
			A /= 10000;
			memcpy(di + dig, C + A % 10000 * 4, 4);
			A /= 10000;
			memcpy(di, C + A * 4 + 4 - dig, dig);
			di += 8 + dig;
		}
		else if (A >= 10000) {
			if (A >= 10000000) dig = 4;
			else if (A >= 1000000) dig = 3;
			else if (A >= 100000) dig = 2;
			memcpy(di + dig, C + A % 10000 * 4, 4);
			A /= 10000;
			memcpy(di, C + A * 4 + 4 - dig, dig);
			di += 4 + dig;
		}
		else {
			if (A >= 1000) dig = 4;
			else if (A >= 100) dig = 3;
			else if (A >= 10) dig = 2;
			memcpy(di, C + A * 4 + 4 - dig, dig);
			di += dig;
		}
		*di++ = '\n';
	}
} f;



int A[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	ll kotae = 0;
	rep(i, N) {
		int kari = getint();
		A[kari]++;
		kotae += kari;
	}

	int Q = getint();
	rep(i, Q) {
		int b = getint();
		int c = getint();

		A[c] += A[b];
		kotae += A[b] * ll(c - b);
		A[b] = 0;

		f.putint(kotae);
	}


	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> P(N),Q(N),R(N);
  for(int i=0;i<N;i++)
    cin>>P[i];
  for(int i=0;i<N;i++)
    cin>>Q[i];
  for(int i=0;i<N;i++)
    R[i]=i+1;
  int p,q,i=0;
  do{
    if(R==P)
      p=i;
    if(R==Q)
      q=i;
    i++;
  }while(next_permutation(R.begin(),R.end()));
  cout<<abs(p-q)<<endl;
}

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

using namespace std;

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

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        double ans = 0;

        // i点(1～n)
        for (int i = 1; i <= n; i++)
        {
            // 連続で表出る必要回数cnt
            int cnt = 0;
            // 1点のとき
            // logの底1不可なので例外処理
            //if (i == 1)
            //{
            //    cnt = (int)Math.Log(k, 2) + 1;
            //}
            //else
            //{
            //    cnt = (int)Math.Log(k, i);
            //}
            for (int tmp = i; tmp < k; cnt++)
            {
                tmp *= 2;
            }

            ans += 1.0 / n * Math.Pow(0.5, cnt);
        }

        Console.WriteLine(ans);
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

#define N 1000005

using namespace std;

int main(){
    string s,k;
    cin>>s>>k;
    int64_t mn=INT_MAX;
    for(int i=0;i<=s.size()-k.size();i++){
        int64_t c=0;
        for(int j=0;j<k.size();j++){
            if(s[i+j]!=k[j]){
                c++;
            }
        }
        mn=min(mn,c);
    }
    if(mn==INT_MAX){mn=0;}
    cout<<mn<<endl;
}


Measured memory_bytes: 3600
#!/usr/bin/python3

import re


n = input()
s = input()


sb = re.sub(r'^0+', '', s)
sb = re.sub(r'0+$', '', sb)
sb = re.sub(r'00+', '-', sb)

tlist = sb.split('-')
counts_list = []

for t in tlist:
    counts = []
    tt = t.split('0')
    for ttt in tt:
        counts.append(len(ttt))
    counts_list.append(counts)

ans = 0

for counts in counts_list:

    len_counts = len(counts)
    sum_all = sum_decr = sum_one = sum_zero = 0

    for i in range(len_counts - 1):

        new_sum_all = new_sum_decr = new_sum_one = new_sum_zero = 0

        # do nothing
        new_sum_all = max(sum_all, sum_decr, sum_one, sum_zero)

        # go to left all
        new_sum_decr = max(new_sum_decr, sum_all + counts[i])
        new_sum_decr = max(new_sum_decr, sum_decr + counts[i] - 1)
        new_sum_decr = max(new_sum_decr, sum_one + 1)

        # go to right all - 1
        new_sum_one = max(new_sum_one, sum_all + counts[i+1] - 1)
        if (counts[i] >= 2):
            new_sum_one = max(new_sum_one, sum_decr + counts[i+1] - 1)
        new_sum_one = max(new_sum_one, sum_one + counts[i+1] - 1)

        # go to right all
        new_sum_zero = max(new_sum_zero, sum_all + counts[i+1])
        if (counts[i] >= 2):
            new_sum_zero = max(new_sum_zero, sum_decr + counts[i+1])
        new_sum_zero = max(new_sum_zero, sum_one + counts[i+1])

        sum_all = new_sum_all
        sum_decr = new_sum_decr
        sum_one = new_sum_one
        sum_zero = new_sum_zero

    ans += max(sum_all, sum_decr, sum_one, sum_zero)


print(ans)


Measured memory_bytes: 15796
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string S; cin >> S; 
	cout << S; 
	if(S.back() != 's') cout << "s\n"; 
	else cout << "es\n"; 
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
from collections import Counter
L = [i+a for i, a in enumerate(A)]
R = [i-a for i, a in enumerate(A)]
l = Counter(L)
r = Counter(R)
ans = 0
for i in l.keys():
    ans += l[i]*r[i]
print(ans)

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

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

int main() {
    string s;
    cin >> s;

    rep(i, 26) {
        char c = 'a' + i;
        bool found = false;

        rep(j, s.length()) {
            if (s[j] == c) {
                found = true;
                break;
            }
        }

        if (!found) {
            cout << c << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}



Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String X = sc.next();
    String Y = sc.next();
    if (X.compareTo(Y) > 0) {
      System.out.println(">");
    } else if (X.compareTo(Y) < 0) {
      System.out.println("<");
    } else {
      System.out.println("=");
    }
  }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll seg[1200005];
ll val[300005];
void build(ll v,ll l,ll r)
{
    if(l==r)
    {
        seg[v] = l;
        return ;
    }
    ll mid = (l+r)/2;
    build(2*v,l,mid);
    build(2*v+1,mid+1,r);
    if(val[seg[2*v]]>=val[seg[2*v+1]])
    {
        seg[v] = seg[2*v];
    }
    else
    {
        seg[v] = seg[2*v+1];
    }
}
void update(ll v,ll l,ll r,ll value,ll vertex)
{
    if(l==r)
    {
        return ;
    }
    ll mid = (l+r)/2;
    if(vertex>mid)
    {
        update(2*v+1,mid+1,r,value,vertex);
    }
    else
    {
        update(2*v,l,mid,value,vertex);
    }
    if(val[seg[2*v]]>=val[seg[2*v+1]])
    {
        seg[v] = seg[2*v];
    }
    else
    {
        seg[v] = seg[2*v+1];
    }
}
ll query(ll v,ll tl,ll tr,ll l,ll r)
{
    if(l>r)
    {
        return 300001;
    }
    if((l==tl)&&(r==tr))
    {
        return seg[v];
    }
    ll mid = (tl+tr)/2;
    ll x1 = query(2*v,tl,mid,l,min(r,mid));
    ll x2 = query(2*v+1,mid+1,tr,max(l,mid+1),r);
    if(val[x1]>=val[x2])
    {
        return x1;
    }
    else
    {
        return x2;
    }
}
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll k;
    cin>>k;
    val[300001] = -10000000;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(ll i=1;i<=300000;i++)
    {
        val[i] = -10000000;
    }
    build(1,0,300000);
    for(ll i=0;i<n;i++)
    {
        ll x = query(1,0,300000,max(a[i]-k,(ll)(0)),min(a[i]+k,(ll)(300000)));
        val[a[i]] = max(val[x],(ll)(0))+1;
        update(1,0,300000,val[a[i]],a[i]);
    }
    ll res = LONG_LONG_MIN;
    for(ll i=0;i<300001;i++)
    {
        res = max(res,val[i]);
    }
    cout<<res<<"\n";
}


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

int main() {
  int num_query; cin >> num_query;
  multiset<int> integers;
  
  for (int i = 0; i < num_query; i++) {
    int command, x; scanf("%d %d", &command, &x);
    
    switch (command) {
      case 0:
        integers.insert(x);
        printf("%d\n", integers.size());
        break;
        
      case 1:
        printf("%d\n", integers.count(x));
        break;
        
      case 2:
        integers.erase(x);
        break;
        
      case 3:
        int y; scanf("%d", &y);
        multiset<int>::iterator it = integers.lower_bound(x);
        multiset<int>::iterator last = integers.upper_bound(y);
        while (it != last) {
          printf("%d\n", *it);
          it++;
        }
        break;
    }
  }
}


Measured memory_bytes: 12480
#include <iostream>
#include <algorithm>
#include <limits>

using namespace std;

int n;

struct spell
{
	int d;
	int c;
};

spell sps[1005];
int dp[10005];

int dfs(int h)
{
	if (h <= 0)
	{
		return 0;
	}
	if (dp[h] != -1)
	{
		return dp[h];
	}
	int ans = std::numeric_limits<int>::max();
	for (int i = 0; i < n; i++)
	{
		ans = min(ans, dfs(h - sps[i].d) + sps[i].c);
	}
	return dp[h] = ans;
}

int main()
{
	int h;
	cin >> h >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> sps[i].d >> sps[i].c;
	}
	for (int i = 0; i <= h; i++)
	{
		dp[i] = -1;
	}
	cout << dfs(h) << endl;
	return 0;
}

Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while (true) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            if (n == 0 && k == 0) {
                break;
            }
            int[] arr = new int[k];
            for (int i = 0; i < k; i++) {
                arr[i] = sc.nextInt();
            }
            Arrays.sort(arr);
            int start;
            if (arr[0] == 0) {
                start = 1;
            } else {
                start = 0;
            }
            boolean flag = false;
            int st = 0;
            int ed = 0;
            ArrayDeque<Unit> deq = new ArrayDeque<>();
            for (int i = start; i < k; i++) {
                if (flag) {
                    if (arr[i - 1] + 1 == arr[i]) {
                        ed = arr[i];
                    } else {
                        deq.add(new Unit(st, ed));
                        st = arr[i];
                        ed = arr[i];
                    }
                } else {
                    st = arr[i];
                    ed = arr[i];
                    flag = true;
                }
            }
            deq.add(new Unit(st, ed));
            int max = 0;
            while (deq.size() > 0) {
                Unit u = deq.poll();
                if (start == 0) {
                    max = Math.max(max, u.size);
                } else {
                    max = Math.max(max, u.size + 1);
                    if (deq.size() > 0 && deq.peek().start - u.end == 2) {
                        max = Math.max(max, u.size + deq.peek().size + 1);
                    }
                }
            }
            sb.append(max).append("\n");
        }
        System.out.print(sb);
    }
    
    static class Unit {
        int start;
        int end;
        int size;
        
        public Unit(int start, int end) {
            this.start = start;
            this.end = end;
            this.size = end - start + 1;
        }
    }
}


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

int main(void){
	char str[200001];
	int s, e = 0, len, i;

	scanf("%s", str);

	len = strlen(str);
	for(i=0; i < len; i++) {
		if(str[i] == 'A') {
			s = i;
			break;
		}
	}
	for(int j=len; j > i; j--) {
		if(str[j] == 'Z') {
			e = j;
			break;
		}
	}
	printf("%d", e - s + 1);

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include <algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  int ans = 0;
  if (S.size() > 2) {
    rep(i,S.size()-2) {
      if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define int long long
signed main(){
  int K;
  cin>>K;
  int A[100010];
  for(int i=1;i<=K;i++){
    cin>>A[i];
  }
 
  //最終回が2人でなければ-1
  /*if(A[K] != 2){
    cout<<-1<<endl;
    return 0;
  }*/
  
  //最大人数　maxp　最小人数　minp
  int minp[100010];
  int maxp[100010];
  minp[K]=2;
  maxp[K]=2;
  int temp;
  //後ろから人数を決めながら遡る
  for(int i=K-1;i>=0;i--){
    if(maxp[i+1]%A[i+1] !=0 && minp[i+1]%A[i+1]!=0 && maxp[i+1]/A[i+1]-minp[i+1]/A[i+1]==0){
      cout<<-1<<endl;
      return 0;
    }
    
    //i+1の最大値と最小値におさまるA[i+1]の倍数の最小値
    minp[i]=((minp[i+1]-1)/A[i+1]+1)*A[i+1];
    /*if(temp>maxp[i+1]){
      cout<<-1<<endl;
      return 0;
    }*/
    //minp[i]=temp;

    maxp[i]=maxp[i+1]/A[i+1]*A[i+1]+A[i+1]-1;
    /*if(maxp[i]<minp[i]){
      cout<<-1<<endl;
      return 0;
    }*/
    
    //cout<<minp[i]<<" "<<maxp[i]<<endl;
  }
  cout<<minp[0]<<" "<<maxp[0]<<endl;
  return 0;
}


Measured memory_bytes: 5968
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long c,b,i,n,k,q,j;
	cin>>n>>k>>q;
	int a[n];
	c=k-q;
	for(i=0;i<n;i++)
	a[i]=c;
	for(i=0;i<q;i++)
	{
	cin>>b;
	--b;
	++a[b];	
	}
    for(j=0;j<n;j++)
    {
    	if(a[j]>0)
    	cout<<"Yes"<<"\n";
    	else
    	cout<<"No"<<"\n";
	}
	return 0;
}



Measured memory_bytes: 1024
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let isYYMM a b = 0 <= a && a <= 99 && 1 <= b && b <= 12
let isMMYY a b = isYYMM b a

[<EntryPoint>]
let main _ =
    let s = read string
    let a = s.Substring(0, 2) |> int
    let b = s.Substring(2, 2) |> int
    match (isYYMM a b, isMMYY a b) with
    | (true, true) -> "AMBIGUOUS"
    | (true, false) -> "YYMM"
    | (false, true) -> "MMYY"
    | _ -> "NA"
    |> printfn "%s"
    0

Measured memory_bytes: 13916
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

void solve()
{
    int x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

    /* int T; */
    /* cin >> T; */
    /* for (int t = 0; t < T; ++t) { */
        solve();
    /* } */
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
using namespace std;
int main(){
int a,b,c;
cin >> a>> b;
for(int i=1;i<=3;i++){
c=a*b*i;
if(c%2==1) {
  cout <<"Yes"<<endl;
  return 0;
}
}
cout << "No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int l, r, d;
  scanf("%d%d%d", &l, &r, &d);
  int ret = 0;
  for(int i = l;i <= r;i++) {
    if(i % d == 0) ret++;
  }
  printf("%d\n", ret);
  return 0;
}

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

int main() {
        int a,b;
        b = 0;
        cin >> a;
        if(a/100){
                b++;
                a = a%100;
        }
        if(a/10){
                b++;
                a = a%10;
        }
        if(a/1){
                b++;
        }
        cout << b;
        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
int main(void)
{
	int i, n;
	scanf("%d", &n);
	int a[n];
	
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	
	int maxv = INT_MIN;
	int min = a[0];
	
	for(i = 1; i < n; i++){
		if(maxv < a[i]-min)maxv = a[i] - min;
		if(min > a[i]) min = a[i];
	}
	
	printf("%d\n", maxv);
	
	return 0;
}



Measured memory_bytes: 2620
#include <stdio.h>

void countingSort(int *a, int *b, int n, int max) {
  int i, c[max + 1];

  for(i = 0;i <= max;i++)
    c[i] = 0;

  for(i = 0;i < n;i++)
    c[a[i]]++;

  for(i = 1;i <= max;i++)
    c[i] += c[i - 1];

  for(i = 0;i < n;i++) {
    b[c[a[i]]] = a[i];
    c[a[i]]--;
  }
}

int main() {
  int i, n, a[2000000], b[2000001], max = 0;

  scanf("%d", &n);
  for(i = 0;i < n;i++) {
    scanf("%d", &a[i]);
    if(a[i] > max)
      max = a[i];
  }

  countingSort(a, b, n, max);
  for(i = 1;i < n;i++)
    printf("%d ", b[i]);
  printf("%d\n", b[i]);

  return 0;
}



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

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if (A.size() == n + 1) {
    int now = 0;
    rep(i, q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}
int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q) { cin >> a[i] >> b[i] >> c[i] >> d[i]; }
  dfs(vector<int>(1, 1));

  cout << ans << endl;
  return 0;
}

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

int main(){
    int n,m;
    string tmp,tmp2,s;
    bool judge;
    while(1){
        map <string,string> data;
        map <string,string>::iterator itr;
        cin >> n;
        if(n == 0) break;
        for(int i=0;i<n;i++){
            cin >> tmp >> tmp2;
            data.insert(map <string,string>::value_type(tmp,tmp2));
        }
        cin >> m;
        while(m--){
            judge = false;
            cin >> s;
            for(itr=data.begin();itr!=data.end();itr++){
                if(s == (*itr).first) {
                    cout << (*itr).second;
                    judge = true;
                    break;
                }
            }
            if(!judge) cout << s;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    string N;

    cin >> N;

    if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    set<int> set;
    int N; cin >> N;
    rep(i, N) {
        int d; cin >> d;
        set.insert(d);
    }
    cout << set.size() << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools
n,a,b,c=map(int,input().split())
l1=[int(input()) for _ in range(n)]


x=10**9
#print(list(itertools.product([0,1,2,3], repeat=n)))
for i in list(itertools.product([0,1,2,3], repeat=n)):
    l2=[0]*3
    for j in range(n):
        if i[j]!=3:
            l2[i[j]]+=l1[j]
    l2=sorted(l2)
    if l2[0]!=0:
        l3=(len([_ for _ in i if _<3])-3)*10+abs(c-l2[0])+abs(b-l2[1])+abs(a-l2[2])
        if l3<x:
            x=l3

print(x)

Measured memory_bytes: 10996
N = input().split()
A = int(N[0])
B = int(N[1])

if A > B:
    if B != 1:
        print("Alice")
    else:
        print("Bob")
elif A == B:
    print("Draw")
else:
    if A != 1:
        print("Bob")
    else:
        print("Alice")

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

int main(void){
  int n;
  cin >> n;
  set<int> s;
  s.insert(n);
  int count = 1;
  while(true){
    count++;
    if(n%2==0){
      n = n/2;
    }else{
      n = 3*n+1;
    }
    if(s.count(n) != 0){
      cout << count << endl;
      break;
    }else{
      s.insert(n);      
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
#define MAXNUM 111111
set<int> ss;int bef[MAXNUM];
char s[MAXNUM];
int q[MAXNUM],top,front;
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    scanf("%s",s);
    rep(i,0,n+1)ss.insert(i);bef[n]=-1;
    rep(i,0,n+1)if(s[i]=='1')ss.erase(i);
    q[top++]=0;ss.erase(0);
    while(top!=front)
    {
        int k=q[front++];
        auto iter=ss.upper_bound(k);
        while(iter!=ss.end()&&*iter-k<=m)
        {
            bef[*iter]=k;
            q[top++]=*iter;
            ss.erase(iter++);
        }
    }
    if(bef[n]==-1)printf("-1\n");
    else{
        vector<int> v;int now=n;
        while(now)v.push_back(now-bef[now]),now=bef[now];
        reverse(v.begin(),v.end());
        for(int k:v)printf("%d ",k);
    }
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

vector<ll> vec(100);

void luca(int n) {
    if (n == 0) {
        vec.at(n) = 2LL;
        return;
    }
    if (n == 1){
        vec.at(n) = 1LL;
        return;
    }

    if (vec.at(n-1) == 0)
        luca(n - 1);
    if (vec.at(n-2) == 0)
        luca(n - 2);
    vec.at(n) = vec.at(n-1) + vec.at(n-2);
}

int main() {
    int n;
    cin >> n;
    vec.resize(n+1);
    luca(n);
    cout << vec.at(n) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
}

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

using mint=modint998244353;
vector<mint> digit(250000);
vector<mint> digit2(250000);

struct S{
  mint sum;
  int len;
};
using F=int;
S op(S x,S y){
  return{x.sum*digit[y.len]+y.sum,x.len+y.len};
}
S e(){
  return{0,0};
}
S mapping(F f,S s){
  if(f==-1)return s;
  return{f*digit2[s.len],s.len};
}
F composition(F f,F g){
  if(f==-1)return g;
  return f;    
}
F id(){
  return -1;
}

int main(){
  digit[0]=1;
  digit2[0]=0;
  digit2[1]=1;
  for(int i=1;i<250000;i++){
    digit[i]=digit[i-1]*10;
  }
  for(int i=2;i<250000;i++){
    digit2[i]=digit2[i-1]+digit[i-1];
  }
  int n,q;
  cin>>n>>q;
  lazy_segtree<S,op,e,F,mapping,composition,id> seg(vector<S>(n,{1,1}));
  while(q--){
    int l,r,d;
    cin>>l>>r>>d;
    l--;
    seg.apply(l,r,d);
    cout<<seg.all_prod().sum.val()<<endl;
  }
}

Measured memory_bytes: 11936
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N; cin >> N;

    ll ans = LONGINF;
    for(ll d=1; d*d<=N; d++) {
        if(N % d == 0) {
            ll a = d, b = N / d;
            ans = min<ll>(ans, a+b-2);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
N = int(input())
x  = 0
for i in range(1,N+1):
    if i%3 == 0:
            print(" "+ str(i),end = "")
    else:
        x = i
        while (x):
            if x % 10 == 3:
                print(" " + str(i),end = "")
                break
            x //= 10
print("")



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

vector<int> g[114514];
int color[114514];
ll w;

bool dfs(int v, int c){
	if(c==-1){
		++w;
	}
	color[v]=c;
	REP(i, g[v].size()){
		if(color[g[v][i]]==c){
			return false;
		}
		if(color[g[v][i]]==0 && !dfs(g[v][i], -c)){
			return false;
		}
	}
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, m;
	int a, b;
	cin>>n>>m;
	REP(i, m){
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cout<<(dfs(a, 1) ? w*(n-w)-m : n*(n-1)/2-m)<<'\n';
	return 0;
}


Measured memory_bytes: 6912
b=0
for e in iter(input,'0 0'):
 if b:print()
 b=u=1
 s,t=map(int,e.split())
 for y in range(s,t+1):
  if(y%4==0)*(y%100!=0)or y%400==0:print(y);u=0
 if u:print('NA')


Measured memory_bytes: 5724
import java.util.*;
public class Main {
	static int N, A[];
	static List X;
	static boolean mujun;
	public static void main(String[] args) {	
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = new int[N];

		X = new ArrayList<ArrayList<int[]>>();
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();
			List tmp = new ArrayList<int[]>();
			for(int j=0;j<A[i];j++) {
				int x = sc.nextInt() - 1; //人だけ０スタートにする
				int y = sc.nextInt();
				int t[] = {x, y};
				tmp.add(t);
			}	
			X.add(tmp);
		}
		sc.close();
		
		int ans = 0;
		//iさんを、正直者と仮定する。
		for(int i = 0;i<N;i++) {
			int visited[] = new int[N];
			mujun = false;
			dfs(i, visited);
			if(mujun) continue;
			
			for(int j=0;j<N;j++) {
				if(visited[j]==0) {
					int subVisited[] = visited.clone();
					mujun = false;
					dfs(j, subVisited);
					if(mujun) continue;
					visited = subVisited;
				}
			}
			
			int cnt = 0;
			for(int t:visited) {
				if(t==1)cnt ++;
			}
			
			ans = Math.max(ans, cnt);
		}
		System.out.println(ans);
	}
	
	static void dfs(int x, int[] visited) {
		visited[x]=1;
		List T = (List)X.get(x);
		for(int i=0;i<A[x];i++) {
			int[] tmp = (int[])T.get(i);
			int next = tmp[0];
			int nextTrue = tmp[1]; 
			
			if(nextTrue == 0) {
				if(visited[next]==1) {
					mujun = true;
				}
				visited[next] = -1;
			}
			else {
				if(visited[next]==-1) {
					mujun = true;
				}
			}
			
			if(!isVisited(next, visited)&&nextTrue==1) {
				dfs(next,visited);
			}
		}
	}
	
	static boolean isVisited(int x, int[] visited) {
		if(visited[x]==1||visited[x]==-1) return true;
		return false;
	}
	
}

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

using namespace std;

int main()
{
    int n, ans =0 ;

    long long l[1000];

    cin >> n;

    for (int i = 1; i <= n; ++ i)
            cin >> l[i];

    for (int i = 1; i <= n; ++ i)
    {
        for (int j = i + 1; j <= n; ++ j)
        {
            for (int k = j + 1; k <= n; ++ k)
            {
                int a = l[i], b = l[j], c = l[k];

                int AA, BB, CC;

                AA = min(a, min(b, c));

                CC = max(a, max(b, c));

                BB = a + b + c - AA - CC;

                if (AA + BB > CC && AA != BB && AA != CC && BB != CC) 
                    ans ++;//, cout << AA << ' ' << BB << ' ' << CC << endl;
            }
        }
    }

    cout << ans;
}

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  string s,t;
  cin >> s >> t;
  cout << string(t+s) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
using namespace std;
bool ans[100001]  = { };
bool flag[100001] = { };
vector <pair <int, int> > edge[100001];
void dfs(int n) {
  flag[n] = true;
  for (auto itr = edge[n].begin(); itr != edge[n].end(); itr++) {
	  if (flag[(*itr).first]) {
		  continue;
		}
	  if ((*itr).second % 2 == 0) {
		  ans[(*itr).first] = ans[n];
		}
	  else {
		  ans[(*itr).first] = !ans[n];
		}
	  dfs((*itr).first);
	}
}

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

  for (int i = 0; i < N - 1; i++) {
	  int u, v, w;
	  cin >> u >> v >> w;
	  edge[u].push_back(make_pair(v, w));
	  edge[v].push_back(make_pair(u, w));
	}
  ans[1] = true;
  dfs(1);
  for (int i = 1; i <= N; i++) {
	  if (ans[i]) {
		  cout << 1;
		}
	  else {
		  cout << 0;
		}
	  cout << endl;
	}
  return 0;
}


Measured memory_bytes: 7424
now, tx, ty, cant = [0]*4
for i in range(int(input())):
        t, nx, ny = map(int, input().split())
        k = abs(nx-tx)+abs(ny-ty)
        if k>t or k%2!=(t-now)%2: cant = 1
        now, tx, ty = t, nx, ny
print("YNeos"[cant::2])


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n, m;
  cin >> n >> m;

  vector<llong> s(n-1);
  REP(i,n-1){
    cin >> s[i];
  }

  llong dist[100010] = {};
  dist[0] = 0;
  REP(i,n-1){
    dist[i+1] = s[i]; 
  }
  REP(i,n-1){
    dist[i+1] += dist[i];
    
  }

  llong ans = 0;
  llong a;
  int cur = 0;
  REP(i,m){
    cin >> a;

    if(a > 0){
      ans += dist[cur + a] - dist[cur];
      cur += a;
    }else{
      ans += dist[cur] - dist[cur + a];
      cur += a;
    }
    ans %= 100000;
    //cout << ans << endl;
  }
  cout << ans << endl;

  return 0;
}




Measured memory_bytes: 4332
#include <iostream>
using namespace std;
 
int main(){
	int a,b,c;
  	cin >> a >> b >> c;
  	if (a >= b && a >= c) cout << b+c << endl;
  	else if (b >= a && b >= c) cout << a+c << endl;
  	else cout << b+a << endl;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, R;
    cin >> N >> R;
    cout << R + 100 * max((10 - N), 0LL) << endl;
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();

        Integer[] arr = new Integer[num];
        int i = 0;
        while (sc.hasNext()) {
            arr[i++] = sc.nextInt();
        }

        Arrays.sort(arr, Comparator.reverseOrder());

        long answer = 0;
        for (i = 1; i < num; i++) {
            answer = answer + arr[i / 2];
        }

        System.out.printf("%d", answer);

    }
}

Measured memory_bytes: 64152
N,A,B,C,D=map(int,input().split())
if N%A==0:
    a=N//A
else :
    a=N//A+1
    
if N%C==0:
    b=N//C
else:
    b=N//C+1
    
if a*B>b*D:
    print(b*D)
else:
    print(a*B)

    





Measured memory_bytes: 5596
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
		
    int A = sc.nextInt();	
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    if(A+B+C>=22){
      System.out.println("bust");
    }else{
      System.out.println("win");
    }
  }
}

Measured memory_bytes: 21844
#include <stdio.h>

void print(int size1, int size2, int size3, int count[size1][size2][size3]);
int main(void) {
  int n, i, j, k;
  scanf("%d", &n);
  int count[4][3][10];
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++) {
        count[i][j][k] = 0;
      }
    }
  }
  int b, f, r, v;
  for (i = 0; i < n; i++) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    count[b - 1][f - 1][r - 1] += v;
  }
  print(4,3,10,count);
}
void print(int size1, int size2, int size3, int count[size1][size2][size3]) {
  int i, j, k;
  for (i = 0; i < size1; i++) {
    for (j = 0; j < size2; j++) {
      for (k = 0; k < size3; k++) {
        printf(" %d", count[i][j][k]);
      }
      putchar('\n');
    }
    if (i < 3) {
      for (j = 0; j < 20; j++) {
        putchar('#');
      }
      putchar('\n');
    }
  }
}



Measured memory_bytes: 2052
n, k, q = gets.split.map(&:to_i)
a = readlines.map(&:to_i)
necessary_answer_count = q - k + 1
participant_list = {}
(1..n).each do |i|
  participant_list[i] = 0
end
a.each do |x|
  participant_list[x] += 1
end
participant_list.each do |k, v|
  if v >= necessary_answer_count
    puts 'Yes'
  else
    puts 'No'
  end
end


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

using namespace std;
typedef unsigned long long ull;

int n, k, h, cnt=0;

int main(){
  cin >> n >> k;
  rep(i, n){
    cin >> h;
    if(h>=k){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        boolean yes = false;
        for(int i = 0; i <= 25; i++){
            for(int j = 0; j <= 14; j++){
                if(i*4 + j*7 == n){
                    yes = true;
                    break;
                }
            }
        }
        
        if(yes){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
import sys
import bisect
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())

A, B = tuple(li())

def F(num):
    if num == 0:
        return 0
    # there are a pair: (0,1), (2,3)... where xor in every pair is 1
    a = (num + 1) // 2
    ret = 0 if a % 2 == 0 else 1
    ret = ret ^ num if num % 2 == 0 else ret
    return ret
res = F(A - 1) ^ F(B)
print(res)


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

// 💖 Hi, thanks for using ICIE! 💖
// 🔧 To use a custom code template, set it in Settings(Ctrl+,) in "Icie Template List" entry 🔧
// 📝 If you spot any bugs or miss any features, create an issue at https://github.com/pustaczek/icie/issues 📝

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, v[105];

    cin  >> n;
    for (int i=1;i<=n;i++)
        cin >> v[i];
    int ans = 100000000;
    for (int i=1;i<=100;i++)
    {
        int aux = 0;
        for (int j=1;j<=n;j++)
            aux += (i-v[j])*(i-v[j]);
        ans = min(aux,ans);
    }
    cout << ans << '\n';
}



Measured memory_bytes: 256