akhauriyash/Code-Regression huggingface dataset:
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int INF=1000000;
char fi[101][101];
int d[21][21];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003

int dp[353][353]={0};
int bow[353][353]={0};


int main(){
	
	int n;
	while(cin>>n,n!=0){
		vector< vector<char> > c(n,vector<char>(n));
		vector< vector<int> > p(1200,vector<int>(1200));
		int maxwidth=0;
		rep(i,n){
			rep(j,n){
				cin>>c[i][j];
			}
		}
		
		rep(i,n){
			if(c[0][i]=='.')
				p[0][i]=1;
			else
				p[0][i]=0;
			if(c[i][0]=='.')
				p[i][0]=1;
			else
				p[i][0]=0;
		}
		
		for(int i=1;i<n;i++){
			for(int j=1;j<n;j++){
				if(c[i][j]=='.'){
					p[i][j]=min(p[i][j-1],min(p[i-1][j-1],p[i-1][j]))+1;
					maxwidth=max(maxwidth,p[i][j]);
				}
				else
					p[i][j]=0;
			}
		}
		cout<<maxwidth<<endl;	
	}
	
	

	
}

Measured memory_bytes: 7868
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a<<' '<<b<<' '<<-a-b+3*c<<endl;
    cout<<-2*a-b+4*c<<' '<<c<<' '<<2*a+b-2*c<<endl;
    cout<<a+b-c<<' '<<-b+2*c<<' '<<-a+2*c<<endl;
}

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

double distance(double x1, double y1, double x2, double y2) {
  return sqrt((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2));
}


int main() {
  int k=0;
  double x[20],y[20],xa,ya,S=0,a,b,c,z;
  while(scanf("%lf,%lf\n",&xa,&ya) == 2) {
    x[k] = xa;
    y[k] = ya;
    k++;
  }
  for(int i=0;i<k-2;i++) {
    a = distance(x[0],y[0],x[i+1],y[i+1]);
    b = distance(x[0],y[0],x[i+2],y[i+2]);
    c = distance(x[i+1],y[i+1],x[i+2],y[i+2]);
    z = (a + b + c) / 2;
    S += sqrt(z * (z - a) * (z - b) * (z - c));
  }
  printf("%.6lf\n",S);
}

Measured memory_bytes: 0
import sys
a,b,c = map(int,input().split())
ans = 0
pa = []
pb = []
while True:
  if a%2 == 1 or b%2 == 1 or c%2 == 1:
    break
  ans += 1
  lasta = a
  lastb = b
  lastc = c
  a = lastb/2 + lastc/2
  b = lasta/2 + lastc/2
  c = lasta/2 + lastb/2
  for i in range(len(pa)):
    if pa[i] == a:
      if pb[i] == b:
        print(-1)
        sys.exit()
  pa.append(a)
  pb.append(b)
print(ans)

Measured memory_bytes: 61944
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
bool noprime[1000005]={};
int main(){
	int a,d,n;
	noprime[1]=true;
	for(int i=2;i<=1000000;i++){
		if(!noprime[i]){
			for(int j=2;j*i<=1000000;j++){
				noprime[i*j]=true;
			}
		}
	}
	while(1){
		scanf("%d %d %d",&a,&d,&n);
		if(a+d+n==0) break;
		int cou=0;
		for(int i=a;;i+=d){
			if(!noprime[i]){
				cou++;
				if(cou==n){
					printf("%d\n",i); break;
				}
			}
		}
	}
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define Int long long




int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    Int n;
    cin>>n;
    Int cv=(n*(n+1))/2;
  	cv*=n;
  	for(int i = 1;i<=n;i++)
    {
        Int j = (n*(n+1))/2;
      	j-=(i)*(n-i+1);
        cv-=j;
    }
    for(int i = 1;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
      	cv-=(min(x,y)*(n-max(x,y)+1));
    }
    cout<<cv<<endl;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int>sunuke(N);
  for(int i=0;i<K;i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
      int A;
      cin >> A;
      sunuke.at(A-1) ++;
    }
  }

  int count = 0;
  for(int i=0;i<N;i++){
    if(sunuke.at(i)==0){
      count++;
    }
  }
  cout << count << endl;
}


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

using namespace std;
int N;

int main(){
    cin >> N;
    long long ans[N];
    ans[0] = 0;
    for(int i= 1; i <= N; i++){
        if(i % 5 == 0 || i % 3 == 0){
            ans[i] = 0;
            }
        else{ans[0] += i;}
    }
    cout << ans[0] << endl;
}

Measured memory_bytes: 11288
a,b,c,x,y=map(int, input().split())

if a+b<2*c:
    print(a*x+b*y)
    
else:
    if 2*c<a:
        a=2*c
    if 2*c<b:
        b=2*c
    if x<y:
        print(c*x*2+b*(y-x))
    else:
        print(c*y*2+a*(x-y))
        


Measured memory_bytes: 3060
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ld l;
    cin>>l;
    l = l/3.0;
    ld ans = pow(l,3.0);
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}


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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int n,x,a[1010];
int main() {
	read(n);read(x);
	for(int i=0;i<n;i++)read(a[i]);
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(x<a[i]){
			cout<<i<<endl;
			return 0;
		}
		x-=a[i];
	}
	if(x>0)cout<<n-1<<endl;
	else cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll sum = 0;
    rep(i, N) cin >> A[i], sum += A[i];
    sort(ALL(A));

    vector<ll> div;

    for (ll i = 1; i <= sqrt(sum) + 1; ++i){
        if(sum % i == 0) div.pb(i), div.pb(sum/i);
    }
    sort(ALL(div));

    ll ans = 1;

    for(auto d : div){
        if(d == 1) continue;
        vector<ll> tmp(N), S1(N), S2(N);
        rep(i, N) tmp[i] = A[i] % d;
        sort(ALL(tmp));

        rep(i,N){
            if(!i) S1[i] = tmp[i];
            else S1[i] = tmp[i] + S1[i-1];
        }
        rrep(i,N){
            if(i == N - 1) S2[i] = d - tmp[i];
            else S2[i] = d - tmp[i] + S2[i+1];
        }

        rep(i, N) rep(j,N) if(N - 1 - j > i) if(N - 1 - j - i == 1){
            if(S1[i] == S2[N - 1 - j]){
                if(S1[i] <= K) ans = max(ans, d);
                break;
            }
        }
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 384
N = int(input())
alist = [int(input()) for i in range(N)]
import numpy as np
### 三角形が成立しない場合を数える
alist.sort(reverse=False) #大きい方からチェックするとS/2に早く到達しやすい
MOD = 998244353
asum = [0]
for i in range(N):
    asum += [asum[-1] + alist[i]]
S = asum[-1]
Sharf = S / 2

#dptableA[i番目までは振り分けた][Rの合計] -> そこからR>=S/2となる数
dptableA = np.zeros((N+1, S+1), dtype=np.int) #[[0 for i in range(S+1)] for j in range(N+1)]
dptableA[N, int(np.ceil(Sharf)):] = 1
#dptableB[i番目までは振り分けた][Rの合計] -> そこからR=G=S/2, B=0となる数
dptableB = np.zeros((N+1, S+1), dtype=np.int) #[[0 for i in range(S+1)] for j in range(N+1)]
if S %2 == 0:
    dptableB[N, int(Sharf)] = 1 

#dpの計算をまとめて行う
for i in range(N, 0, -1): #後ろから見ていく
    n = i - 1
    an = alist[n]
    asn = asum[n]
    dptableA[n, 0:asn+1] = (2*dptableA[n+1, 0:asn+1] + dptableA[n+1, an:an+asn+1])%MOD
    #dptableA[n] = [(2*dptableA[n+1][k]+dptableA[n+1][k+alist[n]]) % MOD for k in range(asum[n]+1)]
    dptableB[n, 0:asn+1] = (dptableB[n+1, 0:asn+1] + dptableB[n+1, an:an+asn+1])%MOD
    #dptableB[n] = [(dptableB[n+1][k]+dptableB[n+1][k+alist[n]]) %MOD for k in range(asum[n]+1)]
retA, retB = dptableA[0,0], dptableB[0,0]
#全体 - (ある辺がS/2以上) + (2辺がS/2)
ans = (pow(3, N, MOD) - retA*3 + retB*3) % MOD
print(ans)

Measured memory_bytes: 431936
# -*- coding: utf-8 -*-

import sys
import os
import math

n = int(input())
if n == 1:
    # 4
    print(4)
    print(2)
elif n == 2:
    # 8, 9
    print(8)
    print(4)
    print(3)
else:
    a = 1
    for i in range(1, n + 2):
        a *= i
    print(a - n - 1)

    for i in range(n + 1, 1, -1):
        print(i)

Measured memory_bytes: 7800
//Author: master19
#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 int
#define ff first 
#define ss second 
#define pb push_back
#define endl "\n"
#define mod 1000000007LL // fixed...
#define modd 1000000007LL // Can be changed for global use
#define all(arr) arr.begin(),arr.end()
#define x(arr) arr.begin(),arr.end()
#define ulli unsigned long long int
#define assign(x,val) memset(x,val,sizeof(x))
#define prec(val, dig) fixed << setprecision(dig) << val
#define Sort(arr) sort(arr.begin(), arr.end())
#define lower(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define upper(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
#define crap ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define get(arr, num) vector < ll > arr(num); for(int i=0; i<num; i++)cin >> arr[i];
#define get_set(arr, num, st, type) set < type > st; for(int i=0; i<num; i++) st.insert(arr[i]);
#define put(arr, num) for(int i=0; i<num; i++)cout << arr[i] << " "; cout << endl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > new_ds; 
void debug_out() { cerr << endl; }
template <typename HeadStart, typename... TailEnd>
void debug_out(HeadStart H, TailEnd... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
ll lets_do_it();
pair < ll, ll > xy[] = {{-1, 0}, {1, 0} , {0, -1}, {0, 1}};
pair < ll, ll > dig[] = {{-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
bool isValid(ll x, ll y, ll row, ll col){
    return ((x>=0) && (y >=0)  && (x < row) && (y < col));
}
int main(int argc, const char** argv) {
    crap;
    ll test = 1;
    // cin >> test;
    for(int loop=0; loop<test; loop++){
        // cout << "Case #" << (loop+1) << ": "; 
        lets_do_it();
    }
    return 0;
}
ll lets_do_it(){
    // Your code goes by here !!
    string first, second;
    cin >> first >> second;
    ll mini = first.length();
    ll value = 0;
    for(int i=0; i<=first.length() - second.length(); i++){
        value = 0;
        for(int j=0; j<second.length(); j++){
            if(first[i+j] == second[j])
                continue;
            else
                value++;
        }
        mini = min(mini, value);
    }
    cout << mini << endl;



    return 0;
}


Measured memory_bytes: 3644
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let d = 1000000007;
    let mut ps = vec![0; 1000000];
    let mut h = 0;
    for &a in &v {
        for (p, r) in factor(a) {
            ps[p] = max(ps[p], r);
        }
        h = (h + inv_m(a, d)) % d;
    }
    let mut l = 1;
    for i in 2..1000000 {
        if ps[i] > 0 {
            l = l * pow_m(i, ps[i], d) % d;
        }
    }
    println!("{}", l * h % d);
}

fn factor(mut n: usize) -> Vec<(usize, usize)> {
    let mut ret = vec![];
    let mut p = 0;
    while n % 2 == 0 {
        p += 1;
        n /= 2;
    }
    if p != 0 {
        ret.push((2, p));
    }
    let mut r = 3;
    while r * r <= n {
        p = 0;
        while n % r == 0 {
            p += 1;
            n /= r;
        }
        if p != 0 {
            ret.push((r, p));
        }
        r += 2;
    }
    if n != 1 {
        ret.push((n, 1));
    }
    ret
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n, d - 2, d)
}


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

int main() {
  	int N;
	cin >> N;
  
  string S;
  cin >> S;
  vector<int> c(N);
  for(int i=1; i<N; i++){
    if(S.at(i)=='E') c.at(0)++;
    }
  int leader = 0;
  for(int i=1; i<N; i++){
  	c.at(i) = c.at(i-1);
    if(S.at(i-1)=='W') c.at(i)++;
    if(S.at(i)=='E') c.at(i)--;
    if(c.at(i) < c.at(leader)) leader = i;
  }
  cout << c.at(leader) << endl;
  return 0;
} 
    
    

Measured memory_bytes: 1796
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
#define RI register int
const int MAXN=2000000;
const int MAXM=20000000;
const int MX=1000000000;
int n,a[MAXN+10],b[MAXN+10],p[2][MAXN+10],lp,lop;
int lc[MAXN+10],rc[MAXN+10],sz=1;
vector<int> ch[MAXN+10];
int fir[MAXN+10],nxt[MAXM+10],to[MAXM+10],tote;
int dfn[MAXN+10],low[MAXN+10],dfstime,in[MAXN+10],cnt,S[MAXN+10],top;bool inS[MAXN+10];
void dfs(int u)
{
	dfn[u]=low[u]=++dfstime;S[++top]=u;inS[u]=true;
	for(RI i=fir[u],v;v=to[i],i;i=nxt[i])
	{
		if(!dfn[v])dfs(v),low[u]=min(low[u],low[v]);
		else if(inS[v])low[u]=min(low[u],dfn[v]);
	}
	if(dfn[u]==low[u])
	{
		++cnt;int now=-1;
		while(now!=u)
		{
			now=S[top--];
			inS[now]=false;
			in[now]=cnt;
		}
	}
}
inline void adde(int u,int v){to[++tote]=v;nxt[tote]=fir[u];fir[u]=tote;}
void initlinker(int o)
{
	if(lc[o])adde(o,lc[o]),initlinker(lc[o]);
	if(rc[o])adde(o,rc[o]),initlinker(rc[o]);
	for(int i=0;i<(int)ch[o].size();++i)adde(o,ch[o][i]);
}
void link(int ql,int qr,int o=1,int l=1,int r=MX)
{
	if(!o)return;
	if(ql==l&&qr==r)
	{
		if((*lower_bound(ch[o].begin(),ch[o].end(),lop))!=lop){adde(lp,o);return;}
		else if(l==r)for(RI i=0;i<(int)ch[o].size();++i)if(ch[o][i]!=lop)adde(lp,ch[o][i]);
	}
	int mid=(l+r)>>1;
	if(qr<=mid)link(ql,qr,lc[o],l,mid);
	else if(ql>mid)link(ql,qr,rc[o],mid+1,r);
	else link(ql,mid,lc[o],l,mid),link(mid+1,qr,rc[o],mid+1,r);
}
inline bool check(int w)
{
	if(w==0)return true;
	for(RI i=1;i<=sz;++i)fir[i]=dfn[i]=0;dfstime=cnt=tote=0;
	initlinker(1);
	for(int i=1;i<=n;++i)
	{
		lp=p[0][i];lop=p[1][i];
		link(max(1,a[i]-w+1),min(MX,a[i]+w-1));
		swap(lp,lop);
		link(max(1,b[i]-w+1),min(MX,b[i]+w-1));
	}
	for(int i=1;i<=sz;++i)if(!dfn[i])dfs(i);
	for(int i=1;i<=n;++i)if(in[p[0][i]]==in[p[1][i]])return false;
	return true;
}
void insert(int& p,int q,int o=1,int l=1,int r=MX)
{
	if(l==r){ch[o].push_back(p=++sz);return;}
	int mid=(l+r)>>1;
	if(q<=mid)insert(p,q,(lc[o]?lc[o]:(lc[o]=++sz)),l,mid);
	else insert(p,q,(rc[o]?rc[o]:(rc[o]=++sz)),mid+1,r);
	ch[o].push_back(p);
}
int read()
{
	int res;char ch;
	while(!isdigit(ch=getchar()));
	res=ch-'0';
	while(isdigit(ch=getchar()))res=res*10-'0'+ch;
	return res;
}
int main()
{	n=read();
	for(RI i=1;i<=n;++i)
	{
		a[i]=read();b[i]=read();
		insert(p[0][i],b[i]);insert(p[1][i],a[i]);
	}
	for(RI i=1;i<=sz;++i)sort(ch[i].begin(),ch[i].end());
	int left=0,mid,right=MX,ans=0;
	while(left<=right)
	{
		mid=(left+right)>>1;
		if(check(mid))
		{
			ans=mid;
			left=mid+1;
		}
		else right=mid-1;
	}
	printf("%d",ans);
	return 0;
}

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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

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

  int hoge = (N%100)%10;

  int mod1[] = {2,4,5,7,9};
  int mod2[] = {0,1,6,8};

  rep(i,5) {
    if(hoge == mod1[i]){
      cout << "hon" << endl;
      return 0;
    }
  }
  rep(i,4){
    if(hoge == mod2[i]){
      cout << "pon" << endl;
      return 0;
    }
  }
  cout << "bon" << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    cin >> str;
    int sz;
    sz = str.size();
    for( int i=0; i<sz; i++){
        if(str[i] == '1'){
            str[i] = '9';
        }else if( str[i] == '9'){
            str[i] = '1';
        }
    }
    cout << str << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(long long N){
    vector<vector<string>> v(N);
    v[0].push_back("a");
    for (long long i = 1; i < N; i++) {
        for (long long j = 0; j < v[i-1].size(); j++) {
            // char last=v[i-1][j].at(i-1);
            // debg(last);
            char mac='a';
            for (long long l = 0; l < v[i-1][j].size(); l++) {
                mac=max(mac, v[i-1][j][l]);
            }
            for (long long k = 0; k < mac-'a'+2; k++) {
                char addc='a'+k;
                v[i].push_back(v[i-1][j]+addc);
            }
        }
    }
    // vout(v[1]);
    for (long long i = 0; i < v[N-1].size(); i++) {
        cout << v[N-1][i] << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 11380
# %% constants & libraries
# ------------------------

# %% body
# -------

@inbounds function main(io = stdin)
    readto(target = '\n') = readuntil(io, target)
    readnum(T::Type{<:Number} = Int; dlm = isspace, kwargs...) =
        parse.(T, split(readto(), dlm; kwargs...))::Vector{T}

    # handle IO and solve
    H, W, M = readnum()
    G = Set{Tuple{Int,Int}}()
    Rcnt, Ccnt = Dict{Int,Int}(), Dict{Int,Int}()
    for h in 1:M
        h, w = readnum()
        push!(G, (h, w))
        Rcnt[h] = get(Rcnt, h, 0) + 1
        Ccnt[w] = get(Ccnt, w, 0) + 1
    end

    maxr = first(findmax(Rcnt))
    maxc = first(findmax(Ccnt))
    ret = maxr + maxc

    rs = filter(Rcnt) do (k,v)
        v == maxr
    end |> keys |> collect
    cs = filter(Ccnt) do (k,v)
        v == maxc
    end |> keys |> collect

    for r in rs
        for c in cs
            (r, c) ∉ G && return println(ret)
        end
    end
    return println(ret - 1)
end

@static if @isdefined(Juno) || @isdefined(VSCodeServer)
    main(open(replace(@__FILE__, r"(.+)\.jl" => s"\1.in")))
else
    main()
end


Measured memory_bytes: 267000
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    auto b = a;
    sort(all(b));
    b.erase(unique(all(b)), b.end());
    int sz = b.size();
    map<int, int> mp;
    rep(i, sz) {
        mp[b[i]] = i;
    }
    vector<int> cnt(sz, 0);
    rep(i, n) {
        cnt[mp[a[i]]] ++;
    }
    vector<int> c(sz + 1, 0);
    rep(i, sz) {
        c[i + 1] = c[i] + cnt[i];
    }
    vector<int> d(sz + 1, 0);
    rep(i, sz) {
        if(i - 1 >= 0) d[i + 1] = d[i] + (b[i] - b[i - 1]) * (n - c[i]);
        else d[i + 1] = d[i] + b[i] * (n - c[i]);
    }
    
    int ma = 0;
    int bf = 0;
    rep(i, n) {
        if(ma < a[i]) {
            ma = a[i];
            cout << d[mp[a[i]] + 1] - bf << endl;
            bf = d[mp[a[i]] + 1];
        } else {
            cout << 0 << endl;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        P[y]=x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def DD(x):
  dis=0
  while x>=0:
    dis=dis+D[x]
    x=P[x]
  return dis

n,m=map(int,input().split())
uf=UnionFind(n)
D=[0]*n
P=[-1]*n
f=0
for i in range(m):
  l,r,d=map(int,input().split())
  l=l-1
  r=r-1
  if uf.find(l)!=uf.find(r):
    if uf.parents[uf.find(l)]<=uf.parents[uf.find(r)]:
      D[uf.find(r)]=DD(l)+d-DD(r)
    else:
      D[uf.find(l)]=DD(r)-d-DD(l)
    uf.union(l,r)
  else:
    if DD(r)-DD(l)!=d:
      f=1
if f==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 136536
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){

    int[4] bty;
    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	auto s1 = split(chomp(s),',');
	if(s1[1]=="AB") s1[1] = "C";
	if(s1[1]=="O") s1[1] = "D";
	bty[to!int (to!char(s1[1]) - 'A')]++;
    }
    foreach(i;bty) writeln(i);
}

Measured memory_bytes: 2392
#include<bits/stdc++.h>
using namespace std ; 
typedef long long ll;
#define forn(i,e) for(ll i=0; i<e; i++)
#define endl "\n"
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PB push_back 
#define MP make_pair
#define F first
#define S second


int main()
{

zoom;

  ll a , b , c; cin >> a >> b >> c  ; 
  
  if((a+b+c) <22 )
    cout << "win" <<endl ; 
  else cout << "bust" <<endl ; 

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m)-((m)>(n));i!=(n)-((m)>(n));i+=2*((m)<(n))-1)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
bool is[100001];
int a[100],n;

bool find(int k) {
	fop (i,0,n) {
		if (k-a[i]>=0) {
			if (!is[k-a[i]]) {
				is[k]=true;
				return true;
			}
		}
	}
	is[k]=false;
	return false;
}



int main () {
	int m;
	cin >> n >> m;
	fop (i,0,n) {
		cin >> a[i];
	}
	is[0]=false;
	fop (i,1,m+1) find(i);
	if (is[m]) cout << "First" << endl;
	else cout << "Second" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

lli modexp(lli a, lli n) {

    lli r = 1;
    while(n) {
        if(n & 1) {
            r = (r * a) % mod;
        }
        a = (a * a) % mod;
        n >>= 1;
    }

    return r;

}

void solve()
{

    lli n, k;
    cin>>n>>k;

    lli fact[2007] = {};

    fact[1] = 1;
    fact[0] = 1;
    for(int i = 2; i <= n; i ++) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
    }

    for(int i = 1; i <= k; i ++) {
        lli X = n - k + 1;
//        cout<<"DSD"<<endl;
        lli ans = fact[X];
        if(X < i) {
            ans = 0;
        }
//        cout<<ans<<endl;
        lli t = modexp(fact[i], mod - 2);
        ans *= t;
        ans %= mod;
        t = modexp(fact[X - i], mod - 2);
        ans *= t;
        ans %= mod;
        lli mul = fact[k - 1] * modexp(fact[i - 1], mod - 2);
        mul %= mod;
        mul = (mul* modexp(fact[k - i], mod - 2)) % mod ;
//        cout<<mul<<endl;
        ans = (ans * mul) % mod;
        cout<<ans<<endl;
    }

    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main() {
  ll k;
  cin >> k;

  ll ans = 0;
  for (ll i = 1; i <= k; ++i) {
    for (ll j = 1; j <= k; ++j) {
      for (ll l = 1; l <= k; ++l) {
        ans += gcd(i, gcd(j, l));
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

vector<int> dp;
vector<vector<int>> g;
int f(int n){
    if(dp[n] != -1) return dp[n];
    int a=0;
    for(int b : g[n]){
        a = max(a,f(b)+1);
    }
    return dp[n] = a;
}

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

    int n,m;
    cin >> n >> m;
    g = vector<vector<int>> (n,vector<int> (0));
    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--;y--;
        g[x].push_back(y);
    }

    int ans = 0;
    dp = vector<int> (n,-1);
    rep(i,n){
        ans = max(ans,f(i));
    }

    cout << ans << endl;


    cout << endl;
    return 0;
}


Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();
		System.out.println((a<=c&&c<=b)? "Yes":"No");
	}
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);

struct Edge {
  int to;
  int cost;
};

class SingleSourceGraph {
  protected:
    int vertex;
    int start;
    std::vector<long long> dist;
    std::vector<int> prev;
    std::vector<std::vector<Edge> > list;

  public:
    long long inf = LLONG_MAX / 3;

    SingleSourceGraph(int v, int s);

    
    virtual void push(int from, int to, int cost) = 0;

    void dijkstra();

    std::vector<long long> get_dist();
    std::vector<int> get_path(int d);
};

SingleSourceGraph::SingleSourceGraph(int v, int s) {
  vertex = v;
  start = s;
  list.resize(vertex);
  dist.resize(vertex);
  prev.resize(vertex);
  for (int i = 0; i < vertex; ++i) {
    dist[i] = inf;
    prev[i] = -1;
  }
  dist[start] = 0;
}

void SingleSourceGraph::dijkstra() {
  std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > > pq;
  pq.push(std::make_pair(0, start));

  while (!pq.empty()) {
    int cost = pq.top().first;
    int v = pq.top().second;
    pq.pop();

    for (int i = 0; i < (int)list[v].size(); ++i) {
      Edge e = list[v][i];
      if (cost + e.cost < dist[e.to] ) {
        prev[e.to] = v;
        dist[e.to] = cost + e.cost;
        pq.push(std::make_pair(dist[e.to], e.to));
      }
    }
  }
}

std::vector<long long> SingleSourceGraph::get_dist() {
  return dist;
}

std::vector<int> SingleSourceGraph::get_path(int d) {
  std::vector<int> path;
  int v = d;
  while (v != start) {
    path.push_back(v);
    v = prev[v];
  }
  path.push_back(v);
  std::reverse(path.begin(), path.end());
  return path;
}

class SingleSourceDirectedGraph : public SingleSourceGraph {
  using SingleSourceGraph::SingleSourceGraph;

  public:
  void push(int from, int to, int cost) {
    Edge e;
    e.to = to;
    e.cost = cost;
    list[from].push_back(e);
  }
};

class SingleSourceUndirectedGraph : public SingleSourceGraph {
  using SingleSourceGraph::SingleSourceGraph;

  public:
  void push(int from, int to, int cost) {
    Edge e;
    e.to = to;
    e.cost = cost;
    list[from].push_back(e);

    e.to = from;
    e.cost = cost;
    list[to].push_back(e);
  }
};

int main() {
  
  int v;
  int e;
  int s;

  scanf("%d %d %d", &v, &e ,&s);

  SingleSourceDirectedGraph g = SingleSourceDirectedGraph(v, s);

  int from, to, cost;

  for (int i = 0; i <  e; i++) {
    scanf("%d %d %d", &from, &to, &cost);
    g.push(from, to, cost);
  }

  g.dijkstra();
  std::vector<long long> dist = g.get_dist();

  for (long long d: dist) {
    if (d == g.inf) printf("INF\n");
    else printf("%lld\n", d);
  }
}



Measured memory_bytes: 13712
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false




signed main(void){
    int A,B,H,W;
    cin >> A >>B >> H >> W;
    double Ax,Ay,Bx,By;
    Ax = (double)A * cos((((double)H*60+(double)W)/720)*2*PI);
    Ay = (double)A * sin((((double)H*60+(double)W)/720)*2*PI);
    Bx = (double)B * cos(((double)W/60)*2*PI);
    By = (double)B * sin(((double)W/60)*2*PI);
    double Ans = hypot(Ax-Bx,Ay-By);
    printf("%.12f\n",Ans);
    return 0;
}




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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<ll> &s, ll a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

struct Frequency {
    int n, f;
};

vector<Frequency> frequency(map<int, int> &m) {
    vector<Frequency> res;
    for (auto e : m) {
        res.push_back({e.first, e.second});
    }
    sort(res.begin(), res.end(), [](Frequency f, Frequency g) {
        return f.f > g.f;
    });
    res.push_back({0, 0});
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<int> numbers(n);
    rep(i, n) cin >> numbers[i];


    vector<Frequency> a, b;
    {
        map<int, int> m;
        rep(i, n) {
            if (i % 2 == 0) continue;
            m[numbers[i]]++;
        }
        a = frequency(m);
    }
    {
        map<int, int> m;
        rep(i, n) {
            if (i % 2 == 1) continue;
            m[numbers[i]]++;
        }
        b = frequency(m);
    }

    int n2 = n / 2;
    if (a.front().n != b.front().n) {
        cout << (n2 - a.front().f) + (n2 - b.front().f) << endl;
    } else if (a[1].f > b[1].f) {
        cout << (n2 - a[1].f) + (n2 - b.front().f) << endl;
    } else {
        cout << (n2 - a.front().f) + (n2 - b[1].f) << endl;
    }

}



Measured memory_bytes: 4088
#include <stdio.h>

typedef long long ll;

void solve(ll *low, ll *f,ll b) {

ll i;

for (i = 1ll; i <= 100000ll; i += 1ll) {
if ((i*i) - i > 2ll * b) {
break;
}
ll x = -(i*i) + i + (2ll * b);
if (x > 0ll && x % (2ll * i) == 0ll) {
*low = x / (2ll * i);
*f = i;
}
}


}

int main() {

ll low,floor,b;

while (1) {
scanf("%lld",&b);
if (b == 0ll) { break; }
solve(&low,&floor,b);
printf("%lld %lld\n", low, floor);
}

return 0;
}


Measured memory_bytes: 2132
#!/usr/bin/env python3
import sys


def solve(N: int):
    def f(i, h):
        if i == N:
            yield ""
            return
        for c in range(ord('a'), h):
            for s in f(i+1, h):
                yield chr(c) + s
        for s in f(i+1, h+1):
            yield chr(h) + s
    return f(0, ord('a'))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(*solve(N), sep="\n")

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 17792
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string str;
	cin >> str;
	int A = (int)(str[0] - '0');
	int B = (int)(str[1] - '0');
	int C = (int)(str[2] - '0');
	int D = (int)(str[3] - '0');

	for(int mask = 0; mask < 1 << str.length(); mask++) {
		int rsl = (int)(str[0] - '0');
		string txt = "";
		rep(i, 1, str.length()) {
			int tmp = (int)(str[i] - '0');
			if(mask & (1 << i)) {
				rsl += tmp;
				txt += "+";
			} else {
				rsl -= tmp;
				txt += "-";
			}
		}
		if(rsl == 7) {
			cout << str[0] ;
			rep(i, 1, str.length()) {
				cout << txt[i - 1] << str[i];
			}
			cout << "=7" << endl;
				
			return 0;
		}
	}
	
}


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

       

int main(){
  long long n;
  cin>>n;
  vector<long>u(n);
  vector<long>m(n);
  vector<long>d(n);
  for(int i=0;i<n;i++){
    cin>> u.at(i);
  }
  for(int i=0;i<n;i++){
    cin >>m.at(i);
  }
  for(int i=0;i<n;i++){
    cin >>d.at(i);
  }
  sort(u.begin(),u.end());
  sort(m.begin(),m.end());
  sort(d.begin(),d.end());
  long long ans=0;
  long long j=0;
  long long k=0;
  for(int i=0;i<n;i++){
    long long M=m.at(i);
    for(;j<n;j++){
      if(M>u.at(j)){
        continue;
      }
      break;
    }
    for(;k<n;k++){
      if(M>=d.at(k)){
        continue;
      }
      break;
    }

    ans+=(j)*(n-k);
  }
      
  cout <<ans;
}

Measured memory_bytes: 2560
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

ll dp[41][410][410] ;

int main(){
	ll n,ma,mb ;
	cin >> n >> ma >> mb ;
	for(int i=0;i<=n;i++) for(int j=0;j<=400;j++) for(int k=0;k<=400;k++) dp[i][j][k] = INF ;
	dp[0][0][0] = 0 ;
	for(int i=1;i<=n;i++){
		ll a,b,c ;
		cin >> a >> b >> c ;
		for(int j=0;j<=400;j++){
			for(int k=0;k<=400;k++){
				dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k]) ;
				if(j>=a&&k>=b){
					dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-a][k-b]+c) ;
				}
			}
		}
	}
	ll ans = INF ;
	for(int i=1;i*max(ma,mb)<=400;i++) ans = min(ans,dp[n][i*ma][i*mb]) ;
	cout << (ans==INF?-1:ans) << endl ;
}


Measured memory_bytes: 56436
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;

int mod = 1000000007;
ll dp[100005];;

ll gcd(long long a,long long b){

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

int coprime(int a,int b){

 int gcd;

  while(a!=0){
     gcd = a;
     a = b%a;
     b = gcd;
  }

  if(gcd == 1)
    return 1;
  else return 0;

}

// sorting the map elements by the second
// if the second value is equal then sorting is done on the first basis of the first element
bool compare(pair<int,int>p1, pair<int,int>p2){

    if(p1.second == p2.second)
        return p1.first < p2.first;

  return p1.second > p2.second;
 }

 // sorting the map when the first is string ans second is the integer
 bool sortbyval(pair<string,int>a, pair<string,int>b){

     if(a.second == b.second)
        return  a.first < b.first;

   return a.second < b.second;
 }




int main(){

 int l,r,d;
 int cnt=0;
 cin>>l>>r>>d;

 for(int i=l;i<=r;i++){

  if(i%d == 0)
    cnt++;
 }

  cout<<cnt<<endl;

return 0;
}


Measured memory_bytes: 3592
N, M =map(int,input().split())
students = [list(map(int,input().split())) for _ in range(N)]
checkpoints = [list(map(int,input().split())) for _ in range(M)]

def calc_nearest(student,checkpoints):
    nearest_idx = 50
    max_dist = 10**9
    i = 1
    for checkpoint in checkpoints:
        dist = abs(student[0]-checkpoint[0]) + abs(student[1]-checkpoint[1])
        if max_dist > dist:
            nearest_idx = i
            max_dist = dist
        i += 1
    return nearest_idx

for student in students:
    print(calc_nearest(student,checkpoints))

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    
    ll sum=0;
    ll ans=0;
    int mod = 1000000007;
    rep(i,N){
        cin >> A.at(i);
        sum += A.at(i);
        sum %= mod;
    }
    rep(i,N){
        sum -= A.at(i);
        if(sum<0){
            sum += mod;
        }
        ans += A[i] * sum;
        ans %= mod;
    }

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

Measured memory_bytes: 4056
#include "bits/stdc++.h"
using namespace std;
int main()
{
  long long int a,n,i;
  cin>>a>>n;
  string s;cin>>s;
  for(i=0;i<a;i++)
  {
    if(i==n-1)
    {
      cout<<char(int(s[i]+32));
    }
    else 
    {
      cout<<s[i];
    }
    
  }
  return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var n = lines[0];
 var sum = 0;
 for(i=1; i<=n; i++){
   if(i % 3 == 0 && i % 5 == 0){
     continue;
   }else if(i % 3 == 0){
     continue;
   }else if(i % 5 == 0){
     continue;
   }else{
     sum += i;
   }

 }

 console.log(sum);
});


Measured memory_bytes: 35912
#include <stdio.h>

int main(void){
  int i,j,prm[1000000];
  
  for(i=0;i<1000000;i++) prm[i]=1;
  for(i=4;i<1000000;i+=2) prm[i]=0;
  prm[0]=0;
  prm[1]=0;
  for(i=3;i*i<1000000;i+=2){
    if(prm[i]==1){
      for(j=i+i;j<1000000;j+=i) prm[j]=0;
    }
  }
  
  int n;
  while((scanf("%d",&n))!=EOF){
    if(n==0)  break;
    else{
      int i=0,j=0;
      int sum=0;
      while(j<n){
	if(prm[i]==1){
	  j++;
	  sum+=i;
	}
	i++;
      }
      printf("%d\n",sum);
    }
  }
  return 0;
}

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

int INF = 1000000;

int main(){
  int N,mini,ans = 0;cin >> N;
  int A[100 + 1], B[100];
  for(int i = 0;i < N;++i)
    A[i] = -1;
  for(int i = 0;i < N - 1;++i)
    cin >> B[i];
  for(int i = 0;i < N - 1;++i){
    int minc = INF;
    for(int j = 0;j < N - 1;++j){
      if(B[j] < minc){
        minc = B[j];
        mini = j;
      }
    }
    if(A[mini] == -1)
      A[mini] = B[mini];
    if(A[mini + 1] == -1)
      A[mini + 1] = B[mini];
    B[mini] = INF;
  }
  for(int i = 0;i < N;++i)
    ans += A[i];
  cout << ans;
}


Measured memory_bytes: 256