akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
vector<ll> fac(1e6),inv(1e6),finv(1e6);
void initcom(){
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int compress(vector<int> &x,int w){
    vector<int> sx;
    for(int i=0;i<(int)x.size();++i){
        for(int d=-2;d<=2;++d){
            int t=x[i]+d;
            if(t>=0&&t<w) sx.push_back(t);
        }
    }
    sort(sx.begin(),sx.end());
    sx.erase(unique(sx.begin(),sx.end()),sx.end());
    for(int i=0;i<(int)x.size();++i){
        x[i]=lower_bound(x.begin(),x.end(),x[i])-x.begin();
    }
    return (int)sx.size();
}
ll n,k;
vector<ll> a,pls,mns;
bool C(ll x){
    ll cnt=0;
    for(int i=0;i<n;++i){
        if(a[i]==0){
            if(x>=0) cnt+=n-1;
        }else if(a[i]>0){
            ll y=x/a[i];
            cnt+=upper_bound(a.begin(),a.end(),y)-a.begin();
        }else{
            if(x>=0){
                cnt+=(int)pls.size();
                ll y=x/a[i];
                cnt+=mns.end()-lower_bound(mns.begin(),mns.end(),y);
            }else{

            }
        }

    }
}
int main(){
    string s;cin>>s;
    int n=(int)s.size();
    int ans=0;
    for(int i=0;i<n;++i) ans+=(int)(s[i]-'0');
    for(int i=0;i<n;++i){
        if(s[i]=='0') continue;
        int sum=0;
        for(int j=0;j<i;++j) sum+=(int)(s[j]-'0');
        sum+=(int)(s[i]-'0')-1;
        for(int j=i+1;j<n;++j) sum+=9;
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 26544
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
namespace fastio{
	char in[100000];
	int itr=0,llen=0;
	char get(){
		if(itr==llen)llen=fread(in,1,100000,stdin),itr=0;
		if(llen==0)return EOF;
		return in[itr++];
	}
	char out[100000];
	int itr2=0;
	void put(char c){
		out[itr2++]=c;
		if(itr2==100000){
			fwrite(out,1,100000,stdout);
			itr2=0;
		}
	}
	int clear(){
		fwrite(out,1,itr2,stdout);
		itr2=0;
		return 0;
	}
	int getint(){
    	int r=0; bool ng=0; char c; c=get();
    	while (c!='-'&&(c<'0'||c>'9')) c=get();
   		if (c=='-') ng=1, c=get();
    	while (c>='0'&&c<='9') r=r*10+c-'0', c=get();
    	return ng?-r:r;
	}
	string getstr(){
		string ret="";
		char ch=get();
		while(ch==' '||ch=='\n')ch=get();
		while(ch!=' '&&ch!='\n')ret.push_back(ch),ch=get();
		return ret;
	}
	void putstr(string s){
		for(int i=0;i<s.size();i++)put(s[i]);
	}
	void putint(int x){
		if(x<0){
			put('-');
			x=-x;
		}
		if(x==0){
			put('0');
			return;
		}
		char c[20];int pos=0;
		while(x){
			c[pos++]='0'+x%10;
			x/=10;
		}
		for(int i=pos-1;i>=0;i--)put(c[i]);
	}
	void getarr(int arrname[],int size){
		 for(int i=0;i<size;i++)arrname[i]=getint();
	}
}
using namespace fastio;
#define fastio
#define SZ 300005
int n,m;
vector<int>g[SZ],g2[SZ];
int deg[SZ];
int dist[SZ];
int par[SZ];
queue<int>q;
signed main(){
	n=getint();m=getint();
	for(int i=0;i<n-1+m;i++){
		int a=getint(),b=getint();
		g[a].push_back(b);
		deg[b]++;
	}
	for(int i=1;i<=n;i++)if(deg[i]==0)q.push(i);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(auto to:g[x]){
			deg[to]--;
			if(deg[to]==0)par[to]=x,q.push(to); 
		}
	}
	for(int i=1;i<=n;i++){
		cout<<par[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 21888
using System;

namespace ACpra5
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] input = Console.ReadLine().Split(' ');
            int K = int.Parse(input[0]);
            int X = int.Parse(input[1]);
            for(int i = X-K+1; i < X + K -1;i++)
            {
                Console.Write("{0} ",i);
            }
            Console.WriteLine(X + K - 1);
        }
    }
}



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

using namespace std;

void read(){
    freopen("in.txt", "r", stdin);
}
int main(){
    //read();
    int n, k; cin >> n >> k;
    vector<int> h(n);

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

    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for(int i = 2; i < n; i++){
      for(int j = i - 1, jump = 0; j  >= 0 && jump < k; j--, jump++){
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));

      }
    }

    cout << dp[n - 1];
    return 0;
}



Measured memory_bytes: 1024
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    for (int i = 0; i < h; ++i) {
        cin >> c[i];
    }

    int ans = 0;
    for (int i = 0; i < (1 << h); i++) {      // Hのパターン
        for (int j = 0; j < (1 << w); j++) {  // Wのパターン
            vector<string> cp = c;
            int cnt = 0;
            for (int ii = 0; ii < h; ++ii) {
                for (int jj = 0; jj < w; ++jj) {
                    if(i & (1 << ii) || (j & (1 << jj))) {
                        cp[ii][jj] = '?';
                    }
                    if(cp[ii][jj] == '#') {
                        cnt++;
                    }
                }
            }
            ans += (cnt == k);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
N = int(input())

num_list = list(map(int,input().split()))

swap_count = 0

for i in range(len(num_list)-1):
    for k in range(len(num_list)-1,i,-1):
        if num_list[k] < num_list[k-1]:
            num_list[k],num_list[k-1] = num_list[k-1],num_list[k]
            swap_count += 1

print(' '.join(map(str,num_list)))
print("%d"%(swap_count))


Measured memory_bytes: 5600
#include<iostream>
using namespace std;
int main(void)
{
    int N,K,P;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> K >> P;
        if (K % P) {
            cout << K % P << endl;
        }
        else {
            cout << P << endl;
        }
    }
}


Measured memory_bytes: 3104
import sys

def accept_input():
    S = input()
    T = input()
    return S,T

S,T = accept_input()
fromhere = -1
for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] == "?":
            continue
        elif S[i+j] == T[j]:
            continue
        elif S[i+j] != T[j]:
            break
    else:
        fromhere = i
if fromhere == -1:
    print("UNRESTORABLE")
    sys.exit()
sd = ""
for i in range(len(S)):
    if i < fromhere:
        if S[i] == "?":
            sd += "a"
        else:
            sd += S[i]
    elif i >= fromhere+len(T):
        if S[i] == "?":
            sd += "a"
        else:
            sd += S[i]
    else:
        sd += T[i-fromhere]
print(sd)


Measured memory_bytes: 9056
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N;
ll A[201010];
ll P, Q, R, S;
ll PQ, RS;
ll Qlb, Slb;

ll calc_abs() {
  ll ma = max(P, max(Q, max(R, S)));
  ll mi = min(P, min(Q, min(R, S)));
  return abs(ma - mi);
}

int main() {
  cin >> N;
  ll sum = 0;
  rep(i, 0, N) {
    cin >> A[i];
    sum += A[i];
  }
  P = A[0];
  Q = A[1];
  Qlb = 1;
  R = A[2];
  S = sum - A[0] - A[1] - A[2];
  Slb = 3;
  rep(i, Slb, N - 1) {
    ll rr = R + A[i];
    ll ss = S - A[i];
    if (abs(ss - rr) < abs(S - R)) {
      R += A[i];
      S -= A[i];
      Slb = i + 1;
    } else {
      break;
    }
  }

  ll ans = calc_abs();
  rep(i, 2, N - 2) {
    Q += A[i];
    R -= A[i];

    rep(j, Qlb, i) {
      ll pp = P + A[j];
      ll qq = Q - A[j];
      if (abs(pp - qq) < abs(P - Q)) {
        P += A[j];
        Q -= A[j];
        Qlb = j + 1;
      } else {
        break;
      }
    }

    rep(j, Slb, N - 1) {
      ll rr = R + A[j];
      ll ss = S - A[j];
      if (abs(ss - rr) < abs(S - R)) {
        R += A[j];
        S -= A[j];
        Slb = j + 1;
      } else {
        break;
      }
    }
    ans = min(ans, calc_abs());
  }

  cout << ans << endl;
}


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


#define INF 1000000000000


signed main()
 {
int a,b,n;
cin>>a>>b>>n;
if(n<=b-1){cout<<(a*n)/b-(n/b)*a;exit(0);};
int ans=0;
rep(i,n/b+1){
  if(b*(i+1)-1<=n)ans=max(ans,(a*(b*(i+1)-1))/b-((b*(i+1)-1)/b)*a);
  if(ans==b-1){break;}
}
cout<<ans;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(void){
    int a,b,c,i,j=1,apple;
    while(scanf("%d%d",&a,&b)!=EOF){
        c=a+b;
        for(i=0,j=1,apple=c;apple>=0;i++){
            j=10*j;
            apple=c-j;
        }
        printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto A=vecin(N);
	int Q=in();
	int sum=0;
	LOOP(Q){
		if(binary_search(ALL(A),in())) sum++;
	}
	
	out(sum);

	return 0;
}



Measured memory_bytes: 3460
// B - Multiplication 2
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int n; cin>>n;
	ll inf = 1e18;
	ll ans = 1;
	bool ng = false;
	while(n--){
		ll a; cin>>a;
		if(a == 0){ puts("0"); return 0; }
		if(ng || (inf+1)/ans < a || inf < ans*a) ng = true;
		else ans *= a;
	}
	if(ng) puts("-1");
	else cout<< ans <<endl;
}


Measured memory_bytes: 3644
use proconio::{fastout, input, marker::Chars};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        s: Chars
    }

    let mut res = if s[s.len() - 1] == 's' { "es" } else { "s" };
    let s: String = s.iter().collect();
    println!("{}{}", s, res);
}


Measured memory_bytes: 2156
//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fi first 
#define se second 
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end() 
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VC = vector <char>;
using VS = vector <string>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MSS = map<string, string>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long
void mcs(VI &series, int &max_sum){                    // maximum contigous sub sum(kadane)
    int s=0;
    for(auto x: series){
        s += x;
        max_sum = max(max_sum, s);
        if(s < 0)s = 0;
    }
}
template<typename T>
T MAX(T t){ return t;}
template <typename T, typename... Args>
T MAX(T t, Args... args){ return max(t, MAX(args...)); }
const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//
 
int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int x = READ_INT();
    for(int b = -150; b <= 150; ++b){
        for(int a = -150; a <= 150; ++a){
            if(pow(a, 5) - pow(b, 5) == x){
                cout << a << " " << b;
                return 0;
            }
        }
    }

    return 0;
}



/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/

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

using namespace std;

typedef long long int lli ;

lli i,j,k,l,m,n,t,a,b,c,d,x,y,sum=0,total=0;

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

    //freopen("Input.txt","r",stdin);

    cin>>a>>b>>c>>d;

    lli gcd=(c*d)/__gcd(c,d);

    lli A=((a-1)/c)+((a-1)/d)-((a-1)/gcd);

    lli B=(b/c)+(b/d)-(b/gcd);

    sum=(b-a+1)-(B-A);

    cout<<sum<<"\n";

}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#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;

#define int long long
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)  cerr << #x << " = " << (x) << endl;
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; }

int n, m;
vector<vector<int>> g;

vector<bool> used;

int cnt;

void dfs(int v) {
    ++ cnt;
    used[v] = 1;
    for(int nv: g[v]) {
        if(!used[nv]) dfs(nv);
    }
}

vector<int> col;
bool bi;

void dfs2(int v, int c) {
    col[v] = c;
    for(int nv: g[v]) {
        if(col[nv] == -1) dfs2(nv, 1 - c);
        else if(col[nv] == c) {
            bi = 0;
            return;
        }
    }
} 

void solve() {
	cin >> n >> m;
    g.assign(n, vector<int>());
    rep(i, m) {
        int u, v; cin >> u >> v;
        -- u, -- v;
        g[u].pb(v);
        g[v].pb(u);
    }
    used.assign(n, 0);
    col.assign(n, -1);
    int x = 0, y = 0, z = 0;
    rep(i, n) {
        if(!used[i]) {
            cnt = 0;
            dfs(i);
            if(cnt == 1) ++ x;
            else {
                bi = 1;
                dfs2(i, 0);
                if(bi) ++ y;
                else ++ z;
            }
        }
    }
    cout << 2 * n * x - x * x + (y + z) * (y + z) + y * y << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 14812
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}
 
int main() {
    int n,m;
    cin >> n >> m;
    int k;
    vector<vector<int>> A(n, vector<int>(m,0));
    rep(i,n) {
        cin >> k;
        rep(j,k) {
            cin >> A[i][j];
        }
    }
    vector<int> C(m+1,0);
    rep(i,n) {
        rep(j,A[i].size()) {
            for(int k=1; k<=m; ++k) {
            if (A[i][j] == k) {
                C[k]++;
            }
            }
        }
    }
    int cnt = 0;
    rep(i,C.size()) {
        if (C[i] == n) {
            cnt++;
        }
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#include <numeric>
#include <bitset>

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

using namespace std;

typedef long long ll;

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

  int n; cin >> n;

  map<ll, ll> mp;
  rep(i, n) {
    ll a; cin >> a;
    mp[a]++;
  }

  ll ans = 1, cnt = 0;
  for (auto it = mp.rbegin(); it != mp.rend(); it++) {
    ll f = it->first;
    ll s = it->second;
    if ( s > 3 && cnt == 0) {
      ans = f*f; cnt += 2;
      break;
    }
    if ( s > 1 ) {
      ans *= f;
      if (++cnt == 2) { break; }
    }
  }

  cout << (cnt == 2 ? ans: 0) << endl; 

  return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  char *str1,*str2,str[300];
  int i,n;
  
  fgets(str,sizeof(str),stdin);
  n=atoi(str);
  fgets(str,sizeof(str),stdin);
  str1=strtok(str," ");
  str2=strtok(NULL," ");
  
  for(i=0;i<n;i++){
    printf("%c%c",str1[i],str2[i]);
  }
  return 0;
}
  

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {

	int n, i, ii;

	scanf("%d", &n);

	for (i = 1; i <= n; i++) {
		ii = i;
		do {
			if ((30 < ii) && (ii < 40)) {
				printf(" %d", i);
				break;
			} else if (ii % 10 == 3) {
				printf(" %d", i);
				break;
			} else if (i % 3 == 0) {
				printf(" %d", i);
				break;
			}
			ii /= 10;
			} while (ii > 0);
		} 
	printf("\n");
	return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;

    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int X[22], Y[22], P[22];
signed main() {
    cin >> N;
    rep(i, N) { cin >> X[i] >> Y[i] >> P[i]; }
    vvint ho(bit(N), vint(N)), ve(bit(N), vint(N));
    rep(i, bit(N)) {
        rep(j, N) {
            ho[i][j] = abs(X[j]), ve[i][j] = abs(Y[j]);
            rep(k, N) {
                if (!(i & bit(k))) { continue; }
                chmin(ho[i][j], abs(X[j] - X[k])), chmin(ve[i][j], abs(Y[j] - Y[k]));
            }
        }
    }
    vint xc(bit(N)), yc(bit(N));
    rep(i, bit(N)) {
        set<int> xs, ys;
        rep(j, N) {
            if (!(i & bit(j))) { continue; }
            xs.insert(X[j]), ys.insert(Y[j]);
        }
        xc[i] = xs.size(), yc[i] = ys.size();
    }
    vint ans(N + 1, LLONG_MAX);
    int th = 1;
    rep(i, N) { th *= 3; }
    rep(i, th) {
        int c = i;
        int xmask = 0, ymask = 0;
        rep(j, N) {
            if (c % 3 == 0) { xmask |= bit(j); }
            if (c % 3 == 1) { ymask |= bit(j); }
            c /= 3;
        }
        int r = 0;
        rep(j, N) { r += min(ho[xmask][j], ve[ymask][j]) * P[j]; }
        chmin(ans[xc[xmask] + yc[ymask]], r);
    }
    reps(i, N) { chmin(ans[i], ans[i - 1]); }
    rep(i, N + 1) { cout << ans[i] << endl; }
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if(a>=10||b>=10){
    cout << "-1" << endl;
  }
  else{
    cout << a*b << endl;
  }

  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
    int n,a,sum1=0,min_sum=10000;
    scanf("%d",&n);
    for(a=1;a<=n-1;a++){
        sum1=0;
        int a_=a;
        int b_=n-a;
        do{
            sum1+=a_%10;
            a_=a_/10;
        }while(a_!=0);
        do{
            sum1+=b_%10;
            b_=b_/10;
        }while(b_!=0);
        if(sum1<=min_sum)
        min_sum=sum1;
    }
    printf("%d",min_sum);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
 
int main(void){
  int s[100];
  int N, M;
  scanf("%d %d", &N, &M);
  int i;
  int all = 0;
  for(i = 0; i < N; i++){
    scanf("%d", &s[i]);
    all += s[i];
  }
  int buf = 0;
  for(i = 0; i < N; i++){
    if(s[i] * 4 * M >= all) buf++;
  }
  if(buf >= M){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

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

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

  vector<pair<ll, ll>> tasks(n);
  ll a, b;
  for (ll i = 0; i < n; i++) {
    cin >> a >> b;
    tasks[i] = make_pair(b, a);
  }
  
  sort(tasks.begin(), tasks.end());

  ll total = 0;
  for (ll i = 0; i < n; i++) {
    total += tasks[i].second;
    if (tasks[i].first < total) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int count = 0;
  
  if(a <= 1 && b <= 1){
    cout <<count<<endl;
    return 0;
  }
  else{
    for(int i=a-1;i>=0;i--){
      count+= i;
    }
    cout << endl;
     for(int i=b-1;i>=0;i--){
      count+=i;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <cstdio>

typedef long long lint;

int main()
{
	int n, v, max = 0;
	scanf("%d", &n);

	int dp[200001]{};
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &v);
		dp[v] = dp[v - 1] + 1;

		if (max < dp[v]) max = dp[v];
	}

	printf("%d", n - max);

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
using namespace std;

int N, M;
int A[120];
long long int S, B[120], C[120], D[120];
int U[120], V[120];

vector<int>Adj[55];

long long int dis[55][2525];

long long int INF = 99999999999999999;

pair<long long int, pair<int, int>> P;
set < pair<long long int, pair<int, int>> > T;

priority_queue< pair<long long int, pair<int, int>> > PQ;

int COST[55][55];
long long int TIM[55][55];

int main(void) {

	cin >> N >> M >> S;

	for (int i = 1; i <= M; i++) {
		cin >> U[i] >> V[i] >> A[i] >> B[i];
		COST[U[i]][V[i]] = A[i];
		COST[V[i]][U[i]] = A[i];
		TIM[U[i]][V[i]] = B[i];
		TIM[V[i]][U[i]] = B[i];
	}

	for (int i = 1; i <= N; i++){
		cin >> C[i] >> D[i];
}

	for (int i = 1; i <= M; i++) {
		Adj[U[i]].push_back(V[i]);
		Adj[V[i]].push_back(U[i]);
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= 2500; j++) {
			dis[i][j] = INF;
		}
	}


	S = min(S, (long long int ) 2500);
	
	dis[1][S] = 0;
	P.first = 0;
	P.second.first = 1;
	P.second.second = (int) S;
	//T.insert(P);
	PQ.push(P);

	while (PQ.size() > 0) {
		//auto it = T.begin();
		//P = *it;  T.erase(it);
		P = PQ.top(); PQ.pop();
		long long int d =- P.first;
		int K = P.second.first;
		int s = P.second.second;

		//cout << "K= " << K << " s= " << s <<" dis= "<<d<<  endl;

		for (int j = 1; ; j++) {
			int s_num;
			if (C[K] * j+s >= 50*N) { s_num = 50*N; }
			else { s_num = (int) (s + C[K] * j); }
			if (dis[K][s_num] > dis[K][s] + D[K] * j) {
				dis[K][s_num] = dis[K][s] + D[K] * j;
				P.first = -dis[K][s_num];
				P.second.first = K;
				P.second.second = s_num;
				//T.insert(P);
				PQ.push(P);
			}
			
			if (s_num >= 50*N) { break; }
		}

		for (auto y : Adj[K]) {
			if (s >= COST[K][y]) {
				if (dis[y][s - COST[K][y]] > dis[K][s] + TIM[K][y]) {
					dis[y][s - COST[K][y]] = dis[K][s] + TIM[K][y];
					P.first = -(dis[K][s] + TIM[K][y]);
					P.second.first = y;
					P.second.second = s - COST[K][y];
					//T.insert(P);
					PQ.push(P);
				}
			}
		}
	}

		for(int i=2;i<=N;i++){
			long long int ans = INF;
			for (int j = 0; j <= 2500; j++) {
				ans = min(ans, dis[i][j]);
			}
			cout << ans << endl;
			}


	return 0;
}


Measured memory_bytes: 37184
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    sort(arr.begin(), arr.end());
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            auto it = lower_bound(arr.begin()+j+1, arr.end(), arr[i]+arr[j]);
            int idx = prev(it) - arr.begin();
            ans += max(idx-j, 0);
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#include <atcoder/all>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

using mint = modint998244353;
mint ten[200010];

struct S {
    mint a;
    int size;
};

S op(S l, S r) {
    return S{l.a * ten[r.size] + r.a, l.size + r.size};
}

S e() {
    return S{0, 0};
}

S mapping(mint l, S r) {
    if (l == (mint)0) {
        return r;
    } else {
        return S{(ten[r.size] - 1) / 9 * l, r.size};
    }
}

mint composition(mint l, mint r) {
    return (l != (mint)0) ? l : r;
}

mint id() {
    return (mint)0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ten[0] = 1;
    REP(i, 1, 200010) {
        ten[i] = ten[i - 1] * 10;
    }
    ll N, Q;
    cin >> N >> Q;
    V<S> vec(N);
    REP(i, 0, N) {
        vec[i] = S{1, 1};
    }
    lazy_segtree<S, op, e, mint, mapping, composition, id> seg(vec);
    REP(i, 0, Q) {
        ll l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;
        seg.apply(l, r + 1, (mint)d);
        cout << seg.all_prod().a.val() << endl;
    }
}


Measured memory_bytes: 10632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1000000007;
int main(){
  int N;
  string S;
  cin >> N >> S;
  set<int> left;
  rep(i, 2*N){
    if(i%2 == 1 && S.at(i) == 'B') left.insert(i+1);
    else if(i%2 == 0 && S.at(i) == 'W') left.insert(i+1);
  }
  if(left.size() != N || left.count(2*N) == false || left.count(1) == true ) cout << 0 << endl;
  else{
    int64_t mul = 0;
    int64_t ans = 1;
    for(int i = 2*N; i > 0; i--){
      if(left.count(i)) mul++;
      else{
        ans = ans * mul % INF;
        mul--;
      }
    }
    
    int64_t lar = 1;
    rep(i, N){
      lar = lar * (i + 1) % INF;
    }
    cout << ans * lar % INF  << endl;
  }
    
  
}

Measured memory_bytes: 9860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())

int main(){
    int ans(0),small_time(0),first(10);

    rep(i,5){
        int x;  cin >> x;
        string s = to_string(x);
        if(s[s.size()-1]-'0'!=0&&s[s.size()-1]-'0'<first){
            first = s[s.size()-1]-'0';
            small_time = x;
        }

        if(s[s.size()-1]-'0'==0){
            ans += x;
        }else{
            x /= 10;
            x++;
            x *= 10;
            ans += x;
        }
    }
    if(first!=10){
        int dummy_x = small_time;
        dummy_x /=10;
        dummy_x++;
        dummy_x *= 10;
        ans -=  abs(small_time-dummy_x);
    }

    cout << ans << endl;

    return 0;
}

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

#define ll long long

signed main()
{
  string s,t; cin >> s >> t;
  int cnt=0;
  for(int i = 0; i<s.length(); ++i)
  {
    if(s[i]!=t[i]) ++cnt;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3828
def main():
    X = int(input())
    S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

    return S[X - 1]


print(main())


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		String s = sc.next();
		String[] alpha = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
		String[] str = s.split("");

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < 26; j++) {
				if(str[i].equals(alpha[j])) {
					System.out.print(alpha[(j + n) % 26]);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 25168
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

ll len[200], cnt[200][26];
int sum0[26][100001], sum1[26][200001];

ll rec(int n, ll l, ll r, int c){
	if(l >= len[n] || r <= 0) return 0;
	if(l <= 0 && len[n] <= r) return cnt[n][c];
	
	l = max(l, 0ll); r = min(r, len[n]);
	
	if(n <= 1){
		if(n == 1) return sum1[c][r] - sum1[c][l];
		return sum0[c][r] - sum0[c][l];
	}
	return rec(n - 1, l, r, c) + rec(n - 2, l - len[n - 1], r - len[n - 1], c);
}

int* buildFail(const string &s){
	int n = s.size();
	int *p = new int[n];
	p[0] = 0;
	for (int i = 1; i < n; ++i){
		p[i] = p[i - 1];
		while (p[i] > 0 && s[p[i]] != s[i]) p[i] = p[p[i] - 1];
		if (s[p[i]] == s[i]) p[i]++;
	}
	return p;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string s;
	ll l, r; cin >> s >> l >> r; l--;
	int n = s.size() / 2;
	int *f = buildFail(s.substr(0, n));
	int p = n - f[n - 1];
	
	if(n % p == 0){
		rep(i, 26){
			rep(j, p) sum1[i][j + 1] = sum1[i][j] + (s[j] == 'a' + i);
			ll k = r / p, m = l / p, cnt = 0;
			cnt += sum1[i][p] * k + sum1[i][r % p];
			cnt -= sum1[i][p] * m + sum1[i][l % p];
			cout << cnt << (i == 25 ? "\n" : " ");
		}
	}
	else{
		string t = s.substr(0, n) + s.substr(0, p);
		len[0] = n;
		len[1] = t.size();
		rep(i, 26){
			rep(j, n)        sum0[i][j + 1] = sum0[i][j] + (s[j] == 'a' + i);
			rep(j, t.size()) sum1[i][j + 1] = sum1[i][j] + (t[j] == 'a' + i);
			cnt[0][i] = sum0[i][n];
			cnt[1][i] = sum1[i][t.size()];
		}
		int m = 1;
		for(; len[m] < r; m++){
			len[m + 1] = len[m] + len[m - 1];
			rep(i, 26) cnt[m + 1][i] = cnt[m][i] + cnt[m - 1][i];
		}
		rep(i, 26) cout << rec(m, l, r, i) << (i == 25 ? "\n": " ");
	}
	
	return 0;
}

Measured memory_bytes: 31764
#include <stdio.h>
#include <stdlib.h>

typedef struct weight_
{
    int Num;
    int Wei;
    double OneNum;
    int flg;
}wgt;


void disp(int n,wgt *X)
{
    int i;
    for(i=0;i<n;i++) 
    {
        if(i%n==0) printf("\n");
    }
    printf("\n");
}

void swap(wgt *X,wgt *Y)
{
    wgt wk; wk=*X; *X=*Y; *Y=wk;
}

void quicksort(int first,int last,wgt *X)
{
    int i,j;
    double pivot;
    if(first<last)
    {
        pivot=X[(first+last)/2].OneNum;
        i=first;
        j=last;
        while(i<=j){
            while(X[i].OneNum<pivot) i++;
            while(X[j].OneNum>pivot) j--;
            if(i<=j) swap(&X[i++],&X[j--]);
        }
        quicksort(first,j,X);
        quicksort(i,last,X);
    }
}

int main()
{
    int N,W,cnt;
    double d1,d2,tmp=0;
    scanf("%d %d",&N,&W);
    wgt box;
    wgt *X = malloc(sizeof(wgt)*N);
    for(int i=0;i<N;i++)
    {
        scanf("%lf%lf",&d1,&d2);
        X[i].Num = d1;
        X[i].Wei = d2;
        X[i].OneNum = d1/d2;
    }
    quicksort(0,N-1,X);
    for(int i=N-1;0<=i;i--)
    {
        //printf("i=%d Num=%d Weight=%d OneNum=%lf\n",i,X[i].Num,X[i].Wei,X[i].OneNum);
        if(X[i].Wei < W)
        {
            tmp = tmp + (X[i].Wei * X[i].OneNum);
            W = W - X[i].Wei;
        }
        else
        {
            tmp = tmp + (X[i].OneNum * W);
            break;
        }
    }
    /*for(int i=0;i<N;i++)
    {
        cnt = i;
        for(int l=i;l<N;l++)
        {
            if(X[cnt].OneNum<X[l].OneNum)
            {
                cnt = l;
            }
        }
        box = X[i];
        X[i] = X[cnt];
        X[cnt] = box;
        if(X[i].Wei < W)
        {
            tmp =  tmp + (X[i].Wei * X[i].OneNum);
            W = W - X[i].Wei;
        }
        else
        {
            tmp += X[i].OneNum * W;
            break;
        }
    }
    /*for(int i=0;i<N;i++)
    {
        if(X[i].Wei < W)
        {
            tmp =  tmp + (X[i].Wei * X[i].OneNum);
            W = W - X[i].Wei;
        }
        else
        {
            tmp += X[i].OneNum * W;
            break;
        }
    }*/
    printf("%lf\n",tmp);
}


Measured memory_bytes: 4048
def solve():
    N = int(input())
    ans = ['a']
    for i in range(N - 1):
        newest_ans = []
        for a in ans:
            A = [ord(b) for b in a]
            for t in range(min(A), max(A) + 2):
                newest_ans.append(a + chr(t))
        ans = newest_ans
    for a in sorted(ans):
        print(a)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 83692
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
int main(){
  int n,q,m,data;
  map<int,int> mep;
  while(cin >> n >> q && n && q){
    mep.clear();
    for(int i=0;i<n;i++){
      cin >> m;
      for(int j=0;j<m;j++){
	cin >> data;
	mep[data]++;
      }
    }
    int ans = 10000;
    int howMany=-1;
    map<int,int>::iterator it = mep.begin();
    while(it != mep.end()){
      if((*it).second > howMany){
	howMany = (*it).second;       
	ans = (*it).first;
      }
      it++;
    }
    howMany<q?cout << "0" << endl:cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    vector<pair<int, int>> v;
    REP(i, N) { cin >> a[i]; }
    SORT(a);
    REP(i, M) {
        int b, c;
        cin >> b >> c;
        v.push_back(make_pair(c, b));
    }
    sort(v.rbegin(), v.rend());

    LLI sum = 0;
    int idx = 0;
    REP(i, M) {
        REP(j, v[i].second) {
            if(N <= idx) {
                i = M;
                break;
            }
            if(a[idx] < v[i].first) {
                a[idx] = v[i].first;
            }
            idx++;
        }
    }
    REP(i, a.size()) { sum += a[i]; }
    cout << sum;
    return 0;
}

Measured memory_bytes: 1784
program a
	character(len=3) :: day
    read '(a)', day
    
    if (day == 'MON') then
    	print '(i0)', 6
    else if (day == 'TUE') then
    	print '(i0)', 5
    else if (day == 'WED') then
    	print '(i0)', 4
    else if (day == 'THU') then
    	print '(i0)', 3
    else if (day == 'FRI') then
    	print '(i0)', 2
    else if (day == 'SAT') then
    	print '(i0)', 1
    else if (day == 'SUN') then
    	print '(i0)', 7
    end if

end program a

Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int s[100];
bool dp[101][100001];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> s[i];
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 100 * i; j++) {
			if (!dp[i][j]) continue;
			dp[i + 1][j] |= dp[i][j];
			dp[i + 1][j + s[i]] |= dp[i + 1][j];
		}
	}
	for (int i = 100 * N; i >= 0; i--) {
		if (dp[N][i] && i % 10 != 0) {
			cout << i << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

Measured memory_bytes: 6656
#include <iostream>


int n, c; int d[30][39]; int t[3][30];
int main() {
	std::cin >> n >> c;
	for (int i = 0; i < c; ++i)for (int j = 0; j < c; ++j)
		std::cin >> d[i][j];
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) {
			int x;
			std::cin >> x;
			++t[(i + j) % 3][x - 1];
		}
	int res = 1 << 30;
	for (int i = 0; i < c; ++i)for (int j = 0; j < c; ++j)
		if (i != j)
			for (int k = 0; k < c; ++k)
				if (i != k && j != k) {
					int tt = 0;
					for (int l = 0; l < c; ++l)tt += d[l][i] * t[0][l];
					for (int l = 0; l < c; ++l)tt += d[l][j] * t[1][l];
					for (int l = 0; l < c; ++l)tt += d[l][k] * t[2][l];
					if (tt < res)
						res = tt;
				}
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long n, a, sum;
int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a;
		sum += a;
	}
	if(sum % 2 > 0){
		cout << "NO";
	}else{
		cout << "YES";
	}
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    vector<char> S(2);
    rep(i, 3) cin >> S[i];

   if( S[0] != S[1] )
   {
       cout << "Yes" << endl;
   }
   else if ( S[1] != S[2] )
   {
       cout << "Yes" << endl;
   }
   else if ( S[0] != S[2] )
   {
       cout << "Yes" << endl;
   }
   else
   {
       cout << "No" << endl;
   }
   
        
    
}



Measured memory_bytes: 256
package main

import "fmt"

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

func main() {
	var n int
	fmt.Scan(&n)
	t := make([]int, n)
	for i := range t {
		fmt.Scan(&t[i])
	}
	ans := t[0]
	for i := 1; i < len(t); i++ {
		ans = lcm(ans, t[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

s=input()

key = "keyence"

for i in range(len(s)):
    j = i + len(s) -7
    if s[:i] + s[j:] == key:
        print("YES")
        exit()
print("NO")

Measured memory_bytes: 3064
s = list(input())

op_cnt = len(s)-1
sum = 0
for i in range(2**op_cnt):
    op = ['']*op_cnt
    for j in range(op_cnt):
        if (i>>j) & 1:
            op[j] = '+'

    fomula = s[0]
    for j in range(op_cnt):
        fomula += op[j]
        fomula += s[j+1]
    
    sum += eval(fomula)

print(sum)

Measured memory_bytes: 3064
def ncr(n, r, p): 
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p 
        den = (den * (i + 1)) % p 
    return (num * pow(den, p - 2, p)) % p
  
p = 10**9+7
n,a,b = map(int,(input().split()))

bb = ncr(n,a,p)+ncr(n,b,p)+1
print((pow(2,n,p)-(bb%p))%p)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 100001;
string s,w;
int main(){
    cin>>s>>w;
    int c=0;
    for(int i=0;i<s.size();i++)
        if(s[i]!=w[i])
            c++;
    cout<<c;
}



Measured memory_bytes: 3472
#include<stdio.h>
int main(void)
{
	int n,i;
	int a,b,c;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf(" %d %d %d",&a,&b,&c);
		if(c*c==a*a+b*b)
		{
			printf("YES\n");
		}
		else if(a*a==c*c+b*b)
		{
			printf("YES\n");
		}
		else if(b*b==a*a+c*c)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
int n,m;
std::map<std::string,int>cnt;
std::string s;
int main(){
    std::cin >> n;
    std::cin >> s;
    std::map<int,int>max_pos;
    std::map<int,int>min_pos;
    for(int i = 0; i <= 9; ++i) min_pos[i] = n + 1,max_pos[i] = -1;
    std::vector<std::vector<bool>>valid(n,std::vector<bool>(10,false));
    for(int i = 0; i < n; ++i){
        int m = s[i] - '0';
        max_pos[m] = i;
        min_pos[m] = std::min(min_pos[m],i);
    }
    std::map<std::string,int>memo;
    for(int i = 0; i < n; ++i){
        int key = s[i] - '0';
        for(int l = 0; l <= 9; ++l){
            for(int r = 0; r <= 9; ++r){
                if(max_pos[r] == -1 or min_pos[l] == n + 1)
                    continue;
                if(min_pos[l] < i && i < max_pos[r])
                    memo[std::to_string(l) + std::to_string(key) + std::to_string(r)] += 1;
            }
        }
    }
    std::cout << memo.size() << '\n';
}




Measured memory_bytes: 2432