akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main(){
  string s,t;
  cin>>s;
 
  for(int i=0;i<s.size();i++){
   	cout<<s[i]<<s[i+1]<<s[i+2];
    return 0;
   
  }
  
    

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> S(H);
	for(int i=0; i<H; i++) cin >> S[i];

	vector<int> nh(H);
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(S[i][j]=='#') nh[i]++;
		}
	}
	debugv(nh);

	vector<vector<int>> ans(H, vector<int>(W));
	int n = 1;
	vector<int> hs(1, 0);
	int i0 = 0;
	while(nh[i0]==0) i0++;
	for(int i=i0+1; i<H; i++){
		if(nh[i]>0) hs.push_back(i);
	}
	hs.push_back(H);
	for(int i=0; i<hs.size()-1; i++){
		int h0 = hs[i];
		int h1 = hs[i+1];
		debug(h0, h1);

		vector<int> nw(W);
		for(int w=0; w<W; w++){
			for(int h=h0; h<h1; h++){
				if(S[h][w]=='#') nw[w]++;
			}
		}
		vector<int> ws(1, 0);
		int j0 = 0;
		while(nw[j0]==0) j0++;
		for(int w=j0+1; w<W; w++){
			for(int h=h0; h<h1; h++){
				if(S[h][w]=='#'){
					ws.push_back(w);
					break;
				}
			}
		}
		ws.push_back(W);

		for(int j=0; j<ws.size()-1; j++){
			int w0=ws[j];
			int w1=ws[j+1];
			for(int w=w0; w<w1; w++){
				for(int h=h0; h<h1; h++){
					ans[h][w] = n;
				}
			}
			n++;
		}
	}

	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cout << ans[i][j] << (j==W-1?'\n':' ');
		}
	}

	return 0;
}


Measured memory_bytes: 1280
def dis(x_1, y_1, x_2, y_2):
    return ((x_1-x_2)**2 + (y_1-y_2)**2)**(1/2)

n = int(input())
t = [0] * n
x = [0] * n
y = [0] * n
for i in range(n):
    t[i], x[i], y[i] = map(int, input().split())

for i in range(n):
    if t[i] % 2 !=  (x[i] + y[i]) % 2:
        print("No")
        exit(0)
    if i != 0:
        if dis(x[i-1], y[i-1], x[i], y[i]) > t[i] - t[i-1]:
            print("No")
            exit(0)
    else:
        if x[i] + y[i] > t[i]:
            print("No")
            exit(0)

print("Yes")

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

vector<int> a[18][18];


int z[1 << 18];
int us[20], to[20];

void zh(int x, int y, int n) {
	for(int i=0;i<n;i++) us[i] = 0;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) if((x >> i & 1) == (y >> j & 1) && !us[j])
			{ us[j] = 1; to[i] = j; break;}
	}
	for(int i=0;i<(1<<n);i++) {
		int s = 0;
		for(int j=0;j<n;j++) s += (i >> j & 1) * (1 << to[j]);
		z[i] = s;
	}
}

int n, x, y, c;

void pr(int x, int n) {
	for(int i=n-1;i>=0;i--) printf("%d", x >> i & 1); printf(" ");
}

int main() {
	n = 17;
	a[1][1].push_back(0); a[1][1].push_back(1);
	for(int i=2;i<=n;i++) {
		int mx = 1 << (i - 1);
		for(int k=0;k<a[i - 1][1].size();k++)
			a[i][1].push_back(a[i - 1][1][k]);
		for(int k=a[i - 1][1].size()-1;k>=0;k--)
			a[i][1].push_back(a[i - 1][1][k] + mx);
			
		for(int j = 3; j <= i; j += 2) {
			for(int k=0;k<a[i - 1][j - 2].size();k++)
				a[i][j].push_back(a[i - 1][j - 2][k]);
			int h = a[i - 1][j - 2][a[i - 1][j - 2].size() - 1];
			zh(1 << (i - 2), 1 << (i - j), i - 1);
			for(int k=0;k<a[i - 1][1].size();k++)
				a[i][j].push_back((z[a[i - 1][1][k]] ^ h) + (1 << (i - 1)));
		}
	}
	scanf("%d %d %d", &n, &x, &y);
	for(int i=0;i<n;i++) c += (x ^ y) >> i & 1;
	if(c % 2 == 0) {
		printf("NO\n"); return 0;
	}
	printf("YES\n");
	zh(a[n][c][a[n][c].size() - 1], x ^ y, n);
	for(int k=0;k<a[n][c].size();k++) printf("%d ", z[a[n][c][k]] ^ x);
	
}

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

int main() {
  int N;
  cin >> N;
  map<int,int> mapL, mapR;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (i%2 == 0) mapL[x]+=1;
    else mapR[x] += 1;
  }
  
  vector<vector<int>> mx(4,vector<int>(2,0));
  for (auto l : mapL) {
    if (l.second > mx[0][1]) {
      mx[1] = mx[0];
      mx[0] = {l.first, l.second};
    }
    else if (l.second > mx[1][1]) mx[1] = {l.first, l.second};
  }
  for (auto r : mapR) {
    if (r.second > mx[2][1]) {
      mx[3] = mx[2];
      mx[2] = {r.first, r.second};
    }
    else if (r.second > mx[3][1]) mx[3] = {r.first, r.second};
  }
  
  int ans;
  if (mx[0][0] != mx[2][0]) ans = N-mx[0][1]-mx[2][1];
  else ans = N-max(mx[0][1]+mx[3][1],mx[1][1]+mx[2][1]);
  cout << ans << endl;
}

Measured memory_bytes: 4992
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

N = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


divs = make_divisors(N)
cnt = 0

for d in divs:
    if d == 1:
        continue
    rest = N // d
    while rest % d == 0:
        rest //= d
    if (rest - 1) % d == 0:
        cnt += 1

divs2 = make_divisors(N-1)
cnt += len(divs2) - 1

print(cnt)


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  vector<ll> P(N + 1);
  map<ll, int> counter;
  P[0] = 0;
  counter[0]++;
  for (int i = 1; i <= N; i++) {
    P[i] = P[i - 1] + A[i - 1];
    counter[P[i]]++;
  }
  ll res = 0;
  for (auto itr = counter.begin(); itr != counter.end(); itr++)
    res += 1LL * itr->second * (itr->second - 1) / 2;
  cout << res << '\n';
  return 0;
}


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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


int main() {
    int a[3][3];

    rep(i, 3) rep(j, 3) {
        cin >> a[i][j];
    }

    int n;
    cin >> n;

    int b;

    rep(i, n) {
        cin >> b;
        rep(j, 3) {
            rep(k, 3) {
                if (a[j][k] == b) {
                    a[j][k] = 0;
                }
            }
        }
    }

    if (!a[0][0] && !a[0][1] && !a[0][2]) { cout << "Yes" << endl; return 0; }
    if (!a[1][0] && !a[1][1] && !a[1][2]) { cout << "Yes" << endl; return 0; }
    if (!a[2][0] && !a[2][1] && !a[2][2]) { cout << "Yes" << endl; return 0; }
    if (!a[0][0] && !a[1][0] && !a[2][0]) { cout << "Yes" << endl; return 0; }
    if (!a[0][1] && !a[1][1] && !a[2][1]) { cout << "Yes" << endl; return 0; }
    if (!a[0][2] && !a[1][2] && !a[2][2]) { cout << "Yes" << endl; return 0; }
    if (!a[0][0] && !a[1][1] && !a[2][2]) { cout << "Yes" << endl; return 0; }
    if (!a[0][2] && !a[1][1] && !a[2][0]) { cout << "Yes" << endl; return 0; }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin>>n;
  unsigned long l[86];
  l[0]=2,l[1]=1;
  if(n<2){
    cout<<l[n];
    return 0;
  }
  for(int i=2; i<=n; i++) l[i]=l[i-1]+l[i-2];
  cout<<l[n];
}

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

int main()
{
    int n;
    cin >> n;
    ll a[n+1];
    rep(i,n) cin >> a[i+1];

    ll b[n+1] = {0};
    
    b[n] =  2*a[n];
    for( int i = 1; i < n; i++ ){
        if( i%2 == 0 ){
            b[n] +=  2*a[i];
        } 
        else{
            b[n] -=  2*a[i];
        }
    }
    b[n] /= 2;

    for( int i = n-1; i >= 1; i-- ){
        b[i] = -b[i+1] + 2*a[i];
    }

    for( int i = 1; i < n+1; i++ ){
        cout << b[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2816
n=int(input())
a=list(map(int,input().split()))
cnt=cut=total=0
for i in range(n):
    total+=a[i]
    if i%2==0:
        if total<=0:
            cnt+=abs(1-total)
            total=1
    else:
        if 0<=total:
            cnt+=abs(-1-total)
            total=-1
total=0
for i in range(n):
    total+=a[i]
    if i%2==0:
        if 0<=total:
            cut+=abs(-1-total)
            total=-1
    else:
        if total<=0:
            cut+=abs(1-total)
            total=1
print(min(cut,cnt))


Measured memory_bytes: 14464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h){
    rep(j,w){
      cin>>a[i][j];
    }
  }
  vector<bool>f(h,false);
  vector<bool>flag(w,false);  
   rep(i,h){
    rep(j,w){
      if(a[i][j]=='#')f[i]=true;
    }
  }
  rep(j,w){
    rep(i,h){
      if(a[i][j]=='#')flag[j]=true;
    }
  }
  rep(i,h){
    if(!f[i]) continue;
    rep(j,w){
      if(flag[j])cout<<a[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func honest(n int, i uint) int {
	return (n >> i) & 1
}

func honestsNum(n int) int {
	ret := 0
	for i := 0; n > 0; i++ {
		if n&1 == 1 {
			ret++
		}
		n >>= 1
	}
	return ret
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	var n uint
	fmt.Scan(&n)
	a := make([]int, n)
	x := make([][]int, n)
	y := make([][]int, n)
	for i := uint(0); i < n; i++ {
		fmt.Scan(&a[i])
		x[i] = make([]int, a[i])
		y[i] = make([]int, a[i])
		for j := 0; j < a[i]; j++ {
			fmt.Scan(&x[i][j], &y[i][j])
			x[i][j]--
		}
	}

	// bit全探索
	iMax := 1 << n
	ans := 0 // i = 0のとき
	for i := 1; i < iMax; i++ {
		ok := true
		for j := uint(0); j < n; j++ {
			if honest(i, j) == 0 {
				continue
			}
			for k := 0; k < a[j]; k++ {
				if honest(i, uint(x[j][k])) != y[j][k] {
					ok = false
					break
				}
			}
			if !ok {
				break
			}
		}
		if ok {
			ans = max(ans, honestsNum(i))
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
int main (){
int a,b,c;
  scanf("%d",&a);scanf("%d",&b);scanf("%d",&c);
  if (a%b==0){
    printf("%d", (a/b)*c);
  }
  else 
    printf("%d", ((a/b)+1)*c);
  return 0;
}


Measured memory_bytes: 1728
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

      
N,M = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(M)]
ab = ab[::-1]
uf = UnionFind(N)
dli = [N*(N-1)//2]*M

for i in range(M-1):
  a = ab[i][0]-1
  b = ab[i][1]-1
  d = 0
  if not uf.same(a,b):
    d = uf.size(a)*uf.size(b)
  uf.union(a,b)
  
  dli[i+1] = dli[i] - d
  
dli = dli[::-1]
for el in dli:
  print(el)

Measured memory_bytes: 35276
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	s := nextStr()
	str := strings.Split(s, "")
	if str[2] == str[3] && str[4] == str[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        x: usize,
        y: usize,
    }
    let mut ans = "No";
    for c in 0..=x {
        let t = x - c;
        if c * 2 + t * 4 == y {
            ans = "Yes";
            break;
        }
    }
    println!("{}", ans);
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int x,t;
    cin >> x >> t;
    cout << max(x-t,0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define sqr(x) (x) * (x)
#define cube(x) (z) * (z) * (x)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int
const double PI=3.14159265358979323846;

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}

signed main() {
  int R = in();
  cout << 2 * R * PI << endl;
}


Measured memory_bytes: 3764
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <iomanip>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

ll f(int A, int B) {
  string sa = to_string(A);
  string sb = to_string(B);
  return max(sa.size(), sb.size());
}

int main() {
  ll N;
  cin >> N;
  ll mi = 100;
  for(ll i = 1; i * i <= N; i++) {
    if (N % i != 0) continue;
    ll j = N / i;
    mi = min(mi, f(i, j));
  }
  cout << mi << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long sum1 = 0;
	long long numbers[200000];
	int N;
	cin >> N;
	for(int i = 0; i < N; ++i){
		cin >> numbers[i];
	}
	for(int i = 0; i < N-1; ++i){
		if(numbers[i+1] < numbers[i]){
			sum1+=numbers[i] - numbers[i+1]; 
			numbers[i+1] = numbers[i+1] + (numbers[i] - numbers[i+1]);
		}

	}
	cout << sum1; 
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 1001;
const int INF = 1234567890;

int w,h;
int s[N][N]={};
int ps[N][N]={};

int dp[N][N][2];
int dfs(int y, int x, int t)
{
    if(dp[y][x][t] != -INF) return dp[y][x][t];
    if(x==w) return 0;

    int ret;
    if(t==0)
    {
        ret = -INF;
        // down
        if(y+1<=h) ret = max(ret, dfs(y+1,x,!t));
        // right
        if(x+1<=w)
        {
            int diff = 2*ps[y][x+1] - ps[h][x+1];
            ret = max(ret,dfs(y,x+1,!t) + diff);
        }
    }
    else
    {
        ret = INF;
        // down
        if(y+1<=h) ret = min(ret, dfs(y+1,x,!t));
        // right
        if(x+1<=w)
        {
            int diff = 2*ps[y][x+1] - ps[h][x+1];
            ret = min(ret,dfs(y,x+1,!t) + diff);
        }
    }

    return dp[y][x][t] = ret;
}

int main()
{
    scanf(" %d %d", &w, &h);
    rep(i,h)rep(j,w) scanf(" %d", &s[i+1][j+1]);

    // prefix sum (vertical)
    rep(i,w+1)
    {
        for(int j=1; j<=h; ++j) ps[j][i] = ps[j-1][i]+s[j][i];
    }

    rep(i,N)rep(j,N)rep(k,2) dp[i][j][k] = -INF;
    printf("%d\n", abs(dfs(0,0,0)));
    return 0;
}

Measured memory_bytes: 18948
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a <= 1){ return 1; } else{ return a * fact(a - 1); } }
template<class T> inline ll comb(T a, T b){ return a == 0 ? 0 : fact(a) / fact(b) / fact(a - b); }

int main(){
    ll H;
    cin >> H;
    ll cnt = 0;
    while (H >= pow(2, cnt)){
        cnt++;
    }
    ll ans = 0;
    rep(i, 0, cnt){
        ans = ans * 2 + 1;
    }
    cout << ans << endl;
}

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

string s;

bool solve() {
    string rev = s;
    reverse(rev.begin(), rev.end());
    if (s != rev) {
        return false;
    }

    string s1, s2;
    int n = s.size();
    for (int i = 0; i < (n - 1) / 2; i++) {
        s1.push_back(s.at(i));
    }
    rev = s1;
    reverse(rev.begin(), rev.end());
    if (s1 != rev) {
        return false;
    }

    for (int i = (n + 3) / 2 - 1; i < n; i++) {
        s2.push_back(s.at(i));
    }
    rev = s2;
    reverse(rev.begin(), rev.end());
    if (s2 != rev) {
        return false;
    }

    return true;
}

int main() {
    cin >> s;
    if (solve()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main(){
    int k;
    string s;
    cin >> k >> s;
    string str;
    if(s.size() > k){
        str = s.substr(0,k);
        str += "...";
    }else{
        str = s;
    }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 3628
/* ex 9_1
   riverstone */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//入力文字数の上限
#define SIZE 20
 
//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}
 
//出力
void print_stack(stack *stk){
    int i;
    for (i=0;i < stk->count;i++){
        printf("%c",stk->data[SIZE-i-1]);
    }
    printf("\n");
}

int main(void){
    int i=0;
    char string[SIZE];
    stack stk;
 
    //スタックを初期化
    initialize_stack(&stk);
 
    //入力を受け取る
    scanf("%s", string);

    //stringの中身を一文字ずつ見ていく
    for(i=0;i<strlen(string);i++){
        //入力文字が0か1の場合
        if(string[i]=='0' || string[i]=='1'){
            //スタックにプッシュする
            push(&stk,string[i]);
        }

        //入力文字がBの場合
        else if(string[i]=='B' && stk.count>0){
            //スタックから一文字popする
            pop(&stk);
        }
    } 

    //stackの中身を出力
    print_stack(&stk);
    printf("\n");
    return 0;
}


Measured memory_bytes: 1620
#include <string>
#include <vector>
#include <numeric>
#include <iostream>

using namespace std;

int main()
{
	int T, P, R, A, B, C; string M;

	while (true)
	{
		cin >> T >> P >> R;

		if (T == 0 && P == 0 && R == 0) { break; }

		vector<int> S(T, 0);

		vector<vector<int> > W(T, vector<int>(P, 0));

		for (int i = 0; i < R; i++)
		{
			cin >> A >> B >> C >> M;

			if (M == "WRONG")
			{
				W[A - 1][B - 1] += 1;
			}
			else
			{
				S[A - 1] += (1000000 - W[A - 1][B - 1] * 1200 - C);
			}
		}

		vector<int> Q(T); iota(Q.begin(), Q.end(), 1);

		for (int i = 0; i < T; i++)
		{
			for (int j = i + 1; j < T; j++)
			{
				if (S[i] < S[j] || (S[i] == S[j] && Q[i] > Q[j]))
				{
					swap(S[i], S[j]); swap(Q[i], Q[j]);
				}
			}
		}

		for (int i = 0; i < T; i++)
		{
			cout << Q[i] << ' ' << (S[i] + 999999) / 1000000 << ' ' << (1000000 - S[i] % 1000000) % 1000000 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3180
// Copyright 2017 wu_qing
#include <cstdio>
int n, a, x, y = 3000;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a);
        if (a > x) x = a;
        if (a < y) y = a;
    }
    printf("%d\n", x - y);
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    unsigned long ans{0};
    for(unsigned long i = 1; i * (i + 2) <= N; ++i){
        if(!(N % i)){
            ans += N / i - 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n, m;

int need[1001];

main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	vector<pii> segs;
	REP(i, m){
		int l, r;
		cin >> l >> r;
		need[l-1] = max(need[l-1], r-1);
	}
	sort(ALL(segs));
	int back = 0;
	int head = 0;
	int ans = 0;
	REP(i, n+1){
		if(head == i){
			ans += (i - back)*2;
			head = 0;
		}
		if(need[i]){
			if(head == 0) back = i;
			head = max(head, need[i]);
		}
		ans ++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	int N; cin >> N;
	int p[N], q[N];
	for (int i = 0; i < N; ++i) {
    	cin >> p[i];
    	q[i] = i+1;
    }
	int cnt = 0;
	for (int i = 0; i < N; ++i) {
    	if (p[i] != q[i]) {
        	++cnt;
        }
    }
	if (cnt == 0 || cnt == 2) {
    	cout << "YES" << endl;
    } else {
    	cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int N = 15;
int dp[1 << N][N + 1],Sum[1 << N],G[N + 1][N + 1];
inline int read(){
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + ch - '0',ch = getchar();
	return x * flag;
}
int main(){
	int n = read(),m = read(),tot = 0;
	For(i,1,m){
		int x = read(),y = read(),z = read();
		G[x][y] = G[y][x] = z,tot += z;
	}
	For(i,1,(1 << n) - 1){
		For(j,1,n)if(i & (1 << (j - 1)))
			For(k,j + 1,n)if(i & (1 << (k - 1)))
				Sum[i] += G[j][k];
	}
	memset(dp,-63,sizeof(dp));
	dp[1][1] = 0;
	For(i,1,(1 << n) - 1)For(j,1,n){
		int res = dp[i][j];
		if(res < 0)continue;
		For(k,1,n)if(!(i & (1 << (k - 1))) && G[j][k])
			dp[i | (1 << (k - 1))][k] = max(dp[i | (1 << (k - 1))][k],res + G[j][k]);
		int S0 = (1 << n) - 1 - i;
		for(int S = S0;S;S = (S - 1) & S0)
			dp[i | S][j] = max(dp[i | S][j],res + Sum[S | (1 << (j - 1))]);
	}
	printf("%d\n",tot - dp[(1 << n) - 1][n]);
	return 0;
}

Measured memory_bytes: 2432
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  int m;
  cin >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}


Measured memory_bytes: 256
/*
[ ( ^ _ ^ ) ]
*/

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;

    long max(long...x) {long rs = x[0]; for(long y: x) rs = Math.max(rs, y); return rs;}
    long min(long...x) {long rs = x[0]; for(long y: x) rs = Math.min(rs, y); return rs;}
    

    int n;
    ArrayList<ArrayList<Integer>> g;
    HashMap<Long, Long> mp;

    long go(int v, int c, int p) {
        long k = 100l*v + c;
        if(mp.containsKey(k)) return mp.get(k);

        long rs = 1;
        if(c==0) {
            for(int u: g.get(v)) {
                if(u!=p) {
                    long x = (go(u, 0, v) + go(u, 1, v))%MOD;
                    rs = (rs * x) % MOD;
                }
            }
        } else {
            for(int u: g.get(v)) {
                if(u!=p) {
                    long x = go(u, 0, v);
                    rs = (rs * x) % MOD;
                }
            }
        }
        mp.put(k, rs%MOD);
        return rs%MOD;
    }

    void solve(InputReader in, PrintWriter out) throws IOException {
        n = in.nextInt();
        g = new ArrayList<>();
        for(int i=0; i<n; i++) g.add(new ArrayList<>());
        for(int i=0; i<n-1; i++) {
            int x = in.nextInt()-1;
            int y = in.nextInt()-1;
            g.get(x).add(y);
            g.get(y).add(x);
        }
        mp = new HashMap<>();
        long rs = go(0, 0, -1);
        rs = (rs + go(0, 1, -1))%MOD;
        out.println(rs);
    }
    

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 126680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define INF 1000000000
#define M 1000000007ll
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))
int a[20005],b[20005],p[20005],n;
int main() {
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		scanf("%d",&p[i]);
		--p[i];
	}
	for (int i=0;i<n;i++) {
		a[i]=1;
		b[i]=1;
	}
	int c=1;
	for (int i=1;i<n;i++) {
		a[p[i]]+=c;
		b[p[i]]+=c;
		c++;
	}
	for (int i=1;i<n;i++) a[i]+=a[i-1];
	for (int i=n-2;i>=0;i--) b[i]+=b[i+1];
	int x=*min_element(a,a+n);
	int y=*min_element(b,b+n);
	for (int i=0;i<n;i++) printf("%d%c", a[i]-x+1,(i<n-1)?' ':'\n');
	for (int i=0;i<n;i++) printf("%d%c", b[i]-y+1,(i<n-1)?' ':'\n');
}

Measured memory_bytes: 896
def countingSort(A, B, k):
    C = [0]*k

    for i in range(len(A)):
        C[A[i]] = C[A[i]] + 1
        #print(C)

    for i in range(1, k):
        C[i] = C[i] + C[i-1]
        #print(C)
    
    for j in range(len(A)):
        B[C[A[len(A)-1-j]]-1] = A[len(A)-1-j]
        C[A[len(A)-1-j]] = C[A[len(A)-1-j]] - 1
        #print(C)

    return " ".join(map(str, B))

n = int(input())
X = [0]*n
Y = list(map(int, input().split()))

print(countingSort(Y, X, max(Y)+1))


Measured memory_bytes: 240644
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] a = new int[4];
		for(int i = 0; i < 4; i++){
			int x = sc.nextInt();
			switch(x){
			case 1: a[i] = sc.nextInt() * 6000;
			break;
			case 2: a[i] = sc.nextInt() * 4000;
			break;
			case 3: a[i] = sc.nextInt() * 3000;
			break;
			case 4: a[i] = sc.nextInt() * 2000;
			}
		}
		for(int i = 0; i < 4; i++)
			System.out.println(a[i]);
		
		}
	}

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

int32_t main()
{
  int n; cin>>n;
  map<string,int> mp;
  for(int i = 0; i < n; i++)
  {
  string str; cin>>str;
    sort(str.begin(),str.end());
  	mp[str]++;
  
  }
  int ans = 0;
  for(auto x : mp) ans += x.second * (x.second - 1)/2;
  cout<<ans;
}


Measured memory_bytes: 11776
#include<stdio.h>

int main(void){

  int n;

int x;

int i;

long long sum;

int min,max;

scanf("%d",&n);

sum = 0;

min = 1000000;

max = -1000000;

for(i = 0;i<n;i++){

    scanf("%d",&x);

    sum+=x;

    if(x<min){

      min=x;

    }

    if(x>max){

      max=x;

    }

  }

  printf("%d %d %lld\n",min,max,sum);

return 0;

}
 

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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < 3;) {
        if (s[i] == 'S')
            i++;
        else {
            int j = i;
            while (j < 3 && s[j] == 'R') {
                j++;
            }
            ans = max(ans, j - i);
            i = j;
        }
    }

    cout << ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3648
#include<stdio.h>

int main()
{
  int i,n,minv,maxv;
  scanf("%d",&n);
  int R[n];
  for(i=0;i<n;i++) scanf("%d",&R[i]);
  minv=R[0];
  maxv=R[1]-R[0];
  for(i=1;i<n;i++)
    {
      if(maxv<R[i]-minv) maxv=R[i]-minv;
      if(minv>R[i]) minv=R[i];
    }
  printf("%d\n", maxv);
  return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int N = 2e5 + 10;
 
#define FILENAME ""
 
int n;
int m;
 
int dp[N][2];
bool was[N][2];

vi a;

int f (int v, int k) {
	if (was[v][k]) re dp[v][k];
	int ans = inf;
	for (int i : a) {
		if (v + i <= m) {
			if (f (v + i, k ^ 1) == k) ans = k;
			else if (ans == inf) ans = k ^ 1;
		}
	}
	if (ans == inf) {
		dp[v][k] = k ^ 1;
		re dp[v][k];
	}
	was[v][k] = 1;
	dp[v][k] = ans;
	re dp[v][k];
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
//  freopen(FILENAME ".in", "r", stdin);
//  freopen(FILENAME ".out", "w", stdout);
	cin >> n >> m;
	a.resize (n);
	for (int i = 0; i < n; i++) cin >> a[i];
	cout << (f (0, 0) ? "Second" : "First");
    re 0;
}

Measured memory_bytes: 7552
#include<stdio.h>
#include<stdlib.h>
main()
{
	int n,r=0,i;
	int* v;
	int* c;
	scanf("%d\n",&n);
	v=(int*)malloc(sizeof(int)*n);
	c=(int*)malloc(sizeof(int)*n);
	for(i = 0; i < n; i++)scanf("%d", &v[i]);
	for(i = 0; i < n; i++)scanf("%d", &c[i]);
	for(i=0;i<n;++i)if(v[i]-c[i]>0)r+=v[i]-c[i];
	printf("%d\n",r);
	free(v);
	free(c);
}


Measured memory_bytes: 128
/*
 * @Author: Kaizyn
 * @Date: 2020-03-22 20:18:39
 * @LastEditTime: 2020-03-22 20:56:33
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 15;
const int M = 1e3+7;
const int MOD = 1e9+7;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;

int n, m, k;
char a[N][M];
int num[N];

inline bool check(const int &i)
{
    for (int l = 0, now = 0; l < n; ++l) {
        now += num[l];
        if (now > k) return false;
        if ((i>>l)&1) now = 0;
    }
    return true;
}

inline void solve()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int res = INF;
    // cut in horizontal (i>>j)&1 if cur between j && j+1
    for (int i = 0, cnt; i < (1<<(n-1)); ++i) {
        memset(num, 0, sizeof num);
        cnt = __builtin_popcount(i);
        // cut in vertical
        for (int j = 0, flag; j < m; ++j) {
            flag = 0;
            for (int l = 0; l < n; ++l) {
                if (a[l][j] == '1') ++num[l];
            }
            if (check(i)) continue;
            // add the col exceed, cut between j-1 && j
            ++cnt;
            for (int l = 0; l < n; ++l) {
                num[l] = a[l][j] == '1';
            }
            if (!check(i)) { cnt = INF; break; }
        }
        res = min(res, cnt);
    }
    cout << res << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long dp[4001]={0};
int main(){
    dp[0]=1;
    for(int i=0;i<4;++i){
        for(int j=i*1000;j>=0;--j){
            long long back=dp[j];
            dp[j]=0;
            for(int k=0;k<=1000;++k){
                dp[j+k]+=back;
            }
        }
    }
    int n;
    while(cin>>n){
        cout<<dp[n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3144
s = input()
s.split()
length = len(s)
i = 2
f1 = 0
f2 = 0
i2 = 1
f2 = 1
f3 = 0
if s[0] == "A":
    while i < length - 1:
        if s[i] == "C":
            f1 = i
        i = i + 1
    if f1 > 0:
        f2 = 0
        while i2 < length:
            if ord(s[i2]) < 91 and i2 != f1:
                f2 = 1
            i2 = i2 + 1
    if f2 == 0:
        print("AC")
        f3 = 1
if f3 == 0:
    print("WA")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

ll gcd(ll a,ll b){return b ? gcd(b,a%b) :a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}




const int m =2019;
int main()
{
ll x,k,d;
cin>>x>>k>>d;
while(0<k){
    if(llabs(x/d)!=0){
        if(0<=k-llabs(x/d)){
           ll a=x/d;
           x-=d*a;
           k-=llabs(a);
           k%=2; 
           continue;
        }
        else{
            if(0<=x)x-=k*d;
            if(x<0)x+=k*d;
            k=0;
            continue;
        }
    }
    if(0<=x){
        x-=d;
        k--;
        if(x<=0){
            k%=2;
        }
    }else{
        x+=d;
        k--;
        if(0<=x){
            k%=2;
        }
    }
}
cout<<llabs(x)<<endl;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int d[100005], a[100005];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    d[1] = 0;
    d[2] = abs(a[1] - a[2]);
    for(int i = 3; i <= n; ++i)
        d[i] = min(d[i - 1] + abs(a[i - 1] - a[i]), d[i - 2] + abs(a[i - 2] - a[i]));
    cout << d[n];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;


int main(void){

	vector< bool > v( 30, true );

	for( int i = 0; i < 28; i++ ) {
		int n;
		cin >> n;
		v[n-1] = false;
	}

	for( int i = 0; i < 30; i++ ) {
		if( v[i] ) cout << i + 1 << endl;
	}

    return 0;
}

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

int main()
{
  
  int h,w;
  cin>>h>>w;
  int arr[h][w];
  int cost[10][10];
  
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      cin>>cost[i][j];
  
  
  
  for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
        
        if(cost[i][j]>cost[i][k]+cost[k][j])
          cost[i][j]=cost[i][k]+cost[k][j];
      }
    }
  }
  
  long long sum=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int a;
      cin>>a;
      if(a>=0)
      sum=sum+cost[a][1];
    }
  }
  
  cout<<sum<<endl;
  
}


Measured memory_bytes: 256
#!/usr/bin/env runghc
mysum :: Int -> Int -> Int -> Int -> Int -> IO Int
mysum 0 ma mi s z = return (div (s-ma-mi) (z-2)) --(floor(fromIntegral(s-ma-mi)/fromIntegral(z-2)))
mysum n ma mi s z = do
	x <- readLn
	y <- mysum (n-1) (max ma x) (min mi x) (s+x) z
	return (y)

main = do
	n <- readLn
	if n/=0 then do
		s <- mysum n 0 1000 0 n
		print s
		main
	else return ()

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

int main(){
  int n, t, ti, cmin=1000000;
  cin >> n >> t;

  int w;
  while(n--){
    cin >> w >> ti;
    if(ti <= t){
      cmin = min(cmin, w);
    }
  }

  if(cmin != 1000000){
    cout << cmin << endl;
  }else {
    cout << "TLE" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,M;
  cin >> N >> M;
  vi X(M);
  rep(i,M) {
    cin >> X[i];
  }
  if(N >= M) {
    cout << 0 << endl;
    return 0;
  }
  sort(rng(X));
  vp diff(M-1);
  srep(i,1,M) {
    diff[i-1] = P(X[i] - X[i-1],i-1);
  }
  sort(rng(diff),[](P &l, P &r) {
        return l.first > r.first;
  });
  vp select;
  rep(i,N-1) {
    select.push_back(diff[i]);
  }
  select.push_back(P(INF,M-1));
  sort(rng(select),[](P &l, P &r) {
        return l.second < r.second;
  });
  int ans = X[select[0].second] - X[0];
  srep(i,1,N) {
    ans += X[select[i].second] - X[select[i-1].second+1];
  }
  cout << ans << endl;
  return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  int n;
  cin >> n;
  VI v(n);
  REP(i, n) {
    cin >> v[i];
  }

  int tmp = v[0];
  int ans = 0;
  REP(i, n) {
    if (v[i] <= tmp) {
      ans++;
      tmp = v[i];
    }
  }

  ANS(ans)

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

static void printQq();
static const int Max = 10;

int main(int /* argc */, char **/* argv */)
{
    printQq();

    return 0;
}

static void printQq()
{
    for (int i = 1; i < Max; ++i) {
       for (int j = 1; j < Max; ++j ) {
           std::cout << i << "x" << j << "=" << i * j << std::endl;
       }
    }
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  ll n,m;
  cin>>n>>m;
  if(2*n >= m){
    cout<<m/2<<endl;
  }
  else{
    cout<<n+(m-2*n)/4<<endl;
  }
  return 0;
}


Measured memory_bytes: 256