akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))


INF = float("inf")
MOD = 10**9 + 7

class Combination(object):
    def __init__(self, N, mod=MOD):
        fac, finv, inv = [0] * (N + 1), [0] * (N + 1), [0] * (N + 1)
        fac[:2] = 1, 1
        finv[:2] = 1, 1
        inv[1] = 1
        for i in range(2, N + 1):
            fac[i] = fac[i - 1] * i % mod
            inv[i] = -inv[mod % i] * (mod // i) % mod
            finv[i] = finv[i - 1] * inv[i] % mod
        self.N = N
        self.MOD = mod
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def __call__(self, n, k):
        return self.C(n, k)

    def C(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        fac = self.fac
        finv = self.finv
        mod = self.MOD
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

    def P(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n] * self.finv[n - k]


def main():
    N, M = MAP()
    cmb = Combination(M)

    ans = 0
    for i in range(N + 1):
        buf = (-1) ** i * cmb(N, i)
        buf %= MOD
        buf *= cmb.P(M, i)
        buf %= MOD
        buf *= pow(cmb.P(M - i, N - i), 2, MOD)
        buf %= MOD
        ans += buf
        ans %= MOD
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 68132
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if((a+b)==3) printf("3\n");
	else if((a+b)==4) printf("2\n");
	else if((a+b)==5) printf("1\n");
	return 0;
}



Measured memory_bytes: 128
import java.io.*;
public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	while(true){
		String str=input.readLine();
		String[] atr=str.split(" ");
		int a=Integer.parseInt(atr[0]);
		String op=atr[1];
		int b=Integer.parseInt(atr[2]);
		if(op.equals("+")){
			System.out.println(a+b);
		}
		else if(op.equals("-")){
			System.out.println(a-b);
		}
		else if(op.equals("*")){
			System.out.println(a*b);
		}

		else if(op.equals("/")){
			System.out.println(a/b);
		}
		else if(op.equals("?")){
			break;
			}
			

		}
	
		
	}
}

Measured memory_bytes: 24196
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MOD (ll)998244353

int l[200001], r[200001];
set<int> se;
vector<int> v;
ll dp[200001];
ll dpsum[200001];

int main(void)
{
    int n, k;
    scanf("%d %d", &n, &k);

    for (int i = 1; i <= k; i++)
    {
        scanf("%d %d", &l[i], &r[i]);
    }

    dp[1] = 1LL, dpsum[1] = 1LL;

    for (int i = 1; i <= 200000; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            dp[i] = (dp[i] + dpsum[max(0, i - l[j])] - dpsum[max(0, i - r[j] - 1)] + MOD) % MOD;
        }
        dpsum[i] = (dpsum[i - 1] + dp[i]) % MOD;
    }

    /*for (int i = 1; i <= n; i++)
        printf("%lld ", dp[i]);
    printf("\n");
    for (int i = 1; i <= n; i++)
        printf("%lld ", dpsum[i]);
    printf("\n");*/

    printf("%lld", dp[n]);
    return 0;
}

Measured memory_bytes: 6376
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
const int N=100+5;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,x,y;
int main(){
	n=read();m=read();x=read();y=read();
	rep(i,1,n)x=max(x,read());
	rep(i,1,m)y=min(y,read());
	if(y>x)puts("No War");else puts("War");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  char N[4];
  std::cin >> N;

  char n1 = N[0];
  char n2 = N[1];
  if ( n1 == N[1] && n1 == N[2] ) std::cout << "Yes" << std::endl;
  else if ( n2 == N[2] && n2 == N[3] ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    ll l, r; cin >> l >> r;
    ll ans = 2018;
    for(ll i = l; i < r; i++)
    {
        for(ll j = i + 1; j <= r; j++)
        {
            if(i % 2019 == 0 || j % 2019 == 0)
            {
                cout << 0 << endl;
                return;
            }
            ans = min(ans, (i % 2019) * (j % 2019) % 2019);
        }
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b,c; cin>>a>>b>>c;
	if(b-a==c-b) cout<<"YES";
	else cout<<"NO";
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int sum = reader.nextInt() + reader.nextInt();
    out.println(sum < 10 ? "" + sum : "error");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 23124
# range_sum_query
# 
# 
s=STDIN.gets.split
n = s[0].to_i
q = s[1].to_i

ar  = Array.new(100001,0)
ar2 = Array.new(1001  ,0)

1.upto(q) {
s=STDIN.gets.split
com = s[0].to_i
x   = s[1].to_i
y   = s[2].to_i
#printf(":%d %d %d\n",com,x,y)
if(com==0)
  x1=x/100
  diff = y - ar[x]
  ar[x] += y
  ar2[x1] += y
elsif (com==1)
  x1=x/100
  y1=y/100
  ans_=0
  if(x1==y1 || x1+1==y1)
    x.upto(y){|i|
      ans_ += ar[i]
    }
  else
    if (x % 100) > 0 then
      x.upto(x1*100+99){|i| ans_ += ar[i]   }
      (x1+1).upto(y1-1){|i| ans_ += ar2[i]  }
    else
      x1.upto(y1-1){|i|     ans_ += ar2[i]  }
    end
    (y1*100).upto(y){|i| ans_ += ar[i]    } 
  end
  puts ans_
end
}

Measured memory_bytes: 9636
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;
int a[1020];
int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  int n,k,ans = 0;
  cin>>n>>k;
  for(int i = 1;i <= n;i++) cin>>a[i];
  sort(a+1,a+1+n);
  for(int i = 1;i <= k;i++) ans += a[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n;
  cin>>n;
  long a[n], b[n], c[n], ans=0;
  for(int i=0; i<n; i++){
    cin>>a[i]>>b[i];
    c[i]=a[i]+b[i];
    ans-=b[i];
  }
  sort(c,c+n);
  for(int j=0; j<n; j+=2)
    ans+=c[n-j-1];
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int N, D;
    cin >> N >> D;
    int ans = N / (2 * D + 1);
    if(N % (2 * D + 1) != 0) { ans++; }

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	int a[20];
	rep(i,0,n) cin >> a[i];

	int Max = a[0];
	int ans = 1;

	rep(i,1,n){
		if( a[i] >= Max ){
			ans += 1;
		}
		Max = max(Max , a[i] );
	}

	cout << ans << endl;
	ret 0;
}

Measured memory_bytes: 256
let () = Scanf.scanf "%d\n%s" @@ fun n s ->
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 @@
  Array.init (n - 2) @@ fun i ->
    if s.[i] = 'A' && s.[i + 1] = 'B' && s.[i + 2] = 'C'
    then 1
    else 0


Measured memory_bytes: 2432
class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y

class Line():
    def __init__(self, x1, y1, x2, y2):
        self.p1 = Point(x1, y1)
        self.p2 = Point(x2, y2)

    def get_slope(self):
        if self.p1.x == self.p2.x:
            return float('inf')
        return (self.p2.y - self.p1.y)/(self.p2.x - self.p1.x)

q = int(input())
for i in range(q):
    x0, y0, x1, y1, x2, y2, x3, y3 = list(map(int, input().split(' ')))
    line1, line2 = Line(x0, y0, x1, y1), Line(x2, y2, x3, y3)
    a1, a2 = line1.get_slope(), line2.get_slope()
    if a1 == a2: # 平行
        print('2')
    elif round(a1*a2, 8) == -1.0:
        print('1')
    elif (a1 == float('inf') and a2 == 0) or (a1 == 0 and a2 == float('inf')):
        print('1')
    else:
        print('0')


Measured memory_bytes: 5648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,a,cnt=0,b,c,d;
    cin>>n>>m>>a;
    if(n>m)
    {
        c=a/n;
        d=a%n;
        if(d>0)
        {
            cnt=1;
        }
        cout<<(c+cnt)<<endl;
    }
    else
    {
        c=a/m;
        d=a%m;
        if(d>0)
        {
            cnt=1;
        }
        cout<<(c+cnt)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

// AC
public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int x, y;
	int n;
	int[] xs, ys;

	// JGÌWvÍÍ
	int[] dx={-1, 0, 1, -1, 0, 1, -2, -2, -2, 2, 2, 2};
	int[] dy={-2, -2, -2, 2, 2, 2, -1, 0, 1, -1, 0, 1};

	void run(){
		for(;;){
			x=sc.nextInt();
			y=sc.nextInt();
			if((x|y)==0){
				break;
			}
			n=sc.nextInt();
			xs=new int[n];
			ys=new int[n];
			for(int i=0; i<n; i++){
				xs[i]=sc.nextInt();
				ys[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		for(int i=0; i<dx.length; i++){
			if(dfs(x+dx[i], y+dy[i], 0)){
				println("OK");
				return;
			}
		}
		println("NA");
	}

	// (x,y)ÉÄkÔÚÌXvN[ÉË
	boolean dfs(int x, int y, int k){
		if(k==n){
			return true;
		}
		if(x<0||x>=10||y<0||y>=10){
			return false;
		}
		if(x<xs[k]-1||x>xs[k]+1||y<ys[k]-1||y>ys[k]+1){
			return false;
		}
		for(int i=0; i<dx.length; i++){
			if(dfs(x+dx[i], y+dy[i], k+1)){
				return true;
			}
		}
		return false;
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N,K;
const ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	ll ret=0;
	for(ll i=K;i<=N+1;i++) {
		ll mi=i*(i-1)/2;
		ll ma=(N+(N-i+1))*i/2;
		(ret+=ma-mi+1)%=mo;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 200000;
int N, A[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> A[i];
	vector<int> x(A, A+N);
	sort(x.begin(), x.end());

	for(int i=0; i<N; i++){
		if(A[i]==x[N-1]) cout << x[N-2] << endl;
		else cout << x[N-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include<string>
#include<vector>
using namespace std;
int dx[8] = {-1,-1,-1,0,0,+1,+1,+1};
int dy[8] = {-1,0,+1,-1,+1,-1,0,+1};
int main(void){
    int H, W, c = 0;
    cin >> H >> W;
    vector<string> s(H);
    for(int y = 0; y < H; y++){
        cin >> s[y];
    }
    for(int y = 0; y < H; y++){
        for(int x = 0; x < W; x++){
            c=0;
            if (s[y][x] == '#') continue;
            for (int k = 0; k < 8; k++) {
                int ny = y+dy[k], nx = x+dx[k];
                if (0<=ny&&ny<H&&0<=nx&&nx<W){
                    if(s[ny][nx] == '#'){
                        c++;
                    } 
                }
            }
            s[y][x] = c + '0';
        }
    }
    for(int y = 0; y < H; y++){
        cout << s[y] << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int min(int a,int b){
 if(a > b)return b;

 return a;
}


int main(){
 int A,B,C,D;
 int t,b;

 scanf("%d",&A);
 scanf("%d",&B);
 scanf("%d",&C);
 scanf("%d",&D);

 t=min(A,B);
 b=min(C,D);

 printf("%d\n",t+b);

 return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(long long i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
int N;
cin >> N;
vector<int> a(N);
REP(i, N) cin >> a[i];

sort(all(a));
int ans = a.at(N - 1) - a.at(0);
print(ans);

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int cnt = 0;
  while (1) {
    rep(i, n) {
      if (a[i] % 2 != 0) {
        cout << cnt << endl;
        return 0;
      }
      a[i] *= 0.5;
    }
    cnt++;
  }

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

Measured memory_bytes: 3580
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

int H,W,K;
int grid[10][1000];
int cum[11][1001];
void add(int i,int j,int x){
    cum[i+1][j+1] += x;
}
void build(int n,int m){
    for(int j = 1;j <= m;j++){
        cum[0][j] += cum[0][j-1];
    }
    for(int i = 1;i <= n;i++){
        cum[i][0] += cum[i-1][0];
    }
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= m;j++){
            cum[i][j] += cum[i-1][j] + cum[i][j-1] - cum[i-1][j-1];
        }
    }
}
int query(int i,int j,int k,int l){//[i,j],(k,l)
    return cum[k][l] - cum[i][l] - cum[k][j] + cum[i][j];
}
int main(void){
    cin >> H >> W >> K;
    rep(i,H)rep(j,W){
        char x;cin >> x;
        if(x == '1')grid[i][j] = 1;
        add(i,j,grid[i][j]);
    }
    build(H,W);
    int ans = INT_MAX;
    for(int i = 0;i < 1<<(H-1);i++){
        vector<int> split;
        split.push_back(0);
        for(int j = 0;j < (H-1);j++){
            if((i >> j) & 1)split.push_back(j+1);
        }
        split.push_back(H);
        int s = split.size();
        int l = 0,r = 0,res = s - 2;
        int impossible = 0;
        while(r < W){
            bool ok = true;
            for(int j = 0;j < s-1;j++){
                ok &= (query(split[j],l,split[j+1],r) <= K);
            }
            if(ok)r++;
            else{
                if(r == l + 1){impossible = 1;break;}
                l = r - 1;
                res++;
            }
        }
        if(impossible)continue;
        
        bool ok = true;
        for(int j = 0;j < s-1;j++){
            ok &= (query(split[j],l,split[j+1],r) <= K);
        }
        if(ok){
            chmin(ans,res);
        }else{
            l = W - 1;
            bool ok2 = true;
            for(int j = 0;j < s-1;j++){
                ok2 &= (query(split[j],l,split[j+1],r) <= K);
            }
            if(ok2){
                chmin(ans,res + 1);
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<double> x(n);
    vector<string> u(n);
    REP(i,n) cin>>x[i]>>u[i];
    double ans = 0;
    REP(i,n){
        if(u[i]== "JPY"){
            ans += x[i];
        } else if(u[i] == "BTC"){
            ans += x[i] * 380000.0;
        }
    }
    cout<<fixed;
    cout<<setprecision(6)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

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

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define SREP(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTF(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define NMAX 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int x[200000];
int tmp[200000];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		Swap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

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

	REP(i, n) {
		scanf("%d", &x[i]);
		tmp[i] = x[i];
	}
	QSort(tmp, 0, n - 1, 1);

	int s = tmp[(n - 1) / 2];
	int b = tmp[(n - 1) / 2 + 1];

	REP(i, n) {
		if (x[i] <= s) {
			PRINTD(b);
		}
		else {
			PRINTD(s);
		}
	}
}

Measured memory_bytes: 3712
loop do
    record_time=2*3600#????????§???????§???°
    time=gets.chomp.split(nil).map(&:to_i)
    break if time.all?{|x|x==-1}
    t=time[2]
    t+=time[1]*60
    t+=time[0]*3600
    #?¨??????????
    rest_of_time=record_time-t
    h=rest_of_time/3600#hour
    m=(rest_of_time%3600)/60#minute
    s=rest_of_time%60#second
    printf("%02d:%02d:%02d\n",h,m,s)
    #3???????????¢??????
    rest_of_time=(record_time-t)*3
    h=rest_of_time/3600#hour
    m=(rest_of_time%3600)/60#minute
    s=rest_of_time%60#second
    printf("%02d:%02d:%02d\n",h,m,s)
end

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = N;
    char tmp = '\0';
    rep(i, N) {
        if (S[i] == tmp) ans -= 1;
        tmp = S[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
n,y=(int(x) for x in input().split())
flag = False
n=n+1
for i in reversed(range(n)):
  for j in reversed(range(n-i)):
    k=n-i-j-1
    if 10000*i+5000*j+1000*k == y :
      print(i,j,k)
      flag = True
      break
  if flag:
    break
  
if not flag :
  print(-1,-1,-1)

Measured memory_bytes: 3064
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    ll n, d;
    cin >> n >> d;
    ll res = 0;
    for(int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        if(x * x + y * y <= d * d){
            res++;
        }
    }
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
import bisect
N=int(input())
S=list(map(int,input().split()))
Q=int(input())
T=list(map(int,input().split()))
X=0
P=0
for i in range(Q):
  X=bisect.bisect_left(S,T[i])
  if S[X]==T[i]:
    P=P+1
print(P)


Measured memory_bytes: 16740
INF = float('inf')
def f_dp(x, k, h):
    dp = [INF for i in range(x + 1)]
    dp[0] = 0
    for i in range(1, x):
        for j in range(1, k + 1):
            if i - j >= 0:
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
    return dp

if __name__ == "__main__":
    n, k = map(int, input().split())
    h = list(map(int,input().split()))
    dp = f_dp(n, k, h)

    print(dp[n - 1])
    

Measured memory_bytes: 58848
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<Integer>();
        int n = sc.nextInt();
        //String s = sc.next();
        if(n==0){
            System.out.println("1");
        }else{
            System.out.println("0");
        }
    }
}


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

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

using namespace std;

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

int main() {
  int n, m;
  cin >> n >> m;

  int res = (n * (n - 1) + m * (m - 1)) /2 ;

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import math
#N, K, M = map(int,input().split())
alp = [chr(i) for i in range(97, 97+26)]
#print(alp)
#N = int(input())
#K = int(input())
c = input()
ans = 0
#l = list(map(int,input().split()))
#A = list(map(int,input().split()))
print(alp[alp.index(c)+1])

Measured memory_bytes: 9036
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val K = sc.nextInt()
    val S = sc.next()
    if(S.length <= K){
        println(S)
    }else{
        println(S.substring(0,K) + "...")
    }
}

fun abc000a() {

}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



Measured memory_bytes: 36532
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
//#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}
string s,t;
vector<char> v;
int dp[3001][3001];
int solve(int n,int m)
{   
    if(n==0 || m==0)
        return 0;
    if(dp[n][m]==-1)
    {
        if(s[n-1]==t[m-1])
            {   
                dp[n][m] = 1 + solve(n-1,m-1);}
        else
            dp[n][m] = max(solve(n-1,m),solve(n,m-1));
    }
    return dp[n][m];
}
void print(int n,int m)
{
    if(n==0 || m==0)
        return;
    if(s[n-1] == t[m-1])
    {
     print(n-1,m-1);
     cout<<s[n-1];
    return;}
    if(dp[n-1][m] > dp[n][m-1])
        {print(n-1,m);return;}
    print(n,m-1);
}
int main() {
    
    
    cin>>s>>t;
    memset(dp,-1,sizeof(dp));
    int n = s.length(),m = t.length();
    solve(n,m);
    
    print(n,m);
    return 0;
}


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

using namespace std;
int dx[] = {1,0,-1, 0}; // S,SE,E,NE,N,NW,W,SW
int dy[] = {0,1, 0,-1}; // neighbors

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h, w, ch, cw, dh, dw;
    cin>>h>>w>>ch>>cw>>dh>>dw;
    ch--; cw--; dh--; dw--;
    int dist[h][w]; 
    char s[h][w];
    for (int i=0; i<h; ++i){
        for (int j=0; j<w; ++j){
            cin>>s[i][j];
            dist[i][j] = 1e9;
        }
    }
    int cost = 0;
    dist[ch][cw] = 0;
    deque<pair<int, int> > q ; 
    q.emplace_back(ch, cw) ; 
    while (!q.empty()) {
        pair<int,int> u = q.front(); q.pop_front();                        // queue: layer by layer!
        int x = u.first;
        int y = u.second;
        cost = dist[x][y];
        for (int i=0; i<4; ++i){ 
            int r = x + dx[i]; 
            int c = y + dy[i]; 
            if (r>=0 and r<h and c>=0 and c<w and s[r][c] == '.' and dist[r][c] > cost) {
                dist[r][c] = cost;
                q.emplace_front(r, c) ; 
            }
        }   
        cost++;
        for (int i=max(0,x-2); i<=min(h-1,x+2); ++i){
            for (int j=max(0,y-2); j<=min(w-1,y+2); ++j){
                if ((s[i][j] == '.') and (dist[i][j] > cost)) { 
                    dist[i][j] = cost;
                    q.emplace_back(i, j); 
                }
            }
        }
    }
    dist[dh][dw] == 1e9 ? cout<<"-1":cout<<dist[dh][dw];
}


Measured memory_bytes: 8452
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

int main(){

	ll n;
	cin>>n;
	ll check=0;
	vector<ll> a(n,0);
	for(ll i=0;i<n;i++){
		cin>>a[i];
		if(a[i]!=i+1){
			check++;
		}
	}

	if(check==2 || check==0){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	
	
    return 0;
}


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

int main() {
  int N;
  string S;
  cin>>N;
  string ans="Three";
  for(int i=0;i<N;i++){
    cin>>S;
    if(S=="Y"){
       ans="Four";
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5+5;
struct apple{
	int dlc,clr;	
} ap[maxn];
bool cmp(apple i,apple j){
	return (i.dlc > j.dlc);	
}
long long ans = 0;
int odr[2],a,b,c,cntt[2],cnt=0,tot=0;
int main(){
	cin >> odr[0] >> odr[1] >> a >> b >> c;
	for (int i=1;i<=a;i++){
		apple wzr;
		cin >> wzr.dlc;
		wzr.clr = 1;
		ap[++tot]=wzr;
	}
	for (int i=1;i<=b;i++){
		apple wzr;
		cin >> wzr.dlc;
		wzr.clr = 2;
		ap[++tot]=wzr;
	}
	for (int i=1;i<=c;i++){
		apple wzr;
		cin >> wzr.dlc;
		wzr.clr = 0;
		ap[++tot]=wzr;
	}
	sort(ap+1,ap+tot+1,cmp);
	for (int i=1;i<=tot;i++){
		if (cnt >= odr[0]+odr[1]) break;
		apple wzr = ap[i];
		if (!wzr.clr){
			ans += wzr.dlc;
			cnt ++;
		}
		else{
			if (cntt[wzr.clr-1] >= odr[wzr.clr-1]) continue;
			else{
				cnt ++;
				cntt[wzr.clr-1]++;
				ans += wzr.dlc;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2560
while true do
  n, m = gets.split.map(&:to_i)
  break if n + m == 0
  a = gets.split.map(&:to_i)
  charge = []
  min = m
  for i in 0...n do
    case m / a[i] * a[i]
      when 0...min
        charge = [i]
        min = m / a[i] * a[i]
      when min
        charge.push(i)
    end
  end
  if charge.size == 1
    p charge.first + 1
  else
    charge.sort! {|i, j| a[i] <=> a[j]}
    p a[charge[0]] != a[charge[1]] ? charge.first + 1 : n
  end
end

Measured memory_bytes: 6128
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

vector<int> G[MAX_N];
bool visit[MAX_N];

bool dfs(int u, int t, int d)
{
    visit[u] = true;
    for(int v : G[u]){
        if(d > 1 && v == t) return true;
        if(!visit[v]){
            if(dfs(v, t, d+1)){
                return true;
            }
        }
    }
    return false;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vi vec;
    rep(i,m){
        int u, v;
        cin >> u >> v;
        G[u-1].pb(v-1), G[v-1].pb(u-1);
    }
    bool ok = false;
    rep(i,n){
        if(len(G[i]) % 2){
            cout << "No\n";
            return 0;
        }else if(len(G[i]) >= 6){
            ok = true;
        }else if(len(G[i]) == 4){
            vec.pb(i);
        }
    }
    if(ok){
        cout << "Yes\n";
        return 0;
    }
    if(len(vec) >= 3){
        cout << "Yes\n";
    }else if(len(vec) <= 1){
        cout << "No\n";
    }else{
        visit[vec[1]] = true;
        if(dfs(vec[0], vec[0], 0)){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }
    return 0;
}


Measured memory_bytes: 7040
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int h, m, hl, ml;
	double angle, radian, ans;
	scanf("%d%d%d%d", &hl, &ml, &h, &m);//先看数据范围 
	angle = abs(0.5 *( h * 60 + m) - 6 * m );//小数取绝对值 
	//cout<<angle<<endl;
	if(angle > 180) angle = 360 - angle;
//	if(angle == 0) 
//	{
//		printf("%d", abs(hl - ml));
//		return 0;
//	}
//	if(angle == 180) 
//	{
//		printf("%d", hl + ml);
//		return 0;
//	}
	printf("%.20f", sqrt(hl * hl + ml *ml - 2 * hl * ml * cos(angle * M_PI/180)));
	return 0;
} 

Measured memory_bytes: 4212
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n = int(input())
  la, lb = [], []
  for _ in range(n):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)
  la.sort(), lb.sort()
  
  if n % 2 == 0:
    s = (n-1)//2
    e = s + 2
    ma = sum(la[s:e]) / 2.0
    mb = sum(lb[s:e]) / 2.0
    print(int(2 * (mb - ma) + 1))
  if n % 2 == 1:
    ma = la[n//2]
    mb = lb[n//2]
    print(mb - ma + 1)
    
if __name__=='__main__':
  main()



Measured memory_bytes: 43180
#include<iostream>

using namespace std; 
int main()
{
  int in[5], a[3]; 
  while(true)
  {
    a[0] = a[1] = a[2] = 0;
    cin >> in[0];
    if(!in[0])
      break;
    cin >> in[1] >> in[2] >> in[3] >> in[4];
    for(int i = 0; i < 5; i++)
      a[in[i] - 1]++;
    if(a[0] > 0 && a[1] > 0 && a[2] > 0
        || !a[0] && !a[1] || !a[1] && !a[2] || !a[2] && !a[0])
    {
      for(int i = 0; i < 5; i++)
        cout << 3 << endl;
      continue;
    }
    if(!a[0])
    {
      for(int i = 0; i < 5; i++)
      {
        cout << (in[i] == 2 ? 1 : 2) << endl;
      }
      continue;
    }
    if(!a[1])
    {
      for(int i = 0; i < 5; i++)
      {
        cout << (in[i] == 3 ? 1 : 2) << endl;
      }
      continue;
    } 
    if(!a[2])
    {
      for(int i = 0; i < 5; i++)
      {
        cout << (in[i] == 1 ? 1 : 2) << endl;
      }
      continue;
    }
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define vec_cpy(to,from) copy(all(to),back_inserter(from))
#define ary_cpy(to,from) memcpy(to, from, sizeof from)
#define MOD = 1000000007; 
#ifdef DEBUG
#define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl
#define debug_var(e) cout << "L" << __LINE__ << ": " << #e << " = " << e << endl
#define debug_echo_dp(dp, N) { cout << "[ "; rep(i, N) cout << dp[i] << " ";  cout << "]" << endl; }
#else
#define debug_echo(e)
#define debug_var(e)
#define debug_echo_dp(dp, N)
#endif

int main() {
  int N,M;
  cin >> N >> M;
  int dp[N + 1],c[M];

  rep(i,M) cin >> c[i];

  debug_echo_dp(c, M);

  function<void()> solve = [&](){
    rep(i,M){ //??????????????§?????????
      REP(j,c[i],N + 1){ //????±?????????????????????\???????????????????????????????????????
        int hoge = dp[j - c[i]] + 1;
        if(dp[j] == 0) dp[j] = hoge;
        else dp[j] = min(dp[j], hoge);
      } 
    }
  };

  memset(dp, 0, sizeof(dp));
  solve();

  debug_echo_dp(dp, N+1);
  cout << dp[N] << endl;
}

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

int s,a[1000005];

int f(int x)
{
	if (x % 2 == 0) return x/2;
		else return 3*x+1;
}

int main()
{
	cin >> s;
	a[s]++;
	int i = 1;
	do{
		s = f(s);
		i++;
		if(a[s]){
			cout << i << endl;
			break;
		}
		a[s]++;
	}while(1);
	return 0;
}

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

int main(void) {
   int i,j;
   int k_len = 0;
   char s[100];
   int s_len;

   scanf("%d",&k_len);

   scanf("%s",s);

   s_len = strlen(s);
   if(s_len <= k_len) {
      printf("%s\n",s);
   }
   if(k_len < s_len) {
      for(i = 0; i < k_len; i++) {
         printf("%c",s[i]);
      }
      printf("...\n");
   }

   return 0;
}

Measured memory_bytes: 1644
#include<iostream>
#include<cstdio>
#include<map>
#include<stack>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;
 
int main() {
  int index;
  char word[40] = {};
  char words_list[110][40] = {};
  map < string, int > dic;
  int page_cnt[110] = {};
  int page[110][40] = {};
  int i = 1, k;
  while(scanf("%s %d", word, &index) != EOF) {
    if(dic[word] == 0) {
      dic[word] = i;
      strcpy(words_list[i], word);
      //cout << word << ' ' << index << endl;
      i++;
    }
    int k = dic[word];
    page[k][page_cnt[k]++] = index;
    // page[k].push_back(index);
    // page[dic[word]][page[dic[word]].size()] = index;
    //cout << word << index << endl;
  }

  for(int j = 1; j < i - 1; j++) {
    for(int k = i - 1; k > j; k--) {
      if(strcmp(words_list[j], words_list[k]) > 0) {
        swap(words_list[j], words_list[k]);
	swap(dic[words_list[j]], dic[words_list[k]]);
	swap(page[j], page[k]);
	swap(page_cnt[j], page_cnt[k]);
      }
    }
  }
  
  for(int j = 1; j < i ; j++) {
    sort(page[j], page[j] + page_cnt[j]);
    cout << words_list[j] << endl;
    for(k = 0; k < page_cnt[j] - 1; k++) {
      cout << page[j][k] << ' ';
    }
    cout << page[j][k] << endl;
  }
  
      
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define Arman_Sykot ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
 
using namespace std;

int main()
{
/*********************/
// Author:
        Arman_Sykot;
/*********************/
    
    int n;
	cin >> n;
	
	int arr[n], arr1[n];
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i] >> arr1[i];
	}

	for (int i = 0; i < n - 2; i++) {
		if (arr[i] == arr1[i] && arr[i + 1] == arr1[i + 1] && arr[i + 2] == arr1[i + 2]) {
			cout << "Yes" << "\n";
			return 0; 
		}
	}
	cout << "No" << "\n";
	
	return 0;
}


Measured memory_bytes: 3656
n=int(input())
a,b=map(int,input().split(" "))
p=list(map(int,input().split(" ")))
first=0
second=0
third=0
for i in p:
    if i<=a:
        first+=1
    elif a+1<=i<=b:
        second+=1
    elif i>=b+1:
        third+=1
co=0
while True:
    if first>0 and second>0 and third>0:
        first-=1
        second-=1
        third-=1
        co+=1
    else:
        break
print(co)

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

int main(){
  string str;
  cin >> str;
  int n = str.size();
  while(n-=2){
    int flag = 1;
    for(int i = 0; i < n/2; i++){
      if(str[i] != str[i+n/2]) flag = 0;
      if(flag == 0) break;
    }
    if(flag) break;
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
a = int(input())
c = []

for i in range(2):
  c.append(list(map(int,input().split())))

for i in range(a):
  if i == 0:
    c[1][0] += c[0][0]
  else:
    c[0][i] += c[0][i-1]
    c[1][i] += max(c[1][i-1],c[0][i])
    
print(c[1][a-1])


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

const int N = 6;
int a[N][N];

signed main() {
    int h, w, k;
    cin >> h >> w >> k;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            a[i][j] = c;
        }
    }
    int cnt = 0;
    for (int m1 = 0; m1 < (1 << h); m1++) {
        for (int m2 = 0; m2 < (1 << w); m2++) {
            int tmp = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (a[i][j] == '#' && m1 >> i & 1 && m2 >> j & 1) tmp++;
                }
            }
            cnt += (tmp == k);
        }
    }
    cout << cnt;
}


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

int main() {

  int H, W;
  cin >> H >> W;

  char cell[H][W];

  for (int y=0; y<H; y++) {
	for (int x=0; x<W; x++) {
	  cin >> cell[y][x];
	}
  }

  // ----------


  for (int y=0; y<H; y++) {
	for (int x=0; x<W; x++) {

	  int cnt = 0;
	  char replace;
	  if ( cell[y][x] == '.' ) {  // もし . セルが来たら チェックを始める
		// search mine
		// 上 ------
		if ( 0 <= y-1 ) {
		  if ( 0 <= x-1 ) {
			if ( cell[y-1][x-1] == '#' ) {   // 左上
			  cnt++;
			}
		  }
		  if ( cell[y-1][x] == '#' ) {          // 上
			cnt++;
		  }
		  if ( x+1 < W ) {
			if ( cell[y-1][x+1] == '#' ) {   // 右上
			  cnt++;
			}
		  }
		}

		// 左右 -----
		if ( 0 <= x-1 ) {
		  if ( cell[y][x-1] == '#' ) {     // 左
			cnt++;
		  }
		}
		if ( x+1 < W ) {
		  if ( cell[y][x+1] == '#' ) {     // 右
			cnt++;
		  }
		}

		// 下 -----
		if ( y+1 < H ) {
		  if ( 0 <= x-1 ) {
			if ( cell[y+1][x-1] == '#' ) {   // 左下
			  cnt++;
			}
		  }
		  if ( cell[y+1][x] == '#' ) {     // 下
			cnt++;
		  }
		  if ( x+1 < W ) {
			if ( cell[y+1][x+1] == '#' ) {   // 右下
			  cnt++;
			}
		  }
		}
		replace = '0' + cnt;
		cell[y][x] = replace;
	  }
	}
  }

  // ----------

  for (int y=0; y<H; y++) {
	for (int x=0; x<W; x++) {
	  cout << cell[y][x];
	}
	cout << endl;
  }

}


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

int main() {
    int N,X;
    cin>>N>>X;
    vector<int> m(N);
    int i;
    int saisyou=X;
    for(i=0;i<N;i++){
        cin>>m.at(i);
        X=X-m.at(i);
        saisyou=min(saisyou,m.at(i));
    }

    int kosu=N;
    if(X!=0)kosu+=X/saisyou;

    cout<<kosu<<endl;

}


Measured memory_bytes: 256