akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集 

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
int x; cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3644
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import ceil

h, w = map(int, readline().split())
s = [input() for i in range(h)]
dp = [[float('inf')] * w for j in range(h)]
if s[0][0] == '#':
    dp[0][0] = 1
else:
    dp[0][0] = 0
for i in range(h):
    for j in range(w):
        if w - 1 != j:
            cnt = 0
            if s[i][j + 1] != s[i][j]:
                cnt += 1
            dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cnt)
        if h - 1 != i:
            cnt = 0
            if s[i + 1][j] != s[i][j]:
                cnt += 1
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cnt)
print(ceil(dp[-1][-1] / 2))


Measured memory_bytes: 3188
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 2000000001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; ll M; cin >> N >> M;
    ll lm = 1;
    ll data[N];
    F0R(i, N) {
        ll cur; cin >> cur; data[i] = cur;
        ll g = __gcd(lm, cur);
        lm = lm * cur / g;
        if (lm >= MX) {
            cout << 0 << endl; return 0;
        }
    }

    ll res = lm / 2;
    F0R(i, N) {
        if (res % data[i] != data[i] / 2) {
            cout << 0 << endl; return 0;
        }
    }

    ll ans = M / lm;
    ll val = M % lm;
    if (val >= lm / 2) ans++;
    cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) begin(v), end(v)
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,b) FOR(i,0,b)

const int mod = 1e9+7;

int h,w,a,b,ans;
int d[100010];
int fact[500010],inv_fact[500010];

int mod_fact(int n,int mod){
  if(n==0)return 1;
  return mod_fact(n-1,mod)*n%mod;
}

int mod_pow(int x,int k,int mod){
  if(k==0)return 1;
  if(k==1)return x;
  int ret = 1;
  while(k){
    if(k&1)ret=ret*x%mod;
    x=x*x%mod;
    k>>=1;
  }
  return ret;
}

int mod_comb(int n,int r,int mod){
  int a=(fact[n+r]*inv_fact[r])%mod;
  //FOR(i,0,r)a=a*((n-i)%mod)%mod;
  int b=inv_fact[n]%mod;
  return ((a*b%mod))%mod;
}

signed main(){
  cin>>h>>w>>a>>b;

  fact[0]=fact[1]=1;

  for(int i=2;i<h+w;i++){
    fact[i]=(fact[i-1]*i)%mod;
  }
  for(int i = 0;i<h+w;i++){
    inv_fact[i]=mod_pow(fact[i],mod-2,mod);
  }



  for(int i=b;i<w;i++){
    int temp=((fact[i+h-a-1]*inv_fact[i]%mod)*inv_fact[h-a-1])%mod;
    temp = mod_comb(h-a-1,i,mod);
    //temp = (temp*((((fact[a+w-i-2]*inv_fact[a-1])%mod)*inv_fact[w-i-1])%mod))%mod;
    temp *= mod_comb(w-i-1,a-1,mod)%mod;
    ans=(ans+temp)%mod;
  //  cout<<ans<<endl;
  }
  cout<<ans<<endl;




  return 0;
}


Measured memory_bytes: 5888
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        int add = a+b;
        int sub = a-b;
        int mul = a*b;
        System.out.println(Math.max(Math.max(add, sub), mul));

    }
}

Measured memory_bytes: 21844
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())printf("%d ",v[_]);cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

int n;
vi in;
int dp[3010][3010][2];
int f(int l,int r,int a){
	if(l>r)return 0;
	if(dp[l][r][a]-inf)return dp[l][r][a];
	int t1=f(l+1,r,a^1)+(a?-in[l]:in[l]);
	int t2=f(l,r-1,a^1)+(a?-in[r]:in[r]);
	if(a)return dp[l][r][a]=min(t1,t2);
	else return dp[l][r][a]=max(t1,t2);
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>n;
	in=vi(n);
	rep(i,n)cin>>in[i];
	rep(i,3010)rep(j,3010)rep(k,2)
		dp[i][j][k]=inf;
	cout<<f(0,n-1,0)<<endl;

}


Measured memory_bytes: 142080
import itertools

N,C=map(int,input().split())

D=[None]*C
for i in range(C):
    D[i]=list(map(int,input().split()))

c=[None]*N
for i in range(N):
    c[i]=list(map(int,input().split()))

c_0=[]
c_1=[]
c_2=[]

for i in range(N):
    for j in range(N):
        if (i+j+2)%3==0:
            c_0+=[c[i][j]]
        elif (i+j+2)%3==1:
            c_1+=[c[i][j]]
        else:
            c_2+=[c[i][j]]

clist_0=[0]*(C+1)
clist_1=[0]*(C+1)
clist_2=[0]*(C+1)

for i in c_0:
    clist_0[i]+=1
for i in c_1:
    clist_1[i]+=1    
for i in c_2:
    clist_2[i]+=1



L=[]
for i in range(C):
    L+=[i+1]

ROOP=list(itertools.permutations(L,3))


ANS=float("inf")


for i in range(len(ROOP)):
    IWA=0
    for j in range(1,C+1):
        IWA+=D[j-1][ROOP[i][0]-1]*clist_0[j]+D[j-1][ROOP[i][1]-1]*clist_1[j]+D[j-1][ROOP[i][2]-1]*clist_2[j]
        
    if ANS>IWA:
        ANS=IWA

print(ANS)

Measured memory_bytes: 9616
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    map<ll,int> dic;
    dic[0]=1;
    
    ll sum=0, cnt=0;
    rep(i,N){
        ll x; cin>>x;
        sum+=x;
        cnt+=dic[sum];
        dic[sum]++;
    }
    cout1(cnt)
}

Measured memory_bytes: 12800
A, B = map(int, input().split())


def calc(x):
    x += 1
    res = 0
    for i in range(40):
        p = 1 << (i + 1)
        cnt = (x // p) * (p // 2) + max(0, (x % p) - (p // 2))
        if cnt % 2 == 1:
            res += 1 << i
    return res


ans = calc(B) ^ calc(A - 1)
print(ans)


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

int main(){
  double n;
  cin >> n;
  double x = floor(n / 1.08);
  if(floor(x * 1.08) == n) cout << (int) x << endl;
  else if(floor((x+1) * 1.08) == n) cout << (int) x + 1<< endl;
  else cout << ":(" << endl;
  return 0;
}

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

int main() {
	int r,c;
	while(1) {
	scanf("%d %d\n",&r,&c);
	if(r==0&&c==0) break;
	for(int i=0;i<r;i++) { 
		for(int j=0;j<c;j++) {
			printf("#");
		}
    printf("\n");	
	}
	printf("\n");
	}
}


Measured memory_bytes: 2580
"use strict"
function main(arg) {
      
    let aaa = arg.trim().split("\n")[0];

    let gohyaku = parseInt(aaa / 500);

    let goen = parseInt((aaa -  (gohyaku * 500)) / 5);




    console.log((gohyaku * 1000) + (goen * 5));

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>

using namespace std;

#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {
    set<int> s;
    vector<int> v(3);
    for(int i=0; i<3; i++) {
        cin >> v[i];
        s.insert(v[i]);
    } 
    if(s.size() == 2) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	vector <lld> occupied(100002ll, 0ll);

	lld n; cin >> n;
	for4(i, 0ll, n, 1ll) {
		lld l, r; cin >> l >> r;
		occupied[l] += 1ll; occupied[r + 1] -= 1ll;
	}

	for4(i, 1ll, 100002ll, 1ll) {
		occupied[i] += occupied[i - 1];
	}

	lld ANS = 0ll;
	for (auto i : occupied) {
		if (i) ANS++;
	}

	cout << ANS;
	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3916
import sys

def solve():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    S = [input().strip("\n") for _ in range(H)]
    D = ((-1, 0), (0, -1), (1, 0), (0, 1))
    for h in range(H):
        possible = True
        for w in range(W):
            if S[h][w] == "#":
                for dh, dw in D:
                    if 0 <= h+dh < H and 0 <= w+dw < W and S[h+dh][w+dw] == "#":
                        break
                else:
                    possible = False
                    break
        if not possible:
            print("No")
            break
    else: print("Yes")


    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
char s[maxn];
int ans;
vector<int> a;

int main(){
    scanf("%s",s+1);
    int n=strlen(s+1);
    for(int i=1;i<=n;i++){
        int j=i;
        while(j<=n&&s[i]==s[j])++j;
        j--;
        a.push_back(j+1-i);
        i=j;
    }
    n=(int)a.size();
    for(int i=0;i<n;i++){
        if(a[i]==0)continue;
        if(a[i]==1){
            ans++;
            continue;
            }
        if(a[i]==2){
            ans+=(i!=n-1?2:1);
            if(i+1<n)a[i+1]--;
            continue;
        }
        ans+=((a[i]/3)*2);
        a[i]%=3;
        if(a[i]==1){
            ans++;
            continue;
            }
        if(a[i]==2){
            ans+=(i!=n-1?2:1);
            if(i+1<n)a[i+1]--;
            continue;
        }
    }
    printf("%d\n",ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 1528
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;


template <class T, class U>
ll euclid_gcd(T a, U b){
    if(a < b)return euclid_gcd(b,a);
    ll r;
    while((r = a%b)){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll t; cin >> t;
    vector<ll> a(t),b(t),c(t),d(t);
    rep(i,t)cin >> a[i] >> b[i] >> c[i] >> d[i];
    bitset<n_max> ans(0);
    rep(i,t){
        
        if(d[i] % b[i] == 0){
            ans[i] = (a[i] >= b[i] && a[i]%b[i] <= c[i]);
            // debug(a[i]);debug(a[i]%b[i]);
        }
        else if(d[i] < b[i]){
            ans[i] = 0;
        }
        else{
            ll step = d[i] % b[i];
            ll f = a[i] % b[i];
            ll g = euclid_gcd(b[i], step);
            ll jud = b[i] - (g - f%g);
            if(jud == b[i])jud -= step;
            ans[i] = (jud <= c[i] && a[i] >= b[i] && f <= c[i]);
        }
    }
    rep(i,t)cout << (ans[i] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int i,j,k,n,m,s;
	while(scanf("%d %d",&n,&m) != EOF){
		k=1;
		s=n+m;
		if(s==0) k=0;
		while(s>=10) {
			s=s/10;
			k++;
		}
		printf("%d\n",k);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    int a;
    cin >> a;
    if (a>=30)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

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

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

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
    }

    cout << dp[n - 1] << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
    ll n, q;    cin >> n >> q;
    string s;   cin >> s;
    vector<ll> ac(n, 0);
    FOR(i, 1, n){
        ac[i] = ac[i-1]; 
        if(s[i-1]=='A' && s[i]=='C') ac[i] += 1;
    }
    REP(i, q){
        ll st, ed;  cin >> st >> ed;
        st--; ed--;
        cout << ac[ed]-ac[st] << endl;
    }
}


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

int main() {
	string s, t;
	cin >> s >> t;
	sort(all(s));
	sort(all(t));
	reverse(all(t));
	
	if(s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

const int MAXX = 101000;
bool isPrime[MAXX];
vector<int> Pr;

void sieve(){
    rep(i,MAXX) isPrime[i] = true;
    isPrime[0] = isPrime[1] = false;
    for(int i=2;i*i<MAXX;i++){
        if(!isPrime[i]) continue;
        for(int j=i*i;j<MAXX;j+=i){
            isPrime[j] = false;
        }
    }
    rep(i,MAXX) if(isPrime[i]) Pr.push_back(i);
}

int main(){
    sieve();
    while(true){
        int n,p;
        cin >> n >> p;
        if(n == -1) break;
        int start = upper_bound(all(Pr),n) - Pr.begin();
        int cal = 0;
        int ret;
        vector<int> kouho;
        for(int i=start;;i++){
            for(int j=start;j<=i;j++){
                cal++;
                if(cal == 10*p){
                    goto end;
                }
                kouho.push_back(Pr[i] + Pr[j]);
            }
        }
    end:
        sort(all(kouho));
        cout << kouho[p-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1420
// G - Longest Path
// O(n * m)

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back

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

const ll inf = 1e15L;
const int maxn = 123456;
int indeg[maxn], vis[maxn];
std::vector<int> G[maxn];
set<pii>s;
int dist[maxn];

void topo(){
    while(!s.empty()){
        pii u = *(s.begin());
        // vis[u.fi] = 1;
        s.erase(s.begin());
        for(auto v: G[u.fi]){
            // if(!vis[v]){
                dist[v] = max(dist[v], dist[u.fi] + 1);
                indeg[v]--;
                if(!indeg[v])s.insert({v, u.se+1});
            // }
        }
    }
}

int main(){
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, x, y;
    cin >> n >> m;
    for (int i = 0; i <= n; ++i)
    {
        G[i].clear();
    }
    s.clear();
    memset(dist, 0, sizeof(dist));
    memset(indeg, 0, sizeof(indeg));
    memset(vis, 0, sizeof(vis));
    for (int i = 0; i < m; ++i)
    {
        cin >> x >> y;
        G[x].pb(y);
        indeg[y]++;
    }
    for (int i = 1; i <= n; ++i)
    {
        if(!indeg[i])s.insert({i, 0});
    }
    int res = 0;
    topo();
    for(int i = 1; i <= n; ++i)res = max(res, dist[i]);
    cout << res << endl;    
    return 0;

}

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

int main() {
  string s, t;
  cin >> s >> t;
  int i;
  vector<char> change_s;
  vector<char> change_t;
  for (i = 0; i < s.length(); i++) {
    change_s.push_back(s.at(i));
  }
  for (i = 0; i < t.length(); i++) {
    change_t.push_back(t.at(i));
  }
  sort(change_s.begin(), change_s.end());
  sort(change_t.begin(), change_t.end());
  bool result = true;
  for (i = 0; i < min(s.length(), t.length()); i++) {
    if (change_s.at(i) < change_t.at(t.length() - 1 - i)) {
      cout << "Yes" << endl;
      return 0;
    } else if (change_s.at(i) != change_t.at(t.length() - 1 - i)) {
      result = false;
    }
  }
  if (s.length() < t.length() && result) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

void solve() {

    int n, m, v, p;
    SI(n);
    SI(m);
    SI(v);
    SI(p);
    vl rec(n);
    REP(i, n) {
        SL(rec[i]);
    }
    sort(rec.begin(), rec.end());
    ll sum = 0;
    ll target = rec[n-p];
    REP(i, n-p+1) {
        sum += rec[i];
    }
    int rans = 0;
    if(v > p-1) {
        v = v-(p-1);
        REP(i, n-p+1) {
            bool flag = true;
            flag &= (target - rec[i]) <= m;
            ll all = (ll)m * v;
            ll magic1 = (rec[i] + m) * (n-p+1-i);
            ll magic2 = sum + all;
            flag &= magic1 >= magic2;
            if(!flag) {        
                rans = i+1;
            } else break;
            if(v > 1) v--;
            sum -= rec[i];
        }
    } else {
        REP(i, n-p+1) {
            if (target - rec[i] <= m) {
                break;
            } else {
                rans = i+1;
            }
        }
    }
    printf("%d\n", n-rans);
}

void init() {
    


}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long a,b;
long long Gcd(long long a,long long b){
	if(b==0){
		return a;
	}
	return Gcd(b,a%b);
}
int main(){
	cin>>a>>b;
	cout<<a*b/Gcd(a,b);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	string t;
	int count = 0;
	cin >> s >> t;

	for (int i = 0; i < 3; i++)		if (s[i] == t[i])	count++;
  
	cout << count << endl;
	return 0;
}

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

using namespace std;

int64_t divisors(int64_t a) {
  int64_t ret = 0;
  while (a % 2 == 0) {
    a /= 2;
    ret++;
  }
  return ret;
}

int64_t calc(const std::vector<int64_t>& as) {
  int64_t ret = 0;
  for (auto a : as) {
    ret += divisors(a);
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int64_t> as(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> as[i];
  }
  std::cout << calc(as) << std::endl;
  return 0;
}


Measured memory_bytes: 384
def main():
    N = int(input())
    v = [int(x) for x in input().split()]
    while len(v) > 1:
        v.sort()
        a = v[0]
        b = v[1]
        v.pop(0)
        v.pop(0)
        new = (a + b) / 2
        v.append(new)
    print(v[0])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main() {
   int n;
   cin>>n;
   
   long long a,maxV=0;
   for(int i=1;;i++){
      if(i*i>n){
          cout<<(i-1)*(i-1)<<endl;
          break;
      }
   }
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
int n,i;
scanf("%d",&n);
i=n%10;
if(i==3)
{
printf("bon\n");
}
else if(i==0||i==1||i==6||i==8)
{
printf("pon\n");
}
else printf("hon\n");
}

Measured memory_bytes: 1664
#include<iostream>
#include<string.h>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

#define inf 0x3f3f3f3f
#define N




int main()
{
	std::ios::sync_with_stdio(false);
    long long k,minn;
    while(cin>>minn>>k)
    {
        if(minn%k)
        {
            minn=minn%k;
        while(abs(minn-k)<minn)
        {
            minn=abs(minn-k);
        }
        }
        else
            minn=0;
        cout<<minn<<endl;
    }
	return 0;
}


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

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

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, 26) rep(j, 15) {
        if ( n - i * 4 - j * 7 == 0 ) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

typedef long long llong;
using namespace std;

int main() {
	int N, T, A;
	double Tx[1100];
	int Hinp;
	cin >> N;
	cin >> T >> A;

	for (int i = 0; i < N; i++) {
		cin >> Hinp;
		Tx[i] = (double)T - (double)(Hinp*0.006);
	}


	double mingap = 1000000000000;
	int pos_min;
	double gap;

	for (int i = 0; i < N; i++) {
		if (Tx[i] <= A)gap = A - Tx[i];
		else gap = Tx[i] - A;
		if (gap < mingap) {
			pos_min = i;
			mingap = gap;
		}
	}
	cout << pos_min + 1 << endl;


	return 0;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int,input().split()))
A = [B[0]]+(B)

cnt = 0
for a,b in zip(A[:-1],B):
    #print(a,b)
    if a > b:
        cnt += b
    else:
        cnt += a
cnt += A[-1]
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main() {
  double n,m,d;
  double ans;
  cin >> n >> m >> d;
  
  if(d == 0){
    ans = (m-1)/n;
  }
  else{
    ans = (2*(n-d)*(m-1))/(n*n);
  }
  cout << fixed << setprecision(15);
  co(ans);
}

Measured memory_bytes: 256
def main():
    s = input()
    rem = [0] * 2019  # the count of the each remainder: 0 ~ 2018
    rem[0] = 1  # why? can't understand.

    temp = 0
    digit = 1
    for i, c in enumerate(s[::-1]):
        # No time to pow.
        temp += int(c) * digit
        rem[temp % 2019] += 1
        digit *= 10
        digit %= 2019

    return sum(c * (c - 1) // 2 for c in rem)


if __name__ == '__main__':
    print(main())


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

int main() {
  string S,T;
  cin >> S >> T;
  if(S == T){
    cout << "No" << endl;
    return 0;
  }
  int X = S.size(),Y = T.size();
  vector<char>a(X),b(Y);
  for(int i=0; i<X; i++){
    a[i] = S[i];
  }
  for(int i=0; i<Y; i++){
    b[i] = T[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  int Z = min(X,Y);
  bool ok = true;
  for(int i=0; i<Z; i++){
    if((int)a[i] == (int)b[i]){
      continue;
    }
    else if((int)a[i] < (int)b[i]){
      cout << "Yes" << endl;
      return 0;
    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  if(ok && X<Y){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3596
{-# LANGUAGE MultiWayIf        #-}

import Data.List
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Control.Monad
import Control.Monad.ST

--添え字　N以下決定,i文字目,7,5,3の存在
type DP s = STUArray s (Bool,Int,Bool,Bool,Bool) Int

modifyArray :: (MArray a e m ,Ix i) => a i e -> i -> (e -> e) -> m ()
modifyArray arr i f =  readArray arr i >>= writeArray arr i . f

dp_i :: DP s -> (Int,Int) -> ST s ()
dp_i dparr (i,c) = do
  forM_ [False,True] $ \exist7 ->
    forM_ [False,True] $ \exist5 ->
      forM_ [False,True] $ \exist3 ->
        forM_ [False,True] $ \lower -> do
          a <- readArray dparr (lower,i,exist7,exist5,exist3)
          let add7T = modifyArray dparr (True,i+1,True,exist5,exist3) (+a)
              add5T = modifyArray dparr (True,i+1,exist7,True,exist3) (+a)
              add3T = modifyArray dparr (True,i+1,exist7,exist5,True) (+a)
              add7F = modifyArray dparr (False,i+1,True,exist5,exist3) (+a)
              add5F = modifyArray dparr (False,i+1,exist7,True,exist3) (+a)
              add3F = modifyArray dparr (False,i+1,exist7,exist5,True) (+a)
          if lower then add7T >> add5T >> add3T
            else if | c > 7  -> add7T >> add5T >> add3T
                    | c == 7 -> add7F >> add5T >> add3T
                    | c == 6 -> add5T >> add3T
                    | c == 5 -> add5F >> add3T
                    | c == 4 -> add3T
                    | c == 3 -> add3F
                    | c < 3  -> return ()

solve :: String -> ST s Int
solve n = do
  let ln = length n
      ans' k = 3^k - 3*2^k + 3 --k(<=ln-1)桁の七五三数のカウント
  dparr <- newArray ((False,0,False,False,False),(True,ln,True,True,True)) 0
  writeArray dparr (False,0,False,False,False) 1
  forM_ (zip [0..ln-1] n) $ \(i,c) -> dp_i dparr (i,(read [c] :: Int))
  ls <- forM [False,True] $ \lower -> readArray dparr (lower,ln,True,True,True)
  return $ (sum ls) + (sum $ map ans' [3..ln-1])

main :: IO ()
main = do
  s <- getLine
  print $ runST $ solve s


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
  bool operator==(const mint rhs) const { return x == rhs.x; }
  bool operator!=(const mint rhs) const { return x != rhs.x; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<mint> F(s+5,0);
  F[0] = 2;
  if (a[0] <= s) F[a[0]] = 1;
  for (int i = 1; i < n; ++i) {
    for (int j = s; j >= 0; --j) {
      F[j] *= 2;
      if (j-a[i] >= 0) F[j] += F[j-a[i]];
    }
  }
  cout << F[s] << endl;
  return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
struct pr{int f,nw,cnt;};

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<vector<int>>v(n+1);
	for(int i=0;i<m;++i){
		int a,b; cin>>a>>b;
		v.at(a).emplace_back(b);
		v.at(b).emplace_back(a);
	}
	vector<pair<int,int>>a(n+1,{1e9,1e9}); a.at(1)={0,0};
	queue<pr>q; q.push({-1,1,0});
	while(q.size()){
		pr tmp=q.front(); q.pop();
		int f=tmp.f,nw=tmp.nw,cnt=tmp.cnt;
		for(auto&&i:v.at(nw)){
			if(cnt+1<a.at(i).second){
				a.at(i).first=nw,a.at(i).second=cnt+1;
				q.push({nw,i,cnt+1});
			}
		}
	}
	bool yes=true;
	for(int i=2;i<a.size();++i){
		if(a.at(i).first==1e9)yes=false;
	}
	if(yes){
		cout<<"Yes\n"s;
		for(int i=2;i<a.size();++i){
			cout<<a.at(i).first<<"\n"s;
		}
		
	}else cout<<"No\n"s;
}

Measured memory_bytes: 11412
n, x = map(int, input().split())
a = list(map(int, input().split()))
rs = 0
for i in range(1, n):
  if a[i] + a[i - 1] > x:
    toDel = min(a[i], a[i] + a[i - 1] - x)
    a[i] -= toDel
    rs += toDel
  if a[i] + a[i - 1] > x:
    toDel = min(a[i - 1], a[i] + a[i - 1] - x)
    a[i - 1] -= toDel
    rs += toDel
print(rs)

Measured memory_bytes: 14252
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

#define amen ;
#define vec vector
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()
#define int long long
typedef long long ll;
typedef double d;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;
typedef unsigned int ui;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int l, r;
    cin >> l >> r;
    if (r - l > 5000)
    {
        cout << 0;
    }
    else
    {
        int res = 2019;
        for (int i = l; i < r; i++)
        {
            for (int j = i + 1; j <= r; j++)
            {
                res = min(res, i * j % 2019);
            }
        }
        cout << res;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            fi = False
            fj = False
            for ss in s:
                ss = int(ss)
                if not fi and ss == i:
                    fi = True
                    continue
                if fi and not fj and ss == j:
                    fj = True
                    continue
                if fj and ss == k:
                    ans += 1
                    break
print(ans)


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

public class Main {
  public static void main (String[] args) {
    ArrayList<Integer> perfectPowers = new ArrayList<Integer>();
    
    perfectPowers.add(1);
    
    for (int b = 2; b <= 1000; ++b) {
      int perfectPower = b * b;

      while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      }
    }

    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int X = in.nextInt();
      int maxPerfectPower = Integer.MIN_VALUE;
      
      for (int i = 0; i < perfectPowers.size(); ++i) {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      }

      System.out.println(maxPerfectPower);
    }
  }
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll N, C, K;
vector<ll> A;

signed main()
{
    queue<ll> que;

    cin >> N >> C >> K;
    A = vector<ll>(N, 0);
    REP(i, N) {
        cin >> A[i];
    }
    SORT(A);
    REP(i, N) {
        que.push(A[i] + K);
    }

    ll ans = 0;

    while(!que.empty()) {
        ll time = que.front();
        que.pop();
        ans++;
        // バスに乗せられるだけ乗せる
        REP(i, C - 1) {
            if(que.empty()) { break; }
            if(que.front() - K <= time) { que.pop(); }
            else { break; }
        }
    }

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll k;
    string s;
    cin >> k >> s;
    if(s.size() > k){
        string ss = s.substr(0, k);
        cout << ss << "..." << endl;
    }else{
        cout << s << endl;
    }
    return 0;
}

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

int main(){
  string S;
	cin >> S;
	int res = 1000;
	for(int i = 0;i < S.length() -2;i++){
		int a = stoi(S.substr(i,3));
		int kari = abs(753 - a);
		if(res > kari){
			res = kari;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
N, T = map(int, input().split())
num_list = input().split()
num_list = [int(x) for x in num_list]

count = 0
profit = 0
min_val = num_list[0]

for num in num_list:
    if num < min_val:
        min_val = num
    elif num - min_val == profit:
        count += 1
    elif num - min_val > profit:
        count = 1
        profit = num - min_val

print(count)


Measured memory_bytes: 14252
import sys
import numpy as np
from heapq import heappop, heappush

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(C, H, W, S, T, K):
    INF = 10**18
    N = H * W
    q = [5 * S]
    dist = np.full((5 * N), INF, np.int64)
    dist[5 * S] = 0
    move = [0, 1, -1, W, -W]
    B = 5 * N + 10
    while q:
        x = heappop(q)
        dist_x, x = divmod(x, B)
        if dist_x > dist[x]:
            continue
        v, d = divmod(x, 5)
        if d == 0:
            # どちらかに進む
            for i in range(1, 5):
                w = v + move[i]
                y = 5 * w + i
                dist_y = dist_x + 1
                if C[w] and dist_y < dist[y]:
                    dist[y] = dist_y
                    heappush(q, B * dist_y + y)
        else:
            # 直進する
            if dist_x % K != 0:
                w = v + move[d]
                y = 5 * w + d
                dist_y = dist_x + 1
                if C[w] and dist_y < dist[y]:
                    dist[y] = dist_y
                    heappush(q, B * dist_y + y)
            # 止まって向きを変える権利を得る
            y = 5 * v
            dist_y = dist_x + (-dist_x) % K
            if dist_y < dist[y]:
                dist[y] = dist_y
                heappush(q, B * dist_y + y)
    x = dist[5 * T]
    if x == INF:
        return -1
    return dist[5 * T] // K

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(b1[:],i8,i8,i8,i8,i8)')(main)
    cc.compile()
    exit()
from my_module import main

H, W, K = map(int, readline().split())
x1, y1, x2, y2 = map(int, readline().split())

C = np.zeros((H + 2, W + 2), np.bool_)
C[1:-1, 1:-1] = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W] == b'.'
C = C.ravel()
H += 2
W += 2

S = W * x1 + y1
T = W * x2 + y2

print(main(C, H, W, S, T, K))


Measured memory_bytes: 145144
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void solve(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string res="";
    int dx = abs(tx - sx);
    int dy = abs(ty - sy);
    //res += 'U'*dy + 'R'*dx + 'D'*dy + 'L'*dx;
    REP(i, dy) res += 'U';
    REP(i, dx) res += 'R';
    REP(i, dy) res += 'D';
    REP(i, dx) res += 'L';
    //res += 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D';
    res += 'L';
    REP(i, dy+1) res += 'U';
    REP(i, dx+1) res += 'R';
    res += 'D';
    //res += 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U';
    res += 'R';
    REP(i, dy+1) res += 'D';
    REP(i, dx+1) res += 'L';
    res += 'U';
    cout << res << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#define int long long 
#define mod 1000000007
using namespace std;

signed main(){
//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t;cin>>t;
int a[t],b[t],n =t,flag =0;
for(int i=0;i<n;i++){

	cin>>a[i]>>b[i];
	
}
for(int i=0;i+2<n;i++){
	if(a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2] ) {
		flag =1 ;
		cout<<"Yes"<<endl;
		break;
	}
}
if(flag == 0) cout<<"No"<<endl;




}





Measured memory_bytes: 3632
sd = gets.chomp
t  = gets.chomp

j = 0
index = -1
sd.size.times do |i|
    j = i
    r = true
    t.each_char do |c|
      unless sd[j] == c || sd[j] == "?"
          r = false
          break
      end
      j += 1
    end
    if r
        index = i
    end
end

if index==-1
    puts "UNRESTORABLE"
else
  sd[index..(index+t.size-1)] = t
  puts sd.gsub("?","a")
end

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<stack>

#define int long long
#define all(x) x.begin(), x.end()
#define forn(i, x) for(int i = i; i < x; ++i)

using namespace std;

int INF = 1e16 + 7;

void solve() {
    string s, t;
    cin >> s >> t;
    int ans = INF;
    for (int i = 0; i <= s.size() - t.size(); ++i) {
        int a = 0;
        for (int j = i; j < i + t.size(); ++j) {
            a += s[j] != t[j - i];
        }
        ans = min(a, ans);
    }
    cout << ans;
}

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

    cout << setprecision(10) << fixed;

    solve();

    return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
int main(void){
  int n,i,j,ac=0,wa=0,tle=0,re=0;
  scanf("%d",&n);
  char str[n][10];
  for(i=0;i<n;i++){
    scanf("%s",str[i]);
  }
  for(i=0;i<n;i++){
    if(str[i][0]=='A'){
      ac++;
    }else if(str[i][0]=='W'){
      wa++;
    }else if(str[i][0]=='T'){
      tle++;
    }else if(str[i][0]=='R'){
      re++;
    }
  }
  printf("AC x %d\n",ac);
  printf("WA x %d\n",wa);
  printf("TLE x %d\n",tle);
  printf("RE x %d\n",re);
  return 0;
}

Measured memory_bytes: 2696
a = []
a = input()
f = len(a)






if a[f-1] == "3":
  print("bon")
elif a[f-1] == "0" or a[f-1] == "6" or a[f-1] == "1" or a[f-1] == "8":
  print("pon")
else:
  print("hon")

Measured memory_bytes: 9088
N,M=map(int,input().split())
C = [0]*(N+1)
D = []
for i in range(M):
  P,Y=map(int,input().split())
  D.append([i,P,Y])
#  D=順序、県番号、生まれた年
D.sort(key=lambda x:x[2])
for i in range(M):
  P = D[i][1]
  R = C[P] + 1
  C[P] = R
  st = '{0:06d}'.format(P)
  st = st + '{0:06d}'.format(R)
  D[i] = [D[i][0],st]
D.sort(key=lambda x:x[0])
for i in range(M):
  print(D[i][1])

Measured memory_bytes: 31436
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

struct pl {
    bool operator()(const pll &a, const pll &b) {
        return a.first * a.second < b.first * b.second;
    }
};

int main(void)
{
    IOS
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n),f(n);
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> f[i];
    sort(ALL(a));
    sort(RALL(f));
    ll ng = -1, ok = a.back() * f.front();
    ll jump = ok / 2;

    auto isok = [&](ll &x){
        bool ret = true;
        ll k2 = k;
        REP(i,a.size()) {
            ll c = a[i] * f[i] - x;
            if (c > 0) {
                // if (c % f[i] == 0) k2 -= c / f[i];
                // else k2 -= c / f[i] + 1;
                k2 -= ceil(static_cast<double>(c) / f[i]);
                if (k2 < 0) {
                    ret = false;
                    break;
                }
            }
        }
        return ret;
    };

    ll cnt = ok - jump;
    while(ng +1 < ok) {
        jump /= 2;
        if (jump == 0) jump = 1;
        if (isok(cnt)) {
            ok = cnt;
            cnt -= jump;
        } else {
            ng = cnt;
            cnt += jump;
        }
        cerr << ng << " " << ok << endl;
    }
    
    cout << ok << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    scanf("%d",&n);
    cout << (n * (n-1) / 2) - (n / 2) << "\n";
    for(int i = 1;i <= n;i++)
        for(int j = 1;j < i;j++)
            if(i + j != (n | 1)) printf("%d %d\n",i,j);
}

Measured memory_bytes: 256