akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };


int main() {
	int n;
	cin >> n;
	int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cout << a[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
lens = len(s)
ans = [1]*len(s)
for i in range(lens-2):
  if s[i] == 'R' and s[i+1] == 'R':
    ans[i+2] += ans[i]
    ans[i] = 0
for i in range(1,lens-1):
  if s[-i] == 'L' and s[-(i+1)] == 'L':
    ans[-(i+2)] += ans[-i]
    ans[-i] = 0
print(*ans)


Measured memory_bytes: 47804
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin >> s >> t;
	int s_l = s.length();
	int t_l = t.length();
	vector<vector<int>> dp(s_l+1,vector<int>(t_l+1,0));
	for(int i=0;i<s_l;++i)
		for(int j=0;j<t_l;++j)
			if(s[i]==t[j])
				dp[i+1][j+1]=dp[i][j]+1;
			else
				dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
	string ans;
	int i=s_l;
	int j=t_l;
	while(i>0&&j>0){
		if(dp[i][j]==dp[i][j-1])--j;
		else if(dp[i][j]==dp[i-1][j])--i;
		else {
			--i;--j;
			ans.push_back(s[i]);
		}
	}
	reverse(begin(ans),end(ans));
	cout << ans << endl;
}


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

int main(){
  int i,j,cnt=0;
  string s;
  cin>>s;
  for(i=0;i<s.size();i++){
    if(s[i]=='x')cnt++;
  }
  if(15-cnt>=8)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i,j,n,len,mini,c,count=0;
  int A[100];
  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<len;i++){
    mini=i;
    for(j=i;j<len;j++){
      if(A[j]<A[mini]){
	mini=j;
      }
    }
    if(i!=mini){
    c=A[i];
    A[i]=A[mini];
    A[mini]=c;
    count++;
    }
  }
  for(i=0;i<len;i++){
    if(i!=0){
      printf(" ");
    }
    printf("%d",A[i]);
  }
  printf("\n%d\n",count);

  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var;



int main() {
	
	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
	
	int W, H, x, y; std::cin >> W >> H >> x >> y;
	printf("%lf %d", double(W) * double(H) / 2, 2 * x == W && 2 * y == H);

	return 0;
}

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

struct BinaryIndexedTree
{
  vector< int64 > data;
  int curr;
  
  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
    curr = 1;
    while(curr < data.size()) curr <<= 1;
  }
  inline int64 sum(int k)
  {
    int64 ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return(ret);
  }
  inline int upper_bound(int64 w)
  {
    int i = 0;
    for(int k = curr; k > 0; k >>= 1) {
      if(i + k < data.size() && data[i + k] <= w) {
        w -= data[i + k];
        i += k;
      }
    }
    return(i);
  }
  inline void add(int k, int64 x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
 
int N, Q;
int X[200000], D[200000], L[200000];

int main()
{
  scanf("%d %d", &N, &Q);
  for(int i = 0; i < Q; i++) {
    scanf("%d %d %d", &X[i], &D[i], &L[i]);
  }
  BinaryIndexedTree xpy(N), xmy(N);
  for(int i = 0; i < N; i++) {
    xpy.add(i, 1);
    xmy.add(i, 1);
  }
  for(int i = Q - 1; i >= 0; i--) {
    if(D[i] == 1) {
      xmy.add(0, -L[i] * 2);
      xmy.add(xpy.upper_bound(X[i]), L[i] * 2);
    } else {
      xpy.add(xmy.upper_bound(X[i]), L[i] * 2);
    }
  }
  for(int i = 0; i < N; i++) {
    printf("%lld\n", (xpy.sum(i) - xmy.sum(i)) / 2);
  }
}

Measured memory_bytes: 6548
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N;
  cin >> N;
  vector<vector<int>> to(N);
  rep(i, N) rep(j, N) {
    char c;
    cin >> c;
    if (c == '1')
      to[i].push_back(j);
  }
  int ans = 0;
  rep(i, N) {
    vector<int> memo(N);
    queue<int> que;
    que.push(i);
    memo[i] = 1;
    while(!que.empty()) {
      int now = que.front();
      que.pop();
      rep(j, to[now].size()) {
        int next = to[now][j];
        if (memo[next]) {
          if (memo[next] == memo[now]) {
            cout << -1 << endl;
            return 0;
          }
        } else {
          memo[next] = memo[now]+1;
          chmax(ans, memo[next]);
          que.push(next);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import sys
from pprint import pprint

def solve(n, a, b):
    ans = 0
    if (b - a) % 2 == 0:
        ans = (b - a) // 2
    else:
        # 両端で試合するパターン
        simple = min(b - 1, n - a)

        # 両端に一回残留してから端以外で試合するパターン
        mix_a = a + (b - a) // 2
        mix_b = n - b + 1 + (b - a - 1) // 2
        ans = min(simple, mix_a, mix_b)

    print(ans)

if __name__ == '__main__':
    n, a, b = map(int, sys.stdin.readline().strip().split(" "))
    solve(n, a, b)

Measured memory_bytes: 38256
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

nums = [0 for i in range(100000)]
for a in A :
  nums[a-1] += 1

answer = sum(A)
  
for q in range(Q) :
  B, C = list(map(int, input().split()))
  nums[C-1] += nums[B-1]
  answer = answer + C * nums[B-1] - B * nums[B-1]
  nums[B-1] = 0
  print(answer)
  


Measured memory_bytes: 20900
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;

#define i64 long long int

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	int add(int x,int y) {return (x+=y)<mod?x:x-mod;}
	void addto(int &x, int y) { x = add(x, y); }
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
};
modular_arithmetic ma;

#define ran 101101
char s[ran];
int len;
int dp[ran][8][5];
int pw3[ran];

int main() {
	scanf("%s", s);
	len = strlen(s);
	pw3[0] = 1;
	for(int i=1;i<=len;i++)
		pw3[i] = ma.mul(pw3[i-1], 3);
	
	int cnt = 0;
	for(int i=0;i<len;i++) if (s[i]=='?') cnt++;
	
	for(int i=0;i<len;i++) {
		for(int j=0;j<8;j++)
			for(int k=0;k<4;k++)
				dp[i+1][j][k] = dp[i][j][k];
		//0: ???
		//1: A??
		//2: ?B?
		//3: AB?
		//4: ??C
		//5: A?C
		//6: ?BC
		//7: ABC
		if (s[i]=='A') {
			ma.addto(dp[i+1][1][1], 1);
			ma.addto(dp[i+1][3][1], 1);
			ma.addto(dp[i+1][5][1], 1);
			ma.addto(dp[i+1][7][1], 1);
		}
		if (s[i]=='B') {
			ma.addto(dp[i+1][2][2], dp[i][2][1]);
			ma.addto(dp[i+1][3][2], dp[i][3][1]);
			ma.addto(dp[i+1][6][2], dp[i][6][1]);
			ma.addto(dp[i+1][7][2], dp[i][7][1]);
		}
		if (s[i]=='C') {
			for(int j=4;j<=7;j++)
				ma.addto(dp[i+1][j][3], dp[i][j][2]);
		}
		if (s[i]=='?') {
			for(int j=0;j<8;j+=2)
				ma.addto(dp[i+1][j][1], 1);
			ma.addto(dp[i+1][0][2], dp[i][0][1]);
			ma.addto(dp[i+1][1][2], dp[i][1][1]);
			ma.addto(dp[i+1][4][2], dp[i][4][1]);
			ma.addto(dp[i+1][5][2], dp[i][5][1]);
			for(int j=0;j<=3;j++)
				ma.addto(dp[i+1][j][3], dp[i][j][2]);
		}
	}
	int ans = 0;
	ma.addto(ans, ma.mul(dp[len][0][3], pw3[cnt-3]));
	ma.addto(ans, ma.mul(dp[len][1][3], pw3[cnt-2]));
	ma.addto(ans, ma.mul(dp[len][2][3], pw3[cnt-2]));
	ma.addto(ans, ma.mul(dp[len][4][3], pw3[cnt-2]));
	ma.addto(ans, ma.mul(dp[len][3][3], pw3[cnt-1]));
	ma.addto(ans, ma.mul(dp[len][5][3], pw3[cnt-1]));
	ma.addto(ans, ma.mul(dp[len][6][3], pw3[cnt-1]));
	ma.addto(ans, ma.mul(dp[len][7][3], pw3[cnt]));
	printf("%d\n", ans);
	
	return 0;
}	

Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string str;
  cin>>str;
  for(int i=1; i<=3; i++){
    if(str[i-1] == str[i]){
      cout<<"Bad";
      return 0;
    }
    
  }
  cout<<"Good\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

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

    char b;
    cin >> b;
    if(b == 'A') cout << 'T' << endl;
    else if(b == 'T') cout << 'A' << endl;
    else if(b == 'C') cout << 'G' << endl;
    else if(b == 'G') cout << 'C' << endl;

}


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

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

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

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

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

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, k, q;
	cin >> n >> k >> q;
	LL s = 0;
	vector<int> a(n, 0);
	while(q--)
	{
		int x;
		cin >> x;
		a[x - 1]++;
	}
	FOR(i, 0, n) s += a[i];
	FOR(i, 0, n) cout << (k > s - a[i] ? "Yes\n" : "No\n");	
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



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

void solve(void)
{
    ll n;
    cin >> n;
    vector<int> ans;
    if (n == 0)
    {
        cout << 0 << endl;
        return;
    }
    while (n != 0)
    {
        int res;
        if (n > 0)
        {
            res = n % 2;
            n = -(n / 2);
        }
        else
        {
            res = abs(n) % 2;
            n = (abs(n) + 1) / 2;
        }
        ans.emplace_back(res);
    }
    reverse(ans.begin(), ans.end());
    for (auto i : ans)
        cout << i;
    cout << endl;
}
int main(void)
{
    solve();
}

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

#define INF 100000000

//訪問状態
#define White 0
#define Gray 1
#define Black 2

//Treeの状態を表した隣接行列
int Tree[100][100];
int sum = 0;

int prim(int n){
  int u, minv;
  //d = 見て来たノードの中から出る最小の辺を記録
  //p = MSTにおける頂点の親を記録
  int d[100], p[100], color[100];

  for(int i = 0 ; i < n ; i++){
    d[i] = INF;
    p[i] = -1;
    color[i] = White;
  }

  d[0] = 0;

  while(1){
    minv = INF;
    u = -1;

    for(int i = 0 ; i < n ; i++){
      if(minv > d[i] && color[i] != Black){
	u = i ;
	minv = d[i];
      }
    }

    if(u == -1){
      break;
    }

    color[u] = Black;
    for(int v = 0 ; v < n ; v++){
      if(color[v] != Black && Tree[u][v] != INF){
	if(d[v] > Tree[u][v]){
	  d[v] = Tree[u][v];
	  p[v] = u;
	  color[v] = Gray;
	}
      }
    }
  }

  for(int i = 0 ; i < n ; i++){
    if(p[i] != -1) sum += Tree[i][p[i]];
  }

  return sum;

}

int main(){
  int n, status;

  cin >> n;

  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      cin >> status;

      if(status == -1){
	Tree[i][j] = INF;
      }else{
	Tree[i][j] = status;
      }
    }
  }

  cout << prim(n) << endl;

  return 0;
}

Measured memory_bytes: 1200
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0

for i in range(1, N):
    A[i] = A[i - 1] + A[i]
    if A[i] > K:
        A = A[:i]
        break
A = [0] + A
A = A[::-1]

for i in range(1, M):
    B[i] = B[i - 1] + B[i]
    if B[i] > K:
        B = B[:i]
        break
B = [0] + B

A_length = len(A)
B_length = len(B)

j = 0
for i in range(A_length):

    while j < B_length:
        if A[i] + B[j] <= K:
            j += 1
        else:
            break
    j -= 1

    ans = max(ans, A_length - (i + 1) + j)
print(ans)


Measured memory_bytes: 117764
def main():
    s=input()
    a,b=-1,-1
    if len(s)==2:
        if s[0]==s[1]:
            a,b=1,2
    else:
        for i in range(len(s)-2):
            if s[i]==s[i+1] or s[i]==s[i+2]:
                a,b=i+1,i+3
                break
    print(a,b,sep=' ')

if __name__=='__main__':
    main()
        
    

                


Measured memory_bytes: 39280
#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int n, k;
int a[100000];
int w;

int main(void) {
  while(cin >> n >> k, !(n == 0 && k == 0)) {
    w = 0;
    REP(i, 0, k) {
      cin >> a[i];
      if(a[i] == 0) {
        w = 1;
        i--;
        k--;
      }
    }

    sort(a, a + k);

    int i = 0;
    int m = 0;
    while(i < k) {
      int j = i;
      while(j < k && a[j + 1] - a[j] == 1) j++;
      if(w == 1 && a[j + 1] - a[j] == 2) {
        int l = j + 1;
        while(l < k && a[l + 1] - a[l] == 1) l++;
        m = max(m, l - i + 2);
      } else {
        m = max(m, j - i + 1);
      }
      i = j + 1;
    }

    cout << m << endl;
  }

  return 0;
}

Measured memory_bytes: 1492
#include <iostream>
#include <iterator>
#include <string>
#include <unordered_set>

int main()
{
    int N;
    std::unordered_set<std::string> S;

    std::cin >> N;
    S.reserve(N);

    S.insert(std::istream_iterator<std::string>{std::cin}, std::istream_iterator<std::string>{});

    std::cout << S.size() << std::endl;

    return 0;
}

Measured memory_bytes: 17164
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long X, Y;
    cin >> X >> Y;
    long long a = X;
    for(int i=1; i<100; i++){
        a *= 2;
        if(a > Y){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
inline char nc() {
	return getchar();
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
typedef long long ll;
const int maxn = 1e5 + 5;
int n;
int a[maxn];
ll sum[maxn];
ll solve() {
	ll an = sum[n];
	ll x = 0, y = 0;
	for(int i = n; i >= 1; --i) {
		if(a[i] < 0) {
			an = max(an, sum[i - 1] + a[i] - x + y);
			y += x - a[i];
			x = 0;
		}
		else {
			x += a[i];
		}
	}
	return an;
}
int main() {
	read(n);
	for(int i = 1; i <= n; ++i) {
		read(a[i]);
		sum[i] = sum[i - 1] + a[i];
	}
	printf("%lld\n", solve());
	return 0;
} 

Measured memory_bytes: 1408
N,Q = map(int, input().split())
l = [[int(i) for i in input().split()] for Q in range(Q)]
 
base = [0] * N
flag = False
for i in l:
    if i[1] == 0 and i[0]-1 == 0 and N != 1:
        flag = True
        break
    elif base[i[0]-1] == 0:
        base[i[0]-1] = i[1]
    elif base[i[0]-1] == i[1]:
        pass
    elif base[i[0]-1] != i[1]:
        flag = True
        break
 
if flag == True:
    print(-1)
elif N == 1 and base[0] == 0:
    print(0)
elif base[0] == 0:
    base[0] = 1
    a = map(lambda x: str(x), base)
    print(''.join(a))
else:
    a = map(lambda x: str(x), base)
    print(''.join(a))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  int p[N] = {};
  for(int i=1; i<N; i++) if (S[i]=='E') p[0]++; 
  for (int i=1; i<N; i++) {
    if (S[i]=='E'&&S[i-1]=='E') p[i] = p[i-1]-1;
    else if (S[i]=='W'&&S[i-1]=='W') p[i] = p[i-1]+1;
    else p[i] = p[i-1];
  }

  int result = p[0]; rep(i, N) result = min(result, p[i]);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1796
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int i,j,n,a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if((a*100+b*10+c)%4==0){
		printf("YES");
	}else{
		printf("NO");
	}
	return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
vll a;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22) {
		cout<<"bust";
	}
	else {
		cout<<"win";
	}
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 238000
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const long long INF = 1e17;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int x, y, z;
	while(cin >> x >> y >> z) {
		int n = x+y+z;
		vector<LL> a(n), b(n), c(n);
		REP(i,n) cin >> a[i] >> b[i] >> c[i];
		LL sum = accumulate(ALL(a),0ll);
		DEBUG(sum);
		LL dis = -INF;
		{
			vector<LL> bt(n), ct(n);
			REP(i,n){
				bt[i] = b[i]-a[i];
				ct[i] =	c[i]-a[i];
			}
			
			using T = tuple<LL,LL,LL>;
			vector<T> hoge(n);
			REP(i,n){
				hoge[i] = T{ct[i]-bt[i], bt[i], ct[i]};
			}
			sort(ALL(hoge));
			REP(i,n){
				int a, b, c;
				tie(a, b, c) = hoge[i];
				DEBUG(i);
				DEBUG(a); DEBUG(b); DEBUG(c);
			}
			vector<LL> memo(n,-INF);
			{
				int x = y;
				priority_queue<LL,vector<LL>,greater<LL>> qu;
				LL sum = 0;
				REP(i,x){
					int a, b, c;
					tie(a,b,c) = hoge[i];
					qu.emplace(b);
					sum += b;
				}
				memo[x-1] = sum;
				FOR(i,x,n){
					int a, b, c;
					tie(a,b,c) = hoge[i];
					qu.push(b);
					sum += b;
					sum -= qu.top();
					qu.pop();
					memo[i] = sum;
				}
			}

			vector<LL> memor(n,-INF);
			{
				int x = z;
				reverse(ALL(hoge));
				priority_queue<LL,vector<LL>,greater<LL>> qu;
				LL sum = 0;
				REP(i,x){
					int b;
					tie(ignore,ignore,b) = hoge[i];
					qu.emplace(b);
					sum += b;
				}
				memor[x-1] = sum;
				FOR(i,x,n){
					int b;
					tie(ignore,ignore,b) = hoge[i];
					qu.push(b);
					sum += b;
					sum -= qu.top();
					qu.pop();
					memor[i] = sum;
				}
				reverse(ALL(hoge));
				reverse(ALL(memor));
			}

			dpite(ALL(memo)); dpite(ALL(memor));
			REP(i,n-1){
				dis = max(dis,memo[i]+memor[i+1]);
			}
		}
		cout << sum+dis << endl;
	}
	return 0;
}


Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main(){
  string S;
  cin>>S;
  int a=S.size();
  int check=0;
    for(int i=a/2-1;i>0;i--){
        check=0;
        rep(j, i){
            if(S.at(j)!=S.at(i+j)){
                check=1;
                break;
            }
        }
        if(check==0){
            cout<<2*i<<endl;
            break;
        }
    }
}

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

int x[4];

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

    cin >> x[1] >> x[2] >> x[3];
    vector<bool> v(3,false); v[0] = true, v[1] = true;
    int ans = 2e9+5;
    do{
        int sum = 0;
        for(int i=0;i<3;i++)if(v[i])sum += x[i+1];
        ans = min(ans,sum);
    }while(prev_permutation(v.begin(),v.end()));

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=sorted(map(int,input().split()))
A.reverse()

s=[sum(A)]*N #s[i]=sum(A[i:])
ans=1
for i in range(1,N):
  s[i]=s[i-1]-A[i-1]
  if s[i]*2<A[i-1]:
    break
  else:
    ans+=1
print(ans)

Measured memory_bytes: 14320
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(s[K-1])


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
using namespace std;

int main(){
	long long l,r,ans=0,i,j,mod;
	cin >> l >> r;
	if(r-l > 1000){
		ans = 0;
	}else{
		ans = 2019;
		for(i=l+1; i<r+1; i++){
			for(j=l; j<i; j++){
				mod = i*j%2019;
				if(ans>mod){
					ans = mod;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
k=int(input())

q=deque([1,2,3,4,5,6,7,8,9])
for i in range(k):
  x=q.popleft()
  if x%10!=0:
    q.append(10*x+(x%10)-1)
  q.append(10*x+(x%10))
  if x%10 != 9:
    q.append(10*x+(x%10)+1) 
print(x)

Measured memory_bytes: 18916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;} return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;} return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a=0,b=0,c;
    rep(i,4) cin >> c,a+=c;
    rep(i,4) cin >> c,b+=c;
    cout << max(a,b) << endl;
}


Measured memory_bytes: 3164
#include <iostream>

using namespace std;

int main () {
    int x, y;
    while (true) {
        cin >> x >> y;

        if (x == 0 && y == 0) break;
        
        if (x > y) cout << y << " " << x << endl;
        else cout << x << " " << y << endl;
    }
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, dp[100001];

int main() {
	cin >> n;
	
	incII(i, 0, n) { dp[i] = n + 1; }
	
	dp[0] = 0;
	inc1(i, n) {
		int p;
		p = 1; while(i - p >= 0) { setmin(dp[i], dp[i - p] + 1); p *= 6; }
		p = 1; while(i - p >= 0) { setmin(dp[i], dp[i - p] + 1); p *= 9; }
	}
	
	cout << dp[n] << endl;
	
	return 0;
}


Measured memory_bytes: 640
// Sentou
#include <iostream>
#include <algorithm>
using namespace std;
int N,T;
int t,e,ans;

int main(){
    cin>>N>>T;
    for(int i=0;i<N;i++){
        cin>>t;
        ans+=(t+T-max(e,t));
        e=T+t;
    }
    cout<<ans;
}

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

int main(void) {
    string str;
    vector<string> v;
    while (getline(cin, str)) {
        v.push_back(str);
    }

    for (vector<string>::iterator itr = v.begin(); itr != v.end(); itr++) {
        int a, b;
        sscanf((*itr).c_str(), "%d %d", &a, &b);

        int sum = a + b;

        int c = 1;
        int d = 10;
        int z = sum / d;

        while (z != 0) {
            d = d * 10;
            z = sum / d;
            c++;
        }
        printf("%d\n", c);
    }
    return 0;
}

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

using namespace std;

int main() {
  long N;
  cin >> N;
  
  string a, b;
  cin >> a;
  cin >> b;
  long long res = 0;
  for (long i = 0; i < N; i++) {
    if (a[i] == b[i]) {
      if (i == 0)  {
        res = 3;
      } else if (a[i-1] == b[i-1]) {
        res *= 2;
      }
    } else {
      if (i == 0)  {
        res = 6;
      } else if (a[i-1] == b[i-1]) {
        res *= 2;
      } else {
        res *= 3;
      }
      i++;
    }
    res %= 1000000007;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    long long h;
    cin >> h;

    int count = 0;
    while (h) {
        h /= 2;
        count++;
    }

    long long ans = 1;
    REP(i, count - 1)
        ans = ans * 2 + 1;

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
using namespace std;
const int N=1e5+10, mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	string s; int i,j,k,n, mul=10;
	cin>>s; n=s.length();
	
	int dp[n+1][13];
	memset(dp,0,sizeof dp);
	
	if(s[n-1]=='?'){
		for(i=0;i<=9;i++)dp[n-1][i]++;
	}else{
		dp[n-1][ (s[n-1]-'0') ]++;
	}
	
	for(i=n-2;i>=0;i--){
		if(s[i]=='?'){
			for(j=0;j<=9;j++){ // cur
				for(k=0;k<13;k++){ // last
					int x=((1LL*j*mul)%13+k)%13;
					dp[i][x]+=dp[i+1][k];
					dp[i][x]%=mod;
				}
			}
		}else{
			for(j=0;j<13;j++){
				int x=((1LL* ( s[i]-'0' )*mul)%13+j)%13;
				dp[i][x]+=dp[i+1][j];
				dp[i][x]%=mod;
			}
		}
		mul=(mul*10)%13;
	}
	cout<<dp[0][5]<<"\n";
		
}
// check for any potential overflow before submitting


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

int main() {

	int  N;
	int A[99];
	int maxValue;
  	int minValue;
  
	cin >> N;
    cin >> A[0];     
  	maxValue = A[0];
    minValue = A[0];
  
    for (int i = 1; i < N; i++) { 
      cin >> A[i];  
      if (maxValue < A[i] ) maxValue = A[i];
      if (A[i] < minValue ) minValue = A[i];
    }
  	cout << maxValue - minValue << endl;
	return 0;
	
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<iomanip>
using namespace std;
int n,m;
unsigned long long nn,mm;
int main()
{
	cin>>n>>m;
	if(abs(n-m)>1)
	{
		cout<<0<<endl;
		return 0;
	}
	nn=1;
	for(int i=2; i<=n; i++)
		nn=nn*i%1000000007;
	mm=1;
	for(int i=2; i<=m; i++)
		mm=(mm*i)%1000000007;
	if(abs(n-m)==1)cout<<nn*mm%1000000007<<endl;
	else cout<<nn*mm*2%1000000007<<endl;
	return 0;
}

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

public class Main {
    FastScanner in;
    PrintWriter out;

    long ans(long cntOpen, long cntClose) {
        if (cntOpen < cntClose) {
            return ans(cntClose, cntOpen);
        }
        return s(cntOpen) + s(cntClose - 1);
    }

    long s(long x) {
        return x * (x + 1) / 2;
    }

    void solve() {
        char[] s = in.next().toCharArray();
        long res = 0;
        for (int i = 0; i < s.length; ) {
            int cntOpen = 0;
            while (i != s.length && s[i] == '<') {
                cntOpen++;
                i++;
            }
            int cntClose = 0;
            while (i != s.length && s[i] == '>') {
                cntClose++;
                i++;
            }
            res += ans(cntOpen, cntClose);
        }
        out.println(res);
    }

    void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 29024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;

const int maxn=1e3+10;
int n,m,ans,dfn,low[maxn],pre[maxn];
vector<int> g[maxn];

void dfs(int pos,int fa){
	pre[pos]=low[pos]=++dfn;
	for(int i=0;i<g[pos].size();++i)
		if(!pre[g[pos][i]]){
			dfs(g[pos][i],pos);
			low[pos]=min(low[pos],low[g[pos][i]]);
			if(low[g[pos][i]]>pre[pos])
				++ans;
		}
		else if(g[pos][i]!=fa)
			low[pos]=min(low[pos],pre[g[pos][i]]);
}

int main(){
	cin>>n>>m;
	for(int i=0,u,v;i<m;++i){
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int A[1010];
int main(){
	for(int i = 1;i <=1000;i++){
		A[i] = i;
	}
	while(cin>>n,n){
		int s = 1;
		int t = 2;
		int sum = 3;
		int cnt = 0;
		while(t <n){
			if(sum <n){
				sum +=A[++t];
			}else if(sum >n){
				sum -=A[s++];
			}else{
				cnt++;
				sum +=A[++t];
			}
		}
		cout <<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
/*
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const int INF=20050208;
/*------------main part------------*/



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


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
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; }
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path; vl A, T;
//***********//
void bfs(ll now) {
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		flag[u] = 1;
		ll v;
		for (ll i = 0; i < path[u].size(); i++) {
			v = path[u][i];
			if (flag[v] == 0) {
				A[v] = A[u] + 1;
				Q.push(v);
			}
		}
	}
}
void bfs2(ll now) {
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		flag[u] = 1;
		ll v;
		for (ll i = 0; i < path[u].size(); i++) {
			v = path[u][i];
			if (flag[v] == 0) {
				T[v] = T[u] + 1;
				Q.push(v);
			}
		}
	}
}
int main() {
	cin >> N;
	flag.resize(N);
	path.resize(N);
	A.resize(N);
	T.resize(N);
	ll U, V;
	cin >> U >> V;
	for (i = 0; i < N - 1; i++) {
		ll a, b;
		cin >> a >> b;
		path[a - 1].push_back(b - 1);
		path[b - 1].push_back(a - 1);
	}
	A[V - 1] = 0;
	bfs(V - 1);
	for (i = 0; i < N; i++) {
		flag[i] = 0;
	}
	T[U - 1] = 0;
	bfs2(U - 1);
	vl C(N);
	for (i = 0; i < N; i++) {
		C[i] = 0;
	}
	for (i = 0; i < N; i++) {
		ll P = T[i];
		ll Q = A[i];
		while (P <= Q) {
			if (P < Q) {
				C[P] = 2;
			}
			else if (P <= Q) {
				if (C[P] == 0) {
					C[P] = 1;
				}
			}
			P += 2;
		}
	}
	for (i = 0; i < N; i++) {
		if (C[i] == 2) {
			ans++;
		}
		else if (C[i] == 1) {
			ans++;
			break;
		}
	}
	cout << ans-1;
}

Measured memory_bytes: 9600
c = []
for i in range(3):
    a, b = map(int, input().split())
    c.append(a)
    c.append(b)
one = 2
two = 2
for i in range(1, 5):
    if c.count(i) == 1:
        one -= 1
    elif c.count(i) == 2:
        two -= 1
if one == 0 and two == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator it
using namespace std;
typedef long long ll;
ll n,k,sum,a,b;
int main()
{
    cin>>n>>k;
    if(k==0)sum=n*n;
    else
    ff(i,k+1,n)
    {
        b=i;
        ll now=n/b,re=n%b;
        if(re<=k-1) sum+=now*(b-k);
        else
        sum+=((now+1)*(re+1-k)+now*(b-re-1));
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
test_case_1_num = int(input())
test_case_1 = list(map(int,input().split()))

print(" ".join(map(str, test_case_1)))
for i in range(1, test_case_1_num):
    t = test_case_1[i]
    p = i
    for j in range(0, i):
        if t > test_case_1[j]:
            continue
        else:
            for k in reversed(range(j,i)):
                test_case_1[k + 1] = test_case_1[k]
                p -= 1
            break

    test_case_1[p] = t

    print(" ".join(map(str, test_case_1)))


Measured memory_bytes: 5592
#include<iostream>
#include<vector>
#include<algorithm>

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

using namespace std;

int main(){
    int n, m;
    while(cin >> n >> m){
        if(n==0 && m==0) break;
        int t_sum=0, h_sum=0;
        int taros[n], hanakos[m];
        REP(i,n){
            cin >> taros[i];
            t_sum += taros[i];
        }
        REP(i,m){
            cin >> hanakos[i];
            h_sum += hanakos[i];
        }

        int t_ans=100, h_ans=100;
        REP(i,n){
            REP(j,m){
                int tmp_taro = t_sum - taros[i] + hanakos[j];
                int tmp_hanako = h_sum - hanakos[j] + taros[i];
                if(tmp_taro == tmp_hanako && taros[i]+hanakos[j]<t_ans+h_ans){
                    t_ans = taros[i];
                    h_ans = hanakos[j];
                }
            }
        }

        if(t_ans+h_ans == 200) cout << -1 << endl;
        else{
            cout << t_ans << ' ' << h_ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>

using namespace std;

int main(){
	const int MOD = 100000007;
	int dpA[100001], dpB[100001];
	memset(dpA, 0, sizeof(dpA));
	memset(dpB, 0, sizeof(dpB));
	dpA[0] = 1, dpB[0] = 1;
	for(int i=0;i<=100000;i++){
		for(int j=1;j<=5;j++)
			if(i+j<=100000)
				dpA[i+j] = (dpA[i+j]+dpA[i])%MOD;
	}
	for(int i=0;i<=100000;i++){
		for(int j=1;j<=3;j++)
			if(i+j<=100000)
				dpB[i+j] = (dpB[i+j]+dpB[i])%MOD;
	}
	int sumA[100001], sumB[100001];
	memset(sumA, 0, sizeof(sumA));
	memset(sumB, 0, sizeof(sumB));
	for(int i=0;i<=100000;i++){
		sumA[i] = dpA[i];
		if(i-5>0) sumA[i] = (sumA[i]+sumA[i-5])%MOD;
	}
	for(int i=0;i<=100000;i++){
		sumB[i] = dpB[i];
		if(i-3>0) sumB[i] = (sumB[i]+sumB[i-3])%MOD;
	}
	string str;
	while(cin >> str){
		if(str=="#") break;
		int idx = 0;
		long long res = 1;
		while(idx < str.size()){
			int cur = str[idx]-'0';
			int cnt = 0;
			while(idx < str.size() && str[idx]-'0' == cur) cnt++, idx++;
			if(cur == 0 || cur == 8)
				res = (res*sumB[cnt])%MOD;
			else
				res = (res*sumA[cnt])%MOD;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 2704
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//小さい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return aNum - bNum;}

long long _gcd(long long a,long long b){
    long long c;
    while(b!=0){c=a%b;a=b;b=c;}
    return a;
    
}
long long _lcm(long long a,long long b){long long c=_gcd(a,b);a/=c;return a*b;}

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",(a-1)*(b-1));
}




Measured memory_bytes: 128
double x[100],y[100],t,u,a,b,s;
n,i,j,k,c;
main(m){
	for(;m=scanf("%d",&n),j=i=n;printf("%d\n",m)){
		for(;j--;scanf("%lf,%lf",x+j,y+j));
		for(;j=--i;)
			for(;j--;)
				for(u=acos(hypot(a=x[j]-x[i],b=y[j]-y[i])/2),s=1,t=atan2(b,a);c=0,u<9&&s+3;s-=2)
					for(b=y[i]+sin(t+s*u),k=n;k--;)
						hypot(x[i]+cos(t+s*u)-x[k],b-y[k])<1.1&&++c>m?m=c:0;
	}
}

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

#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

#define debug(x) cout << "> " << #x << " = " << x << endl;
#define debug_at(arr, at) cout << "> " << #arr << "[" << at << "] = " << arr[at] << endl;
#define debug_pair(p) cout << "> " << #p << " = (" << p.first << ", " << p.second << ")" << endl;

using namespace std;

typedef long long ll;

const ll INF = 1LL << 62;

ll cost[3];

int main() {
    ios_base::sync_with_stdio(false);

    ll q, h, s, d;
    ll n;

    cin >> q >> h >> s >> d;
    cin >> n;

    cost[1] = min({INF, 4 * q, 2 * h, s});
    cost[2] = min({INF, 2 * cost[1], d});

    ll ans = (n / 2) * cost[2];
    if(n & 1) {
        ans += cost[1];
    }
    cout << ans << '\n';

    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 a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if (a == b && b == c)
      System.out.println("1");
    else if (a == b || b == c || a == c)
      System.out.println("2");
    else
      System.out.println("3");
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,A;
    cin >>N>>A;
    vector<ll>x(N);
    rep(i,N){
        cin>>x[i];
    }

    vector<vector<vector<ll>>>dp(N+1,vector<vector<ll>>(N+1,vector<ll>(3000)));
    
    rep(i,N+1){
        dp[i][0][0]=1;
    }
    rep(i,N){
        rep(j,N){
            rep(k,3000){
                if(k-x[i]>=0){
                    dp[i+1][j+1][k]=dp[i][j+1][k]+dp[i][j][k-x[i]];
                }else{
                    dp[i+1][j+1][k]=dp[i][j+1][k];
                }
            }
        }
    }
    ll ans=0;
    rep2(i,N){
        ans+=dp[N][i][A*i];
        //cout<<dp[N][i][A*i]<<endl;
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 65460