akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

string s;
int f[111111];

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

  cin >> s;

  int one = 0;
  int zero = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == '0'){
      zero++;
    } else {
      one++;
    }
  }

  cout << min(one, zero) * 2 << endl;

  return 0;
}



Measured memory_bytes: 512
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 998244353;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

//vector<ll>v;
//vector<ll>::iterator it;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        ll a,b,c,d,e;
        cin>>a>>b>>c>>d>>e;
        a=60*a+b;
        c=60*c+d;
        a=abs(a-c);
        int ans=0;
        if(a>e){
            ans=a-e;
        }
        else{
            ans=0;
        }
        cout<<ans<<"\n";
        //v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

Measured memory_bytes: 3652
fun main(args: Array<String>) {
  val S = readString()
  val T = readString()

  for (i in 0 until S.length) {
    val l = S.substring(0..i)
    val r = S.substring((i + 1) until (S.length))
    if (r + l == T) {
      println("Yes")
      return
    }
  }
  println("No")
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


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

const int MAX = 60606;
vector<bool> p(MAX, true);
int n;

int main(){
    cin >> n;
    p[0] = p[1] = false;
    for(int i = 2; i < MAX; i++){
        for(int j = i + i; j < MAX; j += i){
            p[j] = false;
        }
    }

    vector<int> sosu(0);
    rep(i, MAX){
        if(i % 5 == 1 && p[i]){
            sosu.emplace_back(i);
        }
    }
    rep(i, n) cout << sosu[i] << ((i == n - 1)? "\n" : " ");
    
    //judge
    /*
    for(int i = 0; i < n - 4; i++){
        for(int j = i + 1; j < n - 3; j++){
            for(int k = j + 1; k < n - 2; k++){
                for(int l = k + 1; l < n - 1; l++){
                    for(int m = l + 1; m < n; m++){
                        if((sosu[i] + sosu[j] + sosu[k] + sosu[l] + sosu[m]) % 5 != 0){
                            cout << "WA" << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << "AC" << endl;
    */

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int n;
int m;
int a[210000];

int main()
{
	cin >> n;
	map<int, int>s;
	int ai;
	for (int i = 0; i < n; i++) {
		cin >> ai;
		s[ai]++;
	}
	
	cin >> m;
	
	int ope = 0;
	int di;
	for (int i = 0; i < m; i++) {
		cin >> di;
		if (s[di] != 0)s[di]--;
		else ope++;
	}
	if (ope != 0)cout << "NO" << endl;
	else cout << "YES" << endl;
	

	return 0;
}

Measured memory_bytes: 9600
n=int(input())
k=int(input())

x=list(map(int, input().split()))
count=0
for i in range(n):
    a_dis=2*x[i]
    b_dis=abs(k-x[i])*2
    if a_dis>=b_dis:
        count+=b_dis
    else:
        count+=a_dis
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>

int main()
{
	std::string a, b;
	std::cin >> a >> b;

	int n = std::atoi( ( a + b ).c_str() );
	int sq = std::sqrt( n );

	std::cout << ( sq * sq == n ? "Yes" : "No" ) << std::endl;
	return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int N = r.i();
        int[] a = r.ii();
        long z = 0;
        for(int i : a)
            z += i;
        long min = Long.MAX_VALUE;
        for(int i = 0; i < N-1; i++){
            z -= 2*a[i];
            long zp = Math.abs(z);
            if(zp < min)
                min = zp;
        }
        println(min);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

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

int main(int argc, char *argv[]){
    int n;
    cin >> n;
    char c[n+1];
    int r=0;
    int w=0;
    int a=0;
    for(int i=0;i<n;i++){
        cin >>c[i];
        if(c[i]=='R') r++;
        else w++;
    }
    for(int i=0;i<r;i++){
        if(c[i]=='W') a++;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
void err() {
  cout << -1 << endl;
  exit(0);
}
void dfs (int crr, int dpt, vector<vector<int>>& grh, long long& cnt) {
  cnt += dpt;
  for (int nxt : grh[crr]) {
    dfs(nxt, dpt + 1, grh, cnt);
  }
}
int main() {
  int n;
  cin >> n;
  vector<long long> d(n);
  map<long long, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    mp[d[i]] = i;
  }
  sort(d.begin(), d.end());
  vector<long long> sz(n, 1);
  vector<int> prt(n);
  vector<vector<int>> grh(n);
  vector<pair<int, int>> edg;
  for (auto it = prev(d.end()); it != d.begin(); it--) {
    auto i = mp[*it];
    long long prtv = *it - n + 2LL * sz[i];
    auto jt = lower_bound(d.begin(), d.end(), prtv);
    if (jt == d.end() || *jt != prtv) err();
    auto p = mp[*jt];
    prt[i] = p;
    grh[p].push_back(i);
    if (i == prt[i]) err();
    sz[prt[i]] += sz[i];
    edg.emplace_back(min(i, prt[i]), max(i, prt[i]));
  }
  long long cnt = 0;
  int rt = mp[d[0]];
  dfs(rt, 0, grh, cnt);
  if (d[0] != cnt) err();
  sort(edg.begin(), edg.end());
  for (auto const & e : edg) {
    cout << e.first + 1 << ' ' << e.second + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 18164
N = int(input())
A = list(map(int, input().split()))
a_to_i = {a: i for i, a in enumerate(A, start=1)}

L = [i - 1 for i in range(N + 2)]
R = [i + 1 for i in range(N + 2)]

ans = 0
for a in range(N, 0, -1):
    i = a_to_i[a]
    ans += a * (R[i] - i) * (i - L[i])
    L[R[i]] = L[i]
    R[L[i]] = R[i]

print(ans)

Measured memory_bytes: 46492
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int f(const vector<string> &C, int idx) {
    const int H = C.size();
    vector<vector<int>> dp(H+1, vector<int>(H+1));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < H; j++) {
            if (C[i][idx] == C[j][idx+1]) {
                dp[i+1][j+1] += 1;
            }
        }
    }
    for (int i = 0; i <= H; i++) {
        int s = i, t = 0;
        while (s+1 <= H && t+1 <= H) {
            dp[s+1][t+1] += dp[s][t];
            s++, t++;
        }
    }
    for (int j = 1; j <= H; j++) {
        int s = 0, t = j;
        while (s+1 <= H && t+1 <= H) {
            dp[s+1][t+1] += dp[s][t];
            s++, t++;
        }
    }
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= H; j++) {
            dp[i][j] += min(dp[i-1][j], dp[i][j-1]);
        }
    }
    return dp[H][H];
}
int main() {
    int H, W; cin >> H >> W;
    vector<string> C(H); for (auto &c : C) cin >> c;
    int ans = 0;
    for (int i = 0; i < W-1; i++) {
        ans += f(C, i);
    }
    cout << ans << '\n';
    return 0;
}


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

ans = 0
for i in range(n-1):
    if a[i] == i + 1:
        a[i], a[i + 1] = a[i+1], a[i]
        ans += 1
for i in range(n-1, 1, -1):
    if a[i] == i + 1:
        a[i-1], a[i] = a[i], a[i-1]
        ans += 1
print(ans)


Measured memory_bytes: 14008
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>

int main() {

	double a, b, x;
	cin >> a >> b >> x;
	
	double s = a * a * b;//体積
	
	double ans;

	if (x <= (double)s / 2) {
		ans = 90 - atan(2*x/(a*b*b)) * 180 / M_PI;
		cout << setprecision(10) << ans << endl;
	}
	else {
		ans = 90 - atan(a*a*a/(2*(a*a*b-x))) * 180 / M_PI;
		cout << setprecision(10) << ans << endl;
 	}


	return 0;

}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

bool IsPrime(int n)
{
    if(n<2) return false;
    if(n==2) return true;
    if(n%2==0) return false;
    for(int i=3;i*i<=n;i+=2){
        if(n%i==0) return false;
    }
    return true;
}

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

    int n;
    while(cin>>n,n)
    {
        int cnt=0;
        for(int i=n+1;i<=2*n;i++){
            if(IsPrime(i)) cnt++;
        }
        cout<<cnt<<endl;
    }
}

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

const int MOD = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b;
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    if (n%2==0) {
        for (int i=0; i<n; i+=2) {
            if (a[i] == a[i+1]) {
                b.push_back(a[i]);
            } else {
                cout << 0 << endl;
                return 0;
            }
        }
    } else {
        for (int i=1; i<n; i+=2) {
            if (a[i] == a[i+1]) {
                b.push_back(a[i]);
            } else {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    int ans = 1;
    rep(i, b.size()) {
        ans *= 2;
        ans %= MOD;
    }

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

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD1 1000000007

int main() {
  int a,b;
  cin >> a >> b;
  if(a*b % 2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;

}

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

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N];

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

  rep(i, n) {
    cin >> to[0][i];
    to[0][i]--;
  }

  rep(i, D - 1) {
    rep(j, n) { to[i + 1][j] = to[i][to[i][j]]; }
  }

  int v = 0;
  for (int i = D - 1; i >= 0; --i) {
    ll l = 1ll << i;
    if (l <= k) {
      v = to[i][v];
      k -= l;
    }
  }
  cout << v + 1 << endl;

  return 0;
}

Measured memory_bytes: 50504
#include<bits/stdc++.h>
using namespace std;
int n,a[15][15],ans;
string to(int x)
{
    string s;
    while(x)
    {
        s.push_back((x%10)+'0');
        x/=10;
    }
    reverse(s.begin(),s.end());
    return s;
}
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("milkvisits.in","r",stdin);
    //freopen("milkvisits.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        string s=to(i);
        int l=*s.begin()-'0',r=*--s.end()-'0';
        a[l][r]++;
    }
    for(int i=1;i<=10;i++)
    {
        for(int j=1;j<=10;j++)
        {
            ans+=a[i][j]*a[j][i];
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<vector>
#include<cstdio> 
#include<cstring> 
#include<map>
#include<cmath> 
#include<algorithm>
#include<bitset>
#include<ctime> 
using namespace std; 
#define ll long long
#define rep(i,x,y)  for(ll i=x;i<y;++i)
#define For(i,x,y)  for(ll i=x;i<=y;++i) 
#define FOr(i,x,y)  for(ll i=x;i>=y;--i) 
ll read(){  ll x=0,f=1; char ch=getchar();  for(;ch<'0'||ch>'9';ch=getchar()) if (ch=='-')    f=-1;   for(;ch>='0'&&ch<='9';ch=getchar())   x=x*10+ch-'0';  return x*f; } 
void write(ll x){   if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  } 
void writeln(ll x){ write(x);   puts("");   }
const ll mod=998244353,N=1000010;
ll n,m,inv[N+5],fac[N+5],pre[N+5],ans;
ll C(ll n,ll m){	return fac[n+m]*pre[n]%mod*pre[m]%mod;	}
ll get(ll x1,ll y1,ll x2,ll y2){	return (x1<=x2&&y1<=y2)?C(x2-x1,y2-y1):0;	}
void add(ll &x,ll y){	x=(x+y)%mod;	}
void del(ll &x,ll y){	x=(x-y)%mod;	}
ll ppow(ll x,ll k){	ll ans=1;	while(k){	if (k&1)	ans=ans*x%mod;	x=x*x%mod;	k>>=1;	}return ans;	}
int main(){
	n=read();	m=read();	if (n>m)	swap(n,m);	inv[0]=inv[1]=fac[0]=pre[0]=1;
	For(i,2,N)	inv[i]=inv[mod%i]*(mod-mod/i)%mod;
	For(i,1,N)	fac[i]=fac[i-1]*i%mod,pre[i]=pre[i-1]*inv[i]%mod;
	ll v1=C(n-1,m),v2=C(n,m-1),tmp=0;
	For(i,1,n+m){
		add(tmp,v1+v2);
		i&1?(del(v1,get(0,0,i/2,i/2)*get(i/2,i/2+1,n-1,m)),del(v2,get(0,0,i/2,i/2)*get(i/2+1,i/2,n,m-1)),0):
			(add(v1,get(0,0,i/2-1,i/2)*get(i/2,i/2,n-1,m)),add(v2,get(0,0,i/2,i/2-1)*get(i/2,i/2,n,m-1)),0);
		add(ans,tmp*inv[i]);
	}
	writeln((ans*ppow(C(n,m),mod-2)%mod+mod)%mod);
}
/*
struct tr{
	ll head[N],nxt[N],vet[N],n,tot;
	void insert(ll x,ll y){	nxt[++tot]=head[x];	head[x]=tot;	vet[tot]=y;	}
	void init(){
		n=read();
		For(i,2,n){
			ll x=read(),y=read();
			insert(x,y);	insert(y,x);
		}
	}
	void dfs(ll x,ll pre){
		sz[x]=1;	ll ans=0;
		for(ll i=head[x];i;i=nxt[i])	if (vet[i]^pre)	dfs(vet[i],x),sz[x]+=sz[vet[i]],ans=max(ans,sz[vet[i]]);
		ans=max(ans,n-sz[x]);	if (ans<=n/2)	rt=x;
	}
}a,b;
int main(){
	a.read();	b.read();	b.dfs(1,0);
}*/

Measured memory_bytes: 23552
#include<iostream>

using namespace std;

class dice {

public:

	int TOP, S, E, W, N, BOTTOM, tmp;

	void rotN () {
		tmp = N;
		N = TOP; TOP = S; S = BOTTOM, BOTTOM = tmp;
	}
	void rotE () {
		tmp = E;
		E = TOP; TOP = W; W = BOTTOM; BOTTOM = tmp;
	}
	void rotW () {
		tmp = W;
		W = TOP; TOP = E; E = BOTTOM; BOTTOM = tmp;
	}
	void rotS () {
		tmp = S;
		S = TOP; TOP = N; N = BOTTOM; BOTTOM = tmp;
	}
	void clockwise () {
		tmp = W;
		W = S; S = E; E = N; N = tmp;
	}
	void antiClockwise () {
		tmp = W;
		W = N; N = E; E = S; S = tmp;
	}
};


int main(){

    int num, i, dice_num[6];
    int n, top_num, s_num;

    for(i=0;i<6;i++){
        cin >> num;
        dice_num[i] = num;
    }

    dice dice = {dice_num[0], dice_num[1], dice_num[2], dice_num[3], dice_num[4], dice_num[5]};

    cin >> n;

    for(i=0;i<n;i++){

        cin >> top_num >> s_num;

        int j = 0;

        while(dice.TOP != top_num){
            dice.rotN();
            // cout << "rotN" << endl;
            j++;
            if(j == 4){
                dice.rotE();
                // cout << "rotE" << endl;
            }
        }

        while(dice.S != s_num){
            dice.clockwise();
            // cout << "clockwise" << endl;
        }

        cout << dice.E << endl;

    }

    return 0;

}


Measured memory_bytes: 2992
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Apr  5 22:47:49 2019

@author: lab
"""

a,b,k = map(int,input().split())

n = min(a,b)
count = 0
while n>0:
    if int(a%n) == 0 and int(b%n) == 0:
        count += 1
        if count == k:
            print(n)
            break
        n -= 1
    else:
        n -= 1
        
        

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,p;
map<long long,long long> f;
map<long long,long long>::iterator it;
void get() {
	long long temp=p;
	for(long long i=2;i*i<=p;i++) {
		if(temp==1) break;
		if(temp%i==0) {
			while(temp%i==0) {
				temp/=i;
				f[i]++;
			}
		}
	} 
}
int main() {
	cin>>n>>p;
	get();
	long long cnt=1;
	if(n==1) {
		cout<<p;
		exit(0);
	}
	for(it=f.begin();it!=f.end();it++) {
		while(it->second>=n) {
			cnt*=it->first;
			it->second-=n; 
		}
	}
	cout<<cnt;
	return 0;
}

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

int main(){
	int n,a,b,c,d[100];
	scanf("%d %d %d %d",&n,&a,&b,&c);
	for(int i = 0;i < n;i++) scanf("%d",&d[i]);
	sort(d,d + n,greater<int>());
	int ma = c / a,sum = c;
	for(int i = 0;i < n;i++){
		sum += d[i];
		ma = max(ma,sum / (a + (i + 1) * b));
	}
	printf("%d\n",ma);
}

Measured memory_bytes: 2808
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H1 = scanner.nextInt();
        int M1 = scanner.nextInt();
        int H2 = scanner.nextInt();
        int M2 = scanner.nextInt();
        int K = scanner.nextInt();
        scanner.close();

        System.out.println(H2 * 60 + M2 - (H1 * 60 + M1) - K);

        
    }
}


Measured memory_bytes: 35764
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from collections import Counter

pos = "Possible"
imp = "Impossible"
def judge(nums):
    N = len(nums)
    count = Counter(nums)
    mx = max(nums)

    if mx == 1:
        if N == 2:
            return pos
        else:
            return imp
    elif mx == 2:
        if count[1] == 1 and count[2] >= 2:
            return pos
        else:
            return imp
    else:
        mid = (mx + 1) // 2

        for i in range(1, mid):
            if count[i] != 0:
                return imp
        if mx % 2 == 1:
            if count[mid] != 2:
                return imp
        else:
            if count[mid] != 1:
                return imp

        for i in range(mid+1, mx+1):
            if count[i] < 2:
                return imp

        return pos
                
dummy = int(input())
nums = list(map(int,input().split()))
print(judge(nums))


def mk(array):
    ret = []
    n = 1
    for e in array:
        ret += [n] * e
        n += 1
    print(ret)
    return ret




Measured memory_bytes: 3444
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Char
import Data.List

-- space delimited integers
getVals::IO [Int]
getVals = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
 

-- space delimited strings
getStrings::IO [String]
getStrings = (map BS.unpack . BS.words) <$> BS.getLine

main::IO()
main = do 
    n:_<-getVals
    dat <- forM [1..n] (\_ -> do
        x:y:_ <- getVals
        return (x,y)
        )
    putStrLn $ if solver dat then "Yes" else "No"


solver::[(Int,Int)]->Bool
solver ls = 3 <= (safeMax $ map length $ filter (\ (h:_) -> h) $ group $ map (\ (x,y) -> x == y) ls)

safeMax::[Int]->Int
safeMax [] = 0
safeMax ls = maximum ls

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    for(ll i=0; i<n; ++i){cin >> a[i];}
    bool ok = true;
    sort(a.begin(), a.end());
    for(ll i=0; i<n; ++i){
        if(a[i]==a[i+1]){ok = false;}
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

const int mod = 1000000007;

long long dp[1010][1010];
char a[1010][1010];

int main(){
	dp[0][1] = 1;
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++){
		scanf("%s", a[i] + 1);
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			if (a[i][j] != '#') dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}
	printf("%I64d\n", dp[n][m]);
	return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int>a(n);
  rep(i,0,n) cin >> a[i];
  rep(i,k,n) cout << (a[i] > a[i-k] ? "Yes" : "No") << endl;
}

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

const int N = 200006;

vector<int> G[N];

int a[N];
int cnt[2][N];
int vis[N];

bool fail(int x)
{
    return cnt[0][x] == 0 || cnt[1][x] == 0;
}

int main ()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    for (int i=0;i<m;++i)
    {
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i=0;i<n;++i)
    {
        if (s[i] == 'A') a[i+1] = 1;
        else a[i+1] = 0;
    }
    for (int i=1;i<=n;++i)
    {
        for (int j:G[i])
        {
            cnt[ a[i] ][j]++;
        }
    }
    queue<int> que;
    int cntt=0;
    for (int i=1;i<=n;++i)
    {
        if (fail(i))
        {
            vis[i] = true;
            que.push(i);
        }
    }
    while (!que.empty())
    {
        ++cntt;
        int x=que.front();
        que.pop();
        for (int j:G[x])
        {
            cnt[ a[x] ][j]--;
            if (!vis[j] && fail(j))
            {
                que.push(j);
                vis[j] = true;
            }
        }
    }
    if (cntt == n) puts("No");
    else puts("Yes");
}



Measured memory_bytes: 14032
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;int H[N];
    for(int i=0;i<N;i++){
        cin>>H[i];
    }bool flag,check;int result=0;
    while(true){
        flag=false;check=false;
        for(int i=0;i<N;i++){
            if(H[i]>0){
                H[i]--;
                flag=true;
                check=true;
                if(i==N-1){
                    result++;
                }
            }else if(flag){
                result++;
                flag=false;  
            }if(i==N-1&&check==false){
                cout<<result<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll f(ll z){
	ll ans=0;
	while(z){
		ans+=z%10;
		z/=10;
	}
	return ans;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll x=f(n);
	if(n%x==0) cout << "Yes";
	else cout << "No";
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
import math
a , b, x = map(int,input().split())

water_h = x / (a ** 2)
emp_high = b - water_h
if 2 * emp_high <= b:
    ans = 2 * emp_high / a
else:
    c = 2 * x / (b * a)
    ans = b / c
print(math.degrees(math.atan(ans)))

Measured memory_bytes: 3060
using System;
class Program
{
    static void Main(string[] args)
    {
        bool i = false;
        int n, k, q, j;
        int[] m, x = new int[4], y = new int[4], p = new int[] { 10, 50, 100, 500 };

        while (true)
        {
            n = int.Parse(Console.ReadLine());
            if (n==0) { break; }
            if (!i) { i = !i; } else { Console.WriteLine(); }
            k = 0;
            m = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            for (j = 3; j >= 0; j--)
            {
                k += m[j] * p[j];
            }
            q = k - n;
            for (j = 3; j >= 0; j--)
            {
                x[j] = q / p[j];
		q -= x[j] * p[j];
                y[j] = m[j] - x[j];
            }

            for (j = 0; j < 4; j++)
            {
                if (y[j]>0) { Console.WriteLine("{0} {1}", p[j], y[j]); }
            }
        }
    }
}


Measured memory_bytes: 9304
#include <stdio.h>
#define W 5
#define H_MAX 10
#define THRESHOLD 3
#define EMPTY -1

int field[W + 1][H_MAX];
int h;

int main(void)
{
    int x, y, i, stable, score;

    for(y = 0; y < H_MAX; y++)
        field[W][y] = EMPTY;

    while(scanf("%d", &h), h)
    {
        for(y = 0; y < h; y++)
            for(x = 0; x < W; x++)
                scanf("%d", &field[x][y]);

        stable = score = 0;

        while(!stable)
        {
            stable = 1;
            for(y = 0; y < h; y++)
                for(x = i = 0; x < W; x++)
                {
                    i++;
                    if(field[x][y] != field[x + 1][y])
                    {
                        if(i >= THRESHOLD && field[x][y] != EMPTY)
                        {
                            stable = 0;
                            score += field[x][y] * i;
                            while(i--) field[x - i][y] = EMPTY;
                        }
                        i = 0;
                    }
                }

            for(x = 0; x < W; x++)
                for(y = h - 1; y > 0; y--)
                    if(field[x][y] == EMPTY)
                    {
                        for(i = y; field[x][i] == EMPTY && i > 0; i--);
                        field[x][y] = field[x][i];
                        field[x][i] = EMPTY;
                    }
        }

        printf("%d\n", score);
    }

    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<long>a(n);
	for (int i = 0;i < n;i++) {
		a[i] = i + 1;
	}
	long x;
	long ans = 1;
	long cnt = 1;
	for (int i = 0;i < n;i++) {
		if (a[i] > 1) {
			x = a[i];
			a[i] /= x;
			for (int j = i + x;j < n;j += i + 1) {
				if (a[j] == 1) {
					continue;
				}
				while (a[j] % x == 0) {
					a[j] /= x;
					cnt++;
					cnt %= 1000000007;
				}
			}
			ans *= cnt + 1;
			ans %= 1000000007;
			cnt = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

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


int inum(int N,int W){
    return N/W;
}
int jnum(int N,int W){
    if((N/W)%2) return N%W;
    else return W - (N%W) - 1;
}

int main(){
    int h,w,n;
    cin >> h >> w >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int table[h][w];

    int N = 0;
    rep(i,n){
        rep(j,a[i]){
            int y = inum(N,w);
            int x = jnum(N,w);
            table[y][x] = i+1;
            //cout << x <<" " << y << endl;
            N++;
        }
    }

    rep(i,h){
        rep(j,w){
            cout << table[i][j]<< " ";
        }
        cout << endl; 
    }


}


Measured memory_bytes: 3676
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');//2?????\?????????????????????????????\????????????
            var a = int.Parse(str[0]);  //??°?????§????????????????????´??????????????????
            var b = int.Parse(str[1]);
            Console.WriteLine("{0} {1}", a * b, (a + b) * 2);
        }
    }
}

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

#define MAX 100000

int main() {
	int N, A[MAX + 2];
	cin >> N;
	A[0] = 0;
	A[N + 1] = 0;
	int sum = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		sum += abs(A[i] - A[i - 1]);
	}
    sum += abs(A[N+1] - A[N]);
	for (int i = 1; i <= N; i++) {
		cout << sum - abs(A[i + 1] - A[i]) - abs(A[i] - A[i - 1]) +
					abs(A[i + 1] - A[i - 1])
			 << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        String ring = s + s;
        String check = scan.nextLine();
        if(ring.contains(check)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 26328
#include <stdio.h>
int main(){
	while(1){
	int change,i,ans=0;
	int coin[]={500,100,50,10,5,1};
	scanf("%d",&change);
	if(change==0)break;
	change=1000-change;
	for(i=0;i<6;i++){
		ans += change/coin[i];
		change %= coin[i];
	}
	printf("%d\n",ans);
	}
return 0;
}

Measured memory_bytes: 600
import collections
H,W=map(int,input().split())
S=[input() for i in [0]*H]
M=[[-1]*W for _ in [0]*H]
k=0
for y in range(H):
    for x in range(W):
        if M[y][x]!=-1:continue #visited
        M[y][x]=k
        Q=collections.deque()
        Q.append((y,x))
        while len(Q)>0:
            i,j=Q.popleft()
            s=S[i][j]
            if i+1<H and M[i+1][j]==-1 and s!=S[i+1][j]:
                M[i+1][j]=k
                Q.append((i+1,j))
            if i-1>=0 and M[i-1][j]==-1 and s!=S[i-1][j]:
                M[i-1][j]=k
                Q.append((i-1,j))
            if j+1<W and M[i][j+1]==-1 and s!=S[i][j+1]:
                M[i][j+1]=k
                Q.append((i,j+1))
            if j-1>=0 and M[i][j-1]==-1 and s!=S[i][j-1]:
                M[i][j-1]=k
                Q.append((i,j-1))
            #print(k,M,Q)
        k+=1
ds={}
dd={}
for i in range(H):
    for j in range(W):
        m=M[i][j]
        if S[i][j]=='#':ds[m]=ds.get(m,0)+1
        else:dd[m]=dd.get(m,0)+1
r=0
for i in range(k):
    r += ds.get(i,0)*dd.get(i,0)
print(r)

Measured memory_bytes: 18400
# C
L, R = map(int,input().split())

l =[]

for j in range(L, R+1):
    for i in range(j+1, R+1):
        l.append(i * j % 2019)
        if i * j % 2019 == 0:
            break
    else:
        continue
    break

print(min(l))


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

public class Main {
	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		int w = nextInt();
		int[] weight = new int[n];
		int[] val = new int[n];
		long[] dp = new long[w + 1];
		for(int i = 0; i < n; i++) {
			weight[i] = nextInt();
			val[i] = nextInt();
		}
		for(int i = 0; i < n; i++) {
//			System.out.println(Arrays.toString(dp));
			for(int k = w; k >= weight[i]; k--) {
				if(dp[k - weight[i]] == 0)
					continue;
				dp[k] = Math.max(dp[k], dp[k - weight[i]] + val[i]);
			} 
			if(weight[i] <= w)
				dp[weight[i]] = Math.max(dp[weight[i]], val[i]);
		}
//		System.out.println(Arrays.toString(dp));
		long max = 0;
		for(int i = 0; i <= w; i++)
			max = Math.max(max, dp[i]);
		System.out.println(max);
	}
	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
}


Measured memory_bytes: 22356
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i,j;
	int N;
	long K;
	int *A;
	int *s;
	int sindex;
	int circ, leng;
	int *ord;
	int temp;
	int v;
	
	scanf("%d %ld", &N, &K);
	A = (int *)malloc(sizeof(int)*N);
	s = (int *)malloc(sizeof(int)*N);
	ord = (int *)malloc(sizeof(int)*(N+1));
	for (i =0; i < N+1; i++) {
		ord[i] = -1;
	}
	
	for (i =0; i < N; i++) {
		scanf(" %d", &A[i]);
	}

	v = 1;
	sindex=0;
	circ = 0;
	leng = 0;
	while (ord[v] == -1) {
		ord[v] = sindex;
		s[sindex++] = v;
		v = A[v-1];
	}
	circ = sindex - ord[v];
	leng = ord[v];

	if (K < leng) {
		v = 1;
		for (i = 0; i < K; i++) {
			v = A[v-1];
		}
	} else {
		v = 1;
		for (i = 0; i < leng; i++) {
			v = A[v-1];
		}
		temp = (K - leng) % circ;
		for (i = 0; i < temp; i++) {
			v = A[v-1];
		}
	}
	printf("%d\n", v);

	free(A);
	free(s);
	free(ord);
	return EXIT_SUCCESS;
}


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

using namespace std;

typedef long long ll;
const double eps=1e-6,pi=acos(-1);
const int N=1e3+5,M=1e9+7,SEGM=4*N,OO=0x3f3f3f3f;
int t,n,W;
int p[N],w[N];
int mem[105][105*N];

int solve(int i,int remV){
    if(i==n){
        return remV==0?0:(int)1e9;
    }
    int &ret=mem[i][remV];
    if(~ret) return ret;
    ret=solve(i+1,remV);
    ret=min(ret,solve(i+1,remV-p[i])+w[i]);
    return ret;
}

int main(){
    //freopen("myfile.txt","w",stdout);
    scanf("%d%d",&n,&W);
    int sumall=0;
    for(int i=0;i<n;++i)
        scanf("%d%d",w+i,p+i),sumall+=p[i];
    memset(mem,-1,sizeof mem);
    for(int i=sumall;i>=0;--i){
        if(solve(0,i)<=W){
            printf("%d",i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 47088
#include <cstdio>
using namespace std;

const int N = 20500;

int P[N];

int A[N], B[N];

int val[N];

const int S = 500 * 1000 * 1000;

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &P[i]);
        --P[i];
        val[P[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        printf("%d%c", S + N * i, " \n"[i + 1 == n]);
    }
    for (int i = 0; i < n; i++) {
        printf("%d%c", S - N * i + val[i], " \n"[i + 1 == n]);
    }
}


Measured memory_bytes: 768
readline = open(0).readline
Q = int(readline())
ans = []
M = {}
get = lambda key, push=ans.append,get=M.get: push("%s\n" % get(key,"0"))
def delete(key):
    if key in M: del M[key]
C = [M.__setitem__, get, delete].__getitem__
for q in range(Q):
    t, *a = readline().split()
    C(int(t))(*a)
open(1, 'w').writelines(ans)



Measured memory_bytes: 41880
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
const int N=2010;
int ne[N*2],tot,fi[N],zz[N*2],n,m,x,y;
bitset<N>M[N],sub_tree[N],S[N][N],res;
vector<int>g[N];
queue<pair<int,int> >q;
int now;
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
void dfs(int x,int y){
	sub_tree[x].reset();
	sub_tree[x][x]=S[now][x][x]=1;
	for(int i=fi[x];i;i=ne[i])
		if (zz[i]!=y){
			S[now][zz[i]]=S[now][x];
			dfs(zz[i],x);
			sub_tree[x]|=sub_tree[zz[i]];
		}
	S[now][x]|=sub_tree[x];
}
void add_edge(int x,int y){
	M[x][y]=M[y][x]=1;
	q.push(mp(x,y));
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		jb(x,y);jb(y,x);
	}
	for (int i=1;i<=n;i++)now=i,dfs(i,0);
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++)
			S[i][j]=S[j][i]=(S[i][j]|S[j][i]);
	while (m--){
		scanf("%d%d",&x,&y);
		add_edge(x,y);
	}
	for (int i=1;i<=n;++i)M[i][i]=1;
	int ans=0;
	while (!q.empty()){
		pair<int,int> x=q.front();
		q.pop();ans++;
		res=(M[x.fi]^M[x.se])&S[x.fi][x.se];
		for (int it=res._Find_first();it!=res.size();it=res._Find_next(it))
			if (M[x.fi][it])add_edge(x.se,it);
			else add_edge(x.fi,it);
	}
	printf("%d",ans);
	return 0;
}


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

ll max3(ll x, ll y, ll z) {
  vector<ll> v;
  v.push_back(x);
  v.push_back(y);
  v.push_back(z);
  sort(v.begin(), v.end());
  return v[2];
}

ll min3(ll x, ll y, ll z) {
  vector<ll> v;
  v.push_back(x);
  v.push_back(y);
  v.push_back(z);
  sort(v.begin(), v.end());
  return v[0];
}

int main() {
  ll h, w;
  cin >> h >> w;
  ll ans = 10000000000LL;
  if(h>2) {
    for(int x=1; x<h; x++) {
      ll rh = h-x;
      if(rh<2) break;
      ll ma = w*max3(x, rh/2, rh-rh/2);
      ll mi = w*min3(x, rh/2, rh-rh/2);
      ans = min(ans, ma-mi);
    }
  }
  if(w>2) {
    for(int x=1; x<w; x++) {
      ll rw = w-x;
      if(rw<2) break;
      ll ma = h*max3(x, rw/2, rw-rw/2);
      ll mi = h*min3(x, rw/2, rw-rw/2);
      ans = min(ans, ma-mi);
    }
  }
  for(int x=1; x<h; x++) {
    ll rh = h-x;
    ll a = x*w;
    ll b = rh*(w/2);
    ll c = rh*(w-w/2);
    ll ma = max3(a, b, c);
    ll mi = min3(a, b, c);
    ans = min(ans, ma-mi);
  }
  for(int x=1; x<w; x++) {
    ll rw = w-x;
    ll a = x*h;
    ll b = rw*(h/2);
    ll c = rw*(h-h/2);
    ll ma = max3(a, b, c);
    ll mi = min3(a, b, c);
    ans = min(ans, ma-mi);
  }
  cout << ans << endl;
  return 0;
}
 

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

int x, y, z;

void input() {
    cin >> x >> y >> z;
}

void solve() {
    if(x+y+z > 21) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}
int main() {
    input();
    solve();
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
		String n = sc.next();
      
      for(int i = 0; i < 3; i++){
        if(n.charAt(i) == '7'){
          System.out.println("Yes");
          return;
        }
      }
      	
      System.out.println("No");
	}
}

Measured memory_bytes: 35744
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int s = Integer.parseInt(scanner.nextLine());

		HashMap<Integer, Boolean> map = new HashMap<Integer, Boolean>();

		int preVal = 0;

		for (int i = 0; i < 1000000; i++) {
			if (i == 0) {
				map.put(s, true);
				preVal = s;

				continue;
			}

			int val = f(preVal);
			if (map.get(val) != null) {
				System.out.println(i + 1);
				return;
			} else {
				map.put(val, true);
				preVal = val;
			}
		}

	}

	private static int f(int n) {
		if (n % 2 == 0) {
			return n / 2;
		} else {
			return 3 * n + 1;
		}
	}

}


Measured memory_bytes: 21716
n,q = map(int,input().split())
queue = []
for i in range(n):
	name,time = input().split()
	queue.append((name, int(time)))

t = 0
while queue:
	name,time = queue.pop(0)
	t += min(q, time)
	if time > q:
		queue.append((name, time-q))
	else:
		print(name,t)


Measured memory_bytes: 12236
#include <iostream>
#include <cstdlib>

using namespace std;

int mf = 1000000007;

long long factorial(long long num) {
  long long result = 1;
  for (int i = 1; i <= num; i++) {
    result = (result * i) % mf;
  }
  return result;
}

int main() {
  int n, m;
  cin >> n >> m;
  int diff = n - m;

  //cout << "diff:" << diff << endl;
  //cout << "abs(diff):" << abs(diff) << endl;
  if (abs(diff) > 1) {
    cout << 0 << endl;
    exit(0);
  }

  int change_pattern;
  if ((n - m) == 0) {
    change_pattern = 2;
  } else {
    change_pattern = 1;
  }
  //cout << "change_pattern:" << change_pattern << endl;

  long long dog = factorial(n) % mf;
  //cout << "dog:" << dog << endl;
  long long  monkey = factorial(m) % mf;
  //cout << "monkey:" << monkey << endl;
  long long result = (dog * monkey) % mf ;
  //cout << "result:" << result << endl;
  result = (result * change_pattern) % mf;
  cout << result << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 1000000

int main()
{
  int i,j,key,n,q,cnt=0,S[N],T[N];

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);

  scanf("%d",&q);
  i = 0;
  while(i<q)
    {
      scanf("%d",&T[i]);
      for(j=0;j<i;j++)
	if(T[i] == T[j]) break;
      if(i == j) i++;
    }

  for(i=0;i<q;i++)
    {
      j = 0;
      key = T[i];
      S[n] = key;
      while(key != S[j])
	{
	  j++;
	  //if(j == n) break;
	}
      if(j != n) cnt++;
    }

  printf("%d\n",cnt);
    return 0;
}



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

typedef long long ll;

int main() {
    int n;
    int ans = 0;
    cin >> n;

    for (int i = 1; i <= n; i += 2) {
        int cnt = 0;
        for (int j = 1; j <= i; j+= 2) {
            if (i % j == 0) {
                cnt++;
            }
        }
        if (cnt == 8) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
using namespace std;
#define MAXN 21
int k , n , dp[1 << 21][21];
char ch[1 << 21];
int main() {
    cin >> n >> k;
    for( int i = 0 ; i <= n ; ++ i ) {
        scanf("%s",ch);
        for( int j = 0 ; j < ( 1 << i ) ; ++ j )
            dp[( 1 << i ) | j][i] = ( ch[j] == '1' );
    }
    int re1 = 0 , re2 = 0;
    for( int i = n ; i >= 0 ; -- i ) {
        for( int j = 0 ; j < ( 1 << i ) ; ++ j ) // sta : ( 1 << i ) | j
            for( int k = i ; k > 0 ; -- k ) if( dp[( 1 << i ) | j][k] ) {
                int S = ( j >> k ) , T = ( j & ( 1 << k ) - 1 ) , f = dp[( 1 << i ) | j][k];
                dp[( 1 << i - k ) | S][0] += f;
                int ls = T & ( 1 << k ) - 1 , re = (~T) & ( 1 << k ) - 1;
                if( T ) {
                    int u = 31 - __builtin_clz( ls );
//                    cout << ls << ' ' << u << endl;
                    dp[( 1 << i - k + u + 1 ) | ( S << u + 1 ) | ( 1 << u ) | ( T & ( 1 << u ) - 1 )][u] += f;
                }
                if( re ) {
                    int u = 31 - __builtin_clz( re );
//                    cout << T << ' ' << u << ' ' << k << endl;
                    dp[( 1 << i - k + u + 1 ) | ( S << u + 1 ) | ( T & ( 1 << u ) - 1)][u] += f;
                }
            }
    }
    for( int i = n ; i >= 0 ; -- i )
        for( int j = 0 ; j < ( 1 << i ) ; ++ j ) if( dp[( 1 << i ) | j][0] >= k ) {
            for( int k = i - 1 ; k >= 0 ; -- k ) printf("%d",( j >> k ) & 1);
            return 0;
        }
}


Measured memory_bytes: 173436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-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(){
    vl a(5);rep(i,5)cin>>a[i];
    rep(i,5)if(a[i]==0){
        cout<<i+1<<endl;
        return 0;
    }
}

Measured memory_bytes: 3500
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#define LL long long
LL x,y;
LL Abs(LL m)
{
	if(m>=0) return m;
	return -m;
}
int main()
{
	scanf("%lld %lld",&x,&y);
	if(Abs(x-y)<=1)
		printf("Brown\n");
	else printf("Alice\n");
    return 0;
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
i=0
p=q=0
for i in range(n-1):
  if a[i]>=a[i+1]:
    p+=1
  else:
    q=max(p,q)
    p=0
q=max(p,q)
print(q)

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

int main() {
    int l;
    cin >> l;
    int n = log2(l);

    vector<tuple<int, int, int>> ans;
    for (int i = 0; i < n; i++) {
        ans.emplace_back(i + 1, i + 2, 0);
        ans.emplace_back(i + 1, i + 2, 1 << i);
    }

    for (int t = n; t >= 0; t--) {
        int s = l - (1 << t);
        if (s >= 1 << n) {
            ans.emplace_back(t + 1, n + 1, s);
            l = s;
        }
    }

    cout << n + 1 << " " << ans.size() << endl;
    for (auto& e : ans) cout << get<0>(e) << " " << get<1>(e) << " " << get<2>(e) << endl;
}


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


int main(){
  string S;
  cin >> S;
  int N=S.size();
  if(N%2==1){
    cout << "No" << endl;
    return 0;
  }
  for(int ii=0; ii<N; ii+=2){
    if(S[ii]!='h'||S[ii+1]!='i'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int k,a,b;
    cin >> k >> a >> b;
    int n;
    n = a / k;
    while(n*k <= b){
        if(n*k >= a){
            cout << "OK" << endl;
            return 0;
        }
        n++;
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main() {
    int n, m, q;
    cin >> n >> m >> q;

    int ps[n+1][n+1];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            ps[i][j] = 0;
        }
    }
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        ps[l][r]++;
    }
    for (int i = 0; i <= n; i++) {
        for (int j = i - 1; j >= 0; j--) {
            ps[j][i] += ps[j+1][i];
        }
    }
    for (int i = 0; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            ps[i][j] += ps[i][j-1];
        }
    }

    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << ps[l][r] << endl;
    }

    return 0;
}

Measured memory_bytes: 1920