akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e5 + 5;
const int M = 1e5 + 5;
const ll OO = 1e18;
const int mod = 1e9 + 7;

int n,a[N],ans=1,tree[1<<20];

void build(int idx = 0, int st = 0, int en = n-1) {

    if(st==en) return tree[idx] = a[st], void();

    int mid = st + (en-st)/2, lf = 2*idx + 1, rt = lf + 1;
    build(lf,st,mid);
    build(rt,mid+1,en);
    tree[idx] = __gcd(tree[lf],tree[rt]);

}

int query(int a = 0, int b = n-1, int idx = 0, int st = 0, int en = n-1) {

    if(a>b) return 0;
    if(a>en || st>b) return 0;
    if(a<=st && en<=b) return tree[idx];
    int mid = st + (en-st)/2, lf = 2*idx + 1, rt = lf + 1;
    return __gcd(query(a,b,lf,st,mid),query(a,b,rt,mid+1,en));

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

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

    build();

    for (int i = 0; i < n; ++i) {
        ans = max(ans, __gcd(query(0,i-1),query(i+1,n-1)));
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 5036
import java.util.Arrays;

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

		int result = 0;
		for (int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
			result += a[i];
		}

		int[] b = new int[5];
		for (int i = 0; i < a.length; i++) {
			int tmp = 10 - a[i] % 10;
			if (tmp == 10) {
				tmp = 0;
			}
			b[i] = tmp;
		}

		Arrays.sort(b);

		for (int i = 0; i < a.length - 1; i++) {
			result += b[i];
		}

		System.out.println(result);
	}
}


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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if ((a*b)%2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
void merge(int *,int,int,int);
void mergesort(int *,int,int);
int cnt=0,n;
int main(){
  int a[500000],i;
  scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
  mergesort(a,0,n);
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1)printf(" ");
    else printf("\n");
  }
  printf("%d\n",cnt);
  return 0;
}
void mergesort(int *a,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(a,left,mid);
    mergesort(a,mid,right);
    merge(a,left,mid,right);
  }
}
void merge(int *a,int left,int mid,int right){
  int l,i,k,j,n1=mid-left,n2=right-mid;
  int *L,*R;
  L=malloc(sizeof(int)*(n1+2));
  R=malloc(sizeof(int)*(n2+2));
  for(i=0;i<n1;i++){
    L[i]=a[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=a[mid+i];
  }
  L[n1]=2147483647;
  R[n2]=2147483647;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j])a[k]=L[i++];
    else a[k]=R[j++];
  }
  free(L);
  free(R);
}



Measured memory_bytes: 5472
#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;
typedef long long ll;

main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  if(a+b>c+d) cout << "Left";
  else if(a+b<c+d) cout << "Right";
  else cout << "Balanced";
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int  prime[50001];
    for(int i=2;i<50001;i++)prime[i]=0;
    for(int i=2;i<=sqrt(50001);i++){
        if(prime[i]==0){
            for(int j=i+i;j<50001;j+=i)prime[j]=1;
        }
    }
    int n,cou=0;
    while(cin>>n&&n!=0){
        for(int i=2;i<=n/2;i++)if(prime[i]==0&&prime[n-i]==0)cou++;
        cout<<cou<<endl;
        cou=0;

    }
}

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

const int INFTY=INT_MAX;
const int maxn=500000;

int L[maxn/2+2],R[maxn/2+2];
int count;

void merge(int *Array,int left,int mid,int right) {
  int n1=mid-left;
  int n2=right-mid;
  for (int i=0; i<n1; i++) {
    L[i]=Array[left+i];
  }
  for (int i=0; i<n2; i++) {
    R[i]=Array[mid+i];
  }
  L[n1]=R[n2]=INFTY;
  int i=0,j=0;
  for (int k=left; k<right; k++) {
    count++;
    if (L[i]<=R[j]) {
      Array[k]=L[i++];
    }
    else {
      Array[k]=R[j++];
    }
  }
}
void mergeSort(int *Array,int left,int right) {
  if (left+1<right) {
    int mid=(left+right)/2;
    mergeSort(Array,left,mid);
    mergeSort(Array,mid,right);
    merge(Array,left,mid,right);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin>>n;
  int S[n];
  for (int i=0; i<n; i++) {
    cin>>S[i];
  }
  count=0;
  mergeSort(S,0,n);
  for (int i=0; i<n; i++) {
    if (i) {
      cout<<" "<<flush;
    }
    cout<<S[i]<<flush;
  }
  cout<<endl;
  cout<<count<<endl;
  return 0;
}



Measured memory_bytes: 7076
# -*- coding: utf-8 -*-
s = input()
t = input()
result = []
for i in range(len(s)-len(t)+1):
    restorable = True
    for j in range(len(t)):
        if (s[i+j] != "?") & (s[i+j] != t[j]):
            restorable = False
            break
    if restorable:
        tmp_s = []
        tmp_s.append(s[0:i].replace("?", "a"))
        tmp_s.append(t)
        tmp_s.append(s[i+len(t):len(s)+1].replace("?", "a"))
        result.append("".join(tmp_s))

if len(result) > 0:
    result.sort()
    print(result[0])
else:
    print("UNRESTORABLE")


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Nmax=8100;
bool dp[2][Nmax];
bool Check(vi w,int t){
	int cur=0,nx=1;
	ZERO(dp[cur]);
	dp[cur][0]=true;
	for(auto a:w){
		ZERO(dp[nx]);
		REP(i,Nmax)if(dp[cur][i]){
			dp[nx][i+a]|=true;
			dp[nx][abs(i-a)]|=true;
		}
		swap(cur,nx);
	}
	return dp[cur][t];
}

signed main(){
	string s=readString();
	int x=read(),y=read();
	vi xs,ys;
	bool hori=true,first=true;
	int n=s.size(),cnt=0;
	REP(i,n)
		if(s[i]=='F'){
			cnt++;
			if(i==n-1||s[i+1]=='T'){
				if(first){
					x-=cnt;
					first=false;
				}else{
					(hori?xs:ys).PB(cnt);
				}
				cnt=0;
			}
		}else{
			first=false;
			hori^=1;
		}
	if(Check(xs,abs(x))&&Check(ys,abs(y)))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n=0;cin>>n;
	pair<int,int> x[200010];
	for(int i=0;i<n;i++)
	{
		cin>>x[i].first;
		x[i].second=i;
	}
	sort(x,x+n);
	
	int ans[200010]={0};
	for(int i=0;i<n;i++)
	{
		int j=x[i].second;
		if(i>=n/2)
		{
			ans[j]=x[n/2-1].first;
		}
		else
		{
			ans[j]=x[n/2].first;
		}
	}
	for(int i=0;i<n;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int Mod = 1e9 + 7;

const int maxn = 2010;

int n, m;
int dp[maxn + 5][maxn + 5];

int ways[maxn + 5][maxn + 5];

int C[maxn + 5][maxn + 5];

inline void prepare()
{
	REP(i, 0, maxn + 1)
	{
		C[i][0] = 1;
		REP(j, 1, i + 1)
			(C[i][j] = C[i - 1][j - 1] + C[i - 1][j]) %= Mod;
		if (!i)
		{
			REP(j, 0, maxn + 1)
				ways[i][j] = 1;
		}
		else
		{
			int tot = 1;
			ways[i][0] = 1;
			REP(j, 1, maxn + 1)
			{
				(tot += C[i - 1][j]) %= Mod;
				ways[i][j] = (ways[i][j - 1] + tot) % Mod;
			}
		}
	}
}

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	prepare();
	scanf("%d%d", &m, &n);
	int ans = 0;
	REP(i, 0, m + 1) REP(j, 0, min(n, m - i + 1))
	{
		int resm = m - i - j, resn = n - (n - j); 
		(ans += (LL)C[n - 1][j] * ways[resn][resm] % Mod) %= Mod;
	}
	(ans += Mod) %= Mod;
	printf("%d\n", ans);
	return 0;
}


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

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

    string s;
    cin >> s;
    int n = s.size();
    int k = 0;
    string t = "", u = "";
    s += "11111111";
    for (int i = 0; i < n; i++) {
        u += s[i];
        while (t == u) {
            i++;
            u += s[i];
        }
        if (i >= n)
            break;
        k++;
        t = u;
        u = "";
    }
    cout << k << endl;

    return 0;
}


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

using namespace std;

struct Pos { 
	int x, y;
	Pos(int a, int b) { x = a, y = b; }
	
};

bool same(Pos a, Pos b) {
	return a.x == b.x && a.y == b.y;
}

int n, m;
vector<Pos> seiza;
vector<Pos> sky;

int main() {
	while (1) {
		cin >> n;
		if (n == 0)break;
		int a, b;
		cin >> a >> b;
		for (int i = 1; i < n; i++) {
			int c, d;
			cin >> c >> d;
			seiza.push_back(Pos(c - a, d - b));
		}
		cin >> m;
		for (int i = 0; i < m; i++) {
			int c, d;
			cin >> c >> d;
			sky.push_back(Pos(c, d));
		}
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n - 1; j++) {
				Pos tmp(sky[i].x + seiza[j].x, sky[i].y + seiza[j].y);
				bool f = false;
				for (int k = 0; k < m; k++) {
					if (same(tmp, sky[k]))f = true;
				}
				if (!f)goto next;
			}
			cout << sky[i].x - a << " " << sky[i].y - b << endl;
		next:;
		}
		seiza.clear(), sky.clear();
	}
	return 0;
}

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

#define int long long

using namespace std;

const int maxn = 2e6 + 10, mod = 1e9 + 7;
int fac[maxn], ifac[maxn], r1, r2, c1, c2;

int pw(int base, int power)
{
        int res = 1;
        while (power) {
                if (power & 1)
                        (res *= base) %= mod;
                (base *= base) %= mod;
                power >>= 1;
        }
        return res;
}

int C(int n, int k) { return n < k ? 0 : fac[n] * ifac[k] % mod * ifac[n - k] % mod; }

signed main()
{
        cin >> r1 >> c1 >> r2 >> c2;

        fac[0] = 1;
        for (int i = 1; i < maxn; i++)
                fac[i] = fac[i - 1] * i % mod;
        ifac[maxn - 1] = pw(fac[maxn - 1], mod - 2);
        for (int i = maxn - 2; ~i; i--)
                ifac[i] = ifac[i + 1] * (i + 1) % mod;

        int ans = 0;
        for (int i = r1; i <= r2; i++)
                (ans += C(i + c2 + 1, i + 1) - C(i + c1, i + 1) + mod) %= mod;

        cout << ans;

        return 0;
}


Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
char ch[100003];
int len,ans;
int main()
{
	scanf("%s",ch+1);
	len=strlen(ch+1);
	if (len%2==0)
	{
		int mid=len/2;
		ans=mid;
		int r=mid+1,l=mid;
		while (ch[l]==ch[r]&&l>0&&ch[l]==ch[mid])
		{
			ans++;
			l--;
			r++;
		}
		printf("%d\n", ans);
	}else{
		int mid=len/2+1;
		ans=len/2;
		int r=mid,l=mid;
		while (ch[l]==ch[r]&&l>0&&ch[l]==ch[mid])
		{
			ans++;
			l--;
			r++;
		}
		printf("%d\n",ans);
	}
	return 0;
}


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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![0; 3];
    for _ in 0..n {
        let c = read::<usize>();
        if c % 4 == 0 {
            seq[0] += 1;
        } else if c % 2 == 0 {
            seq[1] += 1;
        } else {
            seq[2] += 1;
        }
    }
    let mut ok = true;
    if seq[0] == 0 && seq[2] > 0 {
        ok = false;
    }
    if seq[0] + 1 < seq[2] {
        ok = false;
    }
    if seq[0] + 1 == seq[2] && seq[1] > 0 {
        ok = false;
    }
    println!("{}", if ok { "Yes" } else { "No" });
}


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

int main() {

int N, K;
cin >> N >> K;
vector<int> M(N);
  for (int i = 0; i < N; i++){
   cin >> M.at(i);  
  }

  int sum = 0;
  for    (int i = 0; i < N; i++){
     if (M.at(i) >= K){
      sum++; 
     }
  }

cout << sum << endl;  
  
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    if (n % 10 == 7 || (n / 10 % 10) == 7 || n / 100 == 7)
        cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>

void process() {
    int a, b, c;
    int y;
    int i=0;
    scanf("%d %d %d", &a, &b, &c);
    for (; a<=b; a++) {
        y = c % a;
	if (y == 0) i++;
    }
    printf("%d\n", i);
}

int main(void) {
    process();
    return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};


ll power(ll m, ll n) {
    //cout << m << " " << n << endl;
    if (n == 0) return 1;
    if (n == 1) return m;
    
    if (n % 2 != 0) {
        ll tmp = power(m, n - 1) % (ll)(1e9 + 7);
        return tmp * m % (ll)(1e9 + 7);
        
    } else {
        ll tmp = power(m, n / 2) % (ll)(1e9 + 7);
        return tmp * tmp % (ll)(1e9 + 7);
    }
    
}
int main() {
    ll m, n; cin >> m >> n;
    cout << power(m, n) << endl;
}




Measured memory_bytes: 3092
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h = int(input())
d = {}
def sub(h):
    if h in d:
        return d[h]
    if h==1:
        ans = 1
    else:
        ans = sub(h//2) * 2 + 1
    d[h] = ans
    return ans
print(sub(h))

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

int main() {
  int a;
  cin>>a;
  vector<int> b(a),c(a),g(a);
  for(int i=0;i<a;i++)
    cin>>b[i];
  for(int i=0;i<a;i++)
    cin>>c[i];
  for(int i=0;i<a;i++)
    g[i]=b[i]-c[i];
  int h=0;
  for(int i=0;i<a;i++){
    if(g[i]>0)
      h+=g[i];
    }
  cout<<h<<endl;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
using lli=int;
using vect=vector<int>;
#define rep(i, n) for (lli i = 0; i < (n); i++)
class lazy_seg_tree
{
public:
	lazy_seg_tree(vect v) {
		n = 1;
		while (n < v.size()) n *= 2;
		node.resize(n * 2 - 1);
		lazy.resize(n * 2 - 1, 0);
		rep(i, v.size()) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = node[2 * i + 1]+node[2 * i + 2];
	};
	void eval(int k, int l, int r) {
		if (lazy[k] != 0) {
			node[k]+=lazy[k];
			if (r - l > 1) {
				lazy[2 * k + 1]+=lazy[k]/2;
				lazy[2 * k + 2]+=lazy[k]/2;
			}
			lazy[k] =0;
		}
	};
	void update(int a, int b, lli x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k]+=(r-l)*x;
			eval(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] =node[2 * k + 1]+node[2 * k + 2];
		}
	};
	lli getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (r <= a || b <= l) return 0;
		eval(k, l, r);
		if (a <= l && r <= b) return node[k];
		return getmin(a, b, 2 * k + 1, l, (l + r) / 2)+getmin(a, b, 2 * k + 2, (l + r) / 2, r);
	};
private:
	int n;
	vect node, lazy;
};
int n,d,a,x[200000],h[200000];
pair<int,int>xh[200000];
int arr[200000];
signed main(){
    cin>>n>>d>>a;
    d*=2;
    for(int i=0;i<n;i++){
        cin>>x[i]>>h[i];
        h[i]=(h[i]+a-1)/a;
    }
    for(int i=0;i<n;i++)
        xh[i]=make_pair(x[i],h[i]);
    sort(xh,xh+n);
    for(int i=0;i<n;i++)
        x[i]=xh[i].first,h[i]=xh[i].second;
    for(int i=0;i<n;i++)
        arr[i]=upper_bound(x,x+n,x[i]+d)-x;
    vect vh(n);
    for(int i=0;i<n;i++)
        vh[i]=h[i];
    lazy_seg_tree tree(vh);
    int ans=0;
    for(int i=0;i<n;i++){
        int tmp=tree.getmin(i,i+1);
        if(tmp>0){
            ans+=tmp;
            tree.update(i,arr[i],-tmp);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 19328
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  vi dp(51,INF);
  vi v(6),c(6);
  c[0]=380;
  c[1]=550;
  c[2]=850;
  c[3]=380*4;
  c[4]=550*4*85/100;
  c[5]=850*3*88/100;
  v[0]=2;
  v[1]=3;
  v[2]=5;
  v[3]=10;
  v[4]=12;
  v[5]=15;

  dp[0]=0;

  rep(i,25)rep(j,50)if(dp[j]<INF){
    rep(k,6)if(j+v[k]<=50)
      dp[j+v[k]]=min(dp[j+v[k]],dp[j]+c[k]);
  }

  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    cout<<dp[n/100]<<endl;
  }
}

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

int solve(int n, int A[], int B[], int mn, int mx) {
	int ans = 0;
	int T[mx+1];
	sort(B, B+n);
	for (int i = 0; i < n; i++) T[B[i]] = i;
	bool V[n] = {false};

	for (int i = 0; i < n; i++) {
		if (V[i]) continue;
		int cur = i;
		int S = 0;
		int an = 0;
		int m = 1<<30;
		while (1) {
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if (V[cur]) break;
		}
		ans += min(S + (an - 2) * m, m + S + (an + 1) * mn);
	}
	return ans;
}

int main() {
	int n, mn=1<<30, mx=(1<<30)*-1;
	cin >> n;
	int A[n], B[n];
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		B[i] = A[i];
		mn = min(mn, A[i]);
		mx = max(mx, A[i]);
	}
	int ans = solve(n, A, B, mn, mx);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int M, d;
bool used[102];
int main() {
    M = read(), d = read(); int ans = 0;
    for (reg int m = 1; m <= M; m++) {
        memset(used, 0, sizeof(used));
        for (int i = 2; i <= sqrt(m); i++) {
            if (m % i == 0) {
                if (i + 10 * (m / i) <= d && i < 10 && (m / i) < 10) used[i + 10 * (m / i)] = true;
                if (m / i + 10 * i <= d && i < 10 && (m / i) < 10) used[m / i + 10 * i] = true;
            }
        }
        for (reg int i = 1; i <= d; i++) ans += used[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = 0;
        for(int i=1;i<=a;i++){String s = String.valueOf(i); 
                              if(s.length()%2==1){b++;
                                                 }
                             }
		System.out.println(b);
	}
}


Measured memory_bytes: 25684
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  string s[10]={"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
int n,a;
while(cin>>n,n>-1){
  string b="00000000";
  while(n--){
    cin>>a;
    r(i,7){
      if(b[i]!=s[a][i]){
        cout<<1;
      }
      else cout<<0;
      b[i]=s[a][i];
    }
    cout<<endl;
  }
}
}

Measured memory_bytes: 3044
#include <algorithm>
#include <cstdio>
#include <vector>

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

using namespace std;

int n, q;
int v[200000];
vector<vector<int>> edge;

void solve(int a, int x) {
	if(v[a] == 0) {
		v[a] += x;
	} else {
		v[a] += x;
		x = v[a];
	}
	for(auto&& e : edge[a]) {
		solve(e, x);
	}
}

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

	edge.reserve(n);

	REP(i, n - 1) {
		int a, b;
		scanf("%d %d", &a, &b);
		edge[a - 1].push_back(b - 1);
	}

	REP(i, q) {
		int p, x;
		scanf("%d %d", &p, &x);
		v[p - 1] += x;
	}

	/* REP(i, n + 5) {
		REP(j, n + 5) { printf("%d ", static_cast<int>(edge[i][j])); }
		putchar('\n');
	}

	REP(i, n + 5) { printf("v[%d]:%d ", i, v[i]); }
	putchar('\n'); */

	solve(0, 0);

	REP(i, n) { printf("%d ", v[i]); }
	putchar('\n');

	return 0;
}

Measured memory_bytes: 20352
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N, M = input([int, 2])
    PS = input([[str, 2], M])

    ans = {}
    for p, s in PS:
        if not p in ans:
            ans[p] = [0, 0]
        if s == "AC":
            ans[p][0] = 1
        if s == "WA" and ans[p][0] == 0:
            ans[p][1] += 1
    ac, pen = 0, 0
    for v in ans.values():
        if v[0] == 0:
            continue
        ac += 1
        pen += v[1]
    print(ac, pen)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<vector<ll>> A(N, vector(N-1, 0LL));
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N-1; j++) {
      cin >> A[i][j];
      A[i][j]--;
    }
  }
  ll cnt = 0;
  vector<ll> ptr(N, 0LL);
  while (true) {
    vector<bool> ok(N, false);
    bool comp = true;
    bool proc = false;
    for (ll i = 0; i < N; i++) {
      if (ptr[i] == N - 1) continue;
      comp = false;
      ll j = A[i][ptr[i]];
      if (A[j][ptr[j]] == i) {
	ok[i] = true;
	ok[j] = true;
	proc = true;
      }
    }
    if (comp) break;
    if (!proc) {
      cout << -1 << endl;
      return 0;
    }
    for (ll i = 0; i < N; i++) {
      if (ok[i]) ptr[i]++;
    }
    cnt++;
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 11444
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    int n,k;
    in n>>k;
    int tmp=1;
    for(int i=0;i<n;i++)
    {
        if(tmp*2>=tmp+k)tmp+=k;
        else tmp*=2;
    }
    cout<<tmp<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll M,D,i=1,j=1,ANS=0;
	cin>>M>>D;
	while(1){
		//cout<<i<<"月"<<j<<"日"<<endl;
		if((j/10)>=2&&j%10>=2&&(j/10)*(j%10)==i)ANS++;
		if(j==D&&i==M)break;
		else if(j==D){
			i++;
			j=1;
		}
		else j++;
	}
	cout<<ANS<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int s = a * x + b * y;

    int t;
    if (x < y) {
        t = 2 * c * x + b * (y-x);
        if (t < s) s = t;

        t = 2 * c * y;
        if (t < s) s = t;
    }
    else {
        t = 2 * c * y + a *(x-y);
        if (t < s) s = t;

        t = 2 * c * x;
        if (t < s) s = t;
    }

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

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

int a[200005];

int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=k+1,j=1;i<=n;i++,j++){
		if(a[i]>a[j]){
			cout<<"Yes"<<endl;
		}
		else {
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int i = 0;
		int ans = 0;
		while (true) {
			ans = i*i;
			if (n < (i+1)*(i+1)) {
				break;
			}
			i++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
<?php
list($K, $A, $B) = explode(" ", trim(fgets(STDIN)));

$bis = 1;
$lest = $K;

if (!(($B - $A > 2) || ($K <= $A))) {
    echo $K + 1 . "\n";
} else {
    $bis = $A;
    $lest -= ($A - 1);

    if ($lest % 2 == 0) {
        $bis += ($B - $A) * $lest / 2;
    } else {
        $bis += ($B - $A) * ($lest - 1) / 2 + 1;
    }

    echo $bis . "\n";
}

Measured memory_bytes: 4728
N = int(input())

def factors(i):
    ans = []
    for j in range(1, i + 1):
        if i % j == 0:
            ans.append(j)
    return ans

count = 0
for i in range(3, N + 1, 2):
    fi = factors(i)
    # print(i, fi)
    if len(fi) == 8:
        count += 1
print(count)

Measured memory_bytes: 3060
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

n = int(input())
l = primes(101)
d = {}
for i in l:
    d[i] = 0

for i in range(1,n+1):
    for k in factorize(i):
        d[k[0]] += k[1]

n2 = 0
n4 = 0
n14 = 0
n24 = 0
n74 = 0

for v in d.values():
    if v >= 2:
        n2 += 1
    if v >= 4:
        n4 += 1
    if v >= 14:
        n14 += 1
    if v >= 24:
        n24 += 1
    if v >= 74:
        n74 += 1

ans = 0
ans += (n4*(n4-1)//2)*(n2-2)
ans += n14*(n4-1)
ans += n24*(n2-1)
ans += n74
print(ans)





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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n;
	cin >> n;
	vector<int>arr(n),sortarr;
	rep(i, n)cin >> arr[i];
	sortarr = arr;
	sort(all(sortarr));
	int mid = n / 2;
	int one = sortarr[mid - 1], two = sortarr[mid];

	rep(i, n) {
		if (arr[i] <= one)cout << two << endl;
		else cout << one << endl;
	}
	return 0;
}



Measured memory_bytes: 4844
#include <stdio.h>

int main()
{
	int A, B, C, K;
	scanf("%d %d %d", &A, &B, &C);
	scanf("%d", &K);
	
	int i;
	for (i = 1; i <= K; i++) {
		if (A >= B) B *= 2;
		else if (B >= C) C *= 2;
	}
	if (B > A && C > B) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    long long n,m,x;
    cin>>n>>m>>x;
    long long c[n];
    long long a[n][m];
    rep(i,n){
        cin>>c[i];
        rep(k,m){
            cin>>a[i][k];
        }
    }

    long long second[14];
    second[0]=1;
    rep(i,n)second[i+1]=second[i]*2;
    long long ans=INF;
    for(int bit=0;bit<(1<<n);bit++){

    long long total=0;

    long long master[m]={};
        rep(i,n){
            if(bit&second[i]){
                total+=c[i];
                rep(k,m){
                master[k]+=a[i][k];
                }
            }
        }
        bool end=true;
        rep(i,m){
            if(master[i]<x){
                end=false;
                break;
            }
        }

        if(end){
        ans=min(ans,total);
        }

    }
    if(ans==INF)ans=-1;
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3636
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    System.out.println(A + B >= C ? "Yes" : "No");
  }
}

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int n,l,r;
  cin >> n;
  
  int count = 0;
  
  for ( int i = 0; i < n; i++){
    cin >> l >> r;
    count = count + ( r - ( l - 1 ) );
  }
  
  cout << count << endl;

}

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

int main(){
 int x,y;
 while(true){
  cin>>x>>y;
 if(x==0&&y==0){
   break;
  }else{
   if(x>y){
    cout<<y<<' '<<x<<'\n';
   }else{
    cout<<x<<' '<<y<<'\n';
   }
  }
 }
 return 0;
}

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

int main(){
  int l,r;
  cin>>l>>r;

  int p = l % 2019;
  int q = r - l + 1;
  if (q >= 2019){
    cout<<0<<endl;
    return 0;
  }
  vector<int> a(q);
  rep(i,q){
    a[i] = (p + i) % 2019;
  }
  int ans = 1e9;
  rep(i,q)rep(j,q){
    if (i!=j)
      ans = min(ans, a[i]*a[j]%2019);
  }
  cout<<ans<<endl;
}

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


int main(){
	int i,N,K;
	string S;
	int count=0;
	cin>>N>>K>>S;
	for(i=0;i<N;i++)
		if(S[i]==S[i+1])
			count++;
	cout<<min(N-1,count+K*2);
	return 0;	
}

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

int main(){
  int a, b, k, n;
  cin >> a >> b >> k;
  n = min(a, b);
  vector<int> ans(n,0);
  
  for(int i = 1; i <= n; i++){
    if(a % i == 0 && b % i == 0){
      ans.at(i-1) = i;
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.at(n-k);
}

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

// #define MOD 1000000007
// #define INF 1000000001

using namespace std;
// typedef unsigned long long ull;
// typedef long long ll;

void p_() {
    cout << "\n";
}
template<class Head, class... Body>
void p_(Head head, Body... body) {
    cout << head << ",";
    p_(body...);
}


int main(int argc, char const *argv[]) {
    int R;
    cin >> R;
    cout << R*2*3.14159 << endl;
    return 0;
}


Measured memory_bytes: 3784
def resolve():
    from collections import defaultdict
    N = int(input())
    A = [int(i) for i in input().split()]
    dic = defaultdict(int)
    for a in A:
        dic[a] += 1
    ans = 0
    for k, v in dic.items():
        if k <= v:
            ans += v - k
        else:
            ans += v
    print(ans)


resolve()


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

int main() {
  
  int a,b,ans;
  cin >> a >> b ;

  if ((a+b)%2 == 0){
    ans = (a+b)/2;
  }else{
    ans = (a+b)/2 +1;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3524
// Problem : I - Coins
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_i
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define all(x) x.begin(), x.end()
#define rev(x) x.rbegin(), x.rend()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pi 3.141592653589793238
#define mp make_pair
#define pb push_back
#define precise cout<<fixed<<setprecision(15)
#define ff first
#define ss second
#define T int t;cin>>t;rep(mmm,0,t)
#define uniq(v) v.resize(distance(v.begin(),unique(all(v))))

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;

const int N=100001;
int mod=1000000007;
//mod=998244353;

int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
int mul(int a,int b){return ((a%mod)*(b%mod))%mod;}
int sub(int a,int b){return (((a-b)%mod)+mod)%mod;}

void solve()
{
	int n;
	cin>>n;
	double dp[n+1]={0.0};
	dp[0]=1.0;
	rep(i,1,n+1)
	{
		double p;
		cin>>p;
		repr(j,i+1,0)
		{
			dp[j]*=(1.0-p);
			if(j)
			dp[j]+=dp[j-1]*p;
		}
	}
	double ans=0.0;
	rep(i,(n+1)/2,n+1)
	{
		ans+=dp[i];
	}
	precise<<ans;
}

signed main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0);cout.tie(0);
     solve();
    return 0;
}

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

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m;
      cin>>n>>m>>k;
      if(n==0)
      {
          if(m%2==0)
          cout<<0;
          else
          cout<<k;
          return 0;
      }
      if(n>0)
      {
          if(n<k)
          {ans=n; x=0;}
          else
          {ans=n-(n/k)*k; x=n/k;}
          
          if(x<m)
          {
               sum=abs(ans-k);
              m=m-x;
              if(m%2==1)
              cout<<sum;
              else
              cout<<ans;
               
          }
          else
          {
             cout<<n-k*m; 
          }
          
      }
      else
      {
          n=-n;
        if(n<k)
          {ans=n; x=0;}
          else
          {ans=n-(n/k)*k; x=n/k;}
          
          if(x<m)
          {
             sum=abs(ans-k);
              m=m-x;
              if(m%2==1)
              cout<<sum;
              else
              cout<<ans;   
          }
          else
          {
             cout<<n-k*m; 
          }
      }
	return 0;
}


Measured memory_bytes: 3608
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	if len(s)%2 == 1 {
		fmt.Println("No")
		return
	}

	for i := 0; i+1 < len(s); i += 2 {
		if s[i:i+2] != "hi" {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair
#define X				first.first
#define Y				first.second

typedef pair<int, int> P;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

bool field[150][150];
int turn;

int bfs( int sx, int sy ) {
	int ans = 1;

	queue<pair<P, int> > que;
	que.emplace( MP( sx, sy ), 0);
	field[sx][sy] = false;

	while( !que.empty() ) {
		pair<P, int> t = que.front(); que.pop();
		if( t.second == turn ) break;

		REP( i, 6 ) {
			int nx = t.X + dx[i];
			int ny = t.Y + dy[i];

			if( field[nx][ny] ) {
				field[nx][ny] = false;
				ans++;
				que.emplace( MP( nx, ny ), t.second + 1 );
			}
		}
		
	}
	
	return ans;

}

signed main() {
	int n;
	while( cin >> turn >> n, turn ) {
		fill( field[0], field[150], true );
		REP( i, n ) {
			int x, y; cin >> x >> y;
			field[x + 60][y + 60] = false;
		}

		int sx, sy; cin >> sx >> sy;

		cout << bfs( sx + 60, sy + 60 ) << endl;
	}
}


Measured memory_bytes: 3108
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

def ceil(x,y):
  return (x-1)//y+1


n,h = map(int,input().split())
A = [];B = []
for i in range(n):
  a,b = map(int,input().split())
  A.append(a)
  B.append(b)
MA = max(A)
B.sort(reverse = True)
for i in range(n):
  if not (B[i] >= MA and h > 0):break
  count += 1
  h -= B[i]
if h>0:count += (h-1+MA)//MA
print(count)

Measured memory_bytes: 50780
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[200005],B[200005],C[200005],x,ans;
vector <long long> v[200005];
map <long long,long long> mp;
string s;
int main() {
	cin>>n;
	for(long long i=1;i<=n;i++) {
		cin>>A[i];
		B[i]=A[i]+i;
		C[i]=i-A[i];
		mp[C[i]]++;
	}
	for(long long i=1;i<=n;i++) {
		ans+=mp[B[i]];
		if(C[i]==B[i]) ans--;
	}
	cout<<ans;
}

Measured memory_bytes: 35648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;

P a[100010];
ivec hoge(100010);
int n;
int cyclic(ivec &v)
{
	int ima=0;
	int j=0;
	
	do
	{
		ima=v[ima];
		j++;
	}while(ima!=0);
	//cout<<j<<"\n";
	return j;
}

bool hantei(ivec &v)
{
	ivec w(n);
	for(int i=0;i<n;i++)w[i]=v[i];
	sort(w.begin(),w.begin()+n);
	
	bool flag=true;
	bool flag2=true;
	for(int i=0;i<n;i++)
	{
		if(w[i]!=i)flag2=false;
		if(w[i]<i)
		{
			flag=false;
			break;
		}
	}
	if(!flag2)return flag;
	if(cyclic(v)==n)return false;
	else return true;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i].first;
	for(int i=0;i<n;i++)cin>>a[i].second;
	sort(a,a+n);
	
	for(int i=0;i<n;i++)
	{
		 hoge[i]=lower_bound(a,a+n,P(a[i].second,MOD))-a-1;
		 //cout<<hoge[i]<<" ";
	}
	//cout<<"\n";
	if(hantei(hoge))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long limit = sc.nextLong();
		List<Long> a = new ArrayList<>();
		a.add(0L);
		for (int i = 0; i < n; i++) {
			a.add(a.get(i) + sc.nextLong());
		}
		List<Long> b = new ArrayList<>();
		b.add(0L);
		for (int i = 0; i < m; i++) {
			b.add(b.get(i) + sc.nextLong());
		}
		sc.close();

		int ans = 0;
		int j = m;
		for (int i = 0; i < n + 1; i++) {
			Long ai = a.get(i);
			if (ai > limit) {
				break;
			}
			while (b.get(j) > limit - ai) {
				j--;
			}
			ans = Math.max(ans, j + i);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 64828
N = int(input().strip())

def is_prime(n):
  if n == 1: return False
  for i in range(2, int(n**0.5)+1):
    if n % i == 0: return False
  return True

ans = N
while True:
  if is_prime(ans):
    print(ans)
    break
  ans += 1

Measured memory_bytes: 38896
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main() {

	string S;
	ll K;
	cin>>S>>K;
	ll cnt1=0;
	for(int i=0;i<S.size();i++){
		if(S[i]!='1')break;
		cnt1++;
	}
	if(cnt1>=K)cout<<1<<endl;
	else cout<<S[cnt1]<<endl;

	return 0;
}

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


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

using namespace std;

#define int ll

ll dp[65][200005];//dp[i][j]:j番目の要素に対して2^i回操作を適用したときの値
void solve()
{
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i], a[i]--;
	memset(dp,0, sizeof(dp));
	rep(i,n){
		dp[0][i] = a[i];
	}
	rep(i,60)
	{
		rep(j,n){
			if((1LL<<(i+1))>k){
				dp[i + 1][j] = -1;
			}
			else{
				dp[i + 1][j] = dp[i][dp[i][j]];
			}
		}
	}
	int s = 0;
	for (int i = 60; i >= 0; --i)
	{
		if(dp[i][s]<0){
			continue;
		}
		if(k&(1LL<<i)){
			s = dp[i][s];
		}
	}
	cout << s + 1;
}
#undef int

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

Measured memory_bytes: 106424
#include<stdio.h>
#include<string.h>

int main()
{
    int A,B,i,length;
    char s[2000];

    scanf("%d%d",&A,&B);
    scanf("%s",s);

    length=strlen(s);

    for(i=0;i<length;i++){
        if(s[A]!='-'){
            printf("No");
            break;
        }
        if(i==A){
            i++;
        }
        if(s[A]=='-'&&s[i]>=48&&s[i]<=57){
            if(i==(length-1)){
                printf("Yes");
                break;
            }
            else{
                continue;
            }
        }
        if(s[i]=='-'&&s[A]=='-'){
            printf("No");
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 128
S = list(input())
S_1 = []
S_2 = []
for i in range(len(S)):
    if i % 2 == 0:
        S_1.append("0")
        S_2.append("1")
    else:
        S_2.append("0")
        S_1.append("1")
s_1 = 0
s_2 = 0
for j in range(len(S)):
    if S_1[j] != S[j]:
        s_1 += 1
    if S_2[j] != S[j]:
        s_2 += 1
print(min(s_1,s_2))

Measured memory_bytes: 5528
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 50005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	long long x;
	cin >> x;
	long long now = 100;
	for (int i = 1; ; ++i) {
		now = 1.01l * now;
		if (now >= x) {
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3656