akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int H, W;
  cin >> H >> W;
  string S[H];
  REP(i, H) cin >> S[i];

  bool seen[H][W];
  REP(i, H) REP(j, W) seen[i][j] = false;
  queue<pair<int, int>> todo;

  int dx[4] = {1,0,-1,0};
  int dy[4] = {0,1,0,-1};
  long long ans = 0;
  REP(i, H) REP(j, W) if (seen[i][j] == false) {
    // cout << i << ' ' << j << endl;
    long long cnt[] = {0, 0};
    seen[i][j] = true;
    todo.push(make_pair(i, j));
    while (todo.size() > 0) {
      pair<int, int> here = todo.front(); todo.pop();
      // cout << here.first << endl;
      if (S[here.first][here.second] == '#') cnt[0]++;
      else cnt[1]++;
      REP(k, 4) {
        if (0 <= here.first+dy[k] && here.first+dy[k] < H && 0 <= here.second+dx[k] && here.second+dx[k] < W && S[here.first][here.second] != S[here.first+dy[k]][here.second+dx[k]] && seen[here.first+dy[k]][here.second+dx[k]] == false) {
          seen[here.first+dy[k]][here.second+dx[k]] = true;
          todo.push(make_pair(here.first+dy[k], here.second+dx[k]));
        }
      }
    }
  ans += cnt[0] * cnt[1];
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int alice = sc.nextInt(), bob = sc.nextInt();
	if(alice == 1 && bob != 1)
	    System.out.println("Alice");
	else if(bob  == 1 && alice != 1)
	    System.out.println("Bob");
	else if(alice < bob)
	    System.out.println("Bob");
	else if(alice > bob)
	    System.out.println("Alice");
	else
	    System.out.println("Draw");
    }

}


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

int n, m;
string s;

signed main(){
  
  cin>>n>>m;
  
  cin>>s;
  
  reverse(s.begin(),s.end());
  
  int cnt = 0;
  int maxcnt = 0;
  int maxi = 0;
  vector<int> ans;
  
  for(int i=1;i<(int)s.size();i++){
    
    cnt++;
    
    if( s[i] == '0' ){
      maxcnt = cnt;
      maxi = i;
    }
    
    if( cnt == m || i == (int)s.size()-1 ){
      
      if( maxcnt == 0 ){
	cout<<-1<<endl;
	return 0;
      }
      
      ans.push_back( maxcnt );
      
      cnt = maxcnt = i - maxi;
      
      if( cnt == m ){
	cout<<-1<<endl;
	return 0;
      }
      
    }
    
  }
  
  reverse(ans.begin(),ans.end());
  
  for(int i=0;i<(int)ans.size();i++){
    if(i) cout<<' ';
    cout<<ans[i];
  }
  
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 1528
from sys import stdin
import numpy as np
N=int(stdin.readline().rstrip())
A=[x for x in input()]
B=[x for x in input()]
C=[x for x in input()]
arr=[A,B,C]
arr=np.array(arr)
ans=0
cnt=0
for i in range(N):
    if len(set(arr[:,i]))==3:
        ans+=3
        cnt+=1
    else:
        if len(set(arr[:,i])) != 1:
            ans+=(3-len(set(arr[:,i])))
print(ans-cnt)

Measured memory_bytes: 12408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int i=0;
  bool p=false;
  while(7*i<=n){
    if((n-7*i)%4==0){
      p=true;
    }
    i++;
  }
  if(p) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int maxn = 3005;
double a[maxn], dp[2][maxn];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    REP(i, n) cin >> a[i + 1];
    dp[0][0] = 1;
    int prev = 0;
    REPP(i, 1, n + 1) {
        REPP(j, 0, i + 1) {
            dp[prev ^ 1][j] = 0;
            if (j > 0) dp[prev ^ 1][j] += dp[prev][j - 1] * a[i];
            dp[prev ^ 1][j] += dp[prev][j] * (1 - a[i]);
        }
        prev ^= 1;
    }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++) ans += dp[1][i];
    printf("%.10f\n", ans);
    return 0;
}


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

int main(){

    int N, K;
    cin >> N >> K;
    vector<int> h(N, 0);
    for(int i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    sort(h.begin(), h.end());
    
    int mn = 1000000000;
    int len;
    for(int i = 0; i < N-K+1; i++)
    {
        len = h[i+K-1] - h[i];
        if (len < mn) {
            mn = len;
        }
        
    }
    
    cout << mn << endl;

    return 0;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	vector<int> a, b;
	int ans1 = 0, ans2 = 0;
	int N, M;
	
	cin>>N>>M;
	
	a.resize(N+2);
	b.resize(N+2);
	
	for(int i = 0; i < M; i++){
		string S;
		int p;
		
		cin>>p>>S;
		
		if(a[p] == false) {
			if(S == "AC") {
				ans2 += b[p];
				ans1++;
				a[p] = true;
			} else {
				b[p]++;
			}
		}
	}
	
	cout<<ans1<<" "<<ans2<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

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


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

int main(){
    int n;
    cin>>n;
    int m;
    cin>>m;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> queA;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        queA.push({a,b});
    }
    int res=0;
    priority_queue<int,vector<int>,greater<>> queB;
    for(int i=0;i<n;i++){
        if(!queB.empty()){
            if(queB.top()==i){
                while(!queB.empty()){
                    queB.pop();
                }
                res++;
            }
        }
        while(!queA.empty()){
            auto ret=queA.top();
            if(ret.first==i){
                queB.push(ret.second);
                queA.pop();
            }
            else{
                break;
            }
        }
            }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

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

	cout << s / 60 / 60 << ":" << s / 60 % 60 << ":" << s % 60 << endl;
}

Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int max, max_x, max_y, cur_x, cur_y, x, y, n;
	
	cin >> n;
	
	for(int loop = 0; loop < n; loop++){
		max = 0;
		cur_x = 0;
		cur_y = 0;
		max_x = 0;
		max_y = 0;
		while(true){
			cin >> x >> y;
			if(x == 0 && y == 0){
				break;
			}
			cur_x += x;
			cur_y += y;
			if(max < (cur_x * cur_x) + (cur_y * cur_y)){
				max = (cur_x * cur_x) + (cur_y * cur_y);
				max_x = cur_x;
				max_y = cur_y;
			}else if(max == (cur_x * cur_x) + (cur_y * cur_y) && cur_x > max_x){
				max = (cur_x * cur_x) + (cur_y * cur_y);
				max_x = cur_x;
				max_y = cur_y;
			}
		}
		printf("%d %d\n", max_x, max_y);
	}
	
	
	return 0;
}

Measured memory_bytes: 1148
<?php
$sc = new Scanner();

$mochi_num = $sc->nextInt();

$num_arr = array();
for ($i = 0; $mochi_num > $i; $i++) {
    array_push($num_arr, $sc->nextInt());
}

rsort($num_arr);

$dan = 1;
foreach ($num_arr as $k => $v) {
    if (($k + 1) >= count($num_arr)) {
        break;
    }
    if ($num_arr[$k] > $num_arr[$k + 1]) {
        $dan++;
    }
}

out::println($dan);

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function println($str = "")
    {
        echo $str . PHP_EOL;
    }
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
ll dp[105][100005];
int main()
{
	ll i,n,W,j;
	cin>>n>>W;
	ll v[n],wt[n];
	for(i=0;i<n;i++)
		cin>>wt[i]>>v[i];
	for(i=0;i<=100;i++)
		for(j=0;j<=100000;j++)
			dp[i][j] = 10000000000000;
	dp[0][0] = 0;
	dp[0][v[0]] = wt[0];
	for(i = 1; i < n; i++) 
   	{
   		for(j=0;j<100004;j++)
   		{
   			if(j-v[i] >= 0)
   				dp[i][j] = min(dp[i-1][j-v[i]]+wt[i],dp[i-1][j]);
   			else
   				dp[i][j] = dp[i-1][j];
   		}
   	}
   	for(i=100005;i>=0;i--)
   		if(dp[n-1][i]<=W && dp[n-1][i] != 0)
   		{
   			cout<<i<<endl;
   			return 0;
   		}
   	cout<<0<<endl;
   	return 0;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<endl
#define f first
#define s second
#define endl '\n'
#define sq(x) (x)*(x)*1ll
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;


ll weight[100], value[100], dp[100005];
int main () {
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("test_input.txt", "r", stdin);
        int n, w; cin >> n >> w;
        for (int i = 0; i < n; i++) {
                cin >> weight[i] >> value[i];
        }

        for (int i = 0; i < n; i++) {
                for (int j = w; j >= weight[i]; j--){
                        dp[j] = max(dp[j], dp[j - weight[i]] + value[i]);
                }
        }

        cout << dp[w];
        return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int a,b,c;cin>>a>>b>>c;
  bool flag=true;
  if(c-a-b<=0){
    flag=false;
  }
  else{
    flag=4*a*b<(c-a-b)*(c-a-b);
  }
  if(flag){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
words = "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 ".split()

def calcMax(current, i):
    maxC = -1
    for c in range(N):
        if(c != N - i):
            maxC = max(maxC, current[c])
    return maxC

def seek(current):
    for i in range(1, N):
        if(current[-i] <= max(current[:-i])):
            current[-i] += 1
            for j in range(i-1):
                current[N-1-j] = 0
            return True, current
    return False, current

def convert(ans):
    ansStr = ""
    for a in ans:
        ansStr += words[a]
    return ansStr

N = int(input())

ans = [0] * N

print(convert(ans))
flag, ans = seek(ans)
while(flag == True):
    print(convert(ans))
    flag, ans = seek(ans)

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

///#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,avx,sse4.1,sse4.2,mmx")
///#pragma GCC optimize ("unroll-loops")
///#pragma GCC optimize ("Ofast")
///#pragma GCC optimize ("O3")

using namespace std;

#define int long long
#define ff first
#define ss second
#define db double
#define ld long double
#define pb push_back

const int N = 1e6 + 5, M = 1e3 + 5;
const int inf = 1e9 + 100, mod = 1e9 + 7;
const ld eps = 1e-9, pi = atan2(0, -1);

mt19937_64 mt_rnd_64(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r){
    return mt_rnd_64() % (r - l + 1) + l;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    cin >> s >> t;

    int cnt = 0;
    for (int i = 0; i < s.length(); ++i)
        cnt += s[i] != t[i];

    cout << cnt << '\n';
    return 0;
}
/// hto ya? zvychayna domohospodarka chy president Ykrainy?


Measured memory_bytes: 3864
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        // programming
        int n = Util.getInputInteger(sc);
        int t = Util.getInputInteger(sc);
        int a = Util.getInputInteger(sc);
        int min_diff = Integer.MAX_VALUE;
        int min_index = -1;
        for (int i = 0; i < n; i++) {
            int h = Util.getInputInteger(sc);
            int temp = 1000 * t - h * 6;
            int diff = Math.abs(1000 * a - temp);
            if (diff < min_diff) {
                min_index = i + 1;
                min_diff = diff;
            }
        }

        Util.output(String.valueOf(min_index));
	}
}

// =========common=========
class Util {
	public static String getInputString(Scanner sc) {
		return sc.next();
	}

	public static int getInputInteger(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	public static void output(String... params) {
		boolean isInit = true;
		String str = "";
		for (String s : params) {
			if (!isInit) {
				str += " ";
			}
			str += s;
			isInit = false;
		}
		System.out.println(str);
	}

    public static int[] toIntegerList(String[] ss) {
        return Stream.of(ss).mapToInt(Integer::parseInt).toArray();
    }

    public static String[] toList(String s) {
        String[] ret = s.split("");
        return ret;
    }

    public static int sum(int[] vals) {
        int sum = 0;
        for (int val : vals) {
            sum += val;
        }
        return sum;
    }

    public static int[] sort(int[] vals, boolean isAsc) {
        Arrays.sort(vals);
		if (isAsc) {
			return vals;
		}
        int[] ret = new int[vals.length];
        for (int i = 0; i < vals.length; i++) {
            ret[vals.length - i - 1] = vals[i];
        }
		return ret;
	}

    public static void gc() {
        System.gc();
    }
}

Measured memory_bytes: 22356
from fractions import gcd
from functools import reduce

if __name__ == "__main__":
    N, X = map(int, input().split())
    L = list(map(int, input().split()))
    L.append(X)
    D = [abs(x2 - x1) for x1, x2 in zip(L, L[1::])]
    print(reduce(gcd, D))

Measured memory_bytes: 16280
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	long long int s;
	cin >> s;
	COMinit();
	long long int ans = 0;
	if (s % 3 == 0) {
		ans++;
	}
	for (long long int i = 1; i <= s / 3; i++) {
		long long int nokori = s - 3 * i;
		long long int sum = 0;
		for (int j = 0; j <= s / 3 - 1; j++) {
			if (j >= nokori) {
				break;
			}
			long long int c = COM(nokori - 1, j) % MOD;
			//cout << c << endl;
			long long int d = COM(i, j + 1) % MOD;
			//cout << d << endl;
			sum = (c * d) % MOD + sum;
			sum = sum % MOD;
			//cout << sum << endl;
		}
		//cout << sum << endl;
		ans = ans + sum;
		ans = ans % MOD;
		//cout << endl;
	}
	cout << ans;
}

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

#define forn(i,m,n) for(ll i=m;i<n;i++)
#define vv vector
#define vi vv<int>
#define ii pair<int,int>
#define vii vv<ii>
#define mp make_pair
#define pb push_back
#define PI 3.141592653589
#define ll long long
#define pll pair<ll,ll>
#define vl vv<ll>
#define ff first
#define ss second
#define MOD 1000000007

bool is_prime[1000001];
vi prime;
void sieve(int n)
{
    memset(is_prime,true,sizeof(is_prime));
    for(int i=2;i*i<=n;i++)
    {
        if(is_prime[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {
                is_prime[j]=false;
            }
        }
    }
    forn(i,2,n+1)
    {
        if(is_prime[i])
            prime.pb(i);
    }
}


ll ex(ll a,ll b)
{
    ll res=1;
    a=a%MOD;
    while(b)
    {
        if(b%2){res=(res*a)%MOD;b--;}
        b/=2;
        a=(a*a)%MOD;
    }
    return res;
}

ll fermat_inv(ll a){ return ex(a,MOD-2); }
ll max(ll a,ll b){ return a>b?a:b; }
ll min(ll a,ll b){ return a<b?a:b; }


int main()
{
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        #endif
    //sieve(1000000);
    int te=1;
    //cin>>te;
    while(te--)
    {
        ll n,k;
        cin>>n>>k;
        ll a[n];
        forn(i,0,n)
            cin>>a[i];
        ll dp[n+1][k+1];
        forn(i,0,k+1)
            dp[0][i]=0;
        dp[0][0]=1;
        forn(i,1,n+1)
        {
            for(ll j=k;j>=0;j--)
            {
                if(j==k)
                    dp[i][j]=0;
                else
                    dp[i][j]=dp[i][j+1];
                dp[i][j]+=dp[i-1][j-min(a[i-1],j)];
                if(j!=k)
                    dp[i][j]-=dp[i-1][j+1];
                dp[i][j]=(dp[i][j]+MOD)%MOD;
            }
        }
        cout<<dp[n][k];        
    }
}


Measured memory_bytes: 82440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;


struct Edge{
    int to, cost;
    Edge(int to, int cost):to(to),cost(cost){}
};

int n;
vector<vector<Edge>> G;
vector<int> res;

void dfs(int v, int p, int c){
    res[v] = c;
    for(auto e : G[v]){
        if(e.to == p)continue;
        if(e.cost & 1) dfs(e.to, v, 1-c);
        else dfs(e.to, v, c);
    }
}


int main(){
    cin >> n;
    G.assign(n, vector<Edge>());
    for(int i = 0; i < n-1; i++){
        int u, v, w; cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v,w));
        G[v].push_back(Edge(u,w));
    }
    res.assign(n, 0);
    dfs(0, -1, 1);
    for(auto v : res){
        cout << v << endl;
    }
}

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

int main()
{
    long long int n,ans,tmp;
    cin >> n;
    vector<long long int> peo;
    for(int i =0; i < 5; i++){
        cin >> tmp;
        peo.push_back(tmp);
    }
    sort(peo.begin(), peo.end());
    long long int x =peo[0];
    ans = (n-1) / x;
    cout << ans + 5 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,a,b,c,d,count;
	while(scanf("%d", &n) != EOF){
		count = 0;
	for(a = 0; a <= 9; a++){
		for(b = 0; b <= 9; b++){
			for(c = 0; c <= 9; c++){
				for(d = 0; d <= 9; d++){
					if(a + b + c + d == n){
						count++;
					}
				}
			}
		}
	}
	printf("%d\n", count);
	}
	return 0;
}

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

typedef long long int ll;

int main(){
   int N;
   cin >> N;
   vector<int> S(N);
   int sum = 0;
   for(int i = 0;i < N;i++){
      cin >> S[i];
      sum += S[i];
   }
   sort(S.begin(),S.end());
   int ans = 0;
   if(sum % 10 != 0){
      cout << sum << endl;
      return 0;
   }
   for(int i = 0;i < N;i++){
      int a = sum - S[i];
      if(a % 10 != 0){
         ans = max(ans,a);
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef tuple<int,int, int> P;

// // stackの無駄使い。stack<char>ではなくstack<int>にしてindexを保存
// int main(){
//     string s;
//     cin >> s;
//     stack<char> t;
//     ll ans=0;
//     vector<ll> pools;
//     rep(i,s.size()){
//         if(s[i] == '\\')t.push(s[i]);
//         else if(s[i]=='_' && t.size()!=0)t.push(s[i]);
//         else if(s[i]=='_' && t.size()==0)continue;
//         else{
//             if(t.size()==0)continue;
//             stack<char> w;
//             ll p;
//             while(t.top()!='\\'){
//                 t.pop();
//                 char x = '_';
//                 w.push(x);
//             }
//             t.pop();
//             ans+=1+w.size();
//             p += 1+w.size();
//             w.push('_');
//             w.push('_');
//             if(t.size()!=0){
//                 while(w.size()!=0){
//                     char x = w.top();w.pop();
//                     t.push(x);
//                 }
//             }else{
//                 pools.push_back(p);
//                 p = 0;
//             }
//         }
//     }  
//     cout << ans << endl;
//     rep(i,pools.size()){
//         if(i==0)cout << pools.size();
//         cout << " " << pools[i];
//     }
//     cout << endl;
//     return 0;
// }

int main(){
    string s;
    stack<int> s1;
    stack<P> s2;
    ll tot=0;
    vector<ll> ans;
    cin >> s;
    rep(i,s.size()){
        if(s[i]=='\\')s1.push(i);
        else if(s[i]=='/'&&s1.size()>0){
            int x = s1.top();s1.pop();
            int sq = i-x;
            tot += sq;
            // while(x < get<0>(s2.top()) && get<1>(s2.top()) < x && s2.size()>0){
            while(s2.size()>0 && x < get<0>(s2.top())){
                sq+= get<2>(s2.top());
                s2.pop();
            }
            s2.push(make_tuple(x,i,sq));
        }
        else continue;
    }
    cout << tot <<endl;
    cout << s2.size();
    while(s2.size()>0){
        P tp = s2.top();s2.pop();
        ans.push_back(get<2>(tp));
    };
    reverse(ans.begin(),ans.end());
    rep(i,ans.size())cout << " " << ans[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3292
n,m = map(int,input().split())
N = min(n,m)
M = max(n,m)
if N>=3:
    print((N-2)*(M-2))
if N==2:
    print(0)
if N==1:
    if M == 1:
        print(1)
    else:
        print(M-2)

Measured memory_bytes: 3060
/*
  Fuad Ashraful Mehmet Islam
  University of Asia Pacific,Bangladesh
  Date:2nd May 2020
  ToDo:
  https://codeforces.com/problemset/problem/287/B
 */
#include<bits/stdc++.h>
#define dbg(x) cerr <<__LINE__<<" where "<< #x << " = " << x << endl
#define all(x) (x).begin(),(x).end()

using namespace std;
template <class T>
inline void read(T &res)
{
  res = 0; bool bo = 0; char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-');
  if (c == '-') bo = 1; else res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  if (bo) res = ~res + 1;
}
const int N=1e5+5;
typedef long long ll;
int len,_,n,d,k,m,l,c,cs=1;

ll mx=1e18+9;
vector<ll>v1,v2;
void Solve()
{
  
  for(ll i=0;i*i*i*i*i<=mx;++i)
  {
	ll temp=i*i*i*i*i;
	v1.push_back(temp);
	v2.push_back(-temp);
  }

  ll x;
  read(x);

  for(int i=0;i<v1.size();++i)
  {
	for(int j=0;j<v1.size();++j)
	{
		if(v1[i]-v1[j]==x)
		{
			cout<<i<<" "<<j<<endl;
			return;
		}	
	}
  }

  for(int i=0;i<v1.size();++i)
  {
	for(int j=0;j<v2.size();++j)
	{
		if(v1[i]-v2[j]==x)
		{
			cout<<i<<" -"<<j<<endl;
			return;
		}	
	}
  }
  
 // cout<<v1.size()<<" -- "<<v2.size()<<"\n";
} /// end func
int main()
{
 // for(read(_);_;_--)
  Solve();
  return 0;
}

Measured memory_bytes: 3716
n = int(input())
ary = list(map(int, input().split()))
for i in range(n - 1):
  tmp_ary = list(map(int, input().split()))
  t_rate = (ary[0] - 1) // tmp_ary[0] + 1
  a_rate = (ary[1] - 1) // tmp_ary[1] + 1
  rate = max([t_rate, a_rate])
  ary = list(map(lambda x: x * rate, tmp_ary))
print(int(ary[0] + ary[1]))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vvl dat;
ll solve(ll x, ll y, ll z){
  sort(all(dat), [](vll a, vll b){
    return a[2]-a[1] < b[2]-b[1];
  });//1適性->2適性

  vll L(x+1, 0), R(x+1, 0);
  multimap<ll, vll> lef; //1適性が低い順
  multimap<ll, vll> ri; // 2適性が低い順

  for(int i=0;i<y;i++){
    ll sa = dat[i][1] - dat[i][0]; //1適性
    lef.emplace(sa, vll{dat[i][0], dat[i][1]});
    L[0] += dat[i][1];
  }
  for(int i=x+y;i<x+y+z;i++){
    ll sa = dat[i][2] - dat[i][0]; //2適性
    ri.emplace(sa, vll{dat[i][0], dat[i][2]});
    R[0] += dat[i][2];
  }

  for(int i=1;i<=x;i++){
    ll idx = y-1+i;
    ll sa = dat[idx][1] - dat[idx][0];
    auto itr = lef.begin();
    if((*itr).first > sa) L[i] = L[i-1] + dat[idx][0];
    else{
      L[i] = L[i-1] - (*itr).second[1] + (*itr).second[0] + dat[idx][1];
      lef.erase(itr);
      lef.emplace(sa, vll{dat[idx][0], dat[idx][1]});
    }
  }
  for(int i=1;i<=x;i++){
    ll idx = x+y-i;
    ll sa  = dat[idx][2] - dat[idx][0];
    auto itr = ri.begin();
    if((*itr).first > sa) R[i] = R[i-1] + dat[idx][0];
    else{
      R[i] = R[i-1] - (*itr).second[1] + (*itr).second[0] + dat[idx][2];
      ri.erase(itr);
      ri.emplace(sa, vll{dat[idx][0], dat[idx][2]});
    }
  }
  ll ans = 0;
  for(int i=0;i<=x;i++) ans = max(ans, L[i] + R[x-i]);
  return ans;
}


int main(int argc, char const *argv[]) {
  ll x, y, z;std::cin >> x >> y >> z;
  dat = VV(x+y+z, 3, 0, ll);
  re(i, x+y+z) scanf("%lld %lld %lld", &dat[i][0], &dat[i][1], &dat[i][2]);
  std::cout << solve(x, y, z) << '\n';
}


Measured memory_bytes: 16640
#include <iostream>
#include <queue>
#include <string>
using namespace std;

int n;

int s2i(string str){
	int sum = 0;
	int pos;
	pos = str.find("m");
	if(pos>=0){
		if(pos-1>=0 && str[pos-1]>'0' && str[pos-1]<='9'){
			sum += ((int)(str[pos-1]-'0'))*1000;
		}else{
			sum += 1000;
		}
	}
	pos = str.find("c");
	if(pos>=0){
		if(pos-1>=0 && str[pos-1]>'0' && str[pos-1]<='9'){
			sum += ((int)(str[pos-1]-'0'))*100;
		}else{
			sum += 100;
		}
	}
	pos = str.find("x");
	if(pos>=0){
		if(pos-1>=0 && str[pos-1]>'0' && str[pos-1]<='9'){
			sum += ((int)(str[pos-1]-'0'))*10;
		}else{
			sum += 10;
		}
	}
	pos = str.find("i");
	if(pos>=0){
		if(pos-1>=0 && str[pos-1]>'0' && str[pos-1]<='9'){
			sum += ((int)(str[pos-1]-'0'));
		}else{
			sum += 1;
		}
	}
	return sum;
}

string i2s(int sum){
	string str = "";
	int di;
	di = sum / 1000;
	if(di>0){
		if(di>1){
			str.push_back(di+'0');
		}
		str.push_back('m');
	}
	di = (sum%1000)/100;
	if(di>0){
		if(di>1){
			str.push_back(di+'0');
		}
		str.push_back('c');
	}
	di = (sum%100)/10;
	if(di>0){
		if(di>1){
			str.push_back(di+'0');
		}
		str.push_back('x');
	}
	di = (sum%10);
	if(di>0){
		if(di>1){
			str.push_back(di+'0');
		}
		str.push_back('i');
	}
	return str;
}

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		string str1,str2;
		cin >> str1 >> str2;
		cout << i2s( s2i(str1) + s2i(str2) ) << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
class Solution:
    def solve(self, S: str) -> str:

        if S == 'AAA' or S == 'BBB':
            return 'No'
        else:
            return 'Yes'


if __name__ == '__main__':

    # standard input
    S = input()

    # solve
    solution = Solution()
    print(solution.solve(S))


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 1e6 + 1100,inf = 1e9;
int n,mx,a[N],val[N],sum[N];
char s[N];
struct node
{
	int tr[N << 2];
	void build(int k,int l,int r)
	{
		if(l == r) {tr[k] = -inf; return;}
		int mid = (l + r) >> 1;
		build(k << 1,l,mid); build(k << 1 | 1,mid + 1,r);
		tr[k] = max(tr[k << 1],tr[k << 1 | 1]);
	}
	void change(int k,int l,int r,int pos,int v)
	{
		if(l == r) {tr[k] = v; return;}
		int mid = (l + r) >> 1;
		if(pos <= mid) change(k << 1,l,mid,pos,v);
		else change(k << 1 | 1,mid + 1,r,pos,v);
		tr[k] = max(tr[k << 1],tr[k << 1 | 1]);
	}
	int ask(int k,int l,int r,int x,int y)
	{
		if(x <= l && y >= r) return tr[k];
		int mid = (l + r) >> 1,res = -inf;
		if(x <= mid) res = max(res,ask(k << 1,l,mid,x,y));
		if(y > mid)  res = max(res,ask(k << 1 | 1,mid + 1,r,x,y));
		return res;
	}
}Odd,Even;
int check(int mx,int Q)
{
	if(Q < 0) return 0;
	if(Q & 1) return Odd.ask(1,1,n,mx,n) >= Q;
	return Even.ask(1,1,n,mx,n) >= Q;
}
int main()
{
	n = read();
	for(int i = 1;i <= n;i ++)
	{
		a[i] = read();
		if(mx < a[i]) val[i] = 2,mx = a[i];
		else val[i] = 1;
	}
	Odd.build(1,1,n);
	for(int i = n,mx0,mx1;i >= 1;i --)
	{
		mx1 = Odd.ask(1,1,n,a[i],n); mx0 = Even.ask(1,1,n,a[i],n);
		if(val[i] & 1) Odd.change(1,1,n,a[i],mx0 + val[i]),Even.change(1,1,n,a[i],mx1 + val[i]);
		else Odd.change(1,1,n,a[i],mx1 + val[i]),Even.change(1,1,n,a[i],mx0 + val[i]);
	}
	for(int i = n;i >= 1;i --) sum[i] = sum[i + 1] + val[i] - 1;
	int cntx = 0,cnty = 0,mxx = 0,mxy = 0;
	for(int i = 1;i <= n;i ++)
	{
		Odd.change(1,1,n,a[i],-inf); Even.change(1,1,n,a[i],0);
		if(check(mxy,cntx + sum[i + 1] - cnty + (a[i] > mxx))) s[i] = '0',cntx += a[i] > mxx,mxx = max(mxx,a[i]);
		else if(check(max(mxx,a[i]),cnty + sum[i + 1] - cntx - (a[i] > mxx))) s[i] = '0',cntx += a[i] > mxx,mxx = max(mxx,a[i]);
		else s[i] = '1',cnty += a[i] > mxy,mxy = max(mxy,a[i]);
	}
	if(cntx != cnty) cout << "-1";
	else printf("%s",s + 1);
	fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 18816
import java.util.Scanner;

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

		char[] a = sc.next().toCharArray();
		char[] b = sc.next().toCharArray();
		int n = b.length;
		for (int i = 0; i < n; i++) {
			System.out.print(a[i] + "" + b[i]);
		}
		if (a.length > b.length) {
			System.out.println(a[a.length - 1]);
		} else {
			System.out.println();
		}
	}

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


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


long long int comb(long long int n,long long int r){
        long long int num = 1;
        for(int i = 1; i <= r; i++){
            num = num * (n - i + 1) / i;
        }
        return num;
    }

int main() {
  int n;
  cin >> n;
  int num[200010];//各数字の個数をカウントするための配列変数
  long long int rate[200010]; //各数字から2つの数字を抜き出す時の通り数を収納する配列変数
  long long int new_rate[200010];//各数字から1つだけ数字を取り除き2つの数字を抜き出す時の通り数を収納する配列変数
  int A[n]; //問題で与えられる数字を収納する配列変数
  long long int sum=0; //rate[n]の合計値
  long long int ans=0; //最終的に出力する値

  //最初にnum[n]で各数字の個数をカウントしながらA[n]に値を入れていく
  for(int i=0;i<n;i++){
      cin >> A[i];
      num[A[i]]++;
  }
  //次にnum[n]に入った数字の個数から計算される通り数をrate,new_rateに収納する；
  for(int j=1;j<200010;j++){
      long long int test1 = 0;
      long long int test2 = 0;
      test1 = comb(num[j],2);
      test2 = comb(num[j]-1,2); //num[j]==0だとエラーが発生するため、nの最低値は0にする
      ans += test1; //ansを計算
      rate[j] = test1;
      new_rate[j] = test2; 
  }
  //答えを出力する
  for(int k=0;k<n;k++){
      cout << ans - rate[A[k]] + new_rate[A[k]] << endl;
  }  
}

Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <stdio.h>
#include <queue>
#define ll long long
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rep1(i,a) for(ll i = 1;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;

//O(logB)
ll mpow(ll a, ll b, ll m){
	if (!b) return 1 % m;
	if (b == 1) return a % m;
	if (b % 2) return (a*mpow(a, b - 1, m)) % m;
	else return mpow((a*a) % m, b / 2, m) % m;
}

int main(){
    ll n,m; cin>>n>>m;
    if(n<=1 && m<=1){
        cout<<0<<endl;
    }
    else if(m<=1){
        cout<<(n*(n-1))/2<<endl;
    }
    else if(n<=1){
        cout<<(m*(m-1))/2<<endl;
    }
    else{
        cout<<((n*(n-1))/2+((m*(m-1))/2))<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int h = scan.nextInt();
        int w = scan.nextInt();

        int n = scan.nextInt();

        int[] a = new int[n];

        for(int i = 0;i < n;i++){
            a[i] = scan.nextInt();
        }

        int now = 0;
        int[][] b = new int[h][w];
        for(int i = 0;i < h;i++){
            if(i % 2 == 0){
                for(int j = 0;j < w;j++){
                if(a[now] == 0)
                    now++;
                b[i][j] = now + 1;
                if(now < n)
                    a[now]--;
                }
            }else{
                for(int j = w - 1;j >= 0;j--){
                    if(a[now] == 0)
                        now++;
                    b[i][j] = now + 1;
                    if(now < n)
                        a[now]--;
                }
            }
        }
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                System.out.printf("%d ",b[i][j]);
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 41768
from math import ceil
A, B, C, X, Y = map(int, input().split())

ans = float('inf')
# ABピザの枚数
for i in range(2*max(X, Y)+1):
    tmpX = max(X - i/2, 0)
    tmpY = max(Y - i/2, 0)
    ans = min(ans, i*C + ceil(tmpX)*A + ceil(tmpY)*B)
print(ans)


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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> data(N);
  for(int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    data.at(i) = make_tuple(s, 100 - p, i + 1);
  }
  sort(data.begin(), data.end());
  for(int i = 0; i < N; i++) {
    int a = get<2>(data.at(i));
    cout << a << endl;
  }
}

Measured memory_bytes: 3616
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
 
(defconstant inf 1000000)
(defvar *n* (read))
(defvar *hi* (make-array *n*))
 
;dp[i]→i番目にたどり着くための最小コスト
(defvar *dp* (make-array *n* :initial-element inf))
 
(dotimes (i *n*)
         (setf (aref *hi* i) (read)))
 
(defun cost (now delta)
   (abs (- (aref *hi* now) (aref *hi* (- now delta)))))
 
;dpテーブル初期化
(setf (aref *dp* 0) 0)
(setf (aref *dp* 1) (cost 1 1))
 
(loop :for i :from 2 :upto (1- *n*) :do (if (< (aref *dp* i) inf) (aref *dp* i)
                                             (setf (aref *dp* i)
                                                   (min
                                                    (+ (aref *dp* (- i 1)) (cost i 1))
                                                    (+ (aref *dp* (- i 2)) (cost i 2)))
                                                   )))


                                         

(print (aref *dp* (1- *n*)))

Measured memory_bytes: 62396
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define N 1005

int a[10][N];
int h, w, k;

int GetGroup(int mask, int r) {
	int gr = 0;
	REP(i, r) {
		if (mask & bit(i)) {
			gr++;
		}
	}

	return gr;
}

int main(void) {
	scanf("%d%d%d", &h, &w, &k);

	REP(i, h) {
		REP(j, w) {
			scanf("%1d", &a[i][j]);
		}
	}

	int ans = -1;

	REP(mask, bit(h - 1)) {
		int num_g = GetGroup(mask, h - 1) + 1;
		vector<int> v(num_g, 0);

		int cnt = num_g - 1;
		REP(j, w) {
			int cur_g = 0;
			bool ok = 1;
			REP(i, h) {
				v[cur_g] += (a[i][j] == 1);
				if (v[cur_g] > k) {
					ok = 0;
				}
				if (mask & bit(i)) {
					cur_g++;
				}
			}

			if (!ok) {
				cnt++;
				int cur_g = 0;
				v[cur_g] = 0;
				ok = 1;
				REP(i, h) {
					v[cur_g] += (a[i][j] == 1);
					if (v[cur_g] > k) {
						ok = 0;
					}
					if (mask & bit(i)) {
						cur_g++;
						v[cur_g] = 0;
					}
				}

				if (!ok) {
					cnt = -1;
					break;
				}
			}
		}

		if (cnt == -1) {
			continue;
		}

		if (ans == -1 || ans > cnt) {
			ans = cnt;
		}
	}

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

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#define pi 3.14159
using namespace std;

int a;
char map[20][20];
int w, h;
void dfs(int y, int x);

int main() {
	while(1) {
		a = 1;
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		int x, y;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				cin >> map[i][j];
				if(map[i][j] == '@') {
					y = i;
					x = j;
					map[y][x] = 0;
				}
				else if(map[i][j] == '.') { map[i][j] = -1;}
			}
		}
		dfs(y+1, x);
		dfs(y, x-1);
		dfs(y, x+1);
		dfs(y-1, x);
		cout << a <<endl;
	}
	return 0;
}

void dfs(int y, int x) {
	if(y == -1 || x == -1 || y >= h || x >= w) {return ;}
	if(map[y][x] == '#') {return ;}
	if(map[y][x] == 0) {return ;}
	map[y][x] = 0;
	a++;
	dfs(y-1, x);
	dfs(y, x-1);
	dfs(y, x+1);
	dfs(y+1, x);
	return;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll a,b,x;
int main(){FAST;
	dofloat;
cin>>a>>b>>x;
if(.5*a*a*b <= x)
cout<<(ld)180*atan((ld)2*(a*a*b-x)/(a*a*a))/PI;
else
cout<<(ld)180*atan((ld)(a*b*b)/(2*x))/PI;
return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {


	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);


		// 整数の入力
		int x1 = sc.nextInt();
		// スペース区切りの整数の入力
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		// 文字列の入力
		//String s = sc.next();
		// 出力
		int x3 = x2-(y2-y1);
		int y3 = y2+(x2-x1);
		int x4 = x1 -(y2-y1);
		int y4 = y1+(x2-x1);

		System.out.println(x3 +" " +y3 +" " +x4+" " +y4  );


	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const long double INF=1e30;
 
int cnt[(int)1e5+3];
bool possible[(int)1e5+3];

int main(){
    int N,x;
    cin>>N>>x;
    if(x>=2&&x<=2*N-2){
        cout<<"Yes"<<endl;
        vector<int>res(2*N-1,0);
        set<int>st;
        if(x!=2){
            res[N-1]=x;
            res[N-2]=x-1;
            res[N]=x+1;
            res[N+1]=x-2;
            REP(i,4)st.insert(x-2+i);
        }else{
            res[N-1]=x;
            res[N-2]=x+1;
            res[N]=x-1;
            res[N+1]=x+2;
            REP(i,4)st.insert(x-1+i);
        }
        int c=1;
        REP(i,2*N-1)if(res[i]==0){
            while(st.find(c)!=st.end())c++;
            st.insert(c);
            res[i]=c;
        }
        REP(i,SZ(res))cout<<res[i]<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	string S, T, U; int A, B;
	cin >> S >> T >> A >> B >> U;
	if (S == U) A--;
	else B--;
	cout << A << ' ' << B << endl;

	/*--------------------------*/
}

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

Measured memory_bytes: 256
#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;

int conv[100] = {};

void init(){
    rep(i, 100) conv[i] = 0;
}

int main(void){
    int N, Q, M;
    vector<int> ans;
    while(true){
        int res = 0;
        int mx = 0;
        cin >> N >> Q;
        if(N == 0 && Q == 0) break;
        rep(j, N){
            cin >> M;
            rep(i, M){
                int temp; cin >> temp;
                conv[temp]++;
            }
        }
        rep(i, 100){
            if(conv[i] > mx){
                mx = conv[i];
                res = i;
            }
        }
        if(mx >= Q) ans.push_back(res);
        else ans.push_back(0);
        init();
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3024
#include<bits/stdc++.h>
//#define IORD
#define eps 1e-8
#define inf 0x3f3f3f3f
//#define mod (1000000007)

using namespace std;
typedef long long LL;
typedef pair<int,int> pp;

int a,b;

int main()
{
    #ifdef IORD
    freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif // IORD
    cin>>a>>b;
    if(a==2 || b==2) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256