akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int A[3];

int main(){
  for(int i = 0; i<3 ;i++){
    cin >> A[i];
  }
  
  int ma = max(A[0],max(A[1],A[2]));
  int mi = min(A[0],min(A[1],A[2]));
  
  cout << ma - mi << endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
char S[202020][14];
pll s[202020];
ll i, j, k;
ll ans = 1;
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%s", S[i]);
        k = 0;
        fornum(j,0,10){
            k *= 30;
            if(S[i][j])
                k += S[i][j] - 'a' + 1;
        }
        s[i] = {k, i};
    }
    sort(s, s + N);
    j = 0;
    fornum(i,1,N+1){
        if(s[j].first!=s[i].first){
            ans = max(ans, i - j);
            j = i;
        }
    }

    j = 0;
    fornum(i,1,N+1){
        if(s[j].first!=s[i].first){
            if(i-j==ans){
                printf("%s\n", S[s[j].second]);
            }
            j = i;
        }
    }

    return 0;
}

Measured memory_bytes: 7808
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        int s = scan.nextInt();

        while (x != 0 || y != 0 || s != 0) {

            int komi;
            int komi2;
            int max = 0;

            int goukei;
            for (int i = 1; i <= 1000; i++) {
                for (int g = 1; g <= 1000; g++) {
                    goukei = i * (100 + x) / 100 + g * (100 + x) / 100;
                    if (goukei == s) {

                        komi = (i * (100 + y) / 100) + (g * (100 + y) / 100);

                        if (komi > max) {
                            max = komi;
                        }
                    }
                }
            }
            System.out.println(max);

            x = scan.nextInt();
            y = scan.nextInt();
            s = scan.nextInt();

        }
    }

}



Measured memory_bytes: 29248
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef priority_queue<int> PQI;
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);

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

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b;
    cin>>a>>b;
    cout<<a*b<<" "<<a*2+b*2<<endl;
    
}


Measured memory_bytes: 3136
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,a[20]={},ans=INF,cnt,high,x;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=1; i<(1<<n); i++) {
    if(__builtin_popcount(i)<k||!(i&1)) {
      continue;
    }
    cnt=0;
    high=a[0];
    x=1;
    for(int j=1; j<n; j++) {
      if(x>=k) {
        break;
      }
      if(i&(1<<j)) {
        if(a[j]<=high) {
          cnt+=high+1-a[j];
          high++;
          x++;
        }
        else {
          x++;
          high=a[j];
        }
      }
      else {
        high=max(high,a[j]);
      }
    }
    ans=min(ans,cnt);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
# B  => TLE
n = int(input())
a = list(map(int, input().split()))

ans = 1
if a.count(0) > 0:
    ans = 0
else:
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            ans = -1
            break
    
print(ans)

Measured memory_bytes: 21656
a,b,c,k = gets.split.map(&:to_i)


a_num = 0
b_num = 0
c_num = 0

if k - a > 0
  a_num = a
  if (k - a) -b > 0
    b_num = b
    if (k -a -b)-c > 0
      c_num = c

    else
      c_num = k-a-b
    end
  else
    b_num = k-a
  end
else
  a_num = k
end


puts a_num * 1 + c_num * -1

Measured memory_bytes: 14424
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;
  cin >>a>>b;
  if(a==0 || b==0){
    cout<<"Zero"<<endl;
  }else if(a>0){
    cout<<"Positive"<<endl;
  }else if(a<0){
    if(b>0){
      cout<<"Zero"<<endl;
    }
    if(b<0){
      if((b-a)%2==0)	cout<<"Negative"<<endl;
      else	cout<<"Positive"<<endl;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef pair<int,int> pii;
int n,m,S,T;
queue<pii> q;
int dp[N][3];
bool inq[N][3];
vector<int> G[N];

void spfa() {
	memset(dp,0x3f,sizeof(dp));
	dp[S][0]=0; inq[S][0]=1;
	q.push(make_pair(S,0));
	while (!q.empty()) {
		pii x=q.front(); q.pop();
		for (int i=0;i<G[x.first].size();i++) {
			int y=G[x.first][i];
			if (dp[y][(x.second+1)%3]>dp[x.first][x.second]+1) {
				dp[y][(x.second+1)%3]=dp[x.first][x.second]+1;
				if (!inq[y][(x.second+1)%3]) {
					q.push(make_pair(y,(x.second+1)%3));
					inq[y][(x.second+1)%3]=1;
				}
			}
		}
		inq[x.first][x.second]=0;
	}
}

int main()
{
	cin>>n>>m;
	for (int i=1;i<=m;i++) {
		int x,y; scanf("%d%d",&x,&y);
		G[x].push_back(y);
	}	
	scanf("%d%d",&S,&T);
	spfa();
	if (dp[T][0]!=0x3f3f3f3f) cout<<dp[T][0]/3<<endl; else cout<<-1<<endl;
	return 0;
} 

Measured memory_bytes: 7168
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 3/9/2019, 9:02:02 PM
# Powered by Visual Studio Code
#

n, m, c = gets.chomp.split(" ").map{|i| i.to_i}
b = gets.chomp.split(" ").map{|i| i.to_i}
a = []
n.times{
  a << gets.chomp.split(" ").map{|i| i.to_i}
}
ans = 0
for i in 0...n
  t = c
  for j in 0...m
    t += a[i][j] * b[j]
  end
  if t > 0
    ans += 1
  end
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N * 3);
    REP(i, 0, 3 * N) cin >> A[i];

    sort(ALL(A), greater<>());

    ll ans = 0;
    for (int i = 1; i < 2 * N; i += 2) ans += A[i];

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

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint32_t N = 0, x = 0;
  std::cin >> N >> x;

  std::vector<uint32_t> A(N);
  for (auto &&a_n : A) std::cin >> a_n;

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

  uint32_t i = 0, sum = 0;
  for (; i < A.size(); i++) {
    sum += A[i];
    if (sum >= x) break;
  }

  if (sum == x) i++;
  if (sum < x) i--;
  std::cout << i << std::endl;

  return 0;
}

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

int main () {
  int K, X;
  cin >> K >> X;
  
  for (int i = X-K+1; i < X+K;i++) {
    if (i < X+K-1) cout << i << " " ;
    else cout << i << endl;
  }
}

Measured memory_bytes: 256
A, B = map(int, input().split())

if (A%2==0) and (B%2==0):
  if (B-A) % 4 == 0:
    print(B)
  else:
    print(B+1)
elif (A%2==0) and (B%2==1):
  if (B-A+1) % 4 == 0:
    print(0)
  else:
    print(1)
elif (A%2==1) and (B%2==0):
  if (B-A-1) % 4 == 0:
    print(A^B)
  else:
    print(A^B^1)
else:
  if (B-A) % 4 == 0:
    print(A)
  else:
    print(A^1)

Measured memory_bytes: 9180
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=30;

int main(){
    int n;
    ll dp[N+1];

    dp[1]=1;
    dp[2]=2;
    dp[3]=4;

    for(int i=4;i<=N;i++){
        dp[i]= dp[i-1] + dp[i-2] + dp[i-3];
    }

    while(cin>>n,n){
        cout<<ceil(dp[n]/(double)3650)<<endl;
    }

    return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int** dp;
int N,M;
int POW[23],base[500],work[500];
char table[500][501];

int makeCode(){

	int ret = 0;

	for(int i = 0; i < M; i++){
		if(work[i] == 1){
			ret += POW[i];
		}
	}
	return ret;
}


void func_N(){

	int limit = POW[N];

	int ans = 0,count;
	bool FLG;

	for(int i = 0; i < limit; i++){

		for(int k = 0; k < M; k++)work[k] = 0;

		count = 0;

		for(int loop = 0; loop < N; loop++){
			if(i & (1 << loop)){
				count++;
				for(int k = 0; k < M; k++){
					work[k] += table[loop][k] - '0';
				}
			}
		}

		FLG = true;
		for(int k = 0; k < M; k++){
			if(work[k]%2 == 1){
				FLG = false;
				break;
			}
		}

		if(FLG)ans = max(ans,count);

	}

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


void func_M(){

	int limit = POW[M];

	for(int i = 0; i < limit; i++){
		dp[0][i] = 0;
		dp[1][i] = 0;
	}

	for(int i = 0; i < M; i++){
		work[i] = table[0][i]-'0';
	}
	dp[1][makeCode()] = 1;

	int array[500],tmp;

	for(int i = 1; i < N; i++){

		for(int state = 0; state < limit; state++){
			dp[0][state] = dp[1][state];
		}

		for(int k = 0; k < M; k++){
			array[k] = table[i][k] - '0';
		}

		for(int state = 0; state < limit; state++){
			if(dp[0][state] == 0)continue;

			for(int loop = 0; loop < M; loop++){
				if(state & (1 << loop)){
					base[loop] = 1;
				}else{
					base[loop] = 0;
				}
			}

			for(int k = 0; k < M; k++){
				work[k] = base[k]+array[k];
				work[k] %= 2;
			}

			tmp = makeCode();
			dp[1][tmp] = max(dp[1][tmp],dp[0][state]+1);
		}

		for(int k = 0; k < M; k++){
			work[k] = array[k];
		}

		tmp = makeCode();
		dp[1][tmp] = max(dp[1][tmp],1);
	}

	printf("%d\n",dp[1][0]);
}


int main(){

	for(int i = 0; i <= 22; i++){
		POW[i] = pow(2,i);
	}

	dp = new int*[2];
	dp[0] = new int[POW[22]];
	dp[1] = new int[POW[22]];


	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		for(int i = 0; i < N; i++){
			scanf("%s",table[i]);
		}

		if(N <= 22)func_N();
		else{
			func_M();
		}
	}

	return 0;
}

Measured memory_bytes: 19996
class Dice:
    def __init__(self, a, b, c, d, e, f):
        # サイコロの現在一番上にある面
        self.a = a
        self.b = b
        self.c = c
        self.d = d
        self.e = e
        self.f = f

        # 他のダイスと一致したかどうか
        self.result = 0

    def move(self, move_str):
        for i in move_str:
            if i == "N":
                self.move_N()
            elif i == "E":
                self.move_E()
            elif i == "W":
                self.move_W()
            elif i == "S":
                self.move_S()

    def move_N(self):
        tmp1 = self.a
        tmp2 = self.e
        self.a = self.b
        self.b = self.f
        self.e = tmp1
        self.f = tmp2

    def move_E(self):
        tmp1 = self.a
        tmp2 = self.c
        self.a = self.d
        self.c = tmp1
        self.d = self.f
        self.f = tmp2

    def move_W(self):
        tmp1 = self.a
        tmp2 = self.d
        self.a = self.c
        self.c = self.f
        self.d = tmp1
        self.f = tmp2

    def move_S(self):
        tmp1 = self.a
        tmp2 = self.b
        self.a = self.e
        self.b = tmp1
        self.e = self.f
        self.f = tmp2

    def check_one_around(self, dice):
        """チェックのために時計回りに一周させる"""
        for _ in range(4):
            """時計回りに回転"""
            tmp1 = self.b
            tmp2 = self.d
            self.b = self.c
            self.c = self.e
            self.d = tmp1
            self.e = tmp2

            # ダイスが一致しているかチェック
            self.check_dice_same(dice)

    def check_dice_same(self, dice):
        """引数指定したダイスと同一面かチェック"""
        if (
            self.a == dice.a and
            self.b == dice.b and
            self.c == dice.c and
            self.d == dice.d and
            self.e == dice.e and
            self.f == dice.f
        ):
            self.result += 1

    def all_check(self, dice):
        dice1.check_one_around(dice)
        # b面をトップにする
        dice1.move("N")
        dice1.check_one_around(dice)

        # c面をトップにする
        dice1.move("W")
        dice1.check_one_around(dice)

        # e面をトップにする
        dice1.move("W")
        dice1.check_one_around(dice)

        # d面をトップにする
        dice1.move("W")
        dice1.check_one_around(dice)

        # f面をトップにする
        dice1.move("N")
        dice1.check_one_around(dice)

    def clear_result(self):
        self.result = 0


a, b, c, d, e, f = map(int, input().split())
dice1 = Dice(a, b, c, d, e, f)
a, b, c, d, e, f = map(int, input().split())
dice2 = Dice(a, b, c, d, e, f)
dice1.all_check(dice2)

if dice1.result != 0:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5620
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 998244353
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI cnt(N, 0);
	int ans;
	REP(i, N) {
		int a;
		cin >> a;
		if (i == 0 && a != 0) {
			cout << 0 << endl;
			return 0;
		}
		cnt[a]++;
	}
	if (cnt[0]!=1) {
		cout << 0 << endl;
		return 0;
	}
	ans = 1;
	bool F = false;
	FOR(i,1, N) {
		if (F&&cnt[i]) {
			cout << 0 << endl;
			return 0;
		}
		if (!cnt[i])F = true;
	}

	FOR(i, 2, N) {
		int tmp = cnt[i - 1];
		REP(j, cnt[i]) {
			ans *= tmp;
			ans %= mod;
		}
		//cout << ans << endl;
	}
	cout << ans << endl;



	return 0;
}



Measured memory_bytes: 1024
import sys
N = int(sys.stdin.readline().rstrip())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    
    return a

primes = prime_factorize(N)

from collections import Counter

cnts = Counter(primes)
ans = 0
for p, cnt in cnts.items():
    tmp = 1
    while cnt - tmp >= 0:
        cnt -= tmp
        tmp += 1
        ans += 1
print(ans)

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

const int maxn = 1e5+100;

char s[maxn];
int sum[maxn][26];

int Minpos[26];

void solve(int len,int& resL,int& resR)
{
    for(int i = 1;i <= len;++i)
    {
        int w = s[i]-'a';
        sum[i][w]++;
        for(int j = 0;j < 26;++j)
        {
            sum[i][j] += sum[i-1][j];

            if(i == 1) continue;
            int prv = Minpos[j];
            int valprv = 2*sum[prv][j]-prv;
            int now = 2*sum[i][j]-i;
            if(now > valprv)
            {
                resL = prv+1;
                resR = i;
                return;
            }

        }

        for(int j = 0;j < 26;++j)
        {
            int prv = Minpos[j];
            int valprv = 2*sum[prv][j]-prv;

            int now = 2*sum[i-1][j]-(i-1);

            if(valprv > now)
            {
                Minpos[j] = i-1;
            }
        }

    }


}


int main()
{
   // freopen("./test.txt","r",stdin);
    scanf("%s",s+1);
    int len = strlen(s+1);
    memset(sum,0,sizeof(sum));
    memset(Minpos,0,sizeof(Minpos));
    int resL = -1,resR = -1;
    solve(len,resL,resR);
    printf("%d %d\n",resL,resR);

    return 0;
}


Measured memory_bytes: 10496
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        long K = scan.nextLong();

        long ans = 0;

        for(int i = 1; i <= K; i++) {
            for(int j = 1; j <= K; j++) {
                long gcd1 = gcd(i, j);
                for(int k = 1; k <= K; k++) {
                    long gcd2 = gcd(gcd1, k);
                    ans += gcd2;
                }
            }
        }

        os.println(ans);

    }

    static public long gcd(long a, long b) {
        if(a > b) {
            long tmp = a;
            a = b;
            b = tmp;
        }
        while(a > 0) {
            long tmpa = a;
            a = b % a;
            b = tmpa;
        }
        return b;
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,a,b;
int t[1252];

int main(){
  scanf("%d%d%d",&n,&a,&b);
  REP(i,n)scanf("%d",t+i);
  int x=0;
  REP(i,n)if(t[i]<a || b<=t[i])++x;
  cout<<x<<endl;
  return 0;
}


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

int main() {
  int N;
  int K;
  cin >> N >> K;
  int x=0;
  
  for(int i=0; i<N; i++){
    int h;
    cin >> h;
    
    if(h>K-1){
      x=x+1;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#define ll long long
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])

using namespace std;
ll helper(ll h){
    ll res = 1, res2 = 1;
    while(h > 1){
        res2 *= 2;
        res += res2;
        h = h >> 1;
    }
    return res;
}
int main(){
    ll h; cin >> h;
    cout << helper(h);
}













Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
   int a, b;
   cin >> a >> b;
   int power = 1;
   int ans = 0;
   while(power < b)
   {
      power += a-1;
      ans++;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    string s;
    cin >> n >> m >> s;

    vl dp(n+1, INF);  // dp[i] : マスiからマスnへの移動回数の最小値
    queue<ll> Q;

    dp[n] = 0;
    Q.push(0);
    for(ll i = n-1; i >= 0; i--) {
        while(1) {

            if(Q.size() == 0) {
                out(-1);
                re0;
            }
            
            if(Q.front() == INF || Q.size() > m) {
                Q.pop();
            }
            else {
                break;
            } 
        }
        if(s[i] == '0') {
            dp[i] = Q.front() + 1;
        } 
        Q.push(dp[i]);
    }
    
    vl ans;
    ll x = 0;
    ll rest = dp[0];
    while(x < n) {
        rest--;
        ll i = 1;
        while(dp[x+i] != rest) {
            i++;
        } 
        ans.pb(i);
        x += i;
    }

    rep(i, ans.size()) {
        cout << ans[i] << " ";
    }

    re0;
}

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

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

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

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

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

class Data{
public:
	int first;
	double second;
	string third;
};

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

	deque<Data> P1(8),P2(8),P3(8),P;
	REP(i,8){
		P1[i].first=in(),P1[i].third=in<string>();
	}
	REP(i,8){
		P2[i].first=in(),P2[i].third=in<string>();
	}
	REP(i,8){
		P3[i].first=in(),P3[i].third=in<string>();
	}

	auto comp = [](Data& l,Data& r){return l.third<r.third;};
	sort(ALL(P1),comp);
	sort(ALL(P2),comp);
	sort(ALL(P3),comp);
	
	REP(i,2){
		out(P1[0].first,P1[0].third);
		P1.pop_front();
	}
	REP(i,2){
		out(P2[0].first,P2[0].third);
		P2.pop_front();
	}
	REP(i,2){
		out(P3[0].first,P3[0].third);
		P3.pop_front();
	}
	copy(ALL(P1),back_inserter(P));
	copy(ALL(P2),back_inserter(P));
	copy(ALL(P3),back_inserter(P));
	sort(ALL(P),comp);

	REP(i,2){
		out(P[0].first,P[0].third);
		P.pop_front();
	}
	return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;


/*解法
*/
ll mod = 1e9 + 7;

ll pow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b % 2) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

ll imod(ll n) {
    ll p = mod;
    return pow(n, p - 2);
}

ll comb_mod(ll n, ll k, ll fact[]) {
    return (fact[n] * imod(fact[k]) % mod) * imod(fact[n - k]) % mod;
}

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    ll fact[h + w + 1];
    fact[0] = 1;
    for (int i = 0; i < h + w; i++) {
        fact[i + 1] = ((i + 1) * fact[i]) % mod;
    }
    ll ans = 0;
    for (ll x = 0; x < w - b; x++) {
        ans = (ans + (comb_mod(h - a + b - 1 + x, h - a - 1, fact) * comb_mod(w + a - b - 2 - x, a - 1, fact) % mod))% mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

// https://atcoder.jp/contests/abc123/tasks/abc123_d

using namespace std;

int main() {
  long long int x, y, z, k, a[1000], b[1000], c[1000];
  cin >> x >> y >> z >> k;
  for (int i = 0; i < x; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < y; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < z; i++) {
    cin >> c[i];
  }
  sort(a, a + x, std::greater<long long int>());
  sort(b, b + y, std::greater<long long int>());
  sort(c, c + z, std::greater<long long int>());

  vector<long long int> ans;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      for (int l = 0; l < z; l++) {
        if ((i + 1) * (j + 1) * (l + 1) <= k) {
          ans.push_back(a[i] + b[j] + c[l]);
        } else {
          break;
        }
      }
    }
  }
  sort(ans.begin(), ans.end(), std::greater<long long int>());

  for (int i = 0; i < k; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back
#define EPS 1e-9

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);


struct edge{int to,cost;};

const int MAX_V = 100000;
vector<edge> G[MAX_V];
int V,E;
int s,t,c;
int start,goal;

int d[MAX_V];

bool col[MAX_V];



int dijkstra(int s){

    priority_queue<pii,vector<pii>,greater<pii> > que;
    fill(d,d+V,LLINF);
    d[s] = 0;
    que.push(pii(d[s],s));

    while(!que.empty()){
        pii p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for(int i = 0;i < G[v].size();i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}

signed main(){


    cin >>V;
    E=V-1;
    for(int i = 0;i < E;i++){
        cin >> s>>t;
        c=1;
        G[s-1].pb((edge){t-1,c});
        G[t-1].pb((edge){s-1,c});
    }

    start=0;
    goal=V-1;


    for(int i = 0;i < V;i++){
        col[i]=0;
    }


    dijkstra(start);

    int disH;
    disH = d[goal]/2;

    int numB=0,numW=0;
    for(int i = 0;i < V;i++){
        if(d[i]<=disH){
            col[i]=1;
            numB++;
        }
    }

    queue<int> que;
    que.push(goal);
    numW++;
	col[goal]=1;


    while(!que.empty()){
        int q;
        q=que.front();que.pop();
        for(int i = 0;i < G[q].size();i++){
            if(col[G[q][i].to] != true){
                que.push(G[q][i].to);
                numW++;
                col[G[q][i].to]=1;
            }
        }
    }
    if(numW>=(V+1)/2){
        cout<< "Snuke"<< endl;
    }else{
        cout<< "Fennec"<< endl;
    }


    return 0;
}

Measured memory_bytes: 9084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str = reader.readLine();
		String[] pair = str.split("\\s+");
		int N = Integer.parseInt(pair[0]);
		int K = Integer.parseInt(pair[1]);
		
		str  = reader.readLine();
		String[] words = str.split("\\s+");
		int[] A = new int[N];
		for(int i=0;i<N;i++){
			A[i] = Integer.parseInt(words[i]);
		}
		int i  = 0;
		for(int j=K;j<N;j++){
			int last = A[i];
			int curr = A[j];
			if( curr > last){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
			i++;
		}
		reader.close();
	}
}

Measured memory_bytes: 65784
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
  int n;
  cin >> n;
  
  vector<int> v(n * 3);
  for(int i = 0; i < (n * 3); i++) {
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end(), greater<int>());
  
  long ans = 0;
  for(int i = 0; i < n * 2; i++) {
    if(i % 2 != 0) {
      ans += v.at(i);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1408
N, X = map(int, input().split())

f = [[0, 0] for i in range(N + 1)]

# 総数, パティ
f[0] = [1, 1]
for i in range(1, N + 1):
    # print(i)
    f[i][0] = 2 * f[i - 1][0] + 3
    f[i][1] = 2 * f[i - 1][1] + 1
    # print(f[i][0], f[i][1])

"""
for i in range(0, N + 1):
    print(f[i][0], f[i][1])
"""

leftA = 0
leftB = 0

ans = 0

for i in range(N, 0, -1):
    if leftA + 1 == X:
        # finish
        ans = leftB
        break
    elif leftA + 1 + f[i-1][0] == X:
        # finish
        ans = leftB + f[i-1][1]
        break
    elif leftA + 1 + f[i-1][0] > X:
        leftA = leftA + 1
    elif leftA + 1 + f[i-1][0] + 1 == X:
        # finish
        ans = leftB + 1 + f[i-1][1]
        break
    elif leftA + 1 + f[i-1][0] + 1 + f[i-1][0] == X:
        # finish
        ans = leftB + 1 + 2 * f[i-1][1]
        break
    elif leftA + 1 + f[i-1][0] + 1 + f[i-1][0] > X:
        leftA = leftA + 1 + f[i-1][0] + 1
        leftB = leftB + 1 + f[i-1][1]
    elif leftA + 1 + f[i-1][0] + 1 + f[i-1][0] + 1 == X:
        # finish
        ans = leftB + 1 + 2 * f[i-1][1]
        break
    # print(leftA, leftB)

print(ans)

Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
	int N,x,y,z,i;
	long long total=0;
	scanf("%d",&N);
	for(x=1;x<=N;x++){
		for(y=x;y<=N;y++){
			for(z=y;z<=N;z++){
				for(i=x;;i--){
					if(x%i==0&&y%i==0&&z%i==0){
						if(x==y&&y==z){
							total+=i;
							break;
						}else if(x==y&&z!=x){
							total+=i*3;
							break;
						}else if(x!=y&&y==z){
							total+=i*3;
							break;
						}else{
							total+=i*6;
							break;
						}
					}
				}
			}
		}
	}
	printf("%lld",total);
	return 0;
}

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

int main(){
    int X, Y;
    cin >> X >> Y;

    if ( ( (Y - 2 * X) % 2 == 0) && (Y >= 2 * X) ){
        if ( ( (4 * X - Y) % 2 == 0) && (Y <= 4 * X) ){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n; cin>>n;
  vector<int> v1(n/2, 0);
  vector<int> v2(n/2, 0);
  int mv1=0,mv2=0;
  int max1=0,max2=0;
  vector<int> num1(1e5+10,0);
  vector<int> num2(1e5+10,0);
  for (int i=0; i<n/2; i++) {
    cin>>v1[i]>>v2[i];
  }
  for (int i=0; i<n/2; i++) {
    num1[v1[i]]++;
    if(max1 < num1[v1[i]]) {
      max1 = num1[v1[i]];
      mv1 = v1[i];
    }
    num2[v2[i]]++;
    if(max2 < num2[v2[i]]) {
      max2 = num2[v2[i]];
      mv2 = v2[i];
    }
  }
  sort(num1.begin(),num1.end(),greater<int>());
  sort(num2.begin(),num2.end(),greater<int>());

  if (mv1 != mv2) {
    cout << n - (num1[0] + num2[0]) << endl;
  } else {
    cout << n - max(num1[0]+num2[1], num1[1]+num2[0]) << endl;
  }
}

int main()
{
  solve();
  return 0;
}


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

using ll = long long;

struct RMQ {
	using type = int;
	static type id1() { return INT_MAX; }
	static type id2() { return -1; }
	static type op1(const type& l, const type & r) { return min(l, r); }
	static type op2(const type& l, const type & r) { return r != -1 ? r : l; }
};

template <typename T>
class node {
public:
	T val, lazy;
	node<T> *l, *r;
	node() {}
	node(T val_, T lazy_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) : val(val_), lazy(lazy_), l(l_), r(r_) {}
	void init(T val_, T lazy_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) {
		val = val_;
		lazy = lazy_;
		l = l_;
		r = r_;
	}
};

template <typename M>
class DynamicLazySegmentTree {
	using T = typename M::type;
	const ll n;
	node<T> *root;
	vector<node<T>> pool;
	int it;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node() {
		pool[it].init(M::id1(), M::id2());
		return &pool[it++];
	}
	node<T> *push(node<T> *t, ll lb, ll ub) {
		if (t == nullptr || t->lazy == M::id2()) return t;
		if (lb + 1 < ub) {
			if (t->l == nullptr) t->l = new_node();
			if (t->r == nullptr) t->r = new_node();
			t->l->lazy = M::op2(t->l->lazy, t->lazy);
			t->r->lazy = M::op2(t->r->lazy, t->lazy);
		}
		t->val = M::op2(t->val, t->lazy);
		t->lazy = M::id2();
		return t;
	}
	node<T> *suc(ll l, ll r, node<T> *t, ll lb, ll ub, T val) {
		if (ub <= l || r <= lb) return t;
		if (t == nullptr) t = new_node();
		if (l <= lb && ub <= r) {
			t->lazy = M::op2(t->lazy, val);
			return t;
		}
		t = push(t, lb, ub);
		int c = (lb + ub) / 2;
		t->l = suc(l, r, t->l, lb, c, val);
		t->r = suc(l, r, t->r, c, ub, val);
		t->val = M::op1(t->l == nullptr ? M::id1() : M::op2(t->l->val, t->l->lazy), t->r == nullptr ? M::id1() : M::op2(t->r->val, t->r->lazy));
		return t;
	}
	T sub(ll l, ll r, node<T> *t, ll lb, ll ub) {
		if (t == nullptr || ub <= l || r <= lb) return M::id1();
		t = push(t, lb, ub);
		if (l <= lb && ub <= r) return t->val;
		int c = (lb + ub) / 2;
		return M::op1(sub(l, r, t->l, lb, c), sub(l, r, t->r, c, ub));
	}
public:
	DynamicLazySegmentTree(ll n_, int PMAX = 1e7)
		: n(size(n_)), root(nullptr), pool(PMAX), it(0) {}
	void update(ll l, ll r, T val) {
		root = suc(l, r + 1, root, 0, n, val);
	}
	T find(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y, val;
	cin >> n >> q;
	DynamicLazySegmentTree<RMQ> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y));
		}
		else {
			cin >> val;
			st.update(x, y, val);
		}
	}
	return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

double dist(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);
    int fac[10] = {1};
    rep(i, 9) fac[i+1] = fac[i]*(i+1);

    int N; cin >> N;
    int keisuu = fac[N-1];
    double acc = 0.0;
    double X[N], Y[N]; rep(i, N) cin >> X[i] >> Y[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            acc += dist(X[i], Y[i], X[j], Y[j])*keisuu;
        }
    }
    printf("%.10f\n", acc/fac[N]);
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> left(m);
  vector<int> right(m);
  
  for(int i=0; i<m; i++){
    cin >> left.at(i) >> right.at(i);
  }
  
  sort(left.begin(), left.end());
  sort(right.begin(), right.end());
  reverse(left.begin(), left.end());
  
  int min,max;
  min = left.at(0);
  max = right.at(0);
  int answer = 0;
  
  if(min > max){
    answer = 0;
  }else{
    answer = max - min + 1;
  }
  
  cout << answer << endl;
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
   array<int, 3> v;
   for(int i=0; i < 3; i++){
      cin >> v[i];
   }
   sort(v.begin(), v.end());
   cout << 10*v[2] + v[1] + v[0] << endl;
   return 0;
}

Measured memory_bytes: 760
n = int(input())
z = []
for i in range(n):
    z.append(list(map(int, input().split())))
dp = [[0, 0, 0] for i in range(n)]
dp[0][0] = z[0][0]
dp[0][1] = z[0][1]
dp[0][2] = z[0][2]
for i in range(1, n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k]+z[i][j])
print(max(dp[n-1][0], dp[n-1][1], dp[n-1][2]))


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


long A, B, C;
long m = LONG_MAX;
long v;

int main(void) {
  cin >> A >> B >> C;

  v = A * B * (C % 2);
  if(v < m) m = v;

  v = A * (B % 2) * C;
  if(v < m) m = v;

  v = (A % 2) * B * C;
  if(v < m) m = v;

  cout << m << endl;

  return 0;
}


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

int main(){
  string S;
  cin >> S;
  int ans = 0;
  for(int i = 0; i < S.size(); i++){
    int a = 0;
    for(int j = i; j < S.size(); j++){
      if((S[j] != 'A') && (S[j] != 'T') && (S[j] != 'G') && (S[j] != 'C')) break;
      a++;
    }
    ans = max(ans, a);
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
  char alfa[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

  int n;
  string str;
  cin >> n;
  cin >> str;
  for(int i = 0; i < str.size(); i++)
  {
    for(int j = 0; j < 26; j++)
    {
      if(str[i] == alfa[j])
      {
        str[i] = alfa[(j + n) % 26];
        break;
      }
    }  
  }
  cout << str << endl;
  return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL cnt[10000005];

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

    LL N;
    cin >> N;

    LL res = 0;
    for(LL i = 1; i <= N; ++i) {
        for(LL j = i; j <= N; j += i) {
            cnt[j]++;
        }
        res += i * cnt[i];
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 81736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    int ha, ma, hb, mb, k;
    cin(ha); cin(ma); cin(hb); cin(mb); cin(k);

    print(60 * (hb - ha) + mb - ma - k);
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	vector<int>could;
	int bef=0;
	int c=0;
	int n;
	cin >> n;
	while(bef<n){
		c++;
		bef+=c;
		could.push_back(bef);
	}
	vector<vector<int>>ans(c+1);
	if(bef==n){
		cout<<"Yes"<<endl;
		int at=1;
		for(int a=0;a<c;a++){
			for(int ac=a+1;ac<=c;ac++){
			//	clog<<a<<" + "<<at<<endl;
			//	clog<<ac<<" + "<<at<<endl;
				ans[a].push_back(at);
				ans[ac].push_back(at);
				at++;
			}
		}
		cout<<c+1<<endl;
	for(int i=0;i<=c;i++){
		cout<<ans[i].size()<<" ";
		for(int j=0;j<ans[i].size();j++){
			cout<<ans[i][j];
			if(j!=ans[i].size()-1){
				cout<<" ";
			}else{
				cout<<endl;
			}
		}
	}

	}else{
	printf("No\n");
	}
}
/*
1 ... 1, 1
2...  no
3.. 1,2  2,3  1,3
4..  1,2 2,3 3,1  -no
5...  1,2,3,4,5 1,2,3,4,5  1,2,3,4,5
6.. 1,2,3,  1,4,5  2,4,6   3,5,6
10... 1,2,3,4  1,5,6,7  2,5,8,9  3,6,8,10  4,7,9,10
n... allsub . 2n
and. 1 
n(n-1)/2=n
n^2/2 -n/2=n
n^2/2 -3n/2=0
n^2 -3n=0
n(n-3)=0

1,2,3  3,4,5  4,6,7 
*/

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


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		int[] over = new int[n];
		int[] under = new int[n];
		
		int[][] DP= new int[n][];
		for(int i = 0; i < n; i++){
			DP[i] = new int[n - i];
			Arrays.fill(DP[i], Integer.MAX_VALUE);
		}
		
		for(int i = 0; i < n; i++){
			over[i] = sc.nextInt();
			under[i] = sc.nextInt();
			DP[0][i] = 0;
		}
		
		for(int i = 1; i < n; i++){
			for(int j = 0; j < n - i; j++){
				for(int k = 0; k < i; k++){
					final int left_range = k;
					final int left_start = j;
					final int left_end = j + k;
					final int right_range = i - k - 1;
					final int right_start = j + k + 1;
					final int right_end = j + i;
					
					final int cost = DP[left_range][left_start] + DP[right_range][right_start] + 
							over[left_start] * under[left_end] * over[right_start] * under[right_end];
					
					DP[i][j] = Math.min(DP[i][j], cost);
				}
			}
		}
		
			
			
		System.out.println(DP[n-1][0]);
	}

}

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

int main(){
  int N;
  cin >>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  
  int ans=0;
  for(int i=1;i<=N;i++){
    if(i%2==1){
      if(vec[i-1]%2==1){
        ans++;
      }
    }
  }
  cout << ans <<endl;
}

  

Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>

using namespace std;

#define ll long long
#define f0(i,n)for(i=0;i<n;i++)
#define f1(i,n)for(i=1;i<=n;i++)
#define fc(i,c,n)for(i=c;i<=n;i++)
#define f0r(i,n)for(i=n-1;i>=0;i--)
#define f1r(i,n)for(i=n;i>0;i--)
#define fcr(i,c,n)for(i=n;i>=c;i--)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

ll i, j, q;
ll n, m, p, k, t, s, v;
ll a, b, c, d;
ll x, y, z, l, r;
ll one = 1, zero = 0, ans = 0;
ll mod = 1000000007;
ll INF = 9223372036854775807;
ll a1, a2, a3, a4;
string st1, st2, st3;
char ch1, ch2, ch3;

int main() {
	ifstream fin("Text.txt");
	
	cin >> n;
	VEC v1(n), v2(n);
	f0(i, n) 
		cin >> v1[i];
	if (v1[0]) {
		cout << -1 << endl;
		return 0;
	}
	j = n - 1;
	i = 0;
	while (j - i >= 0) {
		if (v1[j - i] + i == v1[j]) {
			i++;
		}
		else if (v1[j - i] + i < v1[j]) {
			cout << -1 << endl;
			return 0;
		}
		else {
			ans += v1[j];
			j -= i;
			i = 0;
		}
	}
	ans += max(zero, i - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
using System;

class Atcoder129
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int x = int.Parse(input[0]);
        int a = int.Parse(input[1]);

        if (x < a)
            Console.WriteLine(0);
        else
            Console.WriteLine(10);
    }
}

Measured memory_bytes: 11092
using System;

namespace AtCoderABC134C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int index = 0;
            int first = 0;
            int second = 0;

            for (int i = 0; i < N; i++)
            {
                int A = int.Parse(Console.ReadLine());

                if(A >= first)
                {
                    second = first;
                    first = A;
                    index = i;
                }
                else if(A>= second)
                {
                    second = A;
                }
            }

            for(int i=0;i<N;i++)
            {
                if (i == index)
                    Console.WriteLine(second.ToString());
                else
                    Console.WriteLine(first.ToString());
            }
        }
    }
}


Measured memory_bytes: 16576
while True:
      n,k=map(int,input().split())
      if n ==0 and k==0:
            break
      a=[int(input()) for _ in range(n)]
      s=sum(a[0:k])
      ss=[s]
      for i in range(k,n):
            s=s+a[i]-a[i-k]
            ss.append(s)
      print(max(ss))


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

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

}



Measured memory_bytes: 256