akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    if(a>b) swap(a, b);
    if(a%2 == b%2)
    {
        cout << abs(a-b)/2 << endl;
        return 0;
    }
    ll cur = (a-1) + 1 + (b-a-1)/2;
    ll cur2 = (n-b) + 1 + (b-a-1)/2;
    cout << min(cur, cur2) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string.h>
using namespace std;

int main()
{
	int n;
	int a[1001];
	memset(a,0,sizeof(a));
	for(int i=1;i<=1000;i++){
		a[i]=a[i-1];
		a[i]+=i;
	}

	while(cin>>n && n!=0){
		int ans=0;
		for(int i=0;i<n;i++){
			for(int j=i+2;j<n;j++){
				if(a[j]-a[i]==n){ans++;}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e18+100;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//
 
int main() {
	string s;
	cin >> s;
	
	bool ans = false;
	REP(i, s.size() - 1) if (s[i] == 'A' && s[i + 1] == 'C') ans = true;
	puts(ans ? "Yes" : "No");
	
	return 0;
}

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

int main(void){
    char s[21];
    char str[21];
    int len,tmp;
    int i = 0;

    scanf("%s", s);
    len = strlen(s);
    tmp = len;
    
    while(tmp>=0){
        str[i] = s[tmp-1];
        i++;
        tmp--;
    }

    str[i+1] = '\0';

    printf("%s\n", str);

    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    REP(i, m) cin >> a[i] >> b[i];

    int ans = 0;
    REP(i, m){
        vector<vector<int>> graph(55, vector<int>(55, INF));
        REP(j, m){
            if(i != j){
                graph[a[j]-1][b[j]-1] = 1;
                graph[b[j]-1][a[j]-1] = 1;
            }
        }
        vector<bool> close(n);
        queue<int> que;
        que.push(0);
        close[0] = true;
        while(!que.empty()){
            int cur = que.front();
            que.pop();
            REP(j, n){
                if(!close[j] && graph[cur][j] == 1){
                    que.push(j);
                    close[j] = true;
                }
            }
        }
        bool flag = true;
        REP(j, n){
            if(!close[j]) flag = false;
        }

        if(!flag) ans++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>
	int main(){
		int a,b,m,i,z,j,h;
		while(scanf("%d",&m),m){
			z=0;
			h=0;
			for(i=0;i<12;i++){
				scanf("%d %d",&a,&b);
				z=z+a-b;
				if(z>=m&&h==0){
					h++;
					j=i+1;
				}
			}
			if(z<m)
				printf("NA\n");
			else
			printf("%d\n",j);
		}
		return 0;
}

Measured memory_bytes: 0
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

data = getInputListInt()
n = data[0]
r = data[1]

ans = 0
if n > 10:
    ans = r
else:
    ans = r + 100*(10-n)

print(ans)

Measured memory_bytes: 22768
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<int> as(n);
    akari<pair<i64, int>> ps(n);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
        ps[i] = {as[i], i};
    }
    sort(ps.rbegin(), ps.rend());
    akari<i64> dp(n + 1, -1e18);
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        auto new_dp(dp);
        int k = ps[i].second;
        i64 a = ps[i].first;
        for (int j = 0; j <= n; j++)
        {
            if (j)
            {
                new_dp[j] = max(new_dp[j], dp[j - 1] + abs(j - k - 1) * a);
            }
            new_dp[j] = max(new_dp[j], dp[j] + abs(n - 1 - i + j - k) * a);
        }
        swap(dp, new_dp);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}

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


Measured memory_bytes: 3668
n,k = map(int, input().split())
s = input()
now = s[0]
start = []
end = []
if k != 0 or s[0] == "1":
  start.append(0)
for i,v in enumerate(s):
  if now == "0" and v == "1":
    start.append(i)
  elif now == "1" and v == "0":
    end.append(i)
  now = v
end.append(len(s))
ans = 0
for st,en in zip(start,end[k+int(s[0])-1:]):
  ans = max(ans,en-st)
if ans == 0:
  if not (all([i == "0" for i in s]) and k == 0):
    ans = len(s)    
print(ans)
    
    
  
  

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    lli a, b, c, x=0;
    cin >> a >> b >> c;

    string flag = "NO";
    while(true){
        if((b*x+c)%a==0){
            flag = "YES";
            break;
        }
        x++;
        if(x>100000000)
            break;
    }
    cout << flag << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define N 512
#define D 9
#define chmax(a,b) a=max(a,b)
ll f[N][N];
int main(){
  for(int i=0;i<D;i++){
      for(int j=0;j<N;j++){
	  if(j%(2LL<<i)<(1LL<<i)){
	      ll p=j+(1LL<<i); p=p/(1LL<<i)*(1LL<<i);
	      for(int k=0;k<(1LL<<i);k++){
		  f[j][p+k]=i+1;
	      }
	  }
	  else{
	      ll p=j-(1LL<<i); p=p/(1LL<<i)*(1LL<<i);
	      for(int k=0;k<(1LL<<i);k++){
		  f[j][p+k]=i+1;
	      }
	  }
      }
  }
  ll n; cin>>n;
  for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)cout<<f[i][j]<<" ";
      cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 2560
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = []
for i in range(n):
    tmp = list(map(int, input().split()))
    a.append(tmp)
ret = 0
for a1 in a:
    source_sum = 0
    for i in range(len(a1)):
        source_sum += a1[i]*b[i]
    if source_sum + c > 0:
        ret += 1
print(ret)


Measured memory_bytes: 3064
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1.01e9;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int mod = (int) 1e9 + 7;

void add(int & x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int sum(int x, int y) {
  add(x, y);
  return x;
}

int mult(int x, int y) {
  return (ll) x * y % mod;
}

int power(int x, ll p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
    p >>= 1;
  }
  return res;
}

int inv(int x) {
  return power(x, mod - 2);
}

void precalc() {
}

ll n;

bool read() {
  if (scanf("%lld", &n) < 1) {
    return false;
  }
  return true;
}

void solve() {
  n++;
  vector<int> ans;
  int mx = -1;
  for (int i = 40; i >= 0; i--) {
    if (n & (1ll << i)) {
      if (mx == -1) {
        mx = i;
      } else {
        ans.pb(i + 41);
      }
    }
    if (mx != -1 && i) {
      ans.pb(i);
    }
  }
  for (int i = 0; i <= 40; i++) {
    ans.pb(i + 41);
  }
  for (int i = mx; i >= 1; i--) {
    ans.pb(i);
  }
  printf("%d\n", sz(ans));
  for (int i = 0; i < sz(ans); i++) {
    printf("%d%c", ans[i], " \n"[i == sz(ans) - 1]);
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.3f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	//"math"
	//"strings"
)

func main() {
	var x int
	fmt.Scan(&x)
	if x <= 1{
		fmt.Print("NO")
		return
	}
	if 105 % x == 0 {
		fmt.Print("YES")
	}else{
		fmt.Print("NO")
	}
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int k = Integer.parseInt(br.readLine());
        String s = br.readLine();
        
        if(s.length() > k){
            out.print(s.substring(0, k));
            out.println("...");
        }else{
            out.println(s);
        }
        
        out.close();
        
    }
}

Measured memory_bytes: 32656
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;

class SCC{
public:
	int n;
	vector<vector<int> > G, rG, G2;
	vector<int> vs, cmp, used;
	void init(int m){
		n = m;
		G.resize(n);rG.resize(n);G2.resize(n);
		vs.resize(n);cmp.resize(n);used.resize(n);
	}
	void add_edge(int from, int to){
		G[from].pb(to);
		rG[to].pb(from);	//逆辺
	}
	void dfs(int v){
		used[v] = 1;
		rep(i,G[v].size())if(!used[G[v][i]])dfs(G[v][i]);
		vs.pb(v);
	}
	void rdfs(int v, int k){
		used[v] = 1;
		cmp[v] = k;
		rep(i,rG[v].size()){
			int to = rG[v][i];
			if(!used[to])rdfs(to, k);
			else if(cmp[to] != cmp[v])G2[cmp[to]].pb(cmp[v]);
		}
	}
	int scc(){
		fill(all(used), 0);
		vs.clear();
		rep(i,n)if(!used[i])dfs(i);
		fill(all(used), 0);
		int k = 0, size = vs.size();
		drep(i,size-1,0)if(!used[vs[i]])rdfs(vs[i], k++);
		rep(i,k)ZIP(G2[i]);
		return k;
	}
};

const int MAX = 100000;
int in[MAX], out[MAX], used[MAX];
vector<vector<int> > G;
int dfs(int v){
	used[v] = 1;
	rep(i,G[v].size()){
		out[v]++;in[G[v][i]]++;
		if(!used[G[v][i]])dfs(G[v][i]);
	}
	return 0;
}

signed main(){
	int n, m;
	scanf("%lld%lld", &n, &m);
	SCC S;S.init(n);
	rep(i,m){
		int x, y;
		scanf("%lld%lld", &x, &y);
		S.add_edge(x, y);
	}
	int size = S.scc();
	G = S.G2;
	rep(i,size)if(!used[i])dfs(i);
	/*rep(i,size){
		rep(j,G[i].size())printf("*%lld %lld*\n", i, G[i][j]);
	}*/
	int x = 0, y = 0;
	rep(i,size)if(in[i] == 0)x++;
	rep(i,size)if(out[i] == 0)y++;
	printf("%lld\n", size == 1 ? 0LL : max(x, y));
	return 0;
}







Measured memory_bytes: 8864
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

ll pos[300005], t[300005], x[300005], y[300005];
ll ans = 1, N, L;

int main(){

    ios :: sync_with_stdio(false);
    
    cin >> N >> L;
    FOR(i,N) cin >> pos[i];
    FOR(i,N) cin >> t[i];

    FOR(i,N){
        ans += t[i] / (2ll*L);
        t[i] %= (2ll*L);
    }

    FOR(i,N){
        if(t[i] == 0){
            x[i] = y[i] = 0;
        }
        else{
            ans++;
            x[i] = (t[i] <= (2ll * (L-pos[i])));
            y[i] = (t[i] <= (2ll * pos[i]));
        }
    }

    ll cnta = 0, cntb = 0;
    FOR(i,N-1){
        if(x[i]){
            if(cnta){
                if(y[i]) cntb++;
                cnta--;
                ans--;
            }
            else if(cntb && !y[i]) cntb--, cnta++;
            else if(y[i]) cnta++;
        }   
        else if(y[i]) cnta++;
    }

    if(x[N]) ans--;
    ans *= 2ll * L;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
import java.io.BufferedReader
import java.io.InputStreamReader

fun main(){
    val br = BufferedReader(InputStreamReader(System.`in`))
    var N = br.readLine()!!.toInt()
    var s = mutableSetOf<String>()
    for(i in 1..N)
        s.add(br.readLine())
    print(s.size)
}

Measured memory_bytes: 66924
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>a[i],ans+=a[i];
    if(ans%10==0){
        sort(a,a+n);
        int ok=0;
        rep(i,n){
            if(a[i]%10!=0){
                ans-=a[i];
                ok=1;
                break;
            }
        }
        if(ok)Cout(ans);
        else Cout(0);
    }
    else Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int main(){int n, k, ans=INT_MAX;cin>>n >>k;vector<int> h(n);for(int i=0;i<n;i++)cin>>h[i];sort(h.begin(), h.end());for(int i=0;i<n-k+1;i++)ans=min(ans, h[i+k-1]-h[i]);cout<<ans<<endl;}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ull;
const ull MOD = 1000000007;
const int MAX_N = 100000;
ull fact[MAX_N + 1];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ull ans;
	fact[0] = 0;
	fact[1] = 1;
	ull fs = 1;
	for (int i = 2; i < MAX_N + 1; i++){
		fs = (fs*i) % MOD;
		fact[i] = (fact[i-1] + fs) % MOD;
	}
	while (1){
		int N, R;
		cin >> N;
		if (N == 0) break;
		vector<int> word(N);
		for (int i = 0; i < N; i++) word[i] = i;
		word.push_back(0);
		ans = 0;
		cin >> R;
		vector<int> s(2*R+2, 0);
		s[2 * R + 1] = N;
		for (int i = 0; i < R; i++){
			cin >> s[i] >> s[i+R];
			s[i]--; s[i+R]--;
			s.push_back(s[i] + 1);
			s.push_back(s[i+R] + 1);
			swap(word[s[i]], word[s[i+R]]);
		}
		sort(s.begin(), s.end());
		s.erase(unique(s.begin(), s.end()), s.end());
		for (int i = 0, R = s.size() - 1; i < R; i++){
			ull tmp = fact[N - s[i] - 1] - fact[N - s[i+1] - 1];
			tmp = (tmp * word[s[i]]) % MOD;
			ans =(ans + tmp) % MOD;
			int dif = s[i+1] - s[i];
			for (int j = i + 1; j < R; j++){
				word[s[j]] -= (word[s[j]] > word[s[i]] ? dif : 0);
			}
		}
		cout << (ans + MOD) % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 2788
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>
using namespace std;

int main(void)
{
    int n;
    cin >> n;
    string iStr;
    unordered_map<string, long long int> uMap;
    long long int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> iStr;
        sort(iStr.begin(), iStr.end());
        uMap[iStr] += 1;
        sum += uMap[iStr] - 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 10660
import java.io.*;
import java.util.*;

public class Main {

    static MyScanner sc;
    private static PrintWriter out;
    static long M = 1000000007;

    public static void main(String[] s) throws Exception {
        StringBuilder stringBuilder = new StringBuilder();


        if (stringBuilder.length() == 0) {
            sc = new MyScanner(System.in);
        } else {
            sc = new MyScanner(new BufferedReader(new StringReader(stringBuilder.toString())));
        }


        out = new PrintWriter(new OutputStreamWriter(System.out));
        long t = System.currentTimeMillis();


        solve();
        out.flush();
    }

    private static void solve() {
        int m = sc.nextInt();
        Map<Integer, Integer> x = new HashMap<>();
        while (m-->0) {
            x.merge(sc.nextInt(), 1, Math::addExact)
        ;}
        int r = sc.nextInt();boolean valid = true;
        while (r-->0) {
          int xx = sc
                  .nextInt();
          if (valid && x.containsKey(xx)) {
            int mx = x.get(xx);
            if (mx > 1) {
                 x.put(xx, mx - 1);
            } else {
                x.remove(xx);
            }
          }else {
              valid = false;
          }
        }
        out.println(valid ? "YES" : "NO");
    }




    private static void solveT() {
        int t = sc.nextInt();
        while (t-- > 0) {
            solve();
        }
    }

    private static long gcd(long l, long l1) {
        if (l > l1) return gcd(l1, l);
        if (l == 0) return l1;
        return gcd(l1 % l, l);
    }

    private static long pow(long a, long b, long m) {
        if (b == 0) return 1;
        if (b == 1) return a;
        long pp = pow(a, b / 2, m);
        pp *= pp;
        pp %= m;
        return (pp * (b % 2 == 0 ? 1 : a)) % m;
    }


    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        MyScanner(BufferedReader br) {
            this.br = br;
        }

        public MyScanner(InputStream in) {
            this(new BufferedReader(new InputStreamReader(in)));
        }

        void findToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }

        String next() {
            findToken();
            return st.nextToken();
        }

        int[] na(int n) {
            int[] k = new int[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.nextInt();
            }
            return k;
        }

        long[] nl(int n) {
            long[] k = new long[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.nextLong();
            }
            return k;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }


}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
//head

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    int val[3];
    cin >> n >> val[0] >> val[1] >> val[2];
    if(val[0] + val[1] + val[2] == 0) {
        cout << "No" << endl;
    } else {
        vector<string> q(n);
        string ans;
        for(int i = 0; i < n; i++) {
            cin >> q[i];
        }
        if(val[(int)q[0][0]-65] == 0 && val[(int)q[0][1]-65] == 0) {
            cout << "No" << endl;
            return 0;
        }
        else {
            ans += "Yes\n";
        }
        for(int i = 0; i < n; i++) {
            int u = (int)q[i][0]-65;
            int v = (int)q[i][1]-65;
            if(val[u] == 0 && val[v] == 0) {
                cout << "No" << endl;
                return 0;
            }
            if(val[u] == 0 || val[v] == 0) {
                if(val[u] == 0) {
                    ans.pb((char)(u+65));
                    ans.pb('\n');
                    val[u]++;
                    val[v]--;
                } else {
                    ans.pb((char)(v+65));
                    ans.pb('\n');
                    val[u]--;
                    val[v]++;
                }
            } else if(val[u] == 1 && val[v] == 1 && val[0] + val[1] + val[2] == 2 && i != n-1 && q[i+1] != q[i]) {
                int uNxt = q[i+1][0]-65;
                int vNxt = q[i+1][1]-65;
                if(u == uNxt || u == vNxt) {
                    ans.pb((char)(u+65));
                    ans.pb('\n');
                    val[u]++;
                    val[v]--;
                } else {
                    ans.pb((char)(v+65));
                    ans.pb('\n');
                    val[u]--;
                    val[v]++;
                }
            } else {
                if(val[u] >= val[v]) {
                    ans.pb((char)(v+65));
                    ans.pb('\n');
                    val[u]--;
                    val[v]++;
                } else {
                    ans.pb((char)(u+65));
                    ans.pb('\n');
                    val[u]++;
                    val[v]--;
                }
            }
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 6752
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(3 * n);
    REP(i, 3 * n) cin >> a[i];
    VSORT(a);
    ll res = 0;
    REP(i, n) res += a[3 * n - 2 - 2 * i];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2560
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	xs := make([]int, m+1)
	var k, a int
	for i := 0; i < n; i++ {
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			fmt.Scan(&a)
			xs[a]++
		}
	}

	cnt := 0
	for _, v := range xs {
		if v == n {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
n,k = map(int, input().split())
a = list(map(int,input().split()))
dp = [0]*n
dp[1] = abs(a[1]-a[0]) 

for i in range(2,n):
    c = float("inf")
    for j in range(1,min(k,i)+1):
        c = min(c,dp[i-j] + abs(a[i] -a[i-j]))
    dp[i] = c
print(dp[n-1])

Measured memory_bytes: 52448
fun main(args: Array<String>) {
    diverta2019d()
}

fun diverta2019d() {
    val n = readLine()!!.toLong()

    var answer = 0L
    for (l in 1..Math.floor(Math.sqrt(n.toDouble())).toLong()) {
        val m = n / l - 1
        if (m > 0 && n / m == n % m) {
            answer += m
        }
    }

    println(answer)
}


Measured memory_bytes: 31844
#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<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

const int INF = 10000001;

ll dp[501][501];
ll a[501][501];

ll sub(int x1, int y1, int x2, int y2)
{
	return (dp[x2][y2]-dp[x1-1][y2]-dp[x2][y1-1]+dp[x1-1][y1-1]);
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,m,h,w; cin>>n>>m>>h>>w;
	
	if(n%h==0&&m%w==0)
	{
		cout<<"No\n";
		return 0;
		
	}
	memset(dp,0,sizeof(dp));
	memset(a,0,sizeof(a));
	cout<<"Yes\n";
	//cerr<<n<<' '<<m<<' '<<h<<' '<<w<<'\n';
	for(int i=1;i<=n;i+=h)
	{
		for(int j=1;j<=m;j+=w)
		{
			a[i][j]=INF;
		}
	}
	for(int i=h;i<=n;i+=h)
	{
		for(int j=w;j<=m;j+=w)
		{
			a[i][j]=-(INF+1);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			dp[i][j]=a[i][j]+dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
		}
	}
	assert(dp[n][m]>0);
	for(int i=1;i<=n-h+1;i++)
	{
		for(int j=1;j<=m-w+1;j++)
		{
			assert(sub(i,j,i+h-1,j+w-1)<0);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cout<<a[i][j];
			if(j<m) cout<<' ';
		}
		cout<<'\n';
	}
}


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

int main(){
    string s;
    cin >> s;
    if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(void) {
  int n, ans = 0, i, j, m, k;
  char a[20];
  scanf("%s", a);
  m = strlen( a );
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    char t[30], s = 1;
    scanf("%s", t);
    for(j = 0; j < 10; ++j) t[j + 10] = t[j];
    for(j = 0; j < 10; ++j) {
      s = 1;
      for(k = 0; k < m; ++k) if(a[k] != t[k + j]) {
        s = 0;
        break;
      }
      if(s) {
        ++ans;
        break;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
int main()
{
    bool chk=false;
    int A;
    cin >> A;
    vector<int> B(1000000);
    B.at(0)=A;
    int count=0;
    for(int i=1; i<10000001; i++)
    {
    if(A%2==0)
    {
        A=A/2;
        B.at(i)=A;
        count++;
    }
    else
    {
        A=3*A+1;
        B.at(i)=A;
        count++;
    }
    for(int j=0; j<i; ++j)
    {
        if(B.at(i)==B.at(j))
        {
            chk=true;
        }
    }
    if(chk)
    {
         break;
    }
    }
    cout << count+1 <<endl;
}

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
#define double long double

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

    double a;
    cin >> a;
    cout << fixed << setprecision(16) << pow(a / 3, 3) << '\n';

    return 0;
}

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

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


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	long long int cnt = 0;
	for (auto i : s)cnt += i - '0';
	long long int ans = 0;
	for (int i = 1; i <= cnt; i++) {
		ans += (i + 1) / 2;
	}
	int length = cnt;
	int one = cnt;
	cnt = 0;
	for (auto &i : s) {
		cnt += i - '0';
		if (i == '0' && (cnt & 1)) {
			length++;
			i = 'A';
			cnt++;
			ans += (length + 1) / 2;
		}
	}
	reverse(s.begin(), s.end());
	cnt = 0;
	int p = length;
	int ok = 0;
	int ng = 0;
	for (auto i : s) {
		if (i == '1')cnt++;
		if (i == '0') {
			swap(ok, ng);
			ans += ok + (p + 1) / 2;
		}
		else {
			if (i == '1') {
				if (p & 1)ok++;
				else ng++;
			}
			p--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3788
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<24

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}
vector<int> buildPath(const vector<int> &prev, int t) {
  vector<int> path;
  for (int u = t; u >= 0; u = prev[u])
    path.push_back(u);
  reverse(path.begin(), path.end());
  return path;
}

int main() {
    int n, m;
    while ( cin >> n >> m ) {
        if ( n == 0 && m == 0 ) break;
        Graph C(m);
        Graph T(m);
        for ( int i = 0; i < n; i++ ) {
            int a, b, c, t;
            cin >> a >> b >> c >> t;
            a--;
            b--;
            C[a].push_back( Edge( a, b, c ) );
            C[b].push_back( Edge( b, a, c ) );
            T[a].push_back( Edge( a, b, t ) );
            T[b].push_back( Edge( b, a, t ) );
        }

        int k;
        cin >> k;
        for ( int i = 0; i < k; i++ ) {
            int p, q, r;
            cin >> p >> q >> r;
            p--;
            q--;
            vector <Weight> Q;
            vector <int> I;
            shortestPath( (r==0?C:T), p, Q, I );
            cout << Q[q] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1092
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    string s; cin >> s;
    ll x = 0LL;
    for(auto i : s)
    {
        ll d = i - '0';
        x += d;
    }
    if(x % 9LL == 0)
        puts("Yes");
    else
        puts("No");

}


Measured memory_bytes: 3628
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

long long calcSum(long long n){
    if(n == 0){
        return 0;
    }
    long long q = n / 2;
    long long ans = (1+n) * q;
    if(n % 2) ans += (1+n) / 2;
    return ans;
}

int main()
{
    long long n;
    cin >> n;
    long long allSum = calcSum(n);
    //cout << allSum << endl;
    long long fizzSum = calcSum(n / 3) * 3;
    long long buzzSum = calcSum(n / 5) * 5;
    long long fizzBuzzSum = calcSum(n / 15) * 15;
    long long ans = allSum - fizzSum - buzzSum + fizzBuzzSum;
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  set<char> st;
  for(char c: s) st.insert(c);
  for(char c: t) {
    if(!st.count(c)) {
      cout << -1 << endk;
      return 0;
    }
  }
  map<char, set<int>> mp;
  rep(i, s.size()) {
    mp[s[i]].insert(i);
    mp[s[i]].insert(i+s.size());
  }
  ll ans = 0;
  int tmp = -1;
  for(char c: t) {
    int ne = *mp[c].lower_bound(tmp+1);
    ans += ne / s.size() * s.size();
    tmp = ne % s.size();
  }
  cout << ans+tmp+1 << endk;
  return 0;
}


Measured memory_bytes: 13252
#include <stdio.h>

int main() {
	char str[11];
	char inp[11];
	char in;
	int a=0;
	char csr=0;
	scanf("%s",inp);
	while(1){
		in=inp[a];
		a++;
		if(!in)break;
		switch(in){
		case '0':
			str[csr]='0';
			str[csr+1]=0;
			csr++;
			break;
		case '1':
			str[csr]='1';
			str[csr+1]=0;
			csr++;
			break;
		case 'B':
			if(csr>0){
				csr--;
				str[csr]=0;
			}
			break;
		}
	}
	printf("%s",str);
}

Measured memory_bytes: 128
import numpy as np
n = int(input())
li = list(map(int,input().split()))
li.sort()
arr_li = np.array(li)
if(arr_li[int(n/2)] == arr_li[int(n/2-1)]):
    print('0')
else:
    print(arr_li[int(n/2)]-arr_li[int(n/2-1)])

Measured memory_bytes: 23476
def solve(A):
	B=[]
	C=[]
	#print(A)
	#??????
	B.append(A[0])
	C.append(0)#?????§??????
	for i in range(1,9):
		if B[-1]<A[i] and C[-1]>A[i]:
			B.append(A[i])
			#print("B",B)
			#print("C",C)
		elif B[-1]>A[i] and C[-1]<A[i]:
			C.append(A[i])
			#print("B",B)
			#print("C",C)
		elif B[-1]<A[i] and C[-1]<A[i]:
			for j in range(i+1,len(A)):
				if A[j]<A[i]:
					if B[-1]<C[-1]:
						C.append(A[i])
						#print("B",B)
						#print("C",C)
						break
					else:
						B.append(A[i])
						#print("B",B)
						#print("C",C)
						break
			else:
				B.append(A[i])
				#print("B",B)
				#print("C",C)
		else:
			break
	del C[0]
	#print("B is ",B)
	#print("C is ",C)
	if B[-1]<A[-1] or C[-1]<A[-1]:
		if len(B)+len(C)==len(A)-1:
			print("YES")
		else:
			print("NO")
	else:
		print("NO")










n=int(input())
for i in range(n):
	A=list(map(int,input().split()))
	solve(A)

Measured memory_bytes: 7684
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,m) = get!(usize, usize);
    let a = get!(usize; m);
    let mut pos = vec![true;n+1];
    for e in a {
        pos[e] = false;
    }
    let mut dp = vec![0usize; n+1];
    dp[0] = 1;
    if pos[1] {
        dp[1] = 1;
    }
    let mo = 1_000_000_007usize;
    for i in 0..n-1 {
        if pos[i+2] {
            dp[i+2] = dp[i+1] + dp[i];
            dp[i+2] %= mo;
        }
    }
    println!("{}", dp[n]);
}


Measured memory_bytes: 10620
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef pair <long long, long long> pll;
 
ll mod = 998244353;
 
int main(){
  ios_base::sync_with_stdio(false);
  ll n, m, k;
  cin >> n >> m >> k;
  vector <ll> a(n);
  vector <ll> b(m);
  for (int i = 0; i < n; i++)
   cin >> a[i];
  for (int i = 0; i < m; i++)
   cin >> b[i];
  vector <ll> ca(n+1,0);
  vector <ll> cb(m+1,0);
  for (int i = 1; i <= n; i++)
   ca[i] += a[i-1] + ca[i-1];
  for (int i = 1; i <= m; i++)
   cb[i] += b[i-1] + cb[i-1];
  ll maksi = 0;
  for (int i = 0; i <= n; i++){
    ll t = i;
    ll rem = k - ca[i];
    if (rem < 0)
     break;
    ll rez = upper_bound(cb.begin(),cb.end(),rem) - cb.begin() - 1;
    t+= rez;
    maksi = max(maksi,t);
  }
  cout << maksi;
}

Measured memory_bytes: 9528
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
N =int(input())
NN=num2alpha(N)
print(NN.lower())


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;

    bool rev = false;
    vector<char> vh;
    vector<char> ve;

    int Q;
    cin >> Q;
    REP(i, Q)
    {
        int tmp;
        cin >> tmp;
        if (tmp == 1)
        {
            rev = !rev;
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1)
            {
                if (!rev)
                    vh.push_back(c);
                else
                    ve.push_back(c);
            }
            else
            {
                if (!rev)
                    ve.push_back(c);
                else
                    vh.push_back(c);
            }
        }
    }

    if (!rev)
    {
        REP(i, vh.size())
        {
            cout << vh[vh.size() - 1 - i];
        }
        cout << S;
        REP(i, ve.size())
        {
            cout << ve[i];
        }
        cout << endl;
    }
    else
    {
        REP(i, ve.size())
        {
            cout << ve[ve.size() - 1 - i];
        }
        REP(i, S.size())
        cout << S[S.size() - 1 - i];
        REP(i, vh.size())
        {
            cout << vh[i];
        }
        cout << endl;
    }

    return 0;
}

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

#define Online 1
// #define multitest 1
#define Debug 1
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

void solve()
{
	int n,m,u,v;
	cin >> n >> m;
	vector<int> V(n+1);
	for(int i=0;i<m;++i)
	{
		cin >> u >> v;
		u--;
		v--;
		V[u]++;
		V[v+1]--;
	}
	int cnt = (V[0]==m);
	for(int i=1;i<n;++i)
	{
		// db(V[i]);
		V[i] = V[i] + V[i-1];
		cnt = cnt + (V[i]==m);
		// db(i,V[i],cnt);
	}
	cout << cnt;
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

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

const int maxn = 1e5 + 58;
int a[maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i] & 1;
	}
	if (n % 2 == 0) {
		if (sum % 2) cout << "First";
		else cout << "Second";
	}
	else {
		if (n == 1) cout << "Second";
		else if (sum % 2 == 0) {
//			vector <int> S;
//			for (int i = 0; i < n; i++) {
//				S.push_back(__builtin_ctz(a[i]));
//			}
//			sort(S.begin(), S.end());
//			if (S[0] == S.back()) cout << "Second";
			cout << "First";
		}
		else {
			vector <int> S;
			for (int i = 0; i < n; i++) {
				S.push_back(__builtin_ctz(a[i]));
			}
			sort(S.begin(), S.end());
			int t = 0;
			while (S[0] != S[1] && S[0] == 0) {
				int g = 0;
				for (int i = 0; i < n; i++) {
					if (__builtin_ctz(a[i]) == 0) {
						a[i]--;
					}
					g = __gcd(a[i], g);
				}
				int d = 0;
				S.clear();
				bool f = 0;
				for (int i = 0; i < n; i++) {
					a[i] /= g;
					d += a[i] & 1;
//					assert(a[i]);
					if (a[i])
						S.push_back(__builtin_ctz(a[i]));
					else f = 1;
				}
				sort(S.begin(), S.end());
				if (d % 2 && !f) t++;
				else break;
			}
			if (t % 2) cout << "First";
			else cout << "Second";
		}
	}
}


Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
    string A,B,C;
    cin >> A >> B >> C;
    bool a=false;
    if(A.at(A.size()-1)==B.at(0)){
        if(B.at(B.size()-1)==C.at(0)) a=true;
    }
    if(a)cout << "YES" << endl;
    else cout << "NO" << endl;
}

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


int main()
{
  int n;
  cin >> n;
  for (int i = 1; i <= 9; i++)
    if (n % i == 0 && n / i <= 9)
    {
      puts("Yes");
      return 0;
    }
  puts("No");
  return 0;
}

Measured memory_bytes: 256