akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
typedef long long ll;
typedef long double ld;
 
int n,m; 
int a[301][301];
int cnt[301];

bool valid(int k){
	int sum=0;
	int cur = 0;
	vector<int> q[2][301];
	rep(i,0,n){
		rep(j,0,m){
			q[cur][i].pb(a[i][j]);
		}
	}
	while(1){
		memset(cnt,0,sizeof(cnt));
		rep(i,0,n){
			cnt[(q[cur][i][0])]++;
		}
		vector<int> x;
		rep(i,1,m+1){
			if(cnt[i]>k){
				x.pb(i);
			}
		}
		if(x.size()==0){
			return 1;
		}
		sum+=(x.size());
		rep(i,0,n){
			iter(it,q[cur][i]){
				if(cnt[(*it)]<=k){
					q[1-cur][i].pb((*it));
				}
			}
		}
		rep(i,0,n){
			q[cur][i].clear();
		}
		cur = 1-cur;
		if(sum==m){
			return 0;
		}	
	}
}

int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);   
    cin>>n>>m;
    rep(i,0,n){
    	rep(j,0,m){
    		cin>>a[i][j];
    	}
    }
    int lo = 0,hi = n;
    while(hi-lo>1){
    	int mid = (lo+hi)>>1;
    	if(valid(mid)){
    		hi=mid;
    	}
    	else{
    		lo = mid;
    	}
    }
    cout<<hi<<endl;
}

Measured memory_bytes: 1900
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int H, W, K;
string s[301];
int ans[301][301];
	

void fill_rect(int sx, int sy, int ex, int ey, int v) {
	for (int y = sy; y <= ey; y++) {
		for (int x = sx; x <= ex;x++) {
			ans[y][x] = v;
		}
	}
}

int main() {
	
	cin >> H >> W >> K;


	rep(i , H) {
		cin >> s[i];
	}
	vector<int> count_v(H, 0);

	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			if (s[y][x] == '#') {
				count_v[y] ++;
			}
		}
	}

	int ly = H - 1;
	for(int y = H - 1; y >= 0; y--) {
		if (count_v[y] > 0) {
			ly = y;
			break;
		}
	}

	vector<pair<int, int> > v_ans;

	
	int sy = 0;
	for (int y = 0; y < H; y++) {
		if (y == ly) {
			v_ans.push_back(make_pair(sy, H - 1));
			break;
		}
		if (count_v[y] <= 0) {
			continue;
		}
		v_ans.push_back(make_pair(sy, y));
		sy = y + 1;
	}

	int cur = 1;

	for (auto p : v_ans) {
		
		int sy = p.first;
		int ey = p.second;
		//cerr << "sy:" << sy << " ey:" << ey << endl; 
 		int count = 0;
		for (int y = sy; y <= ey; y++) {
			count += count_v[y];
		}

		if (count == 1) {
			fill_rect(0, sy, W - 1, ey, cur);
			cur++;

		} else {
			int sx = 0;
			for (int x = 0; x < W; x++) {
				for (int y = sy; y <= ey; y++) {
					if (s[y][x] == '#') {
						fill_rect(sx, sy, x, ey,cur);
						cur++;
						y = ey;
						sx = x + 1;
						count--;
						if (count == 1) {
							fill_rect(sx, sy, W - 1,ey,cur);
							cur++;
							x = W;
							break;
						}

					}
				}
			}
		}

	}
	rep(y, H) {
		rep(x , W) {
			cout << ans[y][x] << " ";
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 1280
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m;
    in >> n >> m;
    out << (n-1)  * (m-1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
#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 rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 7;

int N, K;
vector<int> G[100010];

int dfs(int cur, int par = -1)
{
	int res = 1;
	int mul;

	if (cur == 0) {
		mul = K - 1;
	} else {
		mul = K - 2;
	}

	for (int &nxt : G[cur]) {
		if (nxt == par) continue;

		(res *= dfs(nxt, cur)) %= mod;
		(res *= mul) %= mod;
		--mul;
	}

	return res;
}

signed main()
{
	cin >> N >> K;

	rep(i, N - 1) {
		int a, b; cin >> a >> b;
		--a, --b;

		G[a].PB(b);
		G[b].PB(a);
	}

	cout << K * dfs(0) % mod << endl;
}


Measured memory_bytes: 11520
while true
    h, w = gets.chomp.split.map(&:to_i)
    break if [h, w] == [0, 0]
    map = []
    h.times{map << gets.chomp}
    x = y = 0
    hash = {}
    loop = false
    while true
        if hash[[x, y]]
            loop = true
            break
        end
        hash[[x, y]] = true
        case map[y][x]
        when '>' then x += 1
        when '<' then x -= 1
        when '^' then y -= 1 
        when 'v' then y += 1
        when '.' then break
        end
    end
    puts loop ? "LOOP" : "#{x} #{y}"
end



Measured memory_bytes: 6912
import java.util.Scanner;
 
class Main {
    @SuppressWarnings("resource")
    public static void main(String[] args) {
        StringBuilder sb=new StringBuilder("");
         
        Scanner n=new Scanner(System.in);
         
        int a=n.nextInt();
        int b=n.nextInt();
         
        while (a!=0 || b!=0){
            for (int c = 0; c < a ; c++){
                for (int d = 0 ; d < b ; d++){
                    if(c == 0 || c == a - 1 || d == 0 || d == b - 1){
                    	sb.append("#");
                    } else{
                    	sb.append(".");
                    }
                }
                sb.append("\n");
                 
            }
            System.out.println(sb);
            a=n.nextInt();
            b=n.nextInt();
            sb=new StringBuilder("");
        }
    }
}

Measured memory_bytes: 27676
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int n;
 string s, a, b;
 cin >> n >> s;
 if(s.length()%2==1){
   cout << "No";
 }else{
   if(s.substr(0, s.length()/2)==s.substr(s.length()/2, s.length()/2)) cout << "Yes";
   else cout << "No";
 }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int k, x;
    cin >> k >> x;
    FOR(i,x-k+1,x+k-1) cout << i << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  string S;
  cin >> S;
  FOR(i,0,S.size()-1){
    if(S.substr(i,2) == "AC"){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, k;
  cin >> n >> k;
  double ans = 0.0;
  FOR(i, 1, n + 1) {
    ll c = i, t = n;
    while (c < k) {
      c *= 2;
      t *= 2;
    }
    ans += 1.0 / t;
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

struct sword{
    int att, typ;
}a[200005];

bool cmp(sword a, sword b){
    return a.att > b.att;
}
int main(){
    memset(a, 0, sizeof a);
    int n, h;
    scanf("%d%d", &n, &h);
    int amax = -2147483647;
    for (int i = 0; i < n; i++){
        scanf("%d%d", &(a[2 * i].att), &(a[2 * i + 1].att));
        a[2 * i].typ = 1; a[2 * i + 1].typ = 0;
        amax = max(amax, a[2 * i].att);
    }
    sort(a, a + 2 * n, cmp);
    int i, attsum = 0, cnt;
    for (i = 0; i < 2 * n; i++){
        if (attsum >= h || a[i].typ){
            cnt = i;
            break;
        }
        attsum += a[i].att;
    }
    if (attsum < h) printf("%d", cnt + (int)ceil((double)(h - attsum) / amax));
    else printf("%d", cnt);
    puts("");
    return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    long long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int mn=INT_MAX;
    for(int i=0;i<=n-k;i++)
    {
        mn=min((long long int) mn,a[i+k-1]-a[i]);
    }
    cout<<mn;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 2000000000;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll nCr(int n, int r)
{
    ll ans = 1;
    for (int i = n; i > n - r; --i)
    {
        ans = ans * i;
    }
    for (int i = 1; i < r + 1; ++i)
    {
        ans = ans / i;
    }
    return ans;
}

int main()
{
    ll ans = 0;
    ll N, A, B;
    cin >> N >> A >> B;

    if ((A + B) % 2 == 1)
    {
        ans = min(N-B,A-1) + 1 + (B-A-1)/2;
    }
    else
    {
        ans = ((A + B) / 2) - A;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		double x = Math.PI;
		
		System.out.println(2 * R * x);		
	}

}


Measured memory_bytes: 35632
/*
  AOJ 2489
  Title:Palindromic Number
  @kankichi573
*/
#include <stdio.h>

int is_parin(int n)
{
  if(n<9)
    return(-1);
  else if(n<100)
    {
      if(n%11==0)
	return(-1);
      else
	return(0);
    }
  else if(n<1000)
    {
      if(n/100 == n % 10)
	return(-1);
      else
	return(0);
    }
  else if(n / 1000 == n % 10 && (n/100)%10 == (n/10)%10)
    return(-1);
  else
    return(0);
}
main()
{
  int i,n,ret;

  scanf("%d",&n);
  if(n==10000)
    ret=9999;
  else
    for(i=0;n+i<=10000;i++)
      if(is_parin(n-i))
	{
	  ret=n-i;
	  break;
	}
    else if (is_parin(n+i))
      {
	ret=n+i;
	break;
      }
  printf("%d\n",ret);
  return(0);
}

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

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

    int n;
    cin >> n;

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

    sort(a.begin(),a.end());
    bool flag = true;
    for(int i = 1; i < n; i++){
        if(a[i] == a[i-1]) {
            flag = false;
            break;
        }
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 1024
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt();
        String ans=(a%3!=0&&b%3!=0&&(a+b)%3!=0)?"Impossible":"Possible";
        System.out.println(ans);
    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>

using namespace std;


class Solution{
    
public:
    bool isPossible(int a, int b, int c){
        return a == b + c || b == a + c || c == a + b;
    }
};

int main() {
    
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    printf("%s\n", Solution().isPossible(a, b, c) ? "Yes" : "No");
    
    return 0;
}


Measured memory_bytes: 3124
import sys

sys.setrecursionlimit(10 ** 7)
# import bisect
# import numpy as np
# from collections import deque
from collections import deque
# map(int, sys.stdin.read().split())
import itertools
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    A.sort()
    A = deque(A)
    #    print(A)
    A_minus = deque([s for s in A if s < 0])
    A_plus = deque([s for s in A if s >= 0])

    #    print(A_plus)
    #    print(A_minus)
    AA = []
    if N == K:
        ans = 1
        for i in A:
            ans *= i % mod
            ans %=mod
        print(ans % mod)

    elif K % 2 == 0:
        while len(A_minus) >= 2:
            a1 = A_minus.popleft()
            a2 = A_minus.popleft()
            heapq.heappush(AA, -a1 * a2)

        while len(A_plus) >= 2:
            a1 = A_plus.pop()
            a2 = A_plus.pop()
            heapq.heappush(AA, -a1 * a2)
        ans = 1

        for i in range(K // 2):
            ans *= (-1 * heapq.heappop(AA))
            ans %= mod
        print(ans % mod)

    elif len(A_plus) == 0:
        ans = 1
        for i in range(K):
            ans *= A_minus.pop() % mod
            ans %= mod
        print(ans % mod)

    else:
        ans = A_plus.pop()
        while len(A_minus) >= 2:
            a1 = A_minus.popleft()
            a2 = A_minus.popleft()
            heapq.heappush(AA, -a1 * a2)

        while len(A_plus) >= 2:
            a1 = A_plus.pop()
            a2 = A_plus.pop()
            heapq.heappush(AA, -a1 * a2)

        heapq.heapify(AA)
        for i in range(K // 2):
            ans *= (-1 * heapq.heappop(AA)) % mod
            ans %=mod
        print(ans% mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 118048
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>K;
    vec m(0), p(0), a(N);
    ll ze = 0;
    rep(i,N) {
        cin>>a[i];
        if(a[i] < 0){
            m.push_back(-a[i]);
        }else if(a[i] == 0){
            ++ze;
        }else{
            p.push_back(a[i]);
        }
    }
    sort(ALL(m));
    sort(ALL(p));
    ll lb = -2e+18, ub = 2e+18;
    while(ub - lb > 1){
        ll cen = (ub + lb) / 2;
        ll num = 0;
        rep(i,N){
            ll abc = abs(cen), aba = abs(a[i]);
            ll temp = 0;
            if(a[i] != 0) temp = (abc + aba - 1) / aba;
            if(cen < 0){
                if(a[i] < 0){
                    num += p.end() - lower_bound(ALL(p), temp);
                }else if(a[i] > 0){
                    num += m.end() - lower_bound(ALL(m), temp);
                }
            }else if(cen == 0){
                if(a[i] < 0){
                    num += ze + p.size();
                }else if(a[i] == 0){
                    num += N;
                }else{
                    num += ze + m.size();
                }
            }else{
                if(a[i] < 0){
                    num += ze + p.size() + (upper_bound(ALL(m), cen / aba) - m.begin());
                }else if(a[i] == 0){
                    num += N;
                }else{
                    num += ze + m.size() + (upper_bound(ALL(p), cen / aba) - p.begin());
                }
            }
        }
        rep(i,N) num -= (a[i]*a[i] <= cen);
        (num >= K * 2 ? ub : lb) = cen;
    }
    cout<<ub<<endl;
    /*ll cen = 6, num = 0;
    rep(i,N){
        ll abc = abs(cen), aba = abs(a[i]);
        ll temp = 0;
        if(a[i] != 0) temp = (abc + aba - 1) / aba;
        if(cen < 0){
            if(a[i] < 0){
                num += p.end() - lower_bound(ALL(p), temp);
            }else if(a[i] > 0){
                num += m.end() - lower_bound(ALL(m), temp);
            }
            cout<<i<<' '<<num<<endl;
        }else if(cen == 0){
            if(a[i] < 0){
                num += ze + p.size();
            }else if(a[i] == 0){
                num += N;
            }else{
                num += ze + m.size();
            }
        }else{
            if(a[i] < 0){
                num += ze + p.size() + (upper_bound(ALL(m), temp - 1) - m.begin());
            }else if(a[i] == 0){
                num += N;
            }else{
                num += ze + m.size() + (upper_bound(ALL(p), temp - 1) - p.begin());
            }
        }
        cout<<num<<endl;
    }
    cout<<num<<endl;*/
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n,m;
    cin >> n >> m;
    int mi = -1,ma = n + 3;
    REP(i,m){
        int l,r;
        scanf("%lld%lld",&l,&r);
        mi = max(mi,l);
        ma = min(ma,r);
    }
    cout << max(llong(0),ma - mi + 1) << endl;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	h,w = readline() |> split |> parseMap
	minim = h*w
	for i in 1:h
		s1 = w*i
		s2 = div(w,2)*(h-i)
		s3 = (w-div(w,2))*(h-i)
		s4 = div(h-i,2)*w
		s5 = (h-i-div(h-i,2))*w
		lminim = min(max(s1,s2,s3)-min(s1,s2,s3),max(s1,s4,s5)-min(s1,s4,s5))
    	minim = min(lminim, minim)
	end
    temp = h
    h = w
    w = temp
	for i in 1:h
		s1 = w*i
		s2 = div(w,2)*(h-i)
		s3 = (w-div(w,2))*(h-i)
		s4 = div(h-i,2)*w
		s5 = (h-i-div(h-i,2))*w
		lminim = min(max(s1,s2,s3)-min(s1,s2,s3),max(s1,s4,s5)-min(s1,s4,s5))
    	minim = min(lminim, minim)
	end
	println(minim)
end

main()


Measured memory_bytes: 110704
N, M, C = map(int, input().split())
Bs = list(map(int, input().split()))

right_count = 0
for _ in range(N):
    As = list(map(int, input().split()))
    total_val = sum([a*b for (a, b) in zip(As, Bs)]) + C
    if total_val > 0:
        right_count += 1

print(right_count)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int A = sc.nextInt();
    int ans = 0;
    if (X >= A ) {
      ans = 10;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
l = list(map(int, input().split()))
s = input()
for c in s:
  if c == "S":
    l = [l[4], l[0], l[2], l[3], l[5], l[1]]
  elif c == "N":
    l = [l[1], l[5], l[2], l[3], l[0], l[4]]
  elif c == "E":
    l = [l[3], l[1], l[0], l[5], l[4], l[2]]
  else:
    l = [l[2], l[1], l[5], l[0], l[4], l[3]]
print(l[0])


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

int _main(){
    
    int h,w;
    cin >> h >> w;  
    int _sx,_sy,sx,sy;
    cin >> _sy >> _sx;  
    int _gx,_gy,gx,gy;
    cin >> _gy >> _gx;
    sx = _sx-1; sy = _sy-1;
    gx = _gx-1; gy = _gy-1;

    vector<vector<bool>> road(w, vector<bool>(h));
    for (int y=0; y<h; y++) {
        for (int x=0; x<w; x++) {
            char c;
            cin >> c;
            if(c=='.'){
                road[x][y]=true;
            }else{
                road[x][y]=false;
            }
        }
    }

    vector<vector<int>> cost(w, vector<int>(h,INFINITY));
    queue<tuple<int,int>> searchfrom;
    vector<vector<int>> searching_b(w, vector<int>(h,false));
    searchfrom.push(tuple<int,int>(sx,sy));
    int costnow = 0;
    while(true){
        queue<tuple<int,int>> searching = queue<tuple<int,int>>(searchfrom);
        queue<tuple<int,int>> searched  = queue<tuple<int,int>>();
        for (int y=0; y<h; y++) {
            for (int x=0; x<w; x++) {
                //searching_b[x][y]=false;
            }
        }
        searchfrom = queue<tuple<int,int>>();
        while(searching.size()>0){
            tuple<int,int> coord = searching.front();
            int cx = get<0>(coord); int cy = get<1>(coord);
            searching.pop();


            if(cx==gx && cy==gy){
                return costnow;
            }

            for(int x=max(0,cx-1); x<=min(w-1,cx+1); x++){
                for(int y=max(0,cy-1); y<=min(h-1,cy+1); y++){
                    int lenSu = abs(x-cx)+abs(y-cy);
                    if(road[x][y] && costnow<cost[x][y]){
                        if(lenSu==0){
                            cost[x][y] = costnow;
                            searched.push(tuple<int,int>(x,y));
                        }else if(lenSu==1 && !searching_b[x][y]){
                            searching_b[x][y]=true;
                            searching.push(tuple<int,int>(x,y));
                        }
                    }
                }
            }
        }
        while(searched.size()>0){
            tuple<int,int> coord = searched.front();
            int cx = get<0>(coord); int cy = get<1>(coord);
            searched.pop();

            for(int x=max(0,get<0>(coord)-2); x<=min(w-1,get<0>(coord)+2); x++){
                for(int y=max(0,get<1>(coord)-2); y<=min(h-1,get<1>(coord)+2); y++){
                    if(road[x][y] && costnow<cost[x][y]){
                        searchfrom.push(tuple<int,int>(x,y));
                    }
                }
            }
        }
        if(searchfrom.size()==0) return -1;
        costnow++;
    }
}

int main(){
    int result = _main();
    cout << result;
    return 0;
}

Measured memory_bytes: 11840
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
void insertionSort(vector<int> &a, int n)
{
    rep(k, n)
    {
        cout << a[k] << (k != n - 1 ? " " : "");
    }
    cout << endl;

    rep(i, 1, n)
    {
        //cerr << i << "," << a[i] << endl;
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        rep(k, n)
        {
            cout << a[k] << (k != n - 1 ? " " : "");
        }
        cout << endl;
    }
    return;
}
int main(int argc, char const *argv[])
{

    int n;
    cin >> n;
    vector<int> v(n, 0);
    rep(i, n)
    {
        cin >> v[i];
    }
    insertionSort(v, n);

    return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    ll sum = 0;
    for(int i=1; i<=n; i++){
        if(i%3 != 0 && i%5 != 0) sum += i;
    }
    cout << sum;
    cout << endl;
    return 0;
}

Measured memory_bytes: 3596
def solve():
    a, b = read()
    result = think(a, b)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return list(map(int, input().rstrip().split()[:n]))


def think(a, b):
    if (a * b) % 2 == 0:
        return 'Even'
    else:
        return 'Odd'


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 38256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;
//author_name:Lebron 
//date:2018/11/18
//title:AGC 010 E Rearranging
//ÒòÎªÇÓÅ³£¬ËùÒÔÌÓ±ÜÉúÃü£¬ÒÔ²»µÖ¿¹ÔÚ×îºÚ°µµÄ³ÁÂÙÖÐÉú³ö½¾°Á£¬ÒòÎª½¾°Á£¬ËùÒÔ²»Ñ¡ÔñÉú£¬ËùÒÔ¾Ü³â´Ö±ÉµÄÀÖ¹ÛÖ÷Òå¡£
//Ìì²ÅµÄ±¯¾çµØÓÚ±»Ð¡¶øÊæÊÊµÄÃûÍûËùÊø¸¿¡£
//It's human to lie. Most of the time we can't even be honest with ourselves.

int ar[2020];
vector<int> graph[2020];
bool used[2020];

inline int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}

vector<int> run_merge(vector<int> a,vector<int> b)
{
	vector<int> ret;
	int it1=0,it2=0;
	while(it1<a.size()||it2<b.size())
	{
		if(it1==a.size())
		{
			ret.push_back(b[it2]);
			it2++;
		}
		else if(it2==b.size())
		{
			ret.push_back(a[it1]);
			it1++;
		}
		else if(a[it1]>b[it2])
		{
			ret.push_back(a[it1]);
			it1++;
		}
		else
		{
			ret.push_back(b[it2]);
			it2++;
		}
	}
	return ret;
}

vector<int> dfs(int u)
{
	vector<int> here;
	used[u]=true;
	for(int i=0;i<graph[u].size();i++)
	{
		int to=graph[u][i];
		if(used[to]) continue;
		vector<int> v2=dfs(to);
		here=run_merge(here,v2);
	}
	here.insert(here.begin(),u);
	return here;
}

int n;
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>ar[i];
	sort(ar+1,ar+1+n);
	
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(gcd(ar[i],ar[j])>1)
			{
				graph[i].push_back(j);
				graph[j].push_back(i);
			}
	
	vector<int> ans;
	for(int i=1;i<=n;i++)	if(!used[i])
	{
		vector<int> here=dfs(i);
		ans=run_merge(ans,here);
	}
	for(int i=0;i<ans.size();i++)
		cout<<ar[ans[i]]<<" ";
	return 0;
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N;
void input() {
  scanf("%d",&N);
}
bool is_prime[MX+5];
vector<int> P;
void Eratosthenes(const int N) {
  for (int i = 2; i <= N; i++) {
    is_prime[i] = true;  // initialize.
  }
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
}
int sm[MX+2];
void solve() {
  Eratosthenes(MX);
  sm[3] = 1;
  rep(i,4,MX - 1){
    if (is_prime[i] && is_prime[(i+1)/2]){
      sm[i]++;
    }
    sm[i] += sm[i-1];
  }
  int a,b;
  rep(_,1,N){
    scanf("%d %d",&a,&b);
    //cin>>a>>b;
    cout<<sm[b] - sm[a-1]<<endl;
  }

   ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  string s,t; cin >> s >> t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  if(s<t) puts("Yes");
  else puts("No");
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int dp[51][51][5050];

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

	int N, K;
	cin >> N >> K;
	dp[0][0][0] = 1;
	rep(i, 0, N)rep(j, 0, i + 1)rep(k, 0, K + 1)
	{
		dp[i + 1][j][k + 2 * j] = (dp[i + 1][j][k + 2 * j] + (2 * j + 1)* dp[i][j][k]) % MOD;
		dp[i + 1][j + 1][k + 2 * (j + 1)] = (dp[i + 1][j + 1][k + 2 * (j + 1)] + dp[i][j][k]) % MOD;
		if(0<j)dp[i + 1][j - 1][k + 2 * (j - 1)] = (dp[i + 1][j - 1][k + 2 * (j - 1)] + j*j*dp[i][j][k]) % MOD;
	}

	cout << dp[N][0][K] << endl;

	return 0;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;
using namespace std;

signed main() {
  ll N;
  cin>>N;
  vector<ll> d(N);
  rep(i,0,N)
    cin>>d[i];
  sort(begin(d), end(d));
  ll ans = d[N/2] - d[N/2-1];
  cout<<ans<<endl;
  return 0;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


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

    vector <int> a(n);
    int ss=0;
    loop(i,0,n)
    {
        cin>>a[i];
        ss+=a[i];
    }

    ss=ceil((ss)/(4.0*m));
    int c=0;

    loop(i,0,n)
    {
        if(a[i]>=ss)
            c++;
    }

    if(c>=m) cout<< "Yes";
    else cout<< "No";



    return 0;
}


Measured memory_bytes: 3672
import bisect
N = int(input())
S = input()
# 右全部#
b = []
w = []
for i in range(N):
    if S[i] == '#':
        b.append(i)
    if S[i] == '.':
        w.append(i)

kouho = []
for i in range(0,N+1):
    cost = 0
    #iより右にある白の数
    cost += len(w) - bisect.bisect_left(w,i)
    #iより左にある黒の数
    cost += bisect.bisect_left(b,i)
    
    if cost >= 0:
        kouho.append(cost)

print(min(kouho))

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<string> avoid;
	for (int i = 0; i < k; i++) {
		string digit;
		cin >> digit;
		avoid.push_back(digit);
	}

	while (true) {
		//convert integer to string
		//cout << "n = " << n << endl;
		string nstring = to_string(n);		//having this here means 
		int i = 0;
		for (; i < k; i++) {
			if (nstring.find(avoid.at(i)) != string::npos) {	//have to do npos!
				n++;
				//nstring = to_string(n);		//we have to reset this
				break;
			}
		}
		if (i == k) {
			cout << n << endl;
			return 0;
		}

	} 
}

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

int main(int argc, char const *argv[])
{
    int x, y;
    while(true){
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if (y < x){
            int tmp = y;
            y = x;
            x = tmp;
        }
        printf("%d %d\n", x, y);
    }
    return 0;
}



Measured memory_bytes: 3052
//https://atcoder.jp/contests/dp/tasks/dp_q
//https://qiita.com/drken/items/68b8503ad4ffb469624c#3-lis-の解法1-二分探索-ver

#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>

using namespace std;
typedef pair<int, long long> pil;


template <class T> class SegTree {
    int n;                          // 葉の数
    vector<T> data;                 // データを格納するvector
    T def;                          // 初期値かつ単位元
    function<T(T, T)> operation;    // 区間クエリで使う処理
    function<T(T, T)> update;       // 点更新で使う処理

    // 区間[a,b)の総和。ノードk=[l,r)に着目している。
    T _query(int a, int b, int k, int l, int r){
        // 交差しない場合
        if(r <= a || b <= l) return def; 
        //// a,l,r,bの順で完全に含まれる
        if (a <= l && r <= b){
            return data[k]; 
        }else{
            T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
            T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
            return operation(c1, c2);
        }
    }
    public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    //コンストラクタ
    SegTree(size_t _n, T _def, 
                    function<T(T, T)> _operation, 
                    function<T(T, T)> _update)
                    :def(_def), operation(_operation), update(_update){
        n=1;
        while(n < _n){
            n *= 2;
        }
        data = vector<T>(2*n -1, def);
    }

    //区間クエリ
    T query(int a, int b){
        return _query(a, b, 0, 0, n);
    }

    //更新クエリ:場所i(0-indexed)の値をxで更新
    void change(int i, T x){
        i += n -1;
        data[i] = update(data[i], x);
        while(i > 0){
            i = (i-1)/2;
            data[i] = operation(data[i*2+1], data[i*2+2]);
        }
    }

    // 添字でアクセス
    T operator[](int i){
        return data[i + n -1];
    }
};

int main(){
    int N; cin >> N;
    vector<int> h(N);
    vector<long long> a(N);
    for (int i = 0; i < N; ++i){
        cin >> h[i];
        h[i]--;
    } 
    for (int i = 0; i < N; ++i) cin >> a[i];

    //セグ木
    SegTree<long long> st(N, 0, [](long long a, long long b) { return max(a, b); },
                      [](long long a, long long b) { return b; });
    
    //更新 
    long long res = 0;
    for(int i=0; i<N; ++i){
        //値取得
        long long A = st.query(0, h[i]);

        //更新
        if(st.query(h[i], h[i]+1) < A + a[i] ){
            st.change(h[i], A + a[i]);
            res = max(res, A + a[i]);
        }
    }

    cout << res << endl;
}


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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    int c = 0;
    bool ok = false;
    for(int i = 0; i < n; ++i){
    	int a,b;
    	cin >> a >> b;
    	if(a == b){
    		c++;
    		if(c == 3){
    			ok = true;
    		}
    	}else{
    		c = 0;
    	}
    }
    
    cout << (ok ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3608
def solve(h, w):
    if h % 3 == 0 or w % 3 == 0:
        return 0
    if h == 1 or w == 1:
        return 1
    def f(a, b):
        vals = [0, 0, 0]
        min_diff = h * w
        for i in range(1, a // 2 + 1):
            vals[0] = i * b
            vals[1] = (a - i) * (b // 2 + b % 2)
            vals[2] = (a - i) * (b // 2)
            diff = max(vals) - min(vals)
            if diff < min_diff:
                min_diff = diff
            vals[1] = b * ((a - i) // 2 + (a - i) % 2)
            vals[2] = b * ((a - i) // 2)
            diff = max(vals) - min(vals)
            if diff < min_diff:
                min_diff = diff
        return min_diff
    return min(f(h, w), f(w, h))

_h, _w = map(int, input().split())
print(solve(_h, _w))


Measured memory_bytes: 42588
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define ff(x) cerr << #x << " is " << x << '\n'
#define FL freopen("in", "r", stdin),freopen("out", "w", stdout);
#define time cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b) 
ll pot(ll a, ll b){
    ll ans = 1;
    while(b){
        if(b & 1)
            ans *= a;
        b >>= 1;
        a *= a;
    }
    return ans;
}
int main(){
    //FL;
    fin;
    int x;
    cin >> x;
    ll ans = 0;
    for(ll i = 1; i <= 32; i++){
        for(ll j = 2; j <= 10; j++){
            if(pot(i, j) <= x){
                ans = max(ans, pot(i, j));
            }
        }
    }
    cout << ans << '\n';
    time;
    return 0;
}   

Measured memory_bytes: 256
#include <stdio.h>

int is_prime(int n)
{
    int i;

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

    return 1;
}

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

    int i, n;
    int cnt = 0;

    for (i = 0; i < N; i++) {
        scanf("%d", &n);
        if (is_prime(n)) cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int P[100][11];
bool F[100][10], Open[10];
void DFS(int n, int i, bool flag, int *max)
{
	if(i>=10){
		bool fl=false;
		rep(k, 10){
			if(Open[k]) fl=true;
		}
		if(!fl) return;
		rep(k, 10){
			//cout<<Open[k]<<" ";
		}
		//cout<<endl;
		int value=0;
		rep(j, n){
			int count=0;
			rep(k, 10){
				if(Open[k]&&F[j][k]) count++;
			}
			value+=P[j][count];
		}
		if(*max<value) *max=value;
		return;
	}
	Open[i]=flag;
	DFS(n, i+1, true, max);
	DFS(n, i+1, false, max);
}
int main(void)
{
	int n, max=-1000000000;

	cin>>n;

	rep(i, n){
		rep(j, 10){
			cin>>F[i][j];
		}
	}
	rep(i, n){
		rep(j, 11){
			cin>>P[i][j];
		}
	}
	DFS(n, 0, true, &max);
	DFS(n, 0, false, &max);
	cout<<max<<endl;
}

Measured memory_bytes: 256
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

H,W,A,B=map(int, input().split())
p=10**9+7
ans=0
X=[1]  #階乗テーブル
for i in range(1,H+W-1):
  X+=[ (X[-1]*i) %p ]
Y=[1]*(H+W-1)  #階乗の逆元テーブル
Y[H+W-2]=power_func(X[H+W-2],p-2,p)
for i in range(H+W-3,-1,-1):
  Y[i]=Y[i+1]*(i+1) %p
for i in range(B,W):
  ans+=(X[H-A-1+i]*X[A+W-2-i]*Y[H-A-1]*Y[i]*Y[A-1]*Y[W-1-i])%p

print(ans%p)

Measured memory_bytes: 18964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;


public class Main {

    public static void main(String[] args) throws IOException {
        //Input ??´??°?????\?????????
        BufferedReader br =
                new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int n = Integer.parseInt(str);
        //??????
        double loan = 100000;

        //??\???????????´??°?????????????????????????±???????
        //1??±?????¨???????????????????????????????????????????????\??????
        for(int i=1; i<=n; i++){
           //?????????5%?????????????????????
           loan = loan * 1.05;
           //?????????1000???????????????????????????
           BigDecimal bd = new BigDecimal(String.valueOf(loan));
           //?¬¬1?????°???0?????´???????°???°?¬¬?????????????????????(??????)
           //1000??????????????????????????????????¬¬1?????°???-3??¨????????????????????????????????????
           loan = bd.setScale(-3, BigDecimal.ROUND_UP).doubleValue();
        }
        //??¨???????????????????°???°??????????????¢??§????????????????????????????????????int??????result???????´???????
        int result = (int) loan;
        System.out.println(result);
    }
}

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

typedef long long LL;
const int MO=1e9+7;
const int M=55;

int dp[M][M][M*M];

inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}


int main()
{
	int n,k;
	cin>>n>>k;
	if(k&1)
	{
		cout<<0<<endl;
		return 0;
	}
	dp[0][0][0]=1;
	k/=2;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++)
		{
			for(int l=0;l<=k;l++)
			{
				// put i into i
				dp[i][j][l+j]=add(dp[i][j][l+j],dp[i-1][j][l]);
				// don't put
				dp[i][j+1][l+j+1]=add(dp[i][j+1][l+j+1],dp[i-1][j][l]);
				// put i into less than i or
				// put less than i into i
				dp[i][j][l+j]=add(dp[i][j][l+j],mul(dp[i-1][j][l],mul(2,j)));
				// put i into less than i and
				// put less than i into i
				if(j>=1)
					dp[i][j-1][l+j-1]=add(dp[i][j-1][l+j-1],mul(dp[i-1][j][l],mul(j,j)));
			}
		}
	cout<<dp[n][0][k]<<endl;
	return 0;
}

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

using namespace std;

const int MAXN = 1e5 + 5;
int N, H[MAXN];
int dp[MAXN];
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> H[i];
    dp[1] = abs(H[1] - H[0]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i - 2] + abs(H[i] - H[i - 2]), dp[i - 1] + abs(H[i] - H[i - 1]));
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int ans1=0,ans2=0;
	bool flg=true;
	rep(i,s.size()){
		if(flg){
			if(s.at(i)=='1') ans1++;
			flg=false;
		}
		else{
			if(s.at(i)=='0') ans1++;
			flg=true;
		}
	}
	flg=true;
	rep(i,s.size()){
		if(flg){
			if(s.at(i)=='0') ans2++;
			flg=false;
		}
		else{
			if(s.at(i)=='1') ans2++;
			flg=true;
		}
	}
	cout << min(ans1,ans2) << endl;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
)

// go run ./main.go < in

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	ok := false
	for i := 0; i <= x; i++ {
		if y == 2*(2*x-i) {
			fmt.Println("Yes")
			ok = true
			break
		}
	}

	if !ok {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1752
package main

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

func main() {
	var A, B, C, X, cnt int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	A, _ = strconv.Atoi(scanner.Text())
	scanner.Scan()
	B, _ = strconv.Atoi(scanner.Text())
	scanner.Scan()
	C, _ = strconv.Atoi(scanner.Text())
	scanner.Scan()
	X, _ = strconv.Atoi(scanner.Text())

	for a := int(math.Min(float64(X/500), float64(A))); a >= 0; a-- {
		for b := int(math.Min(float64((X-500*a) / 100), float64(B))); b >= 0; b-- {
			var c int = int(math.Min(float64((X-500*a-100*b) / (50)), float64(C)))
			if 500*a + 100*b + 50*c == X {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 640