akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<string>

using namespace std;

int main()
{
	int n, q;
	cin>>n>>q;
	
	queue< pair<string, int> > ps;
	string p;
	int t;
	for( int i=0; i<n; i++ ) {
		cin>>p>>t;
		ps.push( make_pair( p, t ) );
	}
	
	int progress = 0;
	pair<string, int> tmp;
	while( !ps.empty( ) ) {
		tmp = ps.front( );
		ps.pop( );
		if( tmp.second <= q ) {
			progress += tmp.second;
			cout<<tmp.first<<' '<<progress<<'\n';
		} else {
			tmp.second -= q;
			ps.push( tmp );
			progress += q;
		}	 
	}

    return 0;
}

Measured memory_bytes: 4404
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>

using namespace std;

int T[1000], P[1000], R[1000], tID[1000][500], pID[1000][500], Time[1000][500], msg[1000][500], n = 0;

int main() {
	while (cin >> T[n] >> P[n] >> R[n]) {
		if (T[n] == 0)break;
		for (int j = 0; j < R[n]; j++) {
			string messege;
			cin >> tID[n][j] >> pID[n][j] >> Time[n][j] >> messege;
			if (messege == "CORRECT")msg[n][j] = 1;
			else msg[n][j] = 0;
		}
		n++;
	}
	for (int i = 0; i < n; i++) {
		vector<pair<int, int> > AP, temp;
		AP.resize(T[i]);
		int WA[50][10]{ 0 };
		for (int j = 0; j < R[i]; j++) {
			if (msg[i][j] == 0) {
				WA[tID[i][j] - 1][pID[i][j] - 1]++;
			}
			else {
				AP[tID[i][j] - 1].first--;
				AP[tID[i][j] - 1].second += Time[i][j] + WA[tID[i][j] - 1][pID[i][j] - 1] * 1200;
			}
		}
		temp = AP;
		sort(temp.begin(), temp.end());
		int j = 0, k = 0, memo[50]{0};
		while (j < T[i]) {
			if (memo[k] > 0) {
				k++;
				continue;
			}
			if (temp[j] == AP[k]) {
				cout << k + 1 << " " << -temp[j].first << " " << temp[j].second << endl;
				j++;
				memo[k]++;
				k = 0;
			}
			else k++;
		}
	}
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;


int main(){
  int i,j;
  string N;
  cin>>N;
  if(N.at(N.size()-1)-'0'==3)cout<<"bon"<<endl;
  else if(N.at(N.size()-1)-'0'==0||N.at(N.size()-1)-'0'==1||N.at(N.size()-1)-'0'==6||N.at(N.size()-1)-'0'==8)cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>

using namespace std;

int main(){
	string str;
  	cin >> str;
  	for(int i=1;i<str.length();i++){
		if(str[i]==str[i-1]){
			cout << "Bad" << endl;
          	break;
        }
      	if(i==str.length()-1){
          	cout << "Good" << endl;
        }
    }
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2000;
bitset<N> left_wins[N];
bitset<N> right_wins[N];
bitset<N> wins[N];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; ++i) {
		string str;
		cin >> str;
		for (int j = 0; j < i; ++j) {
			if (str[j] == '1') wins[i][j] = 1;
			else wins[j][i] = 1;
		}
	}
	for (int b = 0; b < n; ++b) {
		right_wins[b][b] = 1;
		left_wins[b][b] = 1;
		for (int a = b-1; a >= 0; --a) {
			bitset<N> mask;

			mask = wins[b] & left_wins[a] & right_wins[b-1];
			if (mask.count() > 0) left_wins[a][b] = 1;
			mask = wins[a] & left_wins[a+1] & right_wins[b];
			if (mask.count() > 0) right_wins[b][a] = 1;
		}
	}

	bitset<N> res = left_wins[0] & right_wins[n-1];
	cout << res.count() << '\n';
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	VS str = { "alert","safe","warning" };

	int n; cin >> n;
	rep(i, n) {
		int h, m; char c;
		cin >> h >> c >> m;

		double a1 = (double)h * 30. + (double)m * 0.5, a2 = (double)m * 6.;
		double diff = abs(a1 - a2);
		diff = diff > 180. ? 360. - diff : diff;

		int ans;
		if (0. <= diff && diff < 30.)ans = 0;
		else if (90. <= diff && diff <= 180.)ans = 1;
		else ans = 2;

		Cout(str[ans]);
		//cout << "Angle : " << diff << endl;
	}
}


Measured memory_bytes: 3116
def main():
    from operator import itemgetter
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = [int(input()) for _ in range(N)]

    it = iter(sorted(enumerate(A, start=1), key=itemgetter(1), reverse=True))
    i, ma1 = next(it)
    _, ma2 = next(it)

    for j in range(1, N + 1):
        if j == i:
            print(ma2)
        else:
            print(ma1)


if __name__ == '__main__':
    main()


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

int n;

int parent(int i);
int left(int i);
int right(int i);
void maxHeap(int node[], int i);
void buildMaxHeap(int node[]);

int main() {
	int i, node[500000];
	cin >> n;
	for (i = 1; i <= n; i++) cin >> node[i];
	
	buildMaxHeap(node);

	for (i = 1; i <= n; i++)cout << " " << node[i];
	cout << endl;

	return 0;
}

int parent(int i) {
	return i / 2;
}

int left(int i) {
	return 2 * i;
}

int right(int i) {
	return 2 * i + 1;
}

void maxHeap(int node[], int i) {
	int r, l, largest;

	if (left(i) <= n)l = left(i);
	else l = i;
	if (right(i) <= n)r = right(i);
	else r = i;
	
	if (node[l] < node[r])largest = r;
	else largest = l;

	if (node[largest] < node[i])largest = i;
	
	if (largest != i) {
		swap(node[i], node[largest]);
		maxHeap(node, largest);
	}
}

void buildMaxHeap(int node[]) {
	int i;
	for (i = n / 2; i > 0; i--)maxHeap(node, i);
}

Measured memory_bytes: 5036
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

std::vector<std::vector<int>> g;

int main(){
	int n, m; cin >> n >> m; g.resize(n);
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}
	
	bool f = true;
	std::set<int> st; st.insert(0); st.insert(g[0][0]);
	std::deque<int> qu; qu.push_front(0); qu.push_back(g[0][0]);
	while(f){
		f = false;
		for(auto e : g[qu.front()]){
			if(st.count(e)) continue;
			qu.push_front(e);
			st.insert(e);
			f = true;
			break;
		}
		
		for(auto e : g[qu.back()]){
			if(st.count(e)) continue;
			qu.push_back(e);
			st.insert(e);
			f = true;
			break;
		}
	}
	
	cout << qu.size() << endl;
	while(!qu.empty()){
		cout << qu.front() + 1 << " "; qu.pop_front();
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 11392
import Data.List
f:: [Int]->Int
f [] = 0
f [x] =  if x `mod`2== 0 && x `mod` 3 == 0 then 0 else if x`mod`2== 0 && x `mod` 5 == 0 then 0 else if x `mod` 2 /=0 then 0  else 1

f (x:xs) = if x`mod`2== 0 && x `mod` 3==0 then 0 + f xs else if x`mod`2== 0 && x `mod` 5 == 0 then 0 + f xs else if x `mod` 2 /=0 then 0+ f xs else 1+f xs

main = do
  _ <- getLine
  s <- map read.words<$>getLine
  if f s == 0 then putStrLn "APPROVED" else putStrLn "DENIED"

Measured memory_bytes: 892
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int main(){
	int n, l, i, j, flag, m, t, k;
	char a[111][111];
	int b[111];
	while(~scanf("%d %d", &n, &l)){
		getchar();
		for(i = 0; i < n; i++){
			scanf("%s", a[i]);
			getchar();
		}
		for(i = 0; i < n - 1; i++)
			for(j = i + 1; j < n; j++){
				if(strcmp(a[i], a[j]) > 0){
					for(k = 0; k < l; k++){
						t = a[i][k];
						a[i][k] = a[j][k];
						a[j][k] = t;
					}
				}
			}
		for(i = 0; i < n; i++)
			printf("%s", a[i]);
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main(){
	string s;
	getline(cin, s);
	int st = 0;
	for(string::iterator it = s.begin(); it != s.end(); it++){
		if(*it == 'A'){
			st = 1;
		}
		else if(*it == 'C'){
			if(st == 1){
				st = 2;
				break;
			}
		}
		else
			st = 0;
	}
	cout << (st == 2 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int H, W; 
	cin >> H >> W; 
	int dp[1010][1010] = {}; 
	dp[0][0] = 1; 
	char C[1010][1010] = {}; 
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> C[i][j]; 
		}
	}
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(C[i][j] == '.'){
				if(i == 0 && j > 0){dp[i][j] = dp[i][j-1];}
				else if(i > 0 && j == 0){dp[i][j] = dp[i-1][j];}
				else if(i > 0 && j > 0){dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % 1000000007;}
            }
		}
	}
	cout << dp[H-1][W-1] << endl; 
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
int main()
{
	ll n;
	cin>>n;
	vec a(n);
	floop(i,0,n)
	cin>>a[i];
	ll ans=0;
	floop(i,0,n)
	{
		if(i%2==0 && a[i]%2!=0)
		ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
using namespace std;
int ans,n,ab;
int main(){
	scanf("%d",&n);
	for (register int c=1;c<n;++c){
		ab=n-c;
		if (ab==1) ++ans;
		else ans+=2;
		for (int i=2;i*i<=ab;++i){
			if (ab%i==0){
				++ans;
				if (ab/i!=i) ++ans;
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int A[500010];
int B[500010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    S = '>' + S;
    S = S + '<';
    int ans = 0;
    rep(i, S.length()) {
        if (i + 1 < S.length() && S[i] == '>' && S[i + 1] == '<') {
            A[i] = 0;
            B[i] = true;
        }
    }
    rep(i, (int)S.length() - 1) {
        if (B[i]) {
            int k = i;
            while(k > 0 && S[k] == '>') {
                A[k - 1] = max(A[k - 1], i - k + 1);
                k--;
            }
            k = i + 1;
            while(k < S.length() - 1 && S[k] == '<') {
                A[k] = max(A[k], k - i);
                k++;
            }
        }
    }
    //cout << S << endl;
    rep(i, (int)S.length() - 1) {
        ans += A[i];
        //cout << A[i];
    }
    //cout << endl;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 8516
n = int(input())
book = [[0] * 9 for i in range(9)]

ans = 0

for i in range(1, n+1) :
    pre = int(str(i)[0])
    end = int(str(i)[-1])

    if end != 0 :
        book[pre-1][end-1] += 1

for i in range(9) :
    for j in range(i, 9) :
        if i == j :
            ans += book[i][j] * book[j][i]
            #print('=', i, j, book[i][j] * book[j][i])
            continue
        if book[i][j] != 0 and book[j][i] != 0 :
            ans += book[i][j] * book[j][i] * 2
            #print('!', i, j, book[i][j] * book[j][i] * 2)

#for i in range(9) :
#    print(book[i])

print(ans)


Measured memory_bytes: 3064
#coding:utf-8
from collections import defaultdict
N,C=map(int,raw_input().split())
S=[];T=[];C=[]
for i in range(N):
    s,t,c=map(int,raw_input().split())
    S.append(s);T.append(t);C.append(c)
beg=defaultdict(int)
end=defaultdict(int)
F=defaultdict(list)
for s,t,c in zip(S,T,C):
    F[c].append((s,t))
for k,v in F.iteritems():
    v.sort()
    buf=[]
    s,t=v[0]
    buf.append([s,t])
    for ss,tt in v[1:]:
        if t!=ss:
            buf.append([ss,tt])
        else:
            buf[-1][1]=tt
        s,t=ss,tt
    for s,t in buf:
        beg[2*s-1]+=1
        end[2*t]+=1
ans=-1; cur=0
for i in range(0,max(end)+100):
    cur+=beg[i]
    cur-=end[i]
    ans=max(ans,cur)
print(ans)


Measured memory_bytes: 58716
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], k = tmp[1];
	string s = ReadLine();

	int hScore = 0;
	for (int i = 0; i < n; i++)
	{
	    if (s[i] == 'L')
	    {
		if (i > 0 && s[i-1] == 'L')
		    hScore++;
	    }
	    else
	    {
		if (i < n-1 && s[i+1] == 'R')
		    hScore++;
	    }
	}

	int ans = Math.Min(n-1, hScore + k*2);
	WriteLine(ans);
    }
}


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

int main()
{
    int a, b;
    string s;
    cin >> a >> b >> s;
    int ans = 0;
    for(int i=0;i<a;i++){
        if(0 > s[i]-'0' || s[i]-'0' > 9){
            ans++;
            break;
        }
    }
    if(s[a] != '-'){ans++;}
    for(int j=a+1;j<a+b+1;j++){
        if(0 > s[j]-'0' || s[j]-'0' > 9){
            ans++;
            break;
        }
    }
    if(ans != 0){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n+1];
        a[0] = 0;
        
        for (int i=1; i<=n; i++){
            a[i] = sc.nextInt();
        }
        
        long count = 0;
        for (int i=0; i<n; i++){
            if (a[i]+a[i+1] > x){
                count += a[i]+a[i+1] - x;
                a[i+1] -= a[i]+a[i+1] - x;
            }
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 51528
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    int n;
    long h;
    long[] as, bs;
    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        h = sc.nextLong();
        as = new long[n];
        bs = new long[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextLong();
            bs[i] = sc.nextLong();
        }
    }

    private void solve() {
        int cnt = 0;
        final long maxA = Arrays.stream(as).max().getAsLong();
        long[] bs2 = Arrays.stream(bs).filter(b -> b > maxA).sorted().toArray();

        for (int i = bs2.length-1; i >= 0; i--) {
            h -= bs2[i];
            cnt++;
            if (h <= 0)
                break;
        }
        if (h <= 0) {
            System.out.println(cnt);
            System.exit(0);
        }
        cnt += h / maxA;
        if (h % maxA != 0)
            cnt++;
        System.out.println(cnt);
    }
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, d;
    cin >> n >> d;
    int span = 2 * d + 1;
    int ans = (n + (span - 1)) / span;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
//#include <vector>
//#include <iostream>

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; std::swap(a, b);
		u -= t * v; std::swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int a1, a2, a3;

void Main()
{
	std::cin >> a1 >> a2 >> a3;
	int sum = a1 + a2 + a3;
	if (sum > 21) {
		std::cout << "bust" << std::endl;
		return;
	}
	std::cout << "win" << std::endl;
	return;



}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	Scanner sc;
	void run(){
		sc = new Scanner( System.in );
		while( true ){
			boolean possible = true;
			int n = sc.nextInt();
			int k = sc.nextInt();
			if( n == 0 && k == 0 ){ return; }
			int[] s = new int[ k ];
			int[] rs = new int[ k ];
			for( int i = 0; i < k; i++ ){
				s[ i ] = sc.nextInt();
				rs[ i ] = 0;
			}
			for( int i = 0; i < n; i++ ){
				for( int j = 0; j < k; j++ ){
					rs[ j ] += ( sc.nextInt() );
					if( rs[ j ] > s[ j ] ){ possible = false; }
				}
			}
			System.out.println( possible ? "Yes" : "No" );
			
		}
	}
	public static void main( String[] args ){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const int INF = 100000; 

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

    s[5] = ' ';
    s[13] = ' ';

    cout << s << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int length = s.length();
        String s1 = s.substring(0, (length-1)/2);
        String s2 = s.substring((length-1)/2+1);
        System.out.println(s1.equals(s2)?"Yes":"No");
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;

main()
{
	int n;
	cin>>n;
	
	int arr[n][n];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		cin>>arr[i][j];
	}
	
	vector<long long> dp(1<<n);
	dp[0]=1;
	
	for(int i=0;i<(1<<n)-1;i++)
	{
		int men=__builtin_popcount(i);
		for(int j=0;j<n;j++)
		{
			if(arr[men][j] && !((1<<j)&i))
			dp[((1<<j)|i)]=(dp[((1<<j)|i)]+dp[i])%MOD;
		}
	}
	
	cout<<dp[(1<<n)-1];
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n)cin >> h.at(i);
    ll ans = 0;
    sort(all(h));
    if(k >= n)cout << 0 << endl;
    else{
        rep(i, n-k)ans += h.at(i);
        cout << ans << endl;
    }
}
    

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    int toD[256];
    toD['E'] = 0;
    toD['S'] = 1;
    toD['W'] = 2;
    toD['N'] = 3;

    char fromD[] = "ESWN";

    for(;;){
        int h, w;
        long long l;
        cin >> h >> w >> l;
        if(h == 0)
            return 0;

        int y, x, d;
        vector<string> grid(h+2, string(w+2, '#'));
        for(int i=1; i<=h; ++i){
            for(int j=1; j<=w; ++j){
                cin >> grid[i][j];
                if(grid[i][j] != '.' && grid[i][j] != '#'){
                    d = toD[grid[i][j]];
                    y = i;
                    x = j;
                    grid[i][j] = '.';
                }
            }
        }

        vector<vector<vector<int> > > t(h+2, vector<vector<int> >(w+2, vector<int>(4, -1)));
        while(--l >= 0){
            int y1, x1;
            for(;;){
                y1 = y + dy[d];
                x1 = x + dx[d];
                if(grid[y1][x1] == '.')
                    break;
                ++ d;
                d %= 4;
            }
            y = y1;
            x = x1;

            if(t[y][x][d] != -1){
                int dt = l - t[y][x][d];
                l %= dt;
            }
            t[y][x][d] = l;
        }

        cout << y << ' ' << x << ' ' << fromD[d] << endl;
    }
}

Measured memory_bytes: 1312
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        char ch = br.readLine().trim().charAt(0);
        if(ch>='A' && ch<='Z') out.println('A');
        else out.println('a');
        out.flush();
    }
}

Measured memory_bytes: 32768
local mab = math.abs
local n = io.read("*n")
local a = {}
local sum = 0
local abssum = 0
for i = 1, n do
  a[i] = io.read("*n")
  sum = sum + a[i]
  abssum = abssum + mab(a[i])
end
table.sort(a)
local allplus = 0 <= a[1]
local allminus = a[n] < 0

if n == 2 then
  if a[1] < a[2] then
    print(a[2] - a[1])
    print(a[2] .. " " .. a[1])
  else
    print(a[1] - a[2])
    print(a[1] .. " " .. a[2])
  end
else
  if allplus then
    print(sum - a[1] * 2)
    local cur = a[1]
    for i = 2, n - 1 do
      print(cur .. " " .. a[i])
      cur = cur - a[i]
    end
    print(a[n] .. " " .. cur)
  elseif allminus then
    print(a[n] * 2 - sum)
    local cur = a[n]
    for i = 1, n - 1 do
      print(cur .. " " .. a[i])
      cur = cur - a[i]
    end
  else
    print(abssum)
    local minlast = 1
    for i = 1, n do
      if a[i] < 0 then
        minlast = i
      else
        break
      end
    end
    local cur = a[minlast]
    for i = minlast + 1, n - 1 do
      print(cur .. " " .. a[i])
      cur = cur - a[i]
    end
    print(a[n] .. " " .. cur)
    cur = a[n] - cur
    for i = 1, minlast - 1 do
      print(cur .. " " .. a[i])
      cur = cur - a[i]
    end
  end
end


Measured memory_bytes: 5344
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#define ll long long
using namespace std;
int a[100005];
int main()
{
   int n;
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
       scanf("%d",&a[i]);
   }
   int cnt=0;
   for(int i=1;i<=n;i++)
   {
       if(a[i]==i)
       {
           cnt++;
           swap(a[i],a[i+1]);
       }
   }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char s[3];
cin >> s;
int a=0;
REP(i,3) {
  if(s[i]=='o') a+=100;
}
cout << 700+a << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;

int T, N;
vector<int> t;
int wktm[110];
int ed;

int memo[110];

int solve(int idx){
    if(memo[idx] != -1) return memo[idx];
    if(idx > ed) return 0;
    int res = INF;
    int startDay = idx;
    rep(i, idx, ed + 1){
        int nowDay = i;
        int wake = t[(nowDay - startDay) % T];
        // cout << idx << " " << i << ' ' << nowDay << " " << wake << endl;
        if(wake > wktm[i]) break;
        int wktmp = solve(i + 1);
        res = min(res, wktmp);
    }
    // cout << idx << ' ' << res + 1 << endl;
    return memo[idx] = res + 1;
}

signed main(){
    while(cin >> T, T){
        t.clear();
        t.resize(T);
        rep(i, 0, T) cin >> t[i];
        cin >> N;
        memset(memo, -1, sizeof(memo));
        rep(i, 0, 110) wktm[i] = INF;
        rep(i, 0, N){
            int a, b;
            cin >> a >> b;
            a--;
            wktm[a] = min(wktm[a], b);
        }
        rep(i, 0, 110){
            if(wktm[i] == INF) continue;
            ed = i;
            // cout << " " << i << " " << wktm[i] << endl;
        }
        int ans = solve(0);
        cout << ans - 1 << endl;
    }
}


Measured memory_bytes: 3108
import sys
sys.setrecursionlimit(100000)
def search(i, visited, ns, ans) :
    #print(i+1)
    visited[i] = True
    for next, weight in ns[i]:
        if visited[next] == False:
            if weight % 2 == 0:
                ans[next] = ans[i]
            else:
                ans[next] = (ans[i]+1) % 2
            search(next, visited, ns, ans)


def dfs(ns, ans):
    visited = [False] * len(ns)
    search(0, visited, ns, ans)

def main():
    n = int(input())
    ns = [[] for _ in range(n)]
    for _ in range(n-1):
        (st,end,weight) = map(int,input().split())
        ns[st-1].append((end - 1,weight))
        ns[end-1].append((st-1,weight))
    ans = [False] * n
    dfs(ns, ans)
    for a in ans:
        if a:
            print(1)
        else:
            print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 80048
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  while(x != 0 || y!= 0){
    cout << min(x,y) << " " << max(x,y) << endl;
    cin >> x >> y;
  }
  return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void){

	int n, i = 1;
	
	while (cin >> n, n) {
		cout << "Case " << i << ": " << n << endl;
		i++;
	}

	return 0;
}

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

int main(){
        int A,B;
        cin >> A >> B;
        if (B == 1) {
                cout << 0 << endl;
                return 0;
        }
        int ans=1;
        while ( ans * (A - 1) + 1 < B) ans++;
        cout << ans << endl;
}

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

F = [0 for i in range(N)]
T = [[]for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    T[a-1].append(b-1)

X = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x

ans = [X[i] for i in range(N)]
for i in range(N):
    F[i] = 1
    for j in range(len(T[i])):
        if F[T[i][j]] == 1:
            continue
        ans[T[i][j]] += ans[i]

for i in range(N):
    print(ans[i], end =" ")


Measured memory_bytes: 95308
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const ll N = 2e5 + 5, mod = 1e9 + 7;

ll x[N], y[N], sumY;

int main()
{
    ll n, m;
    scanf("%lld%lld", &n, &m);
    ll ans = 0, temp;
    for(ll i = 0 ; i < n ; i++) scanf("%lld", x + i);
    for(ll i = 0 ; i < m ; i++) scanf("%lld", y + i);
    for(ll i = 1 ; i < m ; i++)
    {
        sumY += (((i * (m - i)) % mod) * ((y[i] - y[i - 1]) % mod)) % mod;
        sumY %= mod;
    }
    for(ll i = 1 ; i < n ; i++)
    {
        temp = (((i * (n - i)) % mod) * ((x[i] - x[i - 1]) % mod)) % mod;
        ans += (temp * sumY) % mod;
        ans %= mod;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define mp make_pair
#define sz(v) (int)(v.size())
#define len(s) (int)(s.length())
#define M 998244353
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 9e18;
const ld pi = 2*acos(0.0); 
using namespace std;
ll power(ll a,ll n) 
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
const int N=1e6;
vector <ll> sieve(N,0); 
void si() 
{
    sieve[1]=1;
    for(int i=2;i<N;i++){
        if(sieve[i]==0){
            for(int j=i;j<N;j+=i){
                sieve[j]=i;
            }
        }
    }
}
int main(){
    ios;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=b*d;
    ans=max(ans,d*a);
    ans=max(ans,c*b);
    ans=max(ans,c*a);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11024
import math
import numpy as np

def main():
    A, B, H, M = map(int, input().split())

    #何分後
    time = H * 60 + M

    #分針は60分で2pi,1分で1/30pi
    #時針は12*60=720分で2pi,1分で1/360pi
    argmin = time * math.pi / 30
    arghour = time * math.pi / 360

    xh = A * math.cos(arghour)
    yh = A * math.sin(arghour)
    h = np.array([xh, yh])

    xm = B * math.cos(argmin)
    ym = B * math.sin(argmin)
    m = np.array([xm, ym])

    d = np.linalg.norm(h-m)

    print(d)

if __name__ == "__main__":
    main()




Measured memory_bytes: 27260
#include <cstdio>
#include <string>
#include <queue>
using namespace std;

#define MAX_H 50
#define MAX_W 50
#define WHITE '.'
#define BLACK '#'
#define CHECK 'C'

char map[MAX_H][MAX_W] = {0};
int H, W;
int addx[] = {0, 1, 0, -1};
int addy[] = {-1, 0, 1, 0};

int bfs(int xp, int yp) {
	int sum = 0;
	queue<int> qx, qy;
	qx.push(xp);
	qy.push(yp);
	while (!qx.empty()) {
		int x, y;
		int size = qx.size();
		bool flag = false;
		for (int i = 0; i < size; i++) {
			x = qx.front();
			y = qy.front();
			if (x == W-1 && y == H-1)
				flag = true;
			qx.pop();
			qy.pop();
			map[y][x] = CHECK;
			for (int i = 0; i < 4; i++) {
				int nx = x+addx[i], ny = y+addy[i];
				if (0 <= nx && 0 <= ny && nx < W && ny < H && map[ny][nx] == WHITE) {
					map[ny][nx] = CHECK;
					qx.push(nx);
					qy.push(ny);
				}
			}
		}
		sum++;
		if (flag)
			break;
	}
	return sum;

}

int main() {
	scanf("%d %d", &H, &W);
	int black = 0;
	for (int i = 0; i < H; i++)
		scanf("%s", map[i]);
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			if (map[i][j] == BLACK)
				black++;
	int sum = bfs(0, 0);
	int re = H * W;
	re -= black;
	re -= sum;
	if (map[H-1][W-1] == CHECK)
		printf("%d\n", re);
	else
		printf("-1\n");
		
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2297&lang=jp
typedef long long ll;
typedef pair<int, int> pii;
int N;
vector<vector<int>> st;
vector<pii> rec;
int b1[16][3][55];
int b2[16][3][55];

void stamp_stete_check() {
	for (int n = 0; n < N;n++) {
		cout << "[" << rec[n].first << "," << rec[n].second << "]" << endl;
		for (int i = 0; i < st[n].size();i++) {
			for (int j = 0; j < 16;j++) {
				if (j % 4 == 0) cout << endl;
				if (st[n][i] & (1 << j)) {
					cout << "o";
				}
				else {
					cout << "x";
				}
			}
			cout << endl;
		}
	}
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	/* input */
	cin >> N;
	rec.resize(N);
	st.resize(N);
	for (int n = 0; n < N;n++) {
		int H, W; cin >> H >> W;
		rec[n] = { H,W };
		for (int i = -3; i < 4;i++) {
			for (int j = -3; j < 4;j++) {
				int s = 0;
				for (int h = max(0,i); h < min(4, i + H);h++) {
					for (int w = max(0,j); w < min(4, j + W);w++) {
						s += (1 << (4 * h + w));
					}
				}
				if (s == 0)continue;
				st[n].push_back(s);
			}
		}
	}

	// stamp_stete_check();

	/* Classification */
	vector<int> m(16);
	for (int i = 0; i < 16;i++) {
		char c; cin >> c;
		if (c == 'R') m[i] = 0;
		else if (c == 'G') m[i] = 1;
		else m[i] = 2;
	}

	/* Preprocessing */
	for (int n = 0; n < N;n++) {
		for (int c = 0; c < 3;c++) {
			for (int i = 0; i < st[n].size();i++) {
				int B1, B2; B1 = B2 = 0;
				for (int b = 0; b < 16;b++) {
					if (~st[n][i] & (1 << b)) continue;
					if (c == m[b]) {
						B1 += (1 << b);
					}
					else {
						B2 += (1 << b);
					}
				}
				b1[n][c][i] = B1;
				b2[n][c][i] = B2;
			}
		}
	}

	/* initialize */
	vector<int> memo(1 << 16, -1);
	queue<int> q;
	q.push(0);
	memo[0] = 0;

	/* bfs */
	while (!q.empty()) {
		int n = q.front(); q.pop();
		for (int i = 0; i < 16;i++) {
			if (n & (1 << i))continue;
			int v = m[i];
			for (int j = 0; j < N;j++) {
				for (int k = 0; k < st[j].size(); k++) {
					if (~st[j][k] & (1 << i)) continue;	
					int next = n;

					next = next | b1[j][v][k];
					next = next & ~b2[j][v][k];

					if (memo[next] != -1)continue;
					memo[next] = memo[n] + 1;
					if (next == ((1 << 16) - 1)) {
						cout << memo[next] << endl;
						return 0;
					}
					q.push(next);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3516
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(10**5+1):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return


def combination_mod(n, k, mod):
    # power_funcを用いて(nCk) mod p を求める 
    # nCk = n!/((n-k)!k!)を使用

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % mod
    b = factorial(k) % mod
    c = factorial(n - k) % mod
    return (a * power_func(b, mod - 2, mod) * power_func(c, mod - 2, mod)) % mod
    
def power_func(a, b, mod):
    # a^b mod p を求める
    # bを2進数分解して高速累乗

    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod

#D
def D():
    n, k = LI()
    ans = 0
    for i in range(1,k+1):
        a = combination_mod(n - k + 1, i, mod)
        b = combination_mod(k - 1, i - 1, mod)
        print((a*b)%mod)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 40048
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		Set<Integer> as = new HashSet<>();
		int over3200 = 0;
		for (int i = 0; i < N; i++) {
			int a = in.nextInt();
			if (a < 400) {
				as.add(1);
			} else if (a < 800) {
				as.add(2);
			} else if (a < 1200) {
				as.add(3);
			} else if (a < 1600) {
				as.add(4);
			} else if (a < 2000) {
				as.add(5);
			} else if (a < 2400) {
				as.add(6);
			} else if (a < 2800) {
				as.add(7);
			} else if (a < 3200) {
				as.add(8);
			} else {
				over3200++;
			}
		}
		if (over3200 == 0) {
			System.out.println(as.size() + " ");
		} else {
			System.out.print(Math.max(1, as.size()) + " ");
		}
		System.out.println(as.size() + over3200);
		in.close();
	}
}

Measured memory_bytes: 21716
#include <iostream>

int input[4] = {0,0,0,0};
int op[3] = {0,0,0};

using namespace std;

int calc (int total, int i) {
  if (i >= 4) {
    if (total == 7) {
      return true;
    } else {
      return false;
    }
  }

  int result = 0;
  for (op[i] = 0; op[i] <= 1; op[i]++) {
    if (op[i] == 0) {
      result = calc(total + input[i+1], i+1);
    } else {
      result = calc(total - input[i+1], i+1); 
    }
    if (result) {
      return true;
    }
  }
  return false;
}

int main () {
  int in;
  cin >> in;
  input[0] = in / 1000;
  input[1] = (in % 1000) / 100;
  input[2] = (in % 100) / 10;
  input[3] = in % 10;  
  
  calc(input[0], 0);
  cout << input[0];
  if (op[0] == 0) {
	cout << "+";
  } else {
    cout << "-";
  }
  cout << input[1];
  if (op[1] == 0) {
	cout << "+";
  } else {
    cout << "-";
  }
  cout << input[2];
  if (op[2] == 0) {
	cout << "+";
  } else {
    cout << "-";
  }
  cout << input[3];
  cout << "=7" << endl;
  return 0;
}


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

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

    vector<int> x(n);
    for (auto& i : x) cin >> i;

    vector<int> y = x;
    sort(y.begin(), y.end());

    int a = y[n / 2 - 1], b = y[n / 2];
    for (int i : x) cout << (i <= a ? b : a) << endl;

    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD=1e9+7;

#define MAX_N 100010
LL fact[3*MAX_N];

struct INIT{INIT(){
    ios::sync_with_stdio(false);cin.tie(0);
    fact[0]=1;
    for(int i = 1; i < 3*MAX_N; i++)fact[i]=fact[i-1]*i%MOD;
}}init;


// a x + b y = gcd(a, b)
// O(log (a+b) )
LL extgcd(LL a, LL b, LL &x, LL &y) {
    LL g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

// m????????¨??????a?????????
// O(log a)
LL invMod(LL a) {
    LL x, y;
    if (extgcd(a, MOD, x, y) == 1)return (x + MOD) % MOD;
    else return 0; // unsolvable
}
// k?????????n????????°??????????????????
LL calc(LL n,LL k){
    LL u=fact[n+k-1];
    LL d=fact[k-1];
    return u*invMod(d)%MOD;
}

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

int main() {
    int N,T;
    cin>>N>>T;
    vector<int> cnt(3*MAX_N,0);
    rep(i,N){
	int d;
	cnt[cin>>d,d+MAX_N]++;
    }
    LL res=1;
    LL sum=1;
    for(int bg=0,ed=T;ed<3*MAX_N;bg++,ed++){
	if(cnt[ed]>0)res=res*calc(cnt[ed],sum)%MOD;
	sum=(sum+MOD+cnt[ed]-cnt[bg])%MOD;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 6252
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 30 09:02:42 2018
ABC111D
@author: maezawa
"""
import sys
input = sys.stdin.readline

n = int(input())
xy = []
for _ in range(n):
    xy.append(list(map(int, input().split())))
    
#print(xy)
m = 1
parity = sum(xy[0])%2
far = 0
for point in xy:
    length = sum(list(map(abs, point)))
    if length > far:
        far = length
    if length%2 != parity:
        m = -1

if m == -1:
    print(m)
else:
    if parity == 0:
        ds = [1,1]
    else:
        ds = [1,1,1]
    i = 1
    while 2**i < far:
        ds.append(2**i)
        i += 1
    ds.append(2**i)
    ds.reverse()
    print(len(ds))
    print(*ds, sep=' ')
    for point in xy:
        direction = ''
        point0 = [0,0]
        for arm in ds:
            x = point[0] - point0[0]
            y = point[1] - point0[1]
            if abs(x) > abs (y):
                if x > 0:
                    direction += 'R'
                    point0[0] += arm
                else:
                    direction += 'L'
                    point0[0] -= arm
            else:
                if y > 0:
                    direction += 'U'
                    point0[1] += arm
                else:
                    direction += 'D'
                    point0[1] -= arm
            #print(point0)
        print(direction)
                    
            
    
        
        

Measured memory_bytes: 3444
import queue
n,m = map(int, input().split())
V = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int, input().split())
    V[a].append(b)
    V[b].append(a)
ans = [-1]*(n+1)
q = queue.Queue()
q.put(1)
while not q.empty():
    p = q.get()
    for c in V[p]:
        if c > 1 and ans[c] < 0:
            ans[c] = p
            q.put(c)
print('Yes')
print(*ans[2:], sep='\n')


Measured memory_bytes: 35940
#include <bits/stdc++.h>
#define st string
#define ll long long
using namespace std;
int main()
{
    st a;
    cin>>a;
    for(ll i=0;i<a.size();i++)
    {
        if(a[i]==',')
            a[i]=' ';
    }
    for (ll i=0;i<a.size();i++)
    {
        cout<<a[i];
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b, ans=0;
    scanf("%d%d", &a, &b);
    for(int i=a; i<=b; i++)
    {
        if(i/10000==i%10 && (i/1000)%10==(i/10)%10)
            ans++;
    }
    printf("%d", ans);
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main (void){

    int n, x, y, z;
    int b, i;
    int ans = 0;

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

       for(x = 1;x * x <= n;x++){
            for(y = 1;y * y <= n;y++){
                for(z = 1;z * z<= n;z++){
                     b = x*(x + y) + y*(y + z) + z*(z + x);       
                    if(n >= b)
                        a[b]++;
                }
            }
        }
        
        for(i = 1;i <= n;i++)
         cout << a[i] << endl;

    return 0;
}

Measured memory_bytes: 3608
/*
 
Coded and Decoded by : Yash Kapoor
 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

//s.find_by_order(index);
//s.order_of_key(value);
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define why         (ll)1000000007
//#define why         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base,ll power,ll mod){
    ll result=1;
    while(power){
        if(power%2)
        result=(result*base)%mod;
        base=(base*base)%mod;
        power/=2;
    }
    return result;
}
 
ll inverse(ll base,ll mod){
    return fast_power(base,mod-2,mod);
}

ll solve(){
    ll a,b; cin>>a>>b;
    cout<<a*b;
    return 0;
}

int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}  

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a+b==c||b+c==a||c+a==b ? "Yes" :"No")<<endl;
}



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

const int maxN = 1e5 + 5;
set<int> s[maxN];
int N, M, root[maxN], a[maxN];

int get_rt(int v) {
	if(v != root[v]) {
		int rt = get_rt(root[v]);
		root[v] = rt; v = rt;
	}
	return v;
}

int main() {
	scanf("%d%d", &N, &M); 
	for(int i = 1; i <= N; ++i) root[i] = i, scanf("%d", &a[i]);
	for(int i = 1; i <= M; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		int rt1 = get_rt(u), rt2 = get_rt(v);
		if(rt1 != rt2) root[rt1] = rt2;
	}
	for(int i = 1; i <= N; ++i) {
		s[get_rt(i)].insert(a[i]); 
	}
	int ans = 0;
	for(int i = 1; i <= N; ++i) {
		if(s[get_rt(i)].find(i) != s[get_rt(i)].end()) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10368
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> rs(n);
    for (auto& r : rs) {
        cin >> r;
    }

    int ans = INT_MIN;
    int min_r = rs[0];
    for (int i = 1; i < n; i++) {
        ans = max(ans, rs[i] - min_r);
        min_r = min(min_r, rs[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1788