akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
d = {}
a = 0
b = 0

for i in range(N):
    if A[i] not in d:
        d[A[i]] = 1
    else:
        d[A[i]] += 1
    if d[A[i]] == 2 or d[A[i]] == 4:
        if A[i] > a:
            b = a
            a = A[i]
        elif A[i] > b:
            b = A[i]

print(a * b)


Measured memory_bytes: 17960
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<set>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
struct node
{
	int mx1,mx2;
	int pos1,pos2;
};
node unio(node a,node b)
{
	//cout<<"GG"<<endl;
	int aa[4];
	aa[0]=a.mx1;
	aa[1]=a.mx2;
	aa[2]=b.mx1;
	aa[3]=b.mx2;
	sort(aa,aa+4);
	node ret;
	ret.mx1=aa[3];
	ret.mx2=aa[2];
	return ret;
}
int n;
int nn;
int a[300005];
node p[300005];
int main()
{
	read(nn);
	n=(1<<nn);
	for(int i=0;i<n;i++)
		read(a[i]);
	for(int i=0;i<n;i++)
	{
		p[i].mx1=a[i];//cout<<"E"<<endl;
	}
	for(int i=0;i<nn;i++)
		for(int j=0;j<n;j++)
			if((j>>i)&1)
				p[j]=unio(p[j],p[j^(1<<i)]);//cout<<"E"<<endl;
				
//	for(int i=0;i<n;i++)	cout<<p[i].mx1<<' '<<p[i].mx2<<endl;
//	for(int j=1;j<n;j++)
//		p[j]=unio(p[j],p[j-1]);
//	for(int i=0;i<n;i++)	cout<<p[i].mx1<<' '<<p[i].mx2<<endl;
	int ans=0;
	for(int i=1;i<n;i++)
	{
		ans=max(ans,p[i].mx1+p[i].mx2);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 8192
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int p, q, r; cin >> p >> q >> r;
  print(min({p + q, q + r, r + p}));


  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
struct UnionFind {
    vector<int> par; // 親ノード
    UnionFind(int n = 1) { init(n);}
    void init(int n = 1) {
        par.resize(n);
        rep(i,n) par[i] = -1;
    }
    int root(int x) {
        if (par[x] <0) return x;
        else return par[x] = root(par[x]);      
    }
    int size(int x){ return -par[root(x)];}
    bool issame(int x, int y) {return root(x)==root(y);}
    bool connect(int x, int y);
};

signed main(){
	int n,m;
	cin>>n>>m;
	vector<int> x(n),y(m);
	rep(i,n) cin>>x[i];
	rep(i,m) cin>>y[i];
	int X=0,Y=0;
	rep(i,n){
		X+=(i*x[i]-(n-1-i)*x[i]);
	}
	rep(i,m){
		Y+=(i*y[i]-(m-1-i)*y[i]);
	}
	X%=mod;Y%=mod;
	cout<<X*Y%mod<<endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vec a(N+1);
    REP(i,1,N+1) cin >> a[i];

    vec b(N+1, 0);
    ll sum;
    for(ll i=N; i>=1; --i) {
        sum = 0;
        for(ll j=i+i; j<=N; j+=i) sum = (sum + b[j]) % 2;
        b[i] = (sum + a[i]) % 2;
    }
    ll M = 0;
    REP(i,1,N+1) M += b[i];
    PR(M);
    REP(i,1,N+1) {
        if(b[i] == 1) PR(i);
    } 

    return 0;
}

/*



*/

Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAXN = 100100;
int A[MAXN], B[MAXN];
vector<int> G[MAXN];
int V[MAXN], P[MAXN];
int L[MAXN], R[MAXN];
int evenOdd[MAXN];
int ans[MAXN];
int N, K;

bool dfs(int v, int p) {
	for (int ch : G[v]) if (ch != p) {
		if (!dfs(ch, v)) return false;
	}
	if (evenOdd[v] < 3) {
		// 確定している
		for (int ch : G[v]) if (ch != p) {
			if (!(L[ch]-1 <= L[v] && L[v] < R[ch]+1)) return false;
			if (evenOdd[v] == 1) if ((evenOdd[ch]&2) == 0) return false;
			if (evenOdd[v] == 2) if ((evenOdd[ch]&1) == 0) return false;
		}
	} else {
		R[v] = 1e9;
		for (int ch : G[v]) if (ch != p) {
			L[v] = max(L[v], L[ch]-1);
			R[v] = min(R[v], R[ch]+1);
			int tmp = 0;
			if (evenOdd[ch] == 1) tmp = 2;
			else if (evenOdd[ch] == 2) tmp = 1;
			else if (evenOdd[ch] == 3) tmp = 3;
			else assert(0);
			evenOdd[v] &= tmp;
			if (evenOdd[v] == 0) return false;
			if (evenOdd[v] == 1) {
				if (L[v]%2 == 1) L[v]++;
				if ((R[v]-1)%2 == 1) --R[v];
			} else if (evenOdd[v] == 2) {
				if (L[v]%2 == 0) L[v]++;
				if ((R[v]-1)%2 == 0) --R[v];
			}
			if (L[v] >= R[v]) return false;
		}
	}
	return true;
}

void dfs2(int v, int p, int pNum) {
	int num = pNum-1;
	if (L[v] > num || num >= R[v]) num = pNum+1;
	ans[v] = num;
	for (int ch : G[v]) if (ch != p) {
		dfs2(ch, v, num);
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N-1; i++) {
		cin >> A[i] >> B[i];
		--A[i]; --B[i];
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	}
	for (int i = 0; i < N; i++) {
		evenOdd[i] = 3;
	}
	cin >> K;
	for (int i = 0; i < K; i++) {
		cin >> V[i] >> P[i];
		--V[i];
		L[V[i]] = P[i];
		R[V[i]] = P[i]+1;
		if (P[i] % 2 == 0) evenOdd[V[i]] = 1;
		else evenOdd[V[i]] = 2;
	}
	if (!dfs(0, -1)) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
		dfs2(0, -1, L[0]-1);
		for (int i = 0; i < N; i++)
			cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,d; cin >> m >> d;
  if(m < 4){
    cout << 0;
    return 0;
  }
  int cnt = 0;
  for(int i = 4; i <= m; i++){
    for(int j =22; j <= d; j++){
      int d1 = j % 10;
      int d10 = j / 10;
      if(d1 >= 2 and d1 * d10 == i) cnt ++;
    }
  }
  cout << cnt;
}

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

int main(){
    int n;cin>>n;
    int A[n],B[n-1];
    for(int i=0;i<n;i++){
        cin>>B[i];
    }
    for(int i=0;i<n;i++){
        if(i==0) A[i]=B[0];
        if(1<=i&&i<n){
            if(B[i-1]>=B[i]) A[i]=B[i];
            else A[i]=B[i-1];
        }
        if(i==n-1) A[i]=B[n-2];
    }
    int sum=0;
    for(int i=0;i<n;i++) sum+=A[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 256
sa = list(input())
sb = list(input())
sc = list(input())
s = sa.pop(0)

while True:
    if s=="a":
        if len(sa)==0:
            ans="A"
            break
        s = sa.pop(0)
    elif s=="b":
        if len(sb)==0:
            ans="B"
            break
        s = sb.pop(0)
    elif s=="c":
        if len(sc)==0:
            ans="C"
            break
        s = sc.pop(0)
print(ans)   


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vi a(n), b(n);
  vector<ll> vec(n);
  ll ans = 0;
  rep(i, n) {
    std::cin >> a[i] >> b[i];
    ans += b[i];
    vec[i] = a[i] + b[i];
  }
  ans *= -1;
  sort(vec.rbegin(), vec.rend());
  for (int i = 0; i < n; i+=2) {
    ans += vec[i];
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 1792
#line 1 "/workspaces/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc170_a.cpp"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int sum = 0;
  REP(i, 5) {
    int a;
    cin >> a;
    sum += a;
  }

  cout << 15 - sum << endl;
}


Measured memory_bytes: 3636
S = input()
length = len(S) - 1
ans = ''
for bit in range(2 ** length):
    x = [i for i in range(length) if bit & (2 ** i)]
    tmp = S
    # print(x)
    for i in range(len(x)):
        tmp = tmp[:x[i] + i + 1] + '+' + tmp[x[i] + i + 1:]
    # print(tmp)
    ans += tmp + '+'
print(sum(map(int, ans[:-1].split('+'))))


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

typedef long long ll;

int main(){

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

    ll a;
    long double b;
    cin >> a >> b; 
    ll ans = a*b;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll n; cin >> n;
    vl l,r;
    rep(i,n){
        ll a,b; cin >> a >> b;
        l.push_back(a);
        r.push_back(b);
    }
    sort(all(l)); sort(all(r));
    for(ll i=n+1; i>=1; i--){
        auto itrl = upper_bound(all(l),i);
        auto itrr = lower_bound(all(r),i);
        ll num = l.end() - itrl + itrr - r.begin();
        num = n+1 - num;
        if(num >= i){
            cout << i-1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4804
/*
123 321
ABCDEFG
GABCDEF
FGABCDE
EFGABCD
DEFGABC
CDEFGAB
BCDEFGA
*/
#include<bits/stdc++.h>
using namespace std;

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=1;i<=m;i++) {
		int l = i, r = n+1-i;
		if(n%2==0 && r-l <= l+n-r) r--;
		printf("%d %d\n", l, r);
		//printf("%d %d %d %d\n", l, r, r-l, l+n-r);
	}
	
	return 0;
}

Measured memory_bytes: 3764
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]
es = [[] for _ in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

from collections import deque
q = deque([0])
INF = float('inf')
dist = [INF] * N
dist[0] = 0
back = [-1] * N
while q:
    v = q.popleft()
    for to in es[v]:
        if dist[v] + 1 >= dist[to]: continue
        dist[to] = dist[v]
        back[to] = v+1
        q.append(to)
print('Yes')
print(*back[1:], sep='\n')

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

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

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

	int tmp, ans=INF;
	for(int i=0;i<S.size() - 3 + 1;i++) {
		int num = 0;
		string str = S.substr(i, 3);;
		num = stoi(str);
		tmp = abs(753 - num);
		ans = min(ans, tmp);
	}

	cout<< ans <<endl;

	return 0;
}

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

int main(void){
    int n, tmp;
    cin >> n;
    int* num = new int[n];
    for(int i=0; i<n-1; i++){
        cin >> tmp;
        num[tmp-1]++;
    }
    
    for(int i=0; i<n; i++){
        cout << num[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4300
def resolve():

    N,Y=map(int,input().split())
    def main():
        for i in range(N+1):
            for j in range(N+1-i):
                if 10000*i+5000*j+1000*(N-i-j)==Y:
                    return (i,j,N-i-j)
        return (-1,-1,-1)
    
    for i in main():
        print(i,end=' ')
resolve()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define maxn 5010
#define maxm 210
using namespace std;
typedef long long ll;
int a[maxm][maxn],n,m,sta[maxn],l[maxn],r[maxn];
ll b[maxn];
ll sum[maxn][maxn];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=2;i<=n;++i)scanf("%lld",&b[i]),b[i]+=b[i-1];
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%d",&a[j][i]);
	for(int i=1,tp;i<=m;++i){
		tp=0,sta[tp]=0;
		for(int j=1;j<=n;++j){
			while(tp&&a[i][sta[tp]]<=a[i][j])tp--;
			l[j]=sta[tp]+1,sta[++tp]=j;
		}
		tp=0,sta[tp]=n+1;
		for(int j=n;j>=1;--j){
			while(tp&&a[i][sta[tp]]<a[i][j])tp--;
			r[j]=sta[tp]-1,sta[++tp]=j;
		}
		for(int j=1;j<=n;++j){
			sum[l[j]][j]+=a[i][j];
			sum[l[j]][r[j]+1]-=a[i][j];
			sum[j+1][j]-=a[i][j];
			sum[j+1][r[j]+1]+=a[i][j];
		}
	}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
	long long ans=0;
	for(int i=1;i<=n;++i)
		for(int j=i;j<=n;++j)
			ans=max(ans,sum[i][j]-b[j]+b[i]);
	printf("%lld",ans);
}

Measured memory_bytes: 200320
N,M=map(int,input().split())
H=list(map(int,input().split()))
good=[True]*N
for i in range(M):
    A,B=map(int,input().split())
    if H[A-1]>H[B-1]:
        good[B-1]=False
    elif H[B-1]>H[A-1]:
        good[A-1]=False
    else:
        good[A-1],good[B-1]=False,False
ans=0
for i in good:
    if i==True:
        ans+=1
print(ans)

Measured memory_bytes: 20044
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main() {
    char c[100];

    scanf("%s", c);

    for(int i = 0; i < strlen(c); i++) {
        if(c[i] == ',') {
            c[i] = ' ';
        }
    }

    printf("%s", c);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

int N;

int main(){
	cin>>N;
	int n;
	for(int i=0;i<N;i++){
		cin>>n;
		int M=0,m=0,a,b;
		cin>>a;
		for(int j=0;j<n-1;j++){
			cin>>b;
			M=max(M,b-a);
			m=max(m,a-b);
			a=b;
		}
		cout<<M<<' '<<m<<endl;
	}
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int cnt[101];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int n,q;
        cin >> n >> q;
        if(n == 0){
            break;
        }
        int m;
        rep(i,101){
            cnt[i] = 0;
        }
        rep(i,n){
            cin >> m;
            rep(j,m){
                int a;
                cin >> a;
                cnt[a]++;
            }
        }
        int mx = q-1;
        int id;
        rep(i,101){
            if(cnt[i] > mx){
                mx = cnt[i];
                id = i;
            }
        }
        if(mx == q-1){
            cout << "0\n";
        }else{
            cout << id << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3120
MAX = 10 ** 6
MOD = 10 ** 9 + 7
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX


def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


def COM(n, r):
    if n < r or r < 0 or n < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD


def main():
    COMinit()
    n, k = map(int, input().split())
    a = sorted(list(map(int, input().split())), reverse=True)

    i = 0
    sum_max = 0
    sum_min = 0
    while n - i - 1 >= k - 1:
        cnt = COM(n - i - 1,  k - 1)
        sum_max += a[i] * cnt
        sum_min += a[n - i - 1] * cnt
        i += 1
    ans = (sum_max - sum_min) % MOD
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 132824
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    string s;
    cin >> s;
    int i = 0, j = s.size()-1;
    int cnt = 0;
    while(i < j){
        if(s[i] != s[j])
            cnt++;
        i++, j--;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans=1e9;
  for(int i=0;i<n;i++) {
    int temp;
    cin >> temp;
    int count=0;
    while(temp%2==0) {
      temp/=2;
      count++;
    }
    ans=min(ans,count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int,int>
#define pl pair<ll,ll> 
#define ff first
#define ss second
#define PB push_back
#define F(i,L,R) for(auto i=L; i<R ;i++)
#define FR(i,R,L) for(auto i=R;i>L;i--)
#define all(x) (x).begin(),(x).end()
#define show(x) cout<<(#x)<<" = "<<(x)<<"\n";
#define show2(x,y) cout<<(#x)<<" = "<<(x)<<" & "<<(#y)<<" = "<<(y)<<"\n";
#define show3(x,y,z) cout<<(#x)<<" = "<<(x)<<" & "<<(#y)<<" = "<<(y)<<" & "<<(#z)<<" = "<<(z)<<"\n";
#define endln "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M 1000000007
#define float double
using namespace std;

float arr[3005];
float dp[3005][3005];// dp(i,j) = probability of getting j heads with first i coins


int main() 
{
	fastio;
	int n;
	cin>>n;
    F(i,0,n)
        cin>>arr[i+1];
    arr[0]=0;
    
    
        
    F(i,0,n+1)
    {
        dp[0][i] = 0;
        dp[1][i] = 0;
    }
    
    dp[1][0] = 1-arr[1];
    dp[1][1] = arr[1];
    
    F(i,2,n+1)
    {
        F(j,0,n+1)
        {
            if(j==0)
                dp[i][j] = (1-arr[i])*dp[i-1][j];
  //          else if(i<j)
    //            dp[i][j]=0;
            else
                dp[i][j] = arr[i]*dp[i-1][j-1] + (1-arr[i])*dp[i-1][j];
        }
    }
    
    float ans=0;
    F(i,(n/2)+1,n+1)
        ans+=dp[n][i];
        
    cout<<fixed<<setprecision(10)<<ans;
}




Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
#define NIL -1

LL powl(LL x, LL n){
    LL ans = 1;
    while(n>0){
        if((n&1)==1){
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

int main() {
    LL h;
    LL w;
    LL k;
    cin >> h >> w >> k;
    vector<vector<LL>> c(h, vector<LL>(w));
    string tmp_c;
    for(LL i=0; i<h; i++){
        cin >> tmp_c;
        for(LL j=0; j<tmp_c.size(); j++){
            if(tmp_c[j]=='.'){
                c[i][j]=0;
            }else{
                c[i][j]=1;
            }
        }
    }

    LL pow_h=powl(2,h);
    LL pow_w=powl(2,w);
    vector<LL> ok_h(h);
    vector<LL> ok_w(w);

    LL ans=0;
    for(LL i=0; i<pow_h*pow_w; i++){
        LL tmp_num_h=i%pow_h;
        LL tmp_num_w=i/pow_h;
        LL num_sum=0;
        //cout << tmp_num_h << " " << tmp_num_w << endl;
        for(LL j=0; j<h; j++){
            if(tmp_num_h%2==1){
                ok_h[j]=1;
            }else{
                ok_h[j]=0;
            }
            tmp_num_h/=2;
        }
        for(LL j=0; j<w; j++){
            if(tmp_num_w%2==1){
                ok_w[j]=1;
            }else{
                ok_w[j]=0;
            }
            tmp_num_w/=2;
        }
        for(LL j=0; j<h; j++){
            for(LL l=0; l<w; l++){
                //cout << i << " " << j << " " << l << " " << ok_h[j] << " " << ok_w[l] << endl;
                num_sum+=c[j][l]*ok_h[j]*ok_w[l];
            }
        }
        if(num_sum==k){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

class Program {
    static void Main(string[] args) {
        string a = Cin.Next();
        string b = Cin.Next();
        string answer = "";
        int index = 0;
        while (a.Count() > index) {
            answer += a[index];
            if (b.Count() > index)
            answer += b[index];
            index++;
        }
        Console.WriteLine(answer);
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

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

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

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
#include <utility>

int main()
{
        int N;
        int fmax = 0;
        std::cin >> N;
        for (int i = 0; i < N; ++i) {
                int a;
                std::cin >> a;
                fmax += a - 1;
        }
        std::cout << fmax << "\n";
}

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

int main()
{
  int N;
  int d[110];
  int res=0;
  cin >> N;

  rep(i,N) cin >> d[i];

  sort(d,d+N, greater<int>());

  int prev=INF;
  rep(i,N){
    if(prev>d[i]) res++;
    prev = d[i];
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


void Main(){
    string S;
    cin >> S;
    if(S[0] == S[1] && S[1] == S[2]){
        cout << "No\n";
    }else{
        cout << "Yes\n";
    }
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int i,j,k,m,n,l;
    while(scanf("%lld%lld",&m,&n)!=EOF)
    {
        l=0;
        if(n<m*2)
            l=n/2;
        else
        {
            n=n-2*m;
            l=m+n/4;
        }
        printf("%lld\n",l);
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <limits>
#include <iomanip>
using namespace std;

int main(){

    string s; int a = 0;
    string t; int b = 0;
    string u;

    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if( s == u ) a--;
    if( t == u ) b--;

    cout << a << " " << b << endl;

}


Measured memory_bytes: 256
import copy
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
q=[list(map(int,input().split())) for _ in range(M)]
a1=copy.deepcopy(a)
b1=copy.deepcopy(b)
a1.sort()
b1.sort()
min=a1[0]+b1[0]
ca=0
for i in range(M):
 try:
  ca=a[q[i][0]-1]+b[q[i][1]-1]-q[i][2]
 except:
  ca=float("inf")
 if ca<min:
  min=ca
print(min)

Measured memory_bytes: 112816
import sys
p=['41412121','41212141','21414121','21214141','14141212','14121214','12141412','12121414']
g=lambda x:map(int,x)
for e in sys.stdin:
 d={}
 for f in p:d[sum(s-t for s,t in zip(g(e.split()),g(f))if s>t)]=f
 print(*list(d[min(d)]))


Measured memory_bytes: 5728
#include <iostream>
#include <cstdio>
#include <string>
typedef long long lint;
using namespace std;

int Search(int A[],int n,int key){
	int i=0;
	A[n]=key;
	while(A[i]!=key)i++;
	return i!=n;
}

int main(){
	int n,A[10001],q,key,sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&A[i]);

	scanf("%d",&q);
	for(int t=0;t<q;t++){
		scanf("%d",&key);
		if(Search(A,n,key))sum++;
	}
	printf("%d\n",sum);

return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <stdlib.h>

using namespace std;

int comp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}

int main(){
	int n, m, c[20], T[50001];
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		cin >> c[i];
	}
	qsort(c, m, sizeof(int), comp);
	for (int j = 0; j <= n; j++){
		T[j] = 0;
	}
	for (int i = 0; i < m; i++){
		for (int j = c[i]; j <= n; j++){
			T[j] = T[j] && (T[j] < T[j - c[i]] + 1) ? T[j] : T[j - c[i]] + 1;
		}
	}
	cout << T[n] << endl;
	
	return 0;
}

Measured memory_bytes: 1368
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int K = sc.nextInt();
    int S = sc.nextInt();

    sc.close();

    int count = 0;

    for (int i = 0; i <= K; i++) {
      for (int j = 0; j <= K; j++) {
        int k = S - i - j;
        if (k <= K && 0 <= k) {
          count++;
        }
      }
    }

    System.out.println(count);

  }

}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  vector<int> left(n + 1), right(n + 1);
  rep(i, n) {
    if (s[i] == '<') left[i + 1] = left[i] + 1; 
  }

  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == '>') right[i] = right[i + 1] + 1;
  }

  ll ans = 0;
  rep(i, n + 1) ans += max(left[i], right[i]);
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
int n,m,x;
vector<int> g[100];
int c[100];
int a[100];

bool good()
{
    for(int i = 0 ; i < m ; i++)
       if(a[i] < x)
          return 0;
    
    return 1;
}

void apply(int i,int s)
{
    for(int j = 0 ; j < m ; j++)
        a[j]+=g[i][j] * s;
}

int solve(int i)
{
    if(i == n)
     {
         if(good())
             return 0;
         return 1e9;
     }
     
     int ret = solve(i + 1);
     apply(i,+1);
     ret = min(ret , solve(i + 1) + c[i]);
     apply(i,-1);
     return ret;
}

int main()
{
    
   cin >> n >> m >> x;
   for(int i = 0 ; i < n ; i++)
   {
       cin >> c[i];
       g[i].resize(m);
        for(int j = 0 ; j < m ; j++)
             cin >> g[i][j];
   }
   
   int Ans = solve(0);
    if(Ans >= 1e9)
       cout << -1;
    else
     cout << Ans;
   
}

Measured memory_bytes: 3612
// CPP program to find the minimum number of moves to 
// reach the cell contains N starting from (1, 1). 
#include<bits/stdc++.h>
using namespace std; 
#define MAXI 100005

// Function to find the minimum number of moves to 
// reach the cell contains N starting from (1, 1).
int max_element(int a[], int n)
{
    // To store prefix max element
    int pre[n];
    
    pre[0] = a[0];
    for(int i=1;i<n;i++)
        pre[i] = max(pre[i-1], a[i]);
        
    // To store suffix max element
    int suf[n];
    
    suf[n-1] = a[n-1];
    for(int i=n-2;i>=0;i--)
        suf[i] = max(suf[i+1], a[i]);
        
    // Find the maximum element 
    // in the array other than a[i]
    for(int i=0;i<n;i++)
    {
        if(i==0)
            cout << suf[i+1] << endl;
            
        else if(i==n-1)
            cout << pre[i-1] << endl;
            
        else
            cout << max(pre[i-1], suf[i+1]) << endl;
    }
}

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

    // Function call
    max_element(a, n);

    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
const int N=2e5 + 5;
int v[N];
pair<int, int> seg[2][4 * N];

void update(int n,int l,int r,int s,int e){

	if(r < s || l > e) return;
	if(l >= s && r <= e){
		seg[0][n].fi=seg[1][n].fi=1e9;
		seg[0][n].se=seg[1][n].se=-1;
		seg[l & 1][n].fi=v[l], seg[l & 1][n].se=l;
		return;
	}
	int mid=(l + r) / 2;
	update(n * 2 + 1,l,mid,s,e), update(n * 2 + 2,mid + 1,r,s,e);
	int li=n * 2 + 1,ri=n * 2 + 2;
	for(int i=0;i < 2;i++)
		if(seg[i][li] < seg[i][ri]) seg[i][n].fi=seg[i][li].fi, seg[i][n].se=
			seg[i][li].se;
		else seg[i][n].fi=seg[i][ri].fi, seg[i][n].se=seg[i][ri].se;
}
pair<int, int> get(int n,int l,int r,int s,int e,bool t){
	if(r < s || l > e) return{1e9, -1};
	else if(l >= s && r <= e) return seg[t][n];
	int mid=(l + r) / 2;
	pair<int, int> ret={ 1e9, -1 },li,ri;
	li=get(n * 2 + 1,l,mid,s,e,t);
	ri=get(n * 2 + 2,mid + 1,r,s,e,t);
	if(li.fi < ri.fi) ret.fi=li.fi, ret.se=li.se;
	else ret.fi=ri.fi, ret.se=ri.se;
	return ret;
}
int n;
struct obj {
	int l,r,lev,p;
	obj(int a,int b,int c,int d){
		l=a, r=b, lev=c, p=d;
	}
	bool operator <(const obj &s) const{
		return p > s.p;
	}
};
priority_queue<obj> st;
void dq(int l,int r,int lev){
	st.push(obj(l,r,lev,get(0,0,n - 1,l,r,l & 1).fi));
	while(!st.empty()){
		l=st.top().l, r=st.top().r, lev=st.top().lev;
		st.pop();
		if(r < l) continue;
		pair<int, int> mn,m;
		int t;
		if(!(l & 1)) mn=get(0,0,n - 1,l,r - 1,0), t=1;
		else mn=get(0,0,n - 1,l,r - 1,1), t=0;
		m=get(0,0,n - 1,mn.se + 1,r,t);
		printf("%d %d ",mn.fi,m.fi);
		if(l < mn.se - 1)
			st.push(
				obj(l,mn.se - 1,lev + 1,get(0,0,n - 1,l,mn.se - 1,(l) & 1).fi));
		if(mn.se + 1 < m.se - 1)
			st.push(
				obj(mn.se + 1,m.se - 1,lev + 1,
					get(0,0,n - 1,mn.se + 1,m.se - 1,(mn.se + 1) & 1).fi));
		if(m.se + 1 < r)
			st.push(
				obj(m.se + 1,r,lev + 1,
					get(0,0,n - 1,m.se + 1,r,(m.se + 1) & 1).fi));
	}
}

int main(){

//	freopen("in.txt","r",stdin);

	scanf("%d",&n);
	for(int i=0;i < n;i++){
		scanf("%d",&v[i]);
		update(0,0,n - 1,i,i);
	}
	dq(0,n - 1,0);
	return 0;
}


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

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

const long long MOD = 1000000007;

int main(){
  ll n,a;
  ll ans=0,t=0,m=1e9;
  cin >> n;
  rep(i,n){
      cin >> a;
      if(a>=0){
          ans+=a;
          m=min(a,m);
      }
      else{
          ans-=a;
          t=(t+1)%2;
          m=min(m,-1*a);
      }
  }
  if(t) ans-=2*m;
  cout<<ans<<endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main() {
    int N,humidai,max;
    int64_t total=0;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++)
        cin >> A.at(i);
    max = A.at(0);
    for(int i=1;i<N;i++){
        humidai = 0;
        if(max>A.at(i)){
            humidai = max - A.at(i);
        }
        max =A.at(i) + humidai;
        total += humidai;
    }
    

    cout << total <<endl;
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

using Graph=vector<vector<int>>;
Graph G;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a+b+c<22)cout<<"win"<<endl;
  else cout<<"bust"<<endl;
  
}
    

Measured memory_bytes: 764
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    s = input()
    sl = [i for i in s]
    n = len(s)-1
    sublist = [-1]*n
    anslist = []
    ans = []
    for i in range(1<<n):
        for j in range(n):
            if (i>>j)&1:
                sublist[j] = "+"
        anslist.append(sl[0])
        for j in range(n):
            if sublist[j] == "+":
                anslist.append(sublist[j])
                anslist.append(sl[j+1])
            else:
                anslist.append(sl[j+1])
        ans.append(eval("".join(anslist)))
        anslist = []
        sublist = [-1]*n
    print(sum(ans))
if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 5172
N,x = map(int,input().split())
A = [int(i) for i in input().split()]
ans = 0 
for i in range(N-1):
  if A[i] + A[i+1] <= x :
    continue
  else :
    p = A[i] + A[i+1] - x 
    if p > A[i+1]:
      A[i] -= (p - A[i+1])
      A[i+1] = 0 
      ans += p 
    else :
      A[i+1] -= p 
      ans += p 
print(ans)

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

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

int main() {
  int N,K,Q;
  cin >> N >> K >> Q;
    
  vector<int> A(N);
  
  rep(i,Q){
    int Ai = 0;
    cin >> Ai;
    A.at(Ai-1)++;
  }
  //何もしなければK - Q点で終了
  //終了時:K - Q + (獲得正解数) > 0 なら生き残る
  rep(i,N){
    int points =  K - Q + A.at(i);
    if(points > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;      
    }
  }
  
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int N; cin >> N;
    vector<int> num(N);
    REP(i, N) cin >> num[i];
    int res = 0;
    whole(sort, num);

    res = num[N / 2] - num[N/ 2 - 1];

    cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <utility>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)

int main(){

  string s;
  cin>>s;
  int w=0;
  int i=0;
  for(;i*2<s.size();i++)if(s[i]=='p')w--;
  for(;i<s.size();i++)if(s[i]=='g')w++;
  cout<<w;

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
    int n, i, R = 0;
    int a, b, ans;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d%d", &a, &b);
        if (R < a) {
            R = a;
            ans = a + b;
        }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int dp[1000000];
int dp_odd[1000000];
int main(void){
  vector <int> nums;
  for(int i = 1; i * (i + 1) * (i + 2) / 6 < 1000000; i++){
    nums.push_back(i * (i + 1) * (i + 2) / 6);
  }
  for(int i = 0; i < 1000000; i++){
    dp[i] = INT_MAX;
    dp_odd[i] = INT_MAX;
  }
  dp[0] = 0;
  dp_odd[0] = 0;
  for(int i = 1; i < 1000000; i++){
    for(int j = 0; j < nums.size(); j++){
      if(i - nums[j] >= 0){
        dp[i] = min(dp[i], 1 + dp[i - nums[j]]);
        if(nums[j] % 2 == 1){
          dp_odd[i] = min(dp_odd[i], 1 + dp_odd[i - nums[j]]);
        }
      } else {
        break;
      }
    }
  }
  int n;
  while(true){
    cin >> n;
    if(n == 0){
      break;
    }
    cout << dp[n] << " " << dp_odd[n] << endl;
  }
  return 0;
}


Measured memory_bytes: 10948
#include <cassert>
#include <cstddef>
#include <tuple>
#include <utility>
#include <vector>

template <class Abelian> class PotentializedUnionFind {

public:
  using value_type = Abelian;
  using size_type = std::size_t;
  using container_type =
      std::vector<std::tuple<size_type, value_type, size_type>>;

protected:
  container_type c;

private:
  size_type &par(const size_type i) { return std::get<0>(c[i]); }
  size_type par(const size_type i) const { return std::get<0>(c[i]); }
  value_type &val(const size_type i) { return std::get<1>(c[i]); }
  const value_type &val(const size_type i) const { return std::get<1>(c[i]); }
  size_type &siz(const size_type i) { return std::get<2>(c[i]); }
  size_type siz(const size_type i) const { return std::get<2>(c[i]); }
  value_type potential(size_type x) {
    value_type ret = {};
    while (x != par(x)) {
      val(x) = val(x) + val(par(x));
      ret = ret + val(x);
      x = par(x) = par(par(x));
    }
    return std::move(ret);
  }

public:
  PotentializedUnionFind() : c() {}
  explicit PotentializedUnionFind(const size_type size)
      : c(size, std::forward_as_tuple(static_cast<size_type>(0), value_type(),
                                      static_cast<size_type>(1))) {
    for (size_type i = 0; i < size; ++i)
      par(i) = i;
  }

  size_type size() const { return c.size(); }
  bool empty() const { return c.empty(); }

  size_type find(size_type x) {
    assert(x < size());
    while (x != par(x)) {
      val(x) = val(x) + val(par(x));
      x = par(x) = par(par(x));
    }
    return x;
  }
  value_type diff(const size_type x, const size_type y) {
    assert(x < size());
    assert(y < size());
    assert(same(x, y));
    return potential(y) + (-potential(x));
  }
  bool same(const size_type x, const size_type y) {
    assert(x < size());
    assert(y < size());
    return find(x) == find(y);
  }
  size_type size(const size_type x) {
    assert(x < size());
    return siz(find(x));
  }

  bool unite(size_type x, size_type y, value_type d) {
    assert(x < size());
    assert(y < size());
    d = d + potential(x) + (-potential(y));
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (siz(x) < siz(y))
      std::swap(x, y), d = -d;
    siz(x) += siz(y);
    par(y) = x;
    val(y) = std::move(d);
    return true;
  }
};

#include<iostream>

int main() {
	int n, m;
	std::cin >> n >> m;
	PotentializedUnionFind<int> T(n);
	while (m--) {
		int l, r, d;
		std::cin >> l >> r >> d;
		--l;--r;
		if (!T.unite(l, r, d)) {
			if (T.diff(l, r) != d) {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define fr(i, n) for (ll i = 0; i < n; ++i)
#define frab(i, a, b) for (ll i = a; i < b; ++i)
#define mp make_pair
#define pb push_back
#define F first
#define S second
using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e9 + 7;
const int M = 105;
const ld PI = acos(-1);
const int POW = 42;
const ll MOD = 1000 * 1000 * 1000 + 7;

const int N = 1e6 + 5;

int a[N];

int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    fr(i, n)
        cin >> a[i];
    sort(a, a + n);

    if (a[0] + 1 < a[n - 1]) {
        cout << "No";
        return 0;
    }

    if (a[0] == a[n - 1]) {
        if (a[0] == n - 1)
            cout << "Yes";
        else if (n >= 2 * a[0])
            cout << "Yes";
        else
            cout << "No";
        return 0;
    }

    int b = 0;
    fr(i, n)
        if (a[i] == a[0])
            b++;
    if (n - b >= 2 * (a[n - 1] - b) && a[n - 1] - b >= 1)
        cout << "Yes";
    else
        cout << "No";


}


Measured memory_bytes: 640