akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int gcdExtended(int a, int b, int *x, int *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    int x1, y1; // To store results of recursive call 
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}  
int modInverse(int b, int m) 
{ 
    int x, y; // used in extended GCD algorithm 
    int g = gcdExtended(b, m, &x, &y); 
  
    // Return -1 if b and m are not co-prime 
    if (g != 1) 
        return -1; 
  
    // m is added to handle negative x 
    return (x%m + m) % m; 
}
int modDivide(int a, int b, int m) 
{ 
    a = a % m; 
    int inv = modInverse(b, m); 
    return (inv * a) % m; 
} 

int power(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p  
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
int compute(int n,int a)
{
	vector<int>v1;
	map<int,int>mp;
	int k1 = min(a,n-a);
	int k2 = max(a,n-a);
	int res1 = 1LL,res2=1LL;
	for(int i = 1 ; i <=k1 ; i++ ){
		res1 = (res1*i)%mod;
	}
	for(int i = k2+1 ; i <=n ; i++ ){
		res2 = (res2*i)%mod;
	}
	return modDivide(res2, res1, mod);
}
int32_t main()
{
	int n,a,b;
	cin >> n >> a >> b;
	int ans = power(2,n,mod);
	int res1 =  compute(n,a);
	int res2 =  compute(n,b);
	int fin = (ans-res1+mod)%mod;
	fin = (fin-res2+mod)%mod;
	cout<<(fin-1+mod)%mod;
}


Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int n, x[100009];
int main() {
	cin >> n;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		if (x[i] % 2 == 1) cnt++;
	}
	cout << (cnt % 2 == 0 ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 1148
#include <algorithm>
#include <iostream>

int main(void)
{
    int n;
    std::cin >> n;
    bool four = false;
    for (int i = 0; i < n; ++i)
    {
        char c;
        std::cin >> c;
        if (c == 'Y')
        {
            four = true;
        }
    }
    std::cout << (four ? "Four" : "Three") << std::endl;
}


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


int main() {
#ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);      freopen("outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   ll a, b, c, k;
   cin >> a >> b >> c >> k;
   
   if (k <= a + b)
      cout << min(a, k) << endl;
   else 
      cout << a - (k - (a + b)) << endl;

   return 0;
}  

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
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;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a, b, c;
  cin >> a >> b >> c;

  if (a + b + c >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		StringTokenizer st;
		int a,b;
		for (String line; (line = in.readLine())!=null;) {
			st = new StringTokenizer(line);

			a = Integer.parseInt(st.nextToken());
			b = Integer.parseInt(st.nextToken());

			if((a<0&&b>0)||(a==0||b==0)){
				out.println("Zero");
			}else if((a>0&&b>0)||(Math.abs(Math.abs(b)+Math.abs(a))%2!=0)){
				out.println("Positive");
			}else{
				out.println("Negative");
			}

		}

		out.close();
		in.close();
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int a[105];

int main(void)
{
	int n, m; cin >> n >> m;
	int sum = 0;
	for(int i=1;i<=n;i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a+1, a+n+1, [](int x, int y) {return x > y;});
	int L = (sum % (m * 4) == 0)? sum / (m * 4) - 1 : sum / (m * 4);
	for(int i=1;i<=m;i++){
		if(a[i] <= L) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000

int n;
string s,t;
int res=0;

int main(){
  cin.sync_with_stdio(false);
  cin>>n;
  cin>>s>>t;
  rep(i,n){
    int l=i;
    while(l<n&&s[l]==t[l-i])l++;
    if(l==n){
      res=n+i;
      break;
    }
  }
  if(res==0)res=2*n;
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

double dp[200010];
long int p[200010];

int main(){
    int k,n;
    double mx=0,ans;
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> p[i];
    for(int i=0;i<k;i++) {
        dp[0] += p[i];
    }
    for(int i=0;i<n-k+1;i++){
        dp[i+1] = dp[i] - p[i] + p[i+k];
    }
    for(int i=0;i<n-k+3;i++){
        if(mx < dp[i]) {
            mx = dp[i];
        }
    }
    ans = mx/2 + (float)k/2;
    printf("%.16f", ans);
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int maxN = 100 * 1000 + 9;
const double EPS = 1e-9;

ll h, a[maxN], b[maxN];
int n;

void read(){
  cin >> n >> h;
  for(int i = 0; i <  n; i++)
    cin >> a[i] >> b[i];
}

void solv(){
  sort(b, b + n);
  ll mx = *max_element(a, a + n);

  int j = n - 1;
  ll ans = 0;
  while((0 <= j) && (b[j] >= mx) && (h > 0)){
    h -= b[j];
    j--;
    ans++;
  }

  if(h <= 0){
    cout << ans << '\n';
    return;
  }

  ans += (h / mx) + (h % mx != 0);
  cout << ans << '\n';
}

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

  #ifdef DEBUG
    freopen("in.txt", "r", stdin);
  #endif

  read();
  solv();

  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var r = read[0];
            var D = read[1];
            var x2000 = read[2];

            var ret = new int[11];
            ret[0] = x2000;

            for (int i = 1; i < ret.Length ; i++)
            {
                ret[i] = ret[i - 1] * r - D;
            }
            for (int i = 1; i < ret.Length; i++)
            {
                Console.WriteLine(ret[i]);
            }
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

typedef long long ll;

int main() {
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < n; i++)
int main() {
    ll N,K;
    cin >> N >> K;
    vector<ll> x(N);
    REP(i,N) cin>> x[i];
    ll ans = 0;
    REP(i,N){
        ll dist = abs(x[i]-K) < x[i] ?  abs(x[i]-K)*2 : x[i]*2;
        ans += dist; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int k = 42;
	int trans[51];
	int n = k * k - k + 1;
	cout << n << " " << k << endl;
	rep(i, k) {
		cout << 1;
		int x = 1 + i * (k - 1);
		Rep(j,x, x+k-1) {
			cout << " " << j + 1;
		}
		cout << endl;
	}
	rep(i, k - 1) {
		rep(j, k-1){
			trans[j] = (i + j) % (k - 1);
		}
		rep(j, k - 1) {
			cout << i + 2;
			int now = j;
			rep(l, k - 1) {
				int x = k + l * (k - 1) + now;
				now = trans[now];
				cout << " " << x + 1;
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int main(){
  set<string> used;
  char before = 'z';
  char now1 = 'a', now2 = 'a';
  char s[10];

  while(1){
    string say;
    say += before; say += now1; say += now2; say += "a";
    cout<<"?"<<say<<endl; fflush(stdout);
    used.insert(say);

    string s;
    cin>>s;
    if(s[0] != 'a' || used.find(s) != used.end()){
      cout<<"!OUT\n"; fflush(stdout);
      break;
    }

    used.insert(s);
    before = s[s.length()-1];
    if(now1 == 'z'){
      now2++;
      now1 = 'a' - 1;
    }
    now1++;
  }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main() {
 int a, b, c;
  cin >> a >> b; c = 0;
  if (a > b) {
   	c += a;
    a--;
  }
  else {
   	c += b;
    b--;
  }
  if (a > b) {
   	c += a;
    a--;
  }
  else {
   	c += b;
    b--;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e6+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int p[maxn];
signed main(){
    //file(a);
    n=read();int x=7%n,k=1;p[x]=1;
    while(x){
        // cout<<x<<endl;
        x=(x*10%n+7)%n;++k;
        if(p[x]){puts("-1");exit(0);}
        p[x]=1;
    }printf("%lld\n",k);


    return 0;
}


Measured memory_bytes: 11468
import sys
import heapq, math
from bisect import bisect_right
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))

B = [A[0]]

for i in range(1, N):
    if A[i - 1] != A[i]:
        B.append(A[i])

N = len(B)


def solve():
    ret = 1000
    l = 0
    while l < N:
        while l < N - 1 and B[l] > B[l + 1]:
            l += 1

        if l == N - 1:
            return ret

        C = [B[l]]
        while l < N - 1 and B[l] < B[l + 1]:
            C.append(B[l + 1])
            l += 1

        cnt = ret // C[0]
        ret -= cnt * C[0]
        ret += cnt * C[-1]

        l += 1
    return ret


print(solve())

Measured memory_bytes: 9368
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <memory.h>
#include <deque>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
#define mp make_pair
const int M=100005;
const int N=1000001;
const int K=1000000009;
const ll MAX=1000000000000000000ll;
int n,w[100],c[100],k;
int dp[2][M];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)
    	scanf("%d%d",w+i,c+i);
    for(int i=0;i<M;i++)
    	dp[0][i]=dp[1][i]=K;
    for(int i=n-1;i>=0;i--)
    {
    	for(int j=0;j<M;j++)
    	{
    		int &ret=dp[i%2][j];
    		if(j==c[i])
    		{
    			ret=min(w[i],dp[(i+1)%2][j]);
    			//cout<<j<<endl;
    		}
    		else if(j>c[i]&&dp[(i+1)%2][j-c[i]]<K)
    		{
    			//cout<<dp[(i+1)%2][j-c[i]];
    			ret=min(w[i]+dp[(i+1)%2][j-c[i]],dp[(i+1)%2][j]);
    			//cout<<"lel "<<j<<endl;
    		}
    		else
    			ret=dp[(i+1)%2][j];
    	}
    }
    int ans=0;
    for(int i=0;i<M;i++)
    	if(dp[0][i]<=k)
    		ans=i;
    cout<<ans;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX=100000;
static const int NIL=-1; 

int n;
vector<int>G[MAX];
int color[MAX];

void dfs(int r,int c){
    stack<int>S;
    S.push(r);
    color[r]=c;
    while(!S.empty()){
        int u=S.top();S.pop();
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            if(color[v]==NIL){
                color[v]=c;
                S.push(v);
            }
        }
    }
}

void assignColor(){
    int id=1;
    for(int i=0;i<n;i++)color[i]=NIL;
    for(int u=0;u<n;u++){
        if(color[u]==NIL)dfs(u,id++);
    }
}

int main(){
    int s,t,m,q;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>s>>t;
        if(color[s]==color[t]){
            cout<<"yes"<<endl;
        }
        else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}


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

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

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  ll n;
  ll ans = 1;
  cin >> n;
  map<ll,ll> dist;
  ll maxd = 0;
  rep(i,n)
  {
    dist[i] = 0;
  }
  rep(i,n)
  {
    ll temp;
    cin >> temp;
    if(temp == 0 && i > 0)
    {
      cout << 0;
      return 0;
    }
    maxd = max(maxd,temp);
    dist[temp]++;
  }
  if(dist[0] == 0 || dist[0] > 1)
  {
    cout << 0;
    return 0;
  }
  rep(i,maxd)
  {
    rep(j,dist[i + 1])
    {
      ans =ans % 998244353;
      ans*=dist[i];
      ans =ans % 998244353;
    }
  }
  ans =ans % 998244353;
  cout << ans;
}

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

delta_a = [0] * (n-1)
for i in range(n-1):
  delta_a[i] = a[i+1] - a[i]

stock = 0
money = 1000
for i in range(n-1):
  if delta_a[i] > 0 and delta_a[i-1] <= 0 and i > 0 and stock == 0:
    stock = money // a[i]
    money = money % a[i]
  elif delta_a[i] > 0 and i == 0 and stock == 0:
    stock = money // a[i]
    money = money % a[i]
  elif delta_a[i] < 0 and delta_a[i-1] >= 0  and stock != 0:
    money += stock * a[i]
    stock = 0

if stock != 0:
  money += stock * a[n-1]
print(money)

Measured memory_bytes: 9100
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[]A = new int[N];
		Set<Integer> set = new HashSet<Integer>();
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			set.add(A[i]);
		}
		sc.close();
		int[]c = new int[N + 1];
		for(int i = 0; i < N; i++) {
			c[A[i]]++;
		}
		int l = set.size();
		int[]cnt = new int[l];
		int idx = 0;
		for(int i = 1; i <= N; i++) {
			if(c[i] != 0) {
				cnt[idx] = c[i];
				idx++;
			}
		}
		Arrays.sort(cnt);
		if(l <= K) {
			System.out.println(0);
			System.exit(0);
		}

		int sum = 0;
		for(int i = 0; i < l; i++) {
			sum += cnt[i];
			if(l - i - 1<= K) {
				System.out.println(sum);
				System.exit(0);
			}

		}
	}
}

Measured memory_bytes: 102592
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N, M;
bool G[10][10];

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

  Rep(i, M) {
    int a, b;
    cin >> a >> b;

    G[a][b] = true;
    G[b][a] = true;
  }

  vector<int> v(N);
  iota(All(v), 1);

  int ans = 0;

  do {
    if (v[0] != 1) continue;

    bool flg = true;

    Rep(i, N-1) {
      if (!G[v[i]][v[i+1]]) {
        flg = false;
        break;
      }
    }

    if (flg) ans++;

  } while (next_permutation(All(v)));


  cout << ans << "\n";
}

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

int main() {
  int N, K, X=1;
  cin >> N >> K;

  for (int i = 0; i < N; i++)
  {
    if ((X * 2) < (X + K))
    {
      X *= 2;
    } 
    else 
    {
      X += K;
    }
  }
  
  cout << X << endl;  

}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
      int N = in.nextInt();
      int K = 0;
      for (int i = 0; i<N; i++){
      int R = in.nextInt();
      if (i%2==0 && R%2==1){
        K = K +1;
      }
      }
      System.out.print(K);
      }
}

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

class Program
{
    public static void Main()
    {
        int[] input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        if (input[0] < 10)
        {
            Console.WriteLine(input[1] + 100 * (10 - input[0]));
        } else
        {
            Console.WriteLine(input[1]);
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  ll result = 0;
  for (int i=0; i<N; ++i) {
    int a;
    cin >> a;
    result += a - 1;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <stdio.h>

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

//main code
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
char buf[(1 << 22)], *p1 = buf, *p2 = buf;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int ab[100001];
int main(int argc, char *argv[])
{
	int n = read(),m = read();
	for (int i = 0; i < m; i++) {
		int a = read(),b = read();
		chmax(ab[b], a);
	}
	int ans = 0;
	int k = 1;
	for (int i = 1; i <= n; i++) {
		if (k <= ab[i]) {
			k = i;
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[2],b[2],c[2];
main()
{
	cin>>n;
	for(int i=0;i<2;i++)cin>>a[i]>>b[i]>>c[i];
	for(int o=0;o<2;o++)
	{
		int t=n;
		if(a[0]<a[1])swap(a[0],c[0]),swap(a[1],c[1]);
		if(b[0]<b[1])swap(b[0],c[0]),swap(b[1],c[1]);
		for(int i=0;i<=(a[1]>a[0]?n:0);i++)
			for(int j=0;j<=(b[1]>b[0]?n:0);j++)
				if(i*a[0]+j*b[0]<=n)
				{
					int k=(c[1]>c[0]?(n-i*a[0]-j*b[0])/c[0]:0);
					t=max(t,i*a[1]+j*b[1]+k*c[1]+n-i*a[0]-j*b[0]-k*c[0]);
				}
				else break;
		n=t;
		swap(a[0],a[1]);
		swap(b[0],b[1]);
		swap(c[0],c[1]);
	}
	cout<<n<<'\n';
}


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

long long int max(long long int a,long long int b){
	if(a>b)return a;
	else return b;
}

int main(void) {
	int n,W;
	scanf("%d%d",&n,&W);
	long long int w[n+1],v[n+1];
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&w[i],&v[i]);
	}
	long long int dp[101][100001];
	for(int i=1;i<=n;i++){
		for(int j=0;j<=W;j++){
			if((j-w[i-1])>=0){//n個目の新たな荷物を導入する部分
				dp[i][j] = max(dp[i-1][j-w[i-1]]+v[i-1],dp[i][j]);
			}
			dp[i][j] = max(dp[i-1][j],dp[i][j]);
		}
	}
	printf("%lld\n",dp[n][W]);
}


Measured memory_bytes: 79736
N=int(input())
d=[input() for i in range(N)]
ac=0
wa=0
tle=0
re=0
for i in range(N):
    if d[i]=="AC":
        ac+=1
    elif d[i]=="WA":
        wa+=1
    elif d[i]=="TLE":
        tle+=1
    else:
        re+=1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 16256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        yen: i32,
    }
    for x in 0..(n + 1) {
        for y in 0..(n + 1) {
            let z = n - x - y;
            if z < 0 || n < z {
                continue;
            }
            if 10000 * x + 5000 * y + 1000 * z == yen {
                println!("{:?} {:?} {:?}", x, y, z);
                return;
            }
        }
    }
    println!("-1 -1 -1");
}

Measured memory_bytes: 4352
/*ex5_3
 Sweet_Sweet_Soul */
#include <stdio.h>

int main(void) {
    int hei,wid;/*hei=height、wid＝width*/
    scanf("%d%d",&hei,&wid);
    char grid[hei][wid];
    int hei_ture[hei];/*hei行めに#があるかどうかの真偽値*/
    int wid_ture[wid];
    for(int i=0;i<hei;i++){
        for(int j=0;j<wid;j++){
            scanf(" %c",&grid[i][j]);
            if(grid[i][j]=='#'){
                hei_ture[i]=1;/*真偽値を記録*/
                wid_ture[j]=1;   
            }
        }
    }
    for(int i=0;i<hei;i++){
        if(hei_ture[i]==1){
            for(int j=0;j<wid;j++){
                if(wid_ture[j]==1){
                    printf("%c",grid[i][j]);/*行、列ともに真偽値1なら出力*/
                }
            }
        printf("\n");/*行ごとに改行*/
        }
    }
    return 0;
}



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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c ,n, sum, A[500010], B[500000],rui[500000],  dp[5000];
str S,T,U;bool check = true;	vector<ll> v;



int main() {
	//Code Line
cin >> S;
for(int i = 0;i < S.size();i+= 2){
if(S[i] == 'h' && S[i+1] == 'i');
else check = 0;

}
if(check)cout << "Yes" << endl;
else cout << "No" << endl;



	return 0;
}


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

#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll mod = 1e9 + 7;

void Main() {
  int n;
  cin >> n;
  vector<ll> A(n);
  rep(i, n) cin >> A[i];
  ll ans = 0;
  rep(k, 65) {
    ll a=0;
    rep(i, n) {
      if (A[i] % 2) a++;
      A[i] >>= 1;
    }
    ll score = (1LL << k) % mod;
    (score *= a) %= mod;
    (score *= n - a) %= mod;
    (ans += score) %= mod;
  }
  cout << ans << endl;
}

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


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

int main(int argc, const char * argv[]) {
	int N,H,W,ret=0;
	cin >> N >>H >> W;
	for (int i = 0; i < N; ++i) {
		int A,B;
		cin >> A >> B;
		if(A >= H && B >= W){
			ret++;
		}
	}
	cout << ret << endl;

    return 0;
}


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

class TopoSort {
private:
  int N;
  vector<vector<int>> G;
  vector<int> indeg;
  vector<bool> V;
  list<int> out;

  void add_edge(int from, int to) {
    G[from].push_back(to);
  }

  void bfs(int s) {
    queue<int> q;
    q.push(s);
    V[s] = true;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      out.push_back(u);
      for (auto v : G[u]) {
        indeg[v]--;
        if (indeg[v] == 0 && V[v] != true) {
          V[v] = true;
          q.push(v);
        }
      }
    }
  }

  list<int> do_topoSort() {
    for (int i = 0; i < N; i++) {
      indeg[i] = 0;
    }
    for (int i = 0; i < N; i++) {
      for (auto v : G[i]) {
        indeg[v]++;
      }
    }
    for (int i = 0; i < N; i++) {
      if (indeg[i] == 0 && V[i] != true) {
        bfs(i);
      }
    }
    return out;
  }

public:
  TopoSort(int N) : N(N), G(N, vector<int>()), indeg(N), V(N, false) {}

  void addEdge(int from, int to) { return add_edge(from, to); }
  list<int> topoSort() { return do_topoSort(); }
};

signed main() {
  int V, E;
  cin >> V >> E;
  TopoSort ts(V);
  for (int i = 0; i < E; i++) {
    int s, t;
    cin >> s >> t;
    ts.addEdge(s, t);
  }

  list<int> out = ts.topoSort();

  for (auto x : out) cout << x << endl;
  return 0;
}



Measured memory_bytes: 4460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int MOD = 1000000007;

int main()
{
	string date = "";
	cin >> date;

	string ans = "2019/04/30" < date? "TBD" : "Heisei";
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - ABC333
            var items = GetItemsFromReadLines<int>(1).ToList();

            int a = items[0][0];
            int b = items[0][1];

            bool isOdd = IsOddNumber(a, b);

            if (isOdd)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static bool IsOddNumber(int a, int b)
        {
            for (int i = 1; i <= 3; i++)
            {
                if (a * b * i % 2 == 1)
                {
                    return true;
                }
            }

            return false;
        }

        static IEnumerable<List<T>> GetItemsFromReadLines<T>(int count = 0, char separator = ' ')
        {
            //[summary]コンソールの値を読み込んで、List<T>のコレクションを返却

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string line = Console.ReadLine().TrimEnd();
                count = int.Parse(line);
            }
            
            for(int i = 0; i < count; i++)
            {
                //コンソールを1行読み込み
                string line = Console.ReadLine().TrimEnd();

                //読み込んだ値を"separator"で区切る
                var list = line.Split(separator).ToList();

                //int型のときは数値に変換
                if (typeof(T) == typeof(int))
                {
                    var numbers = list.ConvertAll(int.Parse);
                    yield return (List<T>)(object)numbers;
                }
                else
                {
                    yield return (List<T>)(object)list;
                }
            }
        }
    }
}


Measured memory_bytes: 13268
def gcg(a,b):
    if b==0:
        return a
    else:
        return gcg(b,a%b)

n = int(input())
l = list(map(int,input().split()))

res = l[0]
for i in range(1,n):
    res = gcg(res,l[i])
else:
    print(res)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<int>::max();
#define highest_2_pow(n)  __builtin_clzll((long long)0)- __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int 
#define int long long
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}

void faster(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
void solve(){
    int n;
    cin>>n;
    vector<vi> v(3,vi(n));
    rep(i,0,n){
        cin>>v[0][i];
        cin>>v[1][i];
        cin>>v[2][i];
    }
    vector<vi> dp(3,vi(n));
    dp[0][0] = v[0][0];
    dp[1][0] = v[1][0];
    dp[2][0] = v[2][0];
    rep(i,1,n){
        dp[0][i] = max(dp[1][i-1]+v[0][i],dp[2][i-1]+v[0][i]);
        dp[1][i] = max(dp[2][i-1]+v[1][i],dp[0][i-1]+v[1][i]);
        dp[2][i] = max(dp[0][i-1]+v[2][i],dp[1][i-1]+v[2][i]);
    }
    cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]))<<endl;
}
signed main()
{
    faster();
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 8600
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define mem(arr,x) memset(arr,x,sizeof(arr))
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

void solve()
{
    ll n;
    cin>>n;
    n=n%1000;
    if(n==0)
      cout<<0;
    else
      cout<<1000-n;
}

int main()
{
    fast();
  
       solve();
   
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
using P = pair<int, int>;

int G[110][110] = {};

void solve(long long N){
    V<int> ans1, ans2;
    if (N % 2 == 0) {
        loop (N, i) {
            loop (N, j) {
                if (i >= j) continue;
                if (i + j == N - 1) continue;
                ans1.push_back(i);
                ans2.push_back(j);
            }
        }
    } else {
        loop (N, i) {
            loop (N, j) {
                if (i >= j) continue;
                if (i + j == N - 2) continue;
                ans1.push_back(i);
                ans2.push_back(j);
            }
        }
    }
    cout << ans1.size() << endl;
    loop (ans1.size(), i) {
        cout << ans1[i] + 1 << " " << ans2[i] + 1 << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}



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




int main(){
	long long  a  ,  b , n  ;
	cin >> n ;
	long long m = 1LL << 61 ;
	for( int i = 1 ; i <= sqrt(n) ; i++ ){
		if( n % i == 0  ){
			m = min(m , (i + n/i ));
		}
	}
	cout << m - 2  << endl ; 



	return 0 ;
}

Measured memory_bytes: 256
#071-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
n=I()
a=IL()
da={}
for l in a:
    if l in da:
        da[l]+=1
    else:
        da[l]=1
sda=sorted(da.keys(),reverse=True)
lens=[]
for l in sda:
    if da[l]>=4:
        if len(lens)==1:
            lens.append(l)
        else:
            print(l*l)
            break
    elif da[l]>=2:
        lens.append(l)
    
    if len(lens)==2:
        print(lens[0]*lens[1])
        break
else:
    print(0)

Measured memory_bytes: 18572
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>

using namespace std;

int main(){

  string s, s_out;
  cin >> s;

  int num = s.size();
  // string s_out[num]; ----???----

  for(int i=0; i<num; i++){
    //s_out[i] = "x";   ------???------
    s_out = s_out + "x";
  }
  cout << s_out;


}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	vector<int> a(n); for (int i = 0; i <= n - 1; i++) cin >> a[i];
	vector<int> pref(n, a[0]), suff(n, a[n - 1]);
	for (int i = 1; i <= n - 1; i++) pref[i] = max(pref[i - 1], a[i]);
	for (int i = n - 2; i >= 0; i--) suff[i] = max(suff[i + 1], a[i]);

	for (int i = 0; i <= n - 1; i++) {
		if (i == 0) cout << suff[1] << "\n";
		else if (i == n - 1) cout << pref[n - 2] << "\n";
		else cout << max(pref[i - 1], suff[i + 1]) << "\n";
	}

	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	ll ans =0;
	cin >>n;
	vector<ll> a(n), sm(n+1), xo(n+1);
	rep(i,n) cin >>a[i];
	
	rep(i,n) sm[i+1] = sm[i] + a[i];
	rep(i,n) xo[i+1] = xo[i] ^ a[i];
	
	//for(auto x :sm) printf("%d, ",x); puts("");
	//for(auto x :xo) printf("%d, ",x); puts("");
	
	rep(i,n){
		int hi=n+1, lw= i;
		while(hi - lw > 1){
			int md= (hi + lw) >> 1;
			if( (xo[md] ^ xo[i]) == sm[md] - sm[i])  lw = md;
			else hi = md;
		}
		//printf("%d:%d  ",i,lw);
		ans += lw -i;
	}

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


Measured memory_bytes: 4992
def f(i, X):
    if i == 0:
        return 1

    elif X == 1:
        return 0

    elif X <= 1 + a[i-1]:
        return f(i-1, X-1)

    elif X == 2 + a[i-1]:
        return p[i-1] + 1

    elif X <= 2 + 2 * a[i-1]:
        return f(i-1, X-2-a[i-1]) + 1 + p[i-1]

    else:
        return p[i]

N, X = map(int, input().split())
a = [1]
p = [1]
for i in range(N):
    a.append(2 * a[-1] + 3)
    p.append(2 * p[-1] + 1)

print(f(N, X))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  while(n > 0) {
    if (n % 10 == 9) {
      cout << "Yes" << endl;
      return 0;
    }
    n/=10;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i], a[i]--;
	ll sz = 1;
	set<int> st;
	int cur = 0;
	st.insert(cur);
	vector<int> cnt(n);
	ll x = 0;
	rep(i, n)
	{
		cur = a[cur];
		if(st.count(cur)){
			sz = i + 1 - cnt[cur];
			x = cnt[cur];
			break;
		}
		else{
			if(k==i+1){
				cout << cur + 1;
				return;
			}
			st.insert(cur);
			cnt[cur] = i+1;
		}
	}
	vector<int> v(sz);
	rep(i, sz){
		v[i] = cur;
		cur = a[cur];
		//cerr << v[i] << endl;
	}
	k = (k - x%sz +sz) % sz;
	//cout << k << endl;
	cout << v[k] + 1;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}

Measured memory_bytes: 13664
n = int(input())
a_ls = list(map(int, input().split()))
def isOK(a,b,c):
    return abs(a-b) < c < a+b
a_ls.sort()
ans = 0
for i in range(n):
    short = a_ls[i]
    r = i+1
    num = 0
    for l in range(i+1,n-1):
        while r+1 < n and isOK(short, a_ls[l], a_ls[r+1]):
            r += 1
        num += r - l
        if l == r:
            r += 1
    ans += num
print(ans)

Measured memory_bytes: 9256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll n,a,b,c,d;
int main(){
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	d-=c;
	rep(i,0,n){
		//減らすのをi回
		ll kihon=(n-1-2*i)*c;
		ll upper=d*(n-1-i);
		ll lower=-d*i;
		if(kihon+lower<=b-a&&b-a<=kihon+upper){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

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

using namespace std;
long long int min(long long int a, long long int b)
{
    if(a<b)
        return a;
    else
        return b;
}
long long int max(long long int a, long long int b)
{
    if(a<b)
        return b;
    else
        return a;
}
int main() {
    long long int n, a, b;
    cin >> n >> a >> b;
    if((b-a)%2==0)
    cout << (b-a)/2;
    else if((a+b)>(n+1))
        cout << ((2*n)-a-b+1)/2;
    else
        cout<<(a+b-1)/2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int H,W;
string s[2010];
int dp[2010][2010];
int L[2010],R[2010];
int max_rect(vector<int> v){
	stack<int> st;
	for(int i=0;i<v.size();i++){
		while(!st.empty()&&v[st.top()]>=v[i])st.pop();
		if(st.empty())L[i]=-1;
		else L[i]=st.top();
		st.push(i);
	}
	while(!st.empty())st.pop();
	for(int i=v.size()-1;i>=0;i--){
		while(!st.empty()&&v[st.top()]>=v[i])st.pop();
		if(st.empty())R[i]=v.size();
		else R[i]=st.top();
		st.push(i);
	}
	int res = 0;
	for(int i=0;i<v.size();i++){
		if(L[i]==-1)res = max(res,(R[i]-L[i]-1)*v[i]);
		else res = max(res,(R[i]-L[i])*v[i]);
	}
	return res;
}
int main(){
	cin >> H >> W;
	for(int i=0;i<H;i++)cin >> s[i];
	for(int i=0;i<W;i++)dp[0][i]=W-i;
	for(int i=1;i<H;i++){
		dp[i][W-1]=1;
		for(int j=W-2;j>=0;j--){
			if(s[i][j]==s[i-1][j]&&s[i][j+1]==s[i-1][j+1])dp[i][j]=dp[i][j+1]+1;
			else if(s[i][j]!=s[i-1][j]&&s[i][j+1]!=s[i-1][j+1])dp[i][j]=dp[i][j+1]+1;
			else dp[i][j]=1;
		}
	}
	/*for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cout << dp[i][j] << ' ';
		}
		cout << endl;
	}*/
	int ans = 0;
	for(int j=0;j<W;j++){
		vector<int> v;
		for(int i=0;i<H;i++){
			v.pb(dp[i][j]);
		}
		ans = max(ans,max_rect(v));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 20096
N, M, K = map(int, input().split())

flag = False

for i in range(N+1):
    for j in range(M+1):
        if flag:
            break
        if M*i+N*j-i*j*2==K:
            flag = True
    if flag:
        break

if flag:
    print("Yes")
else:
    print("No")


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

int N, K;
vector<int> edge[100];

int main() {
  cin >> N >> K;
  if(K>(N-1)*(N-2)/2) {
    cout << -1 << endl;
    return 0;
  }
  for(int i=0; i<N-1; i++) {
    edge[N-1].push_back(i);
  }
  vector<pair<int, int>> remain;
  for(int i=0; i<N-1; i++) {
    for(int j=i+1; j<N-1; j++) {
      remain.push_back(make_pair(i, j));
    }
  }
  for(int i=0; i<(N-1)*(N-2)/2-K; i++) {
    pair<int, int> e = remain[i];
    edge[e.first].push_back(e.second);
  }
  cout << N-1+(N-1)*(N-2)/2-K << endl;
  rep(i, N) {
    for(int u : edge[i]) {
      cout << i+1 << " " << u+1 << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;
class Main{
public static void main(String args[]){
	Scanner s=new Scanner(System.in);
	int sumOfLeft=0;
	int max=0;
	int side=0;
	int N=s.nextInt();
	for(int i=0;i<N;i++){
		side=s.nextInt();
		sumOfLeft+=side;
		if(max<side) max=side;
	}
	if(sumOfLeft<=(2*max)) System.out.println("No");
	else System.out.println("Yes");
}}

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

using namespace std;
using ll = long long;

int main() {
    ll h, w;
    cin >> h >> w;
    vector<string> ws;
    ws.reserve(h);
    for (ll i = 0; i < h; ++i) {
        string s;
        cin >> s;
        ws.emplace_back(std::move(s));
    }
    vector<ll> l(static_cast<size_t>(h * w), 0);
    vector<ll> r(l.size(), 0);
    vector<ll> d(l.size(), 0);
    vector<ll> u(l.size(), 0);
    for (ll i = 0; i < h; ++i) {
        for (ll j = 0; j < w; ++j) {
            if (ws[i][j] == '.') {
                if (j > 0)
                    l[j + i * w] = l[j - 1 + i * w];
                ++l[j + i * w];
            }
        }
    }
    for (ll i = 0; i < h; ++i) {
        for (ll j = w - 1; j >= 0; --j) {
            if (ws[i][j] == '.') {
                if (j < w - 1)
                    r[j + i * w] = r[j + 1 + i * w];
                ++r[j + i * w];
            }
        }
    }
    for (ll i = 0; i < w; ++i) {
        for (ll j = 0; j < h; ++j) {
            if (ws[j][i] == '.') {
                if (j > 0)
                    d[i + j * w] = d[i + (j - 1) * w];
                ++d[i + j * w];
            }
        }
    }
    for (ll i = 0; i < w; ++i) {
        for (ll j = h - 1; j >= 0; --j) {
            if (ws[j][i] == '.') {
                if (j < h - 1)
                    u[i + j * w] = u[i + (j + 1) * w];
                ++u[i + j * w];
            }
        }
    }
    ll c = 0;
    for (ll i = 0; i < h; ++i) {
        for (ll j = 0; j < w; ++j) {
            auto k = j + i * w;
            c = max(c, l[k] + r[k] + u[k] + d[k] - 3);
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 129408