akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong sum(llong a) {
    return a * (a + 1) / 2;
}
llong x;

int main() {
    cin >> x;

    llong ans = 0;
    while (sum(ans) < x) ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)


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

    int k; cin >> k;
    vector<string> s(k);
    if(k <= 10){
        cout << k << endl;
        return 0;
    }
    s[9] = "10";
    s[10] = "11";
    for(int i = 10; i < k; ++i){
        string pres = s[i-1];
        bool flag = true;
        rep(j,pres.size()){
            if(pres[j] != '9') flag = false;
        }
        if(flag){
            s[i] = "1";
            rep(j,pres.size()) s[i].push_back('0');
            continue;
        }
        
        if(pres[pres.size()-1] == pres[pres.size()-2]+1 || pres[pres.size()-1] == '9'){ // 繰り上がり処理
            int cnt = pres.size()-1;
            while(cnt >= 1 && (pres[cnt] == pres[cnt-1]+1 || pres[cnt] == '9')) cnt--;
            pres[cnt]++;
            for(int j = cnt+1; j < pres.size(); ++j){
                if(pres[j-1] != '0') pres[j] = pres[j-1]-1;
                else pres[j] = '0';
            }
            s[i] = pres;
        }else{
            pres[pres.size()-1]++; 
            s[i] = pres; 
        }
        
    }
    cout << s[k-1] << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main()
{

  int N, flag, j, b, count;

  scanf("%d",&N);

  int a[N];

  for(j=0;j<N;j++){
    scanf("%d",&a[j]);
  }

  count = 0;
  flag = 1;
  
  while(flag){
    flag = 0;
    for(j=0;j<N;j++){
      if(a[j]<a[j-1]){
	b = a[j];
	a[j] = a[j-1];
	a[j-1] = b;
	flag = 1;
	count++;
      }
    }
  }

  for(j=0;j<N;j++){
    if(j==N-1) printf("%d\n",a[j]);
    else printf("%d ",a[j]);
  }

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

}



Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int main() {
	LL n, s;
	cin >> n >> s;
	if (n == s) {
		cout << n+1 << endl;
		return 0;
	}
	for (LL b = 2; b*b <= n; b++) {
		LL sum = 0;
		LL tmp = n;
		while (tmp > 0) {
			sum += tmp%b;
			tmp /= b;
		}
		if (sum == s) {
			cout << b << endl;
			return 0;
		}
	}
	if (n > s) {
		LL ans = 1LL << 60;
		for (LL p = 1; p*p <= n; p++) {
			if ((n - s) % p == 0) {
				LL b = (n - s) / p + 1;
				LL sum = 0;
				LL tmp = n;
				while (tmp > 0) {
					sum += tmp%b;
					tmp /= b;
				}
				if (sum == s) ans = min(ans, b);
			}
		}
		if (ans != 1LL << 60) {
			cout << ans << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define INF 1000000000
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define w(zz) int zz; cin>>zz; while(zz--)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
using namespace std;
int main(){
	fast();
	int n;cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(all(a));
	int cnt =0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			for(int k = j+1;k<n;k++){
				if(a[i]!=a[j] && a[j]!=a[k]){
					if(a[i]+a[j]>a[k]){
						cnt++;
					}
				}
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3620
def bounding(x, ls)
  count = 1
  pos = 0
  ls.each do |l|
    pos += l
    return count if x < pos
    count += 1
  end
  count
end

n, x = gets.split.map(&:to_i)
ls = gets.split.map(&:to_i)

puts bounding(x, ls)


Measured memory_bytes: 1788
N = int(input())
XL = [list(map(int,input().split())) for i in range(N)]

for i in range(N):
    XL[i].append(XL[i][0]+XL[i][1])
XL.sort(key=lambda x: x[2])

tmp = -1 * float('inf')
ans = 0
for X,L,right in XL:
    left = X-L
    if left >= tmp:
        tmp = right
        ans += 1
print(ans)

Measured memory_bytes: 31864
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

double dis_p(vector<int> x, vector<int>y, int p, int n){
    double sum = 0;
    for(int i=0; i<n; i++){
        sum += pow(abs(x[i]-y[i]), p);
    }
    return pow(double(sum), 1.0/double(p));
}


int main(){


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

    double D_man, D_eu, D_3, D_che;

    D_man = dis_p(x,y,1,n);
    D_eu = dis_p(x,y,2,n);
    D_3 = dis_p(x,y,3,n);

    // D_che
    int tmp=0;
    for(int i=0; i<n; i++){
        if(abs(x[i]-y[i])>tmp){
            tmp = abs(x[i]-y[i]);
        }
    }
    D_che = double(tmp);

    cout << fixed;
    cout << setprecision(6) << D_man << endl;
    cout << setprecision(6) << D_eu << endl;
    cout << setprecision(6) << D_3 << endl;
    cout << setprecision(6) << D_che << endl;


    return 0;
}



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

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

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;
const ll maxn=100000;

int main()
{		
	
   
    IOS
    
    ll n;
    cin>>n;
    vl a(n),b(n);
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }

    sort(b.begin(),b.end());
    if(a==b)
        {
            cout<<"YES"<<endl;
            return 0;
        } 
    for(ll i=0;i<n;i++)
    {
        for(ll j=i;j<n;j++)
        {
            swap(a[i],a[j]);
            if(a==b)
            {
                cout<<"YES"<<endl;
                return 0;
            }
            swap(a[i],a[j]);
        }
    }

    
        cout<<"NO"<<endl;
  

    
    



    
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
    public static void main(String args[]) throws IOException {
	
	int i,j,n,q,time=0,a;
	String c;
	String array[] = new String[100000];
	Scanner scan = new Scanner(System.in);
	Queue<Integer> que = new ArrayDeque<Integer>();
	Queue<String> ques = new ArrayDeque<String>();
	
	n = 2*scan.nextInt();
	q = scan.nextInt();
	
	for(i=0;i<n;i++){
	    array[i] = scan.next();
	}
	for(i=0;i<n;i+=2){
	    c = array[i];
	   ques.add(c);
	}
	for(i=1;i<n;i+=2){
	    a = Integer.parseInt(array[i]);
	    que.add(a);
	}
	
	i=1;
	while(true){
	    if(que.isEmpty()){break;}
	    //if(ques.isEmpty()){break;}
	    a = que.remove();
	    c = ques.remove();
	    if(a-q<=0){
		time += a;
		System.out.println(c+" "+time);
	    }
	    else {
		time += q;
		que.add(a-q);
		ques.add(c);
	    }
	}
	
    }
}



Measured memory_bytes: 79644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cassert>
using namespace std;
const char *str;
int parse(int i){
	if('0'<=str[i]&&str[i]<='9')return strtol(str+i,NULL,10)/2+1;
	assert(str[i]=='[');
	vector<int>v;
	int j=i,c=0;
	for(;;j++){
		if(str[j]=='[')if(++c==1)v.push_back(parse(j+1));
		if(str[j]==']')if(--c==-1)break;
	}
	sort(v.begin(),v.end());
	for(c=j=0;j<=v.size()/2;j++)c+=v[j];
	return c;
}
main(){
	int T;
	string data;
	for(cin>>T,getline(cin,data);T--;cout<<parse(1)<<endl)getline(cin,data),str=data.c_str();
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
//int 2×10の9乗
 
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ans=0;
  rep(i, n-2){
      if(p[i]<p[i+1] && p[i+1]<p[i+2]){
          ans++;
      }
      else if(p[i+2]<p[i+1] && p[i+1]<p[i]){
          ans++;
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//IOI 2021

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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 100 * 1000 + 17;

ll n, a[MAXN], b[MAXN], c[MAXN], sum, fir[MAXN], ans;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i], sum += a[i], fir[i] = a[i];
	for (int i = 1; i <= n; i++)
		cin >> b[i], sum -= b[i];
	if (sum < 0) {
		cout << -1 << endl;
		return 0;
	}
	iota(c + 1, c + n + 1, 1);
	sort(c + 1, c + n + 1, [](int i, int j) { return a[i] - b[i] > a[j] - b[j]; });
	int t = 1;
	for (int i = 1; i <= n; i++) {
		while (a[i] - b[i] < 0) {
			int tmp = min(b[i] - a[i], a[c[t]] - b[c[t]]);
			a[c[t]] -= tmp;
			a[i] += tmp;
			if (a[c[t]] - b[c[t]] == 0)
				t++;
		}
	}
	for (int i = 1; i <= n; i++)
		if (a[i] != fir[i])
			ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <cassert>
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

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

int main(int argc, char *argv[])
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];

  ll res = 0;

  ll s = 0;
  ll x = 0;
  int l = 0;
  int r = 0;
  while (r < N) {
    x ^= A[r];
    s += A[r];
    r++;
    while (l < r && x != s) {
      x ^= A[l];
      s -= A[l];
      l++;
    }
    res += r - l;
  }
  cout << res << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> PP;

int main(void){
	int n, m, l, a, b, d[100][100], e[100][100], f[100][101], i, j, k, x, y, z, mn;
	priority_queue<PP,vector<PP>,greater<PP> > que;
	while(1){
		scanf("%d%d%d",&n,&m,&l);
		if(n + m + l == 0) break;
		memset(d,-1,sizeof(d));
		memset(e,-1,sizeof(e));
		for(i = 0;i < m;i++){
			scanf("%d%d%d%d",&a,&b,&j,&k);
			d[a - 1][b - 1] = j;
			d[b - 1][a - 1] = j;
			e[a - 1][b - 1] = k;
			e[b - 1][a - 1] = k;
		}
		memset(f,-1,sizeof(f));
		f[0][l] = 0;
		que.push(PP(0,P(l,0))); // 敵との合流回数 お金 町の番号
		while(que.size()){
			x = que.top().first, y = que.top().second.first, z = que.top().second.second;
			que.pop();
			for(i = 0;i < n;i++){
				if(d[z][i] != -1){
					if(y >= d[z][i] && (f[i][y - d[z][i]] == -1 || f[i][y - d[z][i]] > f[z][y])){
						que.push(PP(x,P(y - d[z][i],i)));
						f[i][y - d[z][i]] = x;
					}
					if(f[i][y] == -1 || f[i][y] > x + e[z][i]){
						que.push(PP(x + e[z][i],P(y,i)));
						f[i][y] = x + e[z][i];
					}
				}
			}
		}
		mn = 0x7FFFFFFF;
		for(i = 0;i <= l;i++)
			if(f[n - 1][i] != -1) mn = min(mn,f[n - 1][i]);
		printf("%d\n",mn);
	}
	return 0;
}

Measured memory_bytes: 1640
import java.util.Scanner;

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

        int N = sc.nextInt();

        int A[] = new int[N];
        int minj, tmp, count = 0;

        for(int i = 0; i < N; i++)
            A[i] = sc.nextInt();

        for(int i = 0; i < N; i++) {
            minj = i;
            for (int j = i; j < N; j++) {
                if (A[j] < A[minj])
                    minj = j;
            }
            if (i != minj) {
                tmp = A[i];
                A[i] = A[minj];
                A[minj] = tmp;
                count++;
            }
        }
        System.out.print(A[0]);
        for(int i = 1; i < N; i++)
            System.out.print(" " + A[i]);
        System.out.println();
        System.out.println(count);
        sc.close();
    }
}



Measured memory_bytes: 26368
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

int A, B;

int main(int argc, char **argv) {
    std::cin >> A >> B;

    if (A <= 5) {
        std::cout << 0 << std::endl;
    } else if (A <= 12) {
        std::cout << B / 2 << std::endl;
    } else {
        std::cout << B << std::endl;
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for (int i=0; i<N; i++) cin >> x[i];
  vector<int> y(N);
  for (int i=0; i<N; i++) cin >> y[i];

  double d1 = 0, d2 = 0, d3 = 0, d = 0;
  for (int i=0; i<N; i++) {
    d1 += abs(x[i] - y[i]);
    d2 += pow(abs(x[i] - y[i]), 2);
    d3 += pow(abs(x[i] - y[i]), 3);
    d = max(d, double(abs(x[i] - y[i])));
  }
  d2 = sqrt(d2);
  d3 = cbrt(d3);

  printf("%.5f\n%.5f\n%.5f\n%.5f\n", d1, d2, d3, d);

  return 0;
}



Measured memory_bytes: 3376
#D-Face Produces Unhappiness
N, K = map(int, input().split())
S = str(input())
S_index = [S[i]+S[i+1] for i in range(0,N-1)]

count_LRorRL =0
count_LRorRL += S_index.count('LR')
count_LRorRL += S_index.count('RL')

count_LLorRR = 0
count_LLorRR += S_index.count('LL')
count_LLorRR += S_index.count('RR')

if count_LRorRL > 2*K:
    print(count_LLorRR+2*K)
else:
    print(count_LLorRR+count_LRorRL)

Measured memory_bytes: 9588
# ABC125b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    if (v[i] - c[i] > 0):
        ans += v[i] - c[i]
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> s = a;
  sort(s.rbegin(), s.rend());
  rep(i,n) {
    int ans = s[0];
    if (s[0] == a[i]) ans = s[1];
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

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

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    string s, t;
    int n;
    cin >> n >> s >> t;
    int i = 0, j = 0;
    string ans = "";
    while (i < n) {
        ans += s[i];
        ans += t[i];
        i++, j++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int r, d;
    ll x;
    cin >> r >> d >> x;
    rep(i, 10) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (auto &e: p) cin >> e;

    int ans = 0;
    for (int i = 1; i < n-1; ++i) {
        if ((p[i-1] < p[i] && p[i] < p[i+1]) ||
            (p[i-1] > p[i] && p[i] > p[i+1])) ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s,t;
int dp[3002][3002];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i=n,j=m;
    string ans="";
    while(i>0 && j>0){
        if(dp[i][j]>dp[i-1][j] && dp[i][j]>dp[i][j-1]){
            ans+=s[i-1];
            i--;
            j--;
        }
        else {
            if(dp[i-1][j]>=dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s;
  cin >> s;
  ll n = s.size();

  for (char c = 'a'; c <= 'z'; c++) {
    for (ll i = 0; i < n; i++) {
      if (c == s[i]) break;
      if (i == n - 1) {
        cout << c << endl;
        return 0;
      }
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  cin >> s;
  string sf;
  string ss;
  if(n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  if(s.substr(0, n/2) == s.substr(n/2, n/2)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
use io::*;
use std::*;

fn solve(a: i64, b: i64) {
    let x = format!("{}{}", a, b).parse::<i32>().unwrap();
    let y = {
        let n = (x as f64).sqrt().floor() as i32;
        n * n
    };
    let ans = if x == y {"Yes"} else {"No"}.to_string();
    println!("{}", ans);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut a: i64;
    a = scanner.next();
    let mut b: i64;
    b = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(a, b)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 8572
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int a, b;
    bool okay = true;
    string s;
    cin >> a >> b; cin >> s;
    if(!(all_of(s.cbegin(), s.cbegin() + a, ::isdigit))) okay = false;
    if(s[a] != '-') okay = false;
    if(!(all_of(s.cbegin() + a + 1, s.cend(), ::isdigit))) okay = false;
    cout << (okay ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
//java 11.0.1 2018-10-16 LTS

import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//標準入力からテキストを読み取る
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();

		//処理を行う
		int ret = 0;
		for(int i = 0; i < n-2; i++){
			if(s.substring(i, i+3).equals("ABC")){
				ret++;
			}
		}
		
		//標準出力に出力する
		System.out.println(ret);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

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

  int n;
  string s;
  cin >> n >> s;

  int mx = 0;
  int offset = 0;

  for(int i = 1; i <= n/2; i++) {
    bool find = false;
    for(int j = offset; j+i+i <= n; j++) {
      for(int k = j+i; k+i <= n; k++) {
        bool isOk = true;
        rep(x, i) {
          if(s[j+x] != s[k+x]) {
            isOk = false;
            break;
          }
        }
        if(isOk) {
          find = true;
          break;
        }
      }
      if (find) {
        break;
      } else {
        offset++;
      }
    }
    if (!find) {
      break;
    } else {
      mx = i;
    }
  }
  
  cout << mx << endl;
}


Measured memory_bytes: 384
fun main(args: Array<String>?): Unit {
    while (true) {
        val (x, y) = readLine()?.trim()?.split(' ')?.map{Math.abs(it.toInt())}?.sorted() ?: return
        println(if (x != 0) (x / 2 * 2) + (y / 2 * 2) + Math.max(x % 2, y % 2) else if (y != 1) y + y % 2 else 1)
    }
}


Measured memory_bytes: 32168
#include <iostream>
#include <string>

int main(void)
{
  std::string word;
  std::cin >> word;
  int f_word, s_word;
  
  if (word[0] == word[1]) {
    f_word = 1;
    s_word = (word[2] == word[3]) && !(word[2] == word[0]);
  } else if (word[0] == word[2]) {
    f_word = 1;
    s_word = (word[1] == word[3]) && !(word[1] == word[0]);
  } else if (word[0] == word[3]) {
    f_word = 1;
    s_word = (word[1] == word[2]) && !(word[1] == word[0]);
  }
  
  if (f_word && s_word) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

#define pi (3.14159265358979323846)

int main()
{
    double A, B, H, M;

    cin >> A >> B >> H >> M;

    double dig_h = (pi / 6.0) * H + (pi / 360.0) * M;
    double dig_m = (pi / 30) * M;

    double theta = dig_h - dig_m;

    double x = sqrt(B * B + A * A - 2 * A * B * cos(theta));

    cout << fixed << setprecision(15) << x;


    return 0;
}

Measured memory_bytes: 4292
# coding: utf-8

import sys
input = sys.stdin.readline

def f4(n, h, a):
    bit = [0] * (n + 1)

    def getmax(h):
        x = h - 1
        m = 0
        while x != 0:
            if m < bit[x]:
                m = bit[x]
            x -= x & -x
        return(m)

    def update(h, v):
        x = h
        while x <= n:
            if bit[x] < v:
                bit[x] = v
            x += x & -x

    for i in range(1, n + 1):
        m = getmax(h[i])
        update(h[i], m + a[i])
    return(max(bit))

n = int(input()) # 1 <= n <= 2 x 10^5
h = [0] + list(map(int, input().split()))
a = [0] + list(map(int, input().split()))

print(f4(n, h, a))


Measured memory_bytes: 35936
module Main where

import Control.Applicative
import Numeric

main :: IO()
main = loop

loop :: IO()
loop =do
  {[h, w] <- getInts
  ; if h == 0 && w == 0 then done
    else do
     {putStrLn $ unlines $ checkerboard h w
     ; loop
     }
  }
  
firstLine :: Int -> String
firstLine n = take n (cycle "#.")

secondLine :: Int -> String
secondLine n = take n (cycle ".#")

checkerboard :: Int -> Int -> [String]
checkerboard h w = take h (cycle [firstLine w, secondLine w])
          
--

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO()
putInts = putStrLn . unwords . map show

getDoubles :: IO[Double]
getDoubles = map read . words  <$> getLine

putDoubles :: [Double] -> IO()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""

done :: IO()
done = return ()



Measured memory_bytes: 4228
def hantei_s(n, string_a):
    midle = int(n / 2)
    #print(midle)
    if string_a[0:midle] == string_a[midle:]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    n = int(input())
    string_a = input()
    hantei_s(n, string_a)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=int (a);i<int (n);i++)
#define OUT  freopen("output.txt", "w", stdout)
#define IN  freopen("input.txt", "r", stdin)
#define mem(a,b) memset((a),(b),sizeof(a))
#define NumofDigits(n) ((int)log10(n)+1)
#define NumofBits(n) ((int)log2(n)+1)
#define PI 3.14159265358979323846264
#define vii vector<pair<int,int>>
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi  vector<int>
#define nl  cout<<"\n"
#define pb  push_back
#define mp  make_pair
#define ll  long long 
#define ss  second 
#define ff  first
#define endl "\n"
#define sp  " "
using namespace std;
	
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int t=1; //cin>>t;
while(t--)
{
	
  ll n,cnt=0,d; cin>>n>>d;
  while(n--){
  	ll a,b;cin>>a>>b;
  	if((a*a+b*b)<=(d*d))cnt++;
  }
 	cout<<cnt;
  
}

}


Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var a = ria().Sum();
		Console.WriteLine(a >= 22 ? "bust": "win");
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
#include <stdio.h>

int main(void) {
  int n, x;
  int i, j, k;

  while(1) {
    int cnt = 0;
    scanf("%d %d", &n, &x);

    if(n == 0 && x == 0) break;

    for(i=1; i<=n; ++i) {
      for(j=1; j<=n; ++j) {
        if(i == j) continue;
        for(k=1; k<=n; ++k) {
          if(i == k || j == k) continue;
          if(i+j+k == x) cnt++;
        }
      }
    }
    printf("%d\n", cnt/6);
  }

  return 0;
}



Measured memory_bytes: 2116
import std.stdio, std.string, std.array, std.conv, std.container, std.algorithm;

void main() {
    int[] tmp = readln.chomp.split.to!(int[]);
    int n = tmp[0], m = tmp[1];
    long[] a = readln.chomp.split.to!(long[]);
    BinaryHeap!(long[]) h = heapify(a);
    foreach (i; 0 .. m) {
        long f = h.front / 2;
        h.removeFront;
        h.insert(f);
    }
    h.sum.writeln;
}

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

int n;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    for (char c: s) {
        n += c-'0';
    }
    if (n%9 == 0) {
        cout << "Yes";
    }else
        cout << "No";
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];

bool dp[5002][5002] = {};

signed main(){
	IOS;
	ll n, k;
	cin >> n >> k;
    vec<ll> a(n + 1);   
    ll sum = 0;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }
    a[n] = 0;
    if(sum < k){
        dump(n);
        return 0;
    }
    sort(ALL(a),greater<ll>());
    ll left = 0, right = n;
    ll mid;
    while(right - left > 1){
        Fill(dp,false);
        dp[0][0] = true;
        mid = (right + left) / 2;
        for(int i = 0;i < n;i++){
            for(int j = 0;j < k;j++){
                if(i == mid)dp[i + 1][j] = dp[i][j];
                else {
                    dp[i + 1][j] = dp[i][j];
                    if(j >= a[i])dp[i + 1][j] |= dp[i][j - a[i]];
                }
            }
        }
        bool ok = false;
        for(int j = max(k - a[mid],(ll)0);j < k;j++)if(dp[n][j])ok = true;
        if(ok)left = mid;
        else right = mid;
    }
    left++;
    dump(n - left);
}

Measured memory_bytes: 24704
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int sm=1000;
		for(int i=1;i<s.length()-1;i++){
			int tmpi;
			char tmpc[] = {s.charAt(i-1),s.charAt(i),s.charAt(i+1)};
			String tmps = new String(tmpc);	
			tmpi = Integer.parseInt(tmps);
			if(sm>Math.abs(753-tmpi)){
				sm = Math.abs(753-tmpi);
			}
		}
		System.out.println(sm);
	}
}


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

#define ll long long

using namespace std;

ll l, r;
int main() {
    cin >> l >> r;
    if (!l || r - l + 1 >= 2019) {
        cout << 0;
        return 0;
    }
    ll m = 2019;
    for (ll i = l; i < r; ++i)
        for (ll j = i + 1; j <= r; ++j)
            m = min(m, (i * j) % 2019);

    cout << m;
    return 0;
}


Measured memory_bytes: 256
import re
def end():
    print('UNRESTORABLE')
    exit()

s = input()
t = input()

l_s = len(s)
l_t = len(t)

if l_t > l_s:
    end()

for i in range(l_s - l_t +1):
    target = s[l_s-i-l_t:l_s-i]
    count = 0
    for s1, s2 in zip(target, t):
        if s1 == s2 or s1 == '?':
            count += 1
            if count == l_t:
                ans = re.sub('\?','a',s)
                print(ans[:l_s-i-l_t]+t+ans[l_s-i:])
                exit()
        else:
            break
end()




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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length()-1;i++){
        if(s[i]==s[i+1] ){
           if(i==0){
               cout<<"1 2"<<endl;
               ans=1;
           }
           else if(i==s.length()-2){
            cout<<s.length()-2<<' '<<s.length()<<endl;
               ans=1;
           }
           else{
            cout<<i+1<<' '<<i+3<<endl;
             ans=1;
           }
           break;
        }
        if(i==s.length()-2) break;

        else if(s[i]==s[i+2]){
            cout<<i+1<<' '<<i+3<<endl;
            ans=1;
            break;
        }
    }
    if(!ans){
        cout<<"-1 -1"<<endl;
    }
    return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int dp[40001];

int main() {
    int n, q, a[20], m[200];
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    cin >> q;
    for (int i = 0; i < q; ++i)
        cin >> m[i];
    
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 40000; j >= 0; --j) {
            if (dp[j]) {
                dp[j + a[i]] = 1;
            }
        }
    }

    for (int i = 0; i < q; ++i) {
        cout << (dp[m[i]] ? "yes" : "no") << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,a,b;
int main(){
	n=read();a=read();b=read();
	if(a>b||n<2&&a!=b){puts("0");return 0;}
	printf("%lld\n",1LL*a+1LL*(n-1)*b-1LL*b-1LL*(n-1)*a+1);
	return 0;
}

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

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

#define REP(i,n) for(ll 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

// 300, 15min

ll C[3][3] = {};

signed main()
{
    REP(i, 3) { REP(j, 3) { cin >> C[i][j]; } }

    // a0 の max を求める
    ll a0_max = 0;
    REP(i, 3) { a0_max = max(a0_max, C[0][i]); }

    for(ll a0 = 0; a0 <= a0_max; ++a0) {
        // b が確定する
        ll b0 = C[0][0] - a0;
        ll b1 = C[0][1] - a0;
        ll b2 = C[0][2] - a0;
        // a1 と a2 も正しくできるか判定
        ll a1 = C[1][0] - b0;
        if(C[1][1] == a1 + b1 && C[1][2] == a1 + b2) {
            ll a2 = C[2][0] - b0;
            if(C[2][1] == a2 + b1 && C[2][2] == a2 + b2) {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
import Data.List                                                                                                                                      
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  getLine                                                                                                                                             
  bs <- map read . words <$> getLine                                                                                                                  
  putStrLn $ case solve [(bs,[])] of                                                                                                                  
    Nothing -> "-1"                                                                                                                                   
    Just x -> init $ unlines $ map show x                                                                                                             
                                                                                                                                                      
                                                                                                                                                      
solve :: [([Int],[Int])] -> Maybe [Int]                                                                                                               
solve [] = Nothing                                                                                                                                    
solve (([],ps):_) = Just ps                                                                                                                           
solve ((xs,ps):xss) =                                                                                                                                 
  let check = filter (\(x,y) -> x==y) $ zip xs [1..]                                                                                                  
  in if null check                                                                                                                                    
     then solve xss                                                                                                                                   
     else solve $ (map fst $ delete (last check) (zip xs [1..]), (:ps) . fst $ last check) : xss 

Measured memory_bytes: 1020
import sys
input = sys.stdin.readline

def lcs(a, b):
	return a * b // gcd(a,b)

def gcd(a, b):
	if a % b == 0:
		return b
	else:
		return gcd(b, a%b)

def f(a, b, c):
	leftc = a + (c - a % c) % c
	if leftc > b:
		s = 0
	else:
		rightc = b - b % c
		s = (rightc - leftc) // c + 1
	return s

def main():
	a, b, c, d = map(int, input().strip().split())
	n = b-a+1
	s = f(a, b, c)
	t = f(a, b, d)
	u = f(a, b, lcs(c, d))
	# print(n,s, t, u)
	print(n - (s + t - u))

if __name__ == '__main__':
	main()


Measured memory_bytes: 38384
#include <iostream>
//#include <string>
#include <algorithm>
//#include <functional>
//#include <array>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
	int a,b;
	//char a[110];
	//bool flag = true;
	cin >> a >> b;
	/*for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] == 'Y') {
			flag = false;
		}
	}
	if (flag) {
		cout << "Three" << endl;
	}
	else {
		cout << "Four" << endl;
	}
	*/
	
	int res = max({ a + b,a - b,a * b });
	cout << res << endl;
	return 0;

}


Measured memory_bytes: 256
s = input()
kw = "keyence"
# print(kw[len(kw)-3:])
l = len(s)
if kw in s:
    pos = s.find(kw)
    if pos == 0 or pos == len(s)-6-1:
        print("YES")
else:
    if (s[0:1] == "k") and (s[l-6:]=="eyence"):
        print("YES")
    elif (s[0:2] == "ke") and (s[l-5:]=="yence"):
        print("YES")
    elif (s[0:3] == "key") and (s[l-4:]=="ence"):
        print("YES")
    elif (s[0:4] == "keye") and (s[l-3:]=="nce"):
        print("YES")
    elif (s[0:5] == "keyen") and (s[l-2:] == "ce"):
        print("YES")
    elif (s[0:6] == "keyenc") and (s[l-1:]=="e"):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{   int n,ans=0;
    scanf("%d",&n);
    int h[n];
    for(int i=0;i<n;i++)scanf("%d",&h[i]);
    int max=0;
    for(int i=0;i<n;i++){
        if(max<=h[i]){
            ans++;
            max=h[i];
        }
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int t=0,p[1000];
void push(int a){
  p[++t]=a;
}
int pop(){
  t--;
  return p[t+1];
}
int main(){
  int x,y;
  char q[100];
  while(scanf("%s",q)!=EOF){
    if(q[0]=='+'){
      x=pop();
      y=pop();
      push(y+x);
    }
    else if(q[0]=='-'){
      x=pop();
      y=pop();
      push(y-x);
    }
    else if(q[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else{
      push(atoi(q));
    }
  }
  printf("%d\n",pop());
  return 0;
}



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

int main(){
  long long a,b,k;
  cin>>k>>a>>b;
  long long ans;
  if(k<a)
    ans=k+1;
  else{
    if(a+2>=b)
      ans=k+1;
    else{
      k -= (a-1);
      ans=(k/2)*b-(k/2-1)*a+k%2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
#define mp make_pair
int main()
{
	std::ios::sync_with_stdio(false);
	int n,a[105],i,ans=0;
	cin>>n;
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=1;i<n;i++)
	{
		if(a[i]==a[i-1])
		{
			a[i]=0;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:[usize;a],
    }
    let b:usize=b.iter().sum();
    println!("{}",if b%2==0{"YES"}else{"NO"})
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

bool check(ll n, ll x) {
    if (x == 0) return false;
    return n % x == n / x;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (check(n, i)) {
                ans += i;
            }
            ll x = n / i - 1;
            if (x != i && check(n, x)) {
                ans += x;
            }
                
        }
    }
    cout << ans << endl;
    /*
    for (ll i = 1; i <= n; i++) {
        if (n % i == n / i) {
            cout << n / i << " " << i << endl;
            cout << n / (i + 1) * i + n / (i + 1) << endl;
            ans -= i;
        }
    }
    dump(ans);
    //*/
    return 0;
}


Measured memory_bytes: 256