akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c - (a - b), 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

int W, H, N;
vector<int> X1, X2, Y1, Y2;

int main() {
	cin >> N >> H >> W;
	cout << (N - H + 1)*(N - W + 1) << endl;

	return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  ll k,x;
  cin>>k>>x;
  for(int i=x-k+1;i<=x+k-1;i++){
    printf("%d\n",i);
           }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

  int N,a[100]={0},ans=0;

  cin >> N;

  for(int i = 0; i < N; i++){
    cin >> a[i];
  }

  sort(a,a+N);
  reverse(a,a+N);

  for(int i = 0; i < N; i++){
    if(i % 2 == 1){
      ans -= a[i];
    }
    else{
      ans += a[i];
    }
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int path[10];

signed main(){
	for(int i = 0; i < 3; i++){
		int a, b;
		scanf("%ld %ld", &a, &b);
		path[a]++;
		path[b]++;
	}
	for(int i = 1; i <= 4; i++){
		if(path[i] == 3){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<random>
using namespace std;
int D;
int c[26],s[365][26];
int t[365],now;
int anst[365],ans;
void calc()
{
	int lst[26];
	for(int i=0;i<26;i++)lst[i]=-1;
	now=0;
	for(int i=0;i<D;i++)
	{
		now+=s[i][t[i]];
		lst[t[i]]=i;
		for(int j=0;j<26;j++)now-=c[j]*(i-lst[j]);
	}
}
int change(int d,int q)
{
	int ret=0;
	ret-=s[d][t[d]];
	ret+=s[d][q];
	{
		int r=d+1;
		while(r<D&&t[r]!=t[d])r++;
		int l=d-1;
		while(l>=0&&t[l]!=t[d])l--;
		ret-=c[t[d]]*(r-d)*(d-l);
	}
	{
		int r=d+1;
		while(r<D&&t[r]!=q)r++;
		int l=d-1;
		while(l>=0&&t[l]!=q)l--;
		ret+=c[q]*(r-d)*(d-l);
	}
	return ret;
}
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>s[i][j];
	mt19937 rng(114514);
	for(int i=0;i<D;i++)
	{
		anst[i]=t[i]=rng()%26;
	}
	calc();
	ans=now;
	for(int tm=0;tm<1000;tm++)
	{
		int d=rng()%D,q=rng()%26;
		now+=change(d,q);
		t[d]=q;
		for(int k=0;k<4000;k++)
		{
			int d1=rng()%(D-1)+1,d2=rng()%d1;
			int pt1=t[d1],pt2=t[d2];
			int diff=0;
			diff+=change(d1,pt2);
			t[d1]=pt2;
			diff+=change(d2,pt1);
			t[d2]=pt1;
			if(diff>=0)
			{
				now+=diff;
			}
			else
			{
				t[d1]=pt1;
				t[d2]=pt2;
			}
		}
		if(ans<=now)
		{
			ans=now;
			for(int i=0;i<D;i++)anst[i]=t[i];
		}
		else
		{
			now=ans;
			for(int i=0;i<D;i++)t[i]=anst[i];
		}
	}
	for(int i=0;i<D;i++)cout<<anst[i]+1<<endl;
	cerr<<ans<<endl;
}

Measured memory_bytes: 3680
import itertools
n, m = list(map(int, input().split()))
sss = []
for i in range(m):
  k, *s = list(map(int, input().split()))
  sss.append(s)
ppp = list(map(int, input().split()))
count = 0
for l in itertools.product([0,1], repeat=n):
  l = list(l)
  flag = True
  for i in range(m):
    curr = 0
    for s in sss[i]:
      if l[s-1] == 1:
        curr += 1
    if curr % 2 != ppp[i]:
      flag = False
      break
  if flag == True:
    count += 1

print(count)
      

Measured memory_bytes: 3064
from collections import Counter
n = int(input())
d = Counter(list(map(int, input().split())))
key = list(d.keys())

ans = 0
for k in key:
    if k > d[k]:
        ans += d[k]
    elif k == d[k]:
        pass
    else:
        ans += d[k] - k
print(ans)

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

int main(){
  int n;
  cin >> n;
  double a[n];
  double res = 0;
  for (int i = 0; i < n; i++){
  	cin >> a[i];
  }
  for (int j = 0; j < n; j++){
  	res = res + 1/a[j];
  }
  
  cout << fixed << setprecision(5) << 1/res << endl;
  return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a<c && b>c)cout << "Yes" << endl;
  else if(a>c && b<c)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll N, K;
    cin >> N >> K;

    if (N % K == 0) write(0);
    else write(min(N % K, K - N % K));
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  if(n%2!=0){
    int i=1;
    while(i<=n/2  && s[n/2-i]==s[n/2] && s[n/2+i]==s[n/2]){
      i++;
    }
    cout<<(n-1)/2+i<<endl;
  }
  else{
    if(s[n/2-1]!=s[n/2]) cout<<n/2<<endl;
    else{
      int i=1;
      while(i<=n/2-1&& s[n/2-1-i]==s[n/2-1] && s[n/2+i]==s[n/2]){
        i++;
      }
      cout<<n/2+i<<endl;
    }
  }
}

Measured memory_bytes: 512
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

x=0
k=int(input())

for i in range(1,k+1):
  for j in range(1,k+1):
    for l in range(1,k+1):
      x+=gcd(i,j,l)

print(x)


Measured memory_bytes: 69864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 
    int n;
    cin>>n;
  	string str;
  	cin>>str;
  	if(str.length()<=n)cout<<str;
  	else {
  		for(int i=0;i<n;i++){
  			cout<<str[i];
		}
		cout<<"...";
	}
    return 0;
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int n, ans = 0; cin >> n;
    char c; cin >> c;
    REPI(i, n - 1){
        char x; cin >> x;
        if(c != x) ans++;
        c = x;
    }cout << ans + 1;
}


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

int main(void) {
    int A,B,C,D,E;cin>>A>>B>>C>>D>>E;
    if (A < 0) {
        if (B <= 0) {
            cout << (B - A) * C << endl;
        } else {
            cout << D - A * C + B * E << endl;
        }
    } else {
        cout << (B - A) * E << endl;
    }
    return 0;
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  string s;
  cin >> s;

  REP(i, 3) {
    if (s[i] == s[i + 1]) {
      COUT("Bad");
      return;
    }
  }
  COUT("Good");

}

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

/*

3 2
*/


Measured memory_bytes: 3620
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

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

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n, m = input_list()
  falls = [False]*(n+1)
  for i in range(m):
    falls[int(input())] = True
  
  if n == 1:
    print(1)
    exit(0)

  dp = [0]*(n+1)
  dp[0] = 1
  dp[1] = 0 if falls[1] else 1
  for i in range(2, n+1):
    if falls[i]:
      continue
    dp[i] = dp[i-1] + dp[i-2]
  
  mod = 1000000007
  print(dp[-1]%mod)
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Measured memory_bytes: 482016
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn pow_mod(base: i64, power: i64, modulo: i64) -> i64 {
    let mut base = base;
    let mut power = power;
    let mut ans = 1;
    while power > 0 {
        if power & 1 == 1 {
            ans = ans * base % modulo;
        }
        power >>= 1;
        base = base * base % modulo;
    }
    ans
}

#[allow(dead_code)]
fn inv_mod(a: i64, modulo: i64) -> i64 {
    pow_mod(a, modulo - 2, modulo)
}

const MOD: i64 = 1e+9 as i64 + 7;
const FACT_MAX: usize = 100100;
static mut FACTORIAL: [i64; FACT_MAX + 1] = [0; FACT_MAX + 1];
static mut RFACTORIAL: [i64; FACT_MAX + 1] = [0; FACT_MAX + 1];
fn init_fact() {
    unsafe {
        if FACTORIAL[0] == 0 {
            FACTORIAL[0] = 1;
            for i in 1..FACT_MAX + 1 {
                FACTORIAL[i] = (FACTORIAL[i - 1] * i as i64) % MOD;
            }
            RFACTORIAL[FACT_MAX] = inv_mod(FACTORIAL[FACT_MAX], MOD);
            for i in (0..FACT_MAX).rev() {
                RFACTORIAL[i] = RFACTORIAL[i + 1] * (i as i64 + 1) % MOD;
            }
        }
    }
}
#[allow(dead_code)]
fn fact(n: usize) -> i64 {
    init_fact();
    unsafe { FACTORIAL[n] }
}
#[allow(dead_code, unused_comparisons)]
fn combi(n: usize, m: usize) -> i64 {
    if n < m || m < 0 {
        return 0;
    }
    init_fact();
    unsafe { FACTORIAL[n] * RFACTORIAL[m] % MOD * RFACTORIAL[n - m] % MOD }
}

fn main() {
    let n = read::<usize>();
    let mut w = 0;
    let mut open = vec![-1; n];
    let mut aseq = vec![0; n + 1];
    for i in 0..n + 1 {
        aseq[i] = read::<usize>() - 1;
        if open[aseq[i]] != -1 {
            w = i - open[aseq[i]] as usize + 1;
        } else {
            open[aseq[i]] = i as i32;
        }
    }
    let mut anss = vec![0; n + 1];
    for i in 0..n + 1 {
        anss[i] = (combi(n + 1, i + 1) - combi(n + 1 - w, i) + MOD) % MOD;
    }
    for i in 0..n + 1 {
        println!("{}", anss[i]);
    }
}


Measured memory_bytes: 8828
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

ll n, m, a[1000], mx;

int main() {
  while (scanf("%lld%lld", &n, &m), n) {
    for (ll i = 0; i < n; i++) scanf("%lld", &a[i]);
    mx = -1;
    for (ll i = 0; i < n; i++) for (ll j = i+1; j < n; j++) if (a[i] + a[j] <= m) mx = max(a[i]+a[j], mx);
    if (mx == -1) printf("NONE\n");
    else printf("%lld\n", mx);
  }
}



Measured memory_bytes: 2752
from collections import Counter

U = 10**5+1
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD
    
def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z %= MOD
    z *= fact_inv[n-k]
    z %= MOD
    return z
  
n = int(input())
A = list(map(int, input().split()))
x = Counter(A).most_common()[0][0]
left = A.index(x)
right = A[::-1].index(x)
for k in range(1, n+2):
  ans = comb(n+1, k) - comb(left+right, k-1)
  ans %= MOD
  print(ans)


Measured memory_bytes: 29916
def resolve():
    ans = 0
    N = int(input())
    L = list(map(int, input().split()))
    for i in range(N):
        for j in range(i):
            for p in range(j):
                count = [L[i], L[j], L[p]]
                sei = sorted(count)
                if L[i] != L[j] and L[j] != L[p] and L[p] != L[i] and sei[0] + sei[1] > sei[2]:
                    ans += 1
    print(ans)
resolve()

Measured memory_bytes: 9224
#include <stdio.h>
int main(void){
    // Your code here!
    int m,f,b;
    scanf("%d%d%d",&m,&f,&b);
    int c=0;
    if(m>b)printf("0\n");
    else if(m+f<b)printf("NA\n");
    else printf("%d\n",(m-b)*-1);
    return 0;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
bool isOK(ll &itr, ll &key, vector<ll> &v) {
  if(v[itr] >= key) return true;
  return false;
}

ll bynary_search(ll &key, vector<ll> &v) {
  ll ng = -1; ll ok = (ll)v.size();
  while(ok - ng > 1) {
    ll mid = (ng + ok) / 2;
    if(isOK(mid, key, v)) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  ll N; cin >> N;
  ll cnt = 0; 
  vector<ll> A(N), B(N), C(N);
  for(ll i = 0; i < N; i++) cin >> A.at(i);
  for(ll i = 0; i < N; i++) cin >> B.at(i);
  for(ll i = 0; i < N; i++) cin >> C.at(i);
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());
  for(ll i = 0; i < N; i++) {
    ll b = B[i] + 1;
    ll a = bynary_search(B[i], A);
    ll c = bynary_search(b, C);
    c = N - c;
    cnt += (a * c);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int i, N, d3, d2, d1, d0;
  scanf("%d", &N);
  d0=(N%   10)/   1;
  d1=(N%  100)/  10;
  d2=(N% 1000)/ 100;
  d3=(N%10000)/1000;
  if((d3==d2 && d2==d1) || (d2==d1 && d1==d0))
    printf("Yes\n");
  else
    printf("No\n");
}


Measured memory_bytes: 128
n =gets.chop.to_i
a = gets.chop.split.map(&:to_i)



sum_a = a[0].abs

(n-1).times do |i|
  sum_a += (a[i]-a[i+1]).abs
end

sum_a += a.last.abs

n.times do |i|
  if i == 0
    p sum_a - a[0].abs - (a[1]-a[0]).abs + a[1].abs
  elsif i == n-1
    p sum_a - (a[i]-a[i-1]).abs - a[i].abs + a[i-1].abs
  else
    p sum_a - (a[i-1]-a[i]).abs - (a[i]-a[i+1]).abs + (a[i-1]-a[i+1]).abs
  end
end


Measured memory_bytes: 16780
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

void solve() {
  ll n;
  cin >> n;
  ll min_ = 10000000000000;
  for (ll d1 = 1; d1*d1<=n; d1++) {
    if (n%d1!=0) continue;
    ll d2 = n / d1;
    min_ = min(min_, d2 - 1 + d1 - 1);
  }
  cout << min_ << endl;
}


Measured memory_bytes: 3548
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

  trace(A, n);

  for ( i = 2; i < n+1 ; i++) {
    int key = A[i];
    int j = i-1;
    while (j >= 1 && A[j] > key) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    trace(A, n);
     /* code */
  }

  return 0;
}

Measured memory_bytes: 608
# encoding:utf-8
import copy
import numpy as np
import random


a,b,k = map(int,input().split())

cds = []
for i in range(1,min(a,b)+1):
    if ((a%i==0) and (b%i==0)):
        cds.append(i)

cds.reverse()
print(cds[k-1])


Measured memory_bytes: 24064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			String str[] = br.readLine().split(" ");
			int n = Integer.parseInt(str[0]);
			int m = Integer.parseInt(str[1]);

			if (n == 0 && m == 0)
				break;

			int h[] = new int[n];
			int w[] = new int[m];
			int height[] = new int[1000*1500+1];
			int width[] = new int[1000*1500+1];

			for (int i = 0; i < n; i++) {
				h[i] = Integer.parseInt(br.readLine());
			}

			for (int i = 0; i < m; i++) {
				w[i] = Integer.parseInt(br.readLine());
			}
			for (int i = 0; i < n; i++) {
				int len = 0;
				for (int j = i; j < n; j++) {
					len += h[j];
					height[len]++;
				}
			}
			for (int i = 0; i < m; i++) {
				int len = 0;
				for (int j = i; j < m; j++) {
					len += w[j];
					width[len]++;
				}
			}
			int count = 0;
			for (int i = 0; i < height.length; i++) {
				count += height[i] * width[i];
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 442492
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n;
int a[300010], ml[300010], mr[300010];

signed main() {
    cin >> n;
    int m = 3*n;
    rep(i,0,m) cin >> a[i+1];
    
    int vl = 0, vr = 0;
    // [0, i] and (i, 3n]
    priority_queue< int, vector<int>, greater<int> > l;
    priority_queue< int > r;

    repq(i,1,n) {
        l.push(a[i]);
        vl += a[i];
    }
    ml[n] = vl;
    repq(i,n+1,2*n) {
        l.push(a[i]); vl += a[i];
        int p = l.top(); vl -= p;
        l.pop();
        ml[i] = vl;
    }

    repq(i,2*n+1,3*n) {
        r.push(a[i]);
        vr += a[i];
    }
    mr[2*n] = vr;
    repr(i,2*n-1,n) {
        r.push(a[i+1]); vr += a[i+1];
        int p = r.top(); vr -= p;
        r.pop();
        mr[i] = vr;
    }

    int ans = -1e17;
    repq(i,n,2*n) {
        // printf("%lld: ml = %lld, mr = %lld\n", i, ml[i], mr[i]);
        ans = max(ans, ml[i] - mr[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main () { 
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];  
  } 
  if (n == 1) {
    cout << a[0] << endl;  
    return 0;
  }
  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      int j = n - 1 - i;
      if (j % 2 == 1) {
        cout << a[j] <<  " ";  
      }  
    }  
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0) {
        cout << a[i];  
        if (i != n - 2) {
          cout << " ";  
        }
        else {
          cout << endl;  
        }
      }
    }
  }
  else {
    for (int i = 0; i < n; i++) {
      int j = n - 1 - i;
      if (j % 2 == 0) {
        cout << a[j] << " ";  
      }  
    }  
    for (int i = 0; i < n; i++) {
      if (i % 2 == 1) {
        cout << a[i];
        if (i != n - 2) {
          cout << " ";  
        }
        else {
          cout << endl;  
        }
      }
    }
  }
}

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

using namespace std;

int main() {
  string s;
  int num[0xff] = {};
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    num[s[i]]++;
    if (num[s[i]] > 1) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}

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




 int main()
{

    li n,i,j;
    cin>>n;
    double p[n+1];
    for(i=1;i<=n;i++)
        cin>>p[i];
    double dp[n+1][n+1];
    dp[0][0]=1.0;
    for(i=1;i<=n;i++)
        dp[0][i]=0;
    for(i=1;i<=n;i++)
        dp[i][0]=(1-p[i])*dp[i-1][0];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            dp[i][j]=p[i]*dp[i-1][j-1]+(1-p[i])*dp[i-1][j];
        }
    }
    double ans=0.0;
    j=n/2 +1;
    while(j<=n)
    {
        ans+=dp[n][j];
        j++;
    }
    printf("%.10lf",ans);
    return 0;
}


Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
const int mo=1e9+7,N=2e5+5;
typedef long long LL;
void Inverse(int p,int a[],int n){//ÏßÐÔÇó<=nµÄÊý%pÒâÒåÏÂµÄÄæÔª 
	a[1]=1;
	for(int i=2;i<=n;i++){
		a[i]=1ll*(p-p/i)*a[p%i]%p;
	}
}
int inv[N];
int main(){
	int n,k;scanf("%d%d",&n,&k),k=min(k,n-1);
	Inverse(mo,inv,n-1);
	LL ans=(k!=1),a=1,b=1;
	for(int i=1;i<=k;i++){
		a=a*inv[i]%mo*(n-i+1)%mo,b=b*inv[i]%mo*(n-i)%mo;
		(ans+=a*b)%=mo;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
ll n;
ll ans;


int main()
{
    cin>>n;
    ans = (1 + n)*n/2;
    ans-=n;
    cout<<ans<<endl;
    return 0;
}



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

int main() {
    int N, T, A;
    cin >> N >> T >> A;
    int res = 0;
    int cc = 100000000000;
    for (int i=1; i<=N; i++) {
        int x;
        cin >> x;
        int diff;
        diff = (T*1000 - x * 6) - A * 1000;
        if (diff < 0) diff = -diff;
        if (cc > diff) cc = diff, res = i;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int p,r;
 
int main(){
   
  int n,i,A[100000];
  int index;
 
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &A[i]);
  }
  index = Partition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i==index) printf("[");
    printf("%d", A[i]);
    if(i==index) printf("]");
    if(i!=n-1)
    printf(" ");
  }
  printf("\n");
  return 0;
 
}
 
int Partition(int A[], int p, int r){
 
  int x,i,j;
  int Q,R;
  int k;
 
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      Q=A[i];
      A[i]=A[j];
      A[j]=Q;
    }
  }
 
  R=A[i+1];
  A[i+1]=A[r];
  A[r]=R;
  return i+1;
}

Measured memory_bytes: 992
#include <cstdio>

int main()
{
    int n, i;
    int arr[100];
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf(" %d", &arr[i]);
    }
    for (i = 0; i < n; i++)
    {
    if (i)
            printf(" ");
        printf("%d", arr[n - i - 1]);
    }
    printf("\n");
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, P;
    cin >> N >> P;
    string S;
    cin >> S;

    ll ans = 0;

    if (P == 2) {
        for (ll i = 0; i < N; i++) {
            int si = S[i] - '0';
            if (~si & 1) {
                ans += i + 1;
            }
        }
        cout << ans << "\n";
        return;
    }
    else if (P == 5) {
        for (ll i = 0; i < N; i++) {
            int si = S[i] - '0';
            if (si == 0 || si == 5) {
                ans += i + 1;
            }
        }
        cout << ans << "\n";
        return;
    }

    Vl b(N + 1);
    reverse(S.begin(), S.end());
    ll base = 1;
    for (ll i = 0; i < N; i++) {
        b[i + 1] = b[i] + base * (S[i] - '0');
        b[i + 1] %= P;
        base *= 10;
        base %= P;
    }

    map<ll, ll> mp;
    for (ll i = 0; i <= N; i++) {
        ++mp[b[i]];
    }

    for (auto [v, k] : mp) {
        ans += k * (k - 1) / 2;
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

int main(){
	const char C[10][6] = {
		{},
		{'.',',','!','?',' ', 5 },
		{'a','b','c', 0 , 0 , 3 },
		{'d','e','f', 0 , 0 , 3 },
		{'g','h','i', 0 , 0 , 3 },
		{'j','k','l', 0 , 0 , 3 },
		{'m','n','o', 0 , 0 , 3 },
		{'p','q','r','s', 0 , 4 },
		{'t','u','v', 0 , 0 , 3 },
		{'w','x','y','z', 0 , 4 },
	};
	int n;
	cin >> n;
	for(int i=0 ; i<n ; ++i ){
		char s[1025];
		cin >> s;
		char c = 0;
		int pos = -1;
		for(int j=0 ; s[j] ; ++j ){
			int button = s[j] - '0' ;
			if( button == 0 ){
				if( c != 0 ) cout << c ;

				pos = -1;
				c = 0;
			}else{
				pos++;
				c = C[ button ][ pos % (int)(C[button][5]) ];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
 
using namespace std;
 
int main()
{
int n;
cin>>n;
vector<int> all(n+1);
vector<int> cont(1000000);
 
for(int i=0;i<1000000;i++)
cont[i]=0;
 
for(int i=0;i<n;i++)
{
int tmp;
cin>>tmp;
cont[tmp]++;
}
int res=0;
for(int i=0;i<1000000;i++)
{
res=max(res,cont[i]+cont[i+1]+cont[i+2]);
}
cout<<res<<endl;
return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <iomanip>

using namespace std;

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

    int ans = 0;
    int h;
    for (int i=0; i<n; ++i) {
        cin >> h;
        if (h>=k) ans += 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<string>
int main(){
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<"";
  }
  else if(s=="ARC"){
    cout<<"ABC"<<"";
  }
  else{
    return 0;
  }
  return 0;
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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 REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#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 ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}

int main(){

    int n;
    cin >> n;

    ll lcd = 1;

    ll t[n];

    REP(i,n){
        cin >> t[i];

        ll g = gcd(lcd,t[i]);

        lcd = lcd/g*t[i];
    }

    cout << lcd << endl;
    return 0;
}


Measured memory_bytes: 3588
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    int A,B,C;
    int X,Y;
    int ans=0;

    cin>>A>>B>>C;
    cin>>X>>Y;

    while(X!=0||Y!=0){
        if(X>0&&Y>0){
            if(A+B>2*C){
                ans+=2*C;
            }
            else{
                ans+=A+B;
            }
            X--;
            Y--;
        }
        else if(X>0){
            if(A>2*C){
                ans+=2*C;
            }
            else{
                ans+=A;
            }
            X--;
        }
        else if(Y>0){
            if(B>2*C){
                ans+=2*C;
            }
            else{
                ans+=B;
            }
            Y--;
        }
    }
    cout<<ans<<endl;
}


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

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

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

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

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

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

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

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

fn main() {
    input! {
        k: i32,
        x: i32,
    }
    const MIN: i32 = -1000000;
    const MAX: i32 = 1000000;
    let mut left: i32 = x - k + 1;
    let mut right: i32 = x + k;
    if left < MIN {
        left = MIN;
    }
    if right > MAX {
        right = MAX;
    }
    for i in left..right {
        print!("{} ", i);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 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;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,m; cin >> n >> m; ll ans = 0;
  priority_queue<ll> pq;
 
  ll x = 0;
  
  rep(i,n){
    cin >> x;
    pq.push(x);
  }
  
  rep(i,m){
    x = pq.top();
    pq.pop();
    
    pq.push(x/2);
  }
  
  rep(i,n){
    ans += pq.top();
    pq.pop();
  }
  
  cout << ans << endl;
  
  
}


Measured memory_bytes: 4272
using System;

class Program
{
    static void Main()
    {
        int[] num = new int[10000];

        int i = 0; //????????????????????\????????????????????????????????°
        while (true)
        {
           
           int x = int.Parse(Console.ReadLine());
            if (x != 0)
            {
                num[i] = x;
                i++;
            }
            else
            {
                break;
            }

        }

        for (int z = 0; z <= i-1;z++)
        {
            Console.WriteLine("Case {0}: {1}", z + 1, num[z]);
        }
    }
}

Measured memory_bytes: 9372
#include <stdio.h>
int binary(int,int,int *);
int main(){
  int i,n,s[100000],cnt=0,t[50000],q;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
    cnt+=binary(n,t[i],s);
  }
  printf("%d\n",cnt);
  return 0;
}
int binary(int n,int t,int *s){
  int mid,left,right;
  right=n;
  left=0;
  while(right>left){
    mid=(right+left)/2;
    if(s[mid]==t)return 1;
    else if(s[mid]>t)right=mid;
    else if(s[mid]<t)left=mid+1;
  }
  return 0;
}



Measured memory_bytes: 2268
#include <stdio.h>

int main(void)
{
    int n, y;
    int b, r, t;
    int i, j;
    int max_bank;
    double max_monay;
    double monay;
    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        scanf("%d", &y);
        
        max_monay = 0;
        for (i = 0; i < n; i++){
            scanf("%d%d%d", &b, &r, &t);
            
            if (t == 1){    // 単利
                monay = 1 + y * r / 100.0;
            }
            else {          // 複利
                monay = 1;
                for (j = 0; j < y; j++){
                    monay *= (1 + r / 100.0);
                }
            }
            if (monay > max_monay){
                max_monay = monay;
                max_bank = b;
            }
        }
        printf("%d\n", max_bank);
    }
    return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define pff pair<long long, long long> 
#define mp make_pair 
#define pb push_back

using namespace std;
int main()
{
	unsigned long n,q,h,s,d;
	cin>>q>>h>>s>>d>>n;
	vector<pff>v;
	v.pb(mp(q*4,0.25));
	v.pb(mp(h*2,0.5));
	v.pb(mp(s,1));
	v.pb(mp((double)d/2,2));
	
	sort(v.begin(),v.end());
//	for(int i=0;i<4;i++)
//	cout<<v[i].first<<" "<<v[i].second<<endl;
	if(v[0].second!=2)
	{
		cout<<n*(unsigned long long)v[0].first;
	}
	else
	{
		unsigned long ans=0;
		if(n>=2)
		{
		//	cout<<"n>=2 ";
			ans=(n/2)*d;
			ans+=n&1?v[1].first:0;
		}
		else
		{
		//	cout<<"n==1 ";
			ans=v[1].first;
		}
		cout<<ans;
	}
	
	return 0;
}

Measured memory_bytes: 256
main()
{
  int n,i,count=0,ans=0;
  scanf("%d",&n);
  char s[n+1];
  scanf("%s",s);
  for(i=0;i<n;i++)
  {
    if(s[i]=='R')
      count++;
    else
      ans++;
  }
  if(count>ans)
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 128
N=int(input())
A=list(map(int, input().split()))
kabu=0
ans=1000
for i in range(N-1):
    if A[i] > A[i+1]:
        ans=ans+kabu*A[i]
        kabu=0

    if A[i] < A[i+1] and ans >= A[i]:
        kabu=ans // A[i]
        ans=ans % A[i]

ans=ans+kabu*A[N-1]

print(ans)

Measured memory_bytes: 9064
import itertools
 
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
 
# Nが10程度で小さい
# 階乗の全探索をしても間に合う
# Pythonならitertoolsで順列を生成できる！
l = [i for i in range(1, N+1)]
permutations_l = list(itertools.permutations(l))
 
a, b = 0, 0
for i, R in enumerate(permutations_l):
  if R == P: a = i
  if R == Q: b = i

print(abs(a-b))

Measured memory_bytes: 13984
from collections import Counter
s = input()
t = input()
s_cnt = sorted(Counter(s).most_common())
t_cnt = sorted(Counter(t).most_common())[::-1]
s_replaced = ""
t_replaced = ""
for k, v in s_cnt:
    s_replaced += k * v 
for k, v in t_cnt:
    t_replaced += k * v 

def judge(s, t):
    for i in range(min(len(s), len(t))):
        if ord(s[i]) > ord(t[i]):
            return False
        if ord(s[i]) < ord(t[i]):
            return True
    if len(s) < len(t):
        return True
    else:
        return False

if judge(s_replaced, t_replaced):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#!/usr/bin/env ruby

n = STDIN.gets.chomp.to_i
nums = STDIN.gets.chomp.split(' ').map &:to_i

#0.upto(n-2).each do |i|
#  if (nums[i] + nums[i+1]) < -1 * (nums[i] + nums[i+1])
#    nums[i] *= -1
#    nums[i+1] *= -1
#  elsif (nums[i] + nums[i+1]) == -1 * (nums[i] + nums[i+1])
#    if nums[i] < 0
#      nums[i] *= -1
#      nums[i+1] *= -1
#    end
#  end
#  puts "#{i}: #{nums}"
#end
#puts nums.inject(0){|s, i| s+i }

if nums.include? 0
  puts nums.inject(0){|s, i| s+i.abs }
  exit
end

if nums.inject(1){|s, i| s * i / i.abs } > 0
  puts nums.inject(0){|s, i| s+i.abs }
else
  min = nums.map(&:abs).min
  puts nums.inject(0){|s, i| s+i.abs } - 2*min
end



Measured memory_bytes: 10380
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;

int INF=1e9;

int main(){  
    int a,b,c;
    cin>>a>>b>>c;
    int ans=min(a+b,min(b+c,c+a));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int k;
    cin>>k;
    vector<string>ans[10],ans2;
    for(int i=0;i<10;i++){
        for(int j=1;j<=9;j++){
            for(int S=0;S<(int)pow(3,i);S++){
                string tmp;
                tmp.push_back(j+'0');
                bool ok=1;
                int ss=S;
                for(int k=0;k<i;k++){
                    if(ss%3==0)
                        tmp.push_back(tmp.back()+1);
                    else if(ss%3==1)
                        tmp.push_back(tmp.back()-1);
                    else
                        tmp.push_back(tmp.back());
                    if(tmp.back()<'0'||'9'<tmp.back())
                        ok=0;
                    ss/=3;
                }
                if(ok)
                    ans[i].push_back(tmp);
            }
        }
        sort(ans[i].begin(),ans[i].end());
        for(int j=0;j<ans[i].size();j++)
            ans2.push_back(ans[i][j]);
    }
    cout<<ans2[k-1]<<endl;
}


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

int main(int argc, char const *argv[])
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a % 2 == 1 && b % 2 == 1)	cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

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

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cout << "\n\nTime elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
}
#else
#define endl '\n'
#define trace(...)
#define start_routine()
#define end_routine()
#endif

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7

ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }
const ll maxn = 200005;
ll n;
ll a[25][25];
ll dp[25][3000000];
bool vis[25][3000000];

ll recur(ll i, ll x){
    if(vis[i][x]) return dp[i][x];
    if(i >= n){
        return 1;
    }
    ll val = 0;
    rep(j, n) {
        if((x & (1ll << j)) != 0){
            ll xNext = (x & ~(1ll << j)); 
            if(a[i][j] == 1){
                val = (val + recur(i+1, xNext))%mod;
            }
        }
    }
    vis[i][x] = true;
    return dp[i][x] = val;
}

int main()
{ 
    start_routine();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        cin>>n;
        rep(i,n){
            rep(j,n){
                cin>>a[i][j];
            }
        }
        ll init = (1ll<<n) - 1;
        ll anser = 0;
        // rep(i,n){
            rep(j,n){
                if(a[0][j] == 1){
                    ll xNext = (init & ~(1ll<<j));
                    // trace(xNext, j);
                    anser = (anser + recur(1, xNext))%mod;
                    // trace(anser, j);
                }
            }
        // }
        cout<<anser<<endl;
    }
    end_routine();
}

Measured memory_bytes: 373120
#include<iostream>

using namespace std;

int main(void) {
	int K;
	int A[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cin >> K;
	cout << A[K - 1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
 
int main(){
  ll n,c1,c2,c3;
  int mod = 1000000007;
  cin >> n;
  if(n < 2){
    cout << 0 <<endl;
    return 0;
  }
  c1 = 2;
  c2 = 34;
  c3 = 64;
  for (int i = 2; i < n;i++){
    c1 = c1*10+c2;
    c2 = c2*9 + c3*2;
    c3 = c3*8;
    if(c1 > mod)c1 %=mod;
    if(c2 > mod)c2 %=mod;
    if(c3 > mod)c3 %=mod;
  }
  
  cout << c1 <<endl;

}
  

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)
 
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
 
int n,m;
int main() {
	scanf("%d", &n);
	int ans = 0;
	ll reached = -(1LL<<50);
	vector<pair<ll, ll>> V;
	REP(i, n){
		ll x, l;
		scanf("%lld%lld", &x, &l);
		V.pb(mp(x-l, x+l));
	}
	sort(V.begin(), V.end());
	REP(i, n){
	//	printf("%lld %lld\n", V[i].first, V[i].second);
		if(V[i].first >= reached) {
			ans++;
			reached = V[i].second;
		} else if(V[i].second < reached) {
			reached = V[i].second;
		}
	}
	printf("%d\n", ans);
 
 
	return 0;
}


Measured memory_bytes: 2420