akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int n;
  cin >> n;
  pair <int,int> s[n];
  for(int i = 0;i<n;i++){
    int x,y;
    cin >> x >> y;
    s[i].first = x;
    s[i].second = y;
  }
  sort(s,s+n);
  int f = 0;
  bool t = false;
  if(s[0].first >= b)
    t = true;
  if(s[n-1].second <= a)
    t = true;
  for(int i = 0;i < n;i++){
    if(s[i].second <= a && s[i+1].first >= b){
      t = true;
      break;
    }
  }
  if(t)
    cout << '0' << endl;
  else{
    cout << '1' << endl;
  }

  /*while(s[f].first < a){
    
    f++;
    
    }
  f--;
  cout << f << endl;
  if(n != 0){
    if(f != -1){
      if(s[f].second <= a && s[f+1].first >= b)
	cout << '0'<< endl;
      else
	cout << '1' << endl;
	}*/
    
    /*else{
      if(s[0].second >= b && s[0].first > a)
      cout << '0' << endl;
      else
      cout << '1' << endl; 
	}*/
  /*}
  else{
    cout << '0'  << endl;
    }*/
  
 
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << ((B + C - 1) / B <= (A + D - 1) / D ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<double>> x(N, vector<double>(D));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < D; j++){
      cin >> x[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      double sum = 0.0;
      for (int k = 0; k < D; k++){
        sum += pow(x[i][k] - x[j][k], 2.0);
      }
      if (ceil(sqrt(sum)) == floor(sqrt(sum))){
        ans += 1;
      }
    }
  }
  cout << ans << endl;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//#define bug( x ,y) cerr << #x << '=' << x<<','<<#y<<'='<< y << '\n' ;


int a,b;


int main(){

	IOS

	cin >> a >> b;
	
	int have = 1,strips = 0 ;

	while(have < b){
		have += a- 1;
		strips++;

	}

	cout << strips << '\n';



	
 
}

Measured memory_bytes: 384
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let a:i32 = read(&mut s).unwrap();
    let b:i32 = read(&mut s).unwrap();
    if a%3 == 0 || b%3 == 0 || (a+b)%3 ==0 {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}


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

using namespace std;

#define ll long long

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int q, b, e, k;
    cin >> q;
    while (q--) {
        cin >> b >> e >> k;
        int cnt = 0;
        for (int i = b; i < e; i++) {
            if (a[i] == k) cnt++;
        }
        cout << cnt << endl;
    }


    return 0;
}


Measured memory_bytes: 3088
#include<cstdio>
using namespace std;
int n,last[10],o[10],sum=5,t=2;
bool b[30005];
int main(void){
	register int i,j,k;
	scanf("%d",&n);
	if(n==3){
		puts("2 5 63");
		return 0;
	}
	b[2]=b[3]=1,last[0]=0,last[2]=2,last[3]=3,last[4]=4;
	for(i=4;i<=30000;++i){
		if(i%2==0||i%3==0)b[i]=1,sum+=i,++t,last[i%6]=i,o[i%6]=1;
		if(t==n){
			if(sum%6==0)break;
			for(j=0;j<6;++j){
				if(j==1||j==5)continue;
				if(!o[j])continue;
				for(k=0;k<6;++k)
					if(k!=1&&k!=5&&(sum%6-j+k)%6==0&&last[k]+6<=30000){
						b[last[k]+6]=1;
						b[last[j]]=0;
						for(i=1;i<=30000;++i)
							if(b[i])
								printf("%d ",i);
						return 0;		
					}
			}
		}
	}
	for(i=1;i<=30000;++i)
		if(b[i])
			printf("%d ",i);
	return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
h = na()

A = [0 for _ in range(n)]

for i in range(n):
  if i == 1:
    A[i] = abs(h[i]-h[i-1])
  elif i>1:
    A[i] = min(A[i-1]+abs(h[i]-h[i-1]),A[i-2]+abs(h[i]-h[i-2]))
  else:
    A[i] = A[i]

print(A[-1])

Measured memory_bytes: 14012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
int gcd(int a,int b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
int lcm(int a,int b){int c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N;
	ll A;
	cin >> N;
	map<ll,ll> ma;
	FOR(i,0,N){
		cin >> A;
		ma[A]++;
	}

	ll ppp = 0;
	vector<ll> a;
	ll ans;
	for(auto x:ma){
		if((x.first-ppp)%2)a.push_back(N);
		else a.push_back(0);
		N -= x.second;
		ppp = x.first;
	}
	ans = a[0];
	FOR(i,1,a.size()){
		ans ^= a[i];
	}
	if(ans!=0){
		cout << "first" << endl;
	}else{
		cout << "second" << endl;
	}
}

Measured memory_bytes: 7676
k = int(input())
x,y = map(int,input().split())
if abs(x)+abs(y) == k:
    print(1)
    print(x,y)
    exit()
cx = cy = cxy = False
if x < 0:
    x = -x
    cx = True
if y < 0:
    y = -y
    cy = True
if x < y:
    x,y =y,x
    cxy = True

if k %2 == 0 and (x+y)%2 == 1:
    print(-1)
    exit()

ans = []
n = max((x+y+k-1)//k,2)

if (x+y)%2 != (n*k)%2:
    n += 1

if x < k and n==3:
    mid = (k+x-y)//2
    ans.append([x,x-k])
    ans.append([x+mid,y-k+mid])
    ans.append([x,y])

else:
    over = (n*k-x-y)//2
    for i in range(1,n+1):
        d = i*k
        if d <= y+over:
            ans.append([0,d])
        elif d <= y+over+x:
            ans.append([d-over-y,y+over])
        else:
            ans.append([x,y+(n-i)*k])

if cxy:
    ans = [[i,j] for j,i in ans]
if cx:
    ans = [[-i,j] for i,j in ans]
if cy:
    ans = [[i,-j] for i,j in ans]


print(n)
for i,j in ans:
    print(i,j)


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

int main(void){
  int h, w;
  cin >> h >> w;
  
  vector<char> moji(h*w);
  for( int i=0 ; i < h*w ; i++ ){
    cin >> moji.at(i);
  }
  
  vector<char> huti((h+2)*(w+2)-h*w, '#');
  
  int n = 0, m = 0;
  for( int i=0 ; i < h+2 ; i++ ){
    for( int j=0 ; j < w+2 ; j++ ){
      if( i == 0 || i == h+1 ){
        cout << huti.at(n);
        n++;
      }
      else if( j%(w+2) == 0 || j%(w+2) == (w+2)-1 ){
        cout << huti.at(n);
        n++;
      }
      else{
        cout << moji.at(m);
        m++;
      }
      if( j%(w+2) == (w+2)-1 )  cout << endl;
    }
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
vector <long long int> v;
vector <double> vd;
 
vector <char> vc;
vector <string> vs;
map <string,int> sm;
map <int,int> mp;
map <char,int>cm;
set <int> st;
#define For(n) for(int i=0; i<n; i++)
//#define sort(v) sort(v.begin(),v.end());
#define vecprint(v){for(int i=0; i<v.size(); i++)cout << v[i];}
//int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
//long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
//long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
//int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
 
//int cnt =0;
 
void SieveOfEratosthenes(int n=20000000)
{
   // v.push_back(1);
 
//    bool prime[n+1];
//    memset(prime, true, sizeof(prime));
 
    vector <bool>prime(n+1,true);
 
    for (int p=2; p*p<=n; p++)
    {
 
        if (prime[p] == true)
        {
 
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
 
 
    for (int p=2; p<=n; p++)
       if (prime[p])
          mp[p]++;
}
 
 
//int mod(string num, int a)
//{
//    // Initialize result
//    int res = 0;
//
//    // One by one process all digits of 'num'
//    for (int i = 0; i < num.length(); i++)
//         res = (res*10 + (int)num[i] - '0') %a;
//
//    return res;
//}
 
//vector <int> arr(100,-1);
//
//int fib(int n)
//{
//    if(n<=1)return 1;
//
//    if(arr[n]==-1)
//    {
//        arr[n] = fib(n-1)+fib(n-2);
//    }
//    //else return arr[n];
//
//   return arr[n];
//}
 
 
//int arr[1050][1050];
//
//int mx=0;
//int LCS(string s, string p)
//{
//    for(int i=1; i<=s.size(); i++)
//    {
//        for(int j=1; j<=p.size(); j++)
//        {
//
//            if(s[i-1]==p[j-1])
//                arr[i][j]=1+arr[i-1][j-1];
//            else
//                arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
//
//        }
//    }
//    return arr[s.size()][p.size()];
//}
//
//
//void primeFactors(long double n)
//{
//
//    while(fmod(n, 2)==0)
//    {
//        x++;
//        n /= 2;
//    }
//    h+=x;
//    x=0;
//
//    for(int i=3; i<=sqrt(n); i+=2)
//    {
//
//        while(fmod(n, i)==0)
//        {
//            x++;
//            n /= i;
//        }
//        h+=x;
//        x=0;
//
//    }
//
//    if(n>2){
//        h++;
//    }
//
//}
 
int main()
{

    long long int a,b=0,c=0,n;
    
    
    string s,p;
    
    cin >> a >> s >> p;
    
  //  s+=p;
    
    for(int i=0; i<a*2; i++)
    {
        
       if(i%2==0)
       {
           cout << s[b];
           b++;
       }
        else
        {
            cout << p[c];
            c++;
        }
        
        
        
       
    }
    
    
    cout << endl;
    
  
    return 0;
}
 


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

#define INF 200000000
#define FER 0.0000000001

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

pll ps[1 << 20];
ll w[40], v[40];

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

	int N;
	ll W;
	cin >> N >> W;
	
	for (int i = 0; i < N; i++)
	{
		cin >> v[i] >> w[i];
	}

	int n2 = N / 2;
	for (int i = 0; i < 1 << n2; i++)
	{
		ll sv = 0, sw = 0;
		for (int j = 0; j < n2; j++)
		{
			if (i >> j & 1)
			{
				sw += w[j];
				sv += v[j];
			}
		}
		ps[i] = make_pair(sw, sv);
	}

	sort(ps, ps + (1 << n2));
	int m = 1;
	for (int i = 1; i < 1 << n2; i++)
	{
		if (ps[m - 1].second < ps[i].second)
		{
			ps[m++] = ps[i];
		}
	}

	ll ans = 0;
	for (int i = 0; i < 1 << (N - n2); i++)
	{
		ll sw = 0, sv = 0;
		for (int j = 0; j < (N - n2); j++)
		{
			if (i >> j & 1)
			{
				sw += w[n2 + j];
				sv += v[n2 + j];
			}
		}
		if (sw <= W)
		{
			ll tv = (lower_bound(ps, ps + m, make_pair(W - sw, LLONG_MAX)) - 1)->second;
			ans = max(ans, sv + tv);
		}
	}

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


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

int main()
{
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++)
    {
        ans += (i % d == 0);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  priority_queue<int> q;
  rep(i,n){
    int a;
    cin >> a;
    q.emplace(a);
  }
  rep(i,m){
    int a = q.top(); q.pop();
    q.emplace(a/2);
  }
  ll ans = 0;
  while (!q.empty()){
    ans += q.top(); q.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
#include<stdio.h>
int main(void)
{
	char S[3];
	int count = 0;
	for (int i = 0; i < 3; i++) {
		scanf("%c", &S[i]);
		if (S[i] == 'o') {
			count++;
		}
	}
	printf("%d", 700 + 100 * count);
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

const int INF = 1e9;

struct Edge { int from, to, cost; };

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

    int N, M, P;
    cin >> N >> M >> P;
    vector<Edge> edges;
    REP(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        edges.push_back({A, B, P - C});
    }

    vector<int> dist(N+1, INF);
    dist[1] = 0;
    vector<bool> updated(N+1, false);
    REP(i, 2 * N) {
        for (Edge e : edges) {
            if (dist[e.from] != INF && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                if (i >= N - 1) updated[e.to] = true;
            }
            if (updated[e.from]) updated[e.to] = true;
        }
    }

    if (updated[N]) cout << -1 << endl;
    else cout << max(0, -dist[N]) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	double w,h,x,y;
	t = 1;
	while(t--) {
	 cin >> w >> h >> x >> y;
	 cout << fixed << setprecision(16);
	 cout << (w * h) / 2 << " " ;
	 if(w == 2 * x && h == 2 * y)
	  cout << 1 << endl;
	 else
	  cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math

N, H = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
zan = max(ab)
zan = zan[0]
ab.sort(reverse=True, key=lambda x:x[1])

bunnage = [ab[0][1]]
for i in range(1, N):
    bunnage.append(bunnage[i-1]+ab[i][1])

ans = []

for i in range(len(bunnage)):
    Z = max(H - bunnage[i], 0)
    zan_num = math.ceil(Z/zan)
    ans.append(i+1+zan_num)

print(min(ans))




Measured memory_bytes: 36580
#include<stdio.h>

int MAX(int a, int b){return a>b?a:b;}
int MIN(int a, int b){return a<b?a:b;}

int main(void){
    int n;
    scanf("%d", &n);
    int a[100002];
    for(int i=0; i<100002; i++){
        a[i] = 0;
    }
    int min = 100000;
    int max = -1;
    for(int i=0; i<n; i++){
        int tmp;
        scanf("%d", &tmp);
        a[tmp] += 1;
        min = MIN(min, tmp);
        max = MAX(max, tmp);
    }
  
    //printf("min:%d max:%d\n", min, max);
    int ans = -1;
    for(int i=min; i<=max; i++){
        if(i == 0){
            ans = a[i]+a[i+1];
        }else{
            ans = MAX(ans, a[i-1]+a[i]+a[i+1]);
        }
    }

    printf("%d\n", ans);

    return 0;
}

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

int x[9][9];
string S;
char T[10] = "ABCDEFGHI";
vector<int>X;

int main() {
	for (int i = 0; i < 9; i++) {
		if (i % 3 >= 1) {
			x[i][i - 1] = 1;
		}
		if (i % 3 <= 1) {
			x[i][i + 1] = 1;
		}
		if (i < 6) {
			x[i][i + 3] = 1;
		}
		if (i >= 3) {
			x[i][i - 3] = 1;
		}
	}
	for (int h = 0; h < 1000; h++) {
		cin >> S;
		X.clear();
		for (int i = 0; i < S.size(); i++) {
			for (int j = 0; j < 9; j++) {
				if (S[i] == T[j]) {
					X.push_back(j);
				}
			}
		}
		bool ok = true;
		for (int i = 0; i < X.size() - 1; i++) {
			if (x[X[i]][X[i + 1]] == 0) {
				ok = false;
			}
		}
		if (ok == true) {
			cout << S << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>

int main(void){

    int W,H,x,y,r;
    scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);

    if(x>=r && x<=W-r && y>=r && y<=H-r){
     printf("Yes\n");
    } else {
     printf("No\n");   
}
    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    sort(begin(A), end(A), greater<int>());
    int F1 = A.back(); A.pop_back();
    int F2 = A.back(); A.pop_back();
    while (F1 != 1) {
        F2 = F2 % F1;
        if (F2 == 0) {
            if (A.empty()) break;
            F2 = A.back(), A.pop_back();
            continue;
        }
        if (F1 > F2) swap(F1, F2);
    }
    cout << F1 << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//?¨??????\???????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		//??????????????????????????´??°?????¨????????????????????????
		int x = sc.nextInt();
		int answer = x * x * x;
		System.out.println(answer);
	}
}

Measured memory_bytes: 26020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod=1e9+7;
const int N=2e5+100;
int a[N];
map<string,int> mp;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>

int main()
{
  int i,n,q,A[10000+1],key,count=0,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);

    j=0;
    A[n] = key;
    while(A[j] != key && j<n){
      j++;
    }
    if(j == n);
    else count++;
  }

    printf("%d\n",count);

    return 0;
  }

    
  
  



Measured memory_bytes: 2108
N, M = map(int, input().split())
S = input()
T = input()

"""
6 4
GCD=2
LCM=12
a.b.c.d.e.f.
a..b..c..d..
"""
def GCD(a, b):
    if a < b:
        a, b = b, a
    while b > 0:
        a, b = b, a%b
    return a

def LCM(a, b):
    return a * b // GCD(a, b)
  
X = LCM(N, M)
w = 0
while w < N*M:
  if S[w//M] == T[w//N]:
    w += X
    continue
  else:
    print(-1)
    exit(0)

print(X)

Measured memory_bytes: 3316
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main(){
  int H[10000], W[10000], i, j, k, end;
  for(k=0; k<10000; k++){
    cin>>H[k]>>W[k];
    if(H[k]==0 && W[k]==0){
      end = k;
      break;
    }
  }
  for(k=0; k<end; k++){
    for(i=0; i<H[k]; i++) {
      for(j=0; j<W[k]; j++){
	if ((i+j)%2 == 0) cout<<"#";
	else cout<<".";
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3092
/*
Sharif Hasan - CSE, PUST
Apr 24, 2020 02: 14 PM
*/
#include<bits/stdc++.h>
#include "string.h"
#define br cout<<"\n"
#define what(x) cout<<"in here var= "<<x<<"\n";

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
using namespace std;
double clockAngle(double a,double b){
    double f=fabs(b*6-(a*30+b/2));
    if(f>180) f=360-f;
    return  f*acos(-1)/180.0;
}
int main(){
    int a,b;
    cin>>a>>b;
    map <int,bool> mk;
    FOR(i,b){
        int k;cin>>k;mk[k]=1;
    }
    int p=a;
    while (mk[p]==1){
        ++p;
    }
    int np=a;
    while (mk[np]==1){
        --np;
    }
    if(abs(a-p)>abs(a-np)){
        cout<<np<<endl;
    }else if(abs(a-np)>abs(a-p)){
        cout<<p<<endl;
    }else{
        cout<<min(np,p)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#!/usr/bin/python3

import math
#標準出力からの読み込み
input_1 = input()
a = int(input_1.split(" ")[0])
b = int(input_1.split(" ")[1])
n = int(input_1.split(" ")[2])


#判定ロジック
score = math.floor(a/b*min(b-1, n))
print(score)

Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;

vector<int> v(105);
ll dp[105][100010]; //dp[child #][number of candies left] = possibilities up to this point

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    int n, k;
    cin >> n >> k;
    for(int i=1; i<=n; i++)
        cin >> v[i];
    dp[0][0]=1;
    for(int i=1; i<=n; i++)
    {
        dp[i][0] = 1;
        for(int j=1; j<=100000; j++)
        {
            if(j>v[i]) dp[i][j] = (dp[i][j-1]+dp[i-1][j]-dp[i-1][j-v[i]-1]+11*mod)%mod;
            else dp[i][j] = (dp[i][j-1]+dp[i-1][j])%mod;
        }
    }
    cout << dp[n][k];
}


Measured memory_bytes: 79488
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)


void solve() {

}

int main() {
    int A, B, X;
    cin >> A >> B >> X;
    if (A + B < X || A > X) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
int a[4];
int main()
{
    ft
    int t,i,j,n,m,l,r,x=0;
    for(i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    l=a[2]-a[1];
    x+=l;
    a[0]+=l;
    l=a[2]-a[0];
    if(l%2==0)
    {
        cout<<(x+(l/2))<<"\n";
    }
    else
    {
        x+=ceil(l*1.0/2);
        cout<<(x+1)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int[] answer = new int[n];
		for (int i = 0; i < n; i++) {
			int order = getInt(sc);
			answer[order - 1] = i + 1;
		}
		String line = "";
		for (int i = 0; i < n; i++) {
			if (i != 0) {
				System.out.print(" ");
			}
			System.out.print(answer[i]);
		}

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}
}


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

int addingCost(int input1 , int input2[] , int input3){
    int ans = 0 , n = input1 , k = input3;
    vector<int>v(n);
    for(int i = 0; i< n ;i++){
        v[i] = input2[i];
    }
    while(v.size() > 1){
        int maxSum = 1e9 + 7 , in = 0;
        for(int i = 0; i < n; i++){
            if(v[i] + v[i + 1] < maxSum){
                maxSum = v[i] + v[i + 1];
                in = i;
            }
        }
        ans += (v[in] + v[in + 1])*k;
        v.erase(v.begin() + in);
        v.erase(v.begin() + in);
        v.insert(v.begin() + in , maxSum);
    }
    return ans;
}

int main(){
    int x;
    cin>>x;
    if(x == 1){
        cout<<"0";
    }
    else cout<<"1";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

string to_string(string s){
  return '"' + s + '"';
}
string to_string(const char *s){
  return to_string((string)s);
}
string to_string(bool b){
  return (b ? "true" : "false");
}
template<class A, class B>
string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template<class A, class B, class C>
string to_string(tuple<A, B, C> p){
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template<class A, class B, class C, class D>
string to_string(tuple<A, B, C, D> p){
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
template<class A>
string to_string(A v){
  bool first = true;
  string res = "{";
  for(const auto &x : v){
    if(!first){
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out(){cerr << endl;}
template<class Head, class... Tail>
void debug_out(Head H, Tail... T){
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL//compile with -DLOCAL
#define debug(...) cerr << "LINE" << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,M;
  cin >> N >> M;
  dsu uf(N);
  rep(i,M){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    uf.merge(a,b);
  }

  vector<vector<int>> tmp = uf.groups();
  cout << sz(tmp) -1 << endl;

  return 0;
}

Measured memory_bytes: 8856
package main

import (
	"fmt"
)

type point struct {
	x int
	y int
	h int
}

func main() {
	var n int
	fmt.Scan(&n)
	ar := make([]point, n)
	for i := range ar {
		fmt.Scan(&ar[i].x, &ar[i].y, &ar[i].h)
	}
	for x := 0; x <= 100; x++ {
		for y := 0; y <= 100; y++ {
			h := 0
			for _, v := range ar {
				if v.h > 0 {
					h = v.h + abs(v.x-x) + abs(v.y-y)
				}
			}
			if h <= 0 {
				continue
			}
			isValid := true
			for _, v := range ar {
				if v.h != max(h-abs(v.x-x)-abs(v.y-y), 0) {
					isValid = false
					break
				}
			}
			if isValid {
				fmt.Printf("%d %d %d\n", x, y, h)
				return
			}
		}
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 512
#include<stdio.h>
    int main(void){
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    int min=a+b;
    if(min>b+c){
      min=b+c;
    }
    if(min>a+c){
      min=a+c;
    }
    printf("%d\n",min);
    return 0;
    }

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

#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define bug(x) cerr<<#x<<" is "<<x<<endl

using namespace std;

#define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"0\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 1e5+5;

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



main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n; cin>>n;
    vector<int> a(n);
    vector<int> mo(n);
    REP(i,n) cin>>a[i], mo[a[i]-1]=i;

    set<int> st; st.insert(-1); st.insert(n);
    ll re = 0;
    REP(i,n){
        int x = mo[i];
        auto po = st.lower_bound(x);
        int l = *prev(po), r = *po;
        re += (i+1)* (ll)(x-l) * (ll)(r-x);
        // bug(re);
        st.insert(x);
    }
    cout<<re<<endl;
} 

Measured memory_bytes: 12800
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
#define Zero_IQ                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int mod = 1e7 + 7;
int main() {
    Zero_IQ ll n, m;
    cin >> n >> m;
    vector<ll> v;
    for (int i = 0; i < n; i++) {
        ll q;
        cin >> q;
        v.push_back(q);
    }
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < n && m; i++) {
        v[i] = 0;
        m--;
    }
    ll summ = 0;
    for (int i = 0; i < n; i++) {
        summ += v[i];
    }
    cout << 1ll * (summ);

    return 0;
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    string s;
    cin >> s;
    ll a=0;
    rep(i,s.size()){
        a+=s[i]-'0';
    }
    if(a%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}











Measured memory_bytes: 3748
import Control.Applicative ((<$>))
import Data.List (sort, group)

solve (l, h)
  | l > h = l - h
  | l < h = l
  | otherwise = 0

main = do
  n <- read <$> getLine :: IO Int
  a <- words <$> getLine :: IO [String]
  let xs = group . sort $ fmap (read :: String -> Int) a
      ls = fmap length xs
      hs = fmap head xs
      zs = zip ls hs
  putStrLn . show . sum $ fmap solve zs


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,L;
string S;
ll mo=1000000007;
ll dp[5050][5050];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	L=S.size();
	
	dp[0][0]=1;
	
	FOR(i,N) {
		FOR(x,N+1) if(dp[i][x]) {
			(dp[i+1][x+1] += 2*dp[i][x])%=mo;
			(dp[i+1][max(0,x-1)] += dp[i][x])%=mo;
		}
	}
	
	ll ret=dp[N][L];
	FOR(i,L) ret=ret*(mo+1)/2%mo;
	
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 117120
#include<iostream>
#include<cmath>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;

struct Point{
	double x,y;
}; 

void korch(int d,Point p1,Point p2)
{
	if(d==0)return;
	
	Point s,t,u;
	double th=M_PI * 60.0/180.0;//将单位从度变成弧度
	s.x=(2*p1.x+p2.x)/3;
	s.y=(2*p1.y+p2.y)/3;
	t.x=(p1.x+2*p2.x)/3;
	t.y=(p1.y+2*p2.y)/3;
	u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
	u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
	 
	korch(d-1,p1,s);
	printf("%.8lf %.8lf\n",s.x,s.y);
	korch(d-1,s,u);
	printf("%.8lf %.8lf\n",u.x,u.y);
	korch(d-1,u,t);
	printf("%.8lf %.8lf\n",t.x,t.y);
	korch(d-1,t,p2);
}

int main()
{
	int n;
	scanf("%d",&n);
	Point p1,p2;
	p1.x=p1.y=0;
	p2.x=100;
	p2.y=0;
	printf("%.8lf %.8lf\n",p1.x,p1.y);
	korch(n,p1,p2);
	printf("%.8lf %.8lf\n",p2.x,p2.y);
	return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define oo 1000000007
using namespace std;
long long b,ans,k;
string a;
long long dp[10005][105][2];
vector<long long>num;
long long solve(long long idx, long long cnt, bool tight)
{
    if(idx==-1)
        return (cnt%k==0);
    if(dp[idx][cnt][tight]!=-1 && !tight)
    return dp[idx][cnt][tight];
    long long limit=(tight)?num[idx]:9;
    long long res=0;
    for(int i=0;i<=limit;i++)
    {
        long long newtight=(num[idx]==i)?tight:0;
        res=res+solve(idx-1,(cnt+i)%k,newtight);
    }
        dp[idx][cnt][tight]=res%oo;
        return res%oo;
}
long long khoitao(string a)
{
     memset(dp,-1,sizeof(dp));
     num.clear();
     for(int i=a.size()-1;i>=0;i--)
        num.push_back(a[i]-'0');
     return solve(num.size()-1,0,1);
}
main()
{
    cin>>a>>k;
    cout<<(khoitao(a)-1+oo)%oo;
}


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

int main() {
  string s; cin>>s;
  int n = s.size();
  int l=0;
  int r=n-1;
  int ans=0;
  while(l<r) {
    if(s[l]==s[r]) {
      l++;
      r--;
    } else if(s[r]=='x') {
      ans++;
      r--;
    } else if(s[l]=='x') {
      ans++;
      l++;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>
#include <set>

using namespace std;


int main() {

    int N, A, B;
    cin >> N >> A >> B;

    cout << min(N * A, B) << "\n";


    return 0;
}

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

int main() {

    int n;
    cin >> n;

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

    vector<int> l, r;
    rep(i, n) {
        if (i%2 == 0) r.push_back(a[i]);
        else l.push_back(a[i]);
    }

    if (n%2) {

        reverse(r.begin(), r.end());
        for (auto t : r) cout << t << ' ';
        for (auto t : l) cout << t << ' ';
        cout << endl;
        return 0;

    }

    reverse(l.begin(), l.end());
    for (auto t : l) cout << t << ' ';
    for (auto t : r) cout << t << ' ';
    cout << endl;

}


Measured memory_bytes: 4084
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var n = int.Parse(Console.ReadLine());
    var aho = Console.ReadLine().Split();
    var h = new List<int>();
    foreach(var a in aho){
      h.Add(int.Parse(a));
    }
    for(var i = n-2;i>=0;i--){
     if(h[i] > h[i+1]){
     	h[i] -=1; 
        if(h[i] > h[i+1]){
          Console.WriteLine("No");
          return;
        }
     }
    }
      Console.WriteLine("Yes");
  }
}

Measured memory_bytes: 27484
import numpy as np
from numba import njit

N = np.array([int(_) for _ in input()])


def solve(N):
    p, q = 0, 1
    for x in N:
        p, q = min(p + x, q + 10 - x), min(p + x + 1, q + 9 - x)
    print(p)


solve(N)


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

using namespace std;

#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

using ll = long long;

int main()
{
    int K, X;
    ll l, r;

    cin >> K >> X;

    l = MAX(X-K+1, -1000000);
    r = MIN(X+K-1,  1000000);

    for(ll i=l; i<=r; ++i) cout << i << " ";
    cout << endl;

    return 0;
}

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

int  main()
{
	int a,b;
	cin >> a >> b;
	if (a <= b+b) cout << 0;
	else cout << a - (b+b);

	return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 2e5+10;
int n,ans,las,f[2],nxt[3],v[2];

int main(){
	n=read();
	For(i,1,n+1){
		int x=i==n+1?0:read();
		v[0]=0,v[1]=x-las;
		if (v[0]<v[1]) swap(v[0],v[1]);
		nxt[0]=nxt[1]=1e9,nxt[2]=0;
		FOR(j,0,2) FOR(k,0,2) nxt[j+k]=min(nxt[j+k],max(0,v[k]+f[j]));
		int tmp=nxt[0]>x;
		las=x,ans+=tmp;
		FOR(j,0,2) f[j]=nxt[j+tmp];
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 3724
#!/usr/bin/env python3
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
if n % 2 == 0:
    print(2 * (sum(a[n // 2 :]) - sum(a[: n // 2])) - a[n // 2] + a[n // 2 - 1])
else:
    daishou = 2 * (sum(a[n // 2 :]) - sum(a[: n // 2])) - a[n // 2] - a[n // 2 + 1]
    shoudai = (
        2 * (sum(a[1 + n // 2 :]) - sum(a[: 1 + n // 2])) + a[n // 2] + a[n // 2 - 1]
    )
    print(max(daishou, shoudai))



Measured memory_bytes: 13316
A, B, C, X, Y = [int(elem) for elem in input().split(' ')]

pizza_num_dict = {'A': 0, 'B': 0}

price_sum = 0
if A >= 2 * C:
    pizza_num_dict['A'] += X
    pizza_num_dict['B'] += X
    price_sum += 2 * X * C
    if X >= Y:
        print(price_sum)
        exit(0)
    else:
        if B >= 2 * C:
            price_sum += 2 * (Y - X) * C
        else:
            price_sum += (Y - X) * B
        print(price_sum)
        exit(0)

elif B >= 2 * C:
    pizza_num_dict['A'] += Y
    pizza_num_dict['B'] += Y
    price_sum += 2 * Y * C
    if Y >= X:
        print(price_sum)
        exit(0)
    else:
        price_sum += (X - Y) * A
        print(price_sum)
        exit(0)

else:
    if 2 * C <= A + B:
        if X >= Y:
            price_sum = 2 * Y * C + (X - Y) * A
        else:
            price_sum = 2 * X * C + (Y - X) * B
    else:
        price_sum = X * A + Y * B
    print(price_sum)


Measured memory_bytes: 3064
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = readline().strip()

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

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9044
#include <bits/stdc++.h>
#define f first
#define s second
#define mk make_pair

using namespace std;

const int N = 1e5 + 5;

int h[N], dp[N];

int32_t main()
{
    ios::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n,k;
    cin >> n >> k;
    for(int i = 0;i < n; ++i)
    {
        cin >> h[i];
    }
    dp[0] = 0;
    for(int i = 1;i < n; ++i)
    {
        int t = 2 * 1e9;
        for(int j = i-1; j >= max(0, i - k); --j)
        {
            int x = abs(h[i] - h[j]) + dp[j];
            if(x <= t)
            {
                t = x;
            }
        }
        dp[i] += t;
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1024
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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

    cnt = 0
    for a in A:
        cnt += a&1
    if cnt&1:
        print("NO")
    else:
        print("YES")


if __name__ == '__main__':
    main()


Measured memory_bytes: 85392
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
    Mbak Seulgi Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    cin >> n;
    vector<pair<int,int> > v;
    for(i=1;i<=n;i++) {
        cin >> x >> y;
        v.push_back({x, y});
    }
    for(i=2;i<n;i++) {
        if(v[i].first == v[i].second && v[i-1].first == v[i-1].second && v[i-2].first == v[i-2].second) {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#define N 100

int main(){
  int n,i,j,k,u,v;
  int G[N+1][N+1];

  scanf("%d",&n);

  //初期化
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      G[i][j]=0;
    }
  }

  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      G[u][v]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",G[i][j]);
      if(j==n) printf("\n");
      else printf(" ");
    }
  }

  return 0;
  
}



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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

ll c[501], s[501], f[501];
int n;

ll dis(int start){
    ll hour = s[start] + c[start];
    for(int i = start+1; i < n; i++){
        ll j = 0ll;
        while(hour > s[i] + f[i]*j){
            j++;
        }
        hour = s[i] + f[i]*j + c[i];
    }
    return hour;
}

void solve()
{
    cin >> n;
    for(int i = 1; i < n; i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i = 1; i < n; i++) cout << dis(i) << "\n";
    cout << 0 << "\n";

}

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

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

int main(){
    do{
        long long w, h;
        cin >> w >> h;
        if(w == 0)break;
        
        vector<vector<int>> c(h + 2, vector<int>(w + 2));
        for(int i = 0; i < h; ++i){
            for(int j = 0; j < w; ++j){
                cin >> c[i + 1][j + 1];
            }
        }
        
        queue<pair<int, int>> q;
        constexpr int move[9] = {0, 1, 1, -1, 0, -1, -1, 1};
        
        long long ans = 0;
        
        for(int i = 1; i <= h; ++i){
            for(int j = 1; j <= w; ++j){
                if(c[i][j]){
                    ++ans;
                    
                    q.emplace(i, j);
                    c[i][j] = false;
                    
                    while(!q.empty()){
                        auto t = q.front();
                        q.pop();
                        for(int i = 0; i < 8; ++i){
                            int y = t.first + move[i];
                            int x = t.second + move[i + 1];
                            if(c[y][x]){
                                q.emplace(y, x);
                                c[y][x] = false;
                            }
                        }
                    }
                    
                }
            }
        }
        
        cout << ans << endl;
        
    }while(true);
    
    return 0;
}


Measured memory_bytes: 3056
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<string.h>

using namespace std;
const int INF =1001001001;
#define rep(i,n) for(int i=0;i<n;i++)
int N,T,S;//夜店の数、終わる時間、花火の時間
int A[3002],B[3002];//楽しさ、時間
int dp[3002][3002];//たて…夜店iまでを遊ぶ(1-N)Nマス　横…時間jまであそぶ(0-T)T+1マス

int main(){
	scanf("%d %d %d",&N,&T,&S);
	rep(i,N)scanf("%d %d",&A[i],&B[i]);
	//花火前
	rep(i,N){
		rep(j,S+1){
			if(i==0){if(j>=B[i])dp[i][j]=A[i];}
			else{
				if(j-B[i]>-1)dp[i][j]=max(dp[i-1][j-B[i]]+A[i],dp[i-1][j]);
				else dp[i][j]=dp[i-1][j];
			}
		}
	}
	//花火後
	for(int i=N;i>-1;i--){
		for(int j=T;j>=S;j--){
			if(i==N-1){if(T-j>=B[i])dp[i][j+1]=A[i];}
			else{
				if(j+B[i]<T+1)dp[i][j+1]=max(dp[i+1][j+B[i]+1]+A[i],dp[i+1][j+1]);
				else dp[i][j+1]=dp[i+1][j+1];
			}
		}
	}
	//精算
	int ans=0;
	rep(i,N){
		if(i-1>-1&&i<N)ans=max(dp[i-1][S]+dp[i][S+1],ans);
		else if(i-1==-1)ans=max(dp[i][S+1],ans);
		else if(i==N-1)ans=max(dp[i-1][S],ans);
	}
	printf("%d\n",ans);
}

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

int main() {
  int N,M;
  cin>>N>>M;
  priority_queue<int> A;
  rep(i,N) {
    int x;
    cin>>x;
    A.push(x);
  }
  long long ans=0;
  rep(i,M){//以下の操作をM枚の割引券がなくなるまで繰り返す
    int y = A.top();//最大の要素を取得
    A.pop();//最大の要素を消去
    y /= 2;//先程取り出した最大の要素を半分にする
    A.push(y);//半分にした要素を戻す
  }
  //最後に、Aの中の要素をすべて足す
  while(A.size()!=0){
    ans += A.top();
    A.pop();
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  int n;
  while(cin>>n,n){
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int res=1e9;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	res=min(res,abs(a[i]-a[j]));
      }
    }
    cout<<res<<endl;
  }
  return 0;

}

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

int main(){
  int A,B,C,N,n,i;
  cin >> A >> B >> C >> N;
  if(A <= N){
    if(A+B >= N){
    cout << A << endl;
    }
    else if(A+B < N){
      if(A+B+C >= N){
        n=A+B+C-N;
        i=C-n;
        cout << A-i << endl;
      }
      else{
        cout << A-C << endl;
      }
    }
  }
  else if(A > N){
    cout << N << endl;
  }
}

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

using namespace std;

int main() {
  int n,a; cin >> n;
  int cnt=0,tmp=0;
  for(int i=0;i<n;++i){
    cin >> a;
    if(a==1) tmp++,cnt=max(cnt,tmp);
    else tmp=0;
  }
  cout << cnt+1 << endl;
  
  return 0;
}



Measured memory_bytes: 3084
'use strict'
// inputに入力データ全体が入る
function Main(input) {
  let inAry = input.split(" ");
  inAry = inAry.map( (value) => {
    return parseInt(value);
  })

  let a = inAry[0];
  let b = inAry[1];
  let c = inAry[2];

  let kai = b / a;
  kai = Math.floor(kai);
  if(kai >= c){
      console.log(c)
    }else{

      if(kai < 1){
        kai = 0;
      }
      console.log(kai);
    }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

long long int gcd(long long int a, long long int b) {
	long long int r;
	while (b!=0) {
		r = a % b;
			a = b;
			b = r;
	}
	return a;
}

int main(void)
{
    long long int a,b,g;
	scanf("%lld %lld", &a, &b);
	g = gcd(a, b);

	printf("%lld\n", (a * b) / g);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 100001; //check the limits, dummy

ll p(ll n, ll x) {
    ll ans = 1, cur = n;
    while(x) {
        if(x & 1) ans = (cur * ans) % MOD;
        cur = (cur * cur) % MOD;
        x >>= 1;
    }
    return ans;
}

struct Res {
    ll g, x, y;
};

Res modinv(ll a, ll b) {
    if(b == 0) return {a, 1, 0};
    Res prev = modinv(b, a % b);
    return {prev.g, prev.y, prev.x - a / b * prev.y};
}

ll ncr(ll n, ll r) {
    ll ans = 1, den = 1;
    for(int i = n; i > n - r; i--) ans = (ans * i) % MOD;
    for(int i = 2; i <= r; i++) den = (den * i) % MOD;
    ll inv = (modinv(den, MOD).x + MOD) % MOD;
    return (ans * inv) % MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n, a, b;
    cin >> n >> a >> b;
    ll x = p(2, n);
    ll y = ncr(n, a);
    ll z = ncr(n, b);
    cout << (x - y - z - 1 + 3*MOD) % MOD << endl; 
}

Measured memory_bytes: 256