akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;

struct Node {
    int key = 0;
    Node *parent, *left, *right;
};

Node *NIL;

struct Tree {
    Node *root;
};

void insert(Tree *T, int key) {
    Node *n = (Node *)malloc(sizeof(Node));
    n->key = key;
    n->parent = NIL;
    n->left = NIL;
    n->right = NIL;
    
    if (T->root == NIL) {
        T->root = n;
        return;
    }
    
    Node *x;
    x = T->root;
    bool continued = true;
    while (continued) {
        if (x->key >= key) {
            if (x->left != NIL) {
                x = x->left;
                continue;
            }
            
            n->parent = x;
            x->left = n;
            continued = false;
            return;
        }
        
        if (x->key <= key) {
            if (x->right != NIL) {
                x = x->right;
                continue;
            }
            
            n->parent = x;
            x->right = n;
            continued = false;
            return;
        }
    }
};

bool find(Node *N, int key) {
    Node *x;
    x = N;
    
    while(x != NIL && x->key != key) {
        if (key <= x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    if (x == NIL) {
        return false;
    }

    return true;
}

void inorder(Node *N) {
    if (N == NIL) {
        return;
    }

    inorder(N->left);
    cout << " " << N->key;
    inorder(N->right);
}

void preorder(Node *N) {
    if (N == NIL) {
        return;
    }
    
    cout << " " << N->key;
    preorder(N->left);
    preorder(N->right);
}

int main() {
    int N;
    scanf("%d", &N);
    Tree *T = (Tree *)malloc(sizeof(Tree));
    T->root = NIL;

    char command[10];
    int key;
    
    for (int i = 0; i < N; i++) {
        scanf("%s %d", command, &key);
        
        if (!strcmp(command, "insert")) {
            insert(T, key);
            continue;
        }
        
        if (!strcmp(command, "find")) {
            bool result = find(T->root, key);
            if (result) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
            continue;
        }
        
        if (!strcmp(command, "print")) {
            inorder(T->root);
            cout << endl;
            preorder(T->root);
            cout << endl;
            continue;
        }
    }
    
    return 0;
}



Measured memory_bytes: 21824
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

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

	if (a[5]=='1') cout << "TBD" << endl;
	else if (a[6]>'4') cout << "TBD" << endl;
	else cout << "Heisei" << endl;
}


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

int main() {
    string S;
    cin >> S;
    int N = S.length();
    vector<int> C(N, 0);
    
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') cnt++;
        else {
            C[i] += cnt/2;
            C[i-1] += (cnt+1)/2;
            cnt = 0;
        }
    }
    for (int i = N-1; i >= 0; i--) {
        if (S[i] == 'L') cnt++;
        else {
            C[i] += cnt/2;
            C[i+1] += (cnt+1)/2;
            cnt = 0;
        }
    }
    for (int i = 0; i < N; i++) cout << C[i] << ((i+1==N) ? '\n' : ' ');
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
   SPEED;
   int n,n1=5,k=0,t;
   cin>>n;
   if(n%2==1)
   {
       cout<<0;
   }
   else
   {
       while(n1<=n)
       {
           t=n/n1;
           t/=2;
           k+=t;
           n1*=5;
       }
       cout<<k;
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(3001)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
ll dp[MAXN][MAXN];
int main()
{
	fastio;
	int n;
	cin>>n;
	vi a(n);
	for(int i=0;i<n;i++)cin>>a[i];

	for(int k=0;k<=n-1;k++)
	{
		for(int i=0;i+k<=n-1;i++)
		{
			if(k==0)
			{
				dp[i][i]=a[i];
			}
			else
			{
				int j=k+i;
				dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
			}
		}
	}
	cout<<dp[0][n-1]<<endl;	
}


Measured memory_bytes: 70016
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    string s;
    cin>>s;
    int sum=0;
    rep(i,s.size()){
        sum+=s[i]-'0';
    }
    int n;
    n=stoi(s);
    if(n%sum==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);
    long c = long.Parse(input[2]);
    long answer = long.MaxValue;
		if(a%2 == 0 || b%2 == 0 || c%2 == 0) Console.WriteLine(0);
		else
    {
      answer = Math.Min(a*b,a*c);
      answer = Math.Min(b*c,answer);
      Console.WriteLine(answer);
    }
	}
}

Measured memory_bytes: 13140
a = int(input())
b = list(str(a))
if len(b) == 3:
    b = b[::-1]
    b.append("0")
    b = b[::-1]
if int(b[0])+int(b[1])+int(b[2])+int(b[3]) == 7:
    print(b[0]+"+"+b[1]+"+"+b[2]+"+"+b[3]+"=7")
elif int(b[0])-int(b[1])+int(b[2])+int(b[3]) == 7:
    print(b[0]+"-"+b[1]+"+"+b[2]+"+"+b[3]+"=7")
elif int(b[0])+int(b[1])-int(b[2])+int(b[3]) == 7:
    print(b[0]+"+"+b[1]+"-"+b[2]+"+"+b[3]+"=7")
elif int(b[0])+int(b[1])+int(b[2])-int(b[3]) == 7:
    print(b[0]+"+"+b[1]+"+"+b[2]+"-"+b[3]+"=7")
elif int(b[0])-int(b[1])-int(b[2])+int(b[3]) == 7:
    print(b[0]+"-"+b[1]+"-"+b[2]+"+"+b[3]+"=7")
elif int(b[0])-int(b[1])-int(b[2])-int(b[3]) == 7:
    print(b[0]+"-"+b[1]+"-"+b[2]+"-"+b[3]+"=7")
elif int(b[0])-int(b[1])+int(b[2])-int(b[3]) == 7:
    print(b[0]+"-"+b[1]+"+"+b[2]+"-"+b[3]+"=7")
elif int(b[0])+int(b[1])-int(b[2])-int(b[3]) == 7:
    print(b[0]+"+"+b[1]+"-"+b[2]+"-"+b[3]+"=7")

Measured memory_bytes: 3192
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
ll n,m,r,a,b,c,dp[1000],INF=(1LL<<60);
vector<PP> v;
bool Bell(void){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(dp[v[j].F.F]!=INF&&dp[v[j].F.S]>dp[v[j].F.F]+v[j].S){
                dp[v[j].F.S]=dp[v[j].F.F]+v[j].S;
                if(i==n-1&&v[j].F.S==n-1)return false;
            }
        }
    }
    return true;
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<1000;i++)dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        a--,b--,c*=-1;
        v.push_back({{a,b},c});
    }
    if(!Bell()){
        cout<<"inf"<<endl;
        return 0;
    }
    cout<<-dp[n-1]<<endl;
}


Measured memory_bytes: 384
from sys import stdin
n,m = map(int,stdin.readline().rstrip().split())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
li.sort()

yen = 0

for i in li:
    j,k = i
    if k >= m:
        yen += j*m
        break
    yen += j*k
    m -= k

print(yen)

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

int main()
{
  int N; cin >>N;
  int v[N],c[N];
  for (int i = 0; i<N;i++)
    cin >> v[i];
  for (int i = 0; i<N;i++)
    cin >> c[i];
  
  int max = 0;
  for (int bit; bit < (1<<N); bit++)
  {
    int x,y;
    x = 0;y = 0;
    for(int k = 0; k < N;k++)
    {
      if (bit & (1<<k)){
        x += v[k];
        y += c[k];
      }
    }
    if (max < x - y)
      max = x - y;
  }
  
  cout << max << endl;
}

Measured memory_bytes: 256
class Main {
	public static void main (String[] args) {
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				System.out.println(String.valueOf(i)+ "x" + String.valueOf(j) + "=" + String.valueOf(i * j));
			}
		}
	}
}

Measured memory_bytes: 17008
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;

int a[1000];

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

		int ans = 0;

		for (int i = 0; i < n; i++)
		{
			int mini = i;
			for (int j = i; j < n; j++)
				if (a[j] < a[mini])
					mini = j;
			swap(a[i], a[mini]);
			if (mini != i) ans++;
		}

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

Measured memory_bytes: 1164
// ABC051A - Sum of Three Integers

#include <bits/stdc++.h>
using namespace std;

int main() {
	int K, S;
	cin >> K >> S;

	int ans = 0;
	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K; y++) {
			int temp = S - x - y;
			if ((0 <= temp)&&(temp <= K)) {
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
import copy
sys.setrecursionlimit(2**20)
N, M, X = map(int, input().split())

A = [[] for _ in range(N)]
C = list()
for i in range(N):
    B = list(map(int, input().split()))
    C.append(B.pop(0))
    A[i] = B

ans = float("inf")
def dfs(T, cost, i):
    global ans
    TT = copy.deepcopy(T)
    if i == N:
        flag = True
        for t in TT:
            if not t >= X:
                flag = False
        if not flag:
            return
        # print(i, TT, cost)
        ans = min(ans, cost)
        return
    dfs(TT, cost, i+1)
    for j in range(M):
        TT[j] += A[i][j]
    dfs(TT, cost+C[i], i+1)

T = [0]*M
dfs(T, 0, 0)
if ans == float("inf"):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9348
#include <bits/stdc++.h>
#define lowbit(x) (x & -x)
#define jh(x, y) x ^= y ^= x ^= y
#define loc(x, y) (x - 1) * m + y
#define rg register
#define inl inline
#define PI 3.141592654
typedef long long ll;
const int N = 6e5 + 5, INF = 0x3f3f3f3f, mod = 998244353;
using namespace std;
namespace fast_IO {
	inl ll read() {
		rg char c;
		rg ll x = 0;
		rg bool flag = false;
		while ((c = getchar()) == ' ' || c == '\n' || c == '\r');
		if (c == EOF)return c; if (c == '-')flag = true; else x = c ^ 48;
		while ((c = getchar()) != ' ' && c != '\n' && c != '\r' && ~c)
			x = (x << 1) + (x << 3) + (c ^ 48);
		if (flag)return -x; return x;
	}
	inl ll max(rg ll a, rg ll b) { if (a > b)return a; return b; }
	inl ll min(rg ll a, rg ll b) { if (a < b)return a; return b; }
	void write(rg ll x) { if (x < 0)putchar('-'), x = -x; if (x >= 10)write(x / 10); putchar(x % 10 ^ 48); }
}
int p[N], b[N], nt[N], w[N], c[N], num;
inl void add(rg int z, rg int y, rg int x) {
	b[++num] = y, w[num] = z;
	nt[num] = p[x], p[x] = num;
	b[++num] = x, w[num] = z;
	nt[num] = p[y], p[y] = num;
}
void dfs(rg int x, rg int fa) {
	for (rg int e = p[x]; e; e = nt[e]) {
		if (b[e] == fa)continue;
		c[b[e]] = c[x] ^ (w[e] & 1);
		dfs(b[e], x);
	}
}

int main(void) {
	rg int n = fast_IO::read();
	for (rg int i = 1; i < n; ++i)add(fast_IO::read(), fast_IO::read(), fast_IO::read());
	c[1] = 1;
	dfs(1, 0);
	for (rg int i = 1; i <= n; ++i)fast_IO::write(c[i]), putchar('\n');
	return 0;
}

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

using namespace std;

typedef long long int lli;

vector<lli> enumDivisor(lli n) {
    vector<lli> res;
    for (lli i=1; i*i<=n; i++) {
        if (n%i == 0) {
            res.push_back(i);
            if (i*i != n) {
                res.push_back(n/i);
            }
        }
    }
    return res;
}

int main() {
    lli n, m;

    cin >> n >> m;

    auto div = enumDivisor(m);
    sort(div.begin(), div.end(), greater<lli>());

    for (auto e : div) {
        if (e*n <= m) {
            cout << e << endl;
            break;
        }
    }

    return 0;
}


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

int main(){
	int a,b;
    cin >> a >> b;
  
	if(a == b){
        cout << "Draw" << endl;
    }else if(a == 1){
      cout << "Alice" << endl;
    }else if(b == 1){
      cout << "Bob" << endl;
    }else if(a > b){
      cout << "Alice" << endl;
    }else{
      cout << "Bob" << endl;
    }
}

Measured memory_bytes: 256
import sys
n,m=map(int,input().split())
key=[-1 for i in range(n)]
ans=-1
f=False
for i in range(m):
    s,c=map(int,input().split())
    if key[s-1]==-1:
        key[s-1]=c
    elif key[s-1]!=c:
        print(-1)
        sys.exit()
for i in range(n):
    if key[i]==-1:
        if i!=0:
            key[i]=0
        elif n==1:
            key[i]=0
        else:
            key[i]=1
    key[i]=str(key[i])
ans=int("".join(key))
if 10**(n-1)<=ans<10**n:
  print(ans)
elif n==1 and ans==0:
  print(0)
else:
  print(-1)



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

int main() {
	int hand[5];
	while(cin >> hand[0], hand[0]) {
		for(int i = 1; i < 5; i++)
			cin >> hand[i];

		int win[5] = {-1,-1,-1,-1,-1};
		bool flg = true;
		for(int i = 0; i < 5; i++) {
			for(int j = 0; j < 5; j++) {
				if(i != j) {
					int tmp = (hand[j] - hand[i] + 3) % 3;
					if(win[i] == -1 && tmp != 0)
						win[i] = tmp;
					else if(win[i] != tmp && tmp != 0)
						flg = false;
				}
			}
		}

		if(flg) {
			for(int i = 0; i < 5; i++)
				cout << ((win[i] == 0 || win[i] == -1)? 3 : win[i]) << endl;
		}
		else {
			for(int i = 0; i < 5; i++)
				cout << 3 << endl;
		}
	}
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(100000)

n, m = map(int,input().split())
node = [[] for i in range(n + 1)]

for i in range(m):
    a, b = map(int,input().split())
    node[a].append(b)
    node[b].append(a)

q = int(input())
vdc = [[0] * 3 for i in range(q)]
for i in range(q):
    vdc[i][0], vdc[i][1], vdc[i][2] = map(int, input().split())
vdc = vdc[::-1]

ans = [0] * (n + 1)
visited = [[0] * 11 for i in range(n + 1)]
def f(v, d, c):
    if d < 0:
        return
    if visited[v][d]:
        return

    visited[v][d] = 1
    if ans[v] == 0:
        ans[v] = c
        #print("ans", v, ans[v])

    for x in node[v]: #頂点xは頂点vに隣接する頂点
        f(x, d - 1, c)

for v, d, c in vdc:
    f(v, d, c)

for i in range(n):
    print(ans[i + 1])

Measured memory_bytes: 55388
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int r, d, a;
    cin >> r >> d >> a;

    rep(i, 0, 10)
    {
        a = r * a - d;
        cout << a << endl;
    }
}

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

flag = 1
temp_1 = 0
temp = 0
for i in range(n):
    temp += a[i]
    if flag * temp <= 0:
        temp_1 += 1 - flag * temp
        temp = flag
    flag *= -1

flag = -1
temp_2 = 0
temp = 0
for i in range(n):
    temp += a[i]
    if flag * temp <= 0:
        temp_2 += 1 - flag * temp
        temp = flag
    flag *= -1

print(min(temp_1, temp_2))

Measured memory_bytes: 14468
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int main(void){
    int n,k;
    cin>>n>>k;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    cin>>arr[i];
    int dp[n+1][k+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        int sum[k+1];
        sum[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            sum[j]=(sum[j-1]+dp[i-1][j])%mod;
        }
        for(int j=0;j<=k;j++){
            int fake=sum[j];
            int unreach=j-arr[i]-1;
            if(unreach>=0){
                fake=(fake-sum[unreach]+mod)%mod;
            }
            dp[i][j]=fake;
        }
    }
    /*for(int i=0;i<=n;i++){
        for(int j=0;j<=k;j++)
        cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[n][k]<<endl;
}

Measured memory_bytes: 40064
#include <iostream>

using namespace std;

int main()
{
    size_t K;
    cin >> K;

    size_t a = 7 % K;

    for (size_t n = 1; n <= K; ++n)
    {
        if (a == 0)
        {
            cout << n << endl;
            return 0;
        }
        else
        {
            a = (a * 10 + 7) % K;
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using M = map<string,ll>;


int main(){
    ll N;
    cin >> N;
    ll T=sqrt(N);
    ll k;
    for(int i=T;i>0;i--){
        if(N%i==0){k=i;break;}
    ;}
    cout<<k+N/k-2<<endl;

}  



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int dp[100001][3];

int main(){
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif

    fast_io();
    
    int n;
    cin>>n;

    vector<vector<int > > a(n+1, vector<int>(3, 0));

    for(int i=0; i<n; i++){
        int x, y, z;
        cin>>x>>y>>z;

        a[i][0] = x;
        a[i][1] = y;
        a[i][2] = z;
    }

    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    for(int i=1; i<n; i++){
        dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][0], dp[i-1][1]);
    }    

    cout<<max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2])<<"\n";

    return 0;

}
  

Measured memory_bytes: 9712
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <iomanip>
#include <numeric>

using namespace std;

const int N = 2e5 + 5;

int d[N];
vector<pair<int, int>> g[N];
int color[N];
int weight[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        --v;
        --u;
        g[v].emplace_back(u, i);
        g[u].emplace_back(v, i);
    }
    vector<int> kek(n);
    iota(kek.begin(), kek.end(), 0);
    sort(kek.begin(), kek.end(), [&](int a, int b) {
        return d[a] < d[b];
    });
    fill(weight, weight + m, 1e9);
    for (int i = 0; i < n; i++) {
        int v = kek[i];
        bool f = false;
        for (auto e : g[v]) {
            if ((color[v] != color[e.first] || color[v] * color[e.first] == 0) && d[e.first] <= d[v]) {
                if (color[v]) {
                    color[e.first] = 3 - color[v];
                }
                if (color[e.first]) {
                    color[v] = 3 - color[e.first];
                }
                if (!color[v]) {
                    color[v] = 1;
                    color[e.first] = 2;
                }
                weight[e.second] = d[v];
                f = true;
                break;
            }
        }
        if (!f) {
            cout << -1 << endl;
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << "BW"[color[i] == 1];
    }
    cout << '\n';
    for (int i = 0; i < m; i++) {
        cout << weight[i] << '\n';
    }
    return 0;
}

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

int main() {
    int k;
    cin >> k;
    vector<ll> list;
    rep(i,9) list.push_back(i+1);
    while (true) {
        if (k <= list.size()) {
            cout << list[k-1] << endl;
            return 0;
        }
        k -= list.size();
        vector<ll> tmp;
        rep(i,list.size()) {
            for (int j = -1; j <= 1; j++) {
                int d = list[i] % 10 + j;
                if (d < 0 || 9 < d) continue;
                tmp.push_back(list[i]*10+d);
            }
        }
        swap(tmp,list);
    }
}

Measured memory_bytes: 1712
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int[][] rooms_1 = new int[3][10];
        for (int a = 0; a < 3; a ++){
            for (int b = 0; b < 10; b ++)
                rooms_1[a][b] = 0;
        }
        int[][] rooms_2 = new int[3][10];
        for (int a = 0; a < 3; a ++){
            for (int b = 0; b < 10; b ++)
                rooms_2[a][b] = 0;
        }
        int[][] rooms_3 = new int[3][10];
        for (int a = 0; a < 3; a ++){
            for (int b = 0; b < 10; b ++)
                rooms_3[a][b] = 0;
        }
        int[][] rooms_4 = new int[3][10];
        for (int a = 0; a < 3; a ++){
            for (int b = 0; b < 10; b ++)
                rooms_4[a][b] = 0;
        }
        int cnt = input.nextInt();
        int unit = 0;
        int floor = 0;
        int room = 0;
        int number = 0;
        for(int i = 0; i < cnt; i ++){
            unit = input.nextInt();
            floor = input.nextInt();
            room = input.nextInt();
            number = input.nextInt();
            deal(unit, floor, room, number, rooms_1, rooms_2, rooms_3, rooms_4);
        }
        output(rooms_1, rooms_2, rooms_3, rooms_4);
    }
    
    public static void deal(int u, int f, int r, int n, int[][] a, int[][] b, int[][] c, int[][] d){
        switch (u){
            case 1 :
                a[f-1][r-1] += n;
                break;
            case 2 :
                b[f-1][r-1] += n;
                break;
            case 3 :
                c[f-1][r-1] += n;
                break;
            case 4 :
                d[f-1][r-1] += n;
                break;
            default :
                break;
        }
    }
    
    public static void output(int[][] a, int[][] b, int[][] c, int[][] d){
        for (int m = 0; m < 3; m ++){
            for (int o = 0; o < 10; o ++)
                System.out.print(" " + a[m][o]);
            System.out.println();
        }
        System.out.println("####################");
        for (int m = 0; m < 3; m ++){
            for (int o = 0; o < 10; o ++)
                System.out.print(" " + b[m][o]);
            System.out.println();
        }
        System.out.println("####################");
        for (int m = 0; m < 3; m ++){
            for (int o = 0; o < 10; o ++)
                System.out.print(" " + c[m][o]);
            System.out.println();
        }
        System.out.println("####################");
        for (int m = 0; m < 3; m ++){
            for (int o = 0; o < 10; o ++)
                System.out.print(" " + d[m][o]);
            System.out.println();
        }
    }
}


Measured memory_bytes: 28844
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (ll i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (ll i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (ll i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (ll i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (ll i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (ll i = (x), a = 0; a < (N);   \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;

// right is true, left is false.
template<class T, class F>
T bSearch(T l, T r, F func, T diff = 1){
    while (std::abs(r - l) > diff) {
        T m = (l + r) / 2;
        (func(m) ? r : l) = m;
    }
    return r;
}

signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);

    ll n;
    cin >> n;
    vll x(n);

    for0(i, n)cin >> x[i];

    ll result = numeric_limits<ll>::max();

    forn(p, 100){
        int now = 0;
        for0(i, n){
            now += (x[i] - p) * (x[i] - p);
        }
        result = min(result, now);
    }

    cout << result;

    // cout << bSearch(0ll, ll(1e5),
    //                 [&](ll p){
    //                     ll result = 0;
    //                     for0(i, n){
    //                         result += (x[i] - p) * (x[i] - p);
    //                     }
    //                     return result;
    //                 });

    return 0;
}


Measured memory_bytes: 256
program prob6
    implicit none
    integer(16)::n, x, d(0:50), p(0:50), b(0:50), tmp, ans
    integer::i, j
    read(*,*) n, x

    tmp = 1
    d(0) = 1
    p(0) = 1
    b(0) = 0
    do i = 1, 50
        d(i) = d(i-1)*2 + 3
        p(i) = p(i-1)*2 + 1
        b(i) = b(i-1)*2 + 2
    end do
    if(x == d(n)) then
        write(*,*) p(n)
        stop
    end if
    ans = 0
    tmp = x
    do i = n-1, 0, -1
        tmp = tmp - 1
        !write(*,*) tmp
        if(tmp >= d(i)) then
            ans = ans + p(i)
            tmp = tmp - d(i)
            if(tmp > d(i)) then
                ans = ans + p(i) + 1
                tmp = tmp - d(i) - 1
            else if(tmp > 0) then
                ans = ans + 1
                tmp = tmp - 1 
            end if
        end if
        !write(*,*) ans
    end do
    write(*,*) ans
    stop
end program

Measured memory_bytes: 2796
#include<stdio.h>
int main()
{
   int a,b;
   scanf("%d %d",&a,&b);
   if(a==0){
      printf("%d",b+b/100);
   }
   else if(a==1){
      printf("%d",b*100+b*100/10000*100);
   }
   else{
      printf("%d",b!=100?b*10000:(b+1)*10000);
   }
}


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

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

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

	int d; cin >> d;

	cout << "Christmas";
	for (int i = d;i < 25;i++){
		cout << " Eve";
	}	

	cout << endl;

	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    int v[n];
    int c[n];
    for(int i=0; i<n; i++)
    {
        scanf("%d",&v[i]);
    }
    for(int i=0; i<n; i++)
    {
        scanf("%d",&c[i]);
        if(c[i]<v[i])
        {
            sum+=(v[i]-c[i]);
        }
    }
    printf("%d\n",sum);
    return 0;
}

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

int main()
{
	int N;
	int M;
	int x[20];
	int y[20];
	char d;
	int l;

	while (cin >> N && N != 0)
	{
		int flag[21][21] = {};
		int initX = 10;
		int initY = 10;
		int cnt = 0;

		for (int i = 0; i < N; i++)
		{
			cin >> x[i];
			cin >> y[i];
			flag[y[i]][x[i]] = 1;
		}

		cin >> M;

		for (int i = 0; i < M; i++)
		{
			cin >> d;
			cin >> l;
			int dx = 0;
			int dy = 0;

			for (int k = 0; k <= l; k++)
			{
				if (d == 'S' || d == 'W')
				{
					if (d == 'S')
					{
						for (int j = 0; j < N; j++)
						{
							if (x[j] == initX && y[j] == initY - k && flag[y[j]][x[j]] == 1)
							{
								cnt++;
								flag[y[j]][x[j]] = 0;
							}
						}
					}
					else
					{
						for (int j = 0; j < N; j++)
						{
							if (x[j] == initX - k && y[j] == initY && flag[y[j]][x[j]] == 1)
							{
								cnt++;
								flag[y[j]][x[j]] = 0;
							}
						}
					}
				}
				else
				{
					if (d == 'N')
					{
						for (int j = 0; j < N; j++)
						{
							if (x[j] == initX && y[j] == initY + k && flag[y[j]][x[j]] == 1)
							{
								cnt++;
								flag[y[j]][x[j]] = 0;
							}
						}
					}
					else
					{
						for (int j = 0; j < N; j++)
						{
							if (x[j] == initX + k && y[j] == initY && flag[y[j]][x[j]] == 1)
							{
								cnt++;
								flag[y[j]][x[j]] = 0;
							}
						}
					}
				}
			}
			if (d == 'S')
			{
				dy = -l;
			}
			else if (d == 'N')
			{
				dy = l;
			}
			else if (d == 'W')
			{
				dx = -l;
			}
			else
			{
				dx = l;
			}

			initX += dx;
			initY += dy;
		}
		if (cnt == N)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1152
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	string s;
	cin >> s;
	int answer = MAXN;
	for(int i = 0; i < s.size() - 2; ++i) answer = min(answer, abs(753 - stoi(s.substr(i, 3))));
	cout << answer << '\n';
}

Measured memory_bytes: 3672
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;

int n,m,c[100005],cnt[5];
vector<int> g[100005];
bool f;

void dfs(int x,bool col){
    c[x]=col+1;
    cnt[col]++;
    for(size_t i=0;i<g[x].size();i++){
        if(c[g[x][i]]==0)dfs(g[x][i],!col);
        else if(c[g[x][i]]==col+1)f=true;
    }
}

int main(){
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0,false);
    if(f)printf("%lld\n",static_cast<long long>(n)*(n-1)/2-m);
    else printf("%lld\n",static_cast<long long>(cnt[0])*cnt[1]-m);
    return 0;
}


Measured memory_bytes: 6912
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<string>
#include<cmath>
using namespace std;
int main() {
	
	double x1, x2, y1,y2;
	double dis;

	cin >> x1 >> y1 >> x2 >> y2;

	dis = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));

	printf("%.8lf\n", dis);


	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int INF = 1e9;
const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



void solve()
{
    int n, x, t; cin>>n>>x>>t;
    int cnt = 0;
    int ans = 0;
    while(cnt < n)
    {
        ans += t;
        cnt += x;
    }
    cout<<ans<<endl;
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    ll x = INF; x++;
    return 0;
    
}



/*before sub
TEST: 0(1 by 1 too), 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t, early/late mod
RE: double dec, integer overflow(ll or 1LL mult)
*/





Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define INF 100000000000000000LL
using namespace std;
typedef long long LL;
LL f(LL b,LL n)
{
	if(n<b)
		return n;
	return f(b,n/b)+n%b;
}
bool Check(LL b,LL n,LL s)
{
	if(f(b,n)==s)
		return true;
	return false;
}
int main()
{
	LL n,s;
	scanf("%lld %lld",&n,&s);
	if(s>n)
	{
		printf("-1\n");
		return 0;
	}
	if(s==n)
	{
		printf("%lld\n",n+1LL);
		return 0;
	}
	LL n1=n-s;
	LL ans=INF;
	for(LL i=1LL;i*i<=n1;i++)
	{
		if(n1%i==0)//i=b-1
		{
			if(Check(i+1,n,s)==true)
				ans=min(ans,i+1LL);
			if(n1/i!=i&&Check(n1/i+1LL,n,s)==true)
				ans=min(ans,n1/i+1LL);
		}
	}
	if(ans==INF)
		printf("-1\n");
	else
		printf("%lld\n",ans);
	return 0;
}
/*
100000000000 3
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
int m;
while(cin >>n>>m){
if(n==0){break;}
if(n==2){n=m+31;}
if(n==3){n=m+60;}
if(n==4){n=m+91;}
if(n==5){n=m+121;}
if(n==6){n=m+152;}
if(n==7){n=m+182;}
if(n==8){n=m+213;}
if(n==9){n=m+244;}
if(n==10){n=m+274;}
if(n==11){n=m+305;}
if(n==12){n=m+335;}
n=n%7;
if(n==1){cout <<"Thursday";}
if(n==2){cout <<"Friday";}
if(n==3){cout <<"Saturday";}
if(n==4){cout <<"Sunday";}
if(n==5){cout <<"Monday";}
if(n==6){cout <<"Tuesday";}
if(n==0){cout <<"Wednesday";}
cout <<endl;}}

Measured memory_bytes: 1156
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
using namespace std;

struct Rect{
	int height;
	int pos;
};

int HistgramRectangle(vector<int> &hist){
	hist.push_back(0);
	int n=hist.size();
	stack<Rect> st;
	Rect tmp_rect, past_rect;
	int Max=0;

	for (int i=0;i<n;i++){
		tmp_rect.height=hist[i];
		tmp_rect.pos=i;

		if(st.empty()){
			st.push(tmp_rect);
		}else{
			if(st.top().height < hist[i]){
				st.push(tmp_rect);
			}else if(st.top().height > hist[i]){
				int stp = i;
				while(st.top().height >= hist[i] && !st.empty()){
					past_rect = st.top();
					st.pop();
					Max=max(Max, past_rect.height * (i-past_rect.pos));
					stp = past_rect.pos;
					if(st.empty()){
						break;
					}
				}
				tmp_rect.pos = stp;
				st.push(tmp_rect);
			}
		}
	}
	return Max;
}

int main(){
	int H,W,tmp,result=0;
	cin >> H >> W;
	vector<int> hist(W);

	for (int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> tmp;
			if(tmp==1){
				hist[j] = 0; 
			}else{
				hist[j]+=1;
			}
		}
		result = max(HistgramRectangle(hist),result);
	}
	cout << result << endl;
	return 0;
}

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

int n,a;

int main(){
	scanf("%d",&n);
	if (n==1)	printf("Hello World");
	else {
		scanf("%d%d",&n,&a);
		cout<<n+a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        if 4*h*n-N*n-N*h>0 and (N*h*n)%(4*h*n-N*n-N*h)==0:
            print(h, n, (N*h*n)//(4*h*n-N*n-N*h))
            exit()

Measured memory_bytes: 9188
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rrep(i,a,b) for(int i = a; i >=b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define all(x) (x).begin(),(x).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using ii = pair<int, int>;
using pli = pair<ll, int>;
using vi = vector<int>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using pil = pair<int,ll>;
using vvi = vector<vi>;
using vpi = vector<ii>;

const int N = 100100;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if( abs( a - c) <= d ){
		cout<<"Yes"<<nl;
		return 0;
	}
	if( abs( a - b) <= d and abs(b - c) <= d){
		cout<<"Yes"<<nl;
		return 0;
	}
	cout<<"No"<<nl;
	return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>


using namespace std;
#define INF 100100100100100100

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;
typedef pair<ll, ll> PI;

int main() 
{
    ll n; cin >> n;
    ll ans = INF;

    ll i = 1;
    while(i*i <= n) {
        if((n%i) == 0) {
            ll tmp = n/i;
            ans = min(ans, (i-1) + (n/i)-1); 
        }
        i++;
    }
    cout << ans << endl;
    return 0;
}




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

int main()
{
    long long n,m;
    cin>>n>>m;
    long long a[n],sum=0;
    for(int i=0; i<n; i++)
        cin>>a[i];
    sort(a,a+n);
    long long x=n-m;
    for(int i=0; i<x; i++)
        sum+=a[i];
    cout<<sum<<endl;
    return 0;
}


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

int main() {
  string s,t;cin>>s>>t;
  rep(i,s.size()){
    s=s.substr(1)+s[0];
    if(s==t){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int kaijou(int n, int m);
int S[50],n1;
int main(){
  int n2,m;
  int i;
 
  scanf("%d",&n1);
  
 
 for(i=0; i<n1; i++){
   scanf("%d",&S[i]);
 }

 
 scanf("%d",&n2);

 for(i=0; i<n2; i++){
   scanf("%d",&m);
   if(kaijou(0,m)){
     printf("yes\n");
   }

   else{
     printf("no\n");
 }
 }

   return 0;
 }

   


int kaijou(int i,int m){

  if(m==0){
    return 1;
  }
  if(i>=n1){
    return 0;
  }


  return kaijou(i+1,m)||kaijou(i+1,m-S[i]);
  
 }



Measured memory_bytes: 2108
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

int main(){
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i = 0; i < n; i++){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(a,a+n);
  for(int i = 0; i < n; i++){
    if(b[i]!=a[n-1]){
      cout<<a[n-1]<<endl;
    }
    else{
      cout<<a[n-2]<<endl;
    }
  }
  return 0;
}

  



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

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

  ll ans = N * N * N;
  cout << ans << endl;
}

Measured memory_bytes: 256
# frozen_string_literal: true

require 'prime'
n = gets.to_i

class Integer
  def divisors
    return [1] if self == 1

    Prime.prime_division(self).map do |e|
      Array.new(e[1] + 1).map.with_index do |_e, i|
        e[0]**i
      end
    end.reduce { |p, q| p.product(q) }.map do |a|
      [a].flatten.inject(&:*)
    end.sort
  end
end

mid = Math.sqrt(n)
ds = n.divisors.sort_by { |e| (e - mid).abs }

puts ds[0..1].map { |e| n / e + e - 2 }.min


Measured memory_bytes: 3832
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int N = nextInt();
		int A = nextInt();


		System.out.println(N*A%2==0?"Even":"Odd");

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
#include <stdio.h>

int main(void)
{
  int i;
  long long sum;
  int n;

  i = 0;
  sum = 0;
  scanf("%d", &n);
  while (++i <= n)
  {
    if (i % 3 == 0)
      continue;
    if (i % 5 == 0)
      continue;
    sum += i;
  }
  printf("%lld\n", sum);
  return (0);
}

Measured memory_bytes: 1708
#include <cstdio>

auto main() -> int
{
  auto numHA = 0;
  std::scanf("%d\n", &numHA);
  for (int i = 0; i < numHA; ++i) {
    auto ch = std::getchar();
    if (ch == 'Y') {
      std::printf("Four\n");
      return 0;
    }
    std::getchar(); /* SKIP SPACE */
  }
  std::printf("Three\n");
  return 0;
}


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

int main()
{
  while(true)
  {
    for (int i=0; i<3; i++)   //  dataset
    {
      string serves;
      getline(cin, serves);
      if ( serves[0] == '0' ) return 0;
      const char* str = serves.c_str();

      int score[2] = { 0, 0, };

      for (int i=1; str[i]; i++)    //  得点入力
      {
        switch(serves[i])
        {
          case 'A':
            score[0]++;
            break;
          case 'B':
            score[1]++;
            break;
        }
      }
      //  最後の一点
      if ( 10 <= score[0] && 10 <= score[1] )
      {
        if ( score[0] < score[1] )
        {
          score[1]++;
        }
        else
        {
          score[0]++;
        }
      }
      else if ( score[0] == 10 )
      {
        score[0]++;
      }
      else if ( score[1] == 10 )
      {
        score[1]++;
      }
      cout << score[0] << ' ' << score[1] << endl;
    }
  }
}

Measured memory_bytes: 1176