akhauriyash/Code-Regression huggingface dataset:
while true
    n, m, t, p = gets.chomp.split.map(&:to_i)
    break if [n, m, t, p] == [0, 0, 0, 0]

    map = Array.new(m){Array.new(n, 1)}
    t.times{
        map2 = []
        map.each{|m| map2 << m.dup}

        d, i = gets.chomp.split.map(&:to_i)
        case d
        when 1
            map = Array.new(m){Array.new([i, n - i].max, 0)}
            x2 = 0
            i.upto(n-1){|x|
                0.upto(m-1){|y| map[y][x2] += map2[y][x]}
                x2 += 1
            }
            x2 = 0
            (i-1).downto(0){|x|
                0.upto(m-1){|y| map[y][x2] += map2[y][x]}
                x2 += 1
            }
            n = [i, n - i].max
        when 2
            map = Array.new([m-i, i].max){Array.new(n, 0)}
            y2 = [m-i, i].max - 1
            (m-i-1).downto(0){|y|
                0.upto(n-1){|x| map[y2][x] += map2[y][x]}
                y2 -= 1
            }
            y2 = [m-i, i].max - 1
            (m-i).upto(m-1){|y|
                0.upto(n-1){|x| map[y2][x] += map2[y][x]}
                y2 -= 1
            }
            m = [m-i, i].max
        end
    }

    p.times{
        x, y = gets.chomp.split.map(&:to_i)
        puts map[m-y-1][x]
    }
end



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

 int main(){
   int a, b, c;
   cin>>a>>b>>c;
   if(a==7 && b==5 && c==5)
      cout<<"YES\n";
   else if(b==7 && a==5 && c==5)
      cout<<"YES\n";
   else if(c==7 &&  a==5 && b==5)
      cout<<"YES\n";
   else
    cout<<"NO\n";
   return 0;
 }

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; i++) {
    int x, l;
    cin >> x >> l;
    v[i].first = x + l;
    v[i].second = x - l;
  }
  sort(v.begin(), v.end());
  int r = 0, t = -1e9;
  for (auto e : v) {
    if (e.second < t) continue;
    t = e.first;
    r++;
  }
  cout << r << endl;
}


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

int n;
long long a[300001];

bool check(long long x)
{
	int l = 0, r = 1;
	for (; r < 2 * n; r++){
		if (a[r] - a[l] < x) continue;
		while (a[r] - a[l + 1] >= x) l++;
		
		int tail = l + n;
		int mid = lower_bound(a + l + 1, a + tail + 1, (a[r] - a[l]) * 2 + a[l]) - a;
		
		if (mid == tail + 1) continue;
		
		//printf("%d %d %d %d\n", l, r, mid, tail);
		
		if (
			r != mid &&
			mid != tail &&
			tail - n != l + 1 &&
			a[mid] - a[r] >= a[r] - a[l] &&
			a[tail] - a[mid] >= a[r] - a[l]
		){
			return true;
		}
	}
	return false;
}

int main()
{
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++){
		scanf("%lld", &a[i]);
		a[i + n] = a[i + 2 * n] = a[i];
	}
	
	for (int i = 1; i <= 2 * n; i++){
		a[i] += a[i - 1];
	}
	
	long long l = 0, r = 1000000000LL * 100000LL;
	while (l <= r){
		long long mid = (l + r) / 2;
		if (check(mid)) l = mid + 1;
		else r = mid - 1;
	}
	
	printf("%lld\n", r);
	
	return 0;
}

Measured memory_bytes: 3532
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
/*#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>*/

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S secondcin
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e3 + 6;

int n, K, cnt;
vector < int > g[N];

void dfs(int v, int par, int lvl) {
    if (lvl > K / 2) return;
    ++cnt;
    for (auto to : g[v]) {
        if (to == par) continue;
        dfs(to, v, lvl + 1);
    }
}

int main() {
	ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("in", "r", stdin);

	cin >> n >> K;
	forn(i, 1, n - 1) {
        int x, y;
        cin >> x >> y;
        g[x].eb(y);
        g[y].eb(x);
	}

	int ans = n;
	forn(v, 1, n) {
	    if (K & 1) {
            for (auto to : g[v]) {
                cnt = 0;
                dfs(to, v, 0);
                int res = cnt;
                cnt = 0;
                dfs(v, to, 0);
                res += cnt;
                ans = min(ans, n - res);
            }
	    }
	    else {
            cnt = 0;
            dfs(v, 0, 0);
            ans = min(ans, n - cnt);
	    }
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
taro = 0
hanako = 0

n = int(input())
for i in range(n):
    animals = input().split()
    animal1 = animals[0]
    animal2 = animals[1]
    
    if animal1 < animal2:
        hanako += 3
    elif animal1 > animal2:
        taro += 3
    else:
        taro += 1
        hanako += 1

print(taro, hanako)


Measured memory_bytes: 5592
#define _CRT_SECURE_NO_WARNINGS
////#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define FUNC 180.0/(4*atan(1))
int main() {
	double a, b, c, d,delta,ans;
	const double r = 6378.1;
	while (~fscanf(stdin, "%lf%lf%lf%lf", &a, &b, &c, &d)) {
		if (a == -1.0 && b == -1.0 && c == -1.0 && d == -1.0) break;
		a /= FUNC, b /= FUNC, c /= FUNC, d /= FUNC;
		delta = d - b;
		ans = r*acos(sin(a)*sin(c) + cos(a)*cos(c)*cos(delta));
		P(d, (int)(ans+0.5));
	}
	return 0;
}

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

int N,cost[10000];
int dp[2][5010][2];
const int INF=1e9;
int main(){
    scanf("%d",&N);
    for(int i=0;i<N-1;i++)scanf("%d",&cost[i]);

    fill_n(**dp,2*2*5010,INF);
    dp[0][1][0]=dp[0][0][1]=0;

    for(int i=0;i<N-1;i++){
        for(int j=1;j<=N/2;j++){
            dp[(i+1)&1][j+1][0]=min(dp[(i+1)&1][j+1][0],min(dp[i&1][j][0],dp[i&1][j][1]+cost[i]));
            dp[(i+1)&1][j][1]=min(dp[(i+1)&1][j][1],min(dp[i&1][j][0]+cost[i],dp[i&1][j][1]));
            dp[i&1][j][0]=dp[i&1][j][1]=INF;
        }
    }

    printf("%d\n",min(dp[(N-1)&1][N/2][0],dp[(N-1)&1][N/2][1]));
    return 0;
}

Measured memory_bytes: 1304
#include <iostream>
#include <string>

using namespace std;

int main() {
    bool isUsed[26] {};

    string str;
    cin >> str;

    bool isSameChar = false;

    for(auto c : str) {
        if(isUsed[c - 'a']) {
            isSameChar = true;
            break;
        }
        else {
            isUsed[c - 'a'] = true;
        }
    }

    cout << (isSameChar ? "no" : "yes") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int K;
    int A,B;
    cin>>K>>A>>B;
    int flag=0;
    for(int i=A;i<=B;i++){
        if (i%K==0){
            flag=1;
        }
    }
    if (flag==1){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
		using namespace std;
		
		typedef long long ll;
		#define pi 3.14159265 
		#define EPS 1e-8
		
		#define mod 1000000007
		#define fi first
		#define se second
		#define mp make_pair
		#define pb push_back
		#define endl "\n"

		const ll INF=(ll)2e18;
		
		long long binpow(long long a, long long b, long long m) {
		a %= m;
		long long res = 1;
		while (b > 0) {
			if (b & 1)
				res = res * a % m;
			a = a * a % m;
			b >>= 1;
		}
		return res;
		}
		
		int main()
		{
			 ios_base::sync_with_stdio(false);
			 cin.tie(NULL);
			
			 ll n;
			 cin>>n;
			 ll n1=n;
			 ll ans=0;
			 for(ll i=2;i*i<=n;i++)
			 {
				ll n2=n;
				if(n2%i!=0)
					continue;
				 while(n2%i==0)
				 {
					 n2/=i;
				 }
				 if(n2%i==1)
					ans++;
				if(i*i==n1)
						continue;
					n2=n;
					ll j=n/i;
					while(n2%j==0)
					{
						n2/=j;
					}
					if(n2%j==1)
						ans++;
			 }
			
			 
			 n1=n-1;
			 set<ll> s;
			 for(ll i=1;i*i<=n1;i++)
			 {
				 if(n1%i==0)
				 {
					 s.insert(i);
					 s.insert(n1/i);
				 }
			 }
			 ans+=s.size();
		
			 cout<<ans;
		}


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


void input(); template<typename First,typename... Rest> void input(First&,Rest&...);
void inputVector(); template<typename First,typename... Rest>  void inputVector(std::vector<First>&,Rest&...);
#define loop(n) for(int i = 0;i < (int)(n);++i)


void calculate(){
    int a,b;
    input(a,b);
    if(a * b % 2) std::cout << "Odd\n";
    else std::cout << "Even\n";
}

int main(int,char**){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    calculate();
}



void input(){return;}
template<typename First,typename... Rest>
void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> 
void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        mut a: [u64; n],
    }
    a.sort();
    println!("{}", a.last().unwrap() - a.first().unwrap())
}


Measured memory_bytes: 4352
N, X = map(int, input().split())
L, P = [1], [1]
for _ in range(N - 1):
    L.append(L[-1] * 2 + 3)
    P.append(P[-1] * 2 + 1)


def ans(N, X):
    if N == 0:
        return 1 if X >= 1 else 0
    elif X <= 1:
        return 0
    elif X <= L[N - 1] + 1:
        return ans(N - 1, X - 1)
    else:
        return P[N - 1] + 1 + ans(N - 1, X - (L[N - 1] + 2))


print(ans(N, X))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, k, ans=-1e18;
int a[N], pref[N], pos[N];

int32_t main()
{
	IOS;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		pref[i] = pref[i-1] + a[i];
		pos[i] = pos[i-1] + ((a[i]>0)?a[i]:0);
	}
	for(int i=1;i+k-1<=n;i++)
	{
		int others=pos[i-1] + pos[n] - pos[i+k-1];
		int range=pref[i+k-1] - pref[i-1];
		if(range<0)
			range=0;
		ans=max(ans, others + range);
	}	
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2560
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll a, b, k;
  cin >> a >> b >> k;

  vector<ll> y; //sqrtまでの約数列挙
	for(ll i = 1; i * i <= a; i++){
		if(a % i == 0) y.pb(i);
	}
  ll len = y.size();
  REP(i, len){
    if(y[i] * y[i] != a) y.pb(a / y[i]);
  }
  VSORT(y);
  ll cnt = 0;
  for(int i = y.size() - 1; i >= 0; i--){
    if(b % y[i] == 0){
      cnt++;
      if(cnt == k){
        cout << y[i] << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 500100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int l[d5], r[d5];
    fill(l, l + d5, 0);
    fill(r, r + d5, 0);
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i]=='<'){
            l[i + 1] = l[i] + 1;
        }
        else{
            l[i + 1] = 0;
        }
    }
    for (int i = s.size(); i >= 0;i--){
        if(s[i]=='>'){
            r[i] = r[i + 1] + 1;
        }
        else{
            r[i] = 0;
        }
    }
    int res = 0;
    for (int i = 0; i < d5;i++){
        res += max(l[i], r[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 8732
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int N = 6010;
int MOD;

int dp[N][2*N];

int add(int a, int b){
    return (a + b) % MOD;
}
 
int mul(ll a, int b){
    return (a * b) % MOD;
}

void sadd(int &a, int b){
    a = add(a, b);
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int n;cin >> n >> MOD;
    n *= 3;
    dp[0][n] = 1;

    for(int i=1 ; i<=n ; i++)
        for(int j=0 ; j<=2*n ; j++){
            if(j)
                sadd(dp[i][j], dp[i-1][j-1]);
            if(i>1)
                sadd(dp[i][j], mul(i-1, dp[i-2][j+1]));
            if(i>2)
                sadd(dp[i][j], mul((i-1)*(i-2), dp[i-3][j]));
        }

    int ans=0;

    for(int i=n ; i<=2*n ; i++)
        sadd(ans, dp[n][i]);
    cout << ans << "\n";
}


Measured memory_bytes: 281984
#include<bits/stdc++.h>
using namespace std;
#define INF 1e18L + 7
template <typename T>
void max_self(T&a,T b){
    a = max(a,b);
}
template <typename T>
void min_self(T&a,T b){
    a = min(a,b);
}
int main(){
    string s1,s2;
    cin>>s1>>s2;
 //   getline(cin,s1);
 //   getline(cin,s2);
    vector<vector<int>>dp(s1.length() + 1,vector<int>(s2.length() + 1,0));
    for(int i=1 ; i <= (int)s1.length() ; ++i){
        for(int j = 1; j <= (int)s2.length() ; ++j){
            if(s1[i-1] == s2[j-1]){
                dp[i][j] = 1 + dp[i-1][j-1];
            }
            else{
                max_self(dp[i][j], dp[i-1][j]);
                max_self(dp[i][j], dp[i][j-1]);
            }
        }
    }
    int i = s1.length(), j = s2.length();
    string ans = "";
    while(i > 0 && j > 0){
        if(s1[i-1] == s2[j-1]){
            ans = s1[i-1] + ans;i--;j--;
        }
        else if(dp[i-1][j] > dp[i][j-1]){
            i--;
        }
        else{
            j--;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 35584
import string

n = int(input())

d = dict()
for c in string.ascii_lowercase:
    d[c] = []

for _ in range(n):
    s = input()
    for c in string.ascii_lowercase:
        if s.count(c) != 0:
            d[c].append(s.count(c))

ans = ""
for k, v in d.items():
    if len(v) == n:
        ans += k * min(v)

print(ans)

Measured memory_bytes: 9828
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int K,A,B; cin>>K>>A>>B;
	for (int i=A; i<=B; i++)
		if(i%K==0) { cout<<"OK\n"; return 0; }
	cout<<"NG\n";
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
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; }

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> a(N), b(N);
	vector<vector<int>> bit(N, vector<int>(31, 0));
	for(int i = 0;i < N;i++)	cin >> a[i] >> b[i];
	for(int i = 0;i < N;i++){
		for(int j = 30;j >= 0;j--){
			if(((a[i]>>j)&1) == 0 && (((a[i]>>(j+1)) | (K>>(j+1))) == (K>>(j+1))))	bit[i][j] = 1;
		}
	}
	LL ans = 0;
	for(int i = 30;i >= 0;i--){
		if(K&(1<<i)){
			LL res = 0;
			for(int j = 0;j < N;j++){res += bit[j][i]*b[j];}
			ans = max(ans, res);
		}
	}
	LL res = 0;
	for(int i = 0;i < N;i++){if((a[i] | K) == K)	res += b[i];}
	ans = max(ans, res);
	cout << ans << endl;
}

Measured memory_bytes: 17536
#include<iostream>

using namespace std;

int main(void){

    int a;

    cin >> a;

    int b = a / 3600;

    int c = a % 3600;

    int d = c / 60;

    int e = c % 60;

    cout << b << ":" << d << ":" << e << endl;

    return 0;

}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <cstdio>

int main(){
	int c, tmp, d[2] = {0};
	bool res;

	scanf("%d", &c);

	while(c--){
		res = true;
		d[0] = d[1] = 0;

		for(int i = 0; i < 10; ++i){
			std::cin >> tmp;
		
			if( d[0] < tmp ){
				if(d[1] < tmp){
					*std::max_element(d, d + 1) = tmp;
				}else{
					d[0] = tmp;
				}
			}else if( d[1] < tmp ){
				d[1] = tmp;
			}else{
				res = false;
				//break;
			}
		}

		std::cout << (res ? "YES" : "NO") << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 2100000000
#define MOD 1000000007

bool dbgflag = false; //debug


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

  int n, k;
  cin >> n >> k;
  vector<bool> okashi(n, false);
  for (int i = 0; i < k; i++) {
    int p;
    cin >> p;
    for (int q = 0; q < p; q++) {
      int r;
      cin >> r;
      okashi[r-1] = true;
    }
  }

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cnt += (!okashi[i]);
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3676
#include<stdio.h>
int main()
{
    long long int a,b,x,t1,t2;
    scanf("%lld%lld%lld",&a,&b,&x);
    if(a==0)
    {
        t1=(b/x)+1;
        printf("%lld",t1);
    }
    else if(a==1)
    {
        t1=(b/x);
        printf("%lld",t1);
    }
    else
    {
        t2=(a-1)/x;
        t1=(b/x)-t2;
        printf("%lld",t1);
    }
    return 0;

}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        sc.close();

        double allProb = 0.0000000;

        double baseProb = 1.00000 / (double) N;
        int remainVals = 0;

        for (int i = 1; i <= N; i++) {
            int takeCoins = getNeedTakeCoins(Double.parseDouble(String.valueOf(i)), K);
            if (takeCoins == 0) {
                remainVals = N - i + 1;
                break;
            }
            allProb += baseProb * Math.pow(0.5000, takeCoins);
        }

        if (remainVals > 0) {
            allProb += baseProb * remainVals;
        }

        System.out.println(allProb);

    }

    public static int getNeedTakeCoins(double val, double K) {
        int ret = 0;
        boolean times = false;
        while (true) {
            if (val >= K) {
                break;
            }
            val *= 4;
            ret += 2.00;
            times = true;
        }
        if (val / 2.00 >= K && times) {
            ret -= 1;
        }
        return ret;
    }
}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n;
	cin >> n;
	if(n>=400 && n<=599){
		cout << 8 << nl;
		return ;
	}
	if(n>=600 && n<=799){
		cout << 7 << nl;
		return ;
	}
	if(n>=800 && n<=999){
		cout << 6 << nl;
		return ;
	}
	if(n>=1000 && n<=1199){
		cout << 5 << nl;
		return ;
	}
	if(n>=1200 && n<=1399){
		cout << 4 << nl;
		return ;
	}
	if(n>=1400 && n<=1599){
		cout << 3 << nl;
		return ;
	}
	if(n>=1600 && n<=1799){
		cout << 2 << nl;
		return ;
	}
	if(n>=1800 && n<=1999){
		cout << 1 << nl;
		return ;
	}

}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
    	//cout <<"Case #"<<i<<':'<<nl;
        doit();
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  //500円で払える分だけ払う
  if (A + B > C + D) {
    cout << "Left" << endl;
  }else if(A + B < C + D){
  	cout << "Right" << endl;
  }else{
  	cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3624
//
// Created by rajshah9914 on 29/03/20.
//

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    string s;
    int c[n+1][m+1];
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        for(int j=1;j<=s.length();j++)
        {
            if(s[j-1]=='.')
                c[i][j]=0;
            else
                c[i][j]=1;
        }
    }
    long long M=1000000007;
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    if(c[1][1]==1 || c[n][m]==1)
    {
        cout<<"0"<<endl;
        return 0;
    }
    dp[1][1]=1;
    int f=0;
    for(int i=2;i<=m;i++)
    {
        if(c[1][i]==0 && f==0)
            dp[1][i]=1;
        else
        {
            f=1;
            dp[1][i]=0;
        }
    }
    f=0;
    for(int i=2;i<=n;i++)
    {
        if(c[i][1]==0 && f==0)
            dp[i][1]=1;
        else
        {
            f=1;
            dp[i][1]=0;
        }
    }
//    for(int i=1;i<=m;i++)
//        cout<<dp[1][i]<<" ";
//    cout<<endl;
    for(int i=2;i<=n;i++)
    {
        for(int j=2;j<=m;j++)
        {
            if(c[i][j]==0)
            {
                dp[i][j]=(dp[i-1][j]%M+dp[i][j-1]%M)%M;
            }
            else
            {
                dp[i][j]=0;
            }
        }
    }
    cout<<dp[n][m]<<endl;
}

Measured memory_bytes: 8064
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1LL<<60)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


vector<pair<int, int>> edge[1000];


long long d1[1000], d2[1000];


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

	int n,m;
	cin>>n>>m;
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		edge[a].emplace_back(b,c);
	}
	rep(i, n)d1[i]=-INF;
	d1[0]=0;
	rep(i,n){
		rep(j,n){
			for (auto e: edge[j]){
				d1[e.first] = max(d1[e.first], d1[j]+e.second);
			}
		}
	}
	memcpy(d2,d1,sizeof(d1));
	rep(i, n){
		rep(j, n){
			for (auto e : edge[j]){
				d2[e.first] = max(d2[e.first], d2[j] + e.second);
			}
		}
	}


	if (d1[n - 1] < d2[n - 1]){
		cout << "inf"<<endl;
	}
	else{
		cout << d1[n-1]<<endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
    
using namespace std;
    
int main(){
 int H,W,i,j;
 while (1) {
  cin>>H;
  cin >>W;
  if (H==0 && W==0) break;
  for (i=0;i<H;i++) {
   for (j=0;j<W;j++) {
    if ((i+j)%2==0) {
     cout << "#";
    } else {
     cout << ".";
    }
   }
   cout << endl;
  }
  cout << endl;
 }
 return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>

int main(void) {
	int n, sum;
	scanf("%d %d", &n, &sum);
	for (int i = 0; i <= n; i++) {
		if (10000 * i > sum) {
			break;
		}
		for (int j = 0; j <= n - i; j++) {
			if (10000 * i + 5000 * j > sum) {
				break;
			}
			int total = 10000 * i + 5000 * j + 1000 * (n - i - j);
			if (total == sum) {
				printf("%d %d %d\n", i, j, n - i - j);
				return 0;
			}
		}
	}
	printf("%d %d %d\n", -1, -1, -1);
	return 0;
}

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

using namespace std;
int main(int argc, const char * argv[]) {
    int n, i, tmp;
    cin >> n;
    for(i = 0, tmp = n;;i++){
        tmp = (n - i*7);
        if(tmp == 0){
            printf("Yes\n");
            return 0;
        }else if(tmp < 0){
            printf("No\n");
            return 0;
        }else{
            if(tmp % 4 == 0){
                printf("Yes\n");
                return 0;
            }
        }
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>

using namespace std;
const int N=2e5+10,inf=1e9;
int dp[N][2];
char s[N];

int main(){
    int A,P,ans;
	cin >> A >> P;
    P = P + A*3;
    ans = P/2;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A,B,C;
int main(){
    cin>>A>>B>>C;
    int tmp = A;
    A = B;
    B = tmp;

    tmp = C;
    C = A;
    A = tmp;

    cout << A << " " << B << " " << C << endl;
}

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

int main() {
    int a[5];
    fore(i, 0, 5) cin >> a[i];
    int k; cin >> k;
    fore(i, 0, 5) {
        fore(j, i + 1, 5) {
            if(a[j] - a[i] > k) {cout << ":(" << endl; return 0;}
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define p pair<int,int>
using namespace std;
bool comparator(p &A,p &B){
	return A.second>B.second;
}
int main(){
	int n,m;
	cin>>n>>m;
	vector<int>arr(n);
	for(int i=0;i<n;i++)
		cin>>arr[i];
	vector<p>mod(m);
	for(int i=0;i<m;i++){
		cin>>mod[i].first>>mod[i].second;
	}
	sort(arr.begin(),arr.end());
	sort(mod.begin(),mod.end(),comparator);
	// for(int i=0;i<m;i++){
	// 	cout<<mod[i].first<<" "<<mod[i].second<<"\n";
	// }
	int i=0;
	int j=0;
	while(i<n && j<m){
		if(mod[j].first==0 || mod[j].second<=arr[i]){
			j++;
		}else{
			arr[i]=mod[j].second;
			// cout<<"i:"<<i<<" "<<"arr[i]:"<<arr[i]<<"\n";
			mod[j].first-=1;
			i++;
		}
	}
	ll sum=0;
	for(int k=0;k<n;k++){
		// cout<<arr[k]<<" ";
		sum+=arr[k];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

bool pair_compare(const pair<int,int>& first_elof,const pair<int,int>& second_elof){
  return first_elof.second<second_elof.second;
}

int main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int> >pairs(M);
  vector<bool> check(N,true);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    pairs[i]=make_pair(a-1,b-1);
  }
  sort(pairs.begin(),pairs.end(),pair_compare);
  int ans=1,ons=pairs[0].second-1;
  for(int i=0;i<M;i++){
    int nf=pairs[i].first,ns=pairs[i].second;
    if(ons<nf){
      ons=ns-1;
      ans++;
    }
  }

  cout<<ans<<endl;

  return 0;
}




Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int pow10(int p) {
  if (p == 0) return 1;
  return 10 * pow10(p - 1);
}

int main(){
  int N;
  cin >> N;
  int d = log10(N)+1;
  int n = 0;
  for (int i = 1; i < d; i+=2){
    n += pow10(i) - pow10(i-1);
  }
  
  cout << ((d % 2 == 0) ? n : n + N % pow10(d) - pow10(d-1) + 1) << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define maxn 100010
int a[maxn], b[maxn], c[maxn];
using namespace std;
typedef long long LL;
int main() {
//    freopen("in.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
    for (int i = 0; i < n; ++i) scanf("%d", &c[i]);
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);

    int j=n-1, k=n-1;
    LL ans=0, temp=0;
    for (int i = n-1; i >= 0; --i) {
        ans += temp;
        while (j >= 0 && b[j] > a[i]) {
            while (k >= 0 && c[k] > b[j]) --k;
            temp += (n-1-k);
            ans += (n-1-k);
            --j;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

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

signed main(){
  int n;cin>>n;int a[5];rep(i,5)cin>>a[i];sort(a,a+5);
  double dn = n, dm = a[0];
  cout << (int)(ceil(n/dm)+4) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[20];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    int res = arr1[ch[0] - '0'][ch[7] - '0'];
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            res = '4' - ch[2];
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            res = ch[2] - '0';
        }
        else
            res = arr1[ch[0] - '0'][ch[6] - '0'];
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            res = 22888;
        }
        else if (ch[0] == '9') {
            res = 25436;
        }
    }
    puti(res);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1468
#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()
{
  string s;
  cin >> s;
  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
  return 0;
}

Measured memory_bytes: 3624
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int               long long
#define ff                first
#define ss                second
#define md                1000000007
#define md1               998244353
#define inf               1000000000000000
#define minf              -1000000000000000
#define pb                push_back
#define ppb               pop_back
#define in                insert
#define mkp               make_pair
#define mpll              map<ll,ll>
#define len(p)            (ll)p.size()
#define pll               pair<ll,ll>
#define all(v)            v.begin(),v.end()
#define mem(a,t)          memset(a,t,sizeof(a))
#define endl              "\n"
#define ar                array
#define vl                vector<ll>
#define vvl               vector<vl>
#define lb                lower_bound
#define ub                upper_bound
#define be()              begin()
#define en()              end()
#define vpll              vector<pair<ll,ll>>
#define f(i,yha,wha)      for(ll i=yha;i<wha;i++)
#define rf(i,wha,yha)     for(ll i=wha;i>=yha;i--)
#define f0(n)             for(ll i=0;i<n;i++)
#define f1(n)             for(ll i=1;i<=n;i++)
#define fg(i,yha,wha,gap) for(ll i=yha;i<wha;i+=gap)

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


void solve()
{
    ll n;
    cin >> n;
    ll a[n + 10];
    f(i, 0, n)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    ll mx = 1000000000000000000;
    ll mx2 = 1000000000;
    ll ans = 1;
    f0(n)
    {
        if (ans > 0)
        {
            ll tmp = mx / ans + 1;
            if (a[i] > tmp)
            {
                cout << "-1" << endl;
                return;
            }
        }
        if (ans > mx2 and a[i] > mx2)
        {
            cout << "-1" << endl;
            return;
        }

        if (ans * a[i] > mx)
        {
            cout << "-1" << endl;
            return;
        }
        ans = ans * a[i];
    }
    cout << ans << endl;
}

int32_t main()
{
    flash();
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4444
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int ALP='z'-'a'+1,MAX_N=2e5,INF=1e8;
string S;
int N,opt[MAX_N+1],dp[1<<ALP],cnt[ALP];
int main(){
	cin>>S;
	N=(int)S.size();
	opt[0]=0;
	fill(dp,dp+(1<<ALP),INF);
	dp[0]=0;
	int b=0;
	REP(i,N){
		b^=1<<(S[i]-'a');
		opt[i+1]=dp[b]+1;
		REP(j,ALP){
			opt[i+1]=min(dp[b^(1<<j)]+1,opt[i+1]);
		}
		dp[b]=min(dp[b],opt[i+1]);
	}
	cout<<opt[N]<<endl;
}

Measured memory_bytes: 263556
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;

int n, k, total;
vector<int> a;
vector<int> moda;
vector<int> divs;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    a = vector<int>(n);
    moda = vector<int>(n);

    REP(i, n) {cin >> a[i]; total += a[i];};
    for (int k = 1; k * k <= total; ++k) {
        if (total % k != 0) continue;
        divs.push_back(k);
        divs.push_back(total / k);
    }
    sort(divs.begin(), divs.end(), greater<int>());
    // DV(divs);
    for (int d : divs) {
        REP(i, n) moda[i] = a[i] % d;
        sort(moda.begin(), moda.end());
        int l = 0;
        int r = n - 1;
        int cnt = 0;
        while(l < r) {
            assert(l != r || moda[l] != 0);
            int lv = moda[l];
            int rv = d - moda[r];
            int diff = min(lv, rv);
            cnt += diff;
            moda[l] -= diff;
            moda[r] = (moda[r] + diff) % d;
            if (moda[l] == 0) l++;
            if (moda[r] == 0) r--;
        }
        if (cnt <= k) {
            cout << d << endl;
            return 0;
        }
    }
}


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

using ll = long long;
using ld = long double;

int main()
{
    int a,b;
    string s;
    cin >> a >> b >> s;
    bool ok = true;
    
    for(int i = 0; i < a+b+1; i++)
    {
        if(i == a)
        {
            if(s.at(i)!='-') 
            {
                ok = false;
                break;
            }
        }
        else
        {
            if(s.at(i) < '0' || s.at(i) < 9)
            {
                ok = false;
                break;
            }
        }
    }
    
    if(ok)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

ll N, W, w, a, b;
vector<vector<ll>> v(4);

int main()
{
    cin >> N >> W >> w >> a;
    for (int i = 0; i < 4; i++)
        v[i].push_back(0);
    v[0].push_back(a);
    for (int i = 1; i < N; i++)
    {
        cin >> a >> b;
        v[a - w].push_back(b);
    }
    for (int i = 0; i < 4; i++)
    {
        sort(v[i].begin() + 1, v[i].end(), greater<ll>());
        for (int j = 1; j < v[i].size(); j++)
            v[i][j] += v[i][j - 1];
    }
    ll ans = 0, w1 = v[0].size(), w2 = v[1].size(), w3 = v[2].size(), w4 = v[3].size();
    for (int i = 0; i < w1; i++)
    {
        for (int j = 0; j < w2; j++)
        {
            for (int k = 0; k < w3; k++)
            {
                ll weight = w * i + (w + 1) * j + (w + 2) * k;
                if (weight > W)
                    continue;
                ll l = min(w4 - 1, (W - weight) / (w + 3));
                ans = max(v[0][i] + v[1][j] + v[2][k] + v[3][l], ans);
            }
        }
    }
    cout << ans << endl;
}

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

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

int main() {
    int A, B;
    cin >> A >> B;

    if (A <= 8) {
        if (B <= 8) {
            cout << "Yay!" << endl;
        } else {
            cout << ":(" << endl;
        }
    } else {
        cout << ":(" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
#include <algorithm>
using namespace std;

bool IsEqual(int* begin, int size)
{
	for (int i = 1; i < size; i++)
	{
		if (begin[i] != begin[i - 1]) return false;
	}
	return true;
}

int main()
{
	int card[5];

	while (true)
	{
		for (int i = 0; i < 5; i++)
		{
			if (scanf("%d,", &card[i]) == -1) return 0;
		}
		sort(card, card + 5);

		if	(IsEqual(card, 4)) printf("four card\n");

		else if (IsEqual(card + 1, 4)) printf("four card\n");

		else if (IsEqual(card, 3) && IsEqual(card + 3, 2)) printf("full house\n");

		else if (IsEqual(card, 2) && IsEqual(card + 2, 3)) printf("full house\n");

		else if (card[0] + 1 == card[1] && card[1] + 1 == card[2]
			  && card[2] + 1 == card[3] && card[3] + 1 == card[4]) printf("straight\n");

		else if (card[0] == 1 && card[1] == 10 && card[2] == 11
			  && card[3] == 12 && card[4] == 13) printf("straight\n");

		else if (IsEqual(card, 3) || IsEqual(card + 1, 3) || IsEqual(card + 2, 3)) printf("three card\n");

		else if (IsEqual(card, 2) && IsEqual(card + 2, 2)) printf("two pair\n");

		else if (IsEqual(card + 1, 2) && IsEqual(card + 3, 2)) printf("two pair\n");

		else if (IsEqual(card, 2) && IsEqual(card + 3, 2)) printf("two pair\n");

		else
		{
			for (int i = 0; i < 4; i++)
			{
				if (IsEqual(card + i, 2))
				{
					printf("one pair\n");
					break;
				}
				if (i == 3)
				{
					printf("null\n");
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int 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()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main() {
  ll n; cin >> n;
  ll m = n;
  ll s = 0;
  while(m>0){
    s += m%10;
    m /= 10;
  }
  if(n%s == 0) yes();
  else no();
}

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

class union_find {
private:
	vector<int> uf;
public:
	union_find(int n):uf(n, -1) {}

	int find(int x) {
		return uf[x] < 0 ? x : uf[x] = find(uf[x]);
	}

	bool unite(int a, int b) {
		a = find(a);
		b = find(b);

		if(a == b) return false;

		if(uf[a] > uf[b]) {
			swap(a, b);
		}
		else if(uf[a] == uf[b]) {
			--uf[a];
		}

		uf[b] = a;
		return true;
	}
};

struct edge {
	int u, v;
	int cost;
	edge(int u, int v, int c):u(u), v(v), cost(c){}
	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

int calc(int n, vector<edge> &edges) {
	sort(edges.begin(), edges.end());

	int cnt = 0;
	union_find uf(n);
	for(const auto &e : edges) {
		if(uf.unite(e.u, e.v) && ++cnt == n / 2) return e.cost;
	}
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	for(int n, m; cin >> n >> m && n;) {
		vector<edge> edges;
		edges.reserve(m);
		for(int i = 0; i < m; ++i) {
			int s, t, c;
			cin >> s >> t >> c;
			edges.emplace_back(s - 1, t - 1, c);
		}
		cout << calc(n, edges) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1324
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

constexpr int MOD = int(1e5);
int H, W;
auto memo = make_v(-1LL, 101, 101, 2, 2);

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

intmax_t dp(int y, int x, int before1, int before2) {
    if (y > H || x > W) return 0;
    if (y == H && x == W) return 1;
    if (~memo[y][x][before1][before2]) return memo[y][x][before1][before2];

    intmax_t ret = 0;
    if (before1 == before2) {
        ret += dp(y + dy[0], x + dx[0], 1, before1);
        ret += dp(y + dy[1], x + dx[1], 0, before1);
        ret %= MOD;
    } else {
        ret += dp(y + dy[!before1], x + dx[!before1], before1, before1);
        ret %= MOD;
    }

    return memo[y][x][before1][before2] = ret;
}

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

    while (cin >> W >> H, W && H) {
        memo = make_v(-1LL, H + 1, W + 1, 2, 2);
        cout << (dp(2, 1, 1, 1) + dp(1, 2, 0, 0)) % MOD << "\n";
    }

    return 0;
}



Measured memory_bytes: 5832
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(void){
    vector<vector<int>> A(3,vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++) cin >> A[i][j];
    }
    int N;
    cin >> N;
    vector<int> b(N);
    for(int i = 0; i < N; i++) cin >> b[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(b[i] == A[j][k]) A[j][k] = -1;
            }
        }
    }
    if(A[0][0] == A[1][1] && A[2][2] == A[0][0]) cout << "Yes" << endl;
    else if(A[2][0] == A[1][1] && A[1][1] == A[0][2]) cout << "Yes" << endl;
    else if(A[0][0] == A[0][1] && A[0][1] == A[0][2]) cout << "Yes" << endl;
    else if(A[0][0] == A[1][0] && A[1][0] == A[2][0]) cout << "Yes" << endl;
    else if(A[1][0] == A[1][1] && A[1][1] == A[1][2]) cout << "Yes" << endl;
    else if(A[0][1] == A[1][1] && A[1][1] == A[0][2]) cout << "Yes" << endl;
    else if(A[2][0] == A[2][1] && A[2][1] == A[2][2]) cout << "Yes" << endl;
    else if(A[0][2] == A[1][2] && A[1][2] == A[2][2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import numpy as np
N, K = list(map(int, input().split()))
A = np.array(list(map(int, input().split())))
div = 1000000007
s = 0
s2 = 0
for i, n in enumerate(A):
    tmp = A < n
    s += np.count_nonzero(tmp[i+1:])
    s2 += np.count_nonzero(tmp)

print(((s * K) + (s2 * (K-1) * K // 2)) % div)


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

int main() {
	// your code goes here
	string s1,s2,s3;
	int a,b;
	cin >> s1 >> s2 >> a >> b >> s3;
	if(s1==s3)
	cout << a-1 << " " << b << endl;
	else cout << a << " " << b-1 << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}
void add_self(int &x, int y){
	x=add(x,y);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string k;
	cin>>k;
	int d;
	cin>>d;
	int n=k.size();
	vector<vector<int>> dp(2,vector<int>(d));
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		vector<vector<int>> newdp(2,vector<int>(d));
		for(int sum=0;sum<d;sum++)
		for(bool alr:{false,true}){
			for(int j=0;j<10;j++){
				if(j>k[i]-'0'&&!alr){
					break;
				}
				add_self(newdp[alr||(j<k[i]-'0')][(sum+j)%d],dp[alr][sum]);
			}
		}
		dp=newdp;
	}
	cout<<(add(dp[1][0],dp[0][0])+mod-1)%mod<<endl;
}


Measured memory_bytes: 256