akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cassert>

using namespace std;

int n;
int T[100];
int F[100];

int H[101][101];
int N[101][101];

int A[7];

// anti-clockwise
int P[7][4] = {
    {0, 0, 0, 0},
    {2, 3, 5, 4},
    {1, 4, 6, 3},
    {1, 2, 6, 5},
    {1, 5, 6, 2},
    {1, 3, 6, 4},
    {2, 4, 5, 3}
};

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

int find(int s, int n) {
    for (int j = 0; j < 4; j++) {
        if (P[s][j] == n) { return j; }
    }
    return -1;
}

void solve() {
    for (int i = 0; i < 7; i++) {
        A[i] = 0;
    }

    for (int i = 0; i < 101; i++) {
        for (int j = 0; j < 101; j++) {
            H[i][j] = N[i][j] = 0;
        }
    }

    for (int a = 0; a < n; a++) {
        int x = 50;
        int y = 50;

        int t = T[a];
        int f = F[a];

        for (;;) {
            bool update = false;

            for (int i = 6; i >= 4; i--) {
                int ii = find(t, i);
                if (ii == -1) { continue; }
                int fi = find(t, f);
                int d = (4 + ii - fi) % 4;

                if (H[x + dx[d]][y + dy[d]] < H[x][y]) {
                    x = x + dx[d];
                    y = y + dy[d];

                    if (dx[d] == 1) { // y-axis
                        f = t;
                    } else if (dx[d] == -1) {
                        f = 7 - t;
                    }

                    t = 7 - i;
                    update = true;
                    break;
                }
            }

            if (!update) { break; }
        }

        ++H[x][y];
        N[x][y] = t;
    }

    for (int i = 0; i < 101; i++) {
        for (int j = 0; j < 101; j++) {
            A[N[i][j]]++;
        }
    }
}

int main() {
    for (;;) {
        scanf("%d", &n);
        if (!n) { break; }
        for (int i = 0; i < n; i++) {
            scanf("%d%d", &T[i], &F[i]);
        }

        solve();
        printf("%d %d %d %d %d %d\n", A[1], A[2], A[3], A[4], A[5], A[6]);
    }
    return 0;
}

Measured memory_bytes: 1108
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int m1,d1,m2,d2;
cin>>m1>>d1>>m2>>d2;
if(m2>m1){
    cout<<1<<endl;
}
else cout<<0<<endl;
}


Measured memory_bytes: 256
num = list(map(int, list(input())))
for bit in range(1 << 3):
    res = num[0]
    ans = str(num[0])
    for i in range(3):
        res += (-1)**(bit >> i & 1) * num[i+1]
        ans += ('-' if bit >> i & 1 else '+') + str(num[i+1])
    if res == 7:
        print(ans + '=7')
        exit()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int a[100050], n, s;
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    for (int i = 0; i < n - 1; i++) if (a[i] == a[i + 1]) s++;
    cout << (s % 2 == 0 ? n - s : n - s - 1);
}

Measured memory_bytes: 640
// https://beta.atcoder.jp/contests/abc091/tasks/arc092_a
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

immutable int INF = 114514810;
immutable int VMAX = 300;

// ari 196
struct Edge {
    int to, cap, rev;
}
Edge[][] G;
bool[] used; // dfs したか

// 増加パスを探す
int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    foreach (ref e; G[v]) if (!used[e.to] && e.cap > 0) {
        int d = dfs(e.to, t, min(f, e.cap));
        if (d > 0) {
            e.cap -= d;
            G[e.to][e.rev].cap += d;
            return d;
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow;
    used.length = VMAX;
    while (1) {
        fill(used, false);
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
    assert(false);
}

void add_edge(int from, int to, int cap) {
    G[from] ~= Edge(to, cap, G[to].length.to!int);
    G[to]   ~= Edge(from, 0, G[from].length.to!int - 1);
}

void main() {
    G.length = VMAX;
    int X, Y, E;
    readf("%d %d %d\n", &X, &Y, &E);
    foreach (_; 0..E) {
        int x, y; readf("%d %d\n", &x, &y);
        add_edge(x, X + y, 1);
    }
    int s = X + Y, t = s + 1;
    foreach (to; 0..X)
        add_edge(s, to, 1);
    foreach (from; X..X + Y)
        add_edge(from, t, 1);

    writeln(max_flow(s, t));
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s=="Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(s=="Cloudy"){
    cout << "Rainy" << endl;
  }
  else if(s=="Rainy"){
    cout << "Sunny" << endl;
  }
}

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

using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) cin >> a[i], sum += a[i];
    int cnt = 0;
    for (int i = 0; i < n; i++) if (4 * m * a[i] >= sum) cnt++;
    if (cnt >= m) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{   
    int a,b; cin >> a >> b;
    string sa="",sb="";
    for(int i=0;i<b;i++)sa+=to_string(a);
    for(int i=0;i<a;i++)sb+=to_string(b);
    cout << (sa<sb?sa:sb) << endl;
}
    

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T>
vector<T> divisor(T n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++)
    {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main() {
    ll n, m;
    cin >> n >> m;
    auto ds = divisor(m);
    sort(ds.rbegin(), ds.rend());

    for (ll d: ds) {
        if (d * n <= m) {
            cout << d << endl;
            return 0;
        }
    }
}

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

int main(void){
	int n, i;
	double sn;
	scanf("%d", &n);
	sn = sqrt(n);
	printf("%d:", n);
	while(n % 2 == 0){
		n /= 2;
		printf(" 2");
	}
	for(i = 3; i <= sn; i = i + 2){
		while(n % i == 0){
			n /= i;
			printf(" %d", i);
		}
	}

	if(n == 1){
		printf("\n");
	}
	else{
		printf(" %d\n", n);
	}
	return 0;
}

Measured memory_bytes: 600
k = int(input())

if k % 7 == 0:
    mod = 9*k//7
else:
    mod = 9*k

if mod % 2 == 0 or mod % 5 == 0:
    print(-1)
    quit()

t = 10%mod
i = 1
while t != 1:
    i += 1
    t = t*10%mod
print(i)

Measured memory_bytes: 8980
fun main(args: Array<String>) {
    abc109d()
}

private data class Move(val fromY: Int, val fromX: Int, val toY: Int, val toX: Int) {
    override fun toString(): String {
        return "$fromY $fromX $toY $toX"
    }
}

fun abc109d() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val coins = (1..h).map { readLine()!!.split(' ').map { it.toInt() }.toIntArray() }
        .toTypedArray()

    val moves = mutableListOf<Move>()

    for (y in 0 until h) {
        for (x in 0 until w) {
            if (coins[y][x] % 2 != 0) {
                if (x + 1 < w) {
                    coins[y][x]--
                    coins[y][x + 1]++
                    moves.add(Move(y + 1, x + 1, y + 1, x + 2))
                } else if (y + 1 < h) {
                    coins[y][x]--
                    coins[y + 1][x]++
                    moves.add(Move(y + 1, x + 1, y + 2, x + 1))
                }
            }
        }
    }

    val answer = moves.size.toString() + System.lineSeparator() +
            moves.joinToString(System.lineSeparator()) { it.toString() }

    println(answer)
}


Measured memory_bytes: 72556
import java.util.*;
import java.lang.*;

/**
 * SelectionSort
 */
public class Main
 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] list = new int[n];

        for (int i = 0; i < n; i++) {
            list[i] = Integer.parseInt(sc.next());
        }

        int num = MySelectionSort(list, n);

        for (int i = 0; i < list.length; i++) {
            if (i == list.length - 1) {
                System.out.print(list[i]);

            } else {
                System.out.print(list[i] + " ");
            }
        }
        System.out.println("");
        System.out.println(num);
    }

    private static int MySelectionSort(int[] list, int n) {
        int num = 0;
        for (int i = 0; i < n; i++) {
            int minj = i;
            for (int j = i; j < n; j++) {
                if (list[j] < list[minj]) {
                    minj = j;
                }
            }

            if (i != minj) {
                int tmp = list[i];
                list[i] = list[minj];
                list[minj] = tmp;
                num++;
            }
        }

        return num;
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD=1e9+7;

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

 // int n;cin>>n;
 //string s;cin>>s;
 // cout<<fixed<<setprecision(10)<<endl;
 ll a,b,c;cin>>a>>b>>c;
 for(int i=0;i<1e6;i++){
     if(a%2||b%2||c%2){
         cout<<i<<endl;
         return 0;
     }
     ll tmpa=(b+c)/2,tmpb=(c+a)/2,tmpc=(a+b)/2;
     a=tmpa;b=tmpb;c=tmpc;
 }
 cout<<-1<<endl;
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define N 200005
ll mod=998244353;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(x) x.begin(),x.end()
#define lb lower_bound
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
int main()
{
    fast;
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
def readinput():
    n=int(input())
    return n

def main(n):
    name=subname(n)
    return name

def subname(n):
    alph='abcdefghijklmnopqrstuvwxyz'
    if n <=26:
        return alph[n-1]
    else:
        r=n%26
        if r==0:
            addch='z'
            n=n-26
        else:
            addch=alph[r-1]
        q=n//26
        return subname(q)+addch


if __name__=='__main__':
    n=readinput()
    ans=main(n)
    print(ans)


Measured memory_bytes: 9196
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	reader *bufio.Scanner
}

func (s *Scanner) Next() string {
	s.reader.Scan()
	return s.reader.Text()
}

func (s *Scanner) NextInt() int {
	s.reader.Scan()
	val, err := strconv.Atoi(s.reader.Text())
	if err != nil {
		panic(err)
	}
	return val
}

var sc *Scanner

func init() {
	sc = &Scanner{bufio.NewScanner(os.Stdin)}
	sc.reader.Split(bufio.ScanWords)
}

func main() {
	a := sc.NextInt()
	b := sc.NextInt()

	fmt.Printf("%v %v\n", a*b, 2*(a+b))
}



Measured memory_bytes: 1096
// AtCoder template
// 見た奴全員saba!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

template<class T>
T pow(long long a, long long b, T mod){
    if(b == 0) return 1;
    if(b % 2 == 0){
        T d = pow(a,b/2,mod);
        return (d*d)%mod;
    }else return a%mod*pow(a,b-1,mod)%mod;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    const ll MOD = 1e9+7;
    ll n,k; cin >> n >> k;
    ll comb1[n+1],comb2[n+1];
    comb1[0] = 1LL; // nCl
    comb2[0] = 1LL; // n-1Cl
    ll ans = 1LL;
    for(ll i = 1LL; i <= min(k,n-1); ++i){
        ll d = pow(i,MOD-2,MOD);
        comb1[i] = comb1[i-1]*(n-i+1)%MOD*d%MOD;
        comb2[i] = comb2[i-1]*(n-i)%MOD*d%MOD;
        ans += comb1[i]*comb2[i]%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;

    if(a <= b) cout << a << endl;
    else cout << a-1 << endl;


    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#define mxn 200010
using namespace std;
const int mod=1e9+7;
int n,m,K,N,C,sl,fh,ans,inv[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	n=rd();m=rd();K=rd()-2;N=n*m-2;C=1;inv[1]=1;
	for(int i=N-K+1;i<=N;++i) C=1ll*i*C%mod;
	for(int i=2;i<=K;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;;
	for(int i=2;i<=K;++i) C=1ll*C*inv[i]%mod;
	for(int i=1;i<n;++i) ans=(ans+1ll*i*(n-i)*m*m)%mod;
	for(int i=1;i<m;++i) ans=(ans+1ll*i*(m-i)*n*n)%mod;
	ans=1ll*C*ans%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
class Unionfind:
    
    def __init__(self,n):
        self.uf = [-1]*n

    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]

    def same(self,x,y):
        return self.find(x) == self.find(y)

    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x

    def size(self,x):
        x = self.find(x)
        return -self.uf[x]

n,m = map(int,input().split())
l = list(map(int,input().split()))
u = Unionfind(n)
for i in range(m):
    x,y = map(int,input().split())
    u.union(x-1,y-1)

ans = 0
for i in range(n):
    if u.same(i,l[i]-1):
        ans += 1
    
print(ans)





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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int x, y;
  cin >> x >> y;
  int res = x + y / 2;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    ll x; cin >> x;
    ll ans = x / 11 * 2;
    int mod = x % 11;
    if (mod != 0){
        if (mod <= 6){
            ans++;
        }
        else{
            ans += 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
int func(int X){
  return X>=0?X:-X;
  }
signed main(){
  int N,sum=0;
  cin>>N;
  vi A(N+2);
  rep(i,1,N+1){
    cin>>A[i];
    sum+=func(A[i]-A[i-1]);
    }
  sum+=func(A[N+1]-A[N]);
  rep(i,1,N+1){
    if(A[i-1]<A[i]&&A[i]>A[i+1])
      cout<<sum-(min(A[i]-A[i-1],A[i]-A[i+1]))*2<<endl;
    else if(A[i-1]>A[i]&&A[i]<A[i+1])
      cout<<sum-(min(A[i-1]-A[i],A[i+1]-A[i]))*2<<endl;
    else
      cout<<sum<<endl;
   }
}

Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 105

using namespace std;

ll weight[sz],cost[sz];
ll n,cap;

map<pair<ll, ll>, ll>dp;

ll fun(ll pos, ll w)
{
    if(pos==(n+1))
        return 0;

    if(dp[make_pair(pos, w)])
        return dp[make_pair(pos, w)];

    ll profit1;

    if(w+weight[pos]<=cap)
        profit1=cost[pos]+fun(pos+1, w+weight[pos]);

    else
        profit1=0;

    ll profit2=fun(pos+1, w);

    ll r=max(profit1, profit2);

    return dp[make_pair(pos, w)]=r;
}

int main()
{
    scanf("%lld %lld",&n,&cap);

    for(ll i=1; i<=n; i++)
    {
        scanf("%lld %lld",&weight[i],&cost[i]);
    }

    dp.clear();

    ll res=fun(1, 0);

    printf("%lld\n",res);

    return (0);
}


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

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))

int main(){
    int n,m,q;
    vector<char> w(36);
    rep(i,10) w[i]='0'+i;
    reep(j,10,36){
        w[j]='A'+j-10;
    }
    while(cin>>n>>m>>q,n||m||q){
        vector<vector<int>> v(m,vector<int>(n,1));
        string pre(m,'0');
        rep(i,q){
            string a,b;
            cin>>a>>b;
            rep(i,n){
                if(a[i]=='0'){
                    rep(j,m){
                        if(pre[j]!=b[j]){
                            v[j][i]=0;
                        }
                    }
                }
                else rep(j,m){
                    if(pre[j]==b[j]){
                        v[j][i]=0;
                    }
                }
            }
            pre=b;
        }
        rep(i,m){
            int cnt=0;
            int ans=-1;
            rep(j,n){
                if(v[i][j]) cnt++,ans=j;
            }
            if(cnt>=2){
                cout<<"?";
            }
            else if(cnt==1){
                cout<<w[ans];
            }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1376
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;
#define max(a, b) ((a) > (b) ? (a) : (b))



int main(void){
  int n;
  cin >> n;

  string s;
  cin >> s;
  //n = s.length();
  vector<vector<int> > work(n+1,vector<int>(n+1,0));
  
  int ans = 0; 
  for(int i=0;i<n;i++){
	//cout << "[" << i << "]" << endl;
	for(int j=i+1;j<n;j++){
	  if(s[i] == s[j]){
		work[i+1][j+1] = work[i][j]+1;
		if(i < j-work[i][j] && ans < work[i+1][j+1]) ans = work[i+1][j+1];
	  }
	  /*cout << j << ": ";
	  rep(k,work[i][j].size()) cout << work[i][j][k] << " ";
	  cout << endl;*/
	}
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 98176
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define ll long long
#define ii pair<int,int>
ll ara[200005];char st[200004];
ll a[200004]; ll b[200004];
int main()
{
    ll c,d,m,n,i,j,k,l,t,x,y,z;

    float bb;
    cin>>c;
   cin>>bb;

   bb*=100.00;
   k=(long long)bb;
    ll ans=(k*c)/ 100.00;
    cout<<ans<<endl;



    return 0;
}






Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl;

using namespace std;
const int inf = 1e18;
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0){
			cout<<0<<endl;
			return 0;
		}
	}
	int ans = 1;
	for(int i=0;i<n;i++){
		int res = ans*a[i];
		if((res<ans && res<a[i]) || res>inf){
			cout<<-1<<endl;
			return 0;
		}
		ans = res;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4436
#include<iostream>
using namespace std;
int main(){
	int n,c=1;
	cin >> n;
	int i = 1000;
	if(n%i==0)
		cout << 0 << endl;
	else{
		c = (n/i);
		cout << (i*(c+1)-n) << endl;
	}
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,a[200],b[200],c[200],d[200];
struct edge
{
	int v,cap,rev;
	edge(int a,int b,int c):v(a),cap(b),rev(c){}
};
vector<edge> w[23333];
void add_edge(int u,int v,int cap)
{
	w[u].push_back(edge(v,cap,w[v].size()));
	w[v].push_back(edge(u,0,w[u].size()-1));
}
const int oo=1<<29;
int level[23333],iter[23333];
int dfs(int s,int t,int f)
{
	if(s==t)return f;
	for(int &i=iter[s];i<w[s].size();i++)
	{
		edge &e=w[s][i];
		if(e.cap&&level[e.v]>level[s])
			if(int d=dfs(e.v,t,min(f,e.cap)))
			{
				e.cap-=d;
				w[e.v][e.rev].cap+=d;
				return d;
			}
	}
	return 0;
}
int max_flow(int s,int t)
{
	int ans=0;
	for(;;)
	{
		memset(level,-1,sizeof level);
		memset(iter,0,sizeof iter);
		level[s]=0;
		queue<int> q;
		q.push(s);
		while(!q.empty())
		{
			int u=q.front();q.pop();
			for(int e=0;e<w[u].size();e++)
			{
				edge &i=w[u][e];
				if(level[i.v]==-1&&i.cap)
				{
					level[i.v]=level[u]+1;
					q.push(i.v);
				}
			}
		}
		if(level[t]==-1)return ans;
		while(int f=dfs(s,t,oo))ans+=f;
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
	for(int i=1;i<=n;i++)cin>>c[i]>>d[i];
	for(int i=1;i<=n;i++)add_edge(0,i,1),add_edge(n+i,2*n+1,1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		if(a[i]<c[j]&&b[i]<d[j])add_edge(i,n+j,1);
	cout<<max_flow(0,2*n+1)<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define REP(i, a) for (ll i(0), _##i(a); i < _##i; ++i)
#define FOR(i, a, b) for (ll i(a), _##i(b); i <= _##i; ++i)

#ifdef LOCAL
#define _NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
#define _FE_1(_CALL, x) _CALL(x)
#define _FE_2(_CALL, x, ...) _CALL(x) _FE_1(_CALL, __VA_ARGS__)
#define _FE_3(_CALL, x, ...) _CALL(x) _FE_2(_CALL, __VA_ARGS__)
#define _FE_4(_CALL, x, ...) _CALL(x) _FE_3(_CALL, __VA_ARGS__)
#define _FE_5(_CALL, x, ...) _CALL(x) _FE_4(_CALL, __VA_ARGS__)
#define _FE_6(_CALL, x, ...) _CALL(x) _FE_5(_CALL, __VA_ARGS__)
#define FOR_EACH_MACRO(MACRO, ...)                                             \
  _NTH_ARG(__VA_ARGS__, _FE_6, _FE_5, _FE_4, _FE_3, _FE_2, _FE_1)              \
  (MACRO, __VA_ARGS__)
#define watch(x) cerr << "\033[1;32m" #x " = \033[1;34m" << (x) << "\033[0m; ";
#define debug(...)                                                             \
  cerr << "\033[2;31mLine " << __LINE__ << ": \033[0m";                        \
  FOR_EACH_MACRO(watch, __VA_ARGS__)                                           \
  cerr << endl
#else
#define debug(...)
#endif

using namespace std;

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << '{' << p.first << ", " << p.second << '}';
}

template <class T, class = decltype(begin(declval<T>())),
          class = enable_if_t<!is_same<T, string>::value>>
ostream &operator<<(ostream &os, const T &c) {
  os << '[';
  for (auto it = begin(c); it != end(c); ++it)
    os << (it == begin(c) ? "" : ", ") << *it;
  return os << ']';
}
using ll = long long;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &x : a) {
    cin >> x;
  }
  debug(a);
  vector<bool> dp(k + 1);
  // false -> second
  // true -> first
  FOR(i, 1, k) {
    for (int x : a) {
      if (i - x >= 0) {
        dp[i] = dp[i] || !dp[i - x];
      }
    }
  }
  debug(dp);
  cout << (dp[k] ? "First\n" : "Second\n");
}

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

  int T = 1;
  // cin >> T;
  while (T--) {
    solve();
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,long double> Pi;
typedef pair <long double,int> Pd;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
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 (a>b) { a=b; return 1; } return 0; }
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
string a,b,c;
cin>>a>>b>>c;
int ans=0;
for(int i=0;i<n;i++){
   string s={};
   s+=a[i];
   s+=b[i];
   s+=c[i];
   //cout<<s<<endl;
   sort(all(s));
   s.erase(unique(all(s)),s.end());
   if(s.size()==2)ans++;
   else if(s.size()==3)ans+=2;
}
cout<<ans<<endl;
}



Measured memory_bytes: 256
d,g=map(int,input().split())
v=[list(map(int,input().split())) for i in range(d)]
ans=1000
for i in range(1<<d):
  s=0
  n=0
  for j in range(d):
    if i>>j&1 == 1:
      s += v[j][0] * (j+1) * 100 + v[j][1]
      n += v[j][0]
  for j in range(d-1,-1,-1):
    if i>>j&1 == 0:
      r = ((g-s)//100 + j) // (j+1)
      if r>v[j][0]:
        n = 1000
      else:
        n += max(r,0)
      break
  ans=min(ans,n)
print(ans)

Measured memory_bytes: 9164
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

typedef vector< double > VD;
typedef vector< VD > VVD;

double dist( double r1, double r2 )
{
	return sqrt( pow( r1 + r2, 2 ) - pow( r1 - r2, 2 ) );
}

string solve( int x, int n, VI rs )
{
	VVD dp( 1 << n, VD( n, DBL_MAX ) );

	REP( i, 0, n )
	{
		dp[ 1 << i ][i] = rs[i];
	}

	REP( i, 1, 1 << n )
	{
		REP( j, 0, n )
		{
			if ( dp[i][j] == DBL_MAX )
			{
				continue;
			}

			REP( k, 0, n )
			{
				if ( ( i >> k & 1 ) )
				{
					continue;
				}

				dp[ i | 1 << k ][k] = min( dp[ i | 1 << k ][k], dp[i][j] + dist( rs[j], rs[k] ) );
			}
		}
	}

	REP( i, 0, n )
	{
		if ( dp.back()[i] + rs[i] <= x )
		{
			return "OK";
		}
	}

	return "NA";
}

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

	string str;

	while ( getline( cin, str ) )
	{
		ISS iss( str );

		int n;
		iss >> n;

		VI rs;
		int tmp;

		while ( iss >> tmp )
		{
			rs.PB( tmp );
		}

		cout << solve( n, rs.size(), rs ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1632
# 初期入力
from copy import copy
import sys
input = sys.stdin.readline
S =[int(i) for i in input().strip()]
S2 =S.copy()
count =0
for i in range(len(S) -1):
    if S[i] ==S[i+1]:
        S[i+1] =(S[i+1] +1)%2
        count +=1

count2 =0
for i in range(len(S2)-1,0, -1):
    if S2[i] ==S2[i-1]:
        S2[i-1] =(S2[i-1] +1)%2
        count2 +=1
print(min(count,count2))

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    cout << (3 * n + m) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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



                var word = Console.ReadLine().Split();

                int a = int.Parse(word[0]);
                int b = int.Parse(word[1]);
            if (a == b)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");


                Console.ReadKey();



            }
        }
    }


Measured memory_bytes: 13140
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int i=1;
  int x;
  while(cin>>x){
    if(x==0) return 0;
    cout<<"Case "<<i<<": "<<x<<endl;
    i++;
  }
  
  return 0;
}


Measured memory_bytes: 3072
import sys

#a, b = map(int, input().split(" "))
N = int(input())
S = input()

ans = 0
for i in range(1, N):
	max_len = 0
	for asc in range(ord("a"), ord("z")+1):
		flag = False
		for j in range(i):
			if ord(S[j]) == asc:
				for k in range(i,N):
					if ord(S[k]) == asc:
						flag = True
						break
		if not(flag):
			continue
		max_len += 1
		#print(str(i)+" "+str(chr(asc))+str(max_len))
	ans = max(max_len, ans)
print(ans)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

def abc103():
    N = int(input())
    U, V = [None] * N, [None] * N
    OK = True
    for i in range(N):
        x, y = map(int, input().split())
        u, v = x+y, x-y
        U[i], V[i] = u, v
        if i != 0:
            if f ^ (u%2):
                OK = False
        f = u%2
    if OK == False:
        print(-1)
        exit()
    D = [2**i for i in range(30, -1, -1)] + [1]*(f^1)
    print(len(D))
    print(*D)
    for u, v in zip(U, V):
        ans = []
        pu, pv = 0, 0
        for d in D:
            if pu <= u and pv <= v:
                pu += d
                pv += d
                ans.append('R')
            elif pu <= u and pv >= v:
                pu += d
                pv -= d
                ans.append('U')
            elif pu >= u and pv >= v:
                pu -= d
                pv -= d
                ans.append('L')
            elif pu >= u and pv <= v:
                pu -= d
                pv += d
                ans.append('D')
        print(*ans, sep = '')

abc103()


Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

string s, t;
map<char,char> change0, change1;
void solve()
{
	const int N = s.length();
	bool ok = true;
	for(int i=0; i<N;++i){
		//if(s[i]!=t[i]){
			if(change0.count(s[i]) && change0[s[i]]!=t[i]){
				ok  = false;
				break;
			}
			change0[s[i]] = t[i];
		//}
	}
	for(int i=0; i<N;++i){
		//if(s[i]!=t[i]){
			if(change1.count(t[i]) && change1[t[i]]!=s[i]){
				ok  = false;
				break;
			}
			change1[t[i]] = s[i];
		//}
	}
	if(!ok) cout << "No" << endl;
	else cout << "Yes" << endl;
}

int main()
{
	cin >> s >> t;
	solve();
}

Measured memory_bytes: 776
// algo.cpp: 定义应用程序的入口点。
//
#include <iostream>
#include <fstream>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <climits>
#include <cassert>
using namespace std;
struct UnionFind {
    vector<int> par, sz;
    int n_tree;

    explicit UnionFind(int n) : par(n), sz(n, 1), n_tree(n) { //0-indexed
        iota(par.begin(), par.end(), 0);
    }

    int n_cluster() const {
        return n_tree;
    }

    int size(int x) {
        return sz[root(x)];
    }

    int root(int x) {
        return x == par[x] ? x : par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x), ry = root(y);
        if (rx != ry) {
            par[rx] = ry;
            --n_tree;
            sz[ry] += sz[rx];
            return true;
        }
        return false;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    bool is_root(int x) const {
        return par[x] == x;
    }
};

int main() {
#ifdef LOCAL
    // 如何使用相对路径？
    ifstream in("in.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
#if defined LOCAL
    cout << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}

Measured memory_bytes: 256
program main
    character (20) :: cx, ca, cb
    integer :: x, a, b
    read *, cx, ca, cb
    read (cx, *) x
    read (ca, *) a
    read (cb, *) b
    if (abs(x-a) < abs(x-b)) then
        print *, "A"
    else
        print *, "B"
    end if
end program main

Measured memory_bytes: 768
sub f{my($x,$b,$w)=($_,1,1);$_-"@_"and($w*=f($x))%=$==1e9+7,$b=$b*$c%$=for@$x;$b+=$c=$w}$_+=<>;print f(map{push@$_,$_[--$|]for@_=glob}<>)%$=

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

int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    rep(i,n){
        cin >> h[i];
    }
    bool ans = 1;
    for(ll i = n-1;i>0;i--){
        if(h[i] == h[i-1]-1) h[i-1]--;
        else if(h[i] < h[i-1] -1){
            ans = 0;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double

#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll MOD = 1000 * 1000 * 1000 + 7;
using namespace std;



ll dp[100070];
int N;

vector <int> A[100070];


ll seno(ll idx)
{


ll ans=0;


if (dp[idx]!=-1)
return dp[idx];	

if (A[idx].size()==0)
return dp[idx]=0;	



for (int i=0;i<A[idx].size();i++)
{
ans=max(ans, 1+seno(A[idx][i]));

}



return dp[idx]=ans;

}



int main() 
{ 


fastio();

int N,M;


cin>>N>>M;
int x,y;

for (int i=0;i<M;i++)
{
cin>>x>>y;
A[x].pb(y);
}	

memset(dp, -1, sizeof(dp));


ll MAX=0;

for (int i=0;i<=N;i++)
{
MAX=max(MAX, seno(i));
}	

cout<<MAX;

return 0;
} 




Measured memory_bytes: 8576
#include <stdio.h>

int main(void){
	int A[1000];
	int N, M;
	double thr = 0;
	int count = 0;
	int k;

	scanf("%d %d", &N, &M);
	for (k = 0; k < N; k++) {
		scanf("%d", &A[k]);
		thr += A[k];
	}

	thr /= (4*M);
	for (k = 0; k < N; k++) {
		if (A[k] >= thr) { count++; } 
	}
	

	if (count >= M) {
		puts("Yes");
	} else {
		puts("No");
	}

	return 0;
}


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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

char a[22][2222];
int main()
{
ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i ++)
	for(int j = 1; j <= m; j ++)
		cin >> a[i][j];
	int res = 1e9;
	for(int i = 0; i < (1 << (n-1)); i ++)
	{
		set<int> s;
		for(int j = 0; j < (n-1); j ++)
			if((1 << j) & i)
				s.insert(j + 1);
		vi v(n + 3, 0);
		vi f;
		int ok = 0, cur = -1, ans = 0;
		for(int j = 1; j <= m; j ++)
		{
			int id = 0, mx = 0;
			for(int i = 1; i <= n; i ++)
			{
				if(a[i][j] == '1')
					v[id] ++;
				umax(mx, v[id]);
				if(s.count(i))
					id ++;
			}
			if(mx <= k)
			{
				cur = j;
			}
			else
			{
				if(cur == -1)
				{
					ok = 1;
					break;
				}
				for(int j = 0; j <= id; j ++)
					v[j] = 0;
					ans ++;
				j --;
				cur = -1;
			}
			id = 0;
		}
		if(!ok)
		{
			ans += s.size();
			res = min(res, ans);
		}
	}
	cout << res;





	





	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b,c;
    cin >> a >> b >> c;
    cout << (b-a==c-b?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
using namespace std;
const int rlen=1<<18|1;
inline char gc(){
	static char buf[rlen],*ib,*ob;
	(ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin));
	return ib==ob?-1:*ib++;
}
inline int read(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
const int N=1e5+5;
int n,m,cnt=0,s,t;
vector<int>e[N];
bool dfs(int p,int fa){
	for(ri i=0,v;i<e[p].size();++i){
		if((v=e[p][i])==fa||v==t)continue;
		if(v==s)return 1;
		if(dfs(v,p))return 1;
	}
	return 0;
}
inline void check(){
	s=t=-1;
	for(ri i=1;i<=n;++i)if(e[i].size()==4)~s?t=i:s=i;
	puts(dfs(s,0)?"Yes":"No");
}
int main(){
	n=read(),m=read();
	for(ri i=1,u,v;i<=m;++i)u=read(),v=read(),e[u].push_back(v),e[v].push_back(u);
	bool f=1,f3=0;
	for(ri i=1;i<=n;++i)f&=!(e[i].size()&1),cnt+=e[i].size()/2-1,f3|=e[i].size()>4;
	if(!f||cnt<2)return puts("No"),0;
	if(f3||cnt>2)return puts("Yes"),0;
	check();
	return 0;
}

Measured memory_bytes: 7936
use whiteread::parse_line;

fn main() {
    let (n, k): (u32, u32) = parse_line().unwrap();
    let _a: Vec<u32> = parse_line().unwrap();

    println!(
        "{}",
        if (n - 1) % (k - 1) == 0 {
            (n - 1) / (k - 1)
        } else {
            (n - 1) / (k - 1) + 1
        }
    );
}


Measured memory_bytes: 3020
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {};
	Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
	int n;
	bool directed;
	vector<vector<Edge<T>>> edges;
public:

	Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)) {};
	Graph() {};

	void add(int to, T cost) {
		emplace_back(to, cost);
	}

	int size() {
		return n;
	}
};


int main() {

	long long N, A, B;

	cin >> N >> A >> B;

	if (A == 0 && B == 0) {
		cout << 0 << endl;
		return 0;
	}
	if (N <= A + B) {
		if (N >= A) {
			cout << A << endl;
		}
		else {
			cout << N << endl;
		}
	}
	else {
		if (N % (A + B) >= A) {
			cout << (N / (A + B)+1) * A << endl;
		}
		else {
			cout << (N / (A + B)) * A + N % (A + B) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define task ""
#define nmax 500005
#define S second
#define F first
#define reset(x) memset(x,0,sizeof(x))
#define len(s) int(s.length())
#define endl '\n'
#define oo 1000000009

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

string t;
int in[nmax], s[nmax], n;
ll res = 0;
vector <int> a[nmax];
bool visit[nmax];

void dfs(int u)
{
    for (auto v : a[u])
        if (s[v] <= s[u])
    {
        s[v] = s[u] + 1;
        dfs(v);
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    cin >> t;
    t = '0' + t;
    n = t.length();
    for (int i = 1; i < n; i++)
    {
        if (t[i] == '>') a[i+1].push_back(i), in[i]++;
        else
            a[i].push_back(i + 1), in[i+1]++;
    }
    for (int i = 1; i <= n; i++)
        if (!in[i]) dfs(i);
    for (int i = 1; i <= n; i++)
        res += s[i];
    cout << res;

}


Measured memory_bytes: 47664
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 1e5 + 7; 
const ll md = 1e9 + 7;

ll a[maxn];
int go[maxn];
ll dp[maxn];
ll sum[maxn];

int main() {
	int n; sd(n); ll A,B; sl(A); sl(B); if (A > B) swap(A,B);
	for (int i = 1; i <= n; i++) sl(a[i]);
	go[n] = 1; go[n+1] = 0; a[0] = -B-1;
	for (int i = 0; i+2 <= n; i++) {
		if (a[i+2] - a[i] < A) { 
			pd(0); endc; return 0;
		}
	}
	for (int i = n-1; i >= 0; i--) {
		if (a[i+1] >= a[i] + A) go[i] = 1 + go[i+1];
		else go[i] = 1;
	}
	dp[n+1] = 1; sum[n+1] = 1;
	for (int i = n; i >= 0; i--) {
		int l = i, r = n;
		while (l < r) {
			int mid = (l+r-1)>>1;
			if (a[mid] < a[i] + B) l = mid+1;
			else r = mid;
		}
		int x = l;
		if (a[x] < a[i] + B) {
			if (go[i+1] == n-i) dp[i] = 1;
			else dp[i] = 0;
		} else {
			int lft = x, rgt = i+1+go[i+1];
			if (rgt < lft) dp[i] = 0;
			else dp[i] = (sum[lft] - sum[rgt+1] + md)%md;
		}
		sum[i] = (sum[i+1] + dp[i])%md;
	}
	
	pl(dp[0]); endc;
}


Measured memory_bytes: 3072
#include <cstdio>

int main()
{
	int A, B, C, X;
	int cnt=0;
	int i, j, k;
	
	scanf("%d %d %d %d", &A, &B, &C, &X);
	
	for(i=0; i<=A; i++)
		for(j=0; j<=B; j++)
			for(k=0; k<=C; k++)
				if(i*500 + j*100 + k*50 == X)
					cnt++;
	
	printf("%d", cnt);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cstdlib>
    using namespace std;
    const int N=100000;
    int a[N];
    long long int n,m,k,u;
    long long sum;
    int main()
    {
        cin>>n>>m;
        sum=1;
        k=n;
        for(;k<=m;)
        {
            k*=2;
            if(k<=m)
                sum++;
            else
                break;
        }
        cout<<sum<<endl;
    }


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

while True:
    try:
        n, r = map(int, raw_input().split())
    except:
        exit()
    c = map(int, raw_input().split())
    deck = [i for i in range(n)]
    for i in range(r):
        A = deck[n / 2 :]
        B = deck[: n / 2]
        deck = []
        for j in range(0, n / 2 + 1, c[i]):
            deck += A[j : j + c[i]]
            deck += B[j : j + c[i]]
    print deck[-1]


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

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);   

    ll n = 0;
    cin >> n;

    set<string> s;
    string temp;
    for(int i = 0; i < n; i++) {
        cin >> temp;
        s.insert(temp);
    }

    cout << s.size() << endl;



    return 0;
}

Measured memory_bytes: 19300