akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 200010
#define int long long
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct node
{
	int x,y,id;
}P[N];
int n,a,b,size[N],fa[N],cnt[N],stt;
inline bool operator <(const node a,const node b)
{
	return a.x==b.x? a.y<b.y: a.x<b.x;
}
inline bool operator <=(const node a,const node b)
{
	return a.x==b.x? a.y<=b.y: a.x<=b.x;
}
inline bool operator ==(const node a,const node b)
{
	return a.x==b.x&&a.y==b.y;
}
inline int getfa(int x)
{
	return x==fa[x]? x:fa[x]=getfa(fa[x]);
}
inline void uni(int x,int y,int pls)
{
	int f1=getfa(x), f2=getfa(y);
	if(f1==f2) size[f1]+=pls;
	else fa[f1]=f2,size[f2]+=size[f1]+pls;
}
inline void solve(int td)
{
	memset(cnt,0,sizeof cnt);
	for(int i=1,L=1,R=0;i<=n;i++)
	{
		while(L<=n&&P[L]<(node){P[i].x-stt,P[i].y-stt+td,0}) L++;
		while(R<n&&P[R+1]<=(node){P[i].x-stt,P[i].y+stt-td,0}) R++;
		if(L<=R) uni(P[i].id,P[L].id,1), cnt[L]++, cnt[R]--;
	}
	for(int i=1;i<=n;i++)
		if(cnt[i]+=cnt[i-1]) uni(P[i].id,P[i+1].id,cnt[i]);
}
signed main()
{
	n=read(); a=read(); b=read();
	for(int i=1;i<=n;i++)
	{
		int x=read(), y=read();
		P[i].x=x-y; P[i].y=x+y; P[i].id=i;
	}
	for(int i=1;i<=n;i++) fa[i]=i, size[i]=0;
	stt=max(abs(P[a].x-P[b].x),abs(P[a].y-P[b].y));
	sort(P+1,P+1+n); solve(0);
	for(int i=1;i<=n;i++) swap(P[i].x,P[i].y);
	sort(P+1,P+1+n);
	solve(1);
	cout << size[getfa(a)] << endl;
	return 0;
}


Measured memory_bytes: 8448
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int n,r=0,g=0,b=0;
    char s[4002] = {};
    long sum=0;

    cin >> n;

    rep(a, n) {
        cin >> s[a+1];
        if (s[a+1] == 'R') {
            r++;
        }
        else if (s[a+1] == 'G') {
            g++;
        }
        else if (s[a+1] == 'B') {
            b++;
        }
    }

    for (int k = 3; k <= n; k++) {
        for (int j = (k+1+(k+1)%2)/2; j < k; j++) {
            if (s[2 * j - k] != s[j] && s[2 * j - k] != s[k] && s[k] != s[j])sum++;
        }
    }
    sum = (long)r * g * b - sum;

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3604
Modoneprime = []
import math

for i in range (1, 11110):
	count = 0
	k = 5*i + 1
	for j in range (2, math.floor(math.sqrt(k))+1):
		if k%j ==0:
			count+=1
	if count > 0:
		continue
	else:
		Modoneprime.append(k)

N = int(input())

print(*Modoneprime[0:N])

Measured memory_bytes: 3060
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
void fo (){fflush(stdout);}
using namespace std;
int main ()
{
  int n ;
  cin >> n ;
  int T , px , py ;
  T = px = py = 0 ;
  bool ok = 1;
  for (int i =0 ; i < n ;i++)
  {
    int t , x , y ;
    cin >> t >> x >> y ;
    int Time = t - T ;
    int steps = abs (x - px ) + abs (y - py );
    T = t ;
    px = x ;
    py = y ;
    if (steps > Time )
    {
      ok = 0;break;
    }else if (steps == Time )
    {
      continue ;
    }else
    {
      Time -= steps ;
      if (Time % 2 )
      {
        ok = 0 ;
        break;
      }
    }
  }
  if (ok)printf ("Yes\n");
  else
  printf ("No\n"); 
  //cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;

}


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

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n, d;
  cin >> n >> d;
  int ans = (n - 1) / (d * 2 + 1) + 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
U = 2*10**5
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
two = [1]*(U+1)
two_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
    two[i] = (two[i-1]*2)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
two_inv[U] = pow(two[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD
    two_inv[i-1] = (two_inv[i]*2)%MOD

def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z %= MOD
    z *= fact_inv[n-k]
    z %= MOD
    return z
  
B, W = map(int, input().split())
p = 0
q = 0
for i in range(1, B+W+1):
  ans = 1 - p + q
  ans %= MOD
  ans *= two_inv[1]
  ans %= MOD
  print(ans)
  p += comb(i-1, B-1) * two_inv[i] % MOD
  p %= MOD
  q += comb(i-1, W-1) * two_inv[i] % MOD
  q %= MOD

Measured memory_bytes: 36796
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 105
ll n,w;
ll wgt[maxi],val[maxi];
const ll mwt=1e5+5;
ll memo[maxi][mwt];
ll solve(ll pos,ll pwgt)
{
	if(pwgt>w)
		return minf;
	if(pos==n)
	{
		return 0;
	}
	if(memo[pos][pwgt]!=-1)
		return memo[pos][pwgt];
	ll ans=minf;
	ans=max(solve(pos+1,pwgt),solve(pos+1,pwgt+wgt[pos])+val[pos]);
	memo[pos][pwgt]=ans;
	return ans;
}
int main()
{
    fastread;
    cin>>n>>w;
    for(ll i=0;i<maxi;i++)
    	for(ll j=0;j<mwt;j++)
    		memo[i][j]=-1;
    for(ll i=0;i<n;i++)
    	cin>>wgt[i]>>val[i];
    cout<<solve(0,0)<<endl;
    return 0;
}

Measured memory_bytes: 82304
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
R,S,P = [int(x) for x in stdin.readline().rstrip().split()]
T = (stdin.readline().rstrip())
sub = [""]*K
for ind,i in enumerate(T):
    sub[(ind+1)%K] += i

ans = 0

for j in sub:
    former = ""
    for s in j:
        if s == "r":
            p = P
        elif s == "s":
            p = R
        else:
            p = S
        
        if s != former:
            ans += p
            former = s
        else:
            former = ""
            
print(ans)

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

int main() {
    string str;

    while (true) {
        getline(cin, str);
        if (str == ".") break;

        bool flag=true;
        for (int i=str.size()-1; i>=0; --i) {
            if (str[i] == '(' or str[i] == '[') {
                int t=(str[i] == '(' ? 1 : 0);
                str[i]='.';
                flag=false;
                for (int j=i+1; j<str.size(); ++j) {
                    if (str[j] == ')' and t) {
                        str[j]='.';
                        flag=true;
                        break;
                    }
                    else if (str[j] == ')' and !t) {
                        break;
                    }
                    else if (str[j] == ']' and !t) {
                        str[j]='.';
                        flag=true;
                        break;
                    }
                    else if (str[j] == ']' and t) {
                        break;
                    }
                }
            }
            if (!flag) break;
        }

        rep(i, str.size()) {
            if (str[i] == '(' or str[i] == ')' or str[i] == '[' or str[i] == ']') flag=false;
        }

        cout << (flag ? "yes" : "no") << endl;
    }

}

Measured memory_bytes: 3144
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1,N):
    A[i] += A[i-1]
for i in range(1,M):
    B[i] += B[i-1]
SA = [0] + A
SB = [0] + B
def search(rest, arr):
    l = 0
    r = len(arr)
    while (r-l) > 1:
        mid = (r+l)//2
        if arr[mid] <= rest:
            l = mid
        else:
            r = mid
    return l
ans = 0
for i in range(N+1):
    if SA[i] > K: continue
    cnt = i
    rest = K-SA[i]
    cnt += search(rest, SB)
    # print(rest, cnt, i, search(rest, SB))
    ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 40452
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	sc.close();
    	int[] cnt = new int[2];
    	for(int i = 0; i < S.length(); i++){
    		cnt[S.charAt(i) - '0']++;
    	}
    	System.out.println(Math.min(cnt[0], cnt[1]) * 2);
    }
}

Measured memory_bytes: 25172
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner sc = null;
        try {
            sc = new Scanner(System.in);
            while (sc.hasNextBigDecimal()) {

                BigDecimal a = sc.nextBigDecimal();
                BigDecimal b = sc.nextBigDecimal();
                int n = sc.nextInt();

                // divide
                String aDivideB = String.valueOf(a.divide(b, n,
                        RoundingMode.DOWN));

                // add
                char[] array = aDivideB.substring(aDivideB.indexOf(".") + 1)
                        .toCharArray();
                int s = 0;
                for (char c : array) {
                    s += Integer.parseInt(String.valueOf(c));
                }

                System.out.println(s);
            }
        } finally {
            sc.close();
        }
    }

}

Measured memory_bytes: 28692
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a = inpl()
a.sort()
b = (a[1]-a[0]) // 2
c = a[2] - a[1]
if (a[1] - a[0]) % 2 == 0:
    print(b + c)
else:
    print(b + c + 2)

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

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

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

typedef long long ll;
typedef vector<vector<long long> > Matrix;

const ll INF = numeric_limits<long long>::max();
Matrix d;

ll V, E;

void warshall_floyd(){
  for (ll i = 0; i < V; i++) {
    for (ll j = 0; j < V; j++) {
      if (d[j][i]==INF) continue;
      for (ll k = 0; k < V; k++) {
        if (d[i][k]==INF) continue;
        d[j][k] = min(d[j][k], d[j][i]+d[i][k]);
      }
    }
  }
}

int main(int argc, char const *argv[]) {
  cin >> V >> E;
  d = Matrix(V, vector<ll>(V,INF));
  for (ll i = 0; i < V; i++) d[i][i] = 0;
  for (ll i = 0; i < E; i++) {
    ll s, t, dist;
    cin >> s >> t >> dist;
    d[s][t] = dist;
  }
  warshall_floyd();

  bool negative = false;
  for (ll i = 0; i < V; i++) if (d[i][i] < 0) negative = true;
  if (negative) cout << "NEGATIVE CYCLE" << endl;
  else {
    for (ll i = 0; i < V; i++) {
      for (ll j = 0; j < V; j++) {
        if (d[i][j]==INF) cout << "INF";
        else cout << d[i][j];
        if (j<V-1) cout << ' ';
      }
      cout << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    vi vec(3);
    REP(i,3){
        cin>>vec[i];
    }
    int ans=0;
    sort(all(vec));
    do{
        chmax(ans,vec[0]*10+vec[1]+vec[2]);
        chmax(ans,vec[0]+vec[1]*10+vec[2]);
    }while(next_permutation(all(vec)));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

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

template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }


int main()
{
    using namespace std;

    int n, m;
    cin >> n >> m;

    vec<int> b(n), target(n);
    vec<int> p(m);
    
    for (auto& e : b)
        cin >> e;

    for (int i = 0, current = 0, index = 0; i < m; ++i)
    {
        int in;
        cin >> in;

        for (int i = 0; i < in; ++i)
        {
            target[index + i] = current;
        }
        index += in;

        current ^= 1;
    }

    vec<int> posB, posT, posT_;

    for (int i = 0; i < n; ++i)
    {
        if (b[i] == 1)
            posB.push_back(i);
        if (target[i] == 1)
            posT.push_back(i);
        else
            posT_.push_back(i);
    }

    while (posB.size() < n)
    {
        posB.push_back(1000000);
    }

    while (posT.size() < posB.size())
    {
        posT.push_back(1000000);
    }
    while (posT_.size() < posB.size())
    {
        posT_.push_back(1000000);
    }

    int ans1{}, ans2{};

    for (int i = 0; i < posB.size(); ++i)
    {
        ans1 += abs(posB[i] - posT[i]);
        ans2 += abs(posB[i] - posT_[i]);
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}


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

const int INF = 1e9;
const int MOD = 998244353;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

ll powmod(ll n, ll x)
{
    vector<ll> vll(32);
    vll[0] = n;
    FOR(i, 1, 32)
    {
        vll[i] = (vll[i - 1] * vll[i - 1]) % MOD;
    }
    ll ret = 1;
    int cnt = 0;
    while (x > 0) {
        if (x & 1) {
            ret = (ret * vll[cnt]) % MOD;
        }
        x >>= 1;
        cnt++;
    }
    return ret;
}

long long fac[2000001];
struct Comb {
    Comb()
    {
        fac[0] = fac[1] = 1;
        for (int i = 2; i < 2000001; i++) {
            fac[i] = fac[i - 1] * i % MOD;
        }
    }

    long long COM(int n, int k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        ll ret = fac[n];
        ret = (ret * powmod(fac[k], MOD - 2)) % MOD;
        ret = (ret * powmod(fac[n - k], MOD - 2)) % MOD;
        return ret;
    }

    ll PERM(int n, int k)
    {
        if (n < k)
            return 0;
        ll ret = fac[n];
        ret = (ret * powmod(fac[n - k], MOD - 2)) % MOD;
        return ret;
    }
};

int main()
{
    int N, M, K;
    cin >> N >> M >> K;
    Comb C;
    ll ans = 0;
    REP(i, K + 1)
    {
        ll b = M * powmod(M - 1,N - 1 - i);
        b %= MOD;
        b *= C.COM(N - 1, i);
        b % MOD;
        ans += b;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 19268
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val values = Array.fill(5)(sc.nextInt())
    val (justs, notJusts) = values.partition(_ % 10 == 0)
    if (notJusts.nonEmpty) {
      val sorted = notJusts.sortBy(_ % 10)
      val head = sorted.head
      val tail = sorted.tail.map(_ / 10 * 10 + 10).sum
      println(justs.sum + head + tail)
    } else
      println(justs.sum)
  }

}

Measured memory_bytes: 25792
use proconio::input;

fn main() {
    input! {
        x: i64,
        y: i64,
    }

    for tsuru in 0..=x {
        let kame = x - tsuru;
        if tsuru * 2 + kame * 4 == y {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


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

  int N ;
  int ans = 0 ;
  int count = 0 ;
  cin >> N ;
  vector<int> A(N) ;
  string S ;
  cin >> S ;
  rep(i,N){
    if(S.at(i) == 'E' ) A.at(i) = 1 ;
    else A.at(i) = 0 ;
  }
  for(int i = 1; i < N ; i++ ) ans += A.at(i) ;
  //cout << ans << endl ;
  count = ans ;
  //cout << 1 << "人目がリーダの時" << ans <<"人向き変更" << endl;
  for(int i = 1 ; i < N ; i++){
	if( S.at(i-1) == 'W' )ans++ ;
    if( S.at(i)   == 'E' )ans-- ;
    //cout << i+1 << "人目がリーダの時" << ans <<"人向き変更" << endl;
    count  = min(ans,count);
  }
    cout << count << endl;
}

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

int main() {
	int n, m; cin >> n >> m;
	vector< pair<int, int>>ab;
	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		ab.push_back(make_pair(a, b));
	}
	sort(ab.begin(), ab.end());

	long long ans = 0, cnt = 0;
	for (int i = 0; i < n; i++) {
		cnt += ab[i].second;		
		if (cnt >= m) {
			ans += (m - (cnt - ab[i].second)) * ab[i].first;
			break;
		}
		ans += (long long)ab[i].first * ab[i].second;
	}
	cout << ans << endl;

	return 0;
}

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

int max(int x, int y) {
  return (x >= y) ? x : y;
}

int min(int x, int y) {
  return (x <= y) ? x : y;
}

int main() {
  int k, x;
  cin >> k >> x;

  int left = max(x - (k - 1), -1000000);
  int right = min(1000000, x + (k - 1));

  for(int i = left; i <= right; i++) cout << i << " ";
  cout << endl;

  return 0;
}

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

int main(){
    long long int n,k;
    cin >> n >> k;
    long long int num = n/k;
    long long int ans1 = abs(n-num*k);
    long long int ans2 = abs(n-(num+1)*k);
    cout << min(abs(ans1),abs(ans2)) << endl;
}


Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  t,i,x,j,k,n,cnt=0;
    string s;
    cin>>n;
    vector<ll> a(n),b(n),c(n);
    for(i=0; i<n; i++)
        cin>>a.at(i);
    for(i=0; i<n; i++)
        cin>>b.at(i);
    for(i=0; i<n; i++)
        cin>>c.at(i);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    // a< b <c
    for(i=0; i<n; i++)
    {
        auto it1=lower_bound(a.begin(),a.end(),b.at(i));
        ll num=it1-a.begin();
        auto it2=upper_bound(c.begin(),c.end(),b.at(i));
        cnt+=num*(c.end()-it2);
    }

    cout<<cnt<<endl;
    return 0;
}





Measured memory_bytes: 5580
s = input().split(" ")
nums = list(map(int, s))
for i in range(2):
    for j in range(i+1, 3):
        if nums[i] > nums[j]:
            w = nums[i]
            nums[i] = nums[j]
            nums[j] = w
for i in range(3):
    if i == 2:
        print(nums[i])
    else:
        print(nums[i], end=" ")

Measured memory_bytes: 7640
#include<iostream>

using namespace std;

int main(){

int a,b;
  
 cin >> a >> b;
  
  if(a>=13){
  cout << b << endl;
  }
  else if(a>=6){
  cout << b/2 <<endl;
  }
  else{
  cout << 0 << endl;
  }
}

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

using namespace std;

int main(){
	int N,W;
	cin >> N >> W;
	vector<long long> w(N),v(N);
	vector<vector<long long> > dp(N,vector<long long>(100001,1e18));
	for(int i = 0; i < N; i++){
		cin >> w[i] >> v[i];
	}
	
	dp[0][v[0]] = w[0];
	for(int i = 0; i < N; i++) dp[i][0] = 0;
	for(int i = 1; i < N; i++){
		
		for(int j = 0; j <= 100000; j++){
			if(j >= v[i]) dp[i][j] = min(dp[i-1][j-v[i]]+w[i], dp[i-1][j]);
			else 	      dp[i][j] = dp[i-1][j];		
		}
	}
	
//	cout << dp[5][17] << endl;
	for(int j = 100000; j>= 0; j--){
		if(dp[N-1][j]>=0 && dp[N-1][j] <= W ){
			cout << j << "\n";
			return 0;
		}
	}
	cout << 0 << "\n";
	return 0;
}


Measured memory_bytes: 79488
#hは行数
#wは列数
#nは正の整数
h,w,k = gets.split.map(&:to_i)
c_c = h.times.map { gets.chomp!.chars }
 
ans = 0
(1 << h).times do |is| #1<<Hは２のH乗=4通りまで調べる => "0" "1" "10" "11"
  (1 << w).times do |js| 
    cnt = 0
    h.times do |i| #なぜまた繰り返す
      w.times do |j|
        next if is >> i & 1 == 1 #is(行が消されていたらnext)
        next if js >> j & 1 == 1 #js(列が消されていたらnext)
        cnt += 1 if c_c[i][j] == '#' #is,jsに消されていないところが"#"ならインクリメント
      end
    end
 
    ans += 1 if cnt == k
  end
end
 
puts ans

Measured memory_bytes: 14320
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    S = input()
    N = len(S)

    stack = deque([])
    for c in S:
        if len(stack) == 0:
            stack.append(c)
            continue

        a = stack.pop()
        if a == c:
            stack.append(a)
            stack.append(c)

    print(N - len(stack))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4716
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_H = 300, MAX_W = 300, MAX_Q = 1e5;
int H, W, D;
int A[MAX_H][MAX_W];
int Q;
int L[MAX_Q], R[MAX_Q];

void input() {
  cin >> H >> W >> D;
  rep(i,H) {
    rep(j,W) {
      cin >> A[i][j];
    }
  }
  cin >> Q;
  rep(i,Q) cin >> L[i] >> R[i];
}

vector<vector<int> > make_table() {
  vector<pii> a(H*W+1);
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      a[A[i][j]] = pii(i, j);
    }
  }

  vector<vector<int> > res(D+1);
  for (int l = 1; l <= D; ++l) {
    int c = 0;
    for (int k = 0; l + D*k <= H*W; ++k) {
      int d = l + D*k;
      int s = (k == 0 ? d : d - D);
      c += abs(a[s].fi - a[d].fi) + abs(a[s].sc - a[d].sc);
      res[l].push_back(c);
    }
  }

  return res;
}

int main() {
  input();

  vector<vector<int> > qt = make_table();

  for (int i = 0; i < Q; ++i) {
    if (1 <= L[i] && L[i] <= D) {
      int s = L[i], d = (R[i]-L[i])/D;
      cout << qt[s][d] << endl;
    } else if (L[i]%D == 0) {
      int s = D, d1 = L[i]/D-1, d2 = R[i]/D-1;
      cout << qt[s][d2] - qt[s][d1] << endl;
    } else {
      int s = L[i]%D, d1 = (L[i]-s)/D, d2 = (R[i]-s)/D;
      cout << qt[s][d2] - qt[s][d1] << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 7040
/*
ID: vantofr1
TASK: friday
LANG: C++

*/
#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define zurbzan
#define MAXPEOPLE 10
using namespace std;
const int MOD = 1e9;
int to_int(string s){
    int x;
    stringstream geek(s);
    geek >> x;
    return x;
}
int prim_const( int x){
    vector<bool> prime(x, true);
    prime[0] = prime[1] = false;
    for (int i=2; i * i<=x; ++i){
        if (prime[i]){
            if (i * 1ll * i <= x){
                for (int j=i*i; j<=x; j+=i){
                    prime[j] = false;
                }
            }
        }
    }
    if (prime[x] == true){
        return 1;
    }else{
        return 0;
    }
}
using namespace std;
unsigned long long int x,y;
int mxn;
int main(){
    double n,k;
    cin >> n >> k;
    if (k >= n && k != 1 && n != 1){
        cout << "NO";
    }else if(ceil(n/2) >= k || n == 1 && k == 1){
        cout << "YES";
        }else{
            cout << "NO";
        }
}


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

int main() {
  int n;
  int a;
  int nums = 1;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a;
    if (a == nums) {
      nums++;
    }
  }
  if (nums == 1) cout << -1 << endl;
  else cout << n - nums + 1 << endl;
}

Measured memory_bytes: 256
/*
    Stay motivated and keep working hard
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 1e9 + 7;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n, k;
    cin >> n >> k;
    int dp[n+7];
    for(int i=0;i<n+7;i++){
        dp[i] = INF;
    }
    int h[n+7];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
            if(j < n){
                dp[j] = min(dp[j], abs(h[j] - h[i]) + dp[i]);
            }
        }
    }
    cout << dp[n-1] << "\n";


    return 0;
}

Measured memory_bytes: 1024
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var t = int.Parse(line[0]) * 1000;
        var a = int.Parse(line[1]) * 1000;
        line = Console.ReadLine().Trim().Split(' ');
        var h = Array.ConvertAll(line, int.Parse);
        int ans = int.MaxValue; var ansi = 0;
        for (int i = 0; i < n; i++)
        {
            var w = Abs(t - 6 * h[i] - a);
            if (w < ans) { ans = w; ansi = i; }
        }
        Console.WriteLine(ansi + 1);
    }
}


Measured memory_bytes: 13212
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
#define PI (acos(-1))

constexpr ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

ll lcm(ll x, ll y) {
	return x / gcd(x, y) * y;
}

ll nlcm(vector<int> &nums) {
	ll l = nums[0];
	for (int i = 1; i < nums.size(); i++) {
		l = lcm(l, nums[i]) % MOD;
	}
	return l;
}

vector<pair<ll, ll>> primeFactor(ll n) {
	vector<pair<ll, ll>> res;
	for (ll p = 2; p * p <= n; p++) {
		ll tmp = 0;
		while (n % p == 0) {
			n /= p;
			tmp++;
		}
		if (tmp != 0)
			res.push_back(make_pair(p, tmp));
	}
	if (n != 1)
		res.push_back(make_pair(n, 1));
	return move(res);
}

ll pow_mod(ll x, ll n) {
	ll ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % MOD;
		}
		x = x * x % MOD;
		n = (n >> 1);
	}
	return ans;
}

ll modinv(ll a) {
	ll b = MOD, x = 1, y = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		x -= t * y;
		swap(x, y);
	}
	x %= MOD;
	if (x < 0)
		x += MOD;
	return x;
}

ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;

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

	map<int, int> m;
	for (auto &&a : A) {
		auto pf = primeFactor(a);
		for (auto &&p : pf) {
			if (m.count(p.first) == 0) {
				m[p.first] = p.second;
			} else {
				m[p.first] = max((ll)m[p.first], p.second);
			}
		}
	}

	ll l = 1;
	for (auto &&e : m) {
		l *= (ll)pow_mod(e.first, e.second) % MOD;
		l %= MOD;
	}

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += l * modinv(A[i]) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    int m, d;
    cin >> m >> d;

    int ans = 0;
    for(int month = 1; month <= m; month++){
        for(int i = 10; i <= d ;i++){
            int a = i %10;
            int b = (i/10) % 10;

            if(a >= 2 and b >= 2 and a* b == month)ans++;
        }
    }
    cout << ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,m;
string in[10],d[10][10],ans[10][1<<10];

void MIN(string &a,string b){
	if(a.empty()||a.size()>b.size()||a.size()==b.size()&&a>b)a=b;
}
string solve(){
	rep(i,n)rep(j,1<<n)ans[i][j].clear();
	rep(i,n)ans[i][1<<i]=in[i];
	rep(j,1<<n)rep(i,n)if(j&1<<i)rep(k,n)if(!(j&1<<k))
	MIN(ans[k][j^1<<k],ans[i][j]+d[i][k]);
	string ret;
	rep(i,n)MIN(ret,ans[i][(1<<n)-1]);
	return ret;
}
int main()
{
	while(scanf("%d",&m),m){
		string s[10];
		rep(i,m)cin>>s[i];
		sort(s,s+m); m=unique(s,s+m)-s;
		bool con[10]={0};
		rep(i,m)rep(j,m)if(i!=j)if(s[i].find(s[j])!=string::npos)con[j]=1;
		n=0; rep(i,m)if(!con[i])in[n++]=s[i];
		
		rep(i,n)rep(j,n){
			int a=in[i].size(),b=in[j].size();
			for(int l=min(a,b);l>=0;l--){
				rep(k,l)if(in[i][a-l+k]!=in[j][k])goto NG;
				d[i][j]=in[j].substr(l); break;
				NG:;
			}
		}
		cout<<solve()<<endl;
	}
	return 0;
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(N + 1, 0);
  rep(i, M) {
    int a;
    cin >> a;
    A[a] = 1;
  }

  int answer0 = 0;
  for (int i = X; i <= N; ++i) {
    answer0 += A[i];
  }
  int answer1 = 0;
  for (int i = X; i >= 0; --i) {
    answer1 += A[i];
  }
  cout << min(answer0, answer1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int n_p,n_q;
struct Vector
{
	int B,len;
}Push;
vector<Vector> vec[100005];
int pas[100005];bool vis[100005];
bool Error;
void F(int x)
{
	for(int i=0;i<vec[x].size();i++)
	{
		Vector G=vec[x][i];
		if(vis[G.B])
			if(G.len+pas[x]!=pas[G.B]) {Error=true;return;}
			else continue;
		vis[G.B]=true;pas[G.B]=pas[x]+G.len;
		F(G.B);
		if(Error) return;
	}
}
int main()
{
	scanf("%d%d",&n_p,&n_q);
	for(int i=0;i<n_q;i++)
	{
		int A,B,l;
		scanf("%d%d%d",&A,&B,&l);
		Push.B=B;Push.len=l;
		vec[A].push_back(Push);
		Push.B=A;Push.len=-l;
		vec[B].push_back(Push);
	}
	for(int i=0;i<n_p;i++)
		if(!vis[i])
		{
			F(i);
			if(Error) break;
		}
	if(!Error) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int A, B, C;
  cin >> A >> B >> C;

  set<int> m;
  int cnt = 0;
  for (int i = 1; 1; i++) {
    int mm = A * i % B;
    if (mm == C) {
      cout << "YES" << '\n';
      return 0;
    }
    m.insert(mm);
    if (cnt == m.size()) {
      cout << "NO" << '\n';
      return 0;
    }
    cnt = m.size();
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
using namespace std;
int n,m,a[N],b[N];
int check(int x)
{
	for (int i=1;i<=m;i++)
		b[i]=a[i]>=x;
	if (b[n]==b[n-1]||b[n]==b[n+1]) return b[n];
	int l=n,r=n;
	while(l>1&&b[l-1]!=b[l])l--;
	while(r<m&&b[r+1]!=b[r])r++;
	if (l==1&&r==n) return b[1];
	if ((r^l)&1) return (l+r>>1)>=n?b[l]:b[r];
	return (l+r>>1)>=n?b[l]:b[r];
}
int main()
{
	scanf("%d",&n);
	m=n*2-1;
	for (int i=1;i<=m;i++)
		scanf("%d",&a[i]);
	int l=1,r=m,mid,ans;
	while(l<=r)
	{
		mid=l+r>>1;
		if (check(mid)) l=mid+1,ans=mid;
		else r=mid-1;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  while(1){
    int h,w;
    cin>>h>>w;
    if(h==0 and w==0)break;

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        cout<<'#';
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
typedef complex<double> Point;
const ll MAX = 201;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
class UnionFind{
    private:
        vector<ll> par;
        vector<ll> siz;
    public:
        UnionFind(ll sz){
            par.resize(sz);
            siz.assign(sz,1LL);
            rep(i,sz) par[i] = i;
        }

        ll find(ll x){
            if (par[x] == x) return x;
            else return par[x] = find(par[x]);
        }

        void unite(ll x,ll y){
            x = find(x);
            y = find(y);
            if (x == y) return;
            if (siz[x] < siz[y]) swap(x,y);
            siz[x] += siz[y];
            par[y] = x;
        }

        bool same(ll x,ll y){
            return find(x) == find(y);
        }

        ll size(ll x){
            return siz[find(x)];
        }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    UnionFind g(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--,b--;
        g.unite(a,b);
    }
    ll ans = 0;
    rep(i,n){
        chmax(ans,g.size(i));
    }
    PRINT(ans);
}



Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {  
  int N;
  cin >> N;
  string S;
  cin>>S;
  int ans=0;
  
  
  rep2(i,1,N) {
    
    vector<bool> A(26);
    rep(j,i){    
      A.at(S.at(j)-'a')=true;
    }
    
    vector<bool> B(26);
    rep2(j,i,N){
      B.at(S.at(j)-'a')=true;
    }
    int co=0;
    rep(a,26){
      if(A.at(a)){
        if(B.at(a)){
          co++;
        }
      }
    }
    
    ans=max(ans,co);
  }
    
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define DIV 1000000000

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main()
{
    ull a;
    double b;
    cin >> a >> b;
    ull tmp = b *  100LL + 0.5;

    cout << a * tmp / 100LL << endl;
    return 0;
}

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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    int s,w;
    cin >> s >> w;
    if(s > w) cout << "safe" << endl;
    else cout << "unsafe" << endl;
}


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

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    int s[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char c;
            cin >> c;
            if(c=='0') s[i][j] = 0;
            else s[i][j] = 1;
        }
    }
    int ans = h+w;
    for(int i=0; i<pow(2,h-1); i++){
        int t = 0;
        vector<int> cut;
        cut.push_back(0);
        for(int j=0; j<h-1; j++){
            int a = i >> j;
            if(a%2) cut.push_back(j+1);
        }
        t += cut.size()-1;
        cut.push_back(h);
        int l = 0;
        int r = 0;
        int m = cut.size()-1;
        int cnt[m];
        fill(cnt,cnt+m,0);
        while(r<w){
            bool judge = false;
            for(int p=0; p<m; p++){
                for(int j=cut[p]; j<cut[p+1]; j++){
                    if(s[j][r]==1) cnt[p]++;
                }
            }
            for(int j=0; j<m; j++){
                if(cnt[j] > k ){
                    judge = true;
                    break;
                }
            }
            if(judge){
                if(l==r){
                    t = h+w;
                    break;
                }
                else{
                    l=r;
                    t++;
                    fill(cnt,cnt+m,0);
                }
            }
            else r++;
        }
        ans = min(ans,t);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {

  int a, b;
  cin >> a >> b;

  if (a == b) {
    cout << "a == b" << endl;
  } else if (a < b){
    cout << "a < b" << endl;
  } else {
    cout << "a > b" << endl;
  }

  return 0;

}


Measured memory_bytes: 3076
n = int(input())
a = list(map(int,input().split()))
b = [0] * n
for i in range(n):
    b[i] = a[i] - i
b.sort()
x = b[n//2]
ans = 0
for i in range(n):
    ans += abs(b[i]-x)
print(ans)

Measured memory_bytes: 31056
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 110
#define N 100010

ll w[M],v[M];
ll dp[M][N];
ll f(ll pos,ll wt){
	if(wt<0) return -1*inf;
	if(pos<0) return 0;
	if(dp[pos][wt]!=-1) return dp[pos][wt];
	ll ans = max(f(pos-1,wt),f(pos-1,wt-w[pos]) + v[pos]);
	// trace(pos,wt,ans);
	return dp[pos][wt]=ans;
}
int main(){
	IOS;
	// freopen("inp.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	
	ll n,W;cin>>n>>W;
	rep(i,0,n)cin>>w[i]>>v[i];

	memset(dp,-1,sizeof(dp));
	f(n-1,W);
	ll ans = -1;
	rep(i,0,N)ans=max(ans,dp[n-1][i]);
	cout<<ans;


	return 0;
}

Measured memory_bytes: 86272
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var waCount = 0;
        var acCount = 0;
        var ac = new bool[vals[0] + 1];
        var wa = new int[vals[0] + 1];
        for (int i = 0; i < vals[1]; i++)
        {
            var line = Console.ReadLine().Split(' ');
            if (ac[int.Parse(line[0])])
            {
                continue;
            }
            if (line[1] == "WA")
            {
                wa[int.Parse(line[0])]++;
            }
            else
            {
                ac[int.Parse(line[0])] = true;
                acCount++;
                waCount += wa[int.Parse(line[0])];
            }
        }
        Console.WriteLine(acCount + " " + waCount);
    }
}

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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

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

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

inline void proc_status()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) <<endl;
}

template <typename T> T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 1e4 + 100, Mod = 1e9 + 7;

int A[Maxn], D, N;
char S[Maxn];
int Dp[Maxn][100 + 10], Vis[Maxn][100 + 10];

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

inline int get_dp (int x, int sum, int limit)
{
	if (!limit && Vis[x][sum]) return Dp[x][sum];

	if (x == N + 1)
	{
		if (!sum) return 1;
		return 0;
	}

	int Max = limit ? A[x] : 9, ans = 0;
	for (int i = 0; i <= Max; ++i)
		Add (ans, get_dp (x + 1, (sum + i) % D, limit && i == Max));

	if (!limit) Dp[x][sum] = ans, Vis[x][sum] = 1;
	return ans;
}

inline void Solve ()
{
	printf("%d\n", (get_dp (1, 0, 1) - 1 + Mod) % Mod);
}

inline void Input ()
{
	scanf("%s", S + 1); D = read<int>();
	N = strlen(S + 1);
	for (int i = 1; i <= N; ++i) A[i] = S[i] - '0';
}

int main()
{
#ifdef hk_cnyali
	freopen("S.in", "r", stdin);
	freopen("S.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;


bool isprime(ll n){
    long double sqr_n=sqrt((long double)n);
    for(ll i=2;i<=sqr_n;i++){
        if(n%i==0)
            return false;
    }
    return true;
}

int main(void){
    ll n;
	cin >> n;
	int ans=0;
	for(ll i=2;i*i<=n;i++)
        if(n%i==0){
		    int cnt=0;
		    while(n%i==0)
                n/=i,cnt++;
		    for(int j=1;j<=cnt;j++){
			    cnt-=j;
			    ans++;
		    }
	    }
	if(n!=1)
        ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3640
def calc(n, x):
    # n個の数(0~9)の和でxが作れるかどうかを判別する
    if n == 1:
        if x <= 9:
            return 1
        else:
            return 0
    else:
        num = 0
        for i in range(10):
            if x-i < 0:
                continue
            num += calc(n-1, x-i)
        return num


while True:
    try:
        print(calc(4, int(input())))
    except:
        exit(0)


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

using namespace std;
 
typedef long long ll;
 
int like_cnt[31] = {0};




int main(){
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++)
    {
        int k;
        cin >> k;
        for(int j = 0; j < k; j++)
        {
            int x;
            cin >> x;
            like_cnt[x]++;
        }
    }
    
    int ans = 0;
    for(int i = 0; i < 31; i++)
    {
        if(like_cnt[i] == n){
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
X = int(input())

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    return is_prime

is_prime = sieve(2*10**5)
p = X
while is_prime[p-1] == False:
  p+=1
print(p)

Measured memory_bytes: 4632
#include <iostream>

using namespace std;

int main(){
	int A,B;

	cin >> A >> B;

	if(A - B > 1)
		cout << 2*A-1 << endl;
	else if(B - A > 1)
		cout << 2*B-1 << endl;
	else
		cout << A+B << endl;
}

Measured memory_bytes: 256