akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#include<algorithm>
#include<memory.h>
#include<set>
#include<map>
#include<cmath>
#include<time.h>
#include<iomanip>
#include<time.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N = 2e6, M = 1e9 + 7;
const double PI = acos(-1);
ll A, B;
int main() {
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	cin >> A >> B;
	if (A == B) 
		return cout << 1, 0;
	int r;
	for (int i = 60;i >= 0;i--) {
		if ((B & 1LL << i) && !(A & 1LL << i)) {
			r = i;
			break;
		}
	}
	int nxt = 0;
	A &= (1LL << r) -1;
	vector<pair<ll, ll>>v;
	v.pb({ A, (1LL << r) -1 });
	B &= ((1LL << (r + 1))-1);
	v.pb({ ((1LL << r) + A) ,(1LL << (r + 1)) - 1 });
	int k = -1;
	for (int i = r - 1;i >= 0;i--) {
		if (B & (1LL << i)) {
			k = i;
			break;
		}
	}
	
		v.pb({ 1LL << r,(1LL << r) + ((1LL << (k + 1)) - 1) });
	
	sort(v.begin(), v.end());
	vector<pair<ll, ll>>I;
	for (int i = 0;i < v.size();i++) {
		if (!I.size())I.pb(v[i]);
		else if (v[i].fi <= I.back().se)I.back().second = max(I.back().se, v[i].se);
		else I.pb(v[i]);
	}
	ll ans = 0;
	for (int i = 0;i < I.size();i++) {
		//cout << I[i].first << " " << I[i].second << endl;
		ans += I[i].second - I[i].first + 1;
	}
	cout << ans << endl;

	
}

Measured memory_bytes: 256
import sys

A = input()
B = input()

if A == '1':
    if B == '2':
        print('3')
    else:
        print('2')
elif A == '2':
    if B == '1':
        print('3')
    else:
        print('1')
elif A == '3':
    if B == '1':
        print('2')
    else:
        print('1')


Measured memory_bytes: 2940
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n,k;
int cost[110][110];
int a,b;
int d[110];
bool used[110];
void dijkstra(int s){
	for(int i = 1;i <=n;i++){
		d[i]=INF;
		used[i] = false;
	}
	d[s] = 0;
	while(1){
		int v = -1;
		int u;
		for(int u = 1;u <=n;u++){
			if(!used[u]&&(v==-1||d[u]<d[v])){
				v = u;
			}
		}
		if(v==-1)
			break;
		used[v]=true;
		for(int u = 1;u <=n;u++){
			d[u] =min(d[u],d[v]+cost[v][u]);
		}
	}
}

int main(){
	while(cin>>n>>k,n||k){
		for(int i = 1;i <=n;i++){
			for(int j = 1;j <=n;j++){
				cost[i][j] =INF;
			}
		}
		for(int i = 0;i <k;i++){
			int m;
			cin>>m;
			if(m==0){
				scanf("%d %d",&a,&b);
				dijkstra(a);
				if(d[b]!=INF){
					printf("%d\n",d[b]);
				}else{
					printf("%d\n",-1);
				}
			}else if(m==1){
				int c,d,e;
				scanf("%d %d %d",&c,&d,&e);
				cost[c][d] = cost[d][c]=min(min(cost[d][c],cost[c][d]),e);
			}
		}
	}
	return 0;
}

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

namespace AtCoder
{
    public class Prog
    {
        const int MOD = 1000000007;
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var a = cin.ReadInt;
            var b = cin.ReadInt;

            var ans = Math.Min(n * a, b);

            Console.WriteLine(ans);

        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


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

using namespace std;

int main(){
  long long K,A,B;
  long long ans = 0;
  cin >> K >> A >> B;
  if(A+2 >= B){
    cout << K+1 << endl;
  }
  else{
    long long times = (K - (A - 1))/2;
    ans = K+1-times*2 + (B-A)*times;
    cout << max(ans,K+1) << endl;
  }
}


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


using namespace std;

int main(){


    string st;
    cin>>st;

    sort(st.begin(),st.end());

    if(st[0]==st[1]&&st[2]==st[3]&&st[1]!=st[2]){
    cout<<"Yes"<<endl;
        return 0;
    }
        cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    string a;
    cin>>n;
    std::deque<string> deq;
    std::deque<int> num;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
        num.emplace_back(stoi(a));
    }
    for (int j=0;j<n-1;j++) {
        string tmp=deq[j]+deq[j+1];
        num.emplace_back(stoi(tmp));
    }
    for (int k=0;k<n-2;k++) {
        string tmp=deq[k]+deq[k+1]+deq[k+2];
        num.emplace_back(stoi(tmp));
    }
    int ans=0;
    while (1) {
        if (find(num.begin(),num.end(),ans)==num.end()) {
            cout<<ans<<endl;
            break;
        } else {
            ans++;
        }
    }
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n, a, b, c, d;
	string s;
	cin >> n >> a >> b >> c >> d >> s;
	string ans = "Yes";
	s = "#" + s;
	REP(i, a, c){
		if(s[i] == '#' && s[i+1] == '#'){
			cout << "No";
			return 0;
		}
	}
	REP(i, b, d){
		if(s[i] == '#' && s[i+1] == '#'){
			cout << "No";
			return 0;
		}
	}
	
	if( d < c){
		ans = "No";
		for(int i = b; i <= d; i++){
			if(s[i-1] =='.' && s[i] =='.' && s[i+1] =='.') ans = "Yes";
		}
	}
	cout << ans;
		
	

}


Measured memory_bytes: 772
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int num = 0;
    int min = 0;
    ArrayList<Integer> student = new ArrayList<Integer>();
    ArrayList<Integer> point = new ArrayList<Integer>();
    for(int a=0;a<2*N;a++){
      student.add(sc.nextInt());
    }
    for(int b=0;b<2*M;b++){
      point.add(sc.nextInt());
    }
    for(int c=0;c<2*N;c+=2){
      for(int d=0;d<2*M;d+=2){
        if(d==0){
          min = Math.abs(student.get(c)-point.get(d))+Math.abs(student.get(c+1)-point.get(d+1));
          num = d+1;
        }
        if(min>Math.abs(student.get(c)-point.get(d))+Math.abs(student.get(c+1)-point.get(d+1))){
          min = Math.abs(student.get(c)-point.get(d))+Math.abs(student.get(c+1)-point.get(d+1));
          num = d/2+1;
        }
      }
      System.out.println(num);
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;
long long n,i,x;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(x%2==0)
        {
            if(x%3!=0 && x%5!=0)
            {
                cout<<"DENIED";
                return 0;
            }
        }
    }
    cout<<"APPROVED";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N, M;
vector<vector<P>> edge1(100001);
vector<vector<P>> edge2(100001);
bitset<100001> bit;
vector<ll> memo(100001, 0);

void rec(int corrent, int p = 0){
    
    if(bit[corrent]){
        if(memo[corrent] != p) { printf("No\n"); exit(0); }
        return;
    }
    bit[corrent] = true;
    memo[corrent] = p;

    for(auto e : edge1[corrent]) rec(e.first, p + e.second);
    for(auto e : edge2[corrent]) rec(e.first, p - e.second);
    
    return;
}

int main(void){
    
    scanf("%d %d", &N, &M);
    for(int i = 0; i < M; ++i){
        int a, b, c; scanf("%d %d %d", &a, &b, &c);
        edge1[a].push_back(make_pair(b, c)), edge2[b].push_back(make_pair(a, c));
    }
    
    for(int i = 1; i <= N; ++i) if(!bit[i]) rec(i, 0);
    
    printf("Yes\n");
    
    return 0;
}


Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    int len=s.size();
    int a,b,i;
    a=(len-1)/2;
    a--;
    b=(len+3)/2;
    b--;
    string t1="",t2="";
    for(i=0;i<=a;i++)
        t1+=s[i];
    for(i=b;i<len;i++)
        t2+=s[i];
    //cout<<t1<<' '<<t2<<endl;
    string tt1,tt2,t3;
    tt1=t1;
    tt2=t2;
    t3=s;
    reverse(tt1.begin(),tt1.end());
    reverse(tt2.begin(),tt2.end());
    reverse(t3.begin(),t3.end());
    if(t1==tt1 && t2==tt2 && s==t3)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

using namespace std;
int main()
{
     
     int n,m,i,cnt=0,res=0;
     double ans,mmd;

     cin>>n>>m;
     int a[n];
     mmd = (1.0)/(4.0*m);
     for(i = 0; i < n; i++)
     {
          cin>>a[i];
          res+=a[i];
     }
     for(i = 0; i < n; i++)
     {
          ans = (a[i]*1.0)/(res*1.0);

          if(ans<mmd)
               cnt=cnt;
          else
               cnt++;
     }
     if(cnt>=m)
          cout<<"Yes\n";
     else
          cout<<"No\n";


     return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)

#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;

int main() {
	ll x, y; cin >> x >> y;

	ll ans = 0;
	ll d = abs(abs(y) - abs(x));

	if (abs(x) <= abs(y)) {
		if (x > 0 && y > 0) {
			cout << d << endl;
		}
		else if (x < 0 && y < 0) {
			cout << d + 2 << endl;
		}
		else if (x == 0 && y > 0) {
			cout << d << endl;
		}
		else if (x == 0 && y < 0) {
			cout << d + 1 << endl;
		}
		else {
			cout << d + 1 << endl;
		}
	}
	else {
		if (x > 0 && y > 0) {
			cout << d + 2 << endl;
		}
		else if (x < 0 && y < 0) {
			cout << d << endl;
		}
		else if (y == 0 && x > 0) {
			cout << d + 1 << endl;
		}
		else if (y == 0 && x < 0) {
			cout << d << endl;
		}
		else {
			cout << d + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
line1 = input().split()
n = int(line1[0])
k = int(line1[1])
c = int(line1[2])
s = list(input())
l = [s.index("o") + 1]
r = [len(s) - s[::-1].index("o")]
for i in range(1, k):
  j = l[i - 1]
  m = r[i - 1]
  while j - l[i - 1] <= c or s[j - 1] != "o":
    j += 1
  while r[i - 1] - m <= c or s[m - 1] != "o":
    m -= 1
  r.append(m)
  l.append(j)
r = r[::-1]
for i in range(len(r)):
  if r[i] == l[i]:
    print(r[i])

Measured memory_bytes: 24860
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6;
const double PI = acos(-1.0);
#define Test ll tesnum;tesnum = read();while(tesnum--)
ll read();
ll a[N],b[N];
int main()
{
    ll n,m,k;
    cin>>n>>m>>k;
    for(int i = 1; i <= n; i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(int i = 1; i <= m; i++){
        cin>>b[i];
        b[i]+=b[i-1];
    }
    ll ans = 0;
    int j = m;
    for(ll i = 0,j = m; i <= n; i++){
        if(a[i]>k)break;
        while(a[i]+b[j]>k)j--;
        ans = max(ans,i+j);
    }
    cout<<ans<<endl;
    return "BT7274", NULL;
}

inline ll read() {
    ll hcy = 0, dia = 1;char boluo = getchar();
    while (!isdigit(boluo)) {if (boluo == '-')dia = -1;boluo = getchar();}
    while (isdigit(boluo)) {hcy = hcy * 10 + boluo - '0';boluo = getchar();}
    return hcy * dia;
}

Measured memory_bytes: 6700
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(num,init,name) vector<int> name((num),(init));


int main(){
    int n;
    int ans=0;
    int cnt=0;
    
    string s;
    cin>>n;
    cin>>s;
    vec(n,INT_MAX,a);
    repf(i,1,n){
        if(s[i]=='E')ans++;
    }
    a[0]=ans;
    repf(i,1,n){
        cnt=0;
        if(s[i-1]=='W')cnt++;
        if(s[i]=='E')cnt--;
        a[i]=a[i-1]+cnt;
    }
    sort(all(a));
    cout<<a[0]<<endl;
    return 0;

}

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

int main() {
int N;
cin >> N;
if (N % 2 == 1)
{
  double a;
  a = double(N);
  cout << (a+1)/(a*2) << endl;
}

else
{
  cout << 0.5 << endl;
}
}

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
    os << "[";
    for (auto x : V) os << x << ", ";
    return os << "]";
}
//--------------------------------------------------//

int main() {
    use_cio();
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    rep(i, n) {
        int ba = b[i] - a[i], ca = c[i] - a[i];
        if (ba == 0) {
            ans += (ca != 0);
        } else if (ca == 0) {
            ans += (ba != 0);
        } else {
            ans += 1 + (ba != ca);
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
k=int(input())
cnt=0
from collections import deque
queue=deque([1,2,3,4,5,6,7,8,9])
while cnt<k:
	p=queue.popleft()
	cnt+=1
	if p%10!=0:
		queue.append(p*10+p%10-1)
	queue.append(p*10+p%10)
	if p%10!=9:
		queue.append(p*10+p%10+1)
print(p)

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

char data[8][8];
int px, py;

int main(){
	while (true){
		for(int i = 0; i < 8 ; i++){
			for(int j = 0; j < 8; j++){
				if(!(std::cin >> data[i][j]))goto end;
				if(data[i][j] == '1')px = j, py = i;
			}
		}

		if (data[py][px - 1] == '1' && data[py - 1][px] == '1' && data[py - 1][px - 1] == '1')printf("A\n");
		else if (data[py - 1][px] == '1' && data[py - 2][px] == '1' && data[py - 3][px] == '1')printf("B\n");
		else if (data[py][px - 1] == '1' && data[py][px - 2] == '1' && data[py][px - 3] == '1')printf("C\n");
		else if (data[py - 1][px] == '1' && data[py - 1][px + 1] == '1' && data[py - 2][px + 1] == '1')printf("D\n");
		else if (data[py][px - 1] == '1' && data[py - 1][px - 1] == '1' && data[py - 1][px - 2] == '1')printf("E\n");
		else if (data[py - 1][px] == '1' && data[py - 1][px - 1] == '1' && data[py - 2][px - 1] == '1')printf("F\n");
		else if (data[py - 1][px] == '1' && data[py - 1][px + 1] == '1' && data[py][px - 1] == '1')printf("G\n");
	}
	end:;
	return 0;
}

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

using namespace std;

typedef unsigned long long int ulli;

int main(){
	/*
	freopen("input.txt","r",stdin);
	freopen("input.txt","w",stdout);
	*/
	int a,b,c;
	cin >> a >> b >> c;
	if(a == b && c != a || a == c && b != c || b == c && a != b){cout << "Yes";}
	else{cout << "No";}
	
} 
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //逆
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;  //最大値兼MOD
typedef long long ll;
using namespace std;

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }  //GCD

long long sumdigit(string s){  //全ての桁の和
  long long sum = 0;
  for(int i = 0; i < s.length();i++){
    sum += s[i] - '0';
  }
  return sum;
}
bool is_prime(long long n) {  //素数判定
  for(int64_t i = 2; i * i <= n; i++) {
    if(n % i == 0) return false;
  }
  return true;
}

int main(){
    int N,A,B;
    int ans = 0;
    cin >> N >> A >> B;
    rep1(i,N+1){
        int sum = 0;
        int temp = i;
        rep0(j,5){
            sum += temp % 10;
            temp /= 10;
        }
        if(A <= sum && B >= sum)ans += i;
    }
    cout << ans << endl;
    return 0;
}

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

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

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

    ll a,b;
    cin >> a >> b;
    
    ll g = gcd(a,b);
    
    int ans = 0;
    if(g % 2 == 0){
        while(g % 2 == 0) g /= 2;
        ans++;
    }
    
    for(ll i=3; i*i<=g; i+=2){
        if(g % i == 0){
            while(g % i == 0) g /= i;
            ans++;
        }
        
        if(g == 1) break;
    }
    
    if(g != 1) ans++;
    
    cout << ans + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#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()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;

    int cou = 0;
    vi cc(1, 0);
    rep(i, n-1) {
        if(s[i] != s[i+1]) {
            cou++;
            cc.push_back(i+1);
        }
    }
    cc.push_back(n);

    if(cou <= 2*k-1) {
        cout << n << endl;
        return 0;
    }
    if(cou == 2*k && s[0] == 1) {
        cout << n << endl;
        return 0;
    }


    int ans = 0;
    
    if(s[0] == '1') {
        int i = 0;
        while(1) {
            if(i + 2 * k + 1 >= cc.size()) break;
            ans = max(ans, cc[i+2*k+1] - cc[i]);
            i += 2;
        }
        ans = max(ans, n - cc[i]);
    } else {
        int i = 1;
        while(1) {
            if(i + 2 * k + 1 >= cc.size()) break;
            ans = max(ans, cc[i+2*k+1] - cc[i]);
            i += 2;
        }
        ans = max(ans, n - cc[i]);
        ans = max(ans, cc[2*k]);
    }

    cout << ans << endl;
}

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

using namespace std;

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

    vector<long> a(N);
    for(int i = 0; i < N; i++)cin >> a[i];

    long odd = 0;
    long mul4 = 0;
    
    for(int i = 0; i < N; i++){
        if(a[i]%2 != 0){
            odd++;
            continue;
        }
        if(a[i]%4 == 0)mul4++;
    }

    if(mul4 >= odd)cout << "Yes\n";
    else if(odd - mul4 == 1  && odd+mul4 == N) cout << "Yes\n";
    else cout << "No\n";

}

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

ll H;

int main(){
  cin >> H;
  ll N = log2(H), ans = 0;
  rep(i,N+1) ans += pow(2,i);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int N;cin>>N;
    cout<<N*800-(N/15*200)<<endl;
}


Measured memory_bytes: 3568
import java.util.Scanner;
/**
 * HelloWorld
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double pi = Math.PI;
        double r=sc.nextDouble();
        double area = r*r*pi;
        double length= 2*r*pi;
        System.out.printf ("%f %f\n", area,length);
        sc.close();
    }
}


Measured memory_bytes: 28072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		if(a==b)
			System.out.println(c);
		else if(a==c)
			System.out.println(b);
		else
			System.out.println(a);

	}
}


Measured memory_bytes: 23764
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int x = 0;
    int y = 0;
    int d = 0;
    
    for (int i=0; i<n; i++) {
      d = Integer.parseInt(s.substring(i,i+1));
      if (d == i % 2) {
        x++;
      }
      if (d == (i+1) % 2) {
        y++;
      }
    }
   
    System.out.println(Math.min(x,y));
  }
}

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

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++){
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  for (int i = 0; i < N; i++){
    cout << S.at(i);
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N,X,L,cnt,p;
  cin >> N >> X;
  for(cnt=1,p=0;cnt<=N;cnt++){
    cin >> L;
    p+=L;
    if(p>X)break;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

class UnionFind{
public:
	vector<int>T;
	vector<int>p;
	UnionFind(int n){
		T.resize(n);
		p.resize(n);
		for(int i=0;i<n;i++){
			p[i]=i;
		}
	}
	
	int getParent(int n){
		if(p[n]==n)return n;
		return getParent(p[n]);
	}
	bool isSame(int n,int m){
		return getParent(n)==getParent(m);
	}
	void unite(int n,int m){
		int rx=getParent(n);
		int ry=getParent(m);
		p[rx]=ry;
	}
};
	
int main(){
	init();
	UnionFind uf=UnionFind(13);
	uf.unite(1,3);
	uf.unite(1,5);
	uf.unite(1,7);
	uf.unite(1,8);
	uf.unite(1,10);
	uf.unite(1,12);
	uf.unite(4,6);
	uf.unite(4,9);
	uf.unite(4,11);
	
	ll x,y;cin>>x>>y;
	if(uf.isSame(x,y))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	int t=0;
	for(auto &i:a){
		cin>>i;
		t^=i;
	}
	for(auto i:a){
		cout<<(t^i)<<' ';
	}
	cout<<endl;
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define double long double
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = a; i < (int)(b); ++i)
#define all(x) x.begin(), x.end()
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;


int32_t main() {
    int h, w;
    cin >> h >> w;
    char m[h][w];
    int d[h][w];
    FOR(i, 0, h) {
        FOR(j, 0, w) {
            cin >> m[i][j];
            d[i][j] = 0;
        }
    }
    d[0][0] = 1;
    FOR(i, 0, h) {
        FOR(j, 0, w) {
            if (!i && !j) 
                continue;
            if (i && m[i - 1][j] == '.') {
                d[i][j] += d[i - 1][j];
                d[i][j] %= mod;
            }
            if (j && m[i][j - 1] == '.') {
                d[i][j] += d[i][j - 1];
                d[i][j] %= mod;
            }
        }
    }
    cout << d[h - 1][w - 1];
    return 0;
}

Measured memory_bytes: 12172
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC_107_B solver = new ABC_107_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC_107_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int h = in.nextInt();
            int w = in.nextInt();

            char[][] map = new char[h][w];
            for (int i = 0; i < h; i++) {
                String row = in.next();
                map[i] = row.toCharArray();
            }

            for (int i = 0; i < h; i++) {
                boolean isDeletable = true;
                for (int j = 0; j < w; j++) {
                    if (map[i][j] == '#') {
                        isDeletable = false;
                    }
                }

                if (isDeletable) {
                    for (int j = 0; j < w; j++) {
                        map[i][j] = ' ';
                    }
                }
            }

            for (int j = 0; j < w; j++) {
                boolean isDeletable = true;
                for (int i = 0; i < h; i++) {
                    if (map[i][j] == '#') {
                        isDeletable = false;
                    }
                }

                if (isDeletable) {
                    for (int i = 0; i < h; i++) {
                        map[i][j] = ' ';
                    }
                }
            }

            for (int i = 0; i < h; i++) {
                boolean blankLine = true;
                for (int j = 0; j < w; j++) {
                    if (map[i][j] != ' ') {
                        out.print(map[i][j]);
                        blankLine = false;
                    }
                }
                if (!blankLine) {
                    out.println();
                }
            }
        }

    }
}



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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in(), m = in();
    vpint v(m);
    rep(i, m)
    {
        cin >> v[i].fi >> v[i].se;
    }

    rep(i, 1000)
    {
        string s = to_string(i);
        if (s.length() != n)
            continue;
        bool ok = true;
        rep(j, m)
        {
            if (s.length() < v[j].fi)
            {
                ok = false;
                break;
            }
            if (s[v[j].fi - 1] != '0' + v[j].se)
            {
                ok = false;
                break;
            }
        }
        if (ok)
        {
            cout << i << endl;
            return;
        }
    }
    M1;
}

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


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

using namespace std;

#define nl '\n'

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

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

  vector<int> dp(n, -1);
  dp[0] = 0;
  dp[1] = abs(data[1] - data[0]);

  for (int i = 2; i < n; i++) {
    int minV = 1e9 + 7;
    for (int j = 1; j <= k; j++) {
      if (i < j) {
        break;
      }
      int temp = dp[i-j] + abs(data[i] - data[i-j]);
      if (temp < minV) {
        minV = temp;
      }
    }
    dp[i] = minV;
  }

  cout << dp[n-1] << nl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
typedef long long ll;
ll n;
string str, ans[4];
int main(void){
    // Your code here!
    cin >> n >> str;
    ans[0] += "SS", ans[1] += "SW", ans[2] += "WS", ans[3] += "WW";
    for (ll i = 0; i < 4; i++){
        bool res = true;
        for (ll j = 1; j < n - 1; j++){
            if ((str[j] == 'o' && ans[i][j] == 'S') || (str[j] == 'x' && ans[i][j] == 'W')){
                ans[i] += ans[i][j - 1];
            } else {
                ans[i] += (ans[i][j - 1] == 'S' ? 'W' : 'S');
            }
        }
        if ((ans[i][0] == 'S' && str[0] == 'o') || (ans[i][0] == 'W' && str[0] == 'x')){
            if (ans[i][1] != ans[i][n - 1]) res = false;
        } else {
            if (ans[i][1] == ans[i][n - 1]) res = false;
        }
        if ((ans[i][n - 1] == 'S' && str[n - 1] == 'o') || (ans[i][n - 1] == 'W' && str[n - 1] == 'x')){
            if (ans[i][0] != ans[i][n - 2]) res = false;
        } else {
            if (ans[i][0] == ans[i][n - 2]) res = false;
        }
        if (!res) continue;
        cout << ans[i] << endl;
        return 0;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 1024
n,k = map(int,input().split())
a = list(map(int,input().split()))
d2 = []
hist=[-1]*(n+1)
hist[0] = 0
cur = 1
d2.append(1)
st_idx = 0
rp_lgt = 1
for i in range(n):
  cur = a[cur-1]
  if hist[cur-1] >= 0 :
     d2.append(cur)
     st_idx = hist[cur-1]
     rp_lgt = i - st_idx + 1 
     break
  else:
    d2.append(cur)
    hist[cur-1] = i + 1
wk = k - st_idx
md = wk % rp_lgt
if k < st_idx:
  ans = d2[k]
else:
  ans = d2[md+st_idx]
print(ans)


Measured memory_bytes: 94972
program almost_everywhere_zero
  implicit none
  integer :: k, n, d, dp(0:1,0:100,0:4) = 0, i, j, l, m, u
  character(100) :: s
  read(*,'(a)') s
  read(*,*) k
  n = len_trim(s)
  dp(1,0,0) = 1
  do i = 1, n
    d = ichar(s(i:i))-48
    do j = 0, 1
      u = merge(d,9,j == 1)
      do l = 0, u
        do m = 0, k
          dp(merge(merge(1,0,l == d),0,j == 1),i,merge(m+1,m,l > 0)) = &
          & dp(merge(merge(1,0,l == d),0,j == 1),i,merge(m+1,m,l > 0))+dp(j,i-1,m)
        end do
      end do
    end do
  end do
  write(*,'(i0)') sum(dp(:,n,k))
end program almost_everywhere_zero

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


#define MAX 1000001
bitset<MAX> bs;
int n;
long int s[10001] = { 0 };

int main(){
	int it = 1;
	for (int i = 2; i < MAX; i++) {
		if (!bs[i]) {
			for (int j = i + i; j < MAX; j += i) {
				bs.set(j);
			}
			s[it] = s[it - 1] + i;
			it++;
			if (it > 10000) break;
		}
	}
	while (scanf("%d", &n), n != 0) {
		printf("%d\n", s[n]);
	}

	return 0;
}

Measured memory_bytes: 2900
#include<iostream>
#include<algorithm>
#include<stack>
#include<map>
#include<set> 
using namespace std;
int main(){
	int n,m;
	//cin>>n;
	int h[10];
	for(int i=0;i<=9;i++)
	cin>>h[i];
	sort(h,h+10);
	for(int i=9;i>=7;i--)
	cout<<h[i]<<endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  int l = 0, m = 0, h = 0;
  for (int i = 0; i < n; ++i)
  {
    int p;
    cin >> p;
    if (p <= a)
      l++;
    else if (p <= b)
      m++;
    else
      h++;
  }
  cout << min(l, min(m, h)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
typedef long long ll;

int n;
int q;
int s[10100];

int Search(int a[], int n, int key){
  int i = 0;
  a[n] = key;
  while(a[i] != key) i++;
  return i != n;
}

int main(){
  scanf("%d", &n);
  rep(i, n) scanf("%d", &s[i]);

  scanf("%d", &q);
  int cnt = 0;
  rep(i, q){
    int t;
    scanf("%d", &t);
    if(Search(s, n, t)) cnt++;
  }

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

  return 0;
}




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

int sw = 0;

void print(int A[], int N)
{
	for (int i = 0; i < N; i++){
		cout << A[i];
		if (i != N - 1)
			cout << " ";
	}
	cout << endl;
}

void sort(int A[], int N)
{
	int flag = 1;
	while (flag == 1){
		flag = 0;
		for (int j = N - 1; j > 0; j--){
			if (A[j] < A[j - 1]){
				swap(A[j], A[j - 1]);
				sw++;
				flag = 1;
			}
		}
	}
}

int main()
{
	int A[100], N;
	
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	sort(A, N);
	print(A, N);
	cout <<  sw << endl;

	return 0;
}

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

int memo[10]={},dp[11][331]={};

void dfs(int n,int depth,int sum){
	if(depth==n){
		dp[n][sum]++;
		return ;
	}
	for(int i=0;i<10;i++){
		if(!memo[i]){
			memo[i]=1;
			dfs(n,depth+1,sum+i*(depth+1));
			memo[i]=0;
		}
	}
}

int main(){
	int n,s;
	for(int i=1;i<11;i++)dfs(i,0,0);
	while(cin>>n>>s)
		cout<<(s<331?dp[n][s]:0)<<endl;
	return 0;
}

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

int func(int a, int b){
    if(a-b>0){
        swap(a,b);
    }
    if(b%a==0){
        return a;
    }else{
        return func(a,b%a);
    }
    

}



int main(){
    int n;
    cin>>n;
    int i,j,k,m,A,B;
    vector<int> sum(0);

    rep1(i,n){
        rep1(j,n){
            rep1(k,n){
                A=func(i,j);
                B=func(A,k);
                sum.push_back(B);
                
                

            }
        }
    }
    
    int ans=0;
    rep(m,sum.size()){
        ans=ans+sum[m];
    }

    cout<<ans<<endl;


}


Measured memory_bytes: 36288
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

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

int main()
{
  long long a, b, v, w, t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;

  if ((v * t) >= (w * t + abs(a - b)))
  {
    cout << "YES";
  }
  else
  {
    cout << "NO";
  }

  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    ll N;
    cin >> N;
    vecll A(N);
    for(auto& i : A) cin >> i;

    ll max = A.at(0), min = A.at(0);
    for(auto& i : A){
        if(i > max) max = i;
        if(i < min) min = i;
    }
    cout << max - min << endl;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextLong()
  val a = sc.nextLong()
  val b = sc.nextLong()

  val x = n / (a + b) * a
  val y = n % (a + b)
  val z = List(y, a).min

  println(x + z)
}


Measured memory_bytes: 25536
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n, v, p; long long m; cin >> n >> m >> v >> p;
  vector<long long> a(n); REP(i, n) cin >> a[i];
  sort(ALL(a));
  vector<long long> sum(a);
  FOR(i, 1, n) sum[i] += sum[i - 1];
  int ans = 0;
  REP(i, n) {
    if (a[i] >= a[n - p]) {
      ++ans;
      continue;
    }
    long long score = a[i] + m;
    int high = n - (lower_bound(ALL(a), score + 1) - a.begin());
    if (high >= p) continue;
    if (v <= p) {
      ++ans;
      continue;
    }
    int idx = lower_bound(ALL(a), a[i]) - a.begin();
    long long useful = m * idx;
    useful += score * (n - p - idx + 1) - (sum[n - p] - (idx > 0 ? sum[idx - 1] : 0));
    // cout << i << ' ' << score * (n - p - idx + 1) << ' ' << (sum[n - p] - (idx > 0 ? sum[idx - 1] : 0)) << ' ' << useful << '\n';
    useful -= m; // a[i] の分
    ans += useful >= m * (v - p);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
<?php
fscanf(STDIN, "%d", $N);
 
$ALPHA = range('a', 'z');
 
$name = '';
 
while (true) {
  $N--;
  $m = $N % 26;
  $N = (int) floor($N / 26);
  $name = $ALPHA[$m] . $name;
  if ($N < 1) break;
}
 
echo $name;


Measured memory_bytes: 16128
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 10000000000000000;
const int mod = 1000000007;
int test[12345678], kari[345678], aa[12345678];
signed main() {
	int n, a, b, ans; cin >> n >> a >> b;
	n++; cout << (n - a)*(n - b) << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main
{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		BigInteger n=new BigInteger("105");
		BigInteger []a=new BigInteger[n.intValue()];
		int t=scan.nextInt();
		for(int i=0;i<t;i++){
		    a[i]=scan.nextBigInteger();
		}
		BigInteger ans=a[0];
		for(int i=1;i<t;i++){
		    BigInteger k=ans.multiply(a[i]);
		    BigInteger g=ans.gcd(a[i]);
		    ans=k.divide(g);
		}
		System.out.println(ans);
	}
}


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

int main(){
    int n;
    cin >> n;
    vector<int> b(n-1);
    for(int i = 0; i < n-1; i++)    cin >> b[i];
    int ans = b[n-2];
    for(int i = n-2; i >= 1; i--){
        ans += min(b[i], b[i-1]);
    }
    ans += b[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,c = readline() |> split |> parseMap
	x = Array{Int}(2,n)
	for i in 1:n
		x[:,i] = readline() |> split |> parseMap
	end
	r = zeros(Int,n)
	l = zeros(Int,n)
	r[1] = x[2,1]-x[1,1]
	l[1] = x[2,n]-(c-x[1,n])

	for i in 2:n
		r[i] = r[i-1] + x[2,i] - (x[1,i] - x[1,i-1])
		l[i] = l[i-1] + x[2,n+1-i]-(x[1,n+2-i]-x[1,n+1-i])
	end
	mr = zeros(Int,n)
	ml = zeros(Int,n)
	mr[1] = r[1]
	ml[1] = l[1]
	for i in 2:n
		mr[i] = max(r[i],mr[i-1])
		ml[i] = max(l[i],ml[i-1])
	end
	maxim = max(mr[n],ml[n],0)
	for i in 1:n-1
		maxim = max(maxim, r[i]-x[1,i]+ml[n-i],l[i]-(c-x[1,n+1-i])+mr[n-i])
	end
	println(maxim)
end

main()


Measured memory_bytes: 157920
#include <iostream>
#include <queue>
using namespace std;
int w,h;
int g[21][21];
bool visited[21][21];
int moves[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
int count;
bool legal(int x, int y)
{
  if(visited[x][y]!=true&&0<=x&&x<h&&0<=y&&y<w&&g[x][y]==0)
    return true;
  else
    return false;
}

void dfs(int x,int y)
{
  visited[x][y]=true;
  count++;
  for(int i=0;i<4;i++)
  {
    int newx=x+moves[i][0];
    int newy=y+moves[i][1];
    if(legal(newx,newy))
    {
      dfs(newx,newy);
    }
  }
}

int main()
{
  while(1)
  {
    cin>>w>>h;
    if(w==0&&h==0) break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
      {
        g[i][j]=-1;
        visited[i][j]=false;
      }
    int psx,psy;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
      {
        char s;
        cin>>s;
        switch(s)
        {
          case '.':
            g[i][j]=0;break;
          case '#':
            g[i][j]=1;break;
          case '@':
            g[i][j]=2;psx=i;psy=j;break;
        }
      }
    count=0;
    dfs(psx,psy);
/*    int count=0;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
      {
        count+=visited[i][j];
      }
*/  cout<<count<<endl;

  }
}

Measured memory_bytes: 2992
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl

using namespace std;
using ll = long long;

int main() {

	vector<vector<int>> c(3, vector<int>(3));
	int a[3], b[3];

	REP(i, 3) REP(j, 3) cin >> c[i][j];
	a[0] = 0;
	a[1] = c[1][0] - c[0][0];
	a[2] = c[2][0] - c[1][0] + a[1];
	b[0] = c[0][0];
	b[1] = c[0][1] - c[0][0] + b[0];
	b[2] = c[0][2] - c[0][1] + b[1];

	REP(i, 3) REP(j, 3) if (a[i] + b[j] != c[i][j]) {
		cout << "No" NL;
		return 0;
	}

	cout << "Yes" NL;



	return 0;

}

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

int main() {
    long long a, b, n, ans = 0;
    scanf("%lld%lld%lld", &a, &b, &n);
    /*long long t = a * 10 < n ? a * 10 : n;
    for (int i = 1; i <= t; ++i) {
        long long tmp = floor(1.0 * a * i / b) - a * floor(1.0 * i / b);
        if(tmp > ans) ans = tmp;
    }
    printf("%lld", ans);*/
    long long t = n < b - 1 ? n : b - 1;
    printf("%lld", (long long)(floor(1.0 * a * t / b) - a * floor(1.0 * t / b)));
    return 0;
}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<ll> a;
    rep(i,n){
      ll x;
      cin>>x;
      if(i!=0 && a.back()==x) continue;
      a.push_back(x);
    }
    n=len(a);
    int cnt=0;
    int ans=0;
    rep(i,n){
      if(cnt==0){
        if(i+1<=n-1){
          if(a[i]<a[i+1]) cnt=1;
          else cnt=2;
        }
        continue;
      }
      if(cnt==1 && i+1<=n-1 && a[i]>a[i+1]){
        cnt=0;
        ans++;
        //cout<<i<<' '<<a[i]<<endl;
      }else if(cnt==2 && i+1<=n-1 && a[i]<a[i+1]){
        cnt=0;
        ans++;
        //cout<<' '<<i<<' '<<a[i]<<endl;
      }
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int n=sc.nextInt();//縦線の本数
				int m=sc.nextInt();//横線の本数
				int a=sc.nextInt();//調べる番号
				int[][] yoko=new int[n+1][1010];//今いる縦線と高さ＝移動先縦線
				if(n+m+a==0) {
					break;
				}
				for(int i=0; i<m; i++) {
					int h=sc.nextInt();
					int p=sc.nextInt();
					int q=sc.nextInt();
					yoko[p][h]=q;
					yoko[q][h]=p;
				}
				int now=a;
				for(int i=1000; i>=1; i--) {
					if(yoko[now][i]>0) {
						now=yoko[now][i];
					}
				}
				System.out.println(now);
				
			}

		}
	}
}


Measured memory_bytes: 68556
open System
let readInt () = stdin.ReadLine() |> int
let [A; B; C; X]= List.map (fun _ -> readInt()) [1..4]
let mutable cnt = 0
for a in 0..(min A (X / 500)) do
  let res1 = X - 500 * a
  for b in 0..(min B (res1/100)) do
    let res2 = res1 - 100 * b
    if (res2 % 50 = 0) && (res2 / 50 <= C) then cnt <- cnt + 1

printfn "%d" cnt

Measured memory_bytes: 12112