akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
# template


def solve():
    ofs = 1600
    h, w = map(int, readline().split())
    A = [list(map(int, readline().split())) for i in range(h)]
    B = [list(map(int, readline().split())) for i in range(h)]
    dp = [0 for _ in range(w+1)]
    x = abs(A[0][0]-B[0][0])
    dp[0] = 1 << ofs

    for i in range(h):
        for j in range(w):
            x = abs(A[i][j]-B[i][j])
            t = dp[j] | dp[j-1]
            dp[j] = (t << x) | (t >> x)

    b = list(map(lambda s: s == '1', list(bin(dp[w-1])[-ofs-1:-ofs+100])))
    for i, s in enumerate(b):
        if(s):
            print(i)
            return


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3316
n = gets.to_i
s = gets.chomp
east_sum = Array.new(n, 0)
prev = 0
for i in 0...n do
  east_sum[i] = prev + (s[i] == "E" ? 1 : 0)
  prev = east_sum[i]
end
east_sum.unshift(0)
min_count = n
for i in 1..n do
  left_count = (i - 1) - east_sum[i - 1]
  right_count = east_sum[n] - east_sum[i]
  min_count = [min_count, left_count + right_count].min
end
puts min_count


Measured memory_bytes: 18472
#include <stdio.h>
int main(void){
    int i=0,x,y;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0) break;
        if(x<y){
            printf("%d %d\n",x,y);
        }
        else{
            printf("%d %d\n",y,x);
        }
    }
    return 0;
}


Measured memory_bytes: 2592
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main() {
	string S;
	cin >> S;
	int sum = 0;
	int num;
	for (int i = 0; i < (1 << (S.size() - 1)); i++) {
		num = S[0] - '0';
		for (int j = 0; j < S.size() - 1; j++) {	
			if ((i >> j) & 1) {
				sum += num;
				num = S[j + 1] - '0';
			}
			else num = num * 10 + (S[j + 1] - '0');
		}
		sum += num;
	}
	cout << sum;
}

Measured memory_bytes: 256
from collections import defaultdict

n=int(input())
a= list(map(int, input().split()))
q=int(input())
b= [list(map(int, input().split())) for i in range(q)]
d=defaultdict(int)
ans=sum(a)

for i in a:
    d[i]+=1

for i,j in b:
    ans+=d[i]*(j-i)
    print(ans)
    d[j]+=d[i]
    d[i]=0

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

int main() {
  
  int N, K, sum;
  cin >> N >> K;
  sum = 1;
  
  for (int i = 0; i < N; i++) {
      if (sum <= K) {
          sum *= 2;
      }
      else {
          sum += K;
      }
  }
  
  cout << sum << endl;
  
}


Measured memory_bytes: 256
# Import
from collections import deque
import math

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
class PrimeNumber:
    def __init__(self, N):
        self.N = N
        self.ok, self.F, self.P = self.compute(N)

    def compute(self, N):
        isP, F, P = [True] * (N + 1), [-1] * (N + 1), []
        for i in range(2, N+1):
            if isP[i]:
                F[i] = i
                P.append(i)
                for j in range(2*i, N+1, i):
                    isP[j] = False
                    F[j] = i
        return isP, F, P

    def factorization(self, x):
        ret, MAX_P = [], int(math.sqrt(x))
        for p in self.P:
            if p > MAX_P: break
            cnt = 0
            while x % p == 0:
                x /= p
                cnt += 1
            ret.append((x, cnt))
        if x > 1: ret.append((x, 1))
        return ret

N = read_int()

pn = PrimeNumber(1000006)
ans = 0
for p, cnt in pn.factorization(N):
    dec = 1
    while cnt >= dec:
        cnt -= dec
        dec += 1
        ans += 1
print(ans)

Measured memory_bytes: 90256
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# from time import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    last = []
    for i in range(n):
        d1,d2 = readInt()
        if d1==d2:
            last.append(1)
        else:
            last.append(0)
    ans = False
    for i in range(n-2):
        if last[i]==1 and last[i+1]==1 and last[i+2]==1:
            ans = True
    if ans:
        print("Yes")
    else:
        print("No")
    return

if __name__=='__main__':
    main()


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i<n; i++) {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int diff=0;
    for (int i=0; i<n-1; i+=2) {
        diff += (v.at(i) - v.at(i+1));
    }
    if (n%2 != 0) {
        diff += v.at(n-1);
    }
    cout << diff << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let n: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let p: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let ans = (1..(n - 1))
        .filter(|&i| p[i - 1] < p[i] && p[i] < p[i + 1] || p[i - 1] > p[i] && p[i] > p[i + 1])
        .count();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h, n;
    cin >> h >> n;
    int tai = h;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        tai -= a[i];
    }
    if(tai > 0){
        cout << "No";
    }else{
        cout << "Yes";
    }
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, T = MAP()
A = LIST()

min_ = INF
B = []
for i in A:
	B.append(i-min_)
	if i < min_:
		min_ = i

print(B.count(max(B)))

Measured memory_bytes: 21724
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> F[10];
    rep (n, N) {
        rep (d, 10) {
            ll f;
            cin >> f;
            if (f) {
                F[d].pb(n);
            }
        }
    }

    vector<ll> P[100];
    rep (n, N) {
        rep (d, 11) {
            ll p;
            cin >> p;
            P[n].pb(p);
        }
    }

    ll ans = -9999999999999999;
    for (ll i = 1; i < (1 << 10); ++i) {
        ll c[100] = {};
        rep (j, 10) {
            if (i & (1 << j)) {
                for (ll k : F[j]) {
                    ++c[k];
                }
            }
        }
        ll a = 0;
        rep (j, N) {
            a += P[j][c[j]];
        }
        ans = max(ans, a);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(list)))

	result := 0
	for i := k; i < n; i++ {
		result += list[i]
	}

	fmt.Println(result)
}


Measured memory_bytes: 6960
import java.util.*;

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

		double a = sc.nextInt(), b = sc.nextInt();
		
		double tsubo = a * b / 3.305785;
		
		System.out.println(String.format("%6f", tsubo));
	}
}

Measured memory_bytes: 26404
#include <iostream>
using namespace std;
int main() {
    int W, H, x, y, r ;
    cin >> W >> H >> x >> y >> r;
    if (((x + r) <= W) && (0 <= (x - r)) && ((y + r) <= H) && (0 <=(y - r))) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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


int main() {
	
	int N, d, cnt=0;
	cin >> N >> d;
	vector<vector<int>> x(N,vector<int>(d));
	for(auto &i:x){
		for(auto &j:i) cin >> j;
	}
	for(int i=0; i<N; i++){
		for(int j=0; j<i; j++){
			int dist = 0;
			for(int l=0; l<d; l++){
				dist += (x.at(i).at(l)-x.at(j).at(l))*(x.at(i).at(l)-x.at(j).at(l));
			}
			for(int k=0; k<200; k++){
				if(dist==k*k){
					cnt++;
					break;
				}
			}
		}
	}
	cout << cnt << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import sys

def merge_delay_pattern(k, half1, half2):
    len1 = len(half1)
    len2 = len(half2)

    start, delay1_next = half1[0]
    start2 = half2[0][0]
    time1 = start - start2
    mid_start = start + time1 + delay1_next
    offset2_num_period = (mid_start - start2) // k
    offset2_phase = mid_start - offset2_num_period * k
    for head2 in range(len2):
        if half2[head2][0] >= offset2_phase:
            head2 -= 1
            break
    head2 += offset2_num_period * len2
    head1 = 0

    ret = []
    prev = ()
    half1.append((start + k, None))

    pos1_next = start
    pos2_next, delay2_next = half2[head2 % len2]
    pos2_next += (head2 // len2) * k
    mid = pos2_next
    while True:
        if mid <= pos2_next:
            if head1 == len1: break
            head1 += 1
            pos1, delay1 = pos1_next, delay1_next
            pos1_next, delay1_next = half1[head1]
        if pos2_next <= mid:
            head2 += 1
            pos2, delay2 = pos2_next, delay2_next
            pos2_next, delay2_next = half2[head2 % len2]
            pos2_next += (head2 // len2) * k
        if delay1 == 0:
            mid = pos1_next + time1
            if delay2 == 0:
                if prev is not None:
                    ret.append((start, 0))
                    prev = None
            else:
                delay = pos2 + delay2 - time1 - start
                if prev != start + delay:
                    ret.append((start, delay))
                    prev = start + delay
            if pos2_next <= mid:
                start = pos2_next - time1
            else:
                start = pos1_next
        else:
            mid = pos1 + time1 + delay1
            if mid <= pos2_next:
                if delay2 == 0:
                    delay = delay1
                else:
                    delay = pos2 + delay2 - time1 - start
                if prev != start + delay:
                    ret.append((start, delay))
                    prev = start + delay
                start = pos1_next
    return ret

def get_delay_pattern(k, data, first, last):
    if last - first == 1: return data[first]
    middle = (first + last) // 2
    half1 = get_delay_pattern(k, data, first, middle)
    half2 = get_delay_pattern(k, data, middle, last)
    return merge_delay_pattern(k, half1, half2)

def solve():
    data = []
    int_list = [int(s) for s in sys.stdin.read().split()]

    n = int_list[0]
    k = int_list[1]

    position = 0
    for i in range(2, (n + 1) * 2, 2):
        a = int_list[i]
        b = int_list[i + 1]
        if b == 1:
            a2 = a * 2
            if k < a2: return -1
            data.append([(-position, 0), (-position + k - a2, a2)])
        position += a

    if not data: return position * 2
    delay_pattern = get_delay_pattern(k, data, 0, len(data))
    pat_adj_pairs = zip(delay_pattern, delay_pattern[1:] + [(delay_pattern[0][0] + k, None)])
    delay_list = (pos + delay - next_pos for (pos, delay), (next_pos, _) in pat_adj_pairs if delay)
    return position * 2 + min(delay_list, default=0)


print(solve())


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

const int INF = 1000000007;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pr;

char field[50][54];
int w, h;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int group[50][50];

void dfs(int x, int y, int c){
    if((group[x][y] & c) > 0) return;
    group[x][y] |= c;
    for(int i = 0; i < 4; i++){
        int nx = x + dx[i], ny = y + dy[i];
        if(0 <= nx && nx < h && 0 <= ny && ny < w &&
                field[nx][ny] == '.'){
            dfs(nx, ny, c);
        }
    }
}

int main(){
    while(true){
        scanf("%d%d", &w, &h);
        if(w == 0 && h == 0) break;
        for(int i = 0; i < h; i++){
            scanf(" %s", field[i]);
        }
        for(int i = 0; i < h; i++){
            fill(group[i], group[i] + w, 0);
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(field[i][j] == 'B'){
                    dfs(i, j, 1);
                }else if(field[i][j] == 'W'){
                    dfs(i, j, 2);
                }
            }
        }
        int black = 0, white = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(field[i][j] != '.') continue;
                if(group[i][j] == 1){
                    ++black;
                }
                if(group[i][j] == 2){
                    ++white;
                }
            }
        }
        printf("%d %d\n", black, white);
    }
    return 0;
}

Measured memory_bytes: 1256
// luogu-judger-enable-o2
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

template <typename QvQ> inline QvQ Min(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max(QvQ a,QvQ b){if(a>b) return a;return b;}

#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f

#define ll long long
#define rei register int
#define inv inline void

#define bl putchar(' ')
#define ed putchar('\n')

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

template <typename QvQ>inv read(QvQ &x)
{
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+48);
}
using namespace std;
int n; 
int main()
{
	read(n);
	write(n*n*n);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],gcd_now;
int gcd(int a,int b) {
	return b==0?a:gcd(b,a%b);
}
int main() {
	cin>>n>>a[0];
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++) a[i]=abs(a[i+1]-a[i]);
	gcd_now=a[0];
	for(int i=1;i<n;i++) 
		gcd_now=gcd(gcd_now,a[i]);
	cout<<gcd_now;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];
    sort(ALL(A), greater<int>());

    int edge[2] = {}, cnt = 0, i = 0;
    while (cnt < 2 && i < N - 1) {
        if (A[i] == A[i + 1]) {
            edge[cnt++] = A[i];
            i++;
        }
        i++;
    }

    if (cnt == 2) {
        cout << (ll)edge[0] * edge[1] << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    int n, m;
    cin>>n>>m;
    vector<int> adj[n];
    int a[n];
    f(i, n) cin>>a[i];
    f(i, m) {
        int u, v;
        cin>>u>>v;
        u--, v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    int ans = 0;
    f(i, n) {
        bool ok = true;
        for(int u: adj[i]) {
            if(a[i] <= a[u]) {
                ok = false;
                break;
            }
        }
        if(ok) ans++;
    }
    cout<<ans;
} 


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int test = 1; test <= t; test++) {
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 10260
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
using namespace std;

main() {
    int A[3];
    rep(i,3) cin >> A[i];
    sort(A,A+3);
    cout << A[2]*10+A[1]+A[0] << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n;
  	cin >> n;
  	vi a(n);
  	vi cnt(100100, 0);
  	rep(i,n) {
      	cin >> a[i];
    	cnt[a[i]]++;
    }
  	
  	int mx = 0;
  	rep3(i,1,100009){
		mx = max(mx, cnt[i-1]+cnt[i]+cnt[i+1]);      	
    }
  	
	cout << mx << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int x=stoi(s+t);
    rep(i,x){
        if(i*i==x){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    s = input().rstrip()
    t = input().rstrip()
    res = 0
    for i in range(n):
        if s[n-(i+1):] == t[:i+1]:
            res = i + 1
    print(n * 2 - res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
'use strict';
console.log(function(args){
  const N = parseInt(args.trim(),10);
  let min = N.toString().length;
  for ( let A = 1; A*A <= N; A++ ) {
    if ( N % A !== 0 ) continue;
    const B = N / A;
    min = Math.min( min, B.toString().length );
  }
  return min.toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 13004
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <utility>
#include <climits>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<long long > r(n);

    for(int i=0;i<n;i++){
        cin >> r[i];
    }
    
    long long mi = INT_MAX;
    long long ans = -INT_MAX;
    for(int i=0;i<n;i++){
        if(i!=0)
            ans = max(ans,r[i]-mi);
        mi = min(r[i],mi);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,RIGHT,C;
cin >> N;
vector<int>B(N);
RIGHT=0;
C=0;
 for(int i=0;i<N;i++){
     cin >> B.at(i);}
  for(int j=0;j<N;j++){
    RIGHT = B.at(RIGHT)-1;
    C++;
    if(RIGHT == 1){
        cout << C <<endl;
        break;}
  }
  if(RIGHT !=1){
      cout << -1 <<endl;}
}

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

#define int long long

signed main() {
    string s;
    cin >> s;

    if(s.find("RRR") != string::npos) {cout << 3 << endl; return 0;}
    else if(s.find("RR") != string::npos) {cout << 2 << endl; return 0;}
    else if(s.find("R") != string::npos) {cout << 1 << endl; return 0;}
    else {cout << 0 << endl; return 0;}
}

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

int main() {
  char a, b, c;
  cin >> a >> b >> c;
  
  if ( a == '7' || b == '7' || c == '7' ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3072
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

void Main()
{
	int N, K;
	std::cin >> N >> K;
	double sum = 0;
	double base = 1.0 / N;
	for (int i : boost::irange(1, N + 1))
	{
		int k = 0;
		while (i < K)
		{
			i *= 2;
			++k;
		}
		sum += base * std::pow(0.5, k);
	}
	std::cout << sum << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll a[100010];
int main(){
	int n,l;
	scanf("%d%d",&n,&l);
	rep(i,0,n)scanf("%d",a+i);
	int index=0;
	rep(i,1,n)if(a[i-1]+a[i]>=l)index=i;
	if(index){
		puts("Possible");
		rep(i,1,index)printf("%d\n",i);
		for(int i=n-1;i>index;i--)printf("%d\n",i);
		printf("%d\n",index);
	}else{
		puts("Impossible");
	}
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)

int main(){
  int h,n,x;
  int acum=0;
  cin>>h>>n;
  REP(i,0,n){
    cin>>x;
    acum+=x;
  }
  if(h>acum)
    cout<<"No\n";
  else
    cout<<"Yes\n";


  return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x1, x2, x3, x4, y1, y2, y3 ,y4;
    cin >> x1 >> y1 >> x2 >> y2;
    
    if (x2 > x1 && y2 >= y1)
    {
        int dx = x2 - x1;
        int dy = y2 - y1;
        x3 = x2 - dy;
        y3 = y2 + dx;
        x4 = x3 - dx;
        y4 = y3 - dy;
        
    }
    else if (x1 >= x2 && y2 >= y1)
    {
        int dx = x1 - x2;
        int dy = y2 - y1;
        x3 = x2 - dy;
        y3 = y2 - dx;
        x4 = x3 + dx;
        y4 = y3 - dy;
    }
    else if (x1 > x2 && y2 <= y1)
    {
        int dx = x1 - x2;
        int dy = y1 - y2;
        x3 = x2 + dy;
        y3 = y2 - dx;
        x4 = x3 + dx;
        y4 = y3 + dy;
    }
    else
    {
        int dx = x2 - x1;
        int dy = y1 - y2;
        x3 = x2 + dy;
        y3 = y2 + dx;
        x4 = x3 - dx;
        y4 = y3 + dy;
    }
    
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<float> v(N);
  for(int i = 0; i < N; i++){
    cin>>v.at(i);
  }
  
  sort(v.begin(),v.end());

  float Output = v.at(0);
  for(int i = 1; i < N; i++){
    Output += v.at(i);
    Output /= 2;
  }
    cout<<Output<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define INF 10101010

int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> x(M);
    rep(i,M)cin >> x[i];
    

    ssort(x);
    vector<int> dist(M-1);
    rep(i,M-1){
        dist[i]=x[i+1]-x[i];
    }
    sort(dist.begin(),dist.end());
    int ans=x[M-1]-x[0];
    if(N==1){
        cout << x[M-1]-x[0] << endl;
    }else if(N>=M){
        cout << 0 << endl;
    }
    else{
        rep(i,N-1){
            ans-=dist[M-2-i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
using ull = unsigned long long;
#define rep(i,n) for(ull i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ull> a(n);rep(i,n){cin>>a[i];}
#define in(a) ull a;cin>>a;
int main()
{
	in(n);
	in(d);
	cout << (ull)ceil((double)n / (2 * d + 1));
}


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

using ll=long long;

int solve(){
    int n;
    ll pi,pj;
    cin>>n>>pi>>pj;
    pi--,pj--;
    if(n==0) return 1;
    swap(pi,pj);
    vector<int> isUp(n);
    ll tar=pj;
    for(int i=n-1;i>=0;i--){
        bool b=(tar<(1LL<<i));
        if(b) tar=(1LL<<i)-tar-1;
        else tar-=(1LL<<i);
        isUp[i]=b;
    }
    string res;
    for(int i=0;i<n;i++){
        ll len=(1LL<<(n-i));
        bool isToLeft=!((pi<len/2)^(isUp[i]));
        if(isToLeft) res+="L";
        else res+="R";
        if(isToLeft && pi<len/2){
            pi=len/2-pi-1;
        }
        else if(!isToLeft && len/2<=pi){
            pi=len/2-(pi-len/2)-1;
        }
        else if(isToLeft && len/2<=pi){
            pi=pi-len/2;
        }
    }
    cout<<res<<endl;
    return 0;
}

int main(){
    while(!solve()) ;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(0); 

    int n; cin >> n; 
    vector<int> a(n); 
    vector<int> b(n);  
    vector<int> c(n); 
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i]; 
    }

    int dp[100010][3] = {0}; 
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i]; 
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i]; 
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i]; 
    }
    
    int elts[] = {dp[n-1][0], dp[n-1][1], dp[n-1][2]}; 
    cout << *max_element(elts, elts+3) << "\n"; 

}

Measured memory_bytes: 2560
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(N, AS):
    num_division = 0
    maxAS = max(AS)
    eratree = [0] * (maxAS + 10)
    for p in range(2, maxAS + 1):
        if eratree[p]:
            continue
        # p is prime
        x = p
        while x <= maxAS:
            if not eratree[x]:
                eratree[x] = p
            x += p

    from collections import defaultdict
    count = defaultdict(int)
    for a in AS:
        factors = []
        while a > 1:
            d = eratree[a]
            factors.append(d)
            a //= d
            num_division += 1
        # debug(": ", factors)
        for f in set(factors):
            count[f] += 1

    # debug(": num_division", num_division)
    if any(x == N for x in count.values()):
        return "not coprime"
    if any(x >= 2 for x in count.values()):
        return "setwise coprime"
    return "pairwise coprime"


def main():
    # parse input
    N = int(input())
    AS = list(map(int, input().split()))
    print(solve(N, AS))


# tests
T1 = """
3
3 4 5
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
pairwise coprime
"""

T2 = """
3
6 10 15
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
setwise coprime
"""

T3 = """
3
6 10 16
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
not coprime
"""

T4 = """
3
100000 100001 100003
"""
TEST_T4 = """
>>> as_input(T4)
>>> main()
pairwise coprime
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 177876
#include<iostream>
#define MAX 101
using namespace std;

int main()
{
  int n,m=0;
  int c[MAX]={};

  while(cin>>n)c[n]++;
  for(int i=0;i<MAX;i++)m=max(m,c[i]);
  for(int i=1;i<MAX;i++)if(m==c[i])cout<<i<<endl;
  
  return 0;
}

Measured memory_bytes: 1160
a=list(map(int,input().split()))
a.sort()
b=0
ans=0
while a[2]-a[1]!=0 or a[1]-a[0]!=0:
  if a[0]>a[1] or a[1]>a[2]:
    a.sort()
  if a[1]==a[2]:
    if (a[1]-a[0])%2==1:
      a[1]+=1
      a[2]+=1
      ans+=1
      #print('ifif')
    else:
      #print('ifelse')
      while a[0]!=a[1]:
        a[0]+=2
        ans+=1
      print(ans)
      exit()
  elif a[1]==a[0]:
    #print('elif')
    print(ans+a[2]-a[1])
    exit()
  else:
    #print('else')
    a[0]+=2
    ans+=1
  #print(a,ans)
print(ans)

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

int main()
{
    int a, b;
    cin >> a >> b;
    int count = 0;

    for (int i = a; i <= b; i++)
    {
        if ((i/10000 == i % 10) & ((i/1000)%10 == (i/10)%10))
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<time.h>
#define eps 1e-8
#define pi 3.14159265358979
#define MP make_pair
#define PH push
#define pb push_back
#define PII pair<int,int>
#define VI vector<int>
#define fi first
#define se second
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define sqr(x) ((x)*(x))
#define CL(a) memset(a,0,sizeof a)
#define fr(i,n) for(int i=1;i<=n;i++)
#define FR(i,S,n) for(int i=S;i<=n;i++)
#define dr(i,n) for(int i=n;i;i--)
#define DR(i,n,S) for(int i=n;i>=S;i--)
#define SZ(x) ((int)(x).size())
#define rd(x) scanf("%d",&x)
#define pr(x) printf("%d",x)
typedef long long ll;
ll expow(ll a,ll b,ll p) {ll v=1; for (; b; b>>=1,a=a*a%p)if (b&1)v=v*a%p; return v;}
ll inv(ll a,ll p) {return expow(a,p-2,p);}
using namespace std;
ll ans;
int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	if (x < y) {
		swap(a, b);
		swap(x, y);
	}
	if (c * 2 >= a + b) {
		cout << a * x + b * y << endl;
		return 0;
	}
	ans = y * 2 * c;
	x -= y;
	y = 0;
	if (c * 2 >= a) {
		cout << ans + a * x;
		return 0;
	}
	cout << ans + x * 2 * c;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int h, w; cin >> h >> w;
    vector<vector<int>> d(10, vector<int>(10));
    rep(i, 10) rep(j, 10) cin >> d[i][j];
    rep(k, 10) rep(i, 10) rep(j, 10)
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int ans = 0;
    rep(i, h) rep(j, w) {
        int x; cin >> x;
        if(x!=-1) ans += d[x][1];
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    ll C;
    cin>>A>>B>>C;
    rep(i,B){
        ll temp = i*A;
        if(temp%B == C){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<ll> &s, ll a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {
    map<string, int> m;
    int n;
    cin >> n;
    rep(i, n) {
        string s;
        cin >> s;
        m[s]++;
    }

    auto e = *max_element(m.begin(), m.end(), [](pair<string, int> p, pair<string, int> q) {
        return p.second < q.second;
    });

    for (auto i : m) {
        if (i.second == e.second) {
            cout << i.first << endl;
        }
    }


}



Measured memory_bytes: 26880
Option Strict On
Module Module1

    Sub Main()
        Dim z() As String = Split(Console.ReadLine())
        Dim N As Integer = Convert.ToInt32(z(0))
        Dim Q As Integer = Convert.ToInt32(z(1))
        Dim S As String = Console.ReadLine()
        Dim l(Q - 1) As Integer
        Dim r(Q - 1) As Integer
        For i As Integer = 0 To Q - 1
            z = Split(Console.ReadLine())
            l(i) = Convert.ToInt32(z(0))
            r(i) = Convert.ToInt32(z(1))
        Next

        '文字列よりACを拾い出し、各文字数目で配列化　ACACTACG　は01122233　
        Dim Ahurag As Integer = 0
        Dim counter As Integer = 0
        Dim at(N - 1) As Integer
        For i As Integer = 0 To N - 1
            If Mid(S, i + 1, 1) = "A" Then
                Ahurag = 1
            ElseIf Ahurag = 1 AndAlso Mid(S, i + 1, 1) = "C" Then
                Ahurag = 0
                counter += 1

            Else
                Ahurag = 0
            End If
            at(i) += counter
        Next

        '出題の最初の文字数目と終わりの文字数目を上記配列に当てはめ差し引きしてACをカウント
        Dim answer As Integer = 0
        For i As Integer = 0 To Q - 1
            answer = at(r(i) - 1) - at(l(i) - 1)
            Console.WriteLine(answer)
        Next
        Console.ReadLine()
    End Sub

End Module

Measured memory_bytes: 30520
from itertools import combinations

H,W,K=map(int,input().split())
dp=[[0 for i in range(W)] for j in range(H+1)]

mod=10**9+7

if W==1:
  if K==1:print(1)
  else:print(0)
  exit()

memo={}
def is_separate(c):
  for i in range(len(c)-1):
    if c[i+1]-c[i] == 1:
      return False
  return True

def n_select(occupied):
  if memo.get(occupied):
    return memo[occupied]
  else:
    count=1
    if len(occupied)==1:
      for r in range(1,W//2+1):
        for c in combinations(range(W-1),r=r):
          if occupied[0]-1 not in c and occupied[0] not in c:
            if is_separate(c):
              count += 1
    if len(occupied)==2:
      for r in range(1,W//2+1):
        for c in combinations(range(W-1),r=r):
          if occupied[0]-1 not in c and occupied[0] not in c and occupied[0]+1 not in c:
            if is_separate(c):count += 1
  memo[occupied] = count
  return count

dp[0][0]=1
for i in range(1,H+1):
  for j in range(W):
    if j==0:
      dp[i][j] = dp[i-1][j]*n_select((j,))+dp[i-1][j+1]*n_select((j,j+1))
    elif j==W-1:
      dp[i][j] = dp[i-1][j]*n_select((j,))+dp[i-1][j-1]*n_select((j-1,j))
    else:
      dp[i][j] = dp[i-1][j]*n_select((j,))+dp[i-1][j+1]*n_select((j,j+1))+dp[i-1][j-1]*n_select((j-1,j))

print(dp[-1][K-1] % mod)

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

int main(){
  
 string O,E;
 cin>>O>>E;
 
 int o=O.size(),e=E.size();
 if(o==e){
   for(int i=0;i<o;i++){
     cout<<O[i]<<E[i];
   }
 }
 else{
   cout<<O[0];
   for(int i=0;i<e;i++){
     cout<<E[i]<<O[i+1];
   }
 }
 
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define F first
#define S second
int const M=2e5+10,M2=1e6+10,M3=5e3+10,inf=1e9+10,mod=1e9+7;
int a[M];
main()
{
	string x;
	cin>>x;
	if(x[0]==x[1] && x[1]==x[2])
		return cout<<"Yes",0;
	if(x[1]==x[2] && x[2]==x[3])
		return cout<<"Yes",0;
	cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define msit1(a) map<string,int>::iterator a
#define miit(a) map<int,int>::iterator a
#define msit2(a) map<int,string>::iterator a
#define IT iterator
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	int con=0,a,b,n;
	bool ok=0;
	cin>>n;
	REP(i,0,n){
		cin>>a>>b;
		if(a==b)con++;
		else con=0;
		if(con==3)
		ok=1;
	}
	cout<<(ok? "Yes":"No");
    return 0;
}


Measured memory_bytes: 3652
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let n: usize = parse!(it);
    let a: Vec<Vec<usize>> = (0..n).map(|_| parse!(it, n)).collect();
    let mut used = vec![vec![true; n]; n];
    for i in 0..n {
        for j in (i + 1)..n {
            for k in (j + 1)..n {
                if a[i][j] > a[k][i] + a[j][k]
                    || a[j][k] > a[k][i] + a[i][j]
                    || a[k][i] > a[i][j] + a[j][k]
                {
                    println!("{}", -1);
                    return;
                }
                if a[i][j] == a[k][i] + a[j][k] {
                    used[i][j] = false
                }
                if a[j][k] == a[k][i] + a[i][j] {
                    used[j][k] = false
                }
                if a[i][k] == a[i][j] + a[j][k] {
                    used[i][k] = false
                }
            }
        }
    }
    let mut ret = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            ret += (used[i][j] as usize) * a[i][j]
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 6396
N=io.read("n")
T=io.read("n")
c={}
t={}
for i=1,N do 
  c[i]=io.read("n")
  t[i]=io.read("n")
end
s="TLE"
for i=1,N do 
  if t[i]<=T then 
    s=math.max(table.unpack(c))
    break
  end
end
for i=1,N do 
  if t[i]<=T and s>c[i] then
    s=c[i]
  end
end
print(s)

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

bool f[100010];
int c[100010];

int main() {
  

  FOR(i,2,100000){
    if(!f[i]) for(int j=i+i; j<=100000; j+=i) f[j]=true;
  }
  for(int i=3; i<=100000; i+=2){
    if(!f[i] && !f[(i+1)/2]) ++c[i];
  }
  FOR(i,3,100000){
    c[i] += c[i-1];
  }

  int n,l,r;
  cin >> n;

  FOR(i,0,n-1){
    cin >> l >> r;
    cout << c[r] - c[l-1] << endl;
  }
}



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

using namespace std;

ifstream fin ("margele.in");
ofstream fout ("margele.out");

int n, k, ans, v[52], maxx;
int main()
{
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  for (int a = 0; a <= min(n, k); a++) {
    for (int b = 0; b + a  <= min(n, k); b++) {
      int ans = 0;
      priority_queue<int>pq;
      for (int i = 1; i <= a; i++) {
        ans += v[i];
        pq.push(-v[i]);
      }
      for (int j = 1; j <= b; j++) {
        ans += v[n - j + 1];
        pq.push(-v[n - j + 1]);
      }
      int cnt = k - a - b;
      while (cnt > 0 && !pq.empty() && pq.top() > 0) {
        ans += pq.top();
        pq.pop();
        cnt--;
      }
      maxx = max(maxx, ans);
    }
  }
  cout << maxx;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<pair<int,int>>> v(n+1);
    vector<pair<int,int>> ans(m);
    for(int i=0;i<m;i++)
    {
        int p,y;
        cin>>p>>y;
        v[p].pb(make_pair(y,i));
    }
    for(int i=0;i<=n;i++)
    {
        sort(v[i].begin(),v[i].end());
        for(int j=0;j<v[i].size();j++)
        {
            ans[v[i][j].second]=make_pair(i,j+1);
        }
    }
    for(int i=0;i<m;i++)
    printf("%06d%06d\n",ans[i].first,ans[i].second);
    return 0;
}

Measured memory_bytes: 7680