akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		//100003
		for(int i=n;i<100000;i++) {
			if(sosu(i)) {
				System.out.println(i);
				System.exit(0);
			}
		}
		System.out.println("100003");
		
		sc.close();
	}
	
	public static boolean sosu(int n) {
		
		for(int i=2;i<n;i++) {
			if(n%i==0) {
				return false;
			}
		}
		return true;
		
	}
}


Measured memory_bytes: 35856
import sys

sm_alpha = [chr(ord('a') + i) for i in range(26)]
lg_alpha = [chr(ord('A') + i) for i in range(26)]

num_alpha = [0 for i in range(26)]

for e in sys.stdin :
    for i in range(26) :
        num_alpha[i] += e.count(sm_alpha[i])
        num_alpha[i] += e.count(lg_alpha[i])

for i in range(26) :
    print(sm_alpha[i] + " : " + str(num_alpha[i]))


Measured memory_bytes: 5572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x = scan.nextInt();
		int[] m = new int[n];
		int minM = 1000; //いちばん少ないコストで作れるドーナツ
		int zensyu=0;//全種類1個ずつ作ったときのコスト
		for(int i=0;i<n;i++) {
			m[i]=scan.nextInt();
			zensyu = zensyu + m[i];
			minM = Math.min(m[i], minM);
		}
	//	System.out.println(zensyu);
		//System.out.println(minM);
		System.out.println((x-zensyu)/minM + n);
	}

}


Measured memory_bytes: 21844
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def max(a,b)
  return a>b ? a : b
end
n,w=get_i
vw=array(n,1)
n.times do|i|
  vw[i]=get_i
end
vw.sort!{|x,y| y[1]<=>x[1]}
dp=array(w+1,n+1,0)
n.times do|i|
  for j in vw[i][1]..w
    dp[i+1][j]=dp[i][j]
    dp[i+1][j]=max(dp[i+1][j],dp[i+1][j-vw[i][1]]+vw[i][0])
  end
end
puts dp[n][w]


Measured memory_bytes: 14768
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,n) for (lint i = 0; i < (n); i++)
#define REP1(i,n) for (lint i = 1; i < (n); i++)

lint distance(lint a, lint b) {
    return (a - 1) + (b - 1);
}

int main(void){
    lint N;
    cin >> N;

    lint a, b;
    vector<lint> dp;
    dp.push_back(pow(10, 12));
    for (lint i = 1; (i*i) <= N; ++i) {
        if ((N % i) == 0) {
            a = i;
            b = N / i;
            // cout << "a = " << a << ", b = " << b << endl;
            dp.push_back(min(distance(a, b), *(dp.end() - 1)));
        }
    }

    cout << *(dp.end() - 1) << endl;
    return 0;
}

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

#define NINF -1
#define PINF 1E9+1

short n;
int totalW,totalV,*w,*v;
long *dp; // weight

int pos(int i,int j)
{
	return i*(totalV+1)+j;
}

void chMin(long *a,long b)
{
	if (*a>b) *a = b;
	return;
}

int main(void)
{
	int i,j;
	long max;
	scanf("%hd %d",&n,&totalW);
	w = (int *)malloc(sizeof(int) * n);
	v = (int *)malloc(sizeof(int) * n);
	for (i=0;i<n;i++) {
		scanf("%d %d",&w[i],&v[i]);
		totalV += v[i];
	}

	dp = (long *)malloc(sizeof(long) * (n+1)*(totalV+1));
	if (dp==NULL) {
		perror("malloc");
		exit(1);
	}
	dp[0] = 0;
	for (i=1;i<(n+1)*(totalV+1);i++) {
		dp[i] = PINF;
	}

	for (i=1;i<=n;i++) {
		for (j=0;j<totalV+1;j++) {
			dp[pos(i,j)] = dp[pos(i-1,j)];
		}

		for (j=v[i-1];j<totalV+1;j++) {
			if (dp[pos(i-1,j-v[i-1])]==PINF) continue;
			if (dp[pos(i-1,j-v[i-1])] + w[i-1] > totalW) continue;

			chMin(&dp[pos(i,j)] , dp[pos(i-1,j-v[i-1])] + w[i-1]);
		}

	}

	max = NINF;
	for (i=totalV;i>=0;i--) {
		if (dp[pos(n,i)] == PINF) continue;
		max = i;
		break;
	}
	printf("%ld\n",max);

	free(w);
	free(v);
	free(dp);
	return 0;
}


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

long n, a, b, c;
string s[100005];

int main() {
	cin >> n >> a >> b >> c;
	for (int i=0; i<n; i++) {
		cin >> s[i];
	}
	string ans = "";
	bool flag = true;
	for (int i=0; i<n; i++) {
		if (s[i] == "AB") {
			if (a == 0 && b == 0) {
				cout << "No\n";
				flag = false;
				break;
			}
			if (a == 1 && b == 1 && c == 0) {
				if (i == n - 1) {
					ans += "A\n";
					continue;
				}
				if (s[i + 1] == "AC") {
					++a;
					--b;
					ans += "A\n";
					continue;
				}
				else if (s[i + 1] == "BC") {
					--a;
					++b;
					ans += "B\n";
					continue;
				}
			}
			if (a > b) {
				--a;
				++b;
				ans += "B\n";
			}
			else {
				++a;
				--b;
				ans += "A\n";
			}
		}

		else if (s[i] == "BC") {
			if (b == 0 && c == 0) {
				cout << "No\n";
				flag = false;
				break;
			}
			if (b == 1 && c == 1 && a == 0) {
				if (i == n - 1) {
					ans += "B\n";
					continue;
				}
				if (s[i + 1] == "AB") {
					++b;
					--c;
					ans += "B\n";
					continue;
				}
				else if (s[i + 1] == "AC") {
					--b;
					++c;
					ans += "C\n";
					continue;
				}
			}
			if (b > c) {
				--b;
				++c;
				ans += "C\n";
			}
			else {
				++b;
				--c;
				ans += "B\n";
			}
		}

		else if (s[i] == "AC") {
			if (a == 0 && c == 0) {
				cout << "No\n";
				flag = false;
				break;
			}
			if (a == 1 && c == 1 && b == 0) {
				if (i == n - 1) {
					ans += "A\n";
					continue;
				}
				if (s[i + 1] == "BC") {
					++c;
					--a;
					ans += "C\n";
					continue;
				}
				else if (s[i + 1] == "AB") {
					--c;
					++a;
					ans += "A\n";
					continue;
				}
			}
			if (c > a) {
				--c;
				++a;
				ans += "A\n";
			}
			else {
				++c;
				--a;
				ans += "C\n";
			}
		}
	}
	if (flag) {
		cout << "Yes\n" << ans;
	}
}

Measured memory_bytes: 6884
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1, 0); }
	V<V<pin>> qab(2);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	V<vel> c(2, vel(2));
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
			if ((qc + 1) % 2) { c[i][0] ^= 1; }
			if (qc) { c[i][1] ^= 1; }
		}
	}
	rep(i, 2) {
		if (!c[1 - i][0] && !c[1 - i][1]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for (pin& v : ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 2e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 59);
	cout << ret.first - inf << " " << ret.second - inf;
}

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

int main(){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int a = x2 - x1;
	int b = y2 -y1;
	int x3 = x2 - b;
	int y3 = y2 + a;
	int x4 = x3 - a;
	int y4 = y3 - b;
	cout << x3 << " "<< y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 764
#include<stdio.h>

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


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    set<int> st;
    for (int i = 0; i < N; i++) {
        int s; cin >> s;
        st.insert(s);
    }
    cout << st.size() << '\n';
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {

        List<int> list = new List<int>();


        for(int i = 0;i<10;i++)
        {
            list.Add(int.Parse(Console.ReadLine()));
        }

        list.Sort((a,b) => b-a);

        for(int i = 0; i < 3; i++)
        {
            Console.WriteLine(list[i]);
        }








    }
}




Measured memory_bytes: 17976
# AOJ 0060: Card Game
# Python3 2018.6.16 bal4u

while True:
	try: c1, c2, c3 = list(map(int, input().split()))
	except: break
	
	c = [True]*11
	c[c1] = c[c2] = c[c3] = False
	win, my = 0, c1+c2
	for i in range(1, 11):
		if c[i] and my + i <= 20: win += 1
	print('YES' if win >= 4 else 'NO')


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	char a = s1[0] + ('A' - 'a'), b = s2[0] + ('A' - 'a'), c = s3[0] + ('A' - 'a');
	cout << a << b << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll a;
    cin >> a;
    cout << 360 / euclidean_gcd(360, a) << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int a[200];
	int n;
	int c;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		c = i;
	}
	for (int i = 0; i < n; i++)
	{
		cout << a[c];
		if (c!=0)
		{
			cout << " ";
		}
		c = c - 1;
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    ll n;
    cin>>n;
    cout<<(n-1)*n/2<<endl;
}


Measured memory_bytes: 256
// ABC 60 C

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

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

int main() {
  int N, T;
  cin >> N >> T;

  ll start = 0;
  ll end = 0;
  ll ans = 0;
  rep(i, N) {
    ll t;
    cin >> t;
    if (t >= end) {
      ans += end - start;
      start = t;
      end = t + T;
    } else {
      end = t + T;
    }
  }
  ans += end - start;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <set>
#include <stdlib.h>
using namespace std;
int main()
{
	int a,b,x,n;
	cin>>x>>a>>b;
	n=(x-a)/b;
	cout<<x-a-n*b;
	return 0;   
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


const int max_comb=10000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}

int main(int argc, char* argv[])
{
    int n, k;
    scanf("%d%d", &n, &k);

    pre_comb();
    int i;
    for(i=1; i<=k; i++) {
        int m = n-k-(i-1);
        if(m<0) {
            printf("0\n");
        }
        else {
            ll ans = comb(k-1,i-1) * comb(m+i, i) %MOD;
            printf("%lld\n", ans);
        }
    }

    return 0;
}


Measured memory_bytes: 384
n=int(input())
s=input()
lCurrent=rCurrent=0
l=[0]*n
r=[0]*n
ans=[0]*n

for i in range(n-1):
    if s[i]=="W":
        lCurrent+=1
    l[i+1]=lCurrent

for i in reversed(range(1,n)):
    if s[i]=="E":
        rCurrent+=1
    r[i-1]=rCurrent

ans=[x+y for x,y in zip(l,r)]
print(min(ans))

Measured memory_bytes: 32012
#include<cstdio>
#define MOD 1000000007
using namespace std;
int n,cnt[26];
long long ans=1;
char a[100005];
int main()
{
	scanf("%d%s",&n,a+1);
	for(int i=1;i<=n;++i) cnt[a[i]-'a']++;
	for(int i=0;i<26;++i) ans=(ans*(long long)(cnt[i]+1))%MOD;
	printf("%lld",ans-1);
	return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int H,W;
    Scd2(H,W);

    char s[123];
    bool w[113][113] = {};
    int dis[108][108] = {};
    Rep(i,H) {
        Scs(s);
        Rep(j,W) w[i][j] = s[j]=='#';
        Rep(j,W) dis[i][j] = INF;
    }

    using piii = pair<int,pii>;
    deque<piii> dq;

    dq.push_back({w[0][0],{0,0}});
    while( dq.size() ){
        int d = dq.front().first;
        int r = dq.front().second.first;
        int c = dq.front().second.second;
        dq.pop_front();
        if( d >= dis[r][c] ) continue;
        dis[r][c] = d;
        if( r+1 < H ) {
            if( !w[r][c] && w[r+1][c] ) dq.push_back({d+1,{r+1,c}});
            else dq.push_front({d,{r+1,c}});
        }
        if( c+1 < W ) {
            if( !w[r][c] && w[r][c+1] ) dq.push_back({d+1,{r,c+1}});
            else dq.push_front({d,{r,c+1}});
        }
    }

    printf ("%d\n", dis[H-1][W-1] );

    return 0;
}




Measured memory_bytes: 256
def actual(N):
    # 答え候補は 2の累乗 だけ(1<=N<=100なので、最大で64)
    answers = [2 ** i for i in range(6 + 1)]

    and_set = set(answers) & set(range(1, N + 1))

    return max(and_set)


N = int(input())

print(actual(N))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

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

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans=b-a;
  ans-=b/c+b/d-b/(c*d/gcd(c,d));
  ans+=a/c+a/d-a/(c*d/gcd(c,d));
  if(a%c&&a%d) {
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
// #include <stack>
// #include <vector>
#include <cstring>
// #include <algorithm>
using namespace std;

int N = 0;
int A[20];
int Q = 0;
int M;

bool resolve(int i, int m) {
    if (m < 0) {
        return false;
    }
    if (m == 0) {
        return true;
    }
    if (i >= N) {
        return false;
    }
    return resolve(i + 1, m) || resolve(i + 1, m - A[i]);
}

bool findCombination(int m) {
    return resolve(0, m);
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        scanf("%d", &M);
        bool result = findCombination(M);
        if (result) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}


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

int main(void){
    int a=0,b=0,i=0,count=0;
    cin>>a;
    for(i;i<3;i++){
        
        if(b=a%10==1)
          count++;
 a/=10;   }
    cout<<count<<endl;
}

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

public class Main {
    int n;
    int[] as;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        long[] sums = new long[n + 2];
        for (int i = 1; i <= n; i++) {
            sums[i] = sums[i - 1] + as[i - 1];
        }
        sums[n + 1] = Long.MAX_VALUE;
        Arrays.sort(sums);
        long count = 0;
        long ans = 0;
        long prev = sums[0];
        for (int i = 1; i <= n + 1; i++) {
            if (prev != sums[i]) {
                prev = sums[i];
                ans += count * (count + 1) / 2;
                count = 0;
            } else {
                count++;
            }
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 46516
n,m = map(int,input().split())
mp = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    mp[a].append(b)
    mp[b].append(a)

queue = []
dist = [float('INF')]*(n+1)
pre = [-1]*(n+1)
dist[0] = 0
dist[1] = 0
queue.append(1)

while(len(queue)>0):
    now = queue.pop(0)
    for nx in mp[now]:
        if dist[nx]!= float('INF'):
            continue
        dist[nx] = dist[now] + 1
        pre[nx] = now
        queue.append(nx)
print('Yes')
for i in range(2,n+1):
    print(pre[i])


Measured memory_bytes: 34456
const Main = input => {
  const sp = input.split('\n');
  const sp0 = sp[0].split(' ').map(e => Number(e));
  const N = sp0[0];
  const M = sp0[1];
  const A_list = sp[1].split(' ').map(e => Number(e));

  let sum = 0;
  for(let A of A_list) sum += A;
  const rest = N - sum;
  const result = rest > -1 ? rest : -1;
  console.log(result);
};

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
/*Main(`41 2
5 6`)
Main(`10 2
5 6`)
Main(`11 2
5 6`)
Main(`314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3`)*/


Measured memory_bytes: 30816
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,a,b; cin>>n>>a>>b;
    ll ans=1;
    bitset<64> bb(n);
    ll r=2;
    rep(i,64){
        if(bb.test(i)) ans=(ans*r)%MOD;
        r=(r*r)%MOD;
    }
    ans--;
    vector<ll> m(b+1,0); m[1]=1;
    for(int i=2;i<=b;i++){
        m[i]=(-m[MOD%i]*(MOD/i))%MOD;
    }
    ll nCr=1;
    for(int i=1;i<=b;i++){
        nCr=nCr*(n-i+1)%MOD;
        nCr=nCr*m[i]%MOD;
        if(i==a) ans=(ans-nCr)%MOD;
        if(i==b) ans=(ans-nCr)%MOD;
    }
    cout<<(ans+2*MOD)%MOD<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define ll long long
#define hh puts("")
#define pc putchar
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
int n;
double ans;
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();}
    return ret*ff;
}
void write(int x){
    if(x<0){x=-x;putchar('-');}
    if(x>9) write(x/10);
    putchar(x%10+48);
}
signed main(){
	n=read();
	for(int i=1;i<=n;i++){
		ans+=1./read();
	}
	printf("%.7lf",1./ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
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;


#define NUM 1000

struct Info{
	int x,y;
};

int dp[NUM][NUM];
Info info[NUM];

int main(){

	int N;
	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%d %d",&info[i].x,&info[i].y);
	}

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

	int tmp_cost;

	for(int a = 0; a < N; a++){
		for(int i = 0; i+a < N; i++){
			for(int k = i; k < i+a; k++){
				tmp_cost = abs(info[i].x-info[k+1].x)+abs(info[k].y-info[i+a].y);
				dp[i][i+a] = min(dp[i][i+a],dp[i][k]+dp[k+1][i+a]+tmp_cost);
			}
		}
	}

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

	return 0;
}



Measured memory_bytes: 7140
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
#include <fstream>
#include <valarray>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const long double pi=acos(-1.0);
int dx[]={0,1,0,-1,1,1,-1,-1,0},dy[]={1,0,-1,0,1,-1,1,-1,0};

ll dp[31];

main(){
  dp[0]=1;

  for(int i=1;i<=30;++i)
    for(int j=max(0,i-3);j<i;++j)
      dp[i]+=dp[j];
  int n;
  while(cin>>n,n)cout<<(dp[n]+3649)/3650<<endl;
}

Measured memory_bytes: 0
// A - Airport Bus
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, k, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n >> c >> k;
  vlli d(n);
  rep(i, 0, n)
  {
    cin >> d[i];
  }
  SORT(d);
  lli time = 0;
  rep(i, 0, n)
  {
    if (d[i] > time || count == c)
    {
      time = d[i] + k;
      ans++;
      count = 1;
    }
    else
    {
      count++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3972
#include<iostream>
#include<string>

#define Max_N 1001

int dp[Max_N][7];

int main(){
	int n,ans=0;
	std::string str;
	std::cin>>n>>str;

	if(str[0]=='J')dp[0][0]=dp[0][3]=dp[0][4]=dp[0][6]=1;
	else if(str[0]=='O')dp[0][3]=dp[0][6]=1;
	else if(str[0]=='I')dp[0][4]=dp[0][6]=1;

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

		if(str[i]=='J'){

			dp[i][0]=dp[i-1][0]+dp[i-1][3]+dp[i-1][4]+dp[i-1][6];
			dp[i][3]=dp[i-1][0]+dp[i-1][1]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6];
			dp[i][4]=dp[i-1][0]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6];
			dp[i][6]=dp[i-1][0]+dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6];
		
		}else if(str[i]=='O'){
			
			dp[i][1]=dp[i-1][1]+dp[i-1][3]+dp[i-1][5]+dp[i-1][6];
			dp[i][3]=dp[i-1][0]+dp[i-1][1]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6];
			dp[i][5]=dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6];
			dp[i][6]=dp[i-1][0]+dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6];
		
		}else if(str[i]=='I'){
			
			dp[i][2]=dp[i-1][2]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6];
			dp[i][4]=dp[i-1][0]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6];
			dp[i][5]=dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6];
			dp[i][6]=dp[i-1][0]+dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6];
		
		}

		for(int j=0;j<7;j++)dp[i][j]%=10007;

	}
	for(int i=0;i<7;i++){
		ans+=dp[n-1][i];
		ans%=10007;
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 1232
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

signed main() { 
        string s;
        cin >> s;
        int cnt[26] = { 0 };
        for (auto i : s) {
                cnt[i - 'a'] ++;
        }
        bool f = true;
        rep(i, 26) if (cnt[i] >= 2) f = false;
        puts(f ? "yes" : "no");
        return 0;
}               



Measured memory_bytes: 256
count = 1
destroy = 0
N = int(input())
List=list(map(int,input().split()))
isSuccess = False

if len(List) == 1:
  if List[0] == 1:
    print(0)
  else:
    print(-1)
else:
  for i in range(N):
    if List[i] != count:
      destroy += 1
    else:
      count += 1
      isSuccess = True
  if isSuccess == False:
    print(-1)
  else:
    print(destroy)

Measured memory_bytes: 26524
#include<stdio.h>
int main(){
int a[30];
int x,i,b=5;
for(i=0;i<30;i++){
a[i]=b;
b++;
if(b==8){
b=1;
}
}
scanf("%d\n",&x);
x=x-1;
if(a[x]==1){
printf("mon\n");
}
else if(a[x]==2){
printf("tue\n");
}
else if(a[x]==3){
printf("wed\n");
}
else if(a[x]==4){
printf("thu\n");
}
else if(a[x]==5){
printf("fri\n");
}
else if(a[x]==6){
printf("sat\n");
}
else if(a[x]==7){
printf("sun\n");
}
return 0;
}



Measured memory_bytes: 1992
import math
import sys

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


def prime(i):
  k=[]
  num=i
  j=2
  while j*j<=num:
    if i%j==0:
      i//=j
      k.append(j)
    else:
      j+=1
  if i!=1:
    k.append(i)
  k.append(1)
  return k

a=set(prime(M[0]))
b=set(prime(M[1]))
print(len(list(a&b)))

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <cstdio>
#include<iomanip>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N;
  cin >> N;
  int tmp = 0;
  vector<int> list(N+1);
  for (int i = 1; i < N; i++) {
    cin >> tmp;
    list[tmp]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << list[i] << endl;
  }
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 4000
#include <iostream>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;

typedef long long lint;
typedef pair<lint,lint> pt;

int main(){
    lint N;
    cin >> N;
    pt red[100],blue[100];
    for(int i=0;i<N;i++){
        int x,y;
        cin >> x >> y;
        red[i]=make_pair(x,y);
    }
    for(int i=0;i<N;i++){
        int x,y;
        cin >> x >> y;
        blue[i]=make_pair(x,y);
    }
    sort(red,red+N);
    sort(blue,blue+N);

    priority_queue<lint> Rs,Bs,tmp;
    int ar=0,ab=0;
    int cnt=0;
    Rs.push(red[0].second);
    for(ar=1;ar<=N;ar++){
        if(ar<N && red[ar].first==red[ar-1].first){
            Rs.push(red[ar].second);
        }else{
            while(ab<N && blue[ab].first<=red[ar-1].first) ab++;
            if(ab==N) break;
            while(ab<N && (ar==N || blue[ab].first<=red[ar].first)){
                Bs.push(blue[ab].second);
                ab++;
            }
            while(!tmp.empty()) tmp.pop();
            while(!Rs.empty() && !Bs.empty()){
                if(Rs.top()>=Bs.top()){
                    tmp.push(Rs.top());
                    Rs.pop();
                    continue;
                }else{
                    Rs.pop();
                    Bs.pop();
                    cnt++;
                }
            }
            while(!tmp.empty()){
                Rs.push(tmp.top());
                tmp.pop();
            }
            while(!Bs.empty()) Bs.pop();
            if(ar<N) Rs.push(red[ar].second);
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

vector<string> invertMatrix(vector<string> a){
	int h = (int)a.size();
	int w = (int)a[0].size();
	vector<string> res(w, string(h, '.'));
	rep (i, h){
		rep (j, w){
			res[j][i] = a[i][j];
		} // end rep
	} // end rep
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int H, W; cin >> H >> W;
	vector<string> a(H, string(W, '.'));
	rep (i, H) rep (j, W){
		cin >> a[i][j];
	} // end rep

	bool update = false;
	while(true){
		update = false;
		rep (cnt, 2){
			vector<string> next; next.clear();
			rep (i, (int)a.size()){
				bool ok = true;
				rep (j, (int)a[0].size()){
					if (a[i][j] == '#'){
						ok = false;
					} // end if
				} // end rep
				if (ok){
					update |= true;
				}else{
					next.push_back(a[i]);
				} // end if
			} // end rep
			a = next;
			a = invertMatrix(a);
		} // end rep
		if (!update) break;
	} // end while

	rep (i, (int)a.size()){
		cout << a[i] << endl;
	} // end rep

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int> a(q);
  for(int i=0;i<q;i++){
    cin>>a[i];
  }
  vector<int> b(n);
  
  for(int i=0;i<q;i++){
    b[a[i]-1]+=1;
  }
  for(int i=0;i<n;i++){
    if(k-q+b[i]>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  rep(i, H) cin >> S[i];
  int ans_min = inf;
  rep(t, 1<<H) {
    map<int, int> idx;
    int ngroup = 1;
    rep(i, H) {
      idx[i] = ngroup-1;
      if((t>>i)&1) ngroup++;
    }
    vector<vector<int> > cnt(ngroup, vector<int>(W+1));
    rep(i, H) rep(j, W) {
      if(S[i][j] == '1') cnt[idx[i]][j+1]++;
    }
    bool ok = true;
    rep(i, ngroup) rep(j, W+1) {
      if(cnt[i][j] > K) ok = false;
      if(j) cnt[i][j] = cnt[i][j] + cnt[i][j-1];
    }
    if(!ok) continue;
    int prev = 0;
    int ans = 0;
    vector<char> cut(W, '0');
    rep(j, W+1) {
      bool cutp = false;
      rep(i, ngroup) {
	if(cnt[i][j] - cnt[i][prev] > K) cutp = true;
      }
      if(cutp) {
	ans++;
	prev = j-1;
	cut[j-1] = '1';
      }
    }
    if(ans+ngroup-1 < ans_min) {
      ans_min = ans + ngroup-1;
    }
  }
  cout << ans_min << endl;
  return 0;
}


Measured memory_bytes: 256
while 1:
	a,op,b=map(str,raw_input().split())
	a=int(a)
	b=int(b)

	if op=='?':
		break
	elif op=='+':
		print a+b
	elif op=='-':
		print a-b
	elif op=='*':
		print a*b
	elif op=='/':
		print a/b

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i = 0; i < n; i++)
#define for1(i,n) for(int i = 1; i <= n; i++)
#define ford(i,n) for(int i = n-1; i >= 0; i--)
#define fore(i,a,b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;


const  int MAXn= 3e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;

int main(){
	int l,r;
	cin>>l>>r;
	if((l-1)/(int)2019 != r/(int)2019) {
		cout<<0;
		return 0;
	}
	l= l%2019;
	r= r%2019;
	ll minn=2018;
	for(int i=l; i<r;i++){
		for(int j=i+1; j<=r;j++){
			ll temp= (i*j)%2019;
			minn= min(minn, temp);
		}
	}
	cout<<minn;
}
			
	 


Measured memory_bytes: 256
n=int(input())
ans=[]
ans.append(n)
tf=True
while tf:
    if n%2==0:
        n//=2
        ans.append(n)
    else:
        n=3*n+1
        ans.append(n)
    for i in range(len(ans)-1):
        for j in range(i+1,len(ans)):
            if ans[i]==ans[j]:
                print(len(ans))
                tf=False

Measured memory_bytes: 3060
H,W = map(int,input().split())

while H != 0 and W != 0 :
    for i in range(H):
        if i == 0 or i == (H-1):
            print("#"*W)
        else:
            print("#"+"."*(W-2)+"#")
    print("")
    H,W = map(int,input().split())



Measured memory_bytes: 5608
X=input()
Y=input()
dp=[[0 for j  in range(len(X) + 1)]for k in range(len(Y)+1)]

for i in range(len(X)+1):
    dp[0][i]=i
for i in range(len(Y)+1):
    dp[i][0]=i

for i in range(1,len(X)+1):
    for j in range(1,len(Y)+1):
        if X[i-1] == Y[j-1]:
            dp[j][i] = dp[j-1][i-1]
        else:
            dp[j][i] = min(dp[j-1][i], dp[j][i-1], dp[j-1][i-1]) + 1

print(dp[len(Y)][len(X)])


Measured memory_bytes: 42896
import sys
sys.setrecursionlimit(10**6)
n, u, v = map(int, input().split())
u -= 1
v -= 1
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
d1 = [None]*n
d2 = [None]*n
def dfs(node, d, p_node=-1):
    for c_node in graph[node]:
        if c_node==p_node:
            continue
        d[c_node] = d[node] + 1
        dfs(c_node, d, node)
d1[u] = 0
d2[v] = 0
dfs(u, d1)
dfs(v, d2)
ans = 0
for i, j in zip(d1, d2):
    if i<j:
        ans = max(ans, j-1)
print(ans)

Measured memory_bytes: 126952
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>

using namespace std;

list <int> hsf(list <int> li, int c, int p) {
  list <int> :: iterator i1, i2;
  list <int> :: iterator ii;

  if (p == 1) return li;

  i1 = i2 = li.begin();

  advance(i1, p-1);
  advance(i2, c + (p-1));

  li.splice(li.begin(), li, i1, i2);

  return li;

}


int main(void) {

  for (;;) {
    list <int> c1, c2;
    vector <int> c, p;
    int i, j;
    int n, r;

    cin >> n;
    cin >> r;
    if (n == 0 || r == 0) {
      break;
    }
    
    for (i = 0; i < r; i++) {
      int x, y;
      cin >> x;
      cin >> y;
      c.push_back(y);
      p.push_back(x);
    }

    for (j = 0; j < n; j++) {
      c1.push_front(j+1);
    }
  
    for (i = 0; i < r; i++) {
      c2 = hsf(c1, c[i], p[i]);
      c1 = c2;
    }

    list <int> :: iterator ii;

    ii = c1.begin();
    cout << *ii;
    cout << endl;
  }

  
  return 0;

}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//const string YES = "Yes";
const string NO = "No";

void solve(long long N){
  repf(i,1,10){
    if(N%i==0&&(N/i>=1&&N/i<=9)){
      op("Yes");
      return;
    }
  }
  op("No")
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
ar = [b[0]]

for i in range(n-2):
  if b[i] <= b[i+1]:
    
    ar.append(b[i])
  else:
    
    ar.append(b[i+1])
ar.append(b[-1])
print(sum(ar))

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r,d,p;cin>>r>>d>>p;
    int q;
    rep(i,1,10)
    {
        q=r*p-d;
        cout<<q<<"\n";
        p=q;
    }



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, k;
    cin >> n >> k;
    VVL a(n);
    vector<PL> x(n);
    REP(i,n){
        int t = in() - 1, d = in();
        a[t].push_back(d);
        x[i] = PL(d, t);
    }
    sort(ALL(x));
    reverse(ALL(x));
    REP(i,n){
        sort(ALL(a[i]));
        reverse(ALL(a[i]));
    }

    vector<PL> ord;
    REP(i,n){
        if (!a[i].empty()) ord.push_back(P(-a[i][0], i));
    }
    int m = ord.size();
    sort(ALL(ord));

    VI p(m);
    REP(i,m) p[i] = ord[i].second;

    ll s = 0, j = 0;
    priority_queue<ll> que;
    set<int> st;
    REP(i,k){
        s += x[i].first;
        if (st.count(x[i].second)){
            que.push(-x[i].first);
        }else{
            j++;
            st.insert(x[i].second);
        }
    }

    ll ans = s + j * j;
    while (j < m && !que.empty()){
        s += que.top();
        que.pop();
        s += a[p[j]][0];
        j++;
        ans = max(ans, s + j * j);
    }
    cout << ans << endl;

    return 0;
}


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

int main(void) {
    char buffer[15];
    int  A,B,C;
    if (fgets(buffer,15,stdin) != NULL) {
        A = atoi(strtok(buffer, " "));
        B = atoi(strtok(NULL, " "));
        C = atoi(strtok(NULL, " "));
    } else {
        return 1;
    }
    if (A*C <= B) {
        printf("%d", C);
    } else {
        printf("%d", B/A);
    }
    return 0;
}

Measured memory_bytes: 128