akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>

#define INF 100000000
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;


   

int main(){
    int n; cin >> n;
    string s; cin >> s;
    
    int ans = 0;
    char last =s[0];
    rep(i, n){
        if (s[i] == last) {
            continue;
        }
        ans++;
        last = s[i];
        
    }
    cout << ans+1 << endl;
    
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <stack>
using namespace std;


int main(void){
  string s;
  int k,l,i;
  stack<char> st;
  int flag;
  while(getline(cin,s)){
    if(s.length()==1&&s[0]=='.') break;
    while(!st.empty()) st.pop();
    flag=0;
    for(i=0;i<s.length();i++){
      if(s[i]=='('||s[i]=='['){
        st.push(s[i]);
      }
      if(s[i]==')'||s[i]==']'){
        if(st.empty()) flag=1;
        if(!st.empty()){
          if(s[i]==')'){
            if('('!=st.top()) flag=1;
          }
          if(s[i]==']'){
            if('['!=st.top()) flag=1;
          }
          st.pop();
        }
      }
    }
    if(!st.empty()) flag=1;
    if(flag) cout<<"no"<<endl;
    else cout<<"yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3188
A, B = list(map(int, input().split()))
n = int(A/0.08)
while n < (A+1)/0.08 and n < (B+1)/0.1:
  if n >= A/0.08 and n >= B/0.1:
    print(n)
    break
  n += 1
else:
  print(-1)

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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]

int main(){
    int a;

  scanf("%d", &a);

  printf("%d\n", a + a*a + a*a*a);

  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<ll> vec(n);
  rep(i, n) {
    cin >> vec[i];
  }
  int tmp = 0;
  int res = 0;
  for(int i = 0; i < n - 1; i++) {
    if (vec[i] < vec[i+1]) { 
      res = max(res, tmp);
      tmp = 0;
      continue;
    }
    tmp++;
    res = max(res, tmp);
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double dx = x2 - x1;
    double dy = y2 - y1;
    cout << fixed << setprecision(5) << sqrt(dx*dx+dy*dy) << endl;
}


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

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

	string s;
	cin >> s;

	set<string> m;
	m.insert("dream");
	m.insert("dreamer");
	m.insert("erase");
	m.insert("eraser");

	string t;
	while(s.size()) {
		t = s.back() + t;
		s.pop_back();
		if(m.count(t)) {
			//cout << t << endl;
			t.clear();
		}
		if(t.size() > 7) {
			cout << "NO" << endl;
			return 0;
		}
	}

	if(t == "") {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 640
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static Map<Integer, Integer> map = new LinkedHashMap<>();

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		System.out.println((int) Math.ceil((double) (a + b) / 2));
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
using namespace std;
int main()
{
	long long a,b;
	int n;
	cin>>a>>b>>n;
	for(int i=0;i<n;i++)
	{
		if(i%2==0)
		{
			a=a/2;
			b=b+a;
		}
		else
		{
			b=b/2;
			a=a+b;
		}
	}
	cout<<a<<' '<<b;
	
 } 

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

namespace Atcoder_0403
{
    class Program
    {
        static void Main(string[] args)
        {
            var NKS = GetInput_int();
            int _allDayCount = NKS[0];
            int _needDayCount = NKS[1];
            int _restDayLength = NKS[2];
            var _scedule = GetInput_string()[0];

            List<int> _workFastest = new List<int>();//i番目に働く日は最速でd_i日目

            //最速で働いていく日を設定
            for (int i = 0; i < _scedule.Length; i++)
            {
                if (_scedule[i] == 'o')
                {
                    _workFastest.Add(i+1);
                    i += _restDayLength;
                }
                if (_workFastest.Count == _needDayCount) break;
            }

            List<int> _workLatest=new List<int>();//i番目に働く日は最遅でd_i日目
            for (int i = _scedule.Length-1; i>=0; i--)
            {
                if (_scedule[i] == 'o')
                {
                    _workLatest.Add(i+1);
                    i -= _restDayLength;
                }
                if (_workLatest.Count == _needDayCount) break;
            }
            _workLatest.Reverse();

            if (_workFastest.Count != _needDayCount
                || _workLatest.Count != _needDayCount) return;

            var _result = new List<int>();
            for(int i = 0; i < _needDayCount; i++)
            {
                if (_workFastest[i] == _workLatest[i])
                {
                    _result.Add(_workFastest[i]);
                }
            }

            foreach(var data in _result)
            {
                Console.WriteLine(data);
            }
        }

        #region input


        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        #endregion
    }
}


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

int main() {
  std::string str;
  std::cin >> str;
  int year = std::atoi(str.substr(0, 4).c_str());
  int month = std::atoi(str.substr(5, 2).c_str());
  int day = std::atoi(str.substr(8, 2).c_str());

  if (year < 2019) {
    std::cout << "Heisei" << std::endl;
  } else if (2019 < year) {
    std::cout << "TBD" << std::endl;
  } else {
    // 2019
    if (month <= 4) {
      std::cout << "Heisei" << std::endl;
    } else {
      std::cout << "TBD" << std::endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
//const long mod=(long)1e9+7;
inline void solve(void){
  int a,b;in(a,b);
  string A,B;
  rep(i,b){
    A+=to_string(a);
  }
  rep(i,a){
    B+=to_string(b);
  }
  out(A<B?A:B);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	//iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
void solve() {
	int p, q;
	cin >> p >> q;
	q /= gcd(p, q);
	int ans = 1;
	for (int i = 2; i * i <= q; ++i) {
		if (q % i == 0) {
			ans *= i;
			while (q % i == 0) {
				q /= i;
			}
		}
	}
	ans *= q;
	ans = max(ans, 2LL);
	cout << ans << endl;
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3116
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
 
static const double EPS = 1e-8;

static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int sum[50];

int main(){
  for(int i = 1,len=1; len <= 30; i *= 3){
    sum[len] = sum[len-1] + i;
    sum[len+1] = sum[len] + i;
    len+=2;
  }

  int n;
  while(~scanf("%d",&n)){
    int res = 0;
    printf("%d\n",sum[n]);
  }
}

Measured memory_bytes: 1188
N = int(input())
S = [input() for x in range(N)]
dic = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(N):
    dic[S[i]] += 1
print('AC x '+ str(dic['AC']))
print('WA x '+ str(dic['WA']))
print('TLE x '+ str(dic['TLE']))
print('RE x '+ str(dic['RE']))

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

string s[22];
int h,w, ans = 0;
int vis[22][22];
int dx[4]={0,0,-1,1};
int dy[4]={1,-1,0,0};

void bfs(int x, int y, int z){
	queue< pair < ii,int > >q;
	q.push(mp(mp(x,y),z));
	while(!q.empty()){
		int xx = q.front().fi.fi;
		int yy = q.front().fi.se;
		int zz = q.front().se;
		//cout << xx << ' ' << yy << ' ' << zz << endl;
		q.pop();
		if(vis[xx][yy])continue;
		ans = max(ans,zz);
		vis[xx][yy] = 1;
		for(int i = 0; i < 4; i++){
			int X = xx+dx[i];
			int Y = yy+dy[i];
			//cout << "n:" << X << ' ' << Y << endl;
			if(X<0||X>h)continue;
			if(Y<0||Y>w)continue;
			//cout << s[X][Y] << ' ' << vis[X][Y] << endl;
			if(s[X][Y]=='.'&&!vis[X][Y]){
				//cout << "hy " << X << ' ' << Y << endl;
				q.push(mp(mp(X,Y),zz+1));
			}
		}
	}
	
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		cin >> s[i];
	}
	/*
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++)cout << s[i][j];
		cout << endl;
	}
	*/ 
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i][j]=='.'){
				//cout << i << "  "<< j << endl;
				memset(vis,0,sizeof(vis));
				bfs(i,j,0);
			}
		}
	}
	cout << ans << endl;
}	


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
int main() {
	int ans = 0;
	char str[100001], *s, *e;
	scanf("%s", str);
	s = str, e = s + strlen(s) - 1;
	while (s <= e) {
		//printf("s:%c e:%c\n", *s, *e);
		if (*s != *e) {
			if (*s == 'x')s++, ans++;
			else if (*e == 'x')e--, ans++;
			else {
				puts("-1");
				return 0;
			}
		}
		else s++, e--;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>

int main(void) {
  int n, k;
  scanf("%d %d", &n, &k);

  int ans = k;

  for(int i = 1; i < n; i++) {
    ans *= k - 1;
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

int dp[50001];

int main(void)
{
	ios::sync_with_stdio(false);
	int n, m;
	int coins[20];
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
		cin >> coins[i];
	for (int i = 0; i <= n; ++i)
		dp[i] = i;
	for (int i = 1; i < m; ++i)
	{
		for (int j = coins[i]; j <= n; ++j)
		{
			dp[j] = min(dp[j], dp[j - coins[i]] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

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

int max_n=100;
int main(){
  int h,w;
  std::cin >> h>>w;
  char a[max_n][max_n];
  bool han[max_n][max_n];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      /* code */
      han[i][j]=true;
    }
    /* code */
  }
  for (int i = 0; i < h; i++) {
    /* code */
    for (int j = 0; j < w; j++) {
      /* code */
      std::cin >> a[i][j];
    }
  }

  for (int i = 0; i < h; i++) {
    /* code */
    bool hoge=false;
    for (int j = 0; j < w; j++) {
      /* code */
      if(a[i][j]=='#')hoge=true;
    }
    if(not hoge){
      for (int j = 0; j < w; j++) {
        /* code */
        han[i][j]=false;
      }
    }
    
  }
  
  for (int i = 0; i < w; i++) {
    /* code */
    bool hoge=false;
    for (int j = 0; j < h; j++) {
      /* code */
      if(a[j][i]=='#')hoge=true;
    }
    if(not hoge){
      for (int j = 0; j < h; j++) {
        /* code */
        han[j][i]=false;
      }
    }
    
  }
  for (int i = 0; i < h; i++) {
    int j;
    bool hoge=false;
    for ( j = 0; j < w; j++) {
      /* code */
      if(han[i][j]){
        std::cout <<a[i][j];
        hoge=true;
      }
    }
    /* code */
    if(hoge)std::cout   << std::endl;
  }
  
}


Measured memory_bytes: 256
//2020.1.21
//s1270188 xxxmk2
//v0_3

#include<stdio.h>

//prototype
int judge(int *);

int main(){
  int num, i, d[3];
  
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d %d %d",&d[0],&d[1],&d[2]);

    if(judge(d)==1) printf("YES\n");
    else printf("NO\n");
  }
  
  return 0;
}

int judge(int *d){
  int i, max=0, min=1001, mid=0;
  
  for(i=0;i<3;i++){
    if(d[i]>max) max=d[i];
    if(d[i]<min) min=d[i];

    mid+=d[i];
  }

  mid-=max+min;

  if(min*min+mid*mid==max*max) return 1;
  else return 0;
  
}


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

int main(){

    char alpha;
    cin >> alpha;

    if ('A' <= alpha && alpha <= 'Z') cout << 'A' << endl;
    if ('a' <= alpha && alpha <= 'z') cout << 'a' << endl;

    return 0;
}

Measured memory_bytes: 3592
/*
ID: cyxoier1
TASK: A
PROG: a.cpp
LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;

template<typename T>
inline void Read(T &n){
	char ch; bool flag=0;
	while(!isdigit(ch=getchar()))if(ch=='-')flag=1;
	for(n=ch^48;isdigit(ch=getchar());n=(n<<1)+(n<<3)+(ch^48));
	if(flag)n=-n;
}

int a, b, c;

int main(){
	cin>>a>>b>>c;
	if(a+b+c>=22) puts("bust");
	else puts("win");
	return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
dat_a = list(map(int, input().split()))
dat_a_e = []
dat_a_o = []
for i in range(n//2):
    dat_a_e.append(dat_a[2*i])
    dat_a_o.append(dat_a[2*i+1])
#print(dat_a_e)
#print(dat_a_o)
c_e = collections.Counter(dat_a_e).most_common(2)
c_o = collections.Counter(dat_a_o).most_common(2)
if len(c_e) == 1:
    c_e.append((0,0))
if len(c_o) == 1:
    c_o.append((0,0))

if c_o[0][0] != c_e[0][0]:
    print(n//2 - c_e[0][1] + n//2 - c_o[0][1])
else:
    x = n//2 - c_e[0][1] + n//2 - c_o[1][1]
    y = n//2 - c_e[1][1] + n//2 - c_o[0][1]
    print(min(x, y))




Measured memory_bytes: 16100
"""
author : halo2halo
date : 30, Jan, 2020
"""

import sys

# import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = readline().decode('utf8')

print('Yes' if '9' in N else 'No')


Measured memory_bytes: 14428
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

int solve(int n, int maxw, int v[], int w[])
{
	int result[101][10001];
	for(int i = 0; i < n + 1; i++){
		for(int j = 0; j < maxw + 1; j++){
			result[i][j] = 0;
		}
	}
	for(int i = 1; i < n + 1; i++){
		for(int j = 1; j < maxw + 1; j++){
			if(w[i] <= j){
				result[i][j] = max(result[i - 1][j], result[i][j - w[i]] + v[i]);
			} else result[i][j] = result[i - 1][j];
		}
	}
	return result[n][maxw];
}

int main()
{
	int n, maxw;
	int v[101], w[101];
	cin >> n >> maxw;
	for(int i = 1; i < n + 1; i++){
		cin >> v[i] >> w[i];
	} 
	cout << solve(n, maxw, v, w) << endl;
	return 0;
}

Measured memory_bytes: 5104
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, X);
    IN(ll, Y);

    vi ans(N);
    REP1(i, N)
    {
        REP1(j, N)
        {
            if (j <= i)
            {
                continue;
            }
            ++ans[min(j - i, abs(i - X) + 1 + abs(j - Y))];
        }
    }
    REP1(k, N - 1)
    {
        OUT(ans[k]);
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
a, b, c, d = list(map(int, input().split()))

while (a > 0 and c > 0):
    c -= b
    if (c <= 0):
        print('Yes')
        exit()
    a -= d
    if (a <= 0):
        print('No')
        exit()


Measured memory_bytes: 27124
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
using namespace std;

int main(){
  int A, B; cin >> A >> B;
  int plus = A + B;
  int minus = A - B;
  int multi = A * B;

  int ans = plus;
  if(ans < minus) ans = minus;
  if(ans < multi) ans = multi;

  cout << ans;
	return 0;
}


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

typedef long long int lld;
typedef unsigned long long int ulld;
const int mod = 1000000007;

using namespace std;

ulld gbs (lld a, lld b) {
	lld re = a;
	if (b > a) {
		re = b;
		b = a;
		a = re;
	}
	while (re % b) {
		re += a;
	}
	return re;
}

int main (void) {
	ios::sync_with_stdio (false);
	int t;
	ulld re = 1, uinp;
	cin >> t;
	while (t--) {
		cin >> uinp;
		re = gbs (re, uinp);
	}
	cout << re << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int so[246913]={},n;
  for(int i=2;i<246913;i++)if(so[i]==0)for(int j=2;i*j<246913;j++)so[i*j]=1;
  while(1){
  int an=0;cin>>n;
  if(n==0)break;
  for(int i=n+1;i<=2*n;i++)if(so[i]==0)an++;
  cout<<an<<endl;
  }
  return 0;
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main() {
    int64_t N;
    cin >> N;
    vector<long long> diveded = divisor(N);
    int len = diveded.size();
    int64_t count = INT64_MAX;
    for (int i=0; i < len; i++) {
        int64_t yakusuu = diveded[i];
        int64_t yakusuu2 = N / yakusuu;
        int64_t min_ = max(to_string(yakusuu).size(), to_string(yakusuu2).size());
        if (count > min_) {
            count = min_;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
 
int main(){
  ll a, b;
  cin >> a >> b;

  for(ll i = 1; i <= 10000; i++){
    double zeia = (int)(i * 0.08);
    double zeib = (int)(i * 0.1);

    if(zeia == a && zeib == b){
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    L=[]
    for i in range(N):
        L.append([A[i],i])
        
    L.sort()
    ans=[]
    for i in range(N):
        ans.append(L[i][1]+1)
        
    print(' '.join(map(str, ans)))

main()


Measured memory_bytes: 102188
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500001
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll pows(ll ten, ll n) {
	return ten * pow(ten, n - 1);
}

ll ans;

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

	cout << t + s << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <bitset> 

using namespace std;

const int INF=1e9+7,mod=1e9+7;
const double eps=1e-8;
const int MAXN=110000;

int a[100001];

int main()
{
 //   freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    int cas=0,T;
  //  cin>>T;
    //while(++cas<=T)
  // 	while(scanf("%d%d",&nn,&mm)!=EOF)
    {
    	int n,m,x,y;
    	cin>>n>>m;
    	for(int i=1;i<=n;i++)
    		cin>>a[i];
    	int flag=0;
    	for(int i=1;i<=n;i++)
			if(a[i]+a[i+1]>=m)
			{
				cout<<"Possible"<<endl; 
				for(int j=n-1;j>i;j--)
					cout<<j<<endl;
				for(int j=1;j<i;j++)
					cout<<j<<endl;
				cout<<i<<endl;
				flag=1;
				break;
			}
		if(flag==0)
			cout<<"Impossible"<<endl; 
    }
    return 0;
}


Measured memory_bytes: 1152
#include <string>
#include <vector>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

signed main(){
  int N,M,C;
  cin>>N>>M>>C;
  vector<int> l(C);
  map<int,int> mp;//色　上限
  REP(i,C){
    int l;
    cin>>l;
    mp[i]=l;
  }
  vector<pair<int,int> > p(N);
  REP(i,N){
    int c,w;
    cin>>c>>w;
    c--;
    p[i]=make_pair(w,c);
  }
  sort(ALL(p));
  reverse(ALL(p));
  int hoji=0,ans=0;
  REP(i,p.size()){
    if(hoji==M)break;
    if(mp[p[i].second]>0){
      ans+=p[i].first;
      mp[p[i].second]--;
      hoji++;
    }
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 10932
#include <iostream>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int n, x;
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> x;
        a[x] = i;
    }
    for (int i = 1; i < n; i++)
        cout << a[i] << " ";
    cout << a[n];
    //system("pause");
}

Measured memory_bytes: 1152
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        if(k*500>=x){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  
  if(s<t) puts("Yes");
  else puts("No");
  return 0;
}


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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 1e5 + 5;

int N, ans1, ans2;
char s[MAXN];

int main(){
	scanf("%s", s + 1);
	N = strlen(s + 1);
	ans1 = ans2 = N;
	up (i, 1, N) if (s[i] == '1') {
		cmin(ans1, max(i - 1, N - i));
	}
	up (i, 1, N) if (s[i] == '0') {
		cmin(ans2, max(i - 1, N - i));
	} 
	printf("%d\n", max(ans1, ans2));
	return 0;
}


Measured memory_bytes: 384
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
D = {"r": 0, "s": 1, "p": 2}
T = [D[a] for a in input()]
X = [[0] * 3 for _ in range(N)]
for i in range(N):
    if i < K:
        X[i][T[i]] = 0
        X[i][T[i]-1] = A[T[i]-1]
        X[i][T[i]-2] = 0
    else:
        X[i][T[i]] = max(X[i-K][T[i]-1], X[i-K][T[i]-2])
        X[i][T[i]-1] = A[T[i]-1] + max(X[i-K][T[i]], X[i-K][T[i]-2])
        X[i][T[i]-2] = max(X[i-K][T[i]], X[i-K][T[i]-1])

print(sum([max(x) for x in X[-K:]]))

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

int	main()
{
	int	K, A, B;
	cin >> K >> A >> B;
	for (int i = A; i <= B; ++i) {
		if (i % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){

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

    if(a == b && b == c && c == a){
        cout << "No" << endl;
        return 0;
    }
    if(a != b && b != c && c != a){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
typedef long long ll;

ll COM(ll n, ll k) {
	if (k < 0 || n < k) return 0;
	int64_t ret = 1;
	for (int64_t i = 1; i <= k; ++i) {
		ret *= n--;
		ret /= i;
	}
	return ret;
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll v[n];
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v, v + n);
	reverse(v, v + n);
	ll sum = 0;
	for (int i = 0; i < a; i++) {
		sum += v[i];
	}
	map<ll, ll>mp1;
	map<ll, ll>mp2;
	printf("%lf\n", (double)sum / a);
	sum = 0;
	if (v[0] == v[a - 1]) {
		int num = 0;
		for (int i = 0; i < n; i++) {
			if (v[i] == v[0])num++;
		}
		for (int i = a; i <= b; i++) {
			sum += COM(num, i);
		}
		cout << sum << endl;
	}
	else {
		for (int i = 0; i < a; i++) {
			mp1[v[i]]++;
		}
		for (int i = 0; i < n; i++) {
			mp2[v[i]]++;
		}
		cout << COM(mp2[v[a - 1]], mp1[v[a - 1]]) << endl;
	}
}

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

int main() {

  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H+2, vector<char>(W+2,'.'));

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> data.at(i).at(j);
    }
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if(data.at(i).at(j)=='#') {
        if(data.at(i-1).at(j)=='.'&&data.at(i+1).at(j)=='.'
        &&data.at(i).at(j-1)=='.'&&data.at(i).at(j+1)=='.') {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;


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


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

  ll pa=1;
  rep(i,N){
    pa = pa*a[i] / gcd(pa,a[i]);
  }

  ll sum = 0;
  rep(i,N){
    sum += pa/a[i];
  }
  // cout<<pa<<" "<<sum<<endl;
  double ans = pa*1.0/sum*1.0;
  cout<<ans<<setprecision(10)<<endl;
}


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

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

const LL inf = 1000000000000000;
const LL mod = 1000000007;

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

	LL flag = 0;
	for (int i = 1; i <= 9; ++i) {
		if (n % i == 0) {
			LL b = n/i;
			if (b <= 9) {
				flag = 1;
				break;
			}
		}
	}
	if (flag) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	 
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val A = Integer.parseInt(sc.next())
    val B = Integer.parseInt(sc.next())
    val C = Integer.parseInt(sc.next())

    println(A * B / 2)
  }
}

Measured memory_bytes: 25800
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

int mat[110][110];

int
main(void){  
  int w,h,n,x,y,a;
  
  cin >> w >> h >> n;
    
  REP(i, n){
    cin >> x >> y >> a;
    if(a == 1){
      REP(j, x){
	REP(k, h){
	  ++mat[j][k];
	}
      }
    }
    else if(a == 2){
      FOR(j, x, w){
	REP(k, h){
	  ++mat[j][k];
	}
      }
    }
    else if(a == 3){
      REP(j, w){
	REP(k, y){
	  ++mat[j][k];
	}
      }
    }
    else {
      REP(j, w){
	FOR(k, y, h){
	  ++mat[j][k];
	}
      }
    }    
  }

  int count = 0;
  REP(i, w){
    REP(j, h) {
      if(mat[i][j] == 0){
	++count;
      }
    }
  }

  cout << count << endl;
  
  return 0;
}


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

using namespace std;

string solve(int N)
{
	for (int a = 0; a <= N; a += 4) {
		if ((N - a) % 7 == 0) {
			return "Yes";
		}
	}
	return "No";
}

int main()
{
	int N;
	cin >> N;
	cout << solve(N) << endl;
}


Measured memory_bytes: 256
def main():
    n, *a = map(int, open(0).read().split())
    b = sorted(a)

    ans = b[-1]
    cnt = n - 2
    i = -1
    for _ in range(n - 2):
        i -= 1
        if cnt == 0:
            break
        if cnt == 1:
            ans += b[i]
            break
        cnt -= 2
        ans += 2 * b[i]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31680
import sys

sys.setrecursionlimit(200000)


def add_link(a, b):
    la = links[a]
    i, j = [(0, 1), (1, 0)][s[b] == 'B']
    if not la[i] and la[j]:
        able[a] = True
    la[i].add(b)


def close(v, i):
    j = int(s[v] == 'B')
    for u in links[v][i].copy():
        if not able[u]:
            continue
        links[u][j].discard(v)
        if not links[u][j]:
            able[u] = False
            close(u, j ^ 1)


n, m = map(int, input().split())
s = input()
links = [[set(), set()] for _ in range(n)]
able = [False] * n
for line in sys.stdin.readlines():
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    add_link(a, b)
    add_link(b, a)

for v in range(n):
    if able[v]:
        continue
    close(v, bool(links[v][1]))

print('Yes' if any(able) else 'No')


Measured memory_bytes: 209700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

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

    ll ans = 0;
    if (N==0)
     ans = 1;
     
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
import heapq
from collections import deque

X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

r.sort()

if A < X:
  p += r[-(X - A):]
  r = r[:-(X - A)]
  A = X

if B < Y:
  q += r[-(Y - B):]
  r = r[:-(Y - B)]
  B = Y

p.sort()
q.sort()

pq = deque(heapq.merge(p[A - X:], q[B - Y:]))

while r and pq[0] < r[-1]:
  pq.popleft()
  pq.append(r.pop())

print(sum(pq))


Measured memory_bytes: 23592
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(20)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N; INTV A; cin >> N;
  map<int, int> mp;
  REP(i, N){
    int a; cin >> a;
    A.eb(a);
    mp[a]++;
  }
  sort(RALL(A)); A.erase(unique(ALL(A)), A.end());
  int ans = 0;
  for(auto a : A){
    int b;
    for(int i = 0; i <= 30; i++){
      if(a < (1<<i) and (1<<i) <= 2*a){
        b = (1<<i)-a; break;
      }
    }
    int add;
    if(a==b){
      add = mp[a]/2;
    } else {
      add = min(mp[a], mp[b]);
    }
    ans += add; mp[a] -= add; mp[b] -= add;
  }
  cout << ans << endl;
}

Measured memory_bytes: 26864
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var N, K int
	con.Scan(&N, &K)
	A := K
	for i := 0; i < N-1; i++ {
		A *= K - 1
	}
	con.Println(A)
	return nil
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(void){
    int num;
    while(1){
        cin >> num;
        if(num == 0) break;
        double points[num];
        double mean = 0, sd = 0;
        for(int i=0; i<num; i++){
            cin >> points[i];
            mean += points[i];
        }
        mean /= num;
        for(int i=0; i<num; i++){
            sd += pow((points[i] - mean), 2);
        }
        sd /= num;
        sd = sqrt(sd);
        printf("%.8lf\n", sd);
    }
    return 0;
}

Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;


signed main()
{
	fastio(0);
	int n;
	string s;
	cin>>n;
	cin>>s;
	s = '*' + s;
	int dp[n+1],prefix[n+1];  
	init(dp,0);
	init(prefix,0);
	
	dp[1] = 1;
	loop(j,1,n+1) prefix[j] = (prefix[j-1] + dp[j])%mod; 
	loop(i,2,n+1)
	{
		loop(j,1,i+1)
			if(s[i-1]=='>')	dp[j] = (prefix[n] - prefix[j-1] + mod)%mod;
			else dp[j] = prefix[j-1]%mod;
		loop(j,1,n+1) prefix[j] = (prefix[j-1] + dp[j])%mod; 		
	}
	cout<<prefix[n]<<endl;
	return 0;		
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    string s; cin >> s;
    if (s == "RRR") cout << 3 << endl;
    else if (s == "SSS") cout << 0 << endl;
    else if (s == "RRS" || s == "SRR") cout << 2 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int64_t mod=1000000007;
int main() {
  int64_t n,k,i,s=0;
  cin>>n>>k;
  for(i=k;i<=n+1;i++) s=(s+i*(n-i+1)+1)%mod;
  cout<<(s+mod)%mod<<endl;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		String str[] = br.readLine().split("");

		int a = 0;
		int b = 0;
		int c = 0;

		for (int i = 0; i < str.length; i++) {
			if (str[i].equals("a")) {
				a++;
			} else if (str[i].equals("b")) {
				b++;
			} else {
				c++;
			}
		}

		int diff1 = Math.abs(a - b);
		int diff2 = Math.abs(b - c);
		int diff3 = Math.abs(c - a);

		if (diff1 <= 1 && diff2 <= 1 && diff3 <= 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 29012
n=(int)(input())
a = sorted(list(input() for i in range(n)))
lis = sorted(list(set(a)))
big = [0 for i in range(len(lis))]
maxi = 0
counter = 1
check = 0
#print(a)
for i in range(len(a) - 1):
  #print(a[i])
  if a[i] == a[i + 1]:
    counter += 1
  else:
    big[check] = counter
    counter = 1
    check += 1
else:
  big[-1] = counter
maxi = max(big)
#print(lis, big)
for i in range(len(lis)):
  if big[i] == maxi:
    print(lis[i])

Measured memory_bytes: 36116