akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	    ll n;
	    cin>>n;
	    set<string>s;
	    string s1;
	    for(ll i=0;i<n;i++)
	    {
	    	cin>>s1;
	    	s.insert(s1);
	    }
	    cout<<s.size();
}

Measured memory_bytes: 19144
const INF: u64 = 1e10 as u64;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let mut dp = vec![INF; n];
    dp[0] = a[n - 1];
    for a in a.into_iter().rev().skip(1) {
        let i = dp
            .binary_search_by_key(&(a * 2 + 1), |&b| b * 2)
            .err()
            .unwrap();
        dp[i] = a;
    }

    let ans = dp.into_iter().take_while(|&i| i != INF).count();
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

bool d8(int n){
  int ans=0;
  loop(i,1,n/2+1)
    if(n%i==0) ans++;
  return ans+1==8;
}

int main(){
  int n;cin >> n;
  int ans=0;
  for(int i=1;i<=n;i+=2){
    if(d8(i)) ans++;
  }

  cout << ans << endl;
  return 0;
}


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

typedef long long lglg;

vector<int> perm;
bool chosen[8] = {};
int n;
lglg adj[8][8];
long double result = 0;
void search() {
	if (perm.size() == n) {
		int prev = perm[0];
		for (int i=1; i<n; ++i) {
			result += sqrt(adj[prev][perm[i]]);
			prev = perm[i];
		}
	} else {
		for (int i = 0; i < n; i++) {
			if (chosen[i]) continue;
			chosen[i] = true;
			perm.push_back(i);
			search();
			chosen[i] = false;
			perm.pop_back();
		}
	}
}

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

	cin >> n;
	int x[n], y[n];
	for (int i=0; i<n; ++i) {
		cin >> x[i] >> y[i];
	}

	for (int i=0; i<n; ++i) {
		for (int j=0; j<n; ++j) {
			adj[i][j] = (lglg)(x[i]-x[j])*(x[i]-x[j]) + (lglg)(y[i]-y[j])*(y[i]-y[j]);
			adj[j][i] = (lglg)(x[i]-x[j])*(x[i]-x[j]) + (lglg)(y[i]-y[j])*(y[i]-y[j]);
		}
	}

	search();
	for (int i=2; i<=n; ++i) result /= i;
	cout << setprecision(12) << result;
}

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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

// Warshall-Floyd
void init(ll V, vvll& cost) {
  cost = vvll(V, vll(V, INF));
  rep(i, V) {
    // 自分自身へ移動するコストは0
    cost[i][i] = 0;
  }
}

void warshall_floyd(ll V, vvll& cost) {
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m, r;
  cin >> n >> m >> r;

  vll route(r);
  rep(i, r) {
    cin >> route[i];
  }

  // 最終的にiからjの最小コストはcost[i][j]となる。
  vvll cost;
  init(n + 1, cost);

  rep(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    cost[a][b] = c;
    cost[b][a] = c;
  }

  warshall_floyd(n + 1, cost);

  sort(all(route));

  ll ans = INF;

  do {
    ll c = 0;
    REP(i, r) {
      c += cost[route[i]][route[i - 1]];
    }
    chmin(ans, c);
  } while (next_permutation(all(route)));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
n, W = list(map(int,input().split()))
w_v = [list(map(int,input().split())) for i in range(n)]
w = [w_v[i][0] for i in range(n)]
v = [w_v[i][1] for i in range(n)]
inf = 10**9+1
dp = [[inf] * (sum(v)+1) for i in range(n+1)]
dp[0][0] = 0

for i in range(n):
  for j in range(sum(v)+1):
    if j - v[i] >= 0:
      dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]] + w[i])

    dp[i+1][j] = min(dp[i+1][j], dp[i][j])


for i in range(sum(v)+1):
  if dp[n][i] > W:
    pass
  else:
    ans = i
print(ans)


Measured memory_bytes: 121452
#include <iostream>

using namespace std;

int sum(int n)
{
    int s = 0;
    for (int i = 1; i <= n; i++) s += i;
    return s;
}
int main()
{
    int a, b;

    cin >> a >> b;
    cout << sum(b-a) - b << endl;
}

Measured memory_bytes: 256
N=int(input())
alphabets='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
S=input()
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
ans=[]
for i in range(0,len(S)):
  ans.append(S[i])
ans2=[]
for i in ans:
  for j in range(0,26):
    if alphabets[j]==i:
      ans2.append(alphabets[(j+N)%26])
ans=convert(ans2)
print(ans)
      

Measured memory_bytes: 3188
let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let () = Scanf.scanf "%d %d\n%s" @@ fun n p s ->
  if p = 2 || p = 5 then begin
    Printf.printf "%d\n" @@
    Array.fold_left ( + ) 0 @@
    Array.init n @@ fun i ->
      if 0 < (Char.code s.[i] - Char.code '0') mod p
      then 0
      else i + 1
  end else begin
    let ( +^ ) x y = (x + y) mod p in
    let ( *^ ) x y = (x * y) mod p in
    let acc = Array.make (n + 1) 0 in
    for i = 0 to n - 1 do
      acc.(i + 1) <- acc.(i) +^ power ( *^ ) (Char.code s.[i] - Char.code '0') 10 ((p - 2) * (i + 1))
    done;
    let ms = Array.make p 0 in
    Array.iter (fun m -> ms.(m) <- 1 + ms.(m)) acc;
    Printf.printf "%d\n" @@
    Array.fold_right (fun m -> ( + ) @@ m * (m - 1) / 2) ms 0
  end

Measured memory_bytes: 4992
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll n,sum = 0;
    cin >> n;
    rep(i,1,n+1){
        if(i % 3 && i % 5) sum += i;
    }
    cout << sum << endl;
    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int up(int a) {
    int to_add = (10-a%10)%10;
    return a + to_add;
}

int get(int a, int b) {
    if(a%10 == 0) return b;
    else if(b%10 == 0) return a;
    else if(a%10 < b%10) return a;
    else return b;
}

int32_t main() {

    int a, b, c, d, e; cin >> a >> b >> c >> d >> e;

    int sm = get(a, get(b, get(c, get(d, e))));

    int ans = up(a) + up(b) + up(c) + up(d) + up(e) - up(sm) + sm;

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
ll mod = pow(10,9) + 7;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}
int main() {
	int n; cin >> n;
	string s; cin >> s;
	vector<int> v(s.size()+1);
	v[0] = n;
	rep(i,s.size()){
		if (s[i] == 'I'){
			v[i] = v[i-1]+1;
		}else{
			v[i] = v[i-1]-1;
		}
	}
	cout << *max_element(all(v)) << endl;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    if(n%2==0){
        if(k<=n/2) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    else{
        if(k<=(n+1)/2) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a&b||c) cout<<"Open\n";
	else cout<<"Close\n";
}

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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

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



Measured memory_bytes: 256
# Union-Findデータ構造
class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
    def find(self, x):
        if self.pars[x] == x: return x
        else:
            self.pars[x] = self.find(self.pars[x])
            return self.pars[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
        else:
            self.pars[y] = x
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)

def conv(i, j):
    return (i-1)*W + j-1

H, W = map(int, input().split())
Sss = ['_' + input() + '_' for _ in range(H)]
Sss = ['_' * (W + 2)] + Sss + ['_' * (W + 2)]

N = H * W
UF = UnionFind(N)
for i in range(1, H+1):
    for j in range(1, W+1):
        revS = '.' if Sss[i][j] == '#' else '#'
        for di, dj in [(-1,0), (1,0), (0,-1), (0,1)]:
            if Sss[i+di][j+dj] == revS:
                UF.union(conv(i, j), conv(i+di, j+dj))

numBs, numWs = [0]*N, [0]*N
for i in range(1, H+1):
    for j in range(1, W+1):
        no = UF.find(conv(i, j))
        if Sss[i][j] == '#':
            numBs[no] += 1
        else:
            numWs[no] += 1

ans = 0
for numB, numW in zip(numBs, numWs):
    ans += numB * numW
print(ans)


Measured memory_bytes: 59228
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    N, K = read_ints()
    L, R = [], []
    for _ in range(K):
        l, r = read_ints()
        L.append(l)
        R.append(r)
    dp = [0]*N
    prefix = [0]*N
    dp[0] = 1
    prefix[0] = 1
    modulo = 998244353
    for i in range(1, N):
        for k in range(K):
            left = max(0, i-R[k])
            right = i-L[k]
            if right < 0:
                continue
            if left == 0:
                dp[i] = (dp[i]+prefix[right])%modulo
            else:
                dp[i] = (dp[i]+prefix[right]-prefix[left-1])%modulo
        prefix[i] = (prefix[i]+prefix[i-1]+dp[i])%modulo
    return dp[N-1]


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 73876
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,k;
    cin>>n>>k;
    n++;
    long long x=0;
    for(long long i=k+1;i<n;i++){
        x+=n/i*(i-k);
        x+=max(n%i-k,0ll);
    }
    if(k==0)x=(n-1)*(n-1);
    cout<<x<<endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int c = 0;
  for (int i = 0; i < s.size(); i ++) {
    if (s.at(i) == '1') c ++;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n, m= list(map(int,input().split()))
h = list(map(int,input().split()))
h = [0] + h

good = [False] + [True]*n

while m:
    m -= 1
    a, b = list(map(int,input().split()))
    if h[a] < h[b]:
        good[a] = False
    elif h[a]==h[b]:
        good[a] = good[b] = False
    else:
        good[b] = False

print(good.count(True))

    


Measured memory_bytes: 20568
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


int main(){
    ll N,M,K; cin >> N >> M >> K;
    init();
    ll x = (M*N*(M+N)*(M*N-1))/6;
    x %= MOD;
    if (K == 2){
        cout << x << endl;
        return 0;
    } else {
        ll y = COM(M * N - 2, K-2);
        ll ans = (x*y)%MOD;
        if (ans < 0) ans += MOD;
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 12032
# -*- coding: utf-8 -*-
# map(int, input().split())
mod = 998244353

N, K = map(int, input().split())
kukans = []

for k in range(K):
    L, R = map(int, input().split())
    kukans.append([L,R])

kukans = list(sorted(kukans, key=lambda x:x[0]))

ruiseki_dp = [0]
for i in range(1,N+1):
    if i == 1:
        ruiseki_dp.append(1)
    else:
        # たどり着くためにできるマスの動き
        able_kukans = []
        for L,R in kukans:
            if R <= i-1:
                able_kukans.append([L,R])
            elif L <= i-1 < R:
                able_kukans.append([L,i-1])
                break
            else: # i-1 < L
                break
        
        next_dp = 0
        for L, R in able_kukans:
            next_dp = (next_dp+ruiseki_dp[i-L]-ruiseki_dp[i-R-1])%mod

        ruiseki_dp.append((ruiseki_dp[-1]+next_dp)%mod)
    
print((ruiseki_dp[-1]-ruiseki_dp[-2])%mod)

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

#define all(c) (c).begin(),(c).end()
#define FOR(i, x, n) for(int i = x; i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) #x << "=" << (x) << "(L" << __LINE__ << ")"
#define puts(x) cout << x << endl
#define puts2(x,y) cout << x << endl; cout << y << endl
#define show(x) cout << #x << "=" << x << endl
#define show2(x,y) cout << #x << "=" << x << "," << #y << "=" << y <<  endl
#define show3(x,y,z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z <<  endl
#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 ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

const ld eps = 1e-9, pi = acos(-1.0);
const ld EPS = 1e-8;
const int INF = INT_MAX/2;
const ll LINF = LONG_MAX/2;
const int MOD = 1000000007;

template<class T> inline void amin(T &a, const T &b) { if (b<a) a=b; }
template<class T> inline void amax(T &a, const T &b) { if (a<b) a=b; }

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

bool ismonth(int k){
    return (1<=k && k <=12) ? true : false;
}

bool isyear(int k){
    return k ? false : true;
}

int main(){
    
    ll s;
    cin >> s;
    
    ll t = s/100;
    ll u = s%100;
    
    string ans = "NA";
    if( ismonth(t) && ismonth(u) ){
        ans =  "AMBIGUOUS";
    }else if(ismonth(u)){
        ans =  "YYMM"; 
    }else if(ismonth(t)){
        ans = "MMYY";
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main(void){
  int h, w;
  vector<pair<int, pair<int, int> > > v;

  for(int i=1; i<150; i++){
    for(int j=2; j<=150; j++){
      if(i < j)
        v.push_back(make_pair(pow(i, 2) + pow(j, 2), make_pair(i, j)));
    }
  }
  sort(v.begin(), v.end());

  while(cin >> h >> w, h || w){
    int brd = pow(h, 2) + pow(w, 2);

    for(int i=0; i<v.size(); i++){
      if((brd == v[i].first && h < v[i].second.first) || brd < v[i].first){
        cout << v[i].second.first << " " << v[i].second.second << endl;
        break;
      }
    }
  }

  return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string n;
    cin >> n;
    long long num = 0;
    for (int i = 0; i < n.size(); i++) {
        num += n[i] - '0';
    }
    if (num % 9 == 0) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<endl;cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

void f(string s,ll ma,ll n,vector<string>&ans){
  if(s.size()==n){
    ans.push_back(s);
    return;
  }
  rep(i,ma+1){
    s.push_back('a'+i);
    f(s,max(i+1,ma),n,ans);
    s.pop_back();
  }

  return;
}

bool solve(){
  ll n;cin>>n;
  vector<string>ans;
  f(string(),0,n,ans);
  cout<<ans<<endl;
  return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 9332
solve s1 s2
 | s1 && s2       = "NA"
 | (not s1) && s2 = "MMYY"
 | s1 && (not s2) = "YYMM"
 | otherwise      = "AMBIGUOUS"

main = do
 s <- getLine
 let s1 = (\x -> (x > 12) || (x == 0)) $ read $ take 2 s
 let s2 = (\x -> (x > 12) || (x == 0)) $ read $ drop 2 s
 putStr $ solve s1 s2

Measured memory_bytes: 3752
N=int(input())
X=sorted(list(map(int,input().split())))

ans = 100000000

for p in range(1,100): #Pの位置
  sum = 0
  for x in X: #Xの要素を１つずつ取得
    sum += (x - p)**2
  ans = min(sum, ans)

print(ans)
    


Measured memory_bytes: 63796
x=int(input())
if 400<=x<=599:
  print(8)
elif 600<=x<=799:
  print(7)
elif 800<=x<=999:
  print(6)
elif 1000<=x<=1199:
  print(5)
elif 1200<=x<=1399:
  print(4)
elif 1400<=x<=1599:
  print(3)
elif 1600<=x<=1799:
  print(2)
elif 1800<=x<=1999:
  print(1)

Measured memory_bytes: 61772
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, k = f()
    if k&1:
        print((n//k)**3)
    else:
        add = 1 if n%k>= (k//2) else 0
        print((n//k + add)**3  + (n//k)**3)



solve()


Measured memory_bytes: 2940
/*
    Problem 63
    https://atcoder.jp/contests/abc074/tasks/arc083_b
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int V;
    cin >> V;
    vector<vector<ll>> G(V, vector<ll>(V, LINF));
    vector<vector<bool>> use(V, vector<bool>(V, true));
    for (int i = 0; i < V; i++)
        for (int j = 0; j < V; j++)
            cin >> G[i][j];

    bool exist = true;
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                if (i == j) continue;
                if (G[i][j] > G[i][k] + G[k][j])
                    exist = false;
                else if (G[i][j] == G[i][k] + G[k][j])
                    if (i != k  && k != j)
                        use[i][j] = false;
            }
        }
    }


    if (exist) {
        ll sum = 0;
        for (int i = 0; i < V; i++)
            for (int j = 0; j < i; j++)
                if (use[i][j]) sum += G[i][j];
        cout << sum << '\n';
    }
    else cout << -1 << '\n';
}

Measured memory_bytes: 4352
N, K = map(int, input().split())
h = list(map(int, input().split()))
inf = 10**9
dp = [inf] * N
dp[0] = 0


def chmin(num: int, sbn: int):
    dp[num + sbn] = min((dp[num + sbn], dp[num] + abs(h[i + sbn] - h[num])))


for i in range(N):
    for sbn in range(K):
        try:
            chmin(i, sbn + 1)
        except IndexError:
            break
print(dp[-1])


Measured memory_bytes: 52448
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
typedef long long int ll;

constexpr ll mod=1e9+7;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}


ll sum[100100];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k; cin >> n >> k;
	ll res=0;
	sum[1]=1;
	for(int i=2;i<=k;i++){
		vector<int> p;
		for(int j=1;j*j<=i;j++){
			if(i%j==0){
				p.push_back(j);
				if(i/j!=j)p.push_back(i/j);
			}
		}
		sum[i]=i;
		for(int j=0;j<p.size();j++){
			if(p[j]!=i)sum[i]-=sum[p[j]];
		}
	}
	for(int i=1;i<=k;i++){
		ll p=k/i;
		(res-=mod_pow(p,n)*(i-sum[i])%mod)%=mod;
		(res+=mod_pow(p,n)*i%mod)%=mod;
		//cout << res << endl;
	}
	if(res<0)res+=mod;
	cout << res << endl;
}

Measured memory_bytes: 4384
#include <stdio.h>
#include <stdlib.h>
int i,n,m,a[101],sum,count;
double x;

int main()
{

    scanf("%d %d",&n ,&m);

    for(i=1;i<=n;i++){
        scanf("%d",& a[i]);
        sum=sum+a[i];
    }
     x=sum/(4.0*m);
        for(i=1;i<=n;i++){
        if(a[i]>=x){
            count++;
        }
    }
    if(count>=m)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }



    return 0;
}



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

int main(){
	// input
	int r, D, x0; cin >> r >> D >> x0;
	// compute
	int ans = x0;
	for (int i = 0; i < 10; i++){
		ans = r * ans - D;
		// output
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll, ll> P;

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

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

int main() {
	ll n;
	cin >> n;
	vector<ll> vs(n);
	rep(i, n) cin >> vs[i];
	sort(vs.begin(), vs.end());
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ll a = vs[i] + vs[j];
			auto l = std::lower_bound(vs.begin() + j, vs.end(), a);
			advance(l, -1);
			auto d = l - (vs.begin() + j);
			sum += d;
		}
	}
	cout << sum << endl;
	return 0;
}


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

int main(){
	int n,d,x;scanf("%d%d%d",&n,&d,&x);
	rep(i,n){
		int a;scanf("%d",&a);
		x+=(d-1)/a+1;
	}
	cout<<x<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
  int n,i;
  float temp;
  int count = 0;
  int max_count = 0;
  int max_num = 0;
  scanf("%d", &n);

  for(i = 1; i <= n; i++){
    temp = i;
    while (fmodf(temp, 2) == 0){
      temp = temp / 2.0;
      count++;
    }

    if(max_count <= count){
      max_count = count;
      max_num = i;
    }

    count = 0;
  }

  printf("%d\n", max_num);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int h1, h2, m1, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << 60 * (h2 - h1) + m2 - m1 - k << '\n'; 
	return 0;
}

Measured memory_bytes: 3616
t = gets.to_i

t.times {
  n = gets.to_i

  ansA = 0
  ansB = 0
  beforeh = 0

  block = gets.split(" ")

  block.each_with_index do |item, index|

    h = item.to_i

    if index == 0 
      beforeh = h
      next
    end

    if (h - beforeh > ansA)
      ansA = h - beforeh
    end
    if (beforeh - h > ansB)
      ansB = beforeh - h
    end

    beforeh = h

  end

  print "#{ansA} #{ansB}\n"
}

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

typedef long long int ll;

int main()
{
    string o, e;
    cin >> o >> e;

    for(ll i = 0;i < o.size();i++){
        cout << o[i];
        if(o.size() - 1 == i && o.size() != e.size());
        else cout << e[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define dd second
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define pp pair<int,int>
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    int ans = 1;
    int n; cin >> n;
    for(int i = 0; i < n; ++i)
    {
        int temp; cin >> temp;
        int ile = 0;
        for(int x = temp-1; x <= temp+1; ++x) if(x & 1) ile++;
        ans *= ile;
    }
    int kk = 1;
    for(int i = 0; i < n; ++i) kk *= 3;
    cout << kk - ans << endl;
}



Measured memory_bytes: 256
#include <complex>
#include <iostream>
using namespace std;
typedef complex<double> P;
double cr(P a, P b) {
  return (conj(a) * b).imag();
}
int main() {
  P a, b, c, d;
  double x1, y1, x2, y2, x3, y3, x4, y4;
  char cm;
  while (cin >> x1 >> cm >> y1 >> cm >> x2 >> cm >> y2 >> cm >> x3 >> cm >> y3
    >> cm >> x4 >> cm >> y4) {
    a = P(x1, y1), b = P(x2, y2), c = P(x3, y3), d = P(x4, y4);
    P e = a - b, f = b - c, g = c - d, h = d - a;
    double i = cr(e, f), j = cr(f, g), k = cr(g, h), l = cr(h, e);
    cout
      << ((i > 0 && j > 0 && k > 0 && l > 0)
        || (i < 0 && j < 0 && k < 0 && l < 0) ? "YES" : "NO") << endl;
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/

int main(){
cout<<fixed<<setprecision(10);

  int A,B,X;cin>>A>>B>>X;
  
  
  if(A+B>=X&&X>=A){
    cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}


Measured memory_bytes: 384
A,B,C,X,Y = map(int,input().split())
if A+B<2*C:
  print(A*X+B*Y)
else:
  if X >= Y:
    print(min(2*C*X,2*C*Y+A*(X-Y)))
  else:
    print(min(2*C*Y,2*C*X+B*(Y-X)))

Measured memory_bytes: 9160
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // 入力
    String s = sc.next();
    String t = sc.next();
    int a = sc.nextInt();
    int b = sc.nextInt();
    String u = sc.next();
    
    // 解く
    if(s.equals(u)) a -= 1;
    else b -= 1;
    
    // 出力
    System.out.println(a + " " + b);
  }
}


Measured memory_bytes: 21844
<?php
  
  fscanf(STDIN,"%d",$n);

$memo = array();
for($i=1;$i<100000;$i++){
  if($n%2==0){
    $memo[$n]++;
    if($memo[$n]>=2){
    echo $i."\n";
    break;
  }
    $n = $n/2;
  }else{
    $memo[$n]++;
    if($memo[$n]>=2){
    echo $i."\n";
    break;
  }
    $n = 3*$n+1;
  }
 
}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
int main()
{
  int n;
  scanf("%d",&n);
  int a[n][3];
  int dp[n+1][3];
  REP(i,n){
    REP(j,3){
      scanf("%d",&a[i][j]);
      dp[i][j] = 0;
    }
  }
  REP(j,3) dp[n][j] = 0;
  REP(i,n){
    REP(j,3){
      REP(k,3){
        if(j!=k) dp[i+1][k] = max(dp[i+1][k], dp[i][j]+a[i][k]);
      }
    }
  }
  cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;
  
}

Measured memory_bytes: 2560
a,b=map(int,input().split())
a-=1
if a%2==0:
	x=((a//2)%2)^a
else:
	x=(a+1)//2%2
if b%2==0:
	y=((b//2)%2)^b
else:
	y=(b+1)//2%2
print(x^y)

Measured memory_bytes: 38384
A,B = map(int,input().split())
x=0

if A>B:
  x=x+A
  A=A-1
else:
  x=x+B
  B=B-1
  
if A>B:
  x=x+A
  A=A-1
else:
  x=x+B
  B=B-1
   
print(x)

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n, a, b;
  cin >> n >> a >> b;
  if (a + b > n + 1 || 1LL * a * b < n) {
    cout << -1 << '\n';
    return 0;
  }

  vector<int> res(n);
  iota(res.begin(), res.end(), 1);

  int num = n - a, iter = 0, leng;
  while (num > 0) {
    leng = min(num, b - 1);
    reverse(res.begin() + iter, res.begin() + iter + leng + 1);
    iter += leng + 1;
    num -= leng;
  }

  for (auto i : res) {
    cout << i << ' ';
  }
  cout << '\n';

  return 0;
}


Measured memory_bytes: 4476
S = input()

a = 0
ab = 0
abc = 0
all = 1
mod = 10**9 + 7

for i in range(len(S)):
    if S[i] == 'A':
        a += all
    elif S[i] == 'B':
        ab += a
    elif S[i] == 'C':
        abc += ab
    elif S[i] == '?':
        abc = 3*abc + ab
        ab = 3*ab + a
        a = 3*a + all
        all *= 3

    a %= mod
    ab %= mod
    abc %= mod
    all %= mod

print(abc)

Measured memory_bytes: 3188
I0 = lambda :map(int,input().split())
I1 = lambda :int(input())
I2 = lambda :list(map(int,input().split()))
#####################################################
from math import ceil
A,B = I0()
A-=1
res=1
c=0
while res < B:
    res+=A
    c+=1
print(c)


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

int main()
{
  string N;
  int count=0;
  cin >> N;
  if(N=="hi") count++;
  if(N=="hihi") count++;
  if(N=="hihihi") count++;
  if(N=="hihihihi") count++;
  if(N=="hihihihihi") count++; 
  
  if(count >=1) cout << "Yes" <<endl;
  else cout<< "No" << endl;
}
/*
  for(int i=0;i<=N;i++){
	 for(int j=0;j<=N;j++){
		int k = N - i - j;
       if(10000*i+5000*j+1000*k==Y && i+j+k<=N){
			A = i,B=j,C=k;            
            }
        }
     }
  
  cout << A << " " << B << " " << C;
}
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb(x) push_back((ll)(x))
#define pf(x) push_front((ll)(x))
#define nl cout << "\n";
 
void ini(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

int main(){
	ini();
	
	string s,s1;
	cin >> s >> s1;
	ll flag=0;
	if(s.size()+1!=s1.size()){
		flag=1;
	}

	f(i,0,s.size()){
		if(s[i]!=s1[i]){
			flag=1;
		}
	}

	if(flag==1){
		cout << "No";nl;
	}else{
		cout <<"Yes";nl;
	}
}

Measured memory_bytes: 3596
arr = Array.new(4){Array.new(13)}

for i in 0..3
for j in 0..12
 arr[i][j] = 0
end
end

n = gets.to_i

for i in 1..n
suit, r =  gets.split
rank = r.to_i

if suit == "S"
 arr[0][rank-1] = nil
elsif suit == "H"
 arr[1][rank-1] = nil
elsif suit == "C"
 arr[2][rank-1] = nil
else suit == "D"
 arr[3][rank-1] = nil
end
end

su = ["S", "H", "C", "D"]

for i in 0..3
 for j in 1..13
if arr[i][j-1] == 0
 puts su[i] + " " + j.to_s
end
end
end

 




Measured memory_bytes: 6868
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define CVector CPoint
#define INF 0x3f3f3f3f
#define MAXN 1e5
const LL mod=1e9+7;
const double PI=acos(-1.0);
const double EPS=1e-10;

inline int readint(){
  int sum=0;char c=getchar();bool f=0;
  while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}
  while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}
  if(f) return -sum;
  return sum;
}

inline LL readLL(){
  LL sum=0;char c=getchar();bool f=0;
  while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}
  while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}
  if(f) return -sum;
  return sum;
}
struct Edge{
    int s,e,w;
    Edge(int ss,int ee,int ww):s(ss),e(ee),w(ww){}
    Edge(){}
    bool operator <(const Edge & e)const{
        return w<e.w;
    }
};
vector<Edge> edges;
vector<int> parent;
int GetRoot(int a){
    if(parent[a]!=a){
        parent[a]=GetRoot(parent[a]);
    }
    return parent[a];
}

void Merge(int a,int b){
    int p=GetRoot(a);
    int q=GetRoot(b);
    if(p==q){
        return;
    }
    parent[q]=p;
}

struct node{
    int x,y,i;
}s[100005];
bool cmp1(const node &a,const node &b){
    if(a.x==b.x) return a.y<b.y;
    return a.x<b.x;
}
bool cmp2(const node &a,const node &b){
    if(a.y==b.y) return a.x<b.x;
    return a.y<b.y;
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>s[i].x>>s[i].y,s[i].i=i;
    sort(s+1,s+n+1,cmp1);
    for(int i=1;i<n;i++){
        edges.push_back(Edge(s[i].i,s[i+1].i,s[i+1].x-s[i].x));
        edges.push_back(Edge(s[i+1].i,s[i].i,s[i+1].x-s[i].x));
    }
    sort(s+1,s+n+1,cmp2);
    for(int i=1;i<n;i++){
        edges.push_back(Edge(s[i].i,s[i+1].i,s[i+1].y-s[i].y));
        edges.push_back(Edge(s[i+1].i,s[i].i,s[i+1].y-s[i].y));
    }
    for(int i=0;i<=n;i++){
        parent.push_back(i);
    }
    sort(edges.begin(),edges.end());
    int nDone=0;
    int totalsum=0;
    for(int i=0;i<edges.size();i++){
        if(GetRoot(edges[i].s)!=GetRoot(edges[i].e)){
            Merge(edges[i].s,edges[i].e);
            nDone++;
            totalsum+=edges[i].w;
        }
        if(nDone==n-1) break;
    }
    cout<<totalsum<<endl;
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


Measured memory_bytes: 9584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <forward_list>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() { return numeric_limits<long long>::min(); }
ll mal() { return numeric_limits<long long>::max(); }

#define R3(i, a, b) for (long long i = (a); i < (b); ++i)
#define R2(i, b) for (long long i = 0; i < (b); ++i)
#define R1(b) for (long long i = 0; i < (b); ++i)
#define RR(i, a, b) for (long long i = a; i > b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

// build: ctrl + f9

// run: shift + f10
// sanitize: shift + f11
// debug: shift + f9

void A() {
    string S;
    string T;
    cin >> S >> T;

    if(T.substr(0, S.size()) == S) {
        cout << "Yes" << endl;
        return;
    }

    cout << "No" << endl;
}

void B() {
    ll A, B, C, K;

    cin >> A >> B >> C >> K;

    ll tot = 0;
    R1(K) {
        if(i < A) {
            tot += 1;
        }
        else if(i >= (A+B)) {
            tot -=1;
        }
    }

    cout << tot << endl;
}

void C() {
}

void D() {
}

void E() {
}

int main()
{
    B();
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++) 
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++) 
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod = 1000000007;
//const ll INF = mod * mod;
//const double pi = 3.14159265358979;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    int counter = 0;
    rep(i,n) {
        if(a[i] % 2 == 1) counter++;
    }
    if(counter % 2 == 0) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 640
import itertools
 
N = int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
 
for v_idx,v in enumerate(itertools.permutations(range(1,N+1))):
    if v==P:
        a=v_idx
    if v==Q:
        b=v_idx
        
print(abs(a-b))

Measured memory_bytes: 73368
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let w = get_string_input().to_lowercase();
    let mut count = 0usize;
    loop {
        let inputs: Vec<String> = get_vec_input();
        if inputs[0] == "END_OF_TEXT" {
            break;
        }
        for input in inputs {
            let input = input.to_lowercase();
            if input == w {
                count += 1;
            }
        }
    }
    println!("{}", count)
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.trim().to_string()
}



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

long long int GCD(long long int a, long long int b)
{
    long long int tmp = a;
    if (a < b)
        return GCD(b, a);

    while (a % b != 0)
    {
        tmp = a % b;
        a = b;
        b = tmp;
    }
    return b;
}

int main(void)
{
    long long int a, b, gcd, ans = 1;

    cin >> a >> b;
    gcd = GCD(a, b);
    //cout << gcd << endl;

    if (gcd != 1)
    {
        for (long long int i = 2; i * i <= gcd; i++)
        {
            if (gcd % i == 0)
            {

                //cout << gcd << " " << i << endl;
                while (gcd % i == 0)
                    gcd /= i;
                ans++;
            }
        }
    }
    //cout << gcd << endl;
    if (gcd != 1)
        ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

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

def main():
    n = int(read())
    k = (n - 1) // 2
    ab = [[int(i) for i in read().split()] for _ in range(n)]
    a = sorted(a for a, _ in ab)
    b = sorted(b for _, b in ab)
    if n % 2:
        print(b[-1 - k] - a[k] + 1)
    else:
        i = a[k] + a[k + 1]
        j = b[-1 - k - 1] + b[-1 - k]
        print(j - i + 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 45964
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*
5の数
2の数
mapでいれとく
{2,5,小数の数｝

7.5=0,3,1
2.4=3,0,1
3-2=1>0だからOK
全部9桁として
9+4=13桁として扱う
2と5が18桁あればOK

10.000
20.000

10*10の組み合わせもとっちゃう。
2
200000*400はぎりぎりせーふ。50msくらい。
200000*1になりそう
*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll N; cin>>N;
  vector<vector<ll>> DP(20, vector<ll>(20,0));
  vector<pair<ll,ll>> Z(N,{0,0});
  rep(i,N){
    string S; cin>>S;
    ll n=0, j=0, d=100;
    while (S[j] && d-->0){
      if (S[j] == '.'){
        d=9;
        j++;
        continue;
      }
      n = n * 10 + (S[j++] - '0');
    }
    
    d = min(d, 9LL);
    ll two=d, five=d;
    while (n%2==0){
      two++;
      n/=2;
    }
    while (n%5==0){
      five++;
      n/=5;
    }
    two = min(two,18LL);
    five = min(five,18LL);
    DP[two][five]++;
    Z[i] = {two,five};
  }
//DPつくる
  for(ll j=18; j>=0; j--) for(ll k=18; k>=0; k--)
    DP[j][k] += DP[j][k+1];
  for(ll j=18; j>=0; j--) for(ll k=18; k>=0; k--)
    DP[k][j] += DP[k+1][j];

  ll ans=0;
  rep(i, N){
    ll t=Z[i].first;
    ll f=Z[i].second;
    ans += DP[18-t][18-f];
    if (t>=9 && f>=9)
      ans--;
  }
  ans /= 2;
  cout<<ans<<endl;
}


Measured memory_bytes: 6248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    string ans = (A[A.size() - 1] == B[0] and B[B.size() - 1] == C[0]) ? "YES" : "NO";
    OUT(ans);
}

Measured memory_bytes: 256
// sumitrust2019_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int m1,m2,d1,d2;
  cin>>m1>>d1>>m2>>d2;
  if(m1==m2) {
    cout<<0<<endl;
  } else {
    cout<<1<<endl;
  }
  return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    int s = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        s += A[i];
    }
    int tmp = 0;
    for (int i = 1; i < N; i+=2) tmp += 2*A[i];
    int x = s - tmp;
    cout << x << " ";
    for (int i = 1; i <= N-1; i++) {
        x = 2 * A[i-1] - x;
        cout << x << " ";
    }
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
 long n,k; cin>>n>>k;
 map<long,long> mp;
 for(int i=0;i<n;i++){
  long a,b;cin>>a>>b;
  mp[a] += b;
}
long count = 0;
for(auto a : mp){
    count += a.second;
 if(count >= k){
  cout<<a.first<<endl;break;
}
}
 return 0;
}

Measured memory_bytes: 4224