akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	static long mod = 1000000007;

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

		int N = sc.nextInt();
		int zoro = 0;
		String ans = "No";

		for(int i=0; i<N; i++) {
			if(sc.nextInt() == sc.nextInt()) {
				zoro++;
				if(zoro == 3) {
					ans = "Yes";
				}
			} else {
				zoro = 0;
			}
		}

		System.out.println(ans);

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


Measured memory_bytes: 36028
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main() {
	string t;
	cin >> t;
	rep(i, t.size()) {
		if (t[i] == '?') {
			t[i] = 'D';
		}
	}
	cout << t << endl;
	return 0;
}



Measured memory_bytes: 3716
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>(b);i--)
using namespace std;

int main(void) {
	string s,t;
	char a;
	cin >> s;
	FOR(i, 0, s.size()) {
		if (i % 2 == 0) {
			a = s[i];
			t += a;
		}
	}

	cout << t << endl;


	return 0;
}

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

#define DEBUG_MSG_off

string S;

int main() {
  cin >> S;

#if 1
  string pre = "";
  for (int i=0;i<S.size();++i){
    if (pre==""){
    } else {
      if (pre[0]==S[i]) {
        cout << "Bad\n";
        return 0;
      }
    }
#ifdef DEBUG_MSG
    cerr << "S=" << S << ",S[i]=" << S[i] << ",pre=" << pre <<"\n";
#endif
    pre = S[i];
  }
  cout << "Good\n";
#endif

#if 0
  int pre = -1;
  while(S>=0) {
    int a=S%10;
    cerr << S << ",a=" << a << ",pre=" << pre <<"\n";
    if (pre==-1) {
    } else {
      if (pre==a) {
        cout << "Bad\n";
        return 0;
      }
    }
    pre = a;
    S/=10;
  }
  cout << "Good\n";
#endif

#ifdef DEBUG_MSG
  cerr << S << "\n";
#endif
  return 0;
}

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


int s[501][501];
int calc(int y0,int x0,int y1,int x1){
	int a,b,c,d;
	a=s[y0-1][x0-1];
	b=s[y0-1][x1];
	c=s[y1][x0-1];
	d=s[y1][x1];
	return d-c-b+a;
}

int main(){
	int h,w,n;
	memset(s,0,sizeof(s));
	while(cin>>h>>w,h||w){
		for(int y=1;y<=h;y++){
			for(int x=1;x<=w;x++){
				char ch;
				cin>>ch;
				s[y][x]=ch=='*';
				s[y][x]+=s[y-1][x]+s[y][x-1]-s[y-1][x-1];
			}
		}
		int ans=0;
		for(int y=1;y<=h;y++){
			for(int x=1;x<=w;x++){
				int k=y;
				for(int i=w;i>=x;i--){
					while(k<h && calc(y,x,k+1,i)==0){
						k++;
					}
					if(ans<(i-x+1)*(k-y+1) && calc(y,x,k,i)==0)
						ans=(i-x+1)*(k-y+1);
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define F first
#define S second

const int MAXN = 1e5 + 10;

int n, h, c1[MAXN], c0[MAXN];
bool vis[MAXN];
vector<int> adj[MAXN];
bool found = 0;

void dfs(int v){
	vis[v] = 1;
	if (c0[v] ^ c1[v]) found = 1;
	if ((v > h && c1[v] > c0[v]) || (v <= h && c0[v] > c1[v])){
		cout << "NO\n";
		exit(0);
	}
	for (int u:adj[v])
		if (!vis[u])
			dfs(u);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> h;
	while (n--){
		int a, b, c, d; cin >> a >> b >> c >> d;
		int u = -1, v = -1;
		if (c == 0)
			u = a;
		else
			u = h+c;
		if (d)
			v = d;
		else
			v = h+b;
		adj[u].push_back(v);
		c1[u]++;
		adj[v].push_back(u);
		c0[v]++;
	}
	for (int i = 1; i <= h+h; i++)
		if (!vis[i] && adj[i].size()){
			found = 0;
			dfs(i);
			if (!found){
				cout << "NO\n";
				return 0;
			}
		}
	cout << "YES\n";
	return 0;
}


Measured memory_bytes: 4096
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

a,b,n = mp()
x = max(n,min(n,b-1))
ans1 = a*x//b - a*(x//b)

x = min(n,b-1)
ans2 = a*x//b - a*(x//b)
print(max(ans1,ans2))

Measured memory_bytes: 61824
a = raw_input()

b = []
for i in range(30):
	b.append(0)

for i in a:
	b[ord(i) - ord("a")] += 1

c = 0
for i in b:
	if i % 2 != 0:
		c = 1
		break
if c == 0:
	print "Yes"
else:
	print "No"

Measured memory_bytes: 2568
# include <bits/stdc++.h>
using namespace std; 
int main(){
  int n,temp,v;
  cin>>n;
  v=0;
  temp=floor(log10(n))+1;
  //cout<<temp;
  while(temp--){
    if(n%10==7){
      v=1;
      break; 
    }
    n=n/10;
  }
  if(v==1){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 3900
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }
const ll MOD = 1000 * 1000 * 1000 + 7 ;
inline void chadd(ll &a, const ll b) { a = (a + b) % MOD;}
inline ll add(const ll a, const ll b){ return (a + b) %  MOD;}
inline void chsub(ll &a, const ll b) { a = (a - b + MOD) % MOD;}
inline ll sub(const ll a, const ll b){ return (a - b + MOD) % MOD; }
inline void chmul(ll &a, const ll b) { a = (a * b) %  MOD;}
inline ll mul(const ll a, const ll b){ return (a * b) %  MOD;}
const int MOD_TABLE_SIZE = 2000000 + 10;
ll inv[MOD_TABLE_SIZE];
ll fac[MOD_TABLE_SIZE];
ll facinv[MOD_TABLE_SIZE];

void mod_table_init() {
  inv[1] = 1;
  for(int i = 2; i < MOD_TABLE_SIZE; i++) {
    inv[i] = MOD - (MOD / i) * inv[(int)MOD % i] % MOD;
  }
  fac[0] = facinv[0] = 1;
  for(int i = 1; i < MOD_TABLE_SIZE; i++) {
    fac[i] = (fac[i-1] * (ll)i) % MOD;
    facinv[i] = (facinv[i-1] * inv[i]) % MOD;
  }
}

inline ll P(int a, int b) {
  return fac[a] *  facinv[a-b] % MOD;
}

inline ll C(int a, int b) {
  return (fac[a] * facinv[b] % MOD) * facinv[a-b] % MOD;
}

inline ll H(int a, int b) {
  return C(a+b-1,b);
}

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  mod_table_init();
  int N, M; cin>>N>>M;
  ll K; cin>>K;
  ll ans = 0;
  for(int i = 1; i < N; i++) {
    ll tmp = N-i;
    chmul(tmp, i);
    chmul(tmp, M);
    chmul(tmp, M);
    chadd(ans, tmp);
  }
  //  cout << ans << endl;
  for(int i = 1; i < M; i++) {
    ll tmp = M-i;
    chmul(tmp, i);
    chmul(tmp, N);
    chmul(tmp, N);
    chadd(ans, tmp);
  }
  //  cout << ans << endl;
  ll comb = C(N*M-2, K-2);
  //  cout << ans << "," << comb << endl;
  chmul(ans, comb);
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  int n, x, y;
  cin >> n >> x >> y;
  cout << min(x, y) << " " << max(0, x + y - n) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
	int  N,L[10],max=0,sum=0;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>L[i];
		sum+=L[i];
		if(max<L[i]){
			max=L[i];
		}
	}

	if(sum>max*2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	 int a,b,c;
	 scanf("%d %d %d",&a,&b,&c);
	 if(a+b==c){
		 printf("Yes\n");
	 }
	 else if(b+c==a){
		 printf("Yes\n");
	 }
	 else if(a+c==b){
		 printf("Yes\n");
	 }
	 else{
		 printf("No\n");
	 }
	 return 0;
	 
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
int N;
int A_count(int x){
	if (x == 0){
		return 1;
	}else if (x == 1){
		return 1;
	}else if (x == 2){
		return 2;
	}else{
		return (A_count(x-1) + A_count(x-2) + A_count(x-3));
	}
}

int main() {
	while (cin >> N && N){
		cout << (((A_count(N)+9)/10)+364)/365 << endl;		
	}
	return 0;
}

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

int main() {
  int N; cin >> N;
  double make;
  vector<double> rare(N);
  
  for (int i = 0; i < N; i++) {
    cin >> rare.at(i);
  }
  for (int i = 0; i < N - 1; i++) {
    sort(rare.begin(), rare.end());
    make = (double)(rare.at(0) + rare.at(1)) / 2;
    rare.push_back(make);
    reverse(rare.begin(), rare.end());
    rare.pop_back();
    rare.pop_back();
  }
  
  cout << rare.at(0) << endl;
}

    
  

Measured memory_bytes: 256
#include <stdio.h>

int A[200000];

int main(void){
    int n; scanf("%d", &n);
    for(int i = 0; i < n; ++i) scanf("%d", A + i);
    int a = 0; for(int i = 0; i < n; ++i) a ^= A[i];
    for(int i = 0; i < n; ++i) printf("%d\n", a ^ A[i]);
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
using G = vector<vector<bool>>;
const long long INF = 1LL << 60;


ll h ,w;

int main() {
  long double a,b,c;
  cin >> a >> b >> c;
  long double eps = 1.0E-14;
  if(sqrt(a) + sqrt(b) + eps< sqrt(c)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main(void){
    int h,w;
    int i,j;
    while(1){
        cin>>h>>w;
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    if((b*10+c)%4==0) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
int main(){
    int n;cin >> n;
    vector<int> a(n+1);
    vector<int> b(n+1);
    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=n; i>=1; i--){
        int sum=0;
        for(int j=i+i; j<=n; j+=i){
            sum^=b[j];
        }
        b[i]=sum^a[i];
    }
    vector<int> ans;
    for(int i=1; i<=n; i++){
        if(b[i]) ans.push_back(i);
    }
    cout << ans.size() << endl;
    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3064
#include<stdio.h>

int month(int x){
   if(1<=x && x<=12)
      return 1;
   else
      return 0;
}

int main(){
   int s;
   scanf("%d",&s);
   /*aは上二桁、bは下二桁*/
   int a,b;
   a = s/100;
   b = s%100;
   if(month(a) && month(b))
      printf("AMBIGUOUS");
   else if(month(a) && month(b)==0)
      printf("MMYY");
   else if(month(a)==0 && month(b))
      printf("YYMM");
   else
      printf("NA");
   printf("\n");
   return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll dp[201010][2][2];
int N;
ll A[201010];

int main()
{
    cin >> N;
    repe(i, 1, N)
    {
        cin >> A[i];
    }

    /*
    if (N % 2 == 0) {
        ll sum1 = 0;
        ll sum2 = 0;
        repe(i, 1, N / 2)
        {
            sum1 += A[2 * i];
            sum2 += A[2 * i - 1];
        }
        cout << max(sum1, sum2) << endl;
        return 0;
    }
    */

    dp[1][1][1] = A[1];
    dp[2][1][0] = dp[1][1][1];
    dp[2][1][1] = A[2];
    dp[3][0][0] = max(dp[2][1][0], dp[2][1][1]);

    repe(i, 3, N)
    {
        if (i % 2 == 0) {
            dp[i][0][0] = max(dp[i - 1][0][0], dp[i - 1][0][1]);
            dp[i][1][0] = dp[i - 1][1][1];
            dp[i][1][1] = dp[i - 1][0][0] + A[i];
        } else {
            dp[i][0][0] = max(dp[i - 1][1][0], dp[i - 1][1][1]);
            dp[i][0][1] = dp[i - 1][0][0] + A[i];
            dp[i][1][0] = 0;
            dp[i][1][1] = dp[i - 1][1][0] + A[i];
        }
    }

    if (N % 2 == 0) {
        cout << max(dp[N][1][0], dp[N][1][1]) << endl;
    } else {
        cout << max(dp[N][0][0], dp[N][0][1]) << endl;
    }
}

Measured memory_bytes: 11440
#include <stdio.h>
char m[10][10];
int main()
{
  char c;
  int i,j;
  while((scanf("%c",&c))!= EOF){
    m[0][0] = c - '0';
    for(i=1;i<10;i++){
      scanf("%c",&c);
      m[0][i] = c - '0';
    }
    scanf("\n");
    for(i=1;i<10;i++){
      for(j=0;j<10-i;j++){
	m[i][j] = (m[i-1][j] + m[i-1][j+1]) % 10;
      }
    }
    printf("%d\n",m[9][0]);
  }
  return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	
	ll a, b, c;
	cin >> a >> b >> c;

	if (c - a - b<0) {
		cen;
		return 0;
	}

	if (4*a*b<(c-a-b)* (c - a - b)) {
		cey;
	}
	else {
		cen;
	}


    return 0;
}



Measured memory_bytes: 256
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIT = lambda: tuple(MI())
MIS = lambda: input().split()


def main():
    N = II()
    sp = [None] * N
    for i in range(N):
        s, p = MIS()
        sp[i] = (s, -int(p))
    for k in sorted(range(N), key = lambda i: sp[i]):
        print(k + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5644
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int target = Integer.parseInt(sc.next());
        int[] base = new int[m];
        for (int i = 0; i < m; i++) {
            base[i] = Integer.parseInt(sc.next());
        }
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += Integer.parseInt(sc.next()) * base[j];
            }
            if (sum + target > 0) cnt++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    
    int v = 0;
    int max = 0;
    for (int i = 0; i < N; i++) {
      if (S.charAt(i) == 'I') {
        v++;
      } else {
        v--;
      }
      max = Math.max(max, v);
    }
 
    System.out.println(max);
  }
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;

// int gcd(int x, int y)
// {
//     int t;
//     while (y != 0)
//     {
//         t = x % y;
//         x = y;
//         y = t;
//     }
//     return x;
// }

int gcd(int x, int y) {
  if (x < y) {
    swap(x, y);
  }
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}

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

  int x, y;
  cin >> x >> y;

  cout << gcd(x, y) << "\n";

  return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N,H,W;
    cin >> N >> H >> W;
    ll ans = 0;
    rep(i,N){
      ll A,B;
      cin >> A >> B;
      if(A >= H && B >= W) ans++;
    }
    print(ans);
}

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

int main() {
    int x,a,b; cin >> x >> a >> b;
    int A = abs(x-a);
    int B = abs(x-b);
    if(A > B){
        cout << "B" << endl;
    }else{
        cout << "A" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> i_i;
struct edge { int v, w; };
 
ll INF = LLONG_MAX / 2;
 
int dy[] = {0, -1, 0, 1};
int dx[] = {-1, 0, 1, 0};
 
int main() {
    int H, W; cin >> W >> H;
    vector<string> a(H);
    for (int y = 0; y < H; y++)
        cin >> a[y];
    int ys, xs, yg, xg;
    for (int y = 0; y < H; y++)
        for (int x = 0; x < W; x++) {
            if (a[y][x] == 's') {
                a[y][x] = '.';
                ys = y;
                xs = x;
            }
            if (a[y][x] == 'g') {
                yg = y;
                xg = x;
            }
        }
    vector<vector<ll> > dg(H, vector<ll>(W, INF));
    queue<i_i> q;
    dg[yg][xg] = 0;
    q.push(i_i(yg, xg));
    while (q.size()) {
        i_i p = q.front(); q.pop();
        int y = p.first, x = p.second;
        for (int k = 0; k < 4; k++) {
            int _y = y + dy[k], _x = x + dx[k];
            if (a[_y][_x] == '.' && dg[_y][_x] > dg[y][x] + 1) {
                dg[_y][_x] = dg[y][x] + 1;
                q.push(i_i(_y, _x));
            }
        }
    }
    vector<vector<ll> > ds(H, vector<ll>(W, INF));
    for (int y = 0; y < H; y++)
        for (int x = 0; x < W; x++)
            if (a[y][x] == '*') {
                ds[y][x] = 0;
                q.push(i_i(y, x));
            }
    while (q.size()) {
        i_i p = q.front(); q.pop();
        int y = p.first, x = p.second;
        for (int k = 0; k < 4; k++) {
            int _y = y + dy[k], _x = x + dx[k];
            if (a[_y][_x] == '.' && ds[_y][_x] > ds[y][x] + 1) {
                ds[_y][_x] = ds[y][x] + 1;
                q.push(i_i(_y, _x));
            }
        }
    }
    long double lb = 0, ub = 1e15;
    for (int t = 0; t < 100; t++) {
        long double mid = (lb + ub) / 2;
        int k = 0;
        long double sum = 0;
        for (int y = 0; y < H; y++)
            for (int x = 0; x < W; x++)
                if (a[y][x] == '.') {
                    k++;
                    sum += min((long double)dg[y][x], ds[y][x] + mid);
                }
        if (sum / k > mid) lb = mid;
        else ub = mid;
    }
	double ans = min((long double)dg[ys][xs], ds[ys][xs] + lb);
    printf("%.15f\n", ans);
}

Measured memory_bytes: 7424
X,N=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
if X in p:
  for i in range(1,100):
    if not X-i in p:
      print(X-i)
      break
    if not X+i in p:
      print(X+i)
      break
else:
  print(X)



Measured memory_bytes: 9196
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}


int32_t main()
{
    IOS
    
        
 
     int n;
     cin>>n;
     double a[n];
     for(int i=0;i<n;++i)
        cin>>a[i];
    double dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[1][1]=a[0];
    dp[1][0]=1-a[0];
    for(int i=2;i<=n;++i)
    {
        for(int j=0;j<=n;++j)
        {
            if(j>i)
                break;
            if(j==0)
            {
                dp[i][j]=dp[i-1][j]*(1-a[i-1]);
                continue;
            }
            dp[i][j]=dp[i-1][j-1]*a[i-1]+dp[i-1][j]*(1-a[i-1]);
        }
    }
    double ans=0;
    for(int i=(n+1)/2;i<=n;++i)
        ans+=dp[n][i];

    printf("%0.10lf",ans);    
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,i,x,a[500010],ans,m;
int main(){
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%lld",&x);
	 ans+=x;
}
	if(ans>n)puts("-1");
	 else printf("%lld",n-ans);
}

Measured memory_bytes: 3840
from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split(' '))
ss, cc = 0, {0: 1}
rs = 0
for k in a:
  ss += k
  cc[ss] = cc.get(ss, 0) + 1
  rs += cc[ss] - 1

print rs



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

INF = 10**7
dp = [INF]*2**N
dp[0] = 0

for i in range(M):
    a, b = map(int, input().split())
    d = sum((1<< (i - 1)) for i in  map(int, input().split()))  
    for j in range(2**N):
        if dp[j] == INF:
            continue
        jord = j | d
        dp[jord] = min(dp[j] + a, dp[jord])
        
if dp[- 1] == INF:
    print(- 1)
else:
    print(dp[- 1])

Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
using namespace std;
long long cnt[1000];
char str[200100];
int main(){
//	freopen("a.in","r",stdin);
	scanf("%s",str+1);
	long long n=strlen(str+1);
	for(int i=1;i<=n;i++)
		cnt[str[i]-'a']++;
	long long ans=n*(n-1)/2;
	for(int i=0;i<26;i++)
		ans=ans-cnt[i]*(cnt[i]-1)/2;
	ans++;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void OUT(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void OUT(T t,Ts... ts){cout<<t<<" ";OUT(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int A,B,P,Q,R;
	cin>>A>>B>>P>>Q>>R;
	double ans = P*B-Q*(B-A);
	printf("%.20lf\n",B+ans/(R+Q));
}


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

struct input
{
	int c, t;
} inputs[1000];

bool compare (input a, input b)
{
	if (a.t == b.t)
	{
		return a.c < b.c;
	}
	return a.t < b.t;
}

int main()
{
	int N, T; cin >> N >> T;
	int c, t;
	for (int i = 0; i < N; i++)
	{
		cin >> c >> t;
		inputs[i] = input{c, t};
	}
	
	sort(inputs, inputs + N, compare);
	
	if (inputs[0].t > T)
	{
		cout << "TLE" << endl;
	}
	else
	{
		int mincost = 1001;
		int i = 0;
		while (inputs[i].t <= T && i < N)
		{
			mincost = min(mincost, inputs[i].c);
			i++;
		}
		cout << mincost << endl;
	}
	
	return 0;
}

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

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

	vector<int> diff;
	diff.push_back(abs(v[0]));
	for(int i = 0; i < n-1; i++) {
	   diff.push_back(abs(v[i+1]-v[i]));
	}
	diff.push_back(abs(v[n-1]));

	int sum = 0;
	for(int i = 0; i < diff.size(); i++) {
		sum+=diff[i];
	}

	for(int i = 0; i < n; i++) {
		int new_diff = 0;
		int ers = 0;
		ers = diff[i]+diff[i+1];
		if(i == 0) {
			new_diff = abs(v[i+1]);
		}
		else if(i == n-1) {
			new_diff = abs(v[i-1]);
		}
		else {
			new_diff = abs(v[i-1]-v[i+1]);
		}
		cout << sum - ers + new_diff << endl;
	}

	return 0;
}
		
	
		

Measured memory_bytes: 2168
#include<cstdio>
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
	int m[10];
	rep(i, 10)cin >> m[i];
	sort(m, m + 10);
	for (int i = 9; i >= 7; i--) {
		printf("%d\n", m[i]);
	}
	return 0;
}

Measured memory_bytes: 3196
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
int dp[1<<21];
int cnt[21][100010];
int ccnt[21];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll a,b,c;cin>>a>>b>>c;
    ll ans=0;
    while(a%2==0&&b%2==0&&c%2==0){
        ll bb=a/2+c/2;
        ll aa=b/2+c/2;
        ll cc=a/2+b/2;
        ans++;
        a=aa;b=bb;c=cc;
        if(ans==1e6){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int n;
long long ans;
long long top[5];
int ncr[10][3]{
        {0,1,2},
        {0,1,3},
        {0,2,3},
        {1,2,3},
        {0,1,4},
        {0,2,4},
        {1,2,4},
        {0,3,4},
        {1,3,4},
        {2,3,4}
};
int main() {
  cin>>n;
  for(int i=0;i<n;i++){
      cin >> s;
      if(s[0]=='M')top[0]++;
      if(s[0]=='A')top[1]++;
      if(s[0]=='R')top[2]++;
      if(s[0]=='C')top[3]++;
      if(s[0]=='H')top[4]++;
  }
  for(int i=0;i<10;i++)ans+=top[ncr[i][0]]*top[ncr[i][1]]*top[ncr[i][2]];
  cout<<ans<<endl;
};

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int d, t, s;
  cin >> d >> t >> s;
  if (s * t < d) puts("No");
  else puts("Yes");
  return 0;
}

Measured memory_bytes: 3560
void main() {
	auto ip = readAs!(ulong[]), K = ip[0], A = ip[1], B = ip[2];
	ulong res, bis, yen;
	bis = 1;
	if(A+1 < B) {
		if(K < A+1) {
			writeln(1+K);
			return;
		}
		K -= A-1;
		//K.writeln;
		yen++;
		bis = A;
		while(K != 0) {
			auto m = bis / A;
			//writefln("K: %d, m: %d, bis: %d", K, m, bis);
			if(K < 2*m) {
				bis += (K / 2) * B;
				bis -= (K / 2) * A;
				if(K % 2) bis++;
				bis.writeln;
				return;
			}
			K-=2*m;
			bis -= A*m;
			bis += m * B;
		}
		bis.writeln;
		return;
	} else {
		writeln(1+K);
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

int main(){

	int n,m,s,c;
	cin >> n >> m;
	vector<int> v(n,-1);
	
	while(m--){
		cin >> s >> c;
		if(v[s-1] == -1 || v[s-1]==c) v[s-1] = c;
		else{cout << -1; return 0;}
	}
	if(n==1 && (v[0]==-1 || v[0]==0)) {cout << 0; return 0;}
	if(v[0]==0) {cout << -1; return 0;}
	if(v[0]==-1) v[0]=1;
	int result = 0;
	for(auto x:v) {result = result*10 + (x==-1 ? 0 : x);}
	cout << result;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]

d = {}
for s in S:
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
d = sorted(d.items(), key = lambda x:(-x[1],x[0]))

for di in d:
  if di[1] == d[0][1]:
    print(di[0])
  else:
    break


Measured memory_bytes: 115920
#include <stdio.h>

void insertSort(int *A, int N){

  for(int i=1;i<N;i++){
    int v = A[i];
    int j = i - 1;
    while( j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j -= 1;
    }
    A[j+1] = v;
  }
}

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

  insertSort(A, 3);

  for(int i=0;i<3;i++){
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");

  return 0;
}


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

#include <iostream>

using namespace std;


int main(){
	int n,new_t,new_a,temp_t,temp_a;
	long long t,a,rate_t,rate_a,max_rate;
	cin >> n;
	cin >> t;
	cin >> a;
	for(int i = 1;i < n; i++){
		cin >> new_t;
		cin >> new_a;
		if(t % new_t != 0){
			rate_t = (t / new_t) + 1;
		}else{
			rate_t = (t / new_t);
		}
		if(a % new_a != 0){
			rate_a = (a / new_a) + 1;
		}
		else{
			rate_a = (a / new_a);
		}
		if(rate_a >= rate_t){
			max_rate = rate_a;
		}
		else{
			max_rate = rate_t;
		}
		
		t = max_rate * new_t;
		a = max_rate * new_a;
	}
	
	printf("%ld\n",t+a);	
	return 0;
}



Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, K = LI()
    ans = (N - K) if K > 1 else 0
    return ans

print(main())

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 2050;
 ll mod = 1e9+7;


int main(){
  int n,t=0; 
  cin >> n;
  int cnt = 0;
  for(int i=1;i<=n;i++){
    string s = to_string(i);
    if(s.size()%2 != 0) cnt++;
  }
  cout << cnt << endl;
}


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

using namespace std;
const int N = 1e5 + 1, MOD = 1e9 + 7;

int parent[N], sz[N], rnk[N];

void init() {
	memset(rnk, 0, sizeof rnk);
	for (int i = 0; i < N; ++i) {
		parent[i] = i;
		sz[i] = 1;
	}
}

int root(int node) {
	while (node != parent[node]) {
		parent[node] = parent[parent[node]];
		node = parent[node];
	}
	return node;
}

bool join(int u, int v) {
	u = root(u);
	v = root(v);
	
	if (u == v)
		return false;
	
	if (rnk[u] < rnk[v])
		swap(u, v);
	
	rnk[u] += rnk[u] == rnk[v];
	sz[u] += sz[v];
	
	parent[v] = u;
	return true;
}

int find(int u, int v) {
	return root(u) == root(v);
}

struct Things {
	int cost, from, to;
	bool operator<(Things t) const {
		return cost < t.cost;
	}
};

struct Point {
	int x, y, i;
	bool operator<(Point p) const {
		if (x == p.x) {
			return y < p.y;
		}
		return x < p.x;
	}
};

Point a[N], b[N];
int main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//#endif
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d %d", &a[i].x, &a[i].y);
		a[i].i = i;
		b[i] = {a[i].y, a[i].x, i};
	}
	sort(a, a + n);
	sort(b, b + n);
	vector<Things> things;
	for (int i = 1; i < n; ++i) {
		things.push_back({abs(a[i].x - a[i - 1].x), a[i].i, a[i - 1].i});
		things.push_back({abs(b[i].x - b[i - 1].x), b[i].i, b[i - 1].i});
	}
	sort(things.begin(), things.end());
	long long result = 0;
	init();
	for (auto x: things) {
		if (find(x.from, x.to) == 0) {
			join(x.from, x.to);
			result += x.cost;
		}
	}
	printf("%lld\n", result);
	return 0;
}


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

using namespace std;

int main(){
    
    int a, b;
    for (int i=1;i<=10000;i++){
        
        cin >> a >> b;
        if (a == 0 && b == 0)break;
        if (a > b)cout << b << " " << a << endl;
        else cout << a << " " << b << endl;
        
    }
    
}


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

using namespace std;

int main(void) {
	long long a, b, c, d, n, ans;
	cin >> a >> b >> c >> d >> n;
	a <<= 2;
	b <<= 1;
	a = min(a, min(b, c));
	if (n & 1)
		ans = min((n >> 1) * d + a, n * a);
	else
		ans = min((n >> 1) * d, n * a);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;

using namespace std;
int main(){
    int d;std::cin >> d;
    if(d==25)std::cout << "Christmas" << std::endl;
    else if(d==24)std::cout << "Christmas Eve" << std::endl;
    else if(d==23)std::cout << "Christmas Eve Eve" << std::endl;
    else if(d==22)std::cout << "Christmas Eve Eve Eve" << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll X;
  cin >> X;
  ll m = 100;
  ll ans = 0;
  while (m < X) {
    ans += 1;
    m += m / 100;
  }
  cout << ans << endl;
}


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

int k;

int low(int n, int x) {
  if (n == 0) return x;
  return min(low(n-1,2*x),low(n-1,x+k));
}

int main () {
  int n; cin >> n >> k;
  cout << low(n,1) << endl;
  return 0;
}

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

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

B = []
for j in range(m):
    B.append(int(input()))

for k in range(n):
    x = 0
    for l in range(m):
        x += A[k][l] * B[l]
    print(x)

Measured memory_bytes: 7980
import sys
sys.setrecursionlimit(10 ** 6)

def calc(x):
    if x in dp:
        return dp[x]
    
    divs = [5, 3, 2]
    costs = [c, b, a]
    res = d * x
    for div, cost in zip(divs, costs):
        dived = x//div
        res = min(res, calc(dived) + cost + abs(x-dived*div) * d)
        if x > div:
            dived = x//div+1
            res = min(res, calc(dived) + cost + abs(x-dived*div) * d)
    dp[x] = res
    return res
t = int(input())
for _ in range(t):
    n, a, b, c, d = list(map(int, input().split()))
    dp = {}
    dp[0] = 0
    dp[1] = d
    print(calc(n))


Measured memory_bytes: 11488
import java.util.Scanner;

public class Main {

    static long ans = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if ("ABC".equals(s)) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}

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

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;

    int ans = 0;
    for(int i = 0; i < 2; i++)
    {
        if (a> b){
            ans += a;
            a--;
        }else {
            ans += b;
            b--;
        }
    }
    

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    long long N, M;
    cin >> N >> M;

    for (long long i = 0; i < M; i++)
        if (N % 2 == 0 && i >= N / 2 / 2)
            cout << i + 1 << ' ' << N - i - 1 << endl;
        else
            cout << i + 1 << ' ' << N - i << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main()
{
 int a,b;
 while(1){
  scanf("%d%d",&a,&b);
  if(a==0 && b==0)
   break;
  if(a>b)
  {int temp=a;
   a=b;
   b=temp;}
  printf("%d %d\n",a,b);
 }
 return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<chrono>
#include<ctime>

#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define all(x) x.begin(), x.end()
#define f(x) for(int i = 0; i < x; ++i)

using namespace std;
using namespace chrono;

int main(){
    ios::sync_with_stdio(0);

    int cont = 0, n, maior, menor ;

    cin >> n;

    vi v(n);

    f(n) cin >> v[i];

    for(int i =1; i < n-1; ++i){
        maior = max(v[i-1], max(v[i], v[i+1]));
        menor = min(v[i-1], min(v[i], v[i+1]));
        if(v[i] != maior and v[i] != menor) cont++;
    }

    cout << cont << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector <ll> v
#define vii vector<pair<ll,ll>>v
#define pb push_back
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define while_ int t;cin>>t;while(t--)
#define vmax 100000
using namespace std;


ll dp[101][vmax + 1];
ll maxP(ll W, ll n, ll w[], ll v[])
{

	for (int i = 0; i <= vmax; i++)
		dp[0][i] = 1e18;
	dp[0][0] = 0;
	for (ll an = 1; an <= n; an++)
	{
		for (ll av = 0; av <= vmax; av++)
		{
			if (v[an - 1] > av) dp[an][av] = dp[an - 1][av];
			else
				dp[an][av] = min(dp[an - 1][av], w[an - 1] + dp[an - 1][av - v[an - 1]]);
		}
	}
	ll ans = 0;
	f(i, 0, vmax + 1)
	if (dp[n][i] <= W)
		ans = i;
	return ans;

}

int main() {
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	fastio

	ll n, W;
	cin >> n >> W;
	ll w[n], v[n];
	f(i, 0, n) cin >> w[i] >> v[i];
	cout << maxP(W, n, w, v);

}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0, num = 5;
    while (N / 2 / num > 0) {
        ans += N / 2 / num;
        num *= 5;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<algorithm>
#include<iostream>
#include<utility>
#include<functional>
#include<queue>

using namespace std;

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

int N,M;
vector<pair<int,int> > job;

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

	rep(i,N) {
		int a,b; cin>>a>>b;
		job.push_back(pair<int,int>(a, b));
	}

	sort(begin(job), end(job));

	int ans = 0;
	priority_queue<int> q;

	int cur = 0;
	for (int d = 1; d <= M; ++d) {
		while (cur < N and job[cur].first <= d) {
			q.push(job[cur].second);
			cur++;
		}
		if (not q.empty()) {
			int a = q.top();
			q.pop();

			ans += a;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    ll n, k;
    cin >> n >> k;
    map<ll, ll> M;
    rep(i, n)
    {
        ll a, b;
        cin >> a >> b;
        M[a] += b;
    }

    ll tmp = 0;
    ll rui = 0;
    for (auto m : M)
    {
        tmp=m.first;
        rui+=m.second;
        if(rui>=k){
            cout<<tmp<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 7480
import java.util.Scanner;

public class Main {

    static String[] strs = { "eraser", "erase", "dreamer", "dream" };

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();
        int idx = S.length();

        while (true) {
            boolean endsWithStr = false;
            for (String str : strs) {
                if (idx - str.length() >= 0 && S.indexOf(str, idx - str.length()) == idx - str.length()) {
                    idx -= str.length();
                    endsWithStr = true;
                    break;
                }
            }
            if (!endsWithStr) {
                System.out.println("NO");
                break;
            }
            if (idx == 0) {
                System.out.println("YES");
                break;
            }
        }
    }
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N;
string S;
ll dp[200010][2];

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

  cin>>S;
  N=S.size();
  rep(i,N+1)rep(j,2)dp[i][j]=-INF;
  dp[1][0]=1;
  dp[2][1]=1;
  repl(i,1,N)rep(j,2){
    if(dp[i][j]==-INF)continue;
    rep(k,2){
      if(i+k>=N)continue;
      if(k!=j)maxch(dp[i+1+k][k],dp[i][j]+1);
      else{
        if(S.substr(i,k+1)!=S.substr(i-1-j,j+1))maxch(dp[i+1+k][k],dp[i][j]+1);
      }
    }
  }

  cout<<max(dp[N][0],dp[N][1])<<endl;

  return 0;
}


Measured memory_bytes: 3732
#include <stdio.h>
//#include <math.h>

int main(void){
  int r,D,x[10];
  scanf("%d",&r);
  scanf("%d",&D);
  scanf("%d",&x[0]);

  x[1]=r*x[0]-D;
  for(int i=1;i<=10;++i){
    x[i+1]=r*x[i]-D;
    //printf("%d\n",x[i]);
  }

  for(int i=1;i<=10;++i){
    printf("%d\n",x[i]);
  }

return 0;
}

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

int f(int x, int y) {
  if((1<= x && x <= 9) && (1<= y &&  y <= 9)){
    return x*y;
  } else {
    return (-1);
  }
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << f(a, b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;

ll N;
ll A,B;
string s;
int main(){
    cin>>A>>B;
    if((A+B)%2==0){
        cout<<(A+B)/2;
    }else{
        cout<<"IMPOSSIBLE";
    }

    return 0;
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

main(){
  int n; cin >> n;
  vi t(n); rep(i,n) cin >> t[i];
  int sum = accumulate(all(t),0);
  int m; cin >> m;
  int p,x;
  rep(i,m){
    cin >> p >> x;
    cout << sum - (t[p-1] - x) << endl;
  }
}


Measured memory_bytes: 256