akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1000000007;

ll N, K;
ll ans;
vector<int> adj[100005];

void dfs(int from, int now){
    //cout << "now: " << now << endl;
    if(from != -1 && adj[now].size() == 1) return;

    if(from == -1){
        if(K-1 < adj[now].size()){
            ans = 0;
            return;
        }
        else{
            for(int i=K-1; i>K-1-adj[now].size(); --i){
                //cout << " " << i;
                ans *= i;
                ans %= mod;
            }
            //cout << endl;
        }
    }
    else {
        if(K-2 <  adj[now].size()-1){
            ans = 0;
            return;
        }
        for(int i=K-2; i>K-2-adj[now].size()+1; --i){
            //cout << " " << i;
            ans *= i;
            ans %= mod;
        }
        //cout << endl;
    }

    for(auto to:adj[now]){
        if(to == from) continue;
        dfs(now, to);
    }
}

int main(){
    cin >> N >> K;
    for(int i=0; i<N-1; ++i){
        int a, b; cin >> a >> b;
        --a; --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    ans = K;

    dfs(-1, 0);
    cout << ans << endl;

}

Measured memory_bytes: 9216
import java.util.Scanner;

 
class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int[] L = new int[N];
        int[] count = new int[N-1];
        
        for(int i = 1; i <= N-1; i++) {
        	for(int j = i + 1; j <= N; j++) {
        		L[i] = Math.min(j-i, 
        								Math.min(Math.abs(X-i) + 1 + Math.abs(Y-j),
        										 Math.abs(Y-i) + 1 + Math.abs(X-j) ));
        		count[L[i] -1 ] ++;
        	}
        }
        
        for(int ans : count) {
        	System.out.println(ans);
        }

        
	}
}

 

Measured memory_bytes: 24532
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		boolean startflag[] = new boolean[n];
		boolean endflag[] = new boolean[n];
		int tempA = 0;
		int tempB = 0;
		for (int i = 0; i < m; i++) {
			tempA = scan.nextInt();
			tempB = scan.nextInt();
			if (tempA == 1) {
				startflag[tempB - 1] = true;
			}
			if (tempB == n) {
				endflag[tempA - 1] = true;
			}

		}
		for (int i = 0; i < n; i++) {
			if (startflag[i] && endflag[i]) {
				System.out.println("POSSIBLE");
				return;
			}
		}

		System.out.println("IMPOSSIBLE");

	}

}

Measured memory_bytes: 93836
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  char a, b;
  cin >> a >> b;
  bool ans = false;
  if(a=='H'&&b=='H')
  {
    ans = true;
  }
  else if(a=='D'&&b=='D')
  {
    ans = true;
  }
  if(ans==true)
  {
    cout << "H" << endl;
  }
  else if(ans==false)
  {
    cout << "D" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    ios::sync_with_stdio(false);

    int x,y,coins=0;

    cin>>x>>y;

    if(x>y){
        coins+=x;
        x--;
    }
    else{
        coins+=y;
        y--;
    }

    if(x>y){
        coins+=x;
        x--;
    }
    else{
        coins+=y;
        y--;
    }

    cout<<coins<<endl;

    return 0;
}

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

using namespace std;

int main() {

	int n, k;
	bool sunu[100] = {};
  
  	cin>>n>>k;

	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			sunu[a-1] = true;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (sunu[i] == false)ans++;

	}
	cout << ans;
}

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

using ll = long long;

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

	ll ans = numeric_limits<long long>::max();
	for (ll i = 1; i * i <= N; i++) {
		if (N % i != 0) continue;
		ll j = N / i;
		ans = min(ans, i + j - 2);
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
ll Min, N, K, Ans;

int main()
{
	scanf ("%lld", &N);
	while (N--)
	{
		scanf ("%lld", &K);
		if (K >= Min) Min = K;
		else Ans += Min - K;
	}
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 3736
#include<stdio.h>
#include<string.h>
int main(void){
   int N,M,big,min;
   scanf("%d %d",&N,&M);
   if(N>M){
      min=M;
      big=N;
   }else{
      min=N;
      big=M;
   }
   for(int i=0;i<big;i++){
      printf("%d",min);
   }
   
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rp(i,n) for(int i=1;i<=(int)n;i++)
int main(){
    int n;cin>>n;
    ll a=2;
    ll b=1;
    ll c=0;
  if(n==1)cout<<1<<endl;
  
    else{for(int i=0;i<n-1;i++){
        c=a+b;
        a=b;
        b=c;
    }cout<<c<<endl;
        }
  
}

Measured memory_bytes: 256
s=str(input())
s=list(s)
s=set(s)
s=list(s)
s.sort()
a="abcdefghijklmnopqrstuvwxyz"
a=list(a)
i=0
count=0
while i<len(s):
  if s[i]!=a[i]:
    print(a[i])
    break
  i=i+1
  count=count+1
else:
  if count==26:
    print("None")
  else:
    print(a[i])


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

int main()
{
    int A, B, C;

    cin >> A >> B >> C;

    bool res = false;
    if (A == B && A != C)
        res = true;
    if (A == C && A != B)
        res = true;
    if (C == B && A != C)
        res = true;

    cout << ((res) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a= new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		Arrays.sort(a);
		int c=0;
		for(int i=0;i<n;i++) {
			for(int j=0;j<i;j++) {
				for(int k=0;k<j;k++) {
					if(a[k]!=a[j] && a[i]!=a[j] && a[k]+a[j]>a[i]) {
						c++;
					}
				}
			}
		}
		System.out.println(c);
	}

}


Measured memory_bytes: 27600
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = (int) 1e5 + 5;
const int mod = (int) 1e9 + 7;

int x, ans;

inline void solve () {
        scanf ("%d", &x);
        ans = x;
        for (int i = 1; x; i++) {
                if (x < i) {
                        ans = min (ans, i);
                        break;
                }
                ans = min (ans, x);
                x -= i;
        }
        printf ("%d\n", ans);
}

int tests = 1;

int main () {
//        freopen (".in", "r", stdin);
//        freopen (".out", "w", stdout);
//        scanf ("%d", &tests);
        while (tests--) {
                solve ();
        }
        return 0;
}


Measured memory_bytes: 256
import bisect

N = int(input())
A = sorted([int(i) for i in input().split()])
ans = 0
for i in set(A):
    l = bisect.bisect_left(A, i-1)
    r =  bisect.bisect_right(A, i+1)
    ans = max(ans, r-l)
print(ans)

Measured memory_bytes: 14428
from math import factorial
n,k=[int(_) for _ in input().split()]
mod=10**9+7
if n!=k:
    if k+1 > n-k+2:
        for i in range(1,n-k+2):print((((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))%mod)
        for i in range(2*k-n-1):print(0)
    else:
        for i in range(1,k+1):print((((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))%mod)
else:
    print(1)
    for i in range(1,k):print(0)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string C[3];
	cin >> C[0] >> C[1] >> C[2];
	cout << C[0][0] << C[1][1] << C[2][2] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                
using namespace std;
int N, tmp;  
long long a[100005], answer;
int main(void){
	cin >> N; 
  for(int i = 0; i < N; i++){
		cin >> tmp;
		if(100000 < tmp)answer++;
		else a[tmp]++;
	}

	for(int i = 0; i < 100005; i++){
		if(i < a[i]) answer += a[i] - i;
		if(i > a[i]) answer += a[i];
	}
	cout << answer << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n;
vl a;
/******* define variable end *******/
int solve() {
	cin >> n;
	RES(a, n);
	ll ma = 0;
	ll ma_ite = -1;
	REP(i, n){
		cin >> a[i];
		if(ma < a[i]){
			ma = a[i];
			ma_ite = i;
		}
	}
	vll dp(n+1, vl(2, 0));
	dp[0][0] = 1000;
	dp[0][1] = 0;
	REP(i, n-1){
		if(a[i] < a[i+1]){
			dp[i][1] += dp[i][0] / a[i];
			dp[i][0] = dp[i][0] % a[i];
			dp[i+1][0] = dp[i][0] + dp[i][1] * a[i+1];
			dp[i+1][1] = 0;
		}else{
			dp[i][0] = dp[i][0] + dp[i][1] * a[i];
			dp[i][1] = 0;
			dp[i+1][1] += dp[i][0] / a[i+1];
			dp[i+1][0] = dp[i][0] % a[i+1];
		}
	}
	cout << dp[n-1][0] + dp[n-1][1] * a[n-1] << endl;
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3504
#include<iostream>
int abs(int x)
{
	return x<0?-x:x;
}
using namespace std;
int x,y,n,t,a,b,tt;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>tt>>a>>b;
        if((abs(x-a)+abs(y-b)>tt-t) || ((abs(x-a)+abs(y-b))%2==0 &&(tt-t)%2==1) || ((abs(x-a)+abs(y-b))%2==1 &&(tt-t)%2==0)){
            cout<<"No"<<endl;
            return 0;
        }
        x=a;y=b;t=tt;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n,k;cin>>n>>k;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  rep(i,n)a[i]--;
  // cout<<a<<endl;

  vector<ll>d,d2;
  set<ll>s;
  ll now=0;
  while(s.find(now)==s.end()){
    // cout<<now<<endl;
    s.insert(now);
    d.push_back(now);
    now=a[now];
  }
  
  // cout<<d<<endl;

  bool y=false;
  ll x=-1;
  rep(i,d.size()){
    if(now==d[i]){
      x=i;
      
      y=true;
    }
    if(y)d2.push_back(d[i]);
  }
  if(k<d.size())cout<<d[k]+1<<endl;
  else cout<<d2[(k-x)%(int)d2.size()]+1<<endl;
  // cout<<<<endl;
  return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;  cin >> n >> m;
    vector<vector<int> > v(n + 1);
    rep (i, m) {
      int a, b;  cin >> a >> b;
      v[a].push_back(b);
    }
    for (auto itr: v[1]) {
      for (auto iter: v[itr]) {
        if (iter == n) {
          cout << "POSSIBLE" << '\n';
          return 0;
        }
      }
    }
    cout << "IMPOSSIBLE" << '\n';

    return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1, T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2>& a){ return os << a.first << " "<<a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }

main()
{
  std::vector< int > s(10);
  cin >> s;
  cout << accumulate(s.begin(), s.end(), 0) << endl;
}

Measured memory_bytes: 1192
M,A,R,C,H=list(),list(),list(),list(),list()
N=int(input())
for i in range(N):
  S=input()
  if S[0]=="M":
    M.append(S)
  elif S[0]=="A":
    A.append(S)
  elif S[0]=="R":
    R.append(S)
  elif S[0]=="C":
    C.append(S)
  elif S[0]=="H":
    H.append(S)
a=len(M)
b=len(A)
c=len(R)
d=len(C)
e=len(H)
print(a*b*c+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e+b*c*d+b*c*e+b*d*e+c*d*e)

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

right = 0
sum_plus = 0
sum_xor = 0
ans = 0
#import pdb; pdb.set_trace()
for left in range(N):
    while right < N and (sum_plus + A[right]) == (sum_xor ^ A[right]):
        sum_plus += A[right]
        sum_xor = sum_xor ^ A[right]
        right += 1
    ans += right - left
    sum_plus -= A[left]
    sum_xor = sum_xor ^ A[left]

print(ans)


Measured memory_bytes: 24840
import numpy as np

N = int(input())
A = [-1] * N

B = np.array(list(map(int, input().split())))
indices = np.argsort(B)

for i in indices:
    if A[i] == -1 and A[i + 1] == -1:
        A[i] = A[i + 1] = B[i]
    elif A[i] == -1:
        A[i] = B[i]
    elif A[i + 1] == -1:
        A[i + 1] = B[i]

print(sum(A))

Measured memory_bytes: 12388
xy=list(map(int,input().split()))
alist=[1,3,5,7,8,10,12]
blist=[4,6,9,11]
clist=[2]
ans=[]

for i in xy:
    if i in alist:
        ans.append(0)
    if i in blist:
        ans.append(1)
    if i in clist:
        ans.append(2)

if ans[0]==ans[1]:
    print("Yes")
else:print("No")

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int h,w;
    while (1){
        scanf("%d %d",&h,&w);
        if(h==0 && w==0){
            break;
        }else{
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if((i+j)%2!=0){
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
                printf("\n");
            }
            printf("\n");
        }
    }
}


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

using namespace std;

const int M = 2e9;
#define ll long long

const int N = 2e5+15;

int a[N];

bool canDoit(int maxi,int n){
	stack<pair<int,int> > st;
	map<int,int> Hash;
	if(maxi==1){
		for(int i=0;i<n-1;++i){
			if(a[i]>=a[i+1]){
				return false;
			}
		}
		return true;
	}
	if(a[0]!=1){
		st.push(make_pair(1,1));
	}
	for(int i=0;i<n;++i){
		int x = a[i];
		int t = 0;
		while(!st.empty()){
			if(x<st.top().first){
				st.pop();
				t = 1;
			} else {
				break;
			}
		}
		int cur = x;
		if(!st.empty()){
			bool ok = false;
			while(!ok){
				if(st.size()==0){
					return false;
				}
				int u = st.top().first;
				assert(u<=cur);
				if(u<cur){
					st.push(make_pair(cur,t+1));
					ok = true;
				} else {
					int v = st.top().second + 1;
					if(v>maxi){
						--cur;
						st.pop();
					} else {
						st.pop();
						st.push(make_pair(u,v));
						ok = true;
					}
					t = 1;
				}
			}
		} else {
			st.push(make_pair(1,1));
		}
	}
	return true;
}
void solve(){
	int n;
	scanf("%d",&n);
	int prev = 0;
	stack<int> st;
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
	}
	int l = 1,r = 1e8,mid;
	while(l<r){
		mid = (l+r)/2;
		if(canDoit(mid,n)){
			r = mid;
		} else {
			l = mid+1;
		}
	}

	printf("%d\n",l);
}
int main(){
	//freopen("input.txt","r",stdin);
	solve();
}

Measured memory_bytes: 2720
using System;
using System.Linq;
using System.Collections.Generic;
public class Program {
  public static void Main() {
    int N = int.Parse(Console.ReadLine());
    long[] A = new[]{ 0L }.Concat(Console.ReadLine().Split(' ').Select(long.Parse)).ToArray();

    for (int i = 2; i < N+1; i++) {
      A[i] = A[i-1] + A[i];
    }

    Dictionary<long, long> dic = new Dictionary<long, long>();
    foreach (long l in A) {
      if (!dic.ContainsKey(l)) {
        dic[l] = 1;
      } else {
        dic[l] += 1;
      }
    }

    long count = 0;
    foreach (long i in dic.Values) {
      count += i * (i-1) / 2;
    }
    Console.WriteLine(count);
  }
}


Measured memory_bytes: 46644
from sys import stdin
readline = stdin.readline


R, S, P = 1, 2, 3  # rock, scissors, paper
W, L, D = 1, 2, 3  # win, lose, draw

rps = {
    (R, S, P): {R: D, S: D, P: D},
    (R, S):    {R: W, S: L},
    (S, P):    {S: W, P: L},
    (R, P):    {P: W, R: L},
    (R,):       {R: D},
    (S,):       {S: D},
    (P,):       {P: D}
    }

while True:
    hands = []
    hands.append(int(readline()))
    if hands[0] == 0:
        break
    for _ in range(4):
        hands.append(int(readline()))

    hands_set = tuple(sorted(set(hands)))
    for h in hands:
        print(rps[hands_set][h])

Measured memory_bytes: 6740
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 3e5 + 1;

int p[maxn];

bool eq(char c, char d) {
    if (c == '#' && c != d) return 0;
    if (d == '#' && c != d) return 0;
    return (c == '?' || d == '?' || c == d);
}

int solve(string a, string b, string c) {
    int ans = 14488;
    for (int i = 0; i <= a.size(); i++) {
        string t = a; bool fg = 1;
        for (int j = i; j < a.size(); j++) {
            if (j - i >= b.size()) continue;
            if (!eq(a[j], b[j - i])) {
                fg = 0; break;
            } else {
                if (a[j] == '?') t[j] = b[j - i];
                if (b[j - i] == '?') t[j] = a[j];
            }
        }
        if (!fg) continue;
        for (int j = (int)a.size() - i; j < b.size(); j++)
            t += b[j];
        cout << t << '\n';
        string f = c + "#" + t;
        for (int j = 1; j < f.size(); j++) {
            p[j] = p[j - 1];
            while (p[j] && !eq(f[p[j]], f[j]))
                p[j] = p[p[j] - 1];
            if (eq(f[p[j]], f[j])) ++p[j];
        }
        for (int j = c.size(); j < f.size(); j++) {
            if (p[j] == c.size()) {
                ans = min(ans, (int)t.size());
                break;
            }
        }
        ans = min(ans, (int)t.size() + (int)c.size() - p[f.size() - 1]);
        if (t == "z?zx?x") cout << "!" << f << ' ' << p[7] << '\n';
    }
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1;
        return 0;
    }
    if ((h * w) % 2) {
        cout << (h * w + 1) / 2;
    } else {
        cout << (h * w) / 2;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,i,j,k,maxs;
string st;
int main()
{
    cin>>st;
    k=st.size();
    if(st[0]==st[k-1])
    {
        if(k%2==0)                  
          cout<<"First";
        else
          cout<<"Second";  
    }
    else
    {
        if(k%2==0)                  
          cout<<"Second";
        else
          cout<<"First";  
    }
    return 0;
}

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

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

    if (n % 1000 == 0)
        cout << (0) << endl;

    else
    {
        int x = n / 1000;
        n -= x * 1000;
        cout << abs(n - 1000) << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int main(){
    ll H;
    cin >> H;
    ll atk=0;
    int i = 0;
    while(H>0){
        atk += pow(2,i);
        ++i;
        H/=2;
    }
    cout << atk << endl;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,k;
	cin>>k>>n;
	vector<ll> a(n);
	rep(i,n){
		cin>>a[i];
	}
	ll ma=0;
	rep(i,n-1){
		chmax(ma,abs(a[i]-a[i+1]));
	}
	chmax(ma,a[0]+k-a[n-1]);
	cout<<k-ma<<endl;
}

Measured memory_bytes: 1792
# 解説を参考に作成
# 提出 #14841909 を参考に作成

# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, As):
    import math
    x = 1 if max(As) == 0 else math.ceil(math.log2(max(As)))
    ans = 0
    mod = 10 ** 9 + 7

    for i in range(x):
        cnt = sum((A >> i) % 2 for A in As)
        ans += (cnt * (N - cnt)) * pow(2, i, mod)
        ans = ans % mod
    print(ans)


if __name__ == '__main__':
    N = int(input())
    As = [int(i) for i in input().split()]
    # N = 3 * 10 ** 5
    # import random
    # As = [random.randint(2 ** 59, 2 ** 60) for _ in range(N)]
    solve(N, As)


Measured memory_bytes: 50360
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <time.h>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) {return std::vector<T>(len, elem);}

template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i] <<std:: endl;
		else std::cout << da[i] << ' ';
	}
}
template<typename T>
void vvdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
}

using namespace std;

int hoge(int x){
	if(x >= 100000) return x/100000;
	if(x >= 10000) return x/10000;
	if(x >= 1000) return x/1000;
	if(x >= 100) return x/100;
	if(x >= 10) return x/10;
	return x;
}

int main(){
	int n;cin >> n;
	vector<vector<ll>> da(10,vector<ll>(10));
	rip(i,n+1,1){
		da[hoge(i)][i%10]++;
	}
	ll ans = 0;
	rip(i,10,1){
		rip(j,10,1){
			ans += da[i][j]*da[j][i];
		}
	}
	//vvdeb(da);
	cout << ans << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
v={}
for _ in range(m):
    a,b=map(int,input().split())
    v[a]=v.get(a, 0)+1
    v[b]=v.get(b, 0)+1

for ki,vi in v.items():
    if(vi%2!=0):
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 14144
n, m, x = map(int, input().split())

INF = 10 ** 9
ans = INF
c = [0] * n
a = [[] for _ in range(n)]
for i in range(n):
    books = list(map(int, input().split()))
    c[i] = books[0]
    a[i] = books[1:]

for i in range(1 << n):
    score = [0] * m
    value = 0
    for k in range(n):
        if i >> k & 1:
            value += c[k]
            for j in range(m):
                score[j] += a[k][j]
    ok = True
    for scores in score:
        if scores < x:
            ok = False
    if ok:
        ans = min(ans, value)

if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,n,x,y,z,x1[100]={0},y1[100]={0},z1[100]={0},cnt=0;
  cin>>n>>x;
  for(int i=0;i<x;++i){
    cin>>a;
    x1[a-1]=1;
  }
  cin>>y;
  for(int i=0;i<y;++i){
    cin>>a;
    y1[a-1]=1;
  }
  cin>>z;
  for(int i=0;i<z;++i){
    cin>>a;
    z1[a-1]=1;
  }
  for(int i=0;i<n;++i){
    if(!x1[i]&&z1[i]||y1[i]&&z1[i]) ++cnt;
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

const int MAX_N = 2010;
const int MAX_M = 2010;
ll d[MAX_N][MAX_M + 1];

void warshall_floyd(int n) {
  for (int k = 1; k <= n; k++){       // 経由する頂点
    for (int i = 1; i <= n; i++) {    // 始点
      for (int j = 1; j <= n; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  ll x,y,a,b,c;
  cin >> x>>y>>a>>b>>c;
  vector<ll> p(a);
  vector<ll> q(b);
  vector<ll> r(c);

  for(int i=0; i<a; i++){
    cin >> p.at(i);
  }
  for(int i=0; i<b; i++){
    cin >> q.at(i);
  }
  for(int i=0; i<c; i++){
    cin >> r.at(i);
  }
  
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  sort(r.rbegin(),r.rend());

  vector<ll> hpy;
  vector<ll> cq(y);
  vector<ll> cr(c);

  ll answer = 0;
  for(int i=0; i<x; i++){
    hpy.push_back(p.at(i));
  }
  for(int i=0; i<y; i++){
    hpy.push_back(q.at(i));
  }
  for(int i=0; i<c; i++){
    hpy.push_back(r.at(i));
  }
  sort(hpy.rbegin(),hpy.rend());

  for(int i=0; i<x+y; i++){
    answer += hpy.at(i);
  }
  cout << answer << endl;
}

Measured memory_bytes: 9584
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> vr, vw;
    for (int i=0; i<n; i++) {
        if (s[i] == 'R') {
            vr.push_back(i);
        } else if (s[i] == 'W') {
            vw.push_back(i);
        }
    }
    sort(vw.begin(), vw.end(), greater<>());
    int cnt = 0;
    while (vr.size() * vw.size() != 0) {
        if (vr.back() > vw.back()) {
            vr.pop_back();
            vw.pop_back();
            cnt++;
        } else {
            break;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const long long MOD = 1000000007;

void solve(long long N, std::vector<std::string> S){
    vector<ll> domino;
    for(int i=0;i<N;i++){
        // cerr <<S[0][i] <<" " << S[1][i]<< endl;
        if(S[0][i] == S[1][i]){
            domino.push_back(1);
        }else{
            domino.push_back(0);
            i++;
        }
        // cerr << "eval=" << domino.back() << endl;
    }
    ll ans = 1;
    for(int i=0;i<domino.size();i++){
        // cerr <<"domino = " << domino[i] << endl;
        if(i==0){
            if(domino[i] == 0){
                ans *= 6;
            }else{
                ans *= 3;
            }
            continue;
        }
        if(domino[i] == 0){
            if(domino[i-1] == 0){
                ans *= 3;
            }else{
                ans *= 2;
            }
            ans %= MOD;
            continue;
        }
        if(domino[i-1] == 1){
            ans *= 2;
            ans %= MOD;
        }
    }
    cout << ans << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(2);
    for(int i = 0 ; i < 2 ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		String line = readLine();
		String[] strArray = line.split(" ");
		int[] array = new int[2];
		for(int i = 0; i < 2; i++){
			array[i] = Integer.parseInt(strArray[i]);
		}
		if(array[0] < array[1]){
			System.out.println("0");
		}else{
			System.out.println("10");
		}
	}


	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		return br.readLine();
	}
}

Measured memory_bytes: 21332
import java.util.Scanner;

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

        for (int i=1;; ++i) {
            int n = sc.nextInt();

            if (n == 0) {
                break;
            }

            System.out.println(String.format("Case %d: %d", i, n));
        }
    }
}


Measured memory_bytes: 60696
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int sum(int i) {

	int d = 0;

	while (i > 0) {
		d += i % 10;
		i /= 10;
	}
	return d;
}



int main() {

	int n, a, b;
	cin >> n >> a >> b;

	int e = 0;

	for (int i = 1; i <= n; i++) {
		if (sum(i) >= a && sum(i) <= b) {
			e += i;
		}
	}
	cout << e << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll digit_len(ll x){
    ll ans = 0;
    while (x>=10){
        x /= 10;
        ans++;
    }
    ans++;
    return ans;
}

int main() {
    ll N;
    ll ans = 1000000000;
    cin >> N;
    
    for (ll i=1; i*i<=N; i++){
        if (N%i == 0)chmin(ans, max(digit_len(N/i), digit_len(i)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
    int n[4];
    scanf ("%d%d%d",&n[0],&n[1],&n[2]);
    int i, j;
    for (i = 1;i < 3;i++){
        for (j = 0;j < i;j++){
            if (n[i] < n[j]){
                int temp = n[i];
                n[i] = n[j];
                n[j] = temp;
            }
        }
    }
    printf ("%d %d %d\n",n[0],n[1],n[2]);
    return 0;
}


Measured memory_bytes: 1984
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

typedef long long ll;
using namespace std;

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

    reverse(s.begin(), s.end());

    string a = "dream";
    string b = "dreamer";
    string c = "erase";
    string d = "eraser";
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    reverse(c.begin(), c.end());
    reverse(d.begin(), d.end());

    int count = 0;
    bool ok = false;
    while(true){
        if(s.substr(count, 5) == a){
            count += 5;
            continue;
        }
        if(s.substr(count, 7) == b){
            count += 7;
            continue;
        }
        if(s.substr(count, 5) == c){
            count += 5;
            continue;
        }
        if(s.substr(count, 6) == d){
            count += 6;
            continue;
        }
        if(count == s.size()) {
            ok = true;
        }
        break;
    }

    if(ok == true) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
int s[101000];
int main(void)
{
	int i,n;
	while(scanf("%d",&n)!=EOF)
	{
		ll start=0;
		int j;
		ll ans=1;
		memset(s,0,sizeof(s));
		for(i=0;i<n;i++)
		{
			scanf("%d",&s[i]);
		}
		sort(s,s+n);
		start=s[0];
		for(i=1;i<n;i++)
		{
			if(start*2>=s[i])
			{
				ans++;
				start+=s[i];
			}
			else if(start*2<s[i])
			{
				start+=s[i];
				ans=1;
			}
			else;
		}
		printf("%lld\n",ans);
	}
 } 


Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }
	vector<int>B(N); rep(i, 0, N) { cin >> B[i]; }
	int suma = accumulate(all(A), 0ll);
	int sumb = accumulate(all(B), 0ll);
	if (suma < sumb) {
		cout << -1 << endl;
		return 0;
	}
	vector<int>C(N);
	rep(i, 0, N) {
		C[i] = A[i] - B[i];
	}
	sort(all(C));
	dump(C);
	vector<int>cc(C);

	int i = 0, j = N - 1;
	while (C[i] < 0) {
		int m=min(abs(C[i]), C[j]);
		C[i] += m;
		C[j] -= m;
		if (C[i] == 0)i++;
		if (C[j] == 0)j--;
	}
	int ans = 0;
	rep(i, 0, N) {
		ans += cc[i] != C[i];
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3328
#!usr/bin/env python3

import sys


def main():
    r, c = [int(row_col) for row_col in sys.stdin.readline().split()]
    sheet = [
                [int(row_num) for row_num in sys.stdin.readline().split()]
                for row in range(r)
            ]

    sheet.append([0 for col in range(c)])

    for row in range(len(sheet)-1):
        for col in range(len(sheet[0])):
            sheet[-1][col] += sheet[row][col]

    for row in sheet:
        row.append(sum(row))
        print(*row)


if __name__ == '__main__':
    main()

Measured memory_bytes: 8228
#include "bits/stdc++.h"

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

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

  sort(a.begin(), a.end());

  vector<pii> ans;

  if (a.back() <= 0) {
    int t = a[n - 1];
    for (int i = 0; i < n - 1; i++) {
      ans.push_back({t, a[i]});
      t -= a[i];
    }
  } else if (a.front() >= 0) {
    int t = a[0];
    for (int i = 1; i < n - 1; i++) {
      ans.push_back({t, a[i]});
      t -= a[i];
    }
    ans.push_back({a[n-1], t});
  } else {
    vi x, y;
    for (int i: a)
      if (i < 0) x.push_back(i);
      else y.push_back(i);
    for (int i = 0; i < y.size() - 1; i++) {
      ans.push_back({x[0], y[i]});
      x[0] -= y[i];
    }
    int t = y.back();
    for (auto i: x) {
      ans.push_back({t, i});
      t -= i;
    }
  }

  cout << ans.back().first - ans.back().second << endl;
  for (auto p: ans) {
    cout << p.first << ' ' << p.second << endl;
  }
}

Measured memory_bytes: 3520
#include <iostream>
#include <cstdlib>
#include<vector>
#include<string>
#include<cmath>
#include <algorithm>
#include<complex>

using namespace std;
typedef long long LL;


int main() {
	LL n,a,b;

	cin >> n;

	a = n / 10;
	b = n % 10;

	if (a==9 || b==9) {
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    vector<ll> H(N);
    for (int i = 0; i < N; i++) cin  >> H[i];

    ll maxnum = 0;
    for (int i = 1; i < N; i++){
        if (H[i] < H[i-1]){
            if(H[i-1] - 1 == H[i]){
                H[i-1] -= 1;
                maxnum = max(maxnum, H[i-1]);
                if(H[i] < maxnum){
                    cout << "No";
                    return 0;
                }
            }else{
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
    
    return 0;
}

Measured memory_bytes: 1024
import math
 
a, b, x = list(map(int, input().split()))
c = 2 * x / a / b
if c > a:
    bt = 2 * (b - x / a / a)
    print(math.degrees(math.atan2(bt, a)))
else:
    print(math.degrees(math.atan2(b, c)))

Measured memory_bytes: 3060
import java.util.*;

public class Main {

    static Long[] aArr;
    static Long[] bArr;
    static Long[] cArr;

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

        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int k = sc.nextInt();
        aArr = new Long[x];
        bArr = new Long[y];
        cArr = new Long[z];

        for (int i = 0; i < x; i++) {
            aArr[i] = sc.nextLong();
        }

        for (int i = 0; i < y; i++) {
            bArr[i] = sc.nextLong();
        }

        for (int i = 0; i < z; i++) {
            cArr[i] = sc.nextLong();
        }

        Arrays.sort(aArr);
        Arrays.sort(bArr);
        Arrays.sort(cArr);

        PriorityQueue<V> Q = new PriorityQueue<>();
        Q.add(new V(aArr[x - 1] + bArr[y - 1] + cArr[z - 1], x - 1, y - 1, z - 1));
        HashSet<Long> visited = new HashSet<>();
        visited.add(toId(x - 1, y - 1, z - 1));

        for (int i = 0; i < k; i++) {
            V cur = Q.remove();
            System.out.println(cur.cost);

            if (cur.a - 1 >= 0 && !visited.contains(toId(cur.a - 1, cur.b, cur.c))) {
                Q.add(new V(aArr[cur.a - 1] + bArr[cur.b] + cArr[cur.c], cur.a - 1, cur.b, cur.c));
                visited.add(toId(cur.a - 1, cur.b, cur.c));
            }

            if (cur.b - 1 >= 0 && !visited.contains(toId(cur.a, cur.b - 1, cur.c))) {
                Q.add(new V(aArr[cur.a] + bArr[cur.b - 1] + cArr[cur.c], cur.a, cur.b - 1, cur.c));
                visited.add(toId(cur.a, cur.b - 1, cur.c));
            }

            if (cur.c - 1 >= 0 && !visited.contains(toId(cur.a, cur.b, cur.c - 1))) {
                Q.add(new V(aArr[cur.a] + bArr[cur.b] + cArr[cur.c - 1], cur.a, cur.b, cur.c - 1));
                visited.add(toId(cur.a, cur.b, cur.c - 1));
            }
        }


    }

    static long toId(int a, int b, int c) {
        return (long) a * 1000 * 1000 + b * 1000 + c;
    }

    static class V implements Comparable<V> {
        long cost;
        int a, b, c;

        public V(long cost, int a, int b, int c) {
            this.cost = cost;
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public int compareTo(V v) {
            return v.cost - this.cost > 0 ? 1 : -1;
        }

    }

    static void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

}


Measured memory_bytes: 31280
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = (n * a) < b ? n * a : b;
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        StringBuilder A = new StringBuilder();
        StringBuilder B = new StringBuilder();
        ArrayList<String> S = new ArrayList<>();
        for(int i=0;i<a;i++) A.append(b);
        for(int i=0;i<b;i++) B.append(a);
        S.add(A.toString());
        S.add(B.toString());
        Collections.sort(S);
        System.out.println(S.get(0));
    }
}

Measured memory_bytes: 22356
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<string.h>
using namespace std;
int fun(int n)
{
    return n*n;
}
int main()
{
    int n;
    scanf("%d",&n);
    int *a=new int[n];
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int mi=10000000;
    for(int i=1;i<=100;i++)
    {
        int sum=0;
        for(int j=0;j<n;j++)
        {
         sum+=fun(abs(a[j]-i));
        }
        mi=min(sum,mi);
    }
    printf("%d",mi);
    return 0;
}

Measured memory_bytes: 384
from collections import defaultdict

n = int(input())
s = list(map(int, input()))

a = [0] * n
tmp = set()
for i in range(n)[::-1]:
    a[i] = len(tmp)
    tmp.add(s[i])

b = [0] * n
tmp = defaultdict(int)
for i in range(n)[::-1]:
    for x in tmp.values():
        b[i] += a[x]
    tmp[s[i]] = i

ans = 0
tmp = set()
for i in range(n):
    if s[i] in tmp: continue
    ans += b[i]
    tmp.add(s[i])

print(ans)

Measured memory_bytes: 42096
#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  vector<int> v(n); rep(i, n) cin >> v[i];

  int ans = 0;
  rep(i, n) {
    while(v[i] % 2 == 0 && v[i] != 0) {
      ++ans;
      v[i] /= 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256