akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int dp[3000][3000];
int go(int i, int j)
{
    if (i==s1.size() || j==s2.size())
        return 0;
    if (dp[i][j]!=-1)
        return dp[i][j];
    dp[i][j]=0;
    if (s1[i]==s2[j])
        return dp[i][j]=1+go(i+1, j+1);
    else
        return dp[i][j]=max(go(i, j+1), go(i+1, j));
}
void build(int i, int j)
{
    if (i==s1.size() || j==s2.size())
        return;
    if (s1[i]==s2[j])
    {
        cout << s1[i];
        build(i+1, j+1);
    }
    else
        if (dp[i][j]==go(i+1, j)) /// OR ==dp[i+1][j]
            build(i+1, j);
        else if (dp[i][j]==go(i, j+1)) /// OR ==dp[i][j+1]
            build(i, j+1);
}
int main()
{
    cin >> s1 >> s2;
    memset(dp, -1, sizeof dp);
    int n=go(0, 0);
    int a, b;
    for (int i=0 ; i<s1.size() ; i++)
        for (int j=0 ; j<s2.size() ; j++)
            if (dp[i][j]==n)
            {
                a=i, b=j;
                break;
            }
    build(a, b);
    return 0;
}


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

char s[N];

int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	
	for (int i = 1; i <= n - 1; i ++ )
		if (s[i] == s[i + 1])
		{
			printf("%d %d\n", i, i + 1);
			return 0;
		}
	
	for (int i = 1; i <= n - 2; i ++ )
		if (s[i] == s[i + 2])
		{
			printf("%d %d\n", i, i + 2);
			return 0;
		}
	
	puts("-1 -1");
    return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<int> wa(n, 0);
	vector<bool> ok(n, 0);
	while(m--)
	{
		int x;
		string s;
		cin >> x >> s;
		--x;
		if (s == "AC") ok[x] = 1;
		else if (ok[x] == 0) wa[x]++;
	}
	
	int a = 0, b = 0;
	FOR(i, 0, n) if (ok[i]) a += 1, b += wa[i];
	
	cout << a << ' ' << b << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



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

using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({(ll)a * c, (ll)a * d, (ll)b * c, (ll)b * d}) << '\n';
  return 0;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
ld a[5], n;
signed main() {
	cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	cout << (ll)ceil(n / min(a[0],min( a[1], min(a[2],min( a[3], a[4]))))) + 4 << endl;
}

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

int main(){
    int h, w;
    
while(1){
    cin >> h >> w;
    if(h == 0 & w == 0) break;
    for(int i = 0;i < h; ++i){
        for(int j = 0;j < w; ++j){
            cout << "#";
        }
        cout << endl;
    }
    cout << endl;
}
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string a;
	string b = "";
	cin >> a;
	for(int i = 0;i < a.size();i++)
	    {
	    	if(a[i] == '0')b = b + '0';
			else if(a[i] == '1')b = b + '1';
			else if(a[i] == 'B'){
					if(b.size() > 0)
					b.erase(b.size()-1,1); //删除以下标3为起点的2个字符   
				}
		}
	cout << b << endl;
	return 0;
}

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

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

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 ll = long long;

int main()
{
	int n;
	cin >> n;
	set<int> d;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		d.insert(tmp);
	}

	int count = 0;
	for (auto& x : d) count++;

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
const inp = require('fs').readFileSync('/dev/stdin', 'utf8'); const l = inp.trim().split('\n'); var n = null; var ind = 0; while (li = l.shift()) { const isN = ind % 2 === 0; const nAr = li.split(' '); if(isN){ n = nAr[0]; } else { var sSc = null; for(var i = 0; i < nAr.length; i++){ for(var j = 0; j < nAr.length; j++){ if (i!==j) { let sDi = Math.abs(nAr[i] - nAr[j]); if(sSc === null){ sSc = sDi; } else { if(sDi < sSc){ sSc = sDi; } } } } } n = null; console.log(sSc); } ind ++; } 


Measured memory_bytes: 18176
import math
x = int(input())
def prime_get():
    if x <= 1:
        return []
    prime = [2]
    limit = int(math.sqrt(x))
    data = [i+1 for i in range(2,100004,2)]

    while limit >= data[0]:
        prime.append(data[0])
        data = [j for j in data if j % data[0] != 0]
    return prime+data

ans = prime_get()
ans = [i for i in ans if i >= x]
print(ans[0])


Measured memory_bytes: 5400
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define POW_10_5 100000
#define POW_10_9 1000000000
#define MOD 1000000007
#define INF (numeric_limits<int>::max()/2)
#define int long long

typedef pair<int, int> Pair;
typedef unordered_map<int, int> Hash;

// ---
int X;

int Ans() {
  int money = 100;
  int year = 0;
  while (money < X) {
    money += (money / 100);
    year += 1;
  }
  return year;
}

signed main() {
  cin >> X;

  auto ans = Ans();

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


Measured memory_bytes: 3192
n,q,*x=map(int,open(0).read().split())
a=x[:n]
queries=[[]for _ in[0]*n]
for i in range(q):
  l,r=x[n+i*2],x[n+i*2+1]
  l-=1
  r-=1
  queries[r].append((l,i))
lastAppeared=[0]*n
bit=[0]*(n+1)
ans=[0]*q
for i in range(n):
  x=lastAppeared[a[i]-1]+1
  while x<=n+1:
    bit[x-1]-=1
    x+=x&-x
  x=i+2
  while x<=n+1:
    bit[x-1]+=1
    x+=x&-x
  lastAppeared[a[i]-1]=i+1
  for l,ind in queries[i]:
    x=i+2
    while x:
      ans[ind]+=bit[x-1]
      x-=x&-x
    x=l+1
    while x:
      ans[ind]-=bit[x-1]
      x-=x&-x
print(*ans)


Measured memory_bytes: 305944
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;


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


void solve(){
	int n,k;
	cin >> n >> k;
	vi a(n);
	forn(i,0,n) cin >> a[i];

	while(k--){
		vi b(n+1);
		for(int i =0;i<n;i++){
			int from = max(i-a[i],0);
			int to = min(n-1,i+a[i]);
			b[from]+=1;
			if(to<n-1)
				b[to+1]-=1;
 		}

 		vi cpya = a;

 		for(int i =0;i<n;i++){
 			a[i]=b[i];
 			b[i+1]+=b[i];
 		}
 		if(cpya == a)
 			break;
 		// for(int i =0;i<n;i+)
	}

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

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 5652
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    int A, B;
    float T;
    cin >> A >> B >> T;
    int res = floor((T+0.5) / A) * B;
    cout << res << endl;
    return 0;
}

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

const int MAXN = 5005;

int M[MAXN][MAXN];


int main()
{
    std::ios_base::sync_with_stdio(0);
    int n;
    std::string s;
    std::cin >> n >> s;
    int result = 0;
    for (int i=0;i<n;++i)
    {
        for (int j=i+1;j<n;++j)
        {
            if (s[i] == s[j])
            {
                if (i == 0 || j == 0) M[i][j] = 1;
                else M[i][j] = std::min(M[i-1][j-1] + 1, j-i);
                result = std::max(result, M[i][j]);
            }
        }
    }
    std::cout << result;
    return 0;
}

Measured memory_bytes: 96768
N = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(N)]
for a in A:
  B[a-1] += 1
s = 0
for b in B:
  s += b * (b-1) // 2
for a in A:
  print(s - (B[a-1]-1))

Measured memory_bytes: 104628
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func chmin(a *float64, b float64) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func chmax(a *float64, b float64) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n, l int
	fmt.Fscan(read, &n, &l)

	sum := 0
	val := 0
	valabs := 10000000.0
	for i := 1; i <= n; i++ {
		sum += l + i - 1
		if chmin(&valabs, math.Abs(float64(l+i-1))) {
			val = l + i - 1
		}
	}
	sum -= val
	fmt.Fprintln(write, sum)
}


Measured memory_bytes: 640
from collections import deque
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

dxs = [0, 0, 1, -1]
dys = [1, -1, 0, 0]
cand = []
for j in range(H):
    for i in range(W):
        if S[j][i] == '#':
            continue
        q = deque()
        q.append((i, j, 0))
        field = [[-1] * W for _ in range(H)]
        field[j][i] = 0
        while q:
            p = q.popleft()
            for dx, dy in zip(dxs, dys):
                x, y = p[0] + dx, p[1] + dy
                if not (0 <= x < W) or not (0 <= y < H) or S[y][x] == '#' or field[y][x] != -1:
                    continue
                field[y][x] = p[2] + 1
                q.append((x, y, p[2] + 1))
        cand.append(max(max(row) for row in field))
print(max(cand))

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

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

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

    char digit[3];
    int ans = 0;
    rep(i, 1000){
        if(to_string(i).length() == 3){
            digit[0] = to_string(i).at(2);
            digit[1] = to_string(i).at(1);
            digit[2] = to_string(i).at(0);
        }else if(to_string(i).length() == 2){
            digit[0] = to_string(i).at(1);
            digit[1] = to_string(i).at(0);
            digit[2] = '0';
        }else{
            digit[0] = to_string(i).at(0);
            digit[1] = '0';
            digit[2] = '0';
        }
        int count = 0;
        rep(j, N){
            if(S.at(j) == digit[count]){
                count++;
                if (count == 3){
                    break;
                }
            }
        }
        if(count == 3){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <string>
#include <stack>
#include <iostream>

using namespace std;
typedef long long ll;

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

int main(void){
    string s;
    char bra[] = {'(', ')', '[', ']'};
    while(getline(cin, s) && s!=".") {
        stack<char> stk;
        bool ok = true;
        rep(i, s.size()) {
            bool is_bracket = false;
            rep(j, 4) if(s[i] == bra[j]) is_bracket = true;
            if(!is_bracket) continue;
            if(stk.empty() || s[i] == '(' || s[i] == '[') stk.push(s[i]);
            else if( (stk.top() == '(' && s[i] == ')') ||
                     (stk.top() == '[' && s[i] == ']') ) stk.pop();
            else {
                ok = false;
                break;
            }
        }

        if(ok && stk.empty()) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}

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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    os << pai.first << ' ' << pai.second;
	return os;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int N;
pii food[100000];

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

	cin >> N;
	rep(i, N) cin >> food[i];
	sort(food, food+N, [](pii a, pii b) {
		return a.fi+a.se > b.fi+b.se;
	});

	ll res = 0;
	rep(i, N) {
		if (i%2) res -= food[i].se;
		else res += food[i].fi;
	}

	cout << res;
}

Measured memory_bytes: 1024
// 2014/07/15 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int i = 1;

	while(true){
		int x;
		cin >> x;

		if(x==0)
			break;

		cout << "Case " << i << ": " << x << '\n';
		i++;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int d,t;
  char c;
  double x=0.0, y=0.0, angle=0.0;


  while( cin>>d>>c>>t && (d||t) ){
    x += (double)( d*sin( angle*M_PI/180.0) );
    y += (double)( d*cos( angle*M_PI/180.0) );
    angle += (double)t;    
  }

  cout << (int)x << endl;
  cout << (int)y << endl;

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S[7] = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    string T;
    cin >> T;
    rep(i, 7) {
        if (T == S[i]) {
            cout << i + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
<?php

$args = [];
$input = explode(' ', trim(fgets(STDIN)));

$count = $input[0];
$length = $input[1];

while(true){
	$input = explode(' ', trim(fgets(STDIN)));
	foreach ($input as $value) {
		if (!empty($value)) {
			$args[] = $value;
		}
		if (count($args) >= $count) {
			break;
		}
	}
	if (count($args) >= $count) {
		break;
	}
}

usort($args, function($a, $b) use($length){
	for ($i=0; $i < $length; $i++) { 
		if ($a[$i] < $b[$i]) {
			return -1;
		}elseif ($a[$i] > $b[$i]) {
			return 1;
		}
	}
	return 0;
});

echo implode('', $args);

Measured memory_bytes: 4728
#include<iostream>
int main()
{
  int A, B, C, D, E;
  scanf("%d%d%d%d%d",&A,&B,&C,&D,&E);
  if(A == 0)
    printf("1");
  else if(B == 0)
    printf("2");
  else if(C == 0)
    printf("3");
  else if(D == 0)
    printf("4");
  else
    printf("5");
}

Measured memory_bytes: 3148
/*
AOJ 0033 Ball

?¢???????????§??????????????????¢???????§???§?\?????????????A??£?????\???????????????????????????????????????DE?????¶??????B?£???????C?£??????????
??°??????1-10??????????????????????????????A??£?????\???????????????????§???§??¶??????????????\?????\???B?£???????C?£???????????????????????????????????¢????

?????\????¬¬???????????\??°????????°N?????\?????\N??????N???????????°??????????????°?????????10?????´??°?????£??¨???????????\?????????

???????????????????????°????????\?????\?????¨?????????YES?????\????????¨?????????NO
 */
#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include <algorithm>
#include <complex>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define SZ(a) (int)(a).size()
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define REP(i,n) for (int i=0; i<(n); ++i)
#define ALL(c) c.begin(), c.end()
#define CLR(c,n) memset(c, n, sizeof(c))
#define TR(it, c) for(typeof(c.begin()) it = c.begin();it != c.end(); ++it)
#define CONTAIN(it, c) (c.find(it) != c.end())
typedef vector<int> VI;
typedef pair<int, int> PII;
template <class T> void checkmin(T &a, T b) { if (b<a) a=b; }
template <class T> void checkmax(T &a, T b) { if (b>a) a=b; }

const int N = 10;
int x[N];

bool go(int idx, int l1, int l2) {
  if (idx == N) return true;
  return (x[idx] > l1 && go(idx+1, x[idx], l2)) ||
      (x[idx] > l2 && go(idx+1, l1, x[idx]));
}

int main(int argc, char *argv[]) {
  int n;
  for (scanf("%d", &n); n; --n) {
    REP(i, 10) scanf("%d", &x[i]);
    puts(go(0, 0, 0)? "YES" : "NO");
  }
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <deque>
#include <array>
#include <cmath>

using namespace std;

int main()
{
  int n, m;
  deque<int> a;

  cin >> n >> m;

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

  int votes = 0;

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

  int cnt = 0;

  for (int i = 0; i < n; i++)
  {
    if (a[i] >= ceil((double)votes / (4 * m)))
    {
      if (++cnt >= m)
      {
        break;
      }
    }
  }

  if (cnt >= m)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc159/submissions/11108540

def main():
    def calc(group):
        ret = max(group)
        ctr = [0] * H
        for c in range(W):
            need_cut = False
            for r, g in enumerate(group):
                ctr[g] += s[r][c]
                if ctr[g] > K:
                    need_cut = True
                    break

            if need_cut:
                ctr = [0] * H
                ret += 1
                for r, g in enumerate(group):
                    ctr[g] += s[r][c]
                    if ctr[g] > K:
                        return H * W
                continue
        return ret

    def gen():
        from itertools import accumulate, product

        for prod in product(range(2), repeat=H - 1):
            group = [0]
            group.extend(accumulate(prod))
            yield calc(group)

    H, W, K = map(int, input().split())
    s = []
    for _ in range(H):
        *row, = map(int, input())
        s.append(row)

    ret = min(gen())
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42588
#!/usr/bin/env python3
import sys
def comb(n, k):
    k = min(n-k,k)
    ans = 1
    for i in range(1, k + 1):
        ans = (ans * (n + 1 - i) // i)
    return ans

def solve(N: int, P: int, A: "List[int]"):
    odd = 0
    even = 0

    for i in range(N):
        if A[i]&1:
            odd += 1
        else:
            even += 1
    
    all_pattern = 2**N
    odd_pattern = 0
    for o in range(1,odd+1):
        if o&1:
            odd_pattern += comb(odd,o)
    odd_pattern *= 2**even

    if P:
        print(odd_pattern)
    else:
        print(all_pattern-odd_pattern)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//
// Created by 26019 on 2020/6/7/007.
//
#include <iostream>

using namespace std;

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

int main() {
    int k;
    cin >> k;
    int a = 1, b = 1, c = 1;
    long long sum = 0;
    for (int i = a; i <= k; i++) {
        for (int j = b; j <= k; j++) {
            for (int l = c; l <= k; l++) {
                sum += gcd(i, gcd(j, l));
            }
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3184
import sys
from collections import deque
sys.setrecursionlimit(200000)
 
readline = sys.stdin.readline
 
N = int(readline())
 
nodes = [deque() for i in range(N)]
node_colors = [-1 for i in range(N)]
 
for i in range(N - 1):
    u,v,w = map(int, readline().split())
    u, v = u - 1, v - 1
    nodes[u].append([v, w])
    nodes[v].append([u, w])
 
 
node_colors[0] = 0
 
def process(u, parent, w): 
    p_color = node_colors[parent]
    node_colors[u] = p_color if w % 2 == 0 else 1 - p_color
    
    for v, w in nodes[u]:
        if v == parent:
            continue
        process(v, u, w)
 
for v, w in nodes[0]:
    process(v, 0, w)
 
for c in node_colors:
    print(c)

Measured memory_bytes: 209160
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back

vint x;
vint d;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vint x(m);
    REP(i,m) cin >> x[i];
    sort(ALL(x));
    vint d(m-1);
    ll ans=0;
    if(n>=m){
        ans=0;
    }else{
        REP(i,m-1){
            d[i]=x[i+1]-x[i];
        }
        sort(ALL(d));
        REP(i,m-n){
            ans+=(ll)d[i];
        }
    }
    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  ll x,k,d;
  cin >> x >> k >> d;

  x = abs(x);

  // ll count = 0;
  // ll com1,com2;
  // 
  // ll com1_co,com2_co;

  ll x_sho = x / d;
  ll x_amari = x % d;
  ll x_ir = abs(x_amari - d);

  if(x_sho >= k) {
    cout << x - (k * d) << endl;
    return 0;
  }

  k = k % 2;
  x_sho = x_sho % 2;

  if(x_sho == k) cout << x_amari << endl;
  else cout << x_ir << endl;;

  

  // rep(i,k) {
  //   com1 = x;
  //   x -= d;
  // 
  //   com1_co = count;
  // 
  //   if(x <= 0) {
  //     com2 = x;
  //     com2_co = count+ 1;
  //     break;
  //   }
  // 
  //   if( i == k - 1) {
  //     cout << x << endl;
  //     return 0;
  //   }
  // 
  //   count++;
  // }
  // 
  // com1_co %= 2;
  // com2_co %= 2;
  // k %= 2;
  // 
  // if(com1_co == k) {
  //   cout << abs(com1) << endl;
  // }
  // else {
  //   cout << abs(com2) << endl;
  // }

  
}



Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
int gcd(int a, int b){ if(a==0) return b; return gcd(b%a, a);}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char k;
	ci(k);
	if(k>=65 && k<=90){
		co('A');
	}
	else{
		co('a');
	}
	return 0;
}






Measured memory_bytes: 3556
#include <iostream>

using namespace std;

int main() {
    string s;
    int max = 0, now = 0;
    cin >> s;

    for (int i = 0; i < 3; i++) {
        if (s[i] == 'R') {
            now++;
        } else {
            if (max < now) {
                max = now;
            }
            now = 0;
        }
    }

    if (now > max) {
        cout << now << endl;
    } else {
        cout << max << endl;
    }
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long cnt[35],n,m,i,j,ans;
string st;
int main()
{
	ios::sync_with_stdio(0);
	cin>>st;
	for (i=0;i<st.length();i++) cnt[st[i]-'a'+1]++;
	for (i=1;i<=26;i++)
	{
		ans+=(sqr(cnt[i])-cnt[i])/2;
	}
	cout<<sqr(st.length())/2-st.length()/2+1-ans;
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    string s;
    cin>>s;
    if(s=="Rainy")
    {
        printf("Sunny");
    }
    else if(s=="Sunny")
    {
        printf("Cloudy");
    }
    else{
        printf("Rainy");
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<cmath>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep2(i,a,b)for(int i=a;i<b;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define __int64 long long
double EPS=1e-10;
double xs,ys,xt,yt;
int n;
double y[1111],x[1111],r[1111];
double d[1111];
bool u[1111];
vector<pair<int,double> >G[1111];

double g(int a,int b){
	double x1=x[a],y1=y[a],x2=x[b],y2=y[b];
	double dx=x1-x2,dy=y1-y2;
	//cout<<dx<<" "<<dy<<"A"<<endl;
	double dist=sqrt(dx*dx+dy*dy);
	if(dist<EPS+r[a]+r[b])return 0;
	else return dist-r[a]-r[b];
}
int main(){

	cin>>xs>>ys>>xt>>yt;
	cin>>n;
	rep(i,n)cin>>x[i]>>y[i]>>r[i];
	
	x[n]=xs;y[n]=ys;
	x[n+1]=xt;y[n+1]=yt;
	n+=2;

	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			double dist=g(i,j);
			//cout<<i<<" "<<j<<" "<<dist<<endl;
			G[i].push_back(mp(j,dist));
			G[j].push_back(mp(i,dist));
		}
	}


	priority_queue<pair<double,int>,vector<pair<double,int> >,greater<pair<double,int> > >bfs;
	bfs.push(mp(0,n-2));
		
	while(!bfs.empty()){
		double tmp=bfs.top().first;
		int now=bfs.top().second;

		bfs.pop();
		if(u[now])continue;
		u[now]=1;
		d[now]=tmp;
		rep(i,G[now].size()){
			bfs.push(mp(tmp+G[now][i].second,G[now][i].first));
		}
	}
	//rep(i,n)cout<<d[i]<<" ";cout<<endl;
	printf("%.20lf\n",d[n-1]);

	return 0;
}


Measured memory_bytes: 34956
a, b = map(int, input().split())
number_list = list(range(a, b + 1))
ans = []
for i in range(len(number_list)):
    str_number = str(number_list[i])
    len_number = len(str_number)
    count = 0
    for j in range(len_number // 2):
        if str_number[j] != str_number[-1 - j]:
            break
        count += 1
    if count == len_number // 2:
        ans.append(str_number)
print(len(ans))


Measured memory_bytes: 12448
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int N;
multiset<int> A;
multiset<int> B;
bool T[201];

int main() {
  while (cin >> N) {
    if (N == 0) break;
    A.clear(), B.clear();
    for (int i=0; i<=2*N; i++) T[i] = false;
    for (int i=0; i<N; i++) {
      int t;
      cin >> t;
      T[t] = true;
    }
    for (int i=1; i<=2*N; i++) {
      if (T[i]) A.insert(i);
      else      B.insert(i);
    }
    int turn = 0, x = -1;
    while (!A.empty() && !B.empty()) {
      if (turn == 0) {
        auto i = lower_bound(A.begin(), A.end(), x);
        if (i == A.end()) {
          x = -1;
          turn ^= 1;
          continue;
        }
        x = *i;
        A.erase(i);
      }
      if (turn == 1) {
        auto i = lower_bound(B.begin(), B.end(), x);
        if (i == B.end()) {
          x = -1;
          turn ^= 1;
          continue;
        }
        x = *i;
        B.erase(i);
      }
      turn ^= 1;
    }
    cout << B.size() << "\n";
    cout << A.size() << "\n";
  }
  return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
     
template <typename Weight, int MAX_N, Weight INF> class MaxFlow{
public:
	struct E{
		int to, rev;
		Weight lim;
		E(int x, Weight y, int z){
			to = x;
			lim = y;
			rev = z;
		}
	};
     
	vector<E> edge[MAX_N];
	int lev[MAX_N];
	int iter[MAX_N];
     
     
	Weight dfs(int s, int g, Weight f){
		if(s == g)return f;
		for(int &i = iter[s];i < edge[s].size();i++){
			E &e = edge[s][i];
			if(lev[e.to] <= lev[s] || e.lim <= 0)continue;
			Weight tmp = dfs(e.to, g, min(f, e.lim));
			if(tmp<1e-9)continue;
			e.lim -= tmp;
			edge[e.to][e.rev].lim += tmp;
			return tmp;
		}
		return 0;
	}
     
	void bfs(int x){
		queue<int> q;
		q.push(x);
		int p = 0;
		while(!q.empty()){
			for(int i = q.size();i--;){
				int tmp = q.front();q.pop();
				if(lev[tmp] != MAX_N)continue;
				lev[tmp] = p;
				for(int j = 0;j < edge[tmp].size();j++){
					if(edge[tmp][j].lim > 0 && lev[edge[tmp][j].to] == MAX_N)q.push(edge[tmp][j].to);
				}
			}
			p++;
		}
	}
     
	void make_edge(int a, int b, Weight l){
		edge[a].push_back(E(b, l, edge[b].size()));
		edge[b].push_back(E(a, 0, edge[a].size() - 1));
	}
     
	Weight max_flow(int s, int g){
		Weight res = 0;
		bool fin = false;
		while(!fin){
			fill(lev, lev + MAX_N, MAX_N);
			fill(iter, iter + MAX_N, 0);
			bfs(s);
			fin = true;
			while(true){
				Weight p = dfs(s, g, INF);
				if(p < 1e-9)break;
				fin = false;
				res += p;
			}
		}	
		return res;
	}
};
     
MaxFlow<int, 216000, (1<<26)> mf;
bool come[216000];
int n,c, u;
vector<int> ans[216000];
void ng(){
	cout << -1 << endl;
	exit(0);
}

void dfs(int x, int last = -1){
	come[x] = true;
	for(int i = 0;i < mf.edge[x].size();i++){
		if(mf.edge[x][i].lim == 0)continue;
		int to = mf.edge[x][i].to;
		if(come[to])continue;
		dfs(to, x);
		if(x != 0 && x < n){
			ans[x].push_back(to - n);
			ans[x].push_back(last - n);
			return;
		}
	}
}

int main(){
	cin >> n;
	int T = 215000, S = 0;
	for(int i = 1;i <= n;i++)mf.make_edge(S, n + i, 1);
	for(int i = 1;i < n;i++){
		cin >> c;
		mf.make_edge(i, T, 1);
		for(int j = 0;j < c;j++){
			cin >> u;
			mf.make_edge(n + u, i, 1);
		}	
	}
	if(mf.max_flow(S, T) != n-1)ng();
	dfs(S);
	for(int i = 1;i < n;i++)
		if(ans[i].size() != 2)ng();
		
	for(int i = 1;i < n;i++)
		cout << ans[i][0] << " " << ans[i][1] << endl;
	return 0;
}

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

using ll=long long;

int main() {
  int N,D; cin >>N >>D;
  int ans=0;
  rep(i,0,N) {
    int X,Y; cin >>X >>Y;
    if (sqrt(pow(X,2)+pow(Y,2))<=D) ans++;
  }
  cout <<ans <<endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;

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

    ll X, Y;
    cin >> X >> Y;

    if(abs(X - Y) <= 1) {
        cout << "Brown" << endl;
    } else {
        cout << "Alice" << endl;
    }
}

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

using namespace std;

int main() {
	int x, y;
	{
		string s;
		getline(cin, s);
		sscanf(s.c_str(), "%d %d", &x, &y);
	}

	if (
		y & 1
		|| y < 2 * x
		|| y > 4 * x
		) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define vi vector<ll>
#define pi pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;ll arr[n];
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n = 5;
    int arr[n];
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]==0)
            ans=i;
    }
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 3608
N=io.read("n")
local t={0}
local x={0}
local y={0}
for i=2,N+1 do
  t[i]=io.read("n")
  x[i]=io.read("n")
  y[i]=io.read("n")
end
local res="Yes"
for i=2,N+1 do 
  local k=t[i]-t[i-1]
  local s=math.abs(x[i]-x[i-1])+math.abs(y[i]-y[i-1])
  if  k<s or k%2~=s%2 then
    res="No"
    break
  end
end
print(res)

Measured memory_bytes: 6520
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

vector<int> div(int n){
    vector<int> res;
    for(int i = 1; i*i <= n; i++){
        if(n % i == 0){
            res.pb(i);
            res.pb(n/i);
        }
    }
    return res;
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(1000001);
    rep(i,n) cnt[a[i]]++;

    int ans = 0;
    rep(i,n){
        if(cnt[a[i]] > 1) continue;
        bool ok = true;
        auto v = div(a[i]);
        for(int k : v){
            if(k == a[i]) continue;
            if(cnt[k] >= 1){
                ok = false;
                break;
            }
        }
        if(ok) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 8024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
int N,X,T;
  cin>>N>>X>>T;

int ans;
  
  ans=(int)((double)N/(double)X+0.9999999);
  ans=ans*T;
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
vector<int> memo(1e5+5, -1);

int dp(vector<int> &v, int i){
	if(i == 0)
		return 0;
	if(memo[i] != -1)
		return memo[i];
	memo[i] = 0;
	for(int e : v){
	
		if(e <= i){
			if(!dp(v, i-e))
				memo[i] = 1;
		}
	}
	return memo[i];
}

signed main() { 
	cin.tie(0);
	cin.sync_with_stdio();
	int n, k; 
	cin>>n>>k;
	vector<int> v(n);
	for(int &i : v)
		cin>>i;
	cout<<(dp(v, k) ? "First" : "Second");
}


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

int main(){
  string s;
  int count = 700;
  cin >> s;
  if(s[0] == 'o'){
    count+=100;
  }
  if(s[1] == 'o'){
    count+=100;
  }
  if(s[2] == 'o'){
    count+=100;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
counts = int(input())
input_valus = list(map(int, input().split()))
if 0 in input_valus:
    print(0)
else:
    ans = 1
    for count in range(counts):
        if count > 0:
            ans = ans * input_valus[count]
        else:
            ans = input_valus[count]
        if ans > 1000000000000000000:
            ans = -1
            break
    print(ans)

Measured memory_bytes: 21532
from fractions import gcd
from functools import reduce
n = int(input())
l = list(map(int,input().split()))

def lcm(x,y):
  return (x*y)//gcd(x,y)

a = reduce(lcm,l,1)-1
f = 0
for i in l:
  f += a%i
print(f)

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

int main(){

	char a[1001];
	while(cin>>a, strcmp(a,"0")){ // 输入为0时结束程序 
		int n = 0;
		for(int i=0;i<strlen(a);i++) //将字符转换成整数 
			n += a[i] - '0';
		cout<<n<<endl;
	} 

	return 0;
}


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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define REP(i,n) for(ll i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  ll n, y;
  cin >> n >> y;
  for(ll i = 0; i <= n; i++){
    for(ll j = 0; j <= n-i; j++){
      ll k = n-(j+i);
      if(i*(ll)10000 + j*(ll)5000 + k*(ll)1000 == y){
        cout << i << " " << j << " " << k;
        return 0;
      }
    }
  }
  printf("-1 -1 -1");
}

Measured memory_bytes: 256
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 X = sc.nextInt();
		
		if(X >= A && X <= A + B) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
int main() {
	int a, b;
	scanf("%d %d",&a,&b);
	char str[a+b+1];
	scanf("%s",&str);
	int len = strlen(str);
	int flag = 0;
	for (int i = 0; i < len; i++)
	{
		if (48 <= str[i] && str[i] <= 57)
		{
			continue;
		}
		else 
		{
			if (i == a)
			{
				flag = 1;
			}
			else
			{
				flag = 0;
				break;
			}
		}
	}
	flag ? printf("Yes\n") : printf("No\n");
	return 0;
}

Measured memory_bytes: 1660
import math

N = int(input())

mod = 10 ** 9 + 7

if N >=2:
    zero_or_nine = 10**N - 8 **N
    zero = 9 ** N - 8 ** N
    nine = 9 ** N - 8 ** N
    zero_and_nine =  zero_or_nine - zero - nine
    print(zero_and_nine % mod)

else:
    print(0)

Measured memory_bytes: 11304
#include<stdio.h>
#include<string.h>
main(){

  char str[21]={0};
  int len,i;
  
  scanf("%s",str);
  len = strlen(str);
  
  for(i=len-1;i>=0;i--){
    printf("%c",str[i]);
  }
  printf("\n");
  
  return(0);
}

Measured memory_bytes: 524
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <stack>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	queue<int> q;
	vector<vector<pii>> g=vector<vector<pii>>(n+1,vector<pii>(0));
	vector<int> used(n+1,-1);
	FOR(i,1,n){
		int v,u,w;
		cin>>v>>u>>w;
		g[v].PB(MP(u,w));
		g[u].PB(MP(v,w));
	}
	q.push(1);
	used[1]=0;
	while(!q.empty()){
		int nw=q.front();
		q.pop();
		int l=g[nw].size();
		FOR(i,0,l){
			int to=g[nw][i].ST;
			int val=g[nw][i].ND;
			val=val&1;
			if(used[to]==-1){
				q.push(to);
				used[to]=used[nw]^val;
			}
		}
	}

	FORQ(i,1,n){
		cout<<used[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 6784
A,B = map(int,input().split())
ans = 0
if A > B:
    ans += A
    A -=1
    if A > B:
        ans += A
    else :
        ans += B
else :
    ans += B
    B -= 1
    if A > B:
        ans += A
    else :
        ans += B
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
bool get(vector<ll>a, int med)
{
	ll now = 0;
	for (int i = 0; i <= med; i++)now += a[i];
	for (int i = med + 1; i < a.size(); i++)
	{
		if (now + now >= a[i])now += a[i];
		else return false;
	}
	return true;
}
int main()
{
	int num;
	scanf("%d", &num);
	vector<ll>v;
	for (int i = 0; i < num; i++)
	{
		ll z;
		scanf("%lld", &z);
		v.push_back(z);
	}
	sort(v.begin(), v.end());
	int beg = 0, end = num - 1;
	for (;;)
	{
		if (beg == end)break;
		int med = (beg + end) / 2;
		if (get(v, med))end = med;
		else beg = med + 1;
	}
	printf("%d\n", num - beg);
}

Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//BEGIN CUT HERE
template<typename Data, typename T>
struct ReRooting{
  struct Node{
    int to,rev;
    Data data;
    Node(int to,int rev,Data data):to(to),rev(rev),data(data){}
  };

  using F1 = function<T(T,T)>;
  using F2 = function<T(T,Data)>;

  vector<vector<Node> > G;
  vector<vector<T> > ld,rd;
  vector<int> lp,rp;

  const F1 f1;
  const F2 f2;
  const T id;

  ReRooting(int n,const F1 f1,const F2 f2,const T id):
    G(n),ld(n),rd(n),lp(n),rp(n),f1(f1),f2(f2),id(id){}

  void add_edge(int u,int v,Data d){
    G[u].emplace_back(v,(int)G[v].size(),d);
    G[v].emplace_back(u,(int)G[u].size()-1,d);
  }

  T dfs(int v,int p){
    while(lp[v]!=p&&lp[v]<(int)G[v].size()){
      auto &e=G[v][lp[v]];
      ld[v][lp[v]+1]=f1(ld[v][lp[v]],f2(dfs(e.to,e.rev),e.data));
      lp[v]++;
    }
    while(rp[v]!=p&&rp[v]>=0){
      auto &e=G[v][rp[v]];
      rd[v][rp[v]]=f1(rd[v][rp[v]+1],f2(dfs(e.to,e.rev),e.data));
      rp[v]--;
    }
    if(p<0) return rd[v][0];
    return f1(ld[v][p],rd[v][p+1]);
  }

  vector<T> build(){
    for(int i=0;i<(int)G.size();i++){
      ld[i].assign((int)G[i].size()+1,id);
      rd[i].assign((int)G[i].size()+1,id);
      lp[i]=0;
      rp[i]=(int)G[i].size()-1;
    }
    vector<T> res;
    for(int i=0;i<(int)G.size();i++){
      res.emplace_back(dfs(i,-1));
    }
    return res;
  }
};
//END CUT HERE

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed YUKI_768(){
  int n;
  cin>>n;
  auto f1=[](int a,int b){return max(a,0)+max(b,0);};
  auto f2=[](int a,int d){return d-a;};
  ReRooting<int, int> G(n,f1,f2,0);
  for(int i=1;i<n;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G.add_edge(a,b,1);
  }
  auto res=G.build();
  vector<int> ans;
  for(int i=0;i<n;i++)
    if(1-res[i]>0) ans.emplace_back(i);
  cout<<ans.size()<<"\n";
  for(int x:ans) cout<<x+1<<"\n";
  cout<<flush;
  return 0;
};
/*
  verified on 2019/03/04
  https://yukicoder.me/problems/no/768
*/

signed DP_V(){
  int n,m;
  cin>>n>>m;
  auto f1=[m](int a,int b)->int{return (long long)a*b%m;};
  auto f2=[m](int a,int d)->int{return (a+d)%m;};
  ReRooting<int, int> G(n,f1,f2,1);
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G.add_edge(x,y,1);
  }
  auto ans=G.build();
  for(int x:ans) cout<<x<<endl;
  return 0;
}
/*
  verified on 2019/10/15
  https://atcoder.jp/contests/dp/tasks/dp_v
*/

signed main(){
  //YUKI_768();
  DP_V();
  return 0;
}


Measured memory_bytes: 28284
#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 main(){
	string s, t, u;
  	int a, b;
  	cin >> s >> t >> a >> b >> u;
  
  	if(u == s) a--;
  	else b--;
  	cout << a << " " << b << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;

int main() {
	int n; cin >> n;
	vector<int> b;
	vector<int >c;
	int B;
	for (int i = 0; i < n; i++) {
		cin >> B;
		b.push_back(B);
	}
	int index;
	for (int i = 0; i < n; i++) {
		index = -1;
		for (int j = 0; j < b.size(); j++) {
			if (j + 1 == b[j]) {
				index = j;

			}
		}
		if (index != -1) {
			c.push_back(b[index]);
			b.erase(b.begin() + index);
		}
		else {
			cout << index << endl;
			return 0;
		}
	}
	reverse(c.begin(), c.end());
	for (int i = 0; i < c.size(); i++) {
		cout << c[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256