akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#define ls(x) x << 1
#define rs(x) x << 1 | 1
#define ll long long
#define rep(i, a, b) for (int i = a; i <= (int)b; i ++)
#define per(i, a, b) for (int i = (int)a; i >= b; i --)
template < typename T > void read(T & x) {
    x = 0; int flag = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100010;
int n, m;
ll ans[maxn << 2], tag[maxn << 2];
struct event {
    int l, r, c;
    bool operator < (const event & a) const { return l < a.l; }
} a[maxn];
void push_up(int p) { ans[p] = min(ans[ls(p)], ans[rs(p)]); }
void build(int p, int l, int r) {
    tag[p] = -1;
    if(l == r) {
        ans[p] = inf;
        return;
    }
    int mid = (l + r) >> 1;
    build(ls(p), l, mid), build(rs(p), mid + 1, r);
    push_up(p);
}
void push_down(int p) {
    ans[ls(p)] = min(ans[ls(p)], tag[p]);
    ans[rs(p)] = min(ans[rs(p)], tag[p]);
    if(~tag[ls(p)]) tag[ls(p)] = min(tag[ls(p)], tag[p]);
    else tag[ls(p)] = tag[p];
    if(~tag[rs(p)]) tag[rs(p)] = min(tag[rs(p)], tag[p]);
    else tag[rs(p)] = tag[p];
    tag[p] = -1;
}
ll query(int p, int l, int r, int x) {
    if(l == r) return ans[p];
    if(~tag[p]) push_down(p);
    int mid = (l + r) >> 1;
    if(x <= mid) return query(ls(p), l, mid, x);
    else return query(rs(p), mid + 1, r, x);
}
void update(int p, int l, int r, int ql, int qr, ll x) {
    if(ql <= l && r <= qr) {
        ans[p] = min(ans[p], x);
        if(~tag[p]) tag[p] = min(tag[p], x);
        else tag[p] = x;
        return;
    }
    if(~tag[p]) push_down(p);
    int mid = (l + r) >> 1;
    if(ql <= mid) update(ls(p), l, mid, ql, qr, x);
    if(qr > mid) update(rs(p), mid + 1, r, ql, qr, x);
    push_up(p);
}
int main()
{
    read(n), read(m);
    build(1, 1, n);
    rep(i, 1, m)
        read(a[i].l), read(a[i].r), read(a[i].c);
    sort(a + 1, a + 1 + m);
    update(1, 1, n, 1, 1, 0);
    rep(i, 1, m) {
        ll tmp = query(1, 1, n, a[i].l);
        update(1, 1, n, a[i].l + 1, a[i].r, tmp + a[i].c);
    }
    ll res = query(1, 1, n, n);
    printf("%lld\n", res == inf ? -1 : res);
    return 0;
}

Measured memory_bytes: 6528
N, X, Y = map(int, input().split())
ans = [0 for _ in range(N)]

for i in range(N-1):
    for j in range(i+1, N):
        if i <= X-1 and Y-1 <= j:
            ans[j-i-(Y-X)+1] += 1
        elif X-1 <= i and j <= Y-1:
            ans[min(j-i, (Y-1)-j+i-(X-1)+1)] += 1
        elif i <= X-1 and j <= Y-1:
            ans[min(j-i, (Y-1)-j+(X-1)-i+1)] += 1
        elif X-1 <= i and Y-1 <= j:
            ans[min(j-i, j-(Y-1)+i-(X-1)+1)] += 1
        else:
            ans[j-i] += 1

for k in range(1, len(ans)):
    print(ans[k])


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

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << (ll)lcm(a,b) << endl;
  return 0;
}

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

typedef pair<int, int> pii;

int K;

priority_queue<pii> pq;
vector<int> dist;

int main() {
    cin >> K;

    dist = vector<int>(K, 1e9);
    for(int i = 1; i < min(K, 10); i++) {
        dist[i] = i;
        pq.push(pii(-dist[i], i));
    }
    while(!pq.empty()) {
        int u = pq.top().second;
        int ud = -pq.top().first;
        pq.pop();

        for(int i = 0; i <= 9; i++) {
            int v = (10 * u + i) % K;
            if(dist[v] > dist[u] + i) {
                dist[v] = dist[u] + i;
                pq.push(pii(-dist[v], v));
            }
        }
    }

    cout << dist[0];
}


Measured memory_bytes: 2804
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int a;
  cin >> a;
  cout << a + a * a + a * a * a;
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {
    class Combination {
        int n;
        long mod;
        long[] facts;

        public Combination(int n, long mod) {
            this.n = n;
            this.mod = mod;
            facts = new long[n];
            facts[0] = 1;
            for (int i = 1; i < n; i++) {
                facts[i] = facts[i - 1] * i % mod;
            }
        }

        long modpow(long a, long b) {
            if (b == 0) return 1;
            else if (b == 1) return a;

            long x = modpow(a, b / 2);
            return b % 2 == 0 ? x * x % mod : x * (x * a % mod) % mod;
        }

        long inv(long n) {
            return modpow(n, mod - 2);
        }

        public long nck(int n, int k) {
            return n < k ? 0 : facts[n] * (inv(facts[n - k]) * inv(facts[k]) % mod) % mod;
        }
    }


    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] aArr = new int[n + 1];
        int[] nArr = new int[n + 2];
        for (int i = 0; i < n + 2; i++) {
            nArr[i] = -1;
        }
        int start = 0, end = 0;
        for (int i = 0; i < n + 1; i++) {
            int a = sc.nextInt();
            aArr[i] = a;
            if (nArr[a] != -1) {
                start = nArr[a];
                end = i;
            }
            nArr[a] = i;
        }

        int r = start + (n - end);

        Combination combi = new Combination(n + 10, (long) 1e9 + 7);
        for (int i = 1; i < n + 2; i++) {
            hoge(combi, n, i, r);
        }
    }

    void hoge(Combination combi, int n, int k, int r) {
        System.out.println(mod(combi.nck(n + 1, k) - combi.nck(r, k - 1)));
    }

    long mod(long n) {
        long mod = (long) 1e9 + 7;
        return n < 0 ? mod + n : n;
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 62408
/**
*    author:  boutarou
*    created: 20.06.2020 20:32:16
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const double PI = 3.1415926535897932;
const lint MOD = 998244353;

lint dp[3005][3005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int sh, sw, gh, gw;
    cin >> sh >> sw >> gh >> gw;
    dp[sh][sw] = 1;
    for (int i = sh + 1; i <= gh; i++) {
        if (i == sh + 1) dp[i][sw] = sw; 
        else dp[i][sw] = dp[i - 1][sw] * sw;
        dp[i][sw] %= MOD;
    }
    for (int i = sw + 1; i <= gw; i++) {
        if (i == sw + 1) dp[sh][i] = sh;
        else dp[sh][i] = dp[sh][i - 1] * sh;
        dp[sh][i] %= MOD;
    }
    for (int i = sh + 1; i <= gh; i++) {
        for (int j = sw + 1; j <= gw; j++) {
            dp[i][j] += dp[i][j - 1] * i % MOD;
            dp[i][j] += dp[i - 1][j] * j % MOD;
            dp[i][j] %= MOD;
            dp[i][j] -= (i - 1) * (j - 1) * dp[i - 1][j - 1];
            dp[i][j] %= MOD;
            if (dp[i][j] < 0) dp[i][j] += MOD;
        }
    }
    cout << dp[gh][gw] << endl;
    
    return 0;
}

Measured memory_bytes: 73968
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define N 310
#define mod 1000000007
#define pa(a, b) (data){a, b}
using namespace std;
struct data{int x, y;};
int n, m, x, y, z, f[N][N][N], ans;
vector<data>son[N];
inline int check(int x, int y, int i){
	for(int j=0; j<son[i].size(); j++){
		if(son[i][j].y==1&&son[i][j].x<=y)return 0;
		if(son[i][j].y==2&&(son[i][j].x<=x||son[i][j].x>y))return 0;
		if(son[i][j].y==3&&son[i][j].x>x)return 0;
	}
	return 1;
}
int main(){
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; i++)son[i].clear();
	for(int i=1; i<=m; i++){scanf("%d%d%d", &x, &y, &z); son[y].push_back(pa(x, z));}
	memset(f, 0, sizeof(f)); f[0][0][0]=1;
	for(int i=0; i<=n-1; i++)
		for(int j=0; j<=i; j++)
			for(int k=j; k<=i; k++)if(f[i][j][k]){
				if(check(j, k, i+1))f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k])%mod;
				if(check(k, i, i+1))f[i+1][k][i]=(f[i+1][k][i]+f[i][j][k])%mod;
				if(check(j, i, i+1))f[i+1][j][i]=(f[i+1][j][i]+f[i][j][k])%mod;
			}
	ans=0;
	for(int i=0; i<=n; i++)
		for(int j=i; j<=n; j++)ans=(ans+f[n][i][j])%mod;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 116736
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define F first
#define S second
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define MP make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define debug(x) cout << " > " << #x << ':' << x << endl;
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using Prior = priority_queue<T>;
template<typename T> using prior = priority_queue<T, vec<T>, greater<T>>;

const int INF = 1e9;
const ll LLINF = (ll)4*1e18;
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
const int xx[8] = {0,1,0,-1,1,1,-1,-1};
const int yy[8] = {1,0,-1,0,1,-1,-1,1};

void pmod(ll &a, ll b) {a = (a+b)%MOD;}
void mmod(ll &a, ll b) {a = (a-b+MOD)%MOD;}
void tmod(ll &a, ll b) {a = (a*b)%MOD;}
ll POW(ll a, ll b) {ll res=1; do{if(b%2)tmod(res,a);tmod(a,a);}while(b>>=1); return res;}
template<typename T> void amax(T &a, T b) {if(a < b) a = b;}
template<typename T> void amin(T &a, T b) {if(a > b) a = b;}

#define N 100010

void solve(){
    int n, m;
    
    cin >> n >> m;
    vec<int> v(n), sta(m+1, -2);
    for(auto &i:v) cin >> i;
    
    rep(i, v[0]) sta[i] = -1;
    
    rep(i, m){
        for(auto j:v){
            if(i+j > m) break;
            amax(sta[i+j], sta[i]*-1);
        }
    }
    
    cout << (sta[m] == 1 ? "First" : "Second") << endl;

}

int main(){
//    kiyohime
    int T = 1;
    
//    cin >> T;
    while(T--){
        solve();
    }
}


Measured memory_bytes: 3720
n = int(input())
num = 0
flag = False
mx = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        if flag:
            num += 1
        else:
            flag = True
            num = 1
    else:
        flag = False
        num = 0
    mx = max(mx, num)

if mx >= 3:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9172
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(void){
  int x, res;
  rep(i,5){
    cin >> x;
    if(x==0) res=i+1;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d)<<endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, K, A):
    for i in range(H):
        for j in range(W):
            if A[i][j] == 'S':
                s = (i, j)
    from collections import deque

    q = deque([s])
    d = [[None] * W for _ in range(H)]
    d[s[0]][s[1]] = 0

    ans = INF
    while q:
        x, y = q.popleft()
        ans = min(ans, min(abs(x), abs(x-H+1), abs(y), abs(y-W+1)))
        c = d[x][y]
        if c + 1 > K:
            continue
        for vx, vy in [(x-1, y), (x, y-1), (x, y+1), (x+1, y)]:
            if not (0 <= vx < H and 0 <= vy < W):
                continue
            if A[vx][vy] == '#':
                continue
            if d[vx][vy] is not None:
                continue
            q.append((vx, vy))
            d[vx][vy] = c + 1

    return 1 + -(-ans // K)


def main():
    H, W, K = read_int_n()
    A = [read_str() for _ in range(H)]
    print(slv(H, W, K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 95184
def eratosthenes(a, b):
    if a < b:
        return eratosthenes(b, a)
    while a%b != 0:
        temp = b
        b = a%b
        a = temp

    return b


def lcm(a, b):
    return int(a * b / eratosthenes(a, b))


A, B, C, D = map(int, input().split())

count = B - A + 1
count -= B // C - (A-1) // C
count -= B // D - (A-1) // D
L = lcm(C, D)
count += B // L - (A-1) // L

print(count)


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

const int maxn=5005;
const int mod=1e9+7;
int n,m,mm,sz,ans,k;
bool bad;
int p[maxn],a[maxn],pw[maxn],fac[maxn];
int dp[maxn],f[maxn],g[maxn];
vector<int>edge[maxn];
bool vis[maxn];

void Add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

void dfs(int x){
	vis[x]=true;
	sz++;
	if(!~p[x])bad=true;
	for(int i=0;i<int(edge[x].size());i++)
		if(!vis[edge[x][i]])dfs(edge[x][i]);
}

int main(){
	scanf("%d",&n);
	fac[0]=pw[0]=1;
	for(int i=1;i<=n;i++){
		fac[i]=1LL*fac[i-1]*i%mod;
		pw[i]=1LL*pw[i-1]*(n-1)%mod;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&p[i]);
		if(~p[i])edge[i].push_back(p[i]),edge[p[i]].push_back(i);
		else k++;
	}
	for(int i=1;i<=n;i++)if(!vis[i]){
		sz=0;
		bad=false;
		dfs(i);
		if(bad)a[++m]=sz;
		else mm++;
	}
	ans=1LL*mm*pw[k]%mod;
	dp[0]=1;
	for(int i=1;i<=m;i++)
		for(int j=i-1;j>=0;j--)
			Add(dp[j+1],1LL*dp[j]*a[i]%mod);
	dp[1]=(dp[1]+mod-m)%mod;
	for(int j=1;j<=m;j++)
		Add(ans,1LL*dp[j]*fac[j-1]%mod*pw[m-j]%mod);
	printf("%d\n",int((1LL*n*pw[k]+mod-ans)%mod));
	return 0;
}

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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];    
    ll ans = 0;
    ll now = 1;
    for(int i=0;i<n;i++){
        if(now == a[i]){
            now++;
            continue;
        }
        ans += (a[i]-1LL) / now;
        if(now==1)now++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M;
    cin>>N>>M;

    int a[M],b[M];
    Graph G(N);
    rep(i,M){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    string ans="YES";
    rep(i,N){
        if(G[i].size()%2==1){
            ans="NO";
            break;
        }
    }
    cout << ans << endl;
    



}


Measured memory_bytes: 7680
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
  int n;
  cin>>n;
  vector<int> v;

  for(int i = 0; i < n;  i++)
  {
      int a;
      cin>>a;
      v.push_back(a);
  }

    int cnt = 0;
    int target = 1;

    for(int i: v)
    {
        if(i == target)
        {
            cnt++;
            target++;
        }
    }
    if(cnt == 0) cout<<-1<<endl;
    else cout<<n-cnt<<endl;

  return 0;
}

Measured memory_bytes: 1528
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.array;

void main() {
    int n = readln.chomp.to!int;
    auto s = readln.chomp.split;

    bool[string] dict;
    int ans;

    foreach(ss; s) {
        if ((ss in dict) is null) {
            dict[ss] = true;
            ans++;
        }
    }

    if (ans == 3) {
        writeln("Three");
    }
    else {
        writeln("Four");
    }

    return;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;
int r = 0, b = 0, g = 0;
int cr = 0, cb = 0, cg = 0;

using namespace std;

int select(char c){
    if(c == 'R'){
        return 1;
    } else if(c == 'G'){
        return 2;
    } else {
        return 4;
    }
}


int choose(char c){
}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    ll ans = 0;

    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            r++;
        } else if(s[i] == 'G'){
            g++;
        } else {
            b++;
        }
    }
    

    for(int i = 0; i < n-2; i++){
        if(s[i] == 'R'){
            r--;
        } else if(s[i] == 'G'){
            g--;
        } else {
            b--;
        }
        cr = r;
        cb = b;
        cg = g;
            
        int color = 0;
        for(int j = i+1; j < n-1; j++){
            if(s[j] == 'R'){
                cr--;
            } else if(s[j] == 'G'){
                cg--;
            } else {
                cb--;
            }
            if(s[i] == s[j]) continue;
            int d = j-i;

            color = select(s[i]) + select(s[j]);
            if(7-color == 1){
                if(j+d < n && s[j+d] == 'R'){
                    ans += cr;
                    ans--;
                } else{
                    ans += cr;
                }
            }else if(7-color == 2){
                if(j+d < n && s[j+d] == 'G'){
                    ans += cg;
                    ans--;
                } else{
                    ans += cg;
                }
            }if(7-color == 4){
                if(j+d < n && s[j+d] == 'B'){
                    ans += cb;
                    ans--;
                } else{
                    ans += cb;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
n,m=map(int,input().split())
ac=[False]*n
wa=[0]*n

for i in range(m):
    pi,si=list(input().split())
    if si=="AC" and ac[int(pi)-1]==False:
        ac[int(pi)-1]=True
    if si=="WA" and ac[int(pi)-1]==False:
        wa[int(pi)-1]+=1

accnt=0
wacnt=0
for i in range(n):
    if ac[i]:
        accnt+=1
        wacnt+=wa[i]

print(accnt,wacnt)


Measured memory_bytes: 4596
// AOJ NTL_2_A Addition of Big Integers
// 2019.3.8 bal4u

#include <stdio.h>
#include <stdlib.h>

#define N       1000000000

int a[12000], b[12000], s[12000];
int a_minus, b_minus;
char buf[200100];

char *mpStr2Num(int *num, char *str)
{
	char *ss, *end;
	int  *nn;
	int  k, x;

//	while (*str == ' ' || *str == '\t') str++;
	while (*str == '0') str++;
	ss = str;
	while (*ss >= '0' && *ss <= '9') ss++;
	end = ss;

	if (ss == str) {
		*num = 0;
		return end;
	}

	x = 0, k = 1, nn = num;
	do {
		x += (*--ss - '0') * k;
		k *= 10;
		if (k == N || ss == str) {
			*++nn = x;
			x = 0;
			k = 1;
		}
	} while (ss != str);

	*num = nn - num;
	return end;
}

void mpNum2Str(char *str, int *num)
{
	int  i, j, x;
	char *ss;

	if (*num == 0 || (*num == 1 && *(num + 1) == 0)) {
		*str++ = '0';
		*str = '\0';
		return;
	}

	ss = str - 1;
	for (i = *num; i > 0; i--) {
		x = *++num;
		for (j = 1; j < N; j *= 10) {
			*++ss = x % 10 + '0';
			x /= 10;
		}
	}
	while (*ss == '0') ss--;

	*(ss + 1) = '\0';
	while (str < ss) {
		x = *str;
		*str++ = *ss;
		*ss-- = x;
	}
}

void mpAdd(int *ret, int *a, int *b)
{
	int  i, lr, la, lb, x;
	int  *rr;

	la = *a, lb = *b;
	lr = (la >= lb) ? la : lb;
	rr = ret, x = 0;
	for (i = 1; i <= lr; i++) {
		if (i <= la) x += *++a;
		if (i <= lb) x += *++b;
		if (x < N) *++rr = x, x = 0;
		else       *++rr = x - N, x = 1;
	}
	*++rr = x;
	*ret = lr + x;
}

void mpSub(int *ret, int *a, int *b)
{
	int  i, la, lb, x;
	int  *rr;

	la = *a, lb = *b;
	rr = ret, x = 0;
	for (i = 1; i <= la; i++) {
		x += *++a;
		if (i <= lb) x -= *++b;
		if (x >= 0) *++rr = x, x = 0;
		else 		*++rr = x + N, x = -1;
	}
	while (--i > 0) if (*rr-- != 0) break;
	*ret = i;
}

int mpCmp(int *a, int *b)
{
	int  *aa;

	if (*a != *b) return *a - *b;
	aa = a, a += *aa, b += *aa;
	while (a != aa) {
		if (*a != *b) return *a - *b;
		a--, b--;
	}
	return 0;
}

int mpAddSub(int *ret, int *a, int a_minus, int *b, int b_minus)
{
	int k, minus = 0;

	if (a_minus && b_minus) minus = 1, a_minus = 0, b_minus = 0;
	if (!a_minus && !b_minus) mpAdd(ret, a, b);
	else {
		k = mpCmp(a, b);
		if (k == 0) *ret = 0, minus = 0;
		else if (k > 0) mpSub(ret, a, b), minus = a_minus;
		else            mpSub(ret, b, a), minus = b_minus;
	}
	return minus;
}

int main()
{
	int minus;
	char *p;

	fgets(p = buf, 200100, stdin);
	if (*p == '-') a_minus = 1, p++;
	p = mpStr2Num(a, p);
	while (*p == ' ') p++;

	if (*p == '-') b_minus = 1, p++;
	mpStr2Num(b, p);

	minus = mpAddSub(s, a, a_minus, b, b_minus);
	if (minus) putchar('-');
	mpNum2Str(buf, s);
	puts(buf);
	return 0;
}


Measured memory_bytes: 2088
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double result = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
    
    cout << fixed << result << endl;

    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

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;

int main(){
	int n, m;
	set<string> u;
	string s;
	bool o = 0;
	
	cin >> n;
	while(n--){
		cin >> s;
		u.insert(s);
	}
	cin >> m;
	while(m--){
		cin >> s;
		if(!u.count(s)) cout << "Unknown " << s << endl;
		else{
			o ^= 1;
			cout << (o ? "Opened" : "Closed") << " by " << s << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#include <vector>
#define MAX 10100

using namespace std;

int mp[]={0,2,5,5,4,5,6,3,7,6};
vector<int> sticks;
int n,extra,m,firstMatch,firstCnt;
int d[MAX];

// string maxStr(string a,string b){
//     if(a[0]=='-')return b;
//     if(b[0]=='-')return a;
//     if(a.size()==b.size())return max(a,b);
//     return a.size()>b.size()?a:b;
// }

void dp(int extra) {
    int i,j;
    d[0]=0;
    for(i=0;i<=n-2;i++){
        for(j=0;j<m;j++){
            d[i+mp[sticks[j]]]=max(d[i+mp[sticks[j]]],d[i]+1);
        }
    }
    int r=n;
    sort(sticks.rbegin(),sticks.rend());

    while(r>0){
        for(i=0;i<m;i++){
            if(r-mp[sticks[i]]>=0&&d[r-mp[sticks[i]]]==d[r]-1){
                cout<<sticks[i];
                r-=mp[sticks[i]];
                break;
            }
        }
    }
}
int main() {
    int i, t;
    cin>>n>>m;
    for(i=0;i<MAX;i++){
        d[i]=-100;
    }
    int first = 999;
    for(i=0;i<m;i++){
        cin >> t;
        sticks.push_back(t);
    }
    dp(n);
    // cout<<;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<Integer> hList = new ArrayList<Integer>();
		ArrayList<Integer> wList = new ArrayList<Integer>();
		int H = 0;
		int W = 0;

		while (true) {

			H = input();
			W = input();

			if (H == 0 && W == 0) {

				break;

			} else {

				hList.add(H);
				wList.add(W);

			}
		}

		for (int i = 0; i < hList.size(); i++) {

			for (int j = 1; j <= hList.get(i); j++) {

				for (int k = 1; k <=wList.get(i) ; k++) {

					if (j % 2 == 1 && k % 2 == 1) {

						System.out.print("#");

					} else if (j % 2 == 1 && k % 2 == 0) {

							System.out.print(".");

					} else if (j % 2 == 0 && k % 2 == 1) {

						System.out.print(".");

					} else {

						System.out.print("#");

					}
				}

				System.out.println("");

			}

			System.out.println("");

		}

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 34648
import sys
X = int(input())

for x in range(100000):
    if 2 * x ** 5 == X:
        print(x, -x)
        sys.exit()
    for y in range(x):
        if (x ** 5 - y ** 5) == X:
            print(x, y)
            sys.exit()
        if (-x ** 5 + y ** 5) == X:
            print(-y, -x)
            sys.exit()
    tmp = 0
    y = 0
    while tmp < X:
        tmp = x ** 5 + y ** 5
        if tmp == X:
            print(x, -y)
            sys.exit()
        y += 1

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    COMinit();
    ll n,k;cin >>n>>k;
    for (int i = 1; i <= k; ++i) {
        cout <<COM(n-k+1,i)*COM(k-1,i-1)%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
#define M 1000005
#define P 1000000007
#define LL long long
using namespace std;
int A[M];
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b+c<=a)puts("0");
	else printf("%d\n",c-(a-b));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end(),greater<ll>());
  ll ans = 0;
  rep(i,n-1){
    ans+=a[(i+1)/2];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  200005

ll n,x,y;
vi adj[N];
ll subsize[N];
ll par[N];
ll ans=0;
ll pow2[N];
ll dfs(ll n,ll p)
{
    par[n]=p;
    ll c=1;
    for(auto u:adj[n])
    {
        if(u!=p)
        {
            c+=dfs(u,n);
        }
    }
    subsize[n]=c;
    return c;
}
void dfs1(ll nod,ll par)
{
    vi v;
    x=0;
    y=0;
    if(n-subsize[nod]!=0)
    v.pb(n-subsize[nod]);
    for(auto u:adj[nod])
    {
        if(u!=par)
        {
            v.pb(subsize[u]);
        }
    }
    x=0;
    if(v.size()>1)
    {
        // cout<<nod<<endl;
        for(auto u:v)
        {
            // cout<<u<<" ";
            x=(x+pow2[u])%hell;
        }
        x=(x+1)%hell;
        // cout<<endl;
        y=(pow2[n-1]+1)%hell;
        ans=(ans+(y-x+hell)%hell)%hell;
    }
    
    for(auto u:adj[nod])
    {
        if(u!=par)
        {
            dfs1(u,nod);
        }
    }
}
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

void solve()
{
    cin>>n;
    rep(i,0,n-1)
    {
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    rep(i,0,n+1)
    {
        pow2[i]=(expo(2,i,hell)-1+hell)%hell;
    }
    adj[0].pb(1);
    adj[1].pb(0);
    dfs(1,0);
    subsize[0]=n+1;
    // rep(i,0,n+1)
    // cout<<subsize[i]<<" ";
    dfs1(1,0);
    // cout<<ans<<endl;
    y=expo(2,n,hell);
    ans=(ans*expo(y,hell-2,hell))%hell;
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 41956
#include<bits/stdc++.h>
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
int main()
{
     ll n, m, i, j, k, l;
     cin>>n;
     m=100;
     ll cnt=0;
     while(m<n)
     {
         ll res=(m/100);
         m+=res;
         cnt++;
     }
     cout<<cnt<<endl;
     return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

bool RS(string S, int n)
{
	if (n % 2 == 1)
		return false;
	
	for (int i = 0; i < n/2; i++) {
		if (S[i] != S[i + n/2])
			return false;
	}
	
	return true;
}

void PutYN(bool b)
{
	if (b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main()
{
	int n; string S;
	cin >> n >> S;
	
	PutYN(RS(S, n));
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int sum = 700;

        for(int i = 0;i<s.length();i++){
            if(s.charAt(i)=='o'){
                sum += 100;
            }
        }
        System.out.println(sum);

    }

}


Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

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

	double point[2][4097];
	point[0][0] = 0; point[1][0] = 0; point[0][4096] = 100; point[1][4096] = 0;
	double l = 100; double root3 = sqrt(3.0); double gosa = 0.0001;

	for(int i = 0; i < n; i++){
		l = 100 / pow(3.0,i + 1);
		int step = pow(4.0,6-i);
		int step4 = step / 4;
		double x,y;
		for(int j = 0; j < 4096; j += step){
			point[0][j + step4] = point[0][j] / 3 * 2 + point[0][j + step] / 3;
			point[1][j + step4] = point[1][j] / 3 * 2 + point[1][j + step] / 3;
			point[0][j + step4 * 3] = point[0][j] / 3 + point[0][j + step] / 3 * 2;
			point[1][j + step4 * 3] = point[1][j] / 3 + point[1][j + step] / 3 * 2;


			x = point[0][j + step4] - point[0][j];
			y = point[1][j + step4] - point[1][j];

			point[0][j + step4 * 2] = point[0][j + step4] + x / 2 - y / 2 * root3;
			point[1][j + step4 * 2] = point[1][j + step4] + x / 2 * root3 + y / 2;
		}
	}

	int step = pow(4.0, 6 - n);

	for(int i = 0; i < 4097; i += step)
		cout << fixed << setprecision(8) << point[0][i] << " " << point[1][i] << endl;
}

Measured memory_bytes: 1344
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> P;
    for (int i = 2; N; i++) {
        int prime = 1;
        for (auto p : P) if (i%p == 0) {
            prime = 0;
            break;
        }
        if (prime) {
            P.push_back(i);
            if (i%5 == 1) printf("%d%c", i, --N ? ' ' : '\n');
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

string s;int n;
int solve(char ch) {
    int maxm = 0;
    int counter = 0;
    int i = 0;
    while (i < n) {
        if(s[i] != ch) counter++;
        else {
            maxm = max(maxm, counter);
            counter = 0;
        }
        i++;
    }

    maxm = max(maxm, counter);
    return maxm;
}

int main() {
  std::ios::sync_with_stdio(false);
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin>>s;
  n = s.size();

  int answer = 1000;
  for(int i = 0;i < 26;i++) {
      answer = min(answer, solve('a'+i));
  }

  cout<<answer<<endl;

  return 0;
}


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

int main(){
  int d[10]={0,0,1,2,0,-1,2,0,1,2},cnt,ans,c;
  string s;
  while(1){
    cin>>s;
    if(s=="#") break;
    ans=(1e9);
    for(int i=0;i<2;i++){
      c=i;
      cnt=0;
      for(int j=1;j<s.size();j++){
	int k=s[j-1]-'0',t=s[j]-'0';
	if((!c&&d[k]>d[t])||(c&&d[k]<d[t])) cnt++;
	else c=!c;
      }
      ans=min(ans,cnt);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

double PI = 3.1415;

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

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    double a, b, x; cin >> a >> b >> x;
    double ans;
    if(x >= a*a*b/2){
        ans = atan(2.0*(a*a*b-x)/(a*a*a));
        ans = ans*180/M_PI;
    }
    else{
        ans = atan(x*2/(a*b*b));
        ans = ans*180/M_PI;
        ans = 90.0 - ans;
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int n,x,sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&x);
		sum+=x-1;
	}
	printf("%d\n",sum);
}

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

using namespace std;

long long int k, n, i, j, a, b, c, h, sum;
const int maxn = 1000;
int e[maxn][maxn];
int q[maxn];
int w[maxn];
double u, m;

int main()
{
	cin >> n;
	m = n;
	if(n % 2 == 0){
		cout << 0.5;
	}
	else{
		n = n / 2 + 1;
		u = n;
		u = u / m;
		cout << u;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
int n, d[101]; vector<int> v[101];
void bfs(int c, int x) {
  queue<int> q; q.push(c);
  d[c] = x;
  while(!q.empty()) {
    int t = q.front(); q.pop();
    for(int i = 0; i < v[t].size(); ++i) {
      if(d[v[t][i]] > -1) continue;
      q.push(v[t][i]);
      d[v[t][i]] = d[t]+1;
    }
  }
}
int main() {
  scanf("%d", &n);
  for(int i = 0, u, k; i < n; ++i) {
    scanf("%d %d", &u, &k);
    for(int j = 0, vj; j < k; ++j) {
      scanf("%d", &vj);
      v[u].push_back(vj);
    }
    d[i+1] = -1;
  }
  bfs(1, 0);
  for(int id = 1; id <= n; ++id) {
    printf("%d %d\n", id, d[id]);
  }
}


Measured memory_bytes: 2756
N = int(input())
A = list(map(int,input().split()))
A.append(0)

money = 1000
kabu = 0

for i in range(N):
    if kabu > 0:
        money += kabu*A[i]
        kabu = 0
    if A[i] < A[i+1]:
        kabu = money//A[i]
        money -= (money//A[i])*A[i]

print(money)

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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	ll r, D, x;
	cin >> r >> D >> x;
	for (int i = 0; i < 10; ++i) {
		x = r * x - D;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, m; cin >> n >> m;
	string s; cin >> s;
	reverse(all(s));
	vector<int> ans;
	int cnt = 0;
	rep(i, 0, n)
	{
		int tmp = 0;
		while (i < n + 1 && s[i] == '1')
		{
			++tmp;
			++i;
		}
		cnt = max(cnt, tmp);
	}
	if (cnt >= m)
	{
		cout << -1 << endl;
		return 0;
	}

	int now = 0;

	while(now < n)
	{
		int a = m;
		while (now + a > n || s[now + a] == '1')--a;
		ans.push_back(a);
		now += a;
	}
	reverse(all(ans));
	for (int x : ans)cout << x << " ";
}


Measured memory_bytes: 1144
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var mod int64 = 1000000007
var sum int64
var ans int64

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		sum += int64(a[i])
		sum %= mod
	}

	for i := 0; i < n; i++ {
		sum -= int64(a[i])
		if sum < 0 {
			sum += mod
		}

		ans += int64(a[i]) * sum
		ans %= mod
	}
	fmt.Println(ans)
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        int x;
        cin >> x;
        A[i] = x - (i + 1);
    }

    sort(A.begin(), A.end());

    int b = A[N/2];

    ll ans = 0;
    for(int i = 0; i < N; i++) ans += abs(A[i] - b);
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

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

  string s;
  cin >> s;
  int ans = -1;
  REP(i, 1, s.length())
  {
    if (i + i >= s.length())
      break;
    if (s.substr(0, i) == s.substr(i, i))
      ans = i * 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll LINF = ll(1e18) + 1;
int n;
ll k;
vector<ll> a;

bool is_ok(ll x) {
  ll tot = 0;
  REP(i, n) {
    if (a[i] < 0) {
      // l: ng, r: ok
      int l = -1, r = n;
      while(r - l > 1) {
        int mid = (l + r) / 2;
        // ok 側を動かす
        if (a[mid] * a[i] < x) r = mid;
        else
          l = mid;
      }
      tot += n - r;
    } else {
      // l: ok, r: ng
      int l = -1, r = n;
      while(r - l > 1){
        int mid = (r + l) / 2;
        if (a[mid] * a[i] < x) l = mid;
        else
          r = mid;
      }
      tot += r;
    }
    if (a[i] * a[i] < x) tot--;
  }
  tot /= 2;
  return tot < k;
}

void solve(istream& cin, ostream& cout) {
  cin >> n >> k;
  a.resize(n);
  REP(i, n) cin >> a[i];
  SORT(a);
  ll l = -LINF, r = LINF;
  while (r - l > 1) {
    ll mid = (l + r) / 2;
    if (is_ok(mid)) l = mid;
    else
      r = mid;
  }
  cout << l << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

// const ll MOD = 998244353;
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, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

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

  if (d[0] != 0) {
    cout << 0 << endl;
    return 0;
  }

  sort(d.begin(), d.end());
  vector<int> c(d.back() + 1);
  rep(i, n) c[d[i]]++;

  if (c[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  int C = c.size();

  // ll ans = 1;
  mint ans = 1;
  for (int i = 1; i < C; i++) {
    rep(j, c[i]) ans *= c[i - 1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3984
import math

n = int(input())
s = [input() for _ in range(n)]

def c(n):
    return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))

s_list = []
for i in s:
    s_list.append(sorted(i))

s_list = sorted(s_list)

ans = 0
i = 0
while i < n-1:
    count = 0
    while s_list[i] == s_list[i+1]:
        count += 1
        i += 1
        if i == n-1:
            ans += c(count+1)
            break
        elif i+1 <= n-1:
            if s_list[i] != s_list[i+1]:
                ans += c(count+1)
                break
    i += 1

print(ans)

Measured memory_bytes: 33488
N = int(input())
L =list(map(int, input().split()))

L.sort()

cnt = 0
comb = []
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(i+2,N):
      if L[i] < L[j] < L[k] :
        comb.append([L[i],L[j],L[k]])
        
for i in range(len(comb)):
  X = comb[i][0] + comb[i][1]
  if X > comb[i][2]:
    cnt += 1
print(cnt)

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

string s;

bool isOK(int l) {
  for(int i = 0; i < l; i++) {
    if(s[i] != s[i+l]) return false;
  }
  return true;
}

int main () {
  cin >> s;
  int res;
  for(int l = s.size() / 2 - 1; l >= 1; l--) {
    if(isOK(l)) {
      res = 2*l;
      break;
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String[] firstLine = input.readLine().split(" ");
        int N = Integer.parseInt(firstLine[0]);
        int L = Integer.parseInt(firstLine[1]);

        String[] strings = new String[N];

        for (int i = 0; i < N; i++) {
            strings[i] = input.readLine();
        }

        Arrays.sort(strings);

        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < N; i++) {
            builder.append(strings[i]);
        }
        System.out.println(builder.toString());
    }
}

Measured memory_bytes: 21332