akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve(){
    int a, b, c, d;
    cin >> a >> b>> c >> d;
    cout << min(a, b) + min(c, d) << "\n";
}

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

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main {
  def main(args: Array[String]) {
    val alphabets = Array.fill[Int](128)(0)
    stdin.getLines.foreach { _.foreach {
      char => alphabets(char.toLower) += 1
    }}

    for (i <- 'a' to 'z') {
      println(i + " : " + alphabets(i))
    }
  }
}



Measured memory_bytes: 44672
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System;

class Prog
{
    public static void Main(string[] args)
    {
        new Prog().Solve();
    }

    int N, M;
    long K;
    long[] AAdd, BAdd;

    

    void Solve(){
        var nmk = Console.ReadLine().Split(' ');
        N = int.Parse(nmk[0]);
        M = int.Parse(nmk[1]);
        K = long.Parse(nmk[2]);

        AAdd = new long[N];
        BAdd = new long[M];
        var As = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var Bs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        AAdd[0] = As[0];
        BAdd[0] = Bs[0];
        for (int i = 1; i < As.Length;i++){
            AAdd[i] = AAdd[i - 1] + As[i];
        }
        for (int i = 1; i < Bs.Length;i++){
            BAdd[i] = BAdd[i - 1] + Bs[i];
        }

        List<long> Score = new List<long>();
        Score.Add(0);
        (int, int) AB = (N, 0);

        AB.Item1 = serch(K, AAdd);
        while(AB.Item1 >= 0 && AB.Item2 < M){
           
                AB.Item2 = serch(K - AAdd[AB.Item1], BAdd);
                Score.Add(AB.Item1 + AB.Item2 + 2);
                AB.Item1 --;
                AB.Item2++;
        }
        AB.Item2 = serch(K, BAdd);
        Score.Add(AB.Item1 + AB.Item2 + 2);
        Console.WriteLine(Score.Max());
        Console.ReadKey();
    }

    int serch(long target,long[] pool){
        int ok = -1;
        int ngmax = pool.Length;
        while(Math.Abs (ok - ngmax) > 1){
            int mid = (ok + ngmax) / 2;
            if(pool[mid] <= target){
                ok = mid;
            }else {
                ngmax = mid;
            }
        }
        return ok;
    }
}

public struct Vector2
{
    public Vector2(double x, double y)
    {
        this.@this = new double[] { x, y };
    }


    public double[] @this;

    public double x
    {
        get
        {
            return @this[0];
        }
        set
        {
            @this[0] = value;
        }
    }

    public double y
    {
        get
        {
            return @this[1];
        }
        set
        {
            @this[1] = value;
        }
    }

    public double magnitude { get { return Math.Pow(sqrMagnitude, 1 / 2); } }

    public double sqrMagnitude { get { return Math.Pow(x, 2) + Math.Pow(y, 2); } }

    public Vector2 normalized { get { return this * (1 / this.magnitude); } }

    public static Vector2 operator +(Vector2 a, Vector2 b)
    {
        return new Vector2(a.x + b.x, a.y + b.y);
    }

    public static Vector2 operator -(Vector2 a, Vector2 b)
    {
        return new Vector2(a.x - b.x, a.y - b.y);
    }

    public static Vector2 operator *(Vector2 a, double b)
    {
        return new Vector2(a.x * b, a.y * b);
    }


    public static Vector2 operator /(Vector2 a, double b)
    {
        if (b == 0)
        {
            throw new DivideByZeroException();
        }
        else return new Vector2(a.x / b, a.y / b);
    }

    public bool Equals(Vector2 other)
    {
        return (@this[0] == other.@this[0] && @this[1] == other.@this[1]);
    }

}

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

int main() {
char c;
cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
}

Measured memory_bytes: 3564
object Main extends App {
  val src: List[Int] = io.Source.stdin.getLines.map(_.toInt).toList

  val countedList: List[Int] = (for (i <- 1 to src.max) yield (src.count(_ == i))).toList

  println(countedList.zipWithIndex.collect { case (a, b) if a == countedList.max => b + 1 }.mkString("\n"))
}

Measured memory_bytes: 43804
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
string names;

string karuta[100100];
int main() {
    string N;
	cin >> N;
	for (int i = 0; i < 3; i++) {
		if (N[i] == N[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s, t;
    cin >> s >> t;

    int slen = s.size();
    int tlen = t.size();
    string ans;
    rep(i, 0, 100) {
        ans += 'x';
    }
    bool flag = false;;
    if (slen < tlen) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    } else {
        for (int i = 0; i <= slen - tlen; i++) {
            bool match = true;
            for (int j = 0; j < tlen; j++) {
                if (s[i + j] != '?' && s[i + j] != t[j]) {
                    match = false;
                    break;
                }
            }
            if (match) {
                flag = true;
                string s2 = s;
                for (int k = 0; k < tlen; k++) {
                    if (s2[i + k] == '?') s2[i + k] = t[k];
                }
                for (int l = 0; l < slen; l++) {
                    if (s2[l] == '?') s2[l] = 'a';
                }
                ans = min(ans, s2);
            }
        }
    }
    if (flag) cout << ans << endl;
    else cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
int main() {
 
    int n;
    cin >> n;
    ll sum = 0;
    for (ll i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;
 
    return 0;
 
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
const int Max=0x7fffffff;
const int P=1000000007;
using namespace std;
struct node{
int s,e;
}p[55];
int dot[55],g=0;
int found(int x)
{
 if(x!=dot[x])
    dot[x]=found(dot[x]);
 return dot[x];
}
void fun(int ii)
{
    int ss=found(p[ii].s);
    int ee=found(p[ii].e);
    if(ss==ee) return ;
    dot[ss]=ee;
    g++;
}
int main()
{
    int N,M,l=0;
    scanf("%d%d",&N,&M);
    for(int i=1;i<=M;i++)
    {
        scanf("%d %d",&p[i].s,&p[i].e);
    }
    for(int i=1;i<=M;i++)
    {
        g=0;
        for(int k=1;k<=N;k++)
            dot[k]=k;
        for(int j=1;j<=M;j++)
        {
            if(j==i)continue;
            fun(j);
            if(g==N-1) break;
        }
        if(g<N-1)l++;
    }
    printf("%d\n",l);
    return 0;
}

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

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
ll MOD = 1000000007;
ll F[100001] = { 0 };

void f(ll n) {
	repe(i, 1, n) {
		F[i] = F[i - 1] * i % MOD;
	}
}

int main()
{
	ll N, M; cin >> N >> M;
	if (N - M > 1 || M - N > 1) {
		cout << 0 << endl;
		return 0;
	}
	F[0] = 1;
	F[1] = 1;
	f((M > N) ? M : N);

	ll T;
	if (M == N) {
		T = ((F[M] * F[M] % MOD) * 2 % MOD);
	}
	else {
		T = (F[N] * F[M] % MOD);
	}

	cout << T << endl;

	return 0;
}

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

typedef long long ll;
long long a[200001];
long long n, k;
long long f(long long s, long long t) {
  if (s > 0 && t > 0) {
    return (t - 1) / s + 1;
  } else if (s < 0 && t < 0) {
    s *= -1;
    t *= -1;
    return t / s;
  } else if (t <= 0) {
    return abs(t) / s * -1;
  } else {
    return (t - 1)/ s - 1;
  }
}
long long count(long long v) {
  long long ret = 0;
  for (int i=0; i<n; i++) {
    if (a[i] == 0) {
      if (v <= 0) {
        auto it = lower_bound(a + i + 1, a + n, -1e9);
        ret += a + n - it;
      }
    } else if (a[i] > 0) {
      auto it = lower_bound(a + i + 1, a + n, f(a[i], v));
      ret += a + n - it;
    } else {
      auto it = upper_bound(a + i + 1, a + n, f(a[i], v));
      ret += it - (a + i + 1);
    }
  }
  return ret;
}

int main() {
  cin>>n>>k;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a, a + n);
  long long l = -1e18, r = 1e18 + 1;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    long long tmp = count(mid);
    if (tmp >= n * (n - 1) / 2 - k + 1) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout<<l<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	int A,B;
	cin >> A >> B;

	int OK = 1;

	string S;
	cin >> S;

	rep(i, S.size()) {
		if (i != A) {
			if (S[i] < 48 || 57 < S[i]) OK = 0;
		}
		else {
			if (S[i] != 45) OK = 0;
		}
	}
	if (OK) co("Yes");
	else co("No");

	Would you please return 0;
}

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

int main(){
    vector<ll> v;
    ll n;
    cin >> n;
    
    v.push_back(3);
    v.push_back(5);
    v.push_back(7);
    for(int i=0; i<9; i++){
        int last = v.size();
        for(int j=0; j<last; j++){
            ll a = v[j] * 10;
            v.push_back(a+3);
            v.push_back(a+5);
            v.push_back(a+7);
        }
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
    }
    int cnt = 0;
    auto N = string::npos;
    for(int i=0; i<v.size(); i++){
        if(v[i] > n) break;
        string s = to_string(v[i]);
        if(s.find("3") != N && s.find("5") != N && s.find("7") != N) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;


int main() {
	int A, B;
	cin >> A >> B;
    if(A <= 10){
      cout << B + 100*(10-A) <<endl;
    }
    else{
      cout << B <<endl;
    }
	return 0;
}


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

int main(void){
    int n,m;cin >>n >> m;
    priority_queue<ll>q;
    for(int i=0;i<n;i++){
        ll tmp; cin >> tmp;
        q.push(tmp);
    }
    for(int i=0;i<m;i++){
        ll tmp = q.top();q.pop();
        tmp = tmp/2;
        q.push(tmp);
    }
    
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll tmp = q.top();q.pop();
        ans +=  tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
def battle(x, y):
    if x > y:
        return x - y
    elif x == y:
        return x
    else:
        return y - x

N = int(input())
A = [int(input()) for _ in range(2 ** N)]
for i in range(N):
    K = len(A)
    tmp = []
    for j in range(0, K, 2):
        tmp.append(battle(A[j], A[j+1]))
    A = tmp
print(A[0])


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int t1 = h1*60 + m1;
  int t2 = h2*60 + m2;
  int d = t2-t1-k;
  cout << d << '\n';
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define INF 99

int dx[]={-1, 0, 0, 1};
int dy[]={0, -1, 1, 0};
int h, w;
string s[20];
int d[20][20];

void bfs(int x, int y){
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			d[i][j]=INF;
		}
	}
	d[x][y]=0;

	queue<pair<int, int>> q;
	q.push(make_pair(x, y));
	while(!q.empty()){
		pair<int, int> p=q.front();
		q.pop();
		for(int i=0; i<4; i++){
			int x_=p.first+dx[i], y_=p.second+dy[i];
			if(0<=x_ && x_<h && 0<=y_ && y_<w && s[x_][y_]=='.' && d[x_][y_]==INF){
				q.push(make_pair(x_, y_));
				d[x_][y_]=d[p.first][p.second]+1;
			}
		}
	}
	return;
}

int main(){
	cin >> h >> w;
	for(int i=0; i<h; i++) cin >> s[i];

	int ans=0;
	for(int x=0; x<h; x++){
		for(int y=0; y<w; y++){
			if(s[x][y]=='.'){
				bfs(x, y);
			}
			int m=0;
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if(s[i][j]=='.' && d[i][j]!=INF){
						m=max(m, d[i][j]);
					}
				}
			}
			ans=max(ans, m);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
KEY = "keyence"
a=gets.chomp

len = a.length
if len < 7
  puts "NO"
else
  if  a[0..6] ==KEY
    puts "YES"
  elsif a[len-7..len-1] == KEY
    puts "YES"
  else
    flg = false
    for i in 1..6
      if a[0..i-1] + a[i+len-7..len-1] == KEY
        flg = true
      end
    end
    if flg
      puts "YES"
    else
      puts "NO"
    end
  end
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/










int N, A[5010];
vector<int> E[5010];
//---------------------------------------------------------------------------------------------------
vector<pair<ll, int>> dp[5010];
int sz[5010];
void marge(int cu, int to) {
    vector<pair<ll, int>> res(sz[cu] + sz[to] + 1, { infl,0 });
    rep(cui, 0, sz[cu]) rep(toi, 0, sz[to]) {
        // くっつける
        chmin(res[cui + toi].first, dp[cu][cui].first + dp[to][toi].first);
        if (dp[cu][cui].second and dp[to][toi].second) res[cui + toi].second = 1;

        // くっつけない
        if (dp[to][toi].first < 0 or dp[to][toi].second) chmin(res[cui + toi + 1].first, dp[cu][cui].first);
        if ((dp[to][toi].first < 0 or dp[to][toi].second) and dp[cu][cui].second) res[cui + toi + 1].second = 1;
    }
    swap(dp[cu], res);
    sz[cu] += sz[to] + 1;
}
//---------------------------------------------------------------------------------------------------
void dfs(int cu, int pa = -1) {
    sz[cu] = 1;
    dp[cu].resize(1);
    dp[cu][0] = { A[cu], 0 < A[cu] };
    fore(to, E[cu]) if (to != pa) {
        dfs(to, cu);
        marge(cu, to);
    }
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N - 1) {
        int a, b; cin >> a >> b;
        a--; b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }

    dfs(0);
    int ans = inf;
    rep(i, 0, sz[0]) if (dp[0][i].first < 0 or dp[0][i].second) chmin(ans, i);
    cout << ans << endl;
    
}

Measured memory_bytes: 327040
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n, int pos) {return n = (n | (1 << pos));}
int reset_0(int n, int pos) {return n = n & ~(1 << pos);}
bool check_bit(int n, int pos) {return n = n & (1 << pos);}

int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;

bool vis[N];

ll dp[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1, te = 0;
    // cin>>t;
    while (t--) {
        int n, m;
        cin >> n >> m;

        for (int i = 1; i <= m; i++) {
            int x;
            cin >> x;
            vis[x] = true;
        }

        int st = 0;
        ll res = 1ll;
        dp[0] = 1ll;
        if (!vis[1])dp[1] = 1ll;
        for (int i = 2; i <= n; ++i) {
            if (!vis[i]) {
                dp[i] = (dp[i - 1] + dp[i - 2])%M;
            }

            if(vis[i-1] and vis[i-2]){
                dp[n]=0ll;
                break;
            }

        }
        printf("%lld\n", dp[n] % M);


        //printf("Case %d: ",++te);
    }
    return 0;
}

Measured memory_bytes: 3072
N=int(input())
S=[]

for i in range(N):
    S.append(input())

print("AC x {}".format(S.count("AC")))
print("WA x {}".format(S.count("WA")))
print("TLE x {}".format(S.count("TLE")))
print("RE x {}".format(S.count("RE")))

Measured memory_bytes: 16196
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);
    printf("%d\n", (1000 - (n % 1000)) % 1000);


    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long mod2 = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N, Y;
  cin >> N >> Y;
  Y /= 1000;

  int x = -1, y = -1, z = -1;
  for (int i = 0; i <= N; i++)
  {
    for (int j = 0; j <= N; j++)
    {
      int k = N - i - j;
      if (k >= 0 && 10 * i + 5 * j + k == Y)
      {
        x = i; y = j; z = k;
        break;
      }
    }
  }

  cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
char = 'abcdefghijklmnopqrstuvwxyz'


N=int(input())
stack = 26
bstack = 0
length = 1
while True:
    if stack >=N:
        order = N-bstack-1#何番目de
        #print(order)
        counter = 0
        ans = ""
        for i in reversed(range(length)):
            if i == 0:
                ans = ans + char[order]
            elif order > 26**(i):
                div = int(order/26**(i))#3
                ans = ans + char[div]
                order = order - div*26**(i)
            else:
                ans = ans+ "a"
        print(ans)
        break    


    bstack = stack
    length += 1
    stack = stack+26**length#702

Measured memory_bytes: 9208
open Scanf ;;
open Printf ;;

let rec iota a b = if a > b then [] else a :: iota (a + 1) b ;;

let rec product a b = List.map (fun x -> List.map (fun y -> (x, y)) b) a |> List.flatten;;

let can n = 
  List.exists (fun (i, j) -> i * j = n) (product (iota 1 9) (iota 1 9)) ;;

let () =
  let n = scanf "%d" (fun x -> x) in
  if can n
    then print_endline "Yes"
    else print_endline "No"



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

int main(){
    long long int N,result,min;
    vector<long long int> a(5);
    cin >> N;
    for(int i=0;i<5;i++){
        cin >> a[i];
        if(i==0){
            min = a[i];
        }else{
            if(min > a[i]){
                min = a[i];
            }
        }
    }
    if(N%min==0){
        result = N/min+4;
    }else{
        result = N/min+5;
    }
    
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 384
from math import *

a, b, c = map(int, input().split())

def calc(a, b, c):
	r = a // 2

	ans = a * b * c
	for i in range(max(1, r - 5), min(r + 5, a - 1) + 1):
		v1 = i * b * c
		v2 = (a - i) * b * c
		ans = min(ans, abs(v1 - v2))

	return ans

res = a * b * c

res = min(res, calc(a, b, c))
res = min(res, calc(a, c, b))
res = min(res, calc(b, a, c))
res = min(res, calc(b, c, a))
res = min(res, calc(c, a, b))
res = min(res, calc(c, b, a))

print(res)

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

int main(){
    int n, a, mina = 2000000, maxa = -2000000;
    long long totala = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a < mina) {
            mina = a;
        }
        if (a > maxa) {
            maxa = a;
        }
        totala += a;
    }
    cout << mina << " " << maxa << " " << totala << endl;

    return 0;
}


Measured memory_bytes: 3100
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type city struct {
	i, y int
}
type byYear []city

func (a byYear) Len() int           { return len(a) }
func (a byYear) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a byYear) Less(i, j int) bool { return a[i].y < a[j].y }

func solve() {
	n, m := getInt(), getInt()
	prefs := make([][]city, n)
	for i := 0; i < m; i++ {
		p, y := getInt()-1, getInt()
		c := city{i, y}
		prefs[p] = append(prefs[p], c)
	}

	ids := make([]string, m)
	for p, cs := range prefs {
		sort.Sort(byYear(cs))
		for order, c := range cs {
			id := fmt.Sprintf("%06d%06d", p+1, order+1)
			ids[c.i] = id
		}
	}

	for _, id := range ids {
		fmt.Fprintln(wr, id)
	}
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 13952
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
#define debegin printf("debug\nbegin\n")
#define deend printf("debug\nend\n")
#define isfind printf("find\n")
template<class T>inline void rread(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=1e5+5;
int n,tot,rt,flag;
int head[maxn],des[maxn<<1],nxt[maxn<<1];
inline void adde(int x,int y){
	des[++tot]=y;nxt[tot]=head[x];head[x]=tot;
}
inline int dfs(int x,int fa){
	int cnt=0;
	Rep(p,x)if(des[p]!=fa)cnt+=dfs(des[p],x);
	if(flag)return 0;
	if(!cnt)return 1;
	if(cnt==1)return 0;
	flag=1;
	return 0;
}
int main(){
	rread(n);
	rep(i,1,n-1){
		int x,y;rread(x);rread(y);
		adde(x,y);adde(y,x);
	}
	if(dfs(1,0)==1&&(!flag))flag=1;
	if(flag)puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll X,Y;
  cin>>X>>Y;
  ll ans=0;
  if(X==1&&Y==1){
    ans+=400000;

  }

if(X==1){
ans+=300000;
}
  else if(X==2){
ans+=200000;
  }
else if(X==3){
ans+=100000;
}

  
  if(Y==1){
ans+=300000;
}
  else if(Y==2){
ans+=200000;
  }
else if(Y==3){
ans+=100000;
}
  
  cout<<ans<<endl;
}


  


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    string s;
    cin >> s;
    if(s[0] == '7' or s[1] == '7' or s[2] == '7') puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3628
use std::io;


fn main() {
    let (r, d, mut x) = {
        let i = read::<usize>();
        (i[0], i[1], i[2])
    };
    for _ in 0..10 {
        x = r * x - d;
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sort(v) sort(v.begin(),v.end())
#define pb push_back
/*
ll ar[10000+9]={0};
void seiv()
{
ll n=10000+9,i,j;
ar[1]=1;
for(i=4;i<=n;i+=2)ar[i]=1;
for(i=3;i<=n;i+=2)
{
if(ar[i]==0)
{
for(j=i*i;j<=n;j+=i*2)ar[j]=1;
}
}
}*/
int main()
{
    ll a=0,b=0;ll c;
  cin>>a;c=a;
 for(ll i=2;i<=9;i++)
{if(a%i==0)c=a/i;
        
    }
  // cout<<c<<endl;
if(c>9)cout<<"No\n";
else cout<<"Yes\n";
 }

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

const double g=10.0,eps=1e-7;
const int N=100000+10,maxn=20000+10,inf=0x3f3f3f;

int a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    vector<int>v;
    for(int i=1;i<=n;i++)
    {
        if(i==a[i])
            v.push_back(i);
    }
    int ans=v.size();
    for(int i=0;i<v.size();i++)
    {
        if(i+1<v.size()&&v[i]+1==v[i+1])
        {
            i++;
            ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}
/********************

********************/


Measured memory_bytes: 1276
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, M, K; cin >> N >> M >> K;
    vector<int> A(N, 0);
    vector<int> B(M, 0);
    for (int i = 0; i < N; ++i) cin >> A[i];
    long long int sum = 0;
    for (int i = 0; i < M; ++i) {
        cin >> B[i]; sum += B[i];
    }
    int j = M;
    int ans = 0;
    for (int i = 0; i < N + 1; ++i) {
        while (j > 0 && sum > K) {
            --j; sum -= B[j];
        }
        if (sum > K) break;
        ans = max(ans, i + j);
        if (i == N) break;
        sum += A[i];
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 4764
#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 ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=2005;
int a[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n;
  cin>>n;
  rep(i,1,n+1) cin>>a[i];
  sort(a+1,a+n+1);
  ll ans=0;
  rep(i,1,n+1)
    rep(j,i+1,n+1)
    {
      int sum=a[i]+a[j];
      int id=lower_bound(a+1,a+n+1,sum)-a;
      id--;
      ans+=max(0,id-j);
    }
  cout<<ans<<endl;
  return 0 ;
}


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

int main() {
    int N;
    cin>>N;
    vector<int> B(N-1, 0);
    REP(i, 0, N-1) cin >> B[i];
    int sum = B[0];
    REP(i, 0, N-2){
        sum += min(B[i], B[i+1]);
    }
    sum += B[N-2];
    cout << sum << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

S = readline().rstrip()
S = S[::-1]
dp = [0]*13
dp[0] = 1
pow10 = 4
for i,s in enumerate(S):
    dpnew = [0]*13
    pow10 = (pow10*10)%13
    if s != '?':
        k = int(s)
        for j in range(13):
            dpnew[(k*pow10+j)%13] = (dpnew[(k*pow10+j)%13]+dp[j])%mod
    else:
        for k in range(10):
            for j in range(13):
                dpnew[(k*pow10+j)%13] = (dpnew[(k*pow10+j)%13]+dp[j])%mod
    dp = dpnew

print(dp[5])



Measured memory_bytes: 74288
fn main() {
    let sc = std::io::stdin();
    let mut sc = Scanner { reader: sc.lock() };
    let n: usize = sc.read();
    let mut x: Vec<i64> = vec![];
    let mut y: Vec<i64> = vec![];
    for _ in 0..n {
        x.push(sc.read());
        y.push(sc.read());
    }

    for i in 1..n {
        if (x[0] + y[0]).abs() % 2 != (x[i] + y[i]).abs() % 2 {
            println!("-1");
            return;
        }
    }

    let mut arms = vec![];
    if (x[0] + y[0]).abs() % 2 == 0 {
        arms.push(1);
    }
    for i in 0..31 {
        arms.push(1 << i);
    }
    let m = arms.len();
    println!("{}", m);
    for i in 0..m {
        if i > 0 {
            print!(" ");
        }
        print!("{}", arms[i]);
    }
    println!();

    let sum: i64 = arms.iter().map(|&a| a).sum();
    for (u, v) in (0..n).map(|i| (x[i] + y[i], x[i] - y[i])) {
        let calc_up = |u: i64| {
            assert!((u + sum) % 2 == 0);
            let mut u = (u + sum) / 2;
            let mut p = vec![false; m];
            for i in (0..m).rev() {
                if u >= arms[i] {
                    u -= arms[i];
                    p[i] = true;
                }
            }
            p
        };
        let u_up = calc_up(u);
        let v_up = calc_up(v);
        for i in 0..m {
            let dir = match (u_up[i], v_up[i]) {
                (true, true) => 'R',
                (false, false) => 'L',
                (false, true) => 'D',
                (true, false) => 'U',
            };
            print!("{}", dir);
        }
        println!();
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 50005
# define eps 1e-5
# define MAXM 500001
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;
int _MAX(int a, int b){return a>b?a:b;}
int _MIN(int a, int b){return a>b?b:a;}
int Scan() {
    int res=0, flag=0;
    char ch;
    if((ch=getchar())=='-') flag=1;
    else if(ch>='0'&&ch<='9') res=ch-'0';
    while((ch=getchar())>='0'&&ch<='9')  res=res*10+(ch-'0');
    return flag?-res:res;
}
void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}

char s[100005], a[4][10]={"dream","dreamer","erase","eraser"};
bool check(int l, int r, int x)
{
    if (l<0) return 0;
    FOR(i,l,r) {
        if (s[i]!=a[x][i-l]) return 0;
    }
    return 1;
}
int main ()
{
    int flag=1;
    scanf("%s",s);
    int len=strlen(s);
    len--;
    while (len>=0) {
        if (s[len]=='r') {
            if (len>=1&&s[len-1]!='e') {flag=0; break;}
            else if (check(len-5,len-1,2)) len=len-6;
            else if (check(len-6,len-2,0)) len=len-7;
            else {flag=0; break;}
        }
        else if (s[len]=='m') {
            if (check(len-4,len,0)) len=len-5;
            else {flag=0; break;}
        }
        else if (s[len]=='e') {
            if (check(len-4,len,2)) len=len-5;
            else {flag=0; break;}
        }
    }
    puts(flag?"YES":"NO");
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef unsigned long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>N;
    vec a(N+1);
    reps(i,1,N+1) cin>>a.at(i);
    vec b(N+1);
    ll ans = 0;
    for(int i = N; i > 0; --i){
        ll roop = N/i;
        reps(j,2,roop+1){
            b.at(i) ^= b.at(j*i);
        }
        b.at(i) ^= a.at(i);
        ans += b.at(i);
    }

    cout<<ans<<endl;
    reps(i,1,N+1){
        if(b.at(i) == 1) cout<<i<<' ';
    }
}


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

using namespace std;

typedef long long ll;
typedef double dd;

void solve(ll test_num) {
  (void) test_num;
  ll N;
  cin >> N;
  N = 1 << N;
  vector<ll> arr(N);
  for (ll& a : arr) {
    cin >> a;
  }
  while (arr.size() > 1UL) {
    vector<ll> narr;
    for (ll i = 1; i < (ll) arr.size(); i += 2) {
      if (arr[i] == arr[i - 1]) {
        narr.push_back(arr[i]);
      } else {
        narr.push_back(max(arr[i], arr[i - 1]) - min(arr[i], arr[i - 1]));
      }
    }
    arr = narr;
  }
  cout << arr[0] << endl;
}

void init() {

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("/home/azneye/Documents/Stuff/input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  ll tests = 1;
  //cin >> tests;
  for (ll test = 1; test <= tests; ++test) {
    solve(test);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() / 1e9) << " s" << endl;
#endif
  return 0;
}

Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int p;
  if(b<a)
  {p=a-b;}
  if(p<c)
  {cout<<c-p;}
  else
    cout<<0;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    } else {
        cout << min(a-1, n-b) + 1 + (b-a-1)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define all(c) (c).begin(),(c).end()
#define curr(P,i) P[(i)%P.size()]
#define next(P,i) P[(i+1)%P.size()]
#define prev(P,i) P[(i+P.size()-1)%P.size()]


using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  bool operator < (Point p)const{return (p.x!=x)?x<p.x:y<p.y;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
  //点pを中心に角度r(radius)だけ半時計回りに回転する
  Point rotate(Real r,Point p = Point(0,0)){
    Real ta=cos(r)*(x-p.x)-sin(r)*(y-p.y)+p.x;
    Real tb=sin(r)*(x-p.x)+cos(r)*(y-p.y)+p.y;
    return Point(ta,tb);
  }
  Real arg(){
    if(sgn(x)>0)return atan(y/x);
    if(sgn(x)<0)return atan(y/x)+PI;
    if(sgn(y)>0)return PI/2;
    if(sgn(y)<0)return 3*PI/2;
    return 0;
  }
};

//a -> b -> c
int ccw(Point a, Point b, Point c) {
  b = b-a; c = c-a;

  if (b.cross(c) > 0)   return +1;       // counter clockwise
  if (b.cross(c) < 0)   return -1;       // clockwise
  if (b.dot(c) < 0)     return +2;       // c--a--b on line
  if (b.norm() < c.norm()) return -2;    // a--b--c on line
  return 0;                              // a--c--b on line
}

struct Line{
  Point a,b;

  Line(){}
  Line(Point a,Point b):a(a),b(b){}

  bool on(Point c){return abs(ccw(a,b,c))!=1;}
  Real dist(Point c){return abs((b-a).cross(c-a))/(b-a).norm();}

  //射影
  Point project(Point p){
    Point base=b-a;
    Real t=(p-a).dot(base)/base.dot(base);
    return a+base*t;
  }
};

struct Circle{
  Point p;
  Real r;
  Circle(){}
  Circle(Point p, Real r) : p(p) , r(r){}
  
  vector<Point> intersectionPoints(Line l){

    if(sgn(l.dist(p),r)>0)return vector<Point>();

    Point q=l.project(p);
    Real t=(p-q).norm(),d=sqr(r*r-t*t);
    Point base=l.a-l.b;
    vector<Point>res;
    res.push_back(q+base*(d/base.norm()));
    res.push_back(q-base*(d/base.norm()));
    return res;
  }
  
};

int main(void){

  Circle c;
  cin >> c.p.x >> c.p.y >> c.r;
  int q;
  cin >> q;
  while(q--){
    Line l;
    cin >> l.a.x >> l.a.y >> l.b.x >> l.b.y;
    vector<Point>res=c.intersectionPoints(l);
    sort(all(res));
    printf("%.8f %.8f ",res[0].x,res[0].y);
    printf("%.8f %.8f ",res[1].x,res[1].y);
    cout << endl;
  }

  return 0;
}

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

int32_t main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int,int>> graph[n+1];
  for (int i = 2; i <= n; i++) {
    graph[i].emplace_back(i-1, 0);
  }
  while (m--) {
    int l, r, c;
    cin >> l >> r >> c;
    graph[l].emplace_back(r, c);
  }
  priority_queue<pair<int,int>> pq;
  pq.emplace(0, 1);
  vector<int> dist(n+1, INT_MAX);
  while (!pq.empty()) {
    pair<int,int> cur = pq.top();
    pq.pop();
    int v = cur.second;
    int w = -cur.first;
    if (dist[v] == INT_MAX) {
      dist[v] = w;
      for (pair<int,int> child : graph[v]) {
        if (dist[child.first] == INT_MAX) {
          pq.emplace(-w - child.second, child.first);
        }
      }
    }
  }
  if (dist[n] == INT_MAX) {
    cout << -1;
    return 0;
  }
  cout << dist[n];
}

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

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

  int64_t tmp = 0;
  int64_t ans = 0;



  vector<long long> h(n+10);

  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }


  for(int i=0;i<n-1;i++){


   if(h.at(i) >= h.at(i+1)){

     tmp++;
     
     if(i==(n-2)) ans = max(ans, tmp);

   }else{


     ans = max(ans, tmp);
     tmp = 0;



   }

  }


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

Measured memory_bytes: 1024
#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;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

typedef long long  ll;
typedef unsigned long long  ull;
typedef long double ld;
#define lp(i,n)      for(int i=0;i<n;i++)
#define lpi(i,j,n)   for(int i=j;i<n;i++)
#define lpd(i,j,n)   for(int i=j;i>=n;i--)
#define MP           make_pair
#define clr(v, d)    (memset(v, d, sizeof(v)))
#define all(v)     (v.begin()),(v.end())
#define N 100005
const double pi = acos(-1);

ll n,t,m,k;

ll ans;
ll mod = 1e9 +7;




int main() {
 
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// freopen("e.txt","r",stdin); 
// freopen("e_out.txt","w",stdout); 
cout.precision(10);



cin>>n;
vector<ll>a(n);
lp(i,n)cin>>a[i];
ans = 1e5;
lp(i,n){
  ll cnt = 0;
  while(a[i] && a[i]%2 == 0){
    cnt++;
    a[i]>>=1;
  }
  ans= min(ans,cnt);
}
cout<<ans;




  
}
  
 



// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }

Measured memory_bytes: 3616
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    a = na()

    dp = [False for _ in range(k + 1)]

    for i in range(k + 1):
        for ai in a:
            if i + ai < k + 1:
                dp[i + ai] |= not dp[i]

    print("First" if dp[k] else "Second")


if __name__ == '__main__':
    main()


Measured memory_bytes: 78688
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 16 17:42:18 2020

@author: liang
"""
"""
【優先度付きキュー】
・ヒープ構造の部分順序付き木
・挿入、削除、最大値（最小値）の取り出し、要素の値の変更
　⇒　O(log n)
・ヒープ生成
　⇒O(n)
 【使い方】
  import heapq
  ●heapq.heapify(list) #最小値
  ●heapq.heapify(list(map(lambda x:int(x)*(-1),list))) #最大値は値をひっくり返す
  ●heapq.heappop(a)
  ●heapq.heappush(a,1)
"""

import heapq
N, M = map(int, input().split())
# -1倍する
A = [int(x)*(-1) for x in input().split()]
heapq.heapify(A)

#O(M) * O(log N)
for i in range(M):
    Max = heapq.heappop(A) * (-1)
    Max //= 2
    heapq.heappush(A, Max*(-1))
print(-sum(A))

Measured memory_bytes: 20292
#include <iostream>
#include <cmath>
using namespace std;
int T,t[100005],x[100005],y[100005],st=0;
int main()
{	
	cin>>T;
	int flag=true,a=0,b=0;
	for(int i=1;i<=T;i++)
	{
		cin>>t[i]>>x[i]>>y[i];
		//cout<<(t[i]-t[i-1])<<" "<<(abs(x[i]-a)+abs(y[i]-b))<<endl;
		if(((t[i]-t[i-1])-(abs(x[i]-a)+abs(y[i]-b)))%2!=0||((t[i]-t[i-1])-(abs(x[i]-a)+abs(y[i]-b))<0))flag=false;	
		a=x[i];b=y[i];
	}
	if(flag)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 1408