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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll l;

	cin >> l;

	bitset<21> bs(l);

	vector<ll> v;
	v.push_back(1);

	REP(i, 21) {
		v.push_back(v[i] * 2);
	}

	vector<tuple<ll, ll, ll>> ans;
	ll n = 2;
	ll m;
	ll prev = -1;

	RREP(i, 21) {
		if (prev < 0 && bs[i] == 1) {
			REP(j, i) {
				ans.push_back(make_tuple(j + 1, n, 0));
				ans.push_back(make_tuple(j + 1, n, v[j]));
				n++;
			}
			prev = i;
			n--;
		}
		else if (bs[i] == 1) {
			l -= v[i];
			ans.push_back(make_tuple(i + 1, n, l));
		}
	}

	m = ans.size();

	cout << n << " " << m << endl;

	ll uu, vv, ww;

	REP(i, m) {
		tie(uu, vv, ww) = ans[i];
		cout << uu << " " << vv << " " << ww << endl;
	}
}

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

#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c\n",c)
typedef long long int ll;
int min(ll a,ll b){
  if(a>b)return b;
  return a;
}
int main(void){
  ll l,r,ans=2019,i,j;
  scanf("%lld %lld",&l,&r);
  for(i=l;i<r;i++){
    for(j=i+1;j<=r;j++){
      ans=min(ans,i*j%2019);
      if(!ans){
        PRN(0);
        return 0;
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"YES"<<endl
#define printno cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b)?gcd(b,a%b):b;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  startupcpp();
  ll i,j,k,l,N,M;
  string s,t;
  cin>>s>>t;
  vec a(s.size()+1,0),b(t.size()+1,0);
  rep(i,s.size()){
    a[i+1]=(s[i]=='B')+1+a[i];
  }
  rep(i,t.size()){
    b[i+1]=(t[i]=='B')+1+b[i];
  }
  cin>>N;
  while(N--){
    cin>>i>>j>>k>>l;
    i--;k--;
    M=a[j]-a[i]-(b[l]-b[k])+3*(a.size()+b.size());
    if(M%3==0)printyes;
    else printno;
  }
}

Measured memory_bytes: 2512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
#define ll long long
const int maxn=5e5+10; 
ll read()
{
	char c=getchar();
	ll x=0;
	int flag=1;
	while(c<'0'||c>'9')
	{
		if(c=='-')flag=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-48;
		c=getchar();
	}
	x*=flag;
	return x;
}
struct node
{
	int x,y,t;
}v[maxn];
int n;
int main()
{
	v[0].x=v[0].y=v[0].t=0;n=read();
	for(int i=1;i<=n;i++)
	{
		v[i].t=read(),v[i].x=read(),v[i].y=read();
	}
	for(int i=1;i<=n;i++)
	{
		if(v[i].x+v[i].y-v[i-1].x-v[i-1].y>v[i].t-v[i-1].t||(v[i].x+v[i].y+v[i-1].x+v[i-1].y+v[i].t-v[i-1].t)%2!=0)
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1408
#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; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
ll n,a=0,b=0,count=0; cin>>n; 
vector<int> p(n); REP(i,n)cin>>p[i];
vector<int> r(n); REP(i,n)r[i]=i+1;
vector<int> q(n); REP(i,n)cin>>q[i];

do{
   if(r==p)a=count;
   if(r==q)b=count;
   count++;
 }while(next_permutation(ALL(r)));

cout<<abs(a-b)<<endl; 
}

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

int n,f[200101],ans,hd[201001],x,y,cnt,fa[201001];
struct node{int to,next;}e[401001];

void addedge(int x,int y)
{
	e[++cnt]=(node){y,hd[x]},hd[x]=cnt;
	e[++cnt]=(node){x,hd[y]},hd[y]=cnt;
}

void dfs(int x)
{
	int ma=0,Ma=0;
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa[x])
		{
			fa[e[i].to]=x,dfs(e[i].to);
			if (f[e[i].to]>ma) Ma=ma,ma=f[e[i].to]; else
			if (f[e[i].to]>Ma) Ma=f[e[i].to];
		}
	f[x]=ma+1,ans=max(ans,ma+Ma+1);
}

int main()
{
	scanf("%d",&n);
	for (int i=1; i<n; i++)
		scanf("%d%d",&x,&y),addedge(x,y);
	ans=0,dfs(1),puts(ans%3==2?"Second":"First");
	return 0;
}

Measured memory_bytes: 14720
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define SUBIF(a, b, x) ((x) ? (b) : (a))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647LL
#define MOD 1000000007LL
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int n;
bool isPrime[10010];
VI prime;
PII ans[10010];


void makePrime(){
	fill(RNG(isPrime, 10001), true);
	isPrime[0] = isPrime[1] = false;
	for(int i = 2;i*i <= 10000;i++)
		if(isPrime[i])
			for(int j = 2;i*j <= 10000;j++) isPrime[i*j] = false;
	rep(i, 0, 10010)
		if(isPrime[i]) prime.pb(i);
}


void makeAns(){
	ans[5] = { 3, 5 };
	repe(i, 6, 10000){
		if(!isPrime[i]){
			ans[i] = ans[i-1];
			continue;
		}
		int pi = distance(prime.begin(), lower_bound(ALL(prime), i));
		if(prime[pi]-prime[pi-1] == 2) ans[i] = { prime[pi-1], prime[pi] };
		else ans[i] = ans[i-1];
	}
}


int main(){
	makePrime();
	makeAns();
	while(cin >> n, n) cout << ans[n].first << ' ' << ans[n].second << endl;

	return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <deque>
#include <math.h>
#include <map>
#include <stack>
#include <list>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <cstring>
#include <climits>
#include <iterator>
#include <cassert>
#include <string>
using namespace std;

#define REP(i, n) for(int i=0;i<n;i++)
#define REPE(i, n) for(int i=0;i<=n;i++)
#define REP2(i, j, n) for(int i=j;i<n;i++)
#define REP2E(i, j, n) for(int i=j;i<=n;i++)
#define REP3(i, j, n, s) for(int i=j;i<n;i+=s)
#define REP3E(i, j, n, s) for(int i=j;i<=n;i+=s)
#define RREP(i, n) for(int i=n;i>=0;i--)
#define RREP2(i, n, j) for(int i=n;i>=j;i--)
#define MSI unordered_map<string, int>
#define MII unordered_map<int, int>
#define VI vector<int>
#define VL vector<long>
#define VPI vector<pair<int, int>>
#define VVI vector<VI>
#define VC vector<char>
#define VVL vector<VL>
#define VVPI vector<VPI>
#define MSVI unordered_map<string, VI>
#define MII unordered_map<int, int>
#define TCASES int t; cin>>t; while(t-- > 0)
#define MOD 1000000007
#define LL long long

int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	
	LL k;
	cin>>k;
	vector<LL> a(k);
	REP(i,k) cin>>a[i];

	LL hi=2,lo=2;
	for(long long i=k-1;i>=0;i--){

		if(lo > hi || hi < a[i]){
			cout<<"-1"<<endl;
			return 0;
		}

		LL new_hi = ((hi/a[i])*a[i]) + a[i]-1;
		LL new_lo = (lo / a[i]) * a[i];
		if(new_lo < lo) new_lo += a[i];

		hi=new_hi;
		lo=new_lo;
	}

	if(lo > hi){
		cout<<"-1"<<endl;
		return 0;
	}

	cout<<lo<<" "<<hi<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, k;
    cin >> n >> k;
    int ans = 1;
    rep(i, n) {
        ans *= k - (i!=0);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int s;
    cin>>s;
    vector<vector<in>> dp(666,vector<in>(s+1,0));
    REP(i,3,s+1) dp[0][i]=1;
    in ans=0;
    ans += dp[0][s];

    for(int i=1;i<666;i++){
        in sum=0;
        REP(j,4,s+1){
            sum += dp[i-1][j-3];
            sum %= MOD;
            dp[i][j]=sum;
        }
        ans += dp[i][s];
        ans %= MOD;
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 13728
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0; s[i]!='\0'; i++){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    cout<<s<<"\n";

    return 0;
}


Measured memory_bytes: 3752
let () = Scanf.scanf "%d\n" @@ fun n ->
  let vs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun v -> v in
  Array.sort compare vs;
  Printf.printf "%.9f\n" @@
  Array.fold_left (fun s v -> (s +. float_of_int v) *. 0.5) (float_of_int vs.(0)) vs



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

struct Sushi {
  int t, d;
  Sushi(){};
  Sushi(int _t, int _d) { t = _t, d = _d; };
};

signed main() {
  int n, k;
  cin >> n >> k;
  vector<Sushi> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i].t >> s[i].d;
  }
  sort(begin(s), end(s), [&](Sushi x, Sushi y) { return x.d > y.d; });

  auto c = [](Sushi x, Sushi y) { return x.d > y.d; };
  priority_queue<Sushi, vector<Sushi>, decltype(c)> pq(c);

  vector<int> score(n + 1);
  vector<bool> used(n + 1, false);
  int sum = 0, cnt = 0;
  for (int i = 0; i < k; ++i) {
    sum += s[i].d;
    if (used[s[i].t])
      pq.push(s[i]);
    else
      used[s[i].t] = true, cnt++;
  }
  score[cnt] = sum + cnt * cnt;
  for (int i = k; i < n && !pq.empty(); ++i)
    if (!used[s[i].t]) {
      sum = sum - pq.top().d + s[i].d;
      cnt++;
      score[cnt] = sum + cnt * cnt;

      used[s[i].t] = true;
      pq.pop();
    }
  int ans = *max_element(begin(score), end(score));
  cout << ans << endl;
}

Measured memory_bytes: 3708
use proconio::{input, fastout};
// use itertools::Itertools;

const MOD: u64 = 1_000_000_007;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }

    let mut ans = 0u64;
    let mut tmp = a[0];

    for i in 1..a.len() {
        // ans += a[0..i].iter().sum::<u64>() * a[i];
        ans += tmp * a[i];
        ans %= MOD;
        tmp += a[i];
        tmp %= MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 5604
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a, b, c;
        
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        
        if(a<b&&b<c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26160
N, K = map(int, input().split())
A=list(map(int,input().split()))
Acheck=[0 for i in range(N)]
nextI=1
count=0
firstCheck=True
secondCheck=True
if N<=K:
    while(secondCheck):
        Acheck[nextI-1]+=1
        if Acheck[nextI-1]==2 and firstCheck:
            #print("繰り返し始点",nextI)
            K-=count
            count=0
            firstCheck=False
        if Acheck[nextI-1]==3:
            secondCheck=False
            break
        count+=1
        nextI=A[nextI-1]
        #print(nextI,Acheck)
            
    #print(Acheck,count,nextI)
    for i in range(K%count):
        nextI=A[nextI-1]
    print(nextI)
else:
    for i in range(K):
        nextI=A[nextI-1]
    print(nextI)
        

Measured memory_bytes: 32004
#include<iostream>
using namespace std;
typedef long long LL;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	while (n >1) {
		n += 2;
		n /= 3;
		ans++;
	}
	cout << ans << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 3064
#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) unique(v.begin(), 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> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int N, A, B;
int h[100010];

bool C(ll T) {
	ll cnt = 0;
	rep(i, 0, N) {
		ll tmp = 1ll * h[i] - 1ll * B * T;
		if(tmp > 0) {
			cnt += tmp / (A - B);
			if(tmp % (A - B)) cnt++;
		}
	}

	return cnt <= T;
}

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

	cin >> N >> A >> B;
	rep(i, 0, N) cin >> h[i];

	int left = 0, right = 1e9;
	while(right - left > 1) {
		ll mid = (left + right) / 2;
		if(C(mid)) right = mid;
		else left = mid;
	}

	cout << right << endl;

}


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

int main() {
  int N;
  cin >> N;
  
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  double B = 0;
  for (int i = 0; i < N; i++) {
    B += 1.0/A.at(i);
  }
  printf("%.8lf\n", 1/B);
}
  
  

Measured memory_bytes: 3800
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

int main(void){
	int c[26]={};
	string S;
	cin>>S;
	if(S.length()<26){
		rep(i,S.length()){
			c[S[i]-'a']=1;
		}
		rep(i,26){
			if(c[i]==0){
				S+=char('a'+i);
				break;
			}
		}
	}else if(S=="zyxwvutsrqponmlkjihgfedcba"){
		S="-1";
	}else{
		irep(i,26){
			bool can=false;
			rep(j,26){//前から（小さいもの順に）
				if(c[j]==1 && S[i] < 'a'+j){
					S=S.substr(0,i);
					S+=char(j+'a');
					can=true;
					break;
				}
			}
			if(can)break;
			c[S[i]-'a']=1;
		}
	}
	printf("%s\n",S.c_str());
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
  int f[N2];
  int space;
  string path;
  bool operator < ( const Puzzle &p ) const {
    for( int i = 0 ; i <  N2 ; i++ ){
      if( f[i] == p.f[i] ) continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const int dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p){
  for( int i = 0 ; i < N2 ; i++ )
    if(p.f[i] != (i + 1) ) return false;
  return true;
}
string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u,v;
  s.path = "";
  Q.push(s);
  V[s] = true;

  while( !Q.empty() ){
    u = Q.front(); Q.pop();
    if( isTarget(u) ) return u.path;
    int sx = u.space / N;
    int sy = u.space % N;
    for( int r = 0;r < 4;r++){
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if( tx < 0 || ty < 0 ||tx>=N ||ty>=N ) continue;
      v=u;
      swap(v.f[u.space], v.f[tx * N + ty]);
      v.space = tx * N + ty;
      if( !V[v] ){
        V[v] = true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }

  return "unsolvable";
}
int main(){
  Puzzle in;

  for( int i =0 ; i < N2 ; i++ ){
    cin >> in.f[i];
    if( in.f[i] == 0 ){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}



Measured memory_bytes: 30604
h,w = map(int, input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]
d = [[0 for j in range(w)] for i in range(h)]
for i in range(h):
    for j in range(w):
        d[i][j] = abs(a[i][j]-b[i][j])

dp = [[0 for _ in range(6400)] for _ in range(h*w)]
dp[0][d[0][0]]=1

for i in range(h*w):
    nowh,noww = divmod(i,w)
    for k in range(6400):
        if not dp[nowh*w + noww][k]==1:
            continue
        nxth,nxtw=nowh+1, noww+1
        if nxtw<w:
            if k+d[nowh][nxtw] < 6400:
                dp[nowh*w + nxtw][k+d[nowh][nxtw]] = 1
            dp[nowh*w + nxtw][abs(k-d[nowh][nxtw])] = 1
        if nxth<h:
            if k+ d[nxth][noww]< 6400:
                dp[nxth*w + noww][k+d[nxth][noww]] = 1
            dp[nxth*w + noww][abs(k-d[nxth][noww])] = 1


for k in range(6400):
    if dp[-1][k]==1:
        print(k)
        exit()

Measured memory_bytes: 379452
#include <stdio.h>
#include <math.h>

int main(){
	int q;
	double x;
	while(1){
		scanf("%d",&q);
		if(q==-1)	break;
		x = q/2.0;
		while(fabs(x*x*x-q)>=0.00001*q){
			x = x - (x*x*x-q)/(3*x*x);
		}
		printf("%f\n",x);
	}
	
	return 0;
}

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

int main() {
    int n, k, sum = 0;
    std::cin >> n >> k;
    std::vector<int> p;
    for (int i = 0; i < n; i++) {
        int temp;
        std::cin >> temp;
        p.push_back(temp);
    }
    std::sort(p.begin(), p.end());

    for (int i = 0; i < k; i++) {
        sum += p.at(i);
    }
    std::cout << sum << std::endl;
    return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	long long n, k;
	cin >> n >> k;
	long long a = 2*n*k + (2*n) * (2 * n - 1) / 2;
	long long b = n * (k + 2*n) + (n) * (n - 1) / 2;
	
	if(a > b){
		cout << -1;
		return 0;
	}
	
	long long h = (n / 2);
	long long c = 0;
	typedef pair<long long, long long> ii;
	ii arr[n];
	for(int i = 0;i < n;i++){
		long long x = k + i;
		long long y = k + n + ((i + h) % n);
		arr[i] = ii(x+y,x);
	}
	
	sort(arr,arr+n);
	for(int i = 0;i < n;i++){
		cout << arr[i].second << " " << arr[i].first  - arr[i].second << " " << k + 2*n + i << "\n";
	}
	
}


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

int main(void){
    char buf[100001];
    int exist[26] = {0};
    
    scanf("%s", buf);
    int len = strlen(buf);
    
    for (int i = 0; i < len; ++i)
    {
        exist[buf[i] - 'a'] = 1;
    }
    
    for (int i = 0; i < 26; ++i)
    {
        if (exist[i] == 0)
        {
            printf("%c", i + 'a');
            return 0;
        }
    }
    
    printf ("None");
    return 0;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 1005;
int H[N], W[N];
int sol[N][N];

int main(){
  fastIO;
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for(int i = 0 ; i < h; i ++ ){
    for(int j = 0 ; j < w ; j ++ ){
      sol[i][j] = ((i%2)==(j%2));
    }
  }
  for(int i = 0 ; i < w/2-a; i ++ ){
    for(int j = 0 ; j < h; j ++ ){
      sol[j][2 * i + w%2] = 1 - sol[j][2 * i + w%2];
    }
  }
  for(int i = 0 ; i < h/2-b; i ++ ){
    for(int j = 0 ; j < w; j ++ ){
      sol[2 * i + h%2][j] = 1 - sol[2 * i + h%2][j];
    }
  }
  for(int i = 0 ; i < h; i ++ ){
    for(int j = 0 ; j < w; j ++ ){
      H[i] += sol[i][j];
      W[j] += sol[i][j];
    }
  }
  for(int i = 0 ; i < h; i ++ ){
    if(H[i] != a && w - H[i] != a){
      cout << -1;
      return 0;
    }
  }
  for(int i = 0 ; i < w; i ++ ){
    if(W[i] != b && h - W[i] != b){
      cout << -1;
      return 0;
    }
  }
  for(int i = 0 ; i < h; i ++ ){
    for(int j = 0 ;j < w; j ++ ){
      cout << sol[i][j];
    }
    cout << "\n";
  }
  return 0;
}

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

using namespace std;

const int roll[10][10] = {
		{3, 2, 6, 1, 5, 4}, //W
		{4, 2, 1, 6, 5, 3}, //E
		{2, 6, 3, 4, 1, 5}, //N
		{5, 1, 3, 4, 6, 2}  //S
};
int main()
{
	int dice[10], NewDice[10], key[200];
	string cmd;
	key['W'] = 0, key['E'] = 1, key['N'] = 2, key['S'] = 3;
	
	for(int i = 0; i < 6; i++)
	{
		cin >> dice[i];
	}
	cin >> cmd;
	
	for(int i = 0; i < cmd.size(); i++)
	{
		for(int j = 0; j < 6; j++)
		{
			NewDice[j] = dice[roll[key[cmd[i]]][j] - 1];
		}
		for(int j = 0; j < 6; j++)
		{
			dice[j] = NewDice[j];
		}
	}
	cout << dice[0] << endl;
	return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include <map>
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0; i<n; ++i)
cin>>arr[i];
int s[n];
for(int i=0; i<n; ++i)
s[i]=i+1;
int k(0);
for(int i=0; i<n; ++i)
{
if(arr[i]==s[k])
++k;
}
cout<<(n-k==n?-1:n-k);
}


Measured memory_bytes: 4656
N = int(input())
x = 100000
for i in range(N):
    if x % 20 == 0:
        x = x + (x // 20)
        if x % 1000 > 0:
            x = x - (x  % 1000) + 1000
    else:
        x = 1.05 * x
        x = int(x) + 1
        if x % 1000 > 0:
            x = x - (x % 1000) + 1000

print(x)




Measured memory_bytes: 5596
from functools import reduce
from collections import namedtuple
Node = namedtuple('Node', ['parent', 'children'])
 
class my_binary_tree:
    def __init__(self, N=[]):
        self.T = {}
        for ni in N: self.addNode(ni)
 
    def addNode(self, n):
        p = self.T.get(n[0],Node(-1,[-1,-1])).parent
        self.T[n[0]] = Node(p,n[1:])
        for c in n[1:]:
            if c > -1:  
                cc = self.T.get(c,Node(-1,[-1,-1])).children
                self.T[c] = Node(n[0],cc)
 
    def getParent(self, i): return self.T[i].parent
 
    def getChildren(self, i): return self.T[i].children
 
    def getDepth(self, i):
        if self.T[i].parent == -1: return 0
        return self.getDepth(self.T[i].parent) + 1
 
    def getHeight(self, i):
        c0 = self.T[i].children[0]
        c1 = self.T[i].children[1]
        if c0 + c1 == -2: return 0
        return max( ( 0 if c0 == -1 else self.getHeight(c0) ), \
                    ( 0 if c1 == -1 else self.getHeight(c1) ) )\
               + 1
 
    def getDegree(self, i):
        return int(self.T[i].children[0] != -1) + \
               int(self.T[i].children[1] != -1)
 
    def getNodeType(self, i):
        if self.T[i].parent == -1        : return 'root'
        if sum(self.T[i].children) == -2 : return 'leaf'
        return 'internal node'
 
    def getSibling(self, i):
        p = self.T[i].parent
        if p == -1: return -1
        return sum(self.T[p].children) - i
 
    def getIdList(self): return sorted(self.T.keys())
 
  
if __name__=='__main__':
    n = int(input())
    N = [None]*n
    for i in range(n): N[i] = list(map(int,input().split()))
    tree = my_binary_tree(N)
      
    for i in tree.getIdList():        
        print("node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}".format(\
                i, tree.getParent(i), tree.getSibling(i), tree.getDegree(i), tree.getDepth(i), tree.getHeight(i), tree.getNodeType(i)))

Measured memory_bytes: 8324
N=int(input())
lst=[]
for i in range(N):
  lst.append([int(s) for s in input().split()])
lst=sorted(lst, key=lambda x: x[1])
time=0
flag=0
for i in range(N):
  time=time+lst[i][0]
  if time>lst[i][1]:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")  
  
  

Measured memory_bytes: 42832
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

vector<P> g[2][123456];
priority_queue< P, vector<P>, greater<P> > pq;
ll dist[2][123456];

int main(void){
	int n,m,s[2],u,v,k,i,dummy;
	ll a,b,x,d,c;
	P tmp;
	fill(dist[0],dist[2],INFLL);
	x = (ll)(1e15);
	cin >> n >> m >> s[0] >> s[1]; --s[0]; --s[1];
	for(i=0; i<m; ++i){
		cin >> u >> v >> a >> b; --u; --v;
		g[0][u].push_back(P(a,v));
		g[0][v].push_back(P(a,u));
		g[1][u].push_back(P(b,v));
		g[1][v].push_back(P(b,u));
	}
	for(k=0; k<2; ++k){
		dist[k][s[k]] = 0ll;
		pq.push(P(dist[k][s[k]],s[k]));
		while(!pq.empty()){
			tmp = pq.top();
			pq.pop();
			d = tmp.first;
			u = tmp.second;
			for(i=(g[k][u].l_ength()-1); i>=0; --i){
				v = g[k][u][i].second;
				c = g[k][u][i].first;
				if(d + c < dist[k][v]){
					dist[k][v] = d + c;
					pq.push(P(dist[k][v],v));
				}
			}
		}
	}
	for(i=0; i<n; ++i){
		pq.push(P(dist[0][i]+dist[1][i],i));
	}
	for(i=0; i<n; ++i){
		tmp = pq.top();
		while(tmp.second < i){
			pq.pop();
			tmp = pq.top();
		}
		cout << (x-tmp.first) << endl;
	}
	return 0;
}


Measured memory_bytes: 21364
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt(), k = sc.nextInt();
        long count = 0L;
        if (k == 0) {
            System.out.println(((long) n * n));
            return;
        }
        for (int b = 1; b <= n; b++) {
            int rep = n / b;
            int repK = rep * Math.max(b - k, 0);
            int mod = n % b;
            int modK = Math.max(mod - k + 1, 0);
            count += ((long) repK + modK);
        }
        System.out.println(count);
    }
}

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

int main(){
    int n,m,l;
    long int matrixA[100][100]={};
    long int matrixB[100][100]={};
    long int matrixC[100][100]={};
    cin>>n>>m>>l;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>matrixA[i][j];
        }
    }
    for(int k=0;k<m;k++){
        for(int s=0;s<l;s++){
            cin>>matrixB[k][s];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                matrixC[i][j]+=matrixA[i][k]*matrixB[k][j];    
            }
            if(j!=l-1){
                cout<<matrixC[i][j]<<" ";
            }else{
                cout<<matrixC[i][j]<<endl;
            }
                
        }
    }
}


Measured memory_bytes: 3356
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
counter = Counter(A)
total = 0
for k,v in counter.items():
  total += k*v
Q = int(input())

for _ in range(Q):
  b,c = map(int,input().split())
  if b in counter:
    total -= b*counter[b]
    item = counter[b]
    del counter[b]
    if c in counter:
      counter[c] += item
      total += c*item
    else:
      counter[c] = item
      total += c*counter[c]
  
  print(total)


Measured memory_bytes: 87124
#include <iostream>

using namespace std;

int main(){
    string S;
    cin >> S;
    int c0 = 0, c1 = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == '0') c0++;
        else c1++;
    }
    cout << min(c0, c1)*2 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main(){
    cin>>s;
    int c=s.length();
    for(int i=0;i<c;i++){
        if((i%2)==0){
            if((s[i]!='R')&&(s[i]!='U')&&(s[i]!='D'))n++;
        }
        else if((i%2)==1){
            if((s[i]!='L')&&(s[i]!='U')&&(s[i]!='D'))n++;
        }
        if(n!=0)break;
    }
    if(n==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    unsigned long long int a[n],b[n];
    int loop1;
    for(loop1=0;loop1<n;loop1++){
        scanf("%lld %lld",&a[loop1],&b[loop1]);
    }
    unsigned long long int ans=0;
    for(loop1=n-1;loop1>=0;loop1--){
        if((a[loop1]+ans)%b[loop1]!=0)
        ans+=b[loop1]-((a[loop1]+ans)%b[loop1]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	static public void main(String args[]) {
		
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		long[] array = new long[n];
		
		for(int i=0; i<n; i++) {
			array[i] = scan.nextLong();
		}
		
		long m = scan.nextLong();
		
		for(int i=0; i<m; i++) {
		
			int reaction = Arrays.binarySearch(array, scan.nextInt());
			System.out.println(reaction < 0 ? "0" : "1");
		}
	}
}


Measured memory_bytes: 112900
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;

using namespace std;

const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	int n;
	vector<int> h;

	int temp;
	int count = 0;
	int res = 0;
	cin >> n;
	fi(n) {
		cin >> temp;
		h.push_back(temp);
	}

	fi(n-1) {
		if (h[i] - h[i + 1] >= 0) {
			count++;
		}
		else {
			count = 0;
		}

		if (count > res) {
			res = count;
		}
	}

	ce(res);

}

int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 892
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        long result = 0;
        var a = long.Parse(input[0]);
        var b = long.Parse(input[1]);
        var c = long.Parse(input[2]);
        var k = long.Parse(input[3]);
        if (k <= a)
        {
            result = k;
        }
        else if (k <= a + b)
        {
            result = a;
        }
        else
        {
            result = a - (k - a - b);
        }
        Console.WriteLine(result);
    }
}

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

/*

dp[i][j] consider to i-th block there are j pairs of same color

dp[i][j] = dp[i-1][j-1] + dp[i-1][j]*(m-1)

*/

const int M=2e5+5;
const int MO=998244353;

inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}
inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}
inline void subv(int &x,int y)
{
	x-=y;
	if(x<0) x+=MO;
}
inline void mulv(int &x,int y)
{
	x=1LL*x*y%MO;
}
 
int inv[M],fa[M],ifa[M];
void init()
{
	fa[0]=ifa[0]=1;
	inv[1]=fa[1]=ifa[1]=1;
    for(int i=2;i<M;i++)
    {
    	fa[i]=mul(fa[i-1],i);
    	inv[i]=mul(MO-MO/i,inv[MO%i]);
    	ifa[i]=mul(inv[i],ifa[i-1]);
    }
}
 
int C(int n,int m)
{
	if(n<m) return 0;
	return mul(mul(fa[n],ifa[m]),ifa[n-m]);
}
int qp(int x,int n)
{
	int ans=1;
	while(n)
	{
		if(n&1) ans=mul(ans,x);
		x=mul(x,x);
		n>>=1;
	}
	return ans;
}
int solve(int n,int m)
{
	return mul(m,qp(m-1,n-1));
}

int main()
{
	init();
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	if(n==1)
	{
		printf("%d\n",m);
		return 0;
	}
	int ans=0;
	for(int i=0;i<=k;i++)
		addv(ans,mul(solve(n-i,m),C(n-1,i)));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6188
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

  vector<vector<ll>> s_char_loc(26);
  rep(i, s.size()) {
    char ch = s[i];
    s_char_loc[ch - 'a'].pb(i);
  }

  if (s_char_loc[t[0] - 'a'].size() == 0) {
    cout << -1 << endl;
    return 0;
  }

  ll round = 0;
  ll now_ind = -1;
  rep(i, t.size()) {
    char next = t[i];
    if (s_char_loc[next - 'a'].size() == 0) {
      cout << -1 << endl;
      return 0;
    }

    auto itr = upper_bound(all(s_char_loc[next - 'a']), now_ind);
    if (itr != s_char_loc[next - 'a'].end()) {
      now_ind = *itr;
    } else {
      round++;
      now_ind = s_char_loc[next - 'a'][0];
    }
  }

  ll ans = round * s.size() + now_ind + 1;
  cout << ans << endl;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> ii;
const int maxn = 4e3 + 5;
const int mod = 998244353;
const int logn = log2(maxn) + 1;
 
int cnt[maxn];
int fac[maxn];
int r[maxn] , rfac[maxn] , p[maxn];
int n , k;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(taskname".inp", "r")) {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    r[1] = 1;
    for(int i = 2 ; i < maxn ; ++i){
        r[i] = (mod - (ll)(mod / i) * r[mod % i] % mod);
    }
    fac[0] = rfac[0] = p[0] = 1;
    for(int i = 1 ; i < maxn ; ++i){
        fac[i] = (ll)fac[i - 1] * i % mod;
        rfac[i] = (ll)rfac[i - 1] * r[i] % mod;
        p[i] = p[i - 1] * 2 % mod;
    }
    cin >> k >> n;
    for(int i = 1 ; i <= k ; ++i){
        for(int j = i ; j <= k ; ++j){
            cnt[i + j]++;
        }
    }
    auto C = [&](int k , int n){
        if(k > n || n < 0)return 0ll;
        return 1ll * fac[n] * rfac[k] % mod * rfac[n - k] % mod;
    };
    for(int i = 2 ; i <= 2 * k ; ++i){
        int res = 0;
        for(int j = 0 ; j <= cnt[i] ; ++j){
            res += (ll)C(j + k - 2 * cnt[i] - 1 , n + k - 2 * cnt[i] - 1) * C(j,cnt[i]) % mod * p[j] % mod;
            if(res >= mod)res -= mod;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = acos(-1); // cos(pi) = -1 <=> pi = arccos(-1)

/* global variables */

/* function */

/* main */
int main() {

    int n;
    cin >> n;

    vector<double> x(n, 0);
    double max_abs = 0;
    vector<double> D(4, 0);
    for (int i = 0; i < n; i++)
        cin >> x[i];
    for (int i = 0; i < n; i++) {
        double y; cin >> y;
        x[i] -= y;
        x[i] = abs(x[i]);
        max_abs = max(max_abs, x[i]);
        for (int j = 1; j <= 3; j++) {
            D[j] += pow(x[i], (double)j);
        }
    }
    for (int j = 1; j <= 3; j++) {
            D[j]  = pow(D[j], 1.0/(double)j);
    }
    for (int j = 1; j <= 3; j++) {
            cout << fixed << setprecision(6) << D[j] << '\n';
    }

    cout << fixed << setprecision(6) << max_abs << '\n';




 }



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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  string S;cin>>S;
  vs ss={"dream","dreamer","erase","eraser"};
  rep(i,4){
    reverse(all(ss[i]));
  }
  reverse(all(S));
   bool ok =true;
  rep(i,S.size()){
    
    if(S[i]=='m'){
      if(i+4>S.size() ){
        ok=false;break;
      }
      for(int j=i; j<i+5;j++){
        
        if(S[j]!=ss[0][j-i]){
          ok=false;
        }
      }
      i +=4;
    }
    else if(S[i]=='e'){
      if(i+4>S.size() ){
        ok=false;break;
      }
      for(int j=i; j<i+5;j++){
        
        if(S[j]!=ss[2][j-i]){
          ok=false;
        }
      }
      i +=4;
    }
    else if(S[i]=='r'){
      
      if(i+2>S.size() ){
        ok=false;break;
      }
      if(S[i+2]=='m'){
        if(i+6>S.size() ){
          ok=false;break;
        }
        for(int j=i; j<i+7;j++){
        
          if(S[j]!=ss[1][j-i]){
            ok=false;
          }
        }
         i +=6;
      }
      else if(S[i+2]=='s'){
        if(i+5>S.size() ){
          ok=false;break;
        }
        
        for(int j=i; j<i+6;j++){
        
          if(S[j]!=ss[3][j-i]){
            ok=false;
          }
        }
         i +=5;
      }
    }  
  }
  if(ok)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,c;
	int n,q,f,sf=0;
	cin>>s>>n;
	for(int i=0;i<n;i++){
		cin>>q;
		if(q==1){
			sf++;
		}else{
			cin>>f>>c;
			if(f==1){
				if(sf%2==0){
					s.insert(0,c);
				}else{
					s.insert(s.length(),c);
				}
			}else{
				if(sf%2==0){
					s.insert(s.length(),c);
				}else{
					s.insert(0,c);
				}
			}
		}
	}
	if(sf%2!=0){
		reverse(s.begin(),s.end());
	}
	cout<<s<<endl;
}


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

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

int map[2][100];
int main(){
int N;
cin >> N;
rep(i,2) rep(j,N){
        cin >> map[i][j];
}

int max =0;
rep(i,N){
        int point = 0;
        rep(x,i+1) point += map[0][x];
        REP(x,i,N) point += map[1][x];
        if(max < point) max = point;
}

cout << max <<endl;

return 0;
}

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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define deb 0

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

	int x, y;
	cin >> x; cin >> y; x = x * 10 + y;
	cin >> y; x = x * 10 + y;
	if (x%4) cout << "NO" << endl;
	else cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
import sys


class SegmentTree():
    """
    update, get を提供するSegmentTree

    Attributes
    ----------
    __n : int
        葉の数。2 ^ i - 1
    __dot :
        Segment function
    __e: int
        単位元
    __node: list
        Segment Tree
    """
    def __init__(self, A, dot, e):
        """
        Parameters
        ----------
        A : list
            対象の配列
        dot :
            Segment function
        e : int
            単位元
        """
        n = 2 ** (len(A) - 1).bit_length()
        self.__n = n
        self.__dot = dot
        self.__e = e
        self.__node = [e] * (2 * n)
        for i in range(len(A)):
            self.__node[i + n] = A[i]
        for i in range(n - 1, 0, -1):
            self.__node[i] = self.__dot(self.__node[2 * i], self.__node[2 * i + 1])
    
    def update(self, i, c):
        i += self.__n
        node = self.__node
        node[i] = self.__dot(node[i], c)
        while i > 1:
            i //= 2
            node[i] = self.__dot(node[2 * i], node[2 * i + 1])

    def get(self, l, r):
        vl, vr = self.__e, self.__e
        l += self.__n
        r += self.__n
        while (l < r):
            if l & 1:
                vl = self.__dot(vl, self.__node[l])
                l += 1
            l //= 2
            if r & 1:
                r -= 1
                vr = self.__dot(vr, self.__node[r])
            r //= 2
        return self.__dot(vl, vr)


N, Q = map(int, input().split())
query = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]

flagH = [N - 1] * N
flagW = [N - 1] * N

stH = SegmentTree([N - 1] * N, min, N - 1)
stW = SegmentTree([N - 1] * N, min, N - 1)

cnt = 0
for t, x in query:
    if t == 1:
        flagX, flagY = flagW, flagH
        stX, stY = stW, stH
    else:
        flagX, flagY = flagH, flagW
        stX, stY = stH, stW

    cnt += max(0, min(stX.get(x - 1, N), flagX[x - 1]) - 1)
    # flagX[x - 1] = 0
    stY.update(stX.get(x - 1, N), x - 1)

print(pow(N - 2, 2) - cnt)


Measured memory_bytes: 119448
n = int(input())
if n == 1:
    print(1)
    exit()
if n == 2:
    print(3)
    exit()
n *= 2
ans = n*2

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        return float("INF")
    else:
        return x % m
def calc(b1,m1,b2,m2):
    p = modinv(m1,m2)
    if p == float("INF"):
        return float("INF")
    d = 1
    if (b2-b1)%d:
        return float("INF")
    tmp = (b2-b1)*p%m2
    m = m1*m2//d
    tmp = (b2-b1)//d*p%(m2//d)
    r = (b1+m1*tmp)%m
    return r

for i in range(1,int(n**0.5)+1):
    if n%i == 0:
        ans = min(ans,calc(0,i,n//i-1,n//i))
        if i != 1:
            ans = min(ans,calc(0,n//i,i-1,i))
print(ans)

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

double dis[8][8];

// n!*(n-1)/nC2

double don(double n) {
    if (n == 1) return 1;
    return n*don(n-1); 
}

int main() {
    double n;
    cin >> n;
    vector<double> x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];
    auto calcdis = [&] (int i, int j) {
        return double(pow(pow(x[i]-x[j],2)+pow(y[i]-y[j],2),0.5));
    };
    double ans = 0;
    double cnt = don(n-1) * 2.0;
    rep(i,n-1) {
        for (int j = i+1; j < n; ++j) {
            ans += calcdis(i,j) * cnt;
        } 
    }
    ans /= don(n);
    printf("%.7lf", ans);
    return 0;
}

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

void BSort(int a[],int n);

int main () {

	int a[10];
	for(int i=0;i<10;i++){
		cin>>a[i];
	}
	
	BSort(a,10);
	cout << a[9]<<endl;
	cout << a[8]<<endl;
	cout << a[7]<<endl;
	
    return 0;
}

void BSort(int a[],int n){
	int temp;
	for(int i=0;i<n-1;i++){
		for(int j=n-1;j>i;j--){
			if(a[j-1]>a[j]){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;
			}
		}
	}
}

Measured memory_bytes: 0
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, M;
int L[100010], R[100010];
int S[100010];
int ans;

int main()
{
  scanf( "%d%d", &N, &M );
  rep( i, M )
  {
    scanf( "%d%d", L+i, R+i );
    S[L[i]] += 1;
    S[R[i]+1] -= 1;
  }

  rep( i, N+1 )
    S[i+1] += S[i];

  rep( i, N ) if( S[i+1] == M )
    ++ans;

  printf( "%d\n", ans );

  return 0;
}

Measured memory_bytes: 1280