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

public class Main {
	public static void main(String [] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		while(a < -1000 && b > 1000) {
			a = stdIn.nextInt();
			b = stdIn.nextInt();
		}
		
		if(a < b) {
			System.out.println("a < b");
		}else if(a > b) {
			System.out.println("a > b");
		}else {
			System.out.println("a == b");
		}
	}

}


Measured memory_bytes: 26324
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int digit(int n){
   if(n < 10)  return n;
   return digit(n/10) + n%10;
}
int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N+100);
  for(int i=0;i<N;i++) cin>>A.at(i);
  for(int i=0;i<N-K;i++){
    if(A.at(i)<A.at(i+K)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  
return 0;}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    vector<ll> a(n),b(n),c(n);
    rep(i,n) cin >> a[i]; 
    rep(i,n) cin >> b[i]; 
    rep(i,n) cin >> c[i]; 
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    vector<ll> cc(n),bb(n);
    rep(i,n) {
        cc[i]=n-(upper_bound(c.begin(),c.end(),b[i])-c.begin());
    }
    invrep(i,n-1) cc[i]+=cc[i+1];
    rep(i,n) {
        int j=upper_bound(b.begin(),b.end(),a[i])-b.begin();
        bb[i]=cc[j];
    }
    ll ans=0;
    rep(i,n) ans+=bb[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

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

ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,tmp;
  cin>>n;
  tmp=n*0.9;
  for(ll i=tmp;i<=n;i++){
    ll a=i*1.08;
    if(a==n){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define min(a, b) ((a)>(b)?(b):(a))
char s[2222], t[2222];
int ans = 1<<30;
int main(){
	scanf("%s%s", s, t);
	int l = strlen(s), r = strlen(t);
	for(int i=0; i<=l-r; i++){
		int cnt = 0;
		for(int j=0; j<r; j++){
			cnt += t[j] != s[i+j];
		}
		ans = min(ans, cnt);
	}
	printf("%d\n", ans);
	return 0;
}


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

int N;

int solve() {
  for (int i = 111; i < 1000; i += 111) {
    if (i < N) continue;
    return i;
  }
  return -1;
}

int main() {
  cin >> N;
  cout << solve() << endl;
  return 0;
}


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

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int out = 0;
	int rest;
	for(int a=0; a<=A; ++a)
	{
	        for(int b=0; b<=B; ++b)
	        {
	                rest = X - (500 * a + 100 * b);
	                if(0<=rest && rest<=50*C) ++out;
	        }
	}
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 256
D,G = map(int,input().split())

P = []
C = []

for i in range(D) :
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

ans = float("inf")

for bit in range(1 << D) :
    A = []
    score = 0
    cost = 0
    
    for k in range(D) :
        if bit & (1 << k) :
            A.append(k)
    
    
    for a in A :
        score += 100*(a+1)*P[a] + C[a]
        cost += P[a]
    
    if score < G :
        for i in range(D-1,-1,-1) :
            if i in A :
                continue
            
            if score + 100*(i+1)*P[i] + C[i] < G :
                score += 100*(i+1)*P[i] + C[i]
                cost += P[i]
            
            else :
                cost += (G-score)//(100*(i+1)) + ((G-score) % ((100)*(i+1)) != 0)
                break
    
    ans = min(ans, cost)
    
print(ans)


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

#define int long long int 

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

int32_t main()
{
  int h,w;
  cin>>h>>w;
  vector<string> str;
  for(int i=0;i<h;i++)
  {
    string s;
    cin>>s;
    str.push_back(s);
  }

  for(int i=0;i<h;i++)
  {
    for(int j=0;j<w;j++)
    {
       if(str[i][j]!='.')
       continue;
        int ans=0;
        //cout<<"psia "<<i<<" "<<j<<endl;
       for(int k=0;k<8;k++)
       {
            int x=i+dx[k];
            int y=j+dy[k];
            if(x>=0 && x<h && y>=0 && y<w && str[x][y]=='#')ans++; 
       }
       str[i][j]=char(ans+'0');
    }
  }
  for(auto i:str)
  cout<<i<<endl;

}

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

int main(){
    int n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    sort(a, a + n);
    int flag = 0;
    for(int i = 0; i < n - 1; i++){
        if(a[i] == a[i + 1]){
            flag = 1;
            break;
        }
    }

    if(flag == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define int long long

struct Int {
	int exp = 0;
	unsigned int kasu = 1ll << 52;

	Int() {}
	Int(string b) {
		exp = 0;
		kasu = 1ll << 52;
		rep(i, 0, 52) {
			int j = 51 - i;
			if (b[i] == '1') {
				kasu |= (1ll << j);
			}
		}
	}
};


bool operator==(Int a, Int b) {
	return a.exp == b.exp and a.kasu == b.kasu;
}
Int operator+(Int x, Int y) {
	int d = x.exp - y.exp;
	y.kasu >>= d;
	x.kasu += y.kasu;

	while (x.kasu >= (1ll << 53)) {
		x.exp++;
		x.kasu -= (1ll << 52);
	}

	return x;
}

auto binarySearch = [&](int ng, int ok, Int s, Int a) {
	auto f = [&](int m) {
		if ((1LL << 60) / m < (a.kasu >> s.exp))return true;
		return ((a.kasu >> s.exp) * m + s.kasu) >= (1LL << 53);
	};
	if (f(ng))return ng;
	while (ng + 1 < ok) {
		int m = (ng + ok) / 2;
		if (f(m))
			ok = m;
		else
			ng = m;
	}
	return ok;
};

void solve(int n) {
	string b; cin >> b;
	Int a(b);
	Int s = a;

	int k = 0;
	//cerr << "a.exp " << bitset<12>(a.exp) << endl;
	//cerr << "a.kasu " << bitset<53>(a.kasu) << endl;
	while (k < n) {
		int x = binarySearch(1, n - k, s, a);
		s.kasu = (a.kasu >> s.exp) * x + s.kasu;
		if (s.kasu == (1ll << 53)) {
			s.exp++;
			s.kasu >>= 1;
		}
		else {
			if (s.kasu >= (1ll << 53)) {
				s.exp++;
				s.kasu >>= 1;
			}
			while (s.kasu < (1ll << 52)) {
				s.exp--;
				s.kasu <<= 1;
			}
		}
		k += x;
		//cerr << "x " << x << endl;
		//cerr << "s.exp " << bitset<12>(s.exp) << endl;
		//cerr << "s.kasu " << bitset<53>(s.kasu) << endl;
	}

	cout << bitset<12>(s.exp) << bitset<52>(s.kasu) << endl;

}

signed main() {

	int n;
	while (cin >> n, n) {
		solve(n);
	}

	//double hoge = 1.0;
	//int x=*((int*)(&hoge));
	//bitset<64>b(x);
	//cout << b << endl;
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
const int INF = 100000;
typedef pair<int, int> P;
int main()
{
    int x, y, z, K;
    cin >> x >> y >> z >> K;
    vector<long long> A(x), B(y), C(z);
    for (int i = 0; i < x; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < y; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < z; i++)
    {
        cin >> C[i];
    }
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());
    priority_queue<long long> P;
    vector<long long> v;
    for (int i = 0; i < x; i++)
    {
        for (int j = 0; j < y; j++)
        {
            v.push_back(A[i] + B[j]);
        }
    }
    sort(v.rbegin(), v.rend());
    for(int i=0; i<min((int)v.size(),K); i++){
        for(int j=0; j<z; j++){
            P.push(v[i]+C[j]);
        }
    }
    for (int i = 0; i < K; i++)
    {

        cout << P.top() << endl;
        P.pop();
    }
}


Measured memory_bytes: 43368
#include <stdio.h>

int get_weekday(int year,int month,int day)
{
        int weekday,tmp;
        if(month==1||month==2){
                year--;month+=12;
        }
        tmp = year/100;
        weekday=(year+(year>>2)-tmp+(tmp>>2)+(13*month+8)/5+day)%7;
        return weekday;
}

int main()
{
        int m,d;
        char week_data[7][10] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
        while(scanf("%d%d",&m,&d),m){
                printf("%s\n",week_data[get_weekday(2004,m,d)]);
        }
        return 0;
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;




int main() {

	int n;
	cin >> n;

	REP(i, n) {
		int a;
		cin >> a;
		if (a % 2 == 0) {
			if (a % 3 != 0 && a % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
	


}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    int ans = Integer.MAX_VALUE;
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      int count = 0;
      while (a % 2 == 0) {
        count++;
        a /= 2;
      }
      ans = Math.min(ans, count);
    }
    
    System.out.println(ans == Integer.MAX_VALUE ? 0 : ans);
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    int xnum=0; //一番多いカウントを記録しておく
    rep(i,n){
        string s;
        cin >> s;
        mp[s] ++;
        xnum = max(xnum, mp[s]);
    }
    //範囲for文を使うとpがmp[i]になる
    //map[i].secondで値、map[i].firstでキーを取り出せる
    for(auto& p:mp){
        if(p.second == xnum) cout << p.first << endl;
    }


}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define ull unsigned long long
#define ll long long


void add(int &a,int b){
    a+=b;
    if(a>=mod)
        a-=mod;
}
int nCr(long long m, long long n){

    //6 * 5 * 4 *../ 1*2*3*...

    int ans = 1;
    for (long long i = 1; i <= n; i++){
        ans = ans * (m - i + 1) / i;
 
    }
    return ans;
}
int32_t main()
{
    //sbs();
    // int t;cin>>t;
    // while(t--){

    // }
    string s;cin>>s;
    int n=s.length();
    int one=0,zero=0;
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=='0'){
            if(one>0){
                one--;ans+=2;
            }else {
                zero++;
            }
        }else {
            if(zero>0){
                zero--;ans+=2;
            }else {
                one++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

bool isdifferent(vector<int> &a, vector<int> &b, int n) {
    for(int i = 0; i < n; i ++)
        if(a[i] != b[i])
            return 1;
    return 0;
}

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vector<int> p(n, 0);
    for(int i = 0; i < n; i ++)
        cin >> p[i];
    vector<int> q(n, 0);
    for(int i = 0; i < n; i ++)
        cin >> q[i];

    int i = 0;
    while(i < n && p[i] == q[i])
        i ++;
    if(i == n) {
        cout << 0;
        return 0;
    }

    if(p[i] > q[i])
        swap(p, q);
    int ans = 0;
    while(isdifferent(p, q, n)) {
        ans ++;
        next_permutation(p.begin(), p.end());
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

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

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, x, t; cin >> n >> x >> t;
	int res = ((n + x - 1) / x)*t;
	cout << res << endl;
}

Measured memory_bytes: 3632
n = gets.split(" ").map{|k| k.to_i }
until n[0] == 0
    start = n[0]
    finish = n[1]
    count = 0
    arry = (start..finish).to_a
    arry.each do |k|
        if (60**60) % k == 0
            count += 1
        elsif k == 1
            count += 1
        end
    end
    puts count
    n = gets.split(" ").map{|k| k.to_i }
end


Measured memory_bytes: 23564
prime = [True for i in range(250001)]
prime[0] = prime[1] = False
for i in range(2, 500):
    if prime[i]:
        for j in range(2, 250000 // i + 1):
            prime[i * j] = False

while True:
    n = int(input())
    if n == 0:
        break
    print(prime[n + 1 : n * 2 + 1].count(True))


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

int main() {
  int a,b;
  cin >> a >> b;
  if (a%3==0 || b%3==0 || (a+b)%3==0) {
    printf("Possible\n");
  } else {
    printf("Impossible\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    string s, x;
    cin >> s;
    int n = s.size(), y;
    set<int> alphabet;
    for (int i = 0; i < n; i++) {
        y = s[i] - 'a';
        alphabet.insert(y);
    }
    if (alphabet.size() == 26) cout << "None" << endl;
    else {
        alphabet.insert(30);
        for (int i = 0; i < 26; i++) {
            if (alphabet.end() == alphabet.find(i)) {
                x = i + 'a';
                cout << x << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 512
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
// #define ONLINE_JUDGE
#define inf 0x3f3f3f3f
#define mod
#define maxm
#define maxn
ll s[200010];
int main()
{/*
	#ifdef ONLINE_JUDGE
    	freopen("aplusb.in", "r", stdin);
    	freopen("aplusb.out", "w", stdout);
	#endif*/
	// ios::sync_with_stdio(false);
	int n, x;
	
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &x);
		s[i] = s[i - 1] + x;
	}
	ll ans = 0x3f3f3f3f3f3f3f3f;
	for (int i = 1; i < n; i++) {
		ans = min(ans, abs(s[n] - s[i] - s[i]));
	}
	printf("%lld\n", ans);
}


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

int card[255][14] = {{0}};

int main(void){
    int n;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        char c; /*文字コードは0~255*/
        int num;
        cin >> c >> num;
        card[(int)c][num] = 1; //発見
    }
    
    /*Sを探す*/
    for(int i =1; i <= 13; i++){
        if(card[(int)'S'][i] == 0){
            cout << "S" << " " << i << endl;
        }
    }
    for(int i =1; i <= 13; i++){
        if(card[(int)'H'][i] == 0){
            cout << "H" << " " << i << endl;
        }
    }
    for(int i =1; i <= 13; i++){
        if(card[(int)'C'][i] == 0){
            cout << "C" << " " << i << endl;
        }
    }
    for(int i =1; i <= 13; i++){
        if(card[(int)'D'][i] == 0){
            cout << "D" << " " << i << endl;
        }
    }
}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n, 0);
    for(int i=0;i<n;++i){
        cin >> h[i];
    }

    vector<ll> dp(n, 1LL<<60);
    dp[0] = 0;
    for(int i=0;i<n;++i) {
        for(int ki=1;ki<=k&&i+ki<n;++ki) {
            dp[i+ki] = min(dp[i+ki], dp[i]+abs(h[i+ki]-h[i]));
        }
    }

    cout << dp[n-1] << endl;
}

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

int size, list[500001];

void swap(int* a, int* b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void maxheapify(int i) {
	int l = i * 2;
	int r = i * 2 + 1;

	int largest_value;
	if (l <= size && list[l] > list[i]) largest_value = l;
	else largest_value = i;
	if (r <= size && list[r] > list[largest_value]) largest_value = r;
	if (largest_value != i) {
		swap(&list[i], &list[largest_value]);
		maxheapify(largest_value);
	}


	/*
	1  maxHeapify(A, i)
2      l = left(i)
3      r = right(i)
4      // select the node which has the maximum value
5      if l ≤ H and A[l] > A[i]
6          largest = l
7      else
8          largest = i
9      if r ≤ H and A[r] > A[largest]
10         largest = r
11
12     if largest ≠ i　// value of children is larger than that of i
13         swap A[i] and A[largest]
14         maxHeapify(A, largest) // call recursively
	*/

}

void buildmaxheap() {
	/*
	1 buildMaxHeap(A)
2    for i = H/2 downto 1
3        maxHeapify(A, i)

	*/
	for (int i = size / 2; i > 0; i--) {
		maxheapify(i);
	}

}

int main() {
	int i, j;
	scanf("%d", &size);

	//scanning
	for (i = 1; i <= size; i++) {
		scanf("%d", &list[i]);
	}

	buildmaxheap(size);


	//printing
	//printing
	for (i = 1; i <= size; i++) {
		printf(" %d", list[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 3656
D_T_S = list(map(int, input().rstrip().split()))

targetPos = D_T_S[0]
time_Limit = D_T_S[1]
velocity = D_T_S[2]

arrival_time = targetPos / velocity
if (arrival_time > time_Limit):
    print("No")
else:
    print("Yes")

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

int main() {
    int n,a[110];
    bool ok = true;
    cin >> n;
    for(int i=0;i<n;i++)cin >> a[i];

    for(int i=0;i<n;i++){
        if(a[i] % 2 == 0){
            if(!(a[i] % 3 == 0 || a[i] % 5 == 0))ok = false;
        }
    }
    if(ok)cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << (n/2*(n/2+(n%2))) << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/nikkei2019-qual/tasks/nikkei2019_qual_d
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

struct AdjacencyListGraph : public vector<vector<int>> {
  AdjacencyListGraph(int V) : vector<vector<int>>(V) {}
  void addDiEdge(int from, int to) { at(from).push_back(to); }
  void addBiEdge(int v, int w) { addDiEdge(v, w); addDiEdge(w, v); }
};

struct DFSOrder {
  int V, curPre, curPost, curRevPost;
  vector<int> preInd, postInd, revPostInd, preVert, postVert, revPostVert;
  template <class Graph> void dfs(const Graph &G, int v) {
    preVert[preInd[v] = curPre++] = v;
    for (int w : G[v]) if (preInd[w] == -1) dfs(G, w);
    postVert[postInd[v] = curPost++] = v;
    revPostVert[revPostInd[v] = curRevPost--] = v;
  }
  template <class Graph> DFSOrder(const Graph &G, const vector<int> &roots)
      : V(G.size()), curPre(0), curPost(0), curRevPost(V - 1), preInd(V, -1),
        postInd(V), revPostInd(V), preVert(V), postVert(V), revPostVert(V) {
    for (int v : roots) if (preInd[v] == -1) dfs(G, v);
  }
  template <class Graph> DFSOrder(const Graph &G, int rt)
      : DFSOrder(G, vector<int>{rt}) {}
};

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> inDeg(N, 0), par(N, -1);
  AdjacencyListGraph G(N);
  for (int i = 0; i < N - 1 + M; i++) {
    int a, b;
    cin >> a >> b;
    G.addDiEdge(--a, --b);
    inDeg[b]++;
  }
  int root = -1;
  for (int i = 0; i < N; i++) if (inDeg[i] == 0) root = i;
  assert(root != -1);
  for (int i = 0; i < N; i++) if (inDeg[i] == 0) assert(root == i);
  DFSOrder dfs(G, root);
  for (int i = 0; i < N; i++) {
    sort(G[i].begin(), G[i].end(), [&] (const int &i, const int &j) {
      return dfs.revPostInd[i] < dfs.revPostInd[j];
    });
  }
  function<void(int, int)> makeTree = [&] (int v, int prev) {
    par[v] = prev;
    for (int w : G[v]) if (par[w] == -1) makeTree(w, v);
  };
  makeTree(root, -1);
  for (int i = 0; i < N; i++) cout << (par[i] + 1) << nl;
  return 0;
}


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

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

  bool f[1001001] = {false};
  for (char c : s) f[c] = true;
  for (char c = 'a'; c <= 'z'; ++c) {
    if (f[c]) continue;
    cout << c << endl;
    return 0;
  }

  cout << "None" << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin>>S;
  int N=S.size();

  vector<vector<ll>> dp(13,vector<ll>(N,0));

  reverse(ALL(S));
  if(S[0]=='?'){
    for(int i=0;i<10;i++){
      dp[i][0]=1ll;
    }
  }else{
    dp[(int)S[0]-48][0]=1ll;
  }


  vector<ll> mo(N);
  mo[0]=1;
  for(int i=1;i<N;i++){
    mo[i]=(mo[i-1]*10)%13;
    if(S[i]=='?'){
      for(int j=0;j<10;j++){
        int tmp=mo[i]*j%13;
        for(int k=0;k<13;k++){
          dp[(k+tmp)%13][i]+=dp[k][i-1];
          dp[(k+tmp)%13][i]%=MOD;
        }
      }
    }else{
      int tmp=mo[i]*((int)S[i]-48)%13;
      for(int j=0;j<13;j++){
        dp[(j+tmp)%13][i]+=dp[j][i-1];
        dp[(j+tmp)%13][i]%=MOD;
      }
    }
  }
  cout<<dp[5][N-1]<<endl;
}


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

int main(){
//srandom((unsigned long)time(NULL));
long long l,r;
cin>>l>>r;
//l,,,,,,r,,,2018
//l,,,,2018,,,r
long long L,R;
for(int i=0;i<2019;i++){
    if((l+i)%2019==2018){
        cout<<0<<endl;
        return 0;
        break;
    }
    if(l+i==r){
        L=l%2019;
        R=(L+1)%2019;
        break;
    }
}

// cout<<(L*R)%2019<<endl;

l=l%2019;
r=r%2019;
long long is;
long long ans;
long long b;
 
if(l>r){
    is=r;
    r=l;
    l=is;
}
 
ans=(r*l)%2019;
 
for(long long i=l;i<r;i++){
    for(int j=i+1;j<=r;j++){
        i=i%2019;
        j=j%2019;
        b=(i*j)%2019;
        ans=min(ans,b);
    }
}
    cout<<ans<<endl;


return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
    a.append(input())
b=[]
flag=0
for i in range(n):
    s=a[i]
    if i!=0:
        if s[0]!=last:
            flag=1
    last=s[len(s)-1]
    if s in b:
        flag=1
        break
    b.append(s)
    
    
if flag==1:
    print("No")
else:
    print("Yes")

        
    

Measured memory_bytes: 3060
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let s: String = scan(tokens);
    let bytes = s.as_bytes();
    let mut count = 0;
    for i in 2..n {
        if bytes[i - 2] == b'A' && bytes[i - 1] == b'B' && bytes[i] == b'C' {
            count += 1;
        }
    }
    println!("{}", count);
}

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

int maxHappiness(int *a,int *b,int *c,int n){
    int dp[n][3];
    memset(dp,-1,sizeof(dp));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i=1;i<n;i++){
        dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
    }
    return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

int main() {
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }
    cout<<maxHappiness(a,b,c,n);

    return 0;
}

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

int N, K;

void solve()
{
  if (K == 1) {
    cout << 0 << endl;
  }
  else {
    cout << N - K << endl;
  }
}

int main(void)
{
  cin >> N >> K;
  solve();
  return 0;
}


Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        long[] a = Read.Longs();
        long[,] x = new long[a[1],2];
       List<long> Start = new List<long> { };
        HashSet<long> End = new HashSet<long> { };
        for (long i = 0; i < a[1]; i++)
        {
            long[] sd = Read.Longs();
            //    x[i, 0] = sd[0];
            //  x[i, 1] = sd[1];
            if (sd[1] == a[0]) { Start.Add(sd[0]); }
            if (sd[0] == 1) { End.Add(sd[1]); }
        }
        for(int i = 0; i < Start.Count(); i++)
        {
            if (!End.Add(Start[i])) { Console.WriteLine("POSSIBLE"); return; }
        }
        Console.WriteLine("IMPOSSIBLE");
        Console.ReadLine();
    }

    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] Longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 33172
/*ex4_2
 Sweet_Sweet_Soul */

#include <stdio.h>
#include <math.h>
#define PI 3.141592653589

int main(void) {
    double h_hand,m_hand,hour,minute;
    scanf("%lf",&h_hand);
    scanf("%lf",&m_hand);
    scanf("%lf",&hour);
    scanf("%lf",&minute);
    double h_arg=(PI*hour/6)+(PI*minute/360);/*短針のテッペンからの回転度*/
    double m_arg=PI*minute/30;
    double arg=h_arg-m_arg;/*針のなす角*/
    double ans=m_hand*m_hand+h_hand*h_hand-2*m_hand*h_hand*cos(arg);/*A^2+B^2-2ABcosθ*/
    ans=sqrt(ans);/*余弦定理*/
    printf("%.10f\n",ans);/*下10桁出力*/
    return 0;
}


Measured memory_bytes: 2600
#include <cstdio>

int main(){
    int n,m,l;
    scanf("%d%d%d",&n,&m,&l);
    long a[n][m];
    long b[m][l];
    long c[n][l];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            a[i][j] = 0;
            scanf("%ld",&a[i][j]);
        }
    }
    for(int i = 0;i < m;i++){
        for(int j = 0;j < l;j++){
            b[i][j] = 0;
            scanf("%ld",&b[i][j]);
        }
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < l;j++){
            c[i][j] = 0;
            for(int k = 0;k < m;k++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < l;j++){
            printf("%ld",c[i][j]);
            if(j != l - 1){
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2788
N = int(input())
A = [int(input()) for k in range(N)]
A = sorted(A)
k = N//2
if N%2 == 1:
    print(max(-2*sum(A[:k])+sum(A[k:k+2])+2*sum(A[k+2:]),-2*sum(A[:k-1])-sum(A[k-1:k+1])+2*sum(A[k+1:])))
else:
    print(-2*sum(A[:k-1])-A[k-1]+A[k]+2*sum(A[k+1:]))


Measured memory_bytes: 52056
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;


public class Main {
    static Scanner s = new Scanner(System.in);
    static int W, H;
    static int[][] maze;
    static Queue<Param> array = new LinkedList<Param>();

    static class Param {
        int x, y, route;

        Param(int x, int y, int route) {
            this.x = x;
            this.y = y;
            this.route = route;
        }
    }

    public static void main(String[] args) {

        while (true) {
            W = s.nextInt();
            H = s.nextInt();

            if (W == 0 && H == 0) break;

            maze = new int[H * 2+1][W * 2+1];

            for (int i = 1; i < H * 2; i++) {
                int j = 1;
                if (i % 2 == 1) j++;
                for (; j < W * 2; j += 2) {
                    int temp = s.nextInt();
                    if (temp == 0) maze[i][j] = 0;
                    else maze[i][j] = -1;
                }
            }

            array.add(new Param(1, 1, 0));
            while (!array.isEmpty()) {
                Param temp;
                temp = array.poll();
                search(temp.x, temp.y, temp.route);
            }

            System.out.println(maze[H*2-1][W*2-1]);

        }
    }

    static void search(int x, int y, int route) {
        if (x < 1 || x >= W * 2 || y < 1 || y >= H * 2) return;
//        if (maze[y][x] == -1) return;
        if (maze[y][x] > 0) return;
        maze[y][x] = route + 1;


        if (maze[y][x + 1] == 0)
            array.add(new Param(x + 2, y, route + 1));
        if (maze[y][x - 1] == 0)
            array.add(new Param(x - 2, y, route + 1));
        if (maze[y + 1][x] == 0)
            array.add(new Param(x, y + 2, route + 1));
        if (maze[y - 1][x] == 0)
            array.add(new Param(x, y - 2, route + 1));
    }
}

Measured memory_bytes: 67736
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,m,s;
	while(cin>>n>>m>>s,n){
		int N=n*n;
		vvi dp(N+1,vi(s+1));
		dp[0][0]=1;
		loop(k,1,m+1)for(int i=N-1;i>=0;i--)rep(j,s){
			if(j+k>s)continue;
			dp[i+1][j+k]+=dp[i][j];
			dp[i+1][j+k]%=100000;
		}
		cout<<dp[N][s]<<endl;
	}
}

Measured memory_bytes: 1796
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int ans = k / 2;
		if (ans % 2 == 0) {
			System.out.println(ans * ans);
		} else {
			System.out.println((int)Math.ceil((double)k/2) * ans);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

ll pow1(ll a, ll b, ll m = mod)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2, m);
		x *= x;
		x %= m;
		if (b%2)
		{
			x *= a;
			x %= m;
		}
		return x;
	}
}

template <class avgType>
avgType avg(avgType a, avgType b) {
	return (a + b)/2;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());

int randInt() {
	return rng() % INT_MAX;
}

ll randLL() {
	return rng64() % LLONG_MAX;
}

vector< int > hashmods = {1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093};

int h, w, grid[11][1100], K;
char c;

int main() {
	fastio;
	cin>>h>>w>>K;

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin>>c;
			grid[i][j] = (c == '1');
		}
	}

	int ans = 1e9;

	for (int i = 0; i < (1<<(h-1)); i++) {
		vi v;
		for (int j = 0; j < h-1; j++) {
			if (i & (1<<j)) {
				v.pb(j+1);
			}
		}

		int num[11] = {0};
		int curr = __builtin_popcount(i);
		for (int j = 1; j <= w; j++) {
			int p1 = 0;
			for (int k = 1; k <= h; k++) {
				if (p1 < v.size() and k > v[p1]) {
					p1++;
				}
				num[p1] += grid[k][j];
			}

			int cut = 0;
			for (int p2 = 0; p2 <= v.size(); p2++) {
				if (num[p2] > K) {
					cut = 1;
					break;
				}	
			}

			if (cut) {
				curr++;
				for (int p2 = 0; p2 <= v.size(); p2++) {
					num[p2] = 0;
				}

				p1 = 0;
				for (int k = 1; k <= h; k++) {
					if (p1 < v.size() and k > v[p1]) {
						p1++;
					}
					num[p1] += grid[k][j];
					if (num[p1] > K) {
						curr = 1e9;
						break;
					}
				}
			}
		}

		ans = min(ans, curr);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())printf("%d ",v[_]);cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

int n,MOD=1000000007;
vvi G;
pii dfs(int a,int p){
	pii t={1,1};
	rep(i,G[a].size())if(G[a][i]-p){
		pii w=dfs(G[a][i],a);
		(t.first*=w.second)%=MOD;
		(t.second*=w.first+w.second)%=MOD;
	}
	return t;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>n;
	G=vvi(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	pii t=dfs(0,-1);
	cout<<(t.first+t.second)%MOD<<endl;
}


Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>

#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    
    string t;
    
    cin >> t;
    
    for(int i = 0; i < t.length(); i++)
    {
        if(t[i] == '?')
        {
            if(i != t.length() - 1)
            {
                if(t[i + 1] == 'D' || t[i + 1] == '?')
                {
                    if(i && t[i - 1] == 'P')
                    {
                        t[i] = 'D';
                    }
                    else
                    {
                        t[i] = 'P';
                    }
                }
                else
                {
                    t[i] = 'D';
                }
            }
            else
            {
                t[i] = 'D';
            }
        }
    }
    
    cout << t;
    

}

Measured memory_bytes: 3720
while True:
	data=list(map(int,input().split()))
	if data[0]==data[1]==data[2]==-1: break
	
	if data[0]!=-1 and data[1]!=-1:
		sum=data[0]+data[1]
	if data[2]!=-1 and sum<data[2]:
		if data[2]>=50:
			sum=50
		
	if data[0]==-1 or data[1]==-1:
		print('F')
	elif sum<30 :
		print('F')
	elif 30<=sum<50:
		print('D')
	elif 50<=sum<65:
		print('C')
	elif 65<=sum<=79:
		print('B')
	elif 80<=sum:
		print('A')
		
	

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  vector<vector<int>> f(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i + j == 0) {
        f[0][0] = (s[0][0] == '#');
      } else {
        f[i][j] = (int) 1e9;
        if (i > 0) f[i][j] = min(f[i][j], f[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#'));
        if (j > 0) f[i][j] = min(f[i][j], f[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#'));
      }
    }
  }
  cout << f[h - 1][w - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <memory.h>
#include <cstring>
#include <set>
#include <algorithm>
using namespace std;


const int maxn = 200200;

pair<int, int> edge[maxn];

int main() {
    int W, H;
    while(scanf("%d%d", &W, &H) != EOF) {
        int tot = 0;
        for(int i = 0; i < W; i ++) {
            int a; scanf("%d", &a);
            edge[tot ++] = make_pair(a, 0);
        }

        for(int i = 0; i < H; i ++) {
            int a; scanf("%d", &a);
            edge[tot ++] = make_pair(a, 1);
        }
        sort(edge, edge + tot);
        long long ans = 0;
        int len[2] = {H + 1, W + 1};
        for(int i = 0; i < tot; i ++) {
            int a = edge[i].first, type = edge[i].second;
            ans += 1ll * a * len[type];
            len[type ^ 1] --;
        }
        cout << ans << endl;
    }
    return 0;
}

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

using ll = long long;
const int MAXN = 100005;
const ll INF = (ll)1e9;

int main() {
#ifdef LOCAL_PROJECT
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif

    ll n, k;
    cin >> n >> k;
    ll ans = (n / k) * (n / k) * (n / k);
    if (k % 2 == 0) {
        ll dbl = n / k + 1;
        ll rest = n % k;
        if (rest < k / 2 && dbl > 0) {
            --dbl;
        }
        ans += dbl * dbl * dbl;
    }
    cout << ans;
    return 0;
}


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

#define dump(a) (cerr << #a << " = " << (a) << endl)

#define REP(i,a,b) for(int i=(a);i < (int)(b); i++)
#define rep(i,n) REP(i,0,n)
#define ALL(v) begin(v), end(v)

enum FACE {SOUTH, EAST, TOP, BOTTOM, WEST, NORTH};

typedef array<int, 6> A;

struct dice {
  A value;

  dice(const A &value_):value(value_) {}

  void roll(FACE a, FACE b, FACE c, FACE d) {
    const int t = value[a];
    value[a] = value[b];
    value[b] = value[c];
    value[c] = value[d];
    value[d] = t;
  }

  int operator[](const int f) const { return value[f]; }

  void north() { roll(TOP, SOUTH, BOTTOM, NORTH); }
  void south() { roll(TOP, NORTH, BOTTOM, SOUTH); }
  void east()  { roll(TOP, WEST,  BOTTOM, EAST ); }
  void west()  { roll(TOP, EAST,  BOTTOM, WEST ); }
  void ccw()   { roll(NORTH, EAST, SOUTH, WEST ); }
  void cw()    { roll(NORTH, WEST, SOUTH, EAST ); }
};

int ans;
int n;
vector<dice> dies;

int calc() {
  int res = 0;
  for(int i = 0; i < 6; ++i) {
    unordered_map<int, int> cnt;
    for(const auto &d : dies) {
      ++cnt[d[i]];
    }

    int mx = 0;
    for(const auto &e : cnt) {
      mx = max(mx, e.second);
    }

    res += n - mx;
  }

  return res;
}

void dfs(int idx) {
  if(idx == n) {
    ans = min(ans, calc());
    return;
  }

  for(int i = 0; i < 4; ++i) {
    for(int j = 0; j < 4; ++j) {
      dies[idx].north();
      dfs(idx + 1);
    }

    dies[idx].ccw();
  }

  dies[idx].east();
  for(int i = 0; i < 2; ++i) {
    for(int j = 0; j < 4; ++j) {
      dies[idx].north();
      dfs(idx + 1);
    }
    dies[idx].ccw();
    dies[idx].ccw();
  }
}

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

  while(cin >> n && n) {
    unordered_map<string, int> enc;
    dies.clear();

    for(int i = 0; i < n; ++i) {
      A value;
      for(auto &e : value) {
	string s;
	cin >> s;

	if(!enc.count(s)) enc.insert({s, enc.size()});
	e = enc[s];
      }

      dies.emplace_back(value);
    }

    ans = INT_MAX;
    dfs(1);

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1232