akhauriyash/Code-Regression huggingface dataset:
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val k = readInt()
    val s = readString()
    print(
        if (s.length <= k) {
            s
        } else {
            s.substring(0 until k) + "..."
        }
    )
}

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

using namespace std;

void Main() {
    int N;
    cin >> N;
    int x = N * 800;
    int y = (N / 15) * 200;
    cout << (x - y) << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3564
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int> > a(H, vector<int>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> a[i][j];
		}
	}
	vector<pair<int,int> > p1, p2;

	bool f = true;
	for (int i = 0; i < H; i++) {
		if (f) {
			for (int j = 0; j < W; j++) {
				if (j == W - 1) {
					if(i==H-1) break;
					if (a[i][j] % 2 == 1) {
						a[i][j]--; a[i+1][j]++;
						p1.push_back(make_pair(i,j));
						p2.push_back(make_pair(i+1,j));
					}
				}
				else {
					if (a[i][j] % 2 == 1) {
						a[i][j]--; a[i][j+1]++;
						p1.push_back(make_pair(i, j));
						p2.push_back(make_pair(i, j+1));
					}
				}
			}
			f=false;
		}
		else {
			for (int j = W - 1; j >= 0; j--) {
				if (j == 0) {
					if (i == H - 1) break;
					if (a[i][j] % 2 == 1) {
						a[i][j]--; a[i + 1][j]++;
						p1.push_back(make_pair(i, j));
						p2.push_back(make_pair(i + 1, j));
					}
				}
				else {
					if (a[i][j] % 2 == 1) {
						a[i][j]--; a[i][j - 1]++;
						p1.push_back(make_pair(i, j));
						p2.push_back(make_pair(i, j - 1));
					}
				}
			}
			f=true;
		}
	}

	/*cout << endl;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << a[i][j] <<" ";
		}
		cout << endl;
	}*/

	cout << p1.size() << endl;
	for (int i = 0; i < p1.size(); i++) {
		cout << p1[i].first+1 <<" "<< p1[i].second+1 <<" "<< p2[i].first+1 <<" "<< p2[i].second+1 << endl;
	}

}

Measured memory_bytes: 5228
//#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    #define mp make_pair
    #define pb push_back
    #define M_PI           3.14159265358979323846  /* pi */
    typedef long double ld;
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef vector<ll> vi;
    const int maxN = 70224;

    void solve(){
      ll a,b,c;
      cin>>a>>b>>c;
      ll ans = min(b/a, c);
      cout<<ans<<endl;
    }
    
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      solve();
      return 0;
    }   

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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;


main(){
	string s;
	string t="CODEFESTIVAL2016";
	cin >> s;

	int ans=0;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i]) ans++;
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    if (N % 2 == 0){
        cout << (N * (N - 2) / 2) << endl;
        FOR(a, 1, N + 1){
            FOR(b, a + 1, N + 1){
                if (b != N - a + 1){
                    cout << a << " " << b << endl;
                }
            }
        }
    }else{ // N % 2 == 1
        cout << ((N - 1) * (N - 1) / 2) << endl;
        FOR(a, 1, N + 1){
            FOR(b, a + 1, N + 1){
                if (b != N - a){
                    cout << a << " " << b << endl;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define ll  long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<int,int>
using namespace std;

#define maxn 10000005
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll powmod(ll a,ll b){
    ll ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans%mod;
}
map<int,int> mp;
main(){
	ll a,b,c;
	cin>>a>>b>>c;
	ll minn=min(c,b-1);
	cout<<a*minn/b<<endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define N 1000123
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define pb emplace_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007LL
#define M 10000123
 
using namespace std;

int n, m;
ll t, va[N], ab[N], x, curr_sum;

ll bb(ll x){
    int lo = 1, hi = m, mid, r = 1;
    while(lo <= hi){
        mid = lo + (hi - lo) / 2;
        if(x + ab[mid] > t) hi = mid - 1;
        else {
            r = mid;
            lo = mid + 1;
        }
    }
    return r;
}
 
int main(){
    ios_base::sync_with_stdio(0);
    cin >> n >> m >> t;
    ll ans = 0, suma = 0;
    int bol = 1;
    for(int i = 1; i <= n; ++i){
        cin >> va[i];
        if(suma + va[i] <= t && bol) suma += va[i], ans = i;
        else bol = 0;
    }

    for(int i = 1; i <= m; ++i){
        cin >> x;
        ab[i] = x + ab[i-1];
        //cout << ab[i] << ' ';
    }
    //cout << '\n';

    for(int i = 0; i <= n; ++i){
        curr_sum += va[i];
        if(curr_sum > t) break;
        ll cb = bb(curr_sum);
        if(curr_sum + ab[cb] > t) break;
        //cout << i << ' ' << curr_sum << ' ' << cb << '\n';
        ans = max(ans, i + cb);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6792
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

long long int gcd(long long int n,long long int m){
    long long int temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;

}

int main(void){
 long long int N,M,tmp,k,l,m;
 long long int g,j;
 long long int lcm=0;
 long long int ok=1;
 char s[100050];
 char t[100050];
 j=0;
 
 cin>>N>>M;
 cin>>s>>t;

 if(N>M){
   tmp=N;
   N=M;
   M=tmp;
 }
 
 lcm=N*M/gcd(N,M);

 for(int i=0; i<strlen(s); i++){
  l=1+(i*lcm/strlen(s));
  for(; j<strlen(t);){
    m=1+(j*lcm/strlen(t));
	if(l<m){
		break;
	}
	if(l==m){
		if(s[i]==t[j]){
			 j++;
			 break;
		}
		else{
			std::cout<<"-1"<<std::endl;
			return 0;
		}
    }
	j++;
  }
 }


 std::cout<<lcm<<std::endl;
 return 0;
}

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

int main()
{
	string S,T;
	cin>>S>>T;
	long long cnt=0;
	int ln = S.size();
	for(int i=0;i<ln;i++){
		if(S[i]!=T[i]) cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j;
long double dp[3001][3001],f[3001],pas;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(b=1; b<=a; b++){
		cin>>f[b];
	}
  dp[1][0]=(1.0-f[1]);
  dp[1][1]=f[1];
	for(i=2; i<=a; i++){
		//dp[i][j] frst i f[b]ze j;
		dp[i][0]=1.0;
		for(b=1; b<=i; b++){
			dp[i][0]*=(1.0-f[b]);
		}
		for(j=1; j<=i; j++){
			dp[i][j]=dp[i-1][j]*(1.0-f[i])+dp[i-1][j-1]*f[i];
		}
	}
	for(j=a/2+a%2; j<=a; j++){
		pas+=dp[a][j];
	}
	cout<<setprecision(11)<<pas;
	return 0;
}

Measured memory_bytes: 139136
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<climits>
#include<queue>
#include<set>
#include<cmath>
#include<map>
#include<bitset>
#include<fstream>
#include<tr1/unordered_map>

typedef long long LL;
using namespace std;
#define pb push_back
#define x first
#define y second

void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

int read()
{
	int x = 0, f = 1; int c = getchar();
	while(!isdigit(c)) { if(c == '-') f = 0; c = getchar(); }
	while(isdigit(c)) { x = (x * 10) + (c ^ 48); c = getchar(); }
	return f ? x : -x;
}

const int maxn = 2010, maxm = maxn << 1;
int to[maxm], nxt[maxm], head[maxn], e, sz[maxn], dep[maxn], a[maxn];
char s[maxn];

void add(int x, int y)
{
	to[++e] = y; nxt[e] = head[x]; head[x] = e;
	to[++e] = x; nxt[e] = head[y]; head[y] = e;
}

void dfs(int u, int fa)
{
	sz[u] = a[u]; dep[u] = 0;
	for(int i = head[u]; i; i = nxt[i])
	{
		int v = to[i]; if(v == fa) continue;
		dfs(v, u);
		sz[u] += sz[v];
		dep[u] += sz[v] + dep[v];
	}
}

int gao(int u, int fa)
{
	int mx = 0;
	for(int i = head[u]; i; i = nxt[i])
	{
		int v = to[i]; if(v == fa) continue;
		if(!mx || dep[mx] < dep[v]) mx = v;
	}
	if(!mx) return 0;
	int tmp = gao(mx, u) + sz[mx];
	if(dep[u] - dep[mx] - sz[mx] >= tmp) return dep[u] & 1;
	else return tmp - (dep[u] - dep[mx] - sz[mx]);
}

int main()
{

	int n = read();
	scanf("%s", s + 1);
	for(int i = 1; i <= n; ++i) a[i] = s[i] - '0';
	for(int i = 1; i < n; ++i)
	{
		int u = read(), v = read();
		add(u, v);
	}

	int ans = 0x3f3f3f3f;
	for(int i = 1; i <= n; ++i)
	{
		dfs(i, 0);
		if(gao(i, 0) == 0) ans = min(ans, dep[i] >> 1);
	}
	if(ans == 0x3f3f3f3f) cout << "-1" << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll n,l;cin>>n>>l;
	vll v;
	ll ans=0;
	rep(i,1,n+1)v.pb(l+i-1),ans+=(l+i-1);
	ll val=inf;
	rep(i,0,sz(v)){
		val=min(val,abs(v[i]));
	}
	ll k;
	rep(i,0,sz(v)){
		if(abs(v[i])==val)k=v[i];
	}
	cout<<ans-k;
	
	
	
	return 0;
}



Measured memory_bytes: 256
fun binarySearch(array: LongArray, target: Long): Boolean {
    var left = 0
    var right = array.size
    while(left < right){
        val mid = (left + right) / 2
        if (array[mid] == target) return true
        if (array[mid] < target) {
            left = mid + 1
        }else {
            right = mid
        }
    }
    return false
}
fun main(args: Array<String>?): Unit {
    val s = readLine()!!.trim().toInt()
    val sum = LongArray(s + 1){it * (it + 1L) / 2}
    val divisors = (2 .. s).filter{s % it == 0}
    val count = IntArray(s + 1){0}.also{it[1] = 1}
    for (n in sum) {
        for (d in divisors) {
            if (n >= d && binarySearch(sum, n - d)) {
                count[d]++
            }
        }
    }
    println(
            (divisors + 1).map{d -> count[d].toLong() * count[s / d]}.sum()
    )
}


Measured memory_bytes: 36692
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(){
	int n, t, e, x;
	scanf("%d%d%d", &n, &t, &e);

	for(int i = 1; i <= n; ++i){
		scanf("%d", &x);

		for(int s = 0; s <= t + e; s += x){
			if(abs(t - s) <= e){
				printf("%d\n", i);
				return 0;
			}
		}
	}

	puts("-1");
}

Measured memory_bytes: 1024
#include <cstdio>

int main(void){
    int i,j,k,n,m,a,ans;
    int hoge[30];
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++)hoge[i]=0;
    for(i=0;i<n;i++){
        scanf("%d",&k);
        for(j=0;j<k;j++){
            scanf("%d",&a);
            hoge[a-1]++;
        }
    }
    ans = 0;
    for(i=0;i<m;i++){
        if(hoge[i]==n)ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#define MOD 1000000007
using namespace std;

long mod_inv(long n) {
    long ans = 1;
    long mod = MOD - 2;
    for (; mod > 0; mod >>= 1) {
        if (mod & 1) {
            ans *= n;
            ans %= MOD;
        }
        n *= n;
        n %= MOD;
    }
    return ans;
}


long comb(int n, int k) {
    long nl = (long) n;
    nl++;
    long ans = 1;
    k = min(n - k, k);
    for (long i = 1; i <= k; i++) {
        ans *= nl - i;
        ans %= MOD;
        ans *= mod_inv(i);
        ans %= MOD;
    }
    return ans;
}

vector<long> factorize(int m) {
    vector<long> res;
    long a = 0;
    while (m % 2 == 0) {
        a++;
        m /= 2;
    }
    res.push_back(a);
    for (int i = 3; i <= m; i += 2) {
        long a = 0;
        for (; m % i == 0; m /= i) {
            a++;
        }
        res.push_back(a);
    }
    return res;
}


int main() {
    int n, m;
    cin >> n >> m;
    vector<long> v = factorize(m);
    transform(v.begin(), v.end(), v.begin(), [n](int k) {
            return comb(k + n - 1, k);
            });
    long ans = 1;
    for (long x: v) {
        ans *= x;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 264280
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


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


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

	VI v{1,4,8,9,16,25,27,32,36,49,64,64,81,100,121,125,128,144,169,196,216,225,243,256,256,289,324,343,361,400,441,484,512,529,576,625,676,729,729,784,841,900,961,1000 };

	int max;
	REP(i, v.size()) {
		
		if (v[i] > x) {
			cout << v[i - 1]<<endl;
			return 0;
		}
	}
	cout << 1000 << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> a_plus, a_minus;
    rep(i,n) {
        cin >> a[i];
        if(a[i] > 0) a_plus.push_back(a[i]);
        if(a[i] <= 0) a_minus.push_back(-a[i]);
    }
    sort(a_plus.begin(), a_plus.end());
    sort(a_minus.begin(), a_minus.end());
    mint ans=1;
    if(n==k) {
        rep(i,n) ans*= a[i];
        cout << ans << endl;
        return 0;
    } else if(a_plus.size() == 0 && k%2 == 1) {
        rep(i,k) ans*=-a_minus[i];
    } else {
        int rem = k;
        if(k%2==1) {
            rem--;
            ans*=a_plus.back();a_plus.pop_back();
        }
        while(rem>0) {
            if(a_plus.size() < 2) {
                ans*=a_minus.back(); a_minus.pop_back();
                ans*=a_minus.back(); a_minus.pop_back();
            } else if(a_minus.size() < 2) {
                ans*=a_plus.back();a_plus.pop_back();
                ans*=a_plus.back();a_plus.pop_back();
            } else {
                ll p1 = a_plus.back()*a_plus[a_plus.size()-2];
                ll p2 = a_minus.back()*a_minus[a_minus.size()-2];
                if(p1 > p2) {
                    ans*=p1;
                    a_plus.pop_back();a_plus.pop_back();
                } else {
                    ans*=p2;
                    a_minus.pop_back();a_minus.pop_back();
                }
            }
            rem-=2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7028
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>

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

using namespace std;

vector<string> split(string &str,char delim)
{
	vector<string> res;
	size_t current = 0,found;
	while((found = str.find_first_of(delim,current)) != string::npos)
	{
		res.push_back(string(str,current,found  - current));
		current = found + 1;
	}
	res.push_back(string(str,current,str.size() - current));
	return res;
}

int main()
{
	string s;
	int ans;
	bool flag;
	while(true)
	{
		ans = 0;
		flag = false;
		getline(cin,s);
		vector<string> temp = split(s,' ');
		if(atoi(temp[0].c_str()) == 0) break;

		vector<int> res;
		rep(i,temp.size())
		{
			res.push_back(atoi(temp[i].c_str()));
		}

		sort(res.begin(),res.end(),greater<int>());

		rep(i,res.size())
		{
			if(res[i] == 1)
			{
				if(i == res.size()-1)
				{
					if(ans + 11 > 21) ans += 1;
					else ans += 11;
				}
				else ans += 1;
			}
			else if(res[i] >= 10)
			{
				ans += 10;
			}
			else ans += res[i];

			if(ans > 21)
			{
				flag = true;
			}
		}

		if(flag)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << ans << endl;
		}


	}
	return 0;
}

Measured memory_bytes: 1224
(defun n-char (n c)
  (code-char 
    (+ (mod (+ n (- (char-code c)
                    (char-code #\A))) 
            26) 
       (char-code #\A))))

(let ((n (read))
      (str (read-line)))
  (princ (coerce (loop :as c
                       :across str
                       :collect (n-char n c)) 'string)))

Measured memory_bytes: 9572
N = int(input())
A = [int(x) for x in input().split()]

ans_flag = False
B =[0]*N
B[N//2:] = A[N//2:]
for idx in list(reversed(range(N//2))):
  sum_bai = sum(B[idx::idx+1]) % 2
  
  if A[idx] == 0:
    if sum_bai == 0:
      B[idx] = 0
    else:
      B[idx] = 1
  else:
    if sum_bai == 0:
      B[idx] = 1
    else:
      B[idx] = 0
      
M = sum(B)
B_ans = [idx+1 for idx in range(N) if B[idx] == 1]
print(M)
print(' '.join(list(map(str, B_ans))))
    



Measured memory_bytes: 20676
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

inline int calc(ll x) {
  int res = 0;
  while(x > 0) {
    x /= 10;
    ++res;
  }
  return res;
}

int main(void) {
  ll n;
  scanf("%lld", &n);
  int mini = 1000000000;
  for(ll a = 1; a <= n/a; ++a) {
    if(n/a * a == n) {
      int v = max(calc(n/a), calc(a));
      mini = min(mini, v);
    }
  }
  printf("%d\n", mini);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main()
{
	int H, W;
	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;
		int i, j;
		for (i = 1; i <= H; i++)
		{
			if (i % 2 == 1)
			{
				for (j = 1; j <= W - 1; j++)
				{
					if (j % 2 == 1)printf("#");
					if (j % 2 == 0)printf(".");
				}
				if (j % 2 == 1)printf("#\n");
				if (j % 2 == 0)printf(".\n");
			}
			else
			{
				for (j = 1; j <= W - 1; j++)
				{
					if (j % 2 == 0)printf("#");
					if (j % 2 == 1)printf(".");
				}
				if (j % 2 == 0)printf("#\n");
				if (j % 2 == 1)printf(".\n");
			}

		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 1016
#include <stdio.h>
#include <math.h>
#define SQ(a) ((a) * (a))
#define EPS 1e-2
typedef struct {
	double x;
	double y;
} POINT;

double area(double a, double b, double c)
{
	double s;
	s = (a + b + c) / 2;
	return(sqrt(s * (s - a) * (s - b) * (s - c)));
}

int main(void)
{
	POINT a, b, c, p;
	double ab, bc, ca, ap, bp, cp;
	while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y, &p.x, &p.y) != EOF){
		ab = sqrt(SQ(a.x - b.x) + SQ(a.y - b.y));
		bc = sqrt(SQ(b.x - c.x) + SQ(b.y - c.y));
		ca = sqrt(SQ(c.x - a.x) + SQ(c.y - a.y));
		ap = sqrt(SQ(a.x - p.x) + SQ(a.y - p.y));
		bp = sqrt(SQ(b.x - p.x) + SQ(b.y - p.y));
		cp = sqrt(SQ(c.x - p.x) + SQ(c.y - p.y));
		
		if (fabs(area(ab ,bc ,ca) - area(ap, bp, ab) - area(ap, cp, ca) - area(bp, cp, bc)) < EPS){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int LLu;

using namespace std;

const int N =  300000+5;
const int MOD = 998244353;
const int INF = 1e9+7;

inline int read() {
    int x = 0,f=1;char ch = getchar();
    for(; ch<'0'||'9'<ch; ch=getchar()) if(ch == '-') f=-1;
    for(; '0'<=ch&&ch<='9'; ch=getchar()) x=(x<<3)+(x<<1)+ch-'0';
    return x*f;
}

#define lal puts("****");
#define pb push_back
#define mp make_pair

/********************************************************/
int h,w,n;
int a[1000000];
int b[111][111];
int main(){
    scanf("%d%d",&h,&w);
    scanf("%d",&n);
    int l = 0;
    for(int i=1,x;i<=n;i++){
        scanf("%d",&x);
        for(int j=1;j<=x;j++)
            a[++l]=i;
    }

    l=0;
    for(int i=1;i<=h;i++){
        if(i&1){
            for(int j=1;j<=w;j++)
                b[i][j]=a[++l];
        }
        else {
            for(int j=w;j;j--)
                b[i][j]=a[++l];
        }
    }

    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            printf("%d%c",b[i][j],(j==w)?'\n':' ');


    return 0;
}


Measured memory_bytes: 384
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  str s; ll k; cin >> s >> k;
  map <str, ll> flag;
  vs ans;
  for(ll i = 0;i < s.size();i++)
  {
    for(ll j = 1;i + j <= s.size();j++)
    {
      if(j - 1 == k) break;
      str d = s.substr(i, j);
      if(flag.count(d)) continue;
      else { ans.pb(d); flag[d];}
    }
  }
  sort(all(ans));
  //rep(i, ans.size()) cout << ans[i] << endl;
  fin(ans[k - 1]);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define mp std::make_pair
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;
int main()
{
    stat();
    unordered_map<string, int> map;

    int n;
    cin >> n;
    unordered_map<string, int> m;
    string s;
    ull ans=0;
    rep(i, n)
    {
        cin >> s;
        sort(all(s));
	if (m.count(s) != 0) {ans+=m.at(s);++m.at(s); }else{
m.insert(mp(s,1));
	}
    }
    cout<<ans<<endl;
    return 0;

}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}


Measured memory_bytes: 10248
program main
  implicit none
  integer(8) i, ans, frag, r, N
  integer(8),allocatable :: A(:)
  
  read(*, *) N
  allocate(A(N))
  read(*, *) (A(i), i = 1,N)
  call qsort(A)
  ans = 0
  r = N
  frag = 1
  do i = 1,N-1
    ans = ans + A(r)
    if (frag == 1) then
      frag = 0
      r = r-1
    else
      frag = 1
    end if
  end do
 
  write(*, *) ans
  
contains
 
recursive subroutine qsort(a)
implicit none
!integer(8),intent(in) :: n
integer(8),intent(inout) :: a(:)
integer(8)::i,j,toobig,toosmall,pv,n
n = size(a)
i = 1
j = n
pv = a((i+j)/2)
do
   do
     if (a(i) < pv) then
       i = i+1
     else
       exit
     end if
   end do
   do
     if(a(j) > pv) then
       j = j-1
     else
       exit
     end if
   end do
   if (i>=j) then
     exit
   else
     toobig = a(j)
     toosmall = a(i)
     a(i) = toobig
     a(j) = toosmall
     i = i+1
     j = j-1
   end if
 end do
 if (i > 2) then
   call qsort(a(1:i-1))
 end if
 if (j < n-1) then
   call qsort(a(j+1:n))
 end if
end subroutine qsort
end program main

Measured memory_bytes: 4668
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
    const xs = input.split(' ').map(n => n - 0)
    for (let i = 0; i < xs.length; i++) {
        if (xs[i] === 0) {
            console.log(i + 1)
        }
    }
})(input)


Measured memory_bytes: 29416
n = gets.chomp.to_i
hash = {}
arr = Array.new(n)
n.times do |i|
	arr[i] = gets.chomp
end

hash[arr[0]] = true
prev = arr[0]
1.upto(n-1) do |i|
	hoge = arr[i]
	if hash.has_key?(hoge) || prev[-1] != hoge[0]
		puts "No"
		exit
	end
	prev = hoge
	hash[hoge] = true
end
puts "Yes"




Measured memory_bytes: 14244
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int K,A,B;
	cin>>K;
	cin>>A>>B;
	int flag=0;
	for(int i=A;i<=B;i++)
	{
		if(i%K==0)
		{
			flag=1;
			break;
		}
	}
	if(flag==1)
	{
		cout<<"OK";
	}
	else
	{
		cout<<"NG";
	}
	return 0;
}


Measured memory_bytes: 3588
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(K: int, S: int):
    count = 0
    for x in range(K+1):
        for y in range(K+1):
            if S-K <= x+y <= S:
                count += 1
    print(count)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
     
    using namespace std;
     
    #define all(a) a.begin(),a.end()
    #define F first
    #define S second
    #define pb push_back
    #define ll long long
    #define vi vector<int>
    #define pi pair<int,int>
    #define mp make_pair
     
    #ifdef LOCAL
    #include "debug.h"
    #else
    #define debug(...) 42
    #endif
     //~ #define int ll
    int mod=1e9+7;
     
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
    template<typename A> istream& operator>>(istream&,vector<A>&);
    void add(int&,int);
    int mul(int,int);
    int powz(int,int);
    int sub(int,int);
    template<typename A> ostream& operator<<(ostream&,vector<A>&);
     
    const int N=10001;
     
    void solve(){
    	int n;
    	cin>>n;
    	vi a(n+1);
    	cin>>a;
    	vi b(n);
    	cin>>b;
    	ll ans=0;
    	for(int i=0;i<n;i++){
    		if(a[i]<=b[i]){
    			ans+=a[i];
    			b[i]-=a[i];
    		}
    		else{
				ans+=b[i];
				b[i]=0;
			}
    		if(a[i+1]<=b[i]){
    			ans+=a[i+1];
    			a[i+1]=0;
    		}
    		else{
    			a[i+1]-=b[i];
    			ans+=b[i];
    		}
    	}
    	cout<<ans;
    	
    	
    	
    }
     
    signed main(){
    	ios_base::sync_with_stdio(false);
    	cin.tie(0);
    	int tc=1;
    	//~ cin>>tc;
    	for(int _=0;_<tc;_++){
    		//cout<<"Case #"<<_+1<<": ";
    		solve();
    		if(_!=tc-1)
    		cout<<"\n";
    	}
    }
     
    int mul(int a,int b)
    {
    	return ((a)*1ll*(b))%mod;
    }
     
    void add(int &a,int b)
    {
    	a+=b;
    	if(a>=mod)a-=mod;
    }
     
    int sub(int a,int b){
    	a-=b;
    	if(a<0){
    		a+=mod;
    	}
    	return a;
    }
     
    int powz(int a,int b)
    {
    	int res=1;
    	while(b)
    	{
    		if(b&1)res=mul(res,a);
    		b/=2;
    		a=mul(a,a);
    	}
    	return res;
    }
     
    template <typename A, typename B>
    istream& operator>>(istream& input,pair<A,B>& x) {
    	input>>x.F>>x.S;
    	return input;
    }
     
    template <typename A>
    istream& operator>>(istream& input,vector<A>& x) {
    	for(auto& i:x)
    		input>>i;
    	return input;
    }
     
    template<typename A>
    ostream& operator<<(ostream& output,vector<A>& x) {
    	for(auto& i:x)
    	    output<<i<<' ';
    	return output;
    }


Measured memory_bytes: 1024
//Pranet Verma
#include <bits/stdc++.h>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a > 0) {
        cout << "Positive";
    }
    else if (a <= 0 and 0 <= b) {
        cout << "Zero";
    }
    else {
        assert(a < 0 and b < 0);
        int negatives = b - a + 1;
        if (negatives & 1) {
            cout << "Negative";
        }
        else {
            cout << "Positive";
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

struct K {
  ll v;
  int n;
};
bool operator<(const K& k1, const K& k2) {
  return k1.v < k2.v;
}

int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  priority_queue<K> q;
  REP(i, n) {
    ll v;
    scanf("%lld", &v);
    q.push((K){v, 1});
  }
  REP(i, m) {
    int b;
    ll c;
    scanf("%d%lld", &b, &c);
    q.push((K){c, b});
  }
  int rest = n;
  ll res = 0;
  while(rest > 0) {
    K cur = q.top(); q.pop();
    while(rest > 0 && cur.n > 0) {
      res += cur.v;
      cur.n--;
      rest--;
    }
  }
  cout << res << endl;
    
  return 0;
}


Measured memory_bytes: 6512
#include <iostream>

using namespace std;

int main(void)
{
    int N, C[21], V[21], i, sum=0;

    cin >> N;

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

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

    for(i=1; i<=N; i++){
        if(V[i] > C[i]){
            sum += (V[i]-C[i]);
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_BIT_MAX		40										// 最大ビット数

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 桁数毎の個数 - 取得
int
fGetCnt(
	long long plVal				// <I> 値
	, long long *plpCnt			// <O> 個数
)
{
	int i;

	long long llVal = 1;
	long long llVal2 = 2;
	for (i = 0; i < D_BIT_MAX; i++) {

		// 商
		plpCnt[i] = plVal / llVal2 * llVal;

		// 剰余
		long long llMod = plVal % llVal2;
		if (llMod >= llVal) {
			plpCnt[i] += llMod - llVal + 1;
		}

		// 次の桁
		llVal = llVal2;
		llVal2 *= 2;
	}

	return 0;
}

// 実行メイン
long long
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 範囲 - 取得
	long long llValS, llValE;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%lld%lld", &llValS, &llValE);

	// 桁数毎の個数 - 取得
	long long ll1CntE[D_BIT_MAX];
	fGetCnt(llValE, ll1CntE);

	// 桁数毎の個数 - 減算
	if (llValS > 0) {
		long long ll1CntS[D_BIT_MAX];
		fGetCnt(llValS - 1, ll1CntS);

		for (i = 0; i < D_BIT_MAX; i++) {
			ll1CntE[i] -= ll1CntS[i];
		}
	}

	// 排他的論理和合計
	long long llSum = 0;
	long long llVal = 1;
	for (i = 0; i < D_BIT_MAX; i++) {
		if (ll1CntE[i] % 2 == 1) {
			llSum += llVal;
		}

		// 次の桁
		llVal *= 2;
	}

	return llSum;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// 結果 - セット
	sprintf(lc1Out, "%lld\n", llRet);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne(0);
#endif

	return 0;
}



Measured memory_bytes: 128
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)



        
def main(): #startline--------------------------------------------
    N,W = map(int,input().split())
    wv = [list(map(int,input().split())) for i in range(N)]
    w = [wv[i][0] for i in range(N)]
    v = [wv[i][1] for i in range(N)]
    MV = max(v)*N+1
    inf = float("inf")
    dp = [[inf]*MV for i in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(MV):
            if v[i] <= j:
                dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i])
            else:
                dp[i+1][j] = dp[i][j]

    dp = dp[N]
    for i in reversed(range(MV)):
        if dp[i] <= W:
            print(i)
            exit()
if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 300544
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>

using namespace std;

vector<long long int> getDivisor(long long int n){
    vector<long long int> v;
    for(long long int i=1;i*i<=n;i++){
        if(n % i == 0){
            v.push_back(i);
            if( i!= n / i){
                v.push_back(n/i);
            }
        }
    }
    return v;
}

int main(int argc, const char * argv[]) {
    long long int n;
    cin >> n;
    
    vector<long long int> v = getDivisor(n);
    string ans = to_string(v[v.size()-1]);
    cout << ans.length();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
char a[4];
int main()
{
	int i;
	scanf("%s",a);
	for(i=1;i<=3;i++)
		if(a[i]==a[i-1])
		{
			printf("Bad");
			return 0;;
		}
		
	printf("Good");
	return 0;
} 

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


fn main() {
    input!{a:i64,b:i64,c:i64};
    println!("{}", if a+b==c || b+c==a || a+c==b {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
//Beta tumse na ho payega
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
//#define ll long long int
#define ld long double
#define int long long
#define pb push_back 
#define mod 1000000007
#define mod2 998244353
#define Z(c) (int)(c).size()
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
//#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define clber cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);(i)++)
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define pi 3.1415926536
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define FO find_by_order
#define OK order_of_key
#define tr(it,ct) for(auto &(it) : (ct))
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    baap;
 
int power(int a,int n,int lelo)
{
        if(n==0)
                return 1;
        if(n==1)
                return a;
        if(n==2)
                return (a*a)%lelo;
        if(n%2)
                return (a*power(a,n-1,lelo))%lelo;
        else
                return power(power(a,n/2,lelo),2,lelo)%lelo;
}
ld dpower(ld a,int n)
{
        if(n==0)
                return 1;
        if(n==1)
                return a;
        if(n==2)
                return (a*a);
        if(n%2)
                return (a*dpower(a,n-1));
        else
                return dpower(dpower(a,n/2),2);
}
 
 
void swap(int &a,int &b)
{ auto tm=a; a=b; b=tm; }
 
 const int N=1e5+1;   //Take care of duplicates
 const int INF=1e16;
 
 void solve()
 { 
   ld x,y;
   cin>>x>>y;
  cout<<(int)(ceil((y-x)/(x-1))+1);
   } 
signed main()
{  
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
  

 
  int t=1;
   
 // cin>>t;
  rep(i,1,t+1)
  { // cout<<"Scenario #"<<i<<":\n";
   solve();
 
   if(i<t)
   cout<<nl;
  }
  
 return 0; 
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
    while(b!=0){
        a %= b;
        if(a==0) return b;
        b %= a;
    }
    return a;
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll e=c*d/gcd(c,d);
    ll divc,divd,dive;
    divc=(b/c)-((a-1)/c);
    divd=(b/d)-((a-1)/d);
    dive=(b/e)-((a-1)/e);
    ll ans=b-a+1-divc-divd+dive;
    cout << ans;
}

Measured memory_bytes: 256
io = STDIN
n=io.gets.to_i
ar=[[0,0,0]]
n.times do
  ar<<io.gets.split.map(&:to_i)
end
def check(ar)
  ar.each_cons(2) do |before,after|
    t0,x0,y0=before
    t1,x1,y1=after
    spath=(x0-x1).abs+(y0-y1).abs
    t=t1-t0
    next if  spath<=t && (t-spath).even?
    return false
  end
  return true
end
if check(ar)
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 9596
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

constexpr int N = 100100;

using namespace std;

bool less_second(array<int, 2> lhs, array<int, 2> rhs)
{
    return lhs[1] < rhs[1];
}

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

    int n, m;

    cin >> n >> m;
    vector<array<int, 2>> req(m);
    vector<int> bridge(n - 1);

    for (int i = 0; i < m; i++)
        cin >> req[i][0] >> req[i][1];

    sort(req.begin(), req.end(), less_second);

    for (int i = 0; i < m; i++)
    {
        bool can = true;
        for (int j = req[i][0]; j < req[i][1]; j++)
        {
            if (bridge[j - 1] == 1)
            {
                can = false;
                break;
            }
        }
        if (can)
            bridge[req[i][1] - 2] = 1;
    }

    int ans = 0;
    for (int i : bridge)
    {
        ans += i;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    while(true) {

        rep(i, n) {
            if(a[i] % 2 == 0)
                a[i] = a[i] / 2;
            else {
                cout << ans <<endl;
                return 0;
            }
        }
        ans++;
    }
}

Measured memory_bytes: 3640