akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

template <class T>
struct Combination {
    int max_n;
    std::vector<T> f, invf;

    explicit Combination(int n)
        : max_n(n), f(n + 1), invf(n + 1) {
        f[0] = 1;
        for (int i = 1; i <= n; ++i) {
            f[i] = f[i - 1] * i;
        }

        invf[max_n] = f[max_n].inv();
        for (int i = max_n - 1; i >= 0; --i) {
            invf[i] = invf[i + 1] * (i + 1);
        }
    }

    T fact(int n) const { return f[n]; }
    T invfact(int n) const { return invf[n]; }
    T perm(int a, int b) const {
        return a < b ? T(0) : f[a] * invf[a - b];
    }
    T comb(int a, int b) const {
        return a < b ? T(0) : f[a] * invf[a - b] * invf[b];
    }
};

const Combination<mint> C(1000);

int main() {
    int n, k;
    std::cin >> n >> k;
    std::cout << C.comb(k, n) << std::endl;
    return 0;
}



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

int main()
{
    ll n;

    while(~scanf("%lld",&n))
    {
        ll sum =0;
        for(int i=1;i<=n;i++)
        {
            ll m =i,x =0;
            while(m)
            {
                m /=10,x++;
            }
            if(x&1)
                sum++;
        }
        printf("%lld\n",sum);
    }
    return 0;
}


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


int main(){
    int n,d;
    cin >> n >> d;
    int num=0;
    int sum=0;
    int ans = 0;
    num = 2*d+1;
    rep(i,n){
        if(n>sum){
            sum += num;
            ans++;
        }
        else{
            break;
        }
    }
    
    cout  << ans << endl;
    
    
    return 0;
}


















Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
eated = 0
for i in A:
    ans += B[i-1]
    if eated != 0 and eated + 1 == i:
        ans += C[eated-1]
    eated = i

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
map<int, int> res;
vector<int> divisor(int n)
{
    vector<int> res;
    for (int i = 1; i * i <= n; i++)
        if (n % i == 0)
        {
            res.push_back(i);
            if (i != n / i)
                res.push_back(n / i);
        }
    return res;
}
//素因数分解o√n
void prime_factor(int n)
{
    for (int i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            if(res.find(i) != res.end())
            ++res[i];
            else
            res[i] = 1;
            n /= i;
        }
    }
    if (n != 1)
        res[n]++;
}
int n;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;

    for(int i=2;i<=n;i++){
        prime_factor(i);
    }
    int ans=0;
    int count5=0;
    int count3=0;
    int count15=0;
    int count4=0;
    int count75=0;
    int count25=0;
    for(int i=2;i<=n;i++){
        
        if(res.find(i) != res.end()){
        if(res[i]>=4)count5++;
        if(res[i]>=2)count3++;
        if(res[i]>=14)count15++;
        if(res[i]>=74)count75++;
        if(res[i]>=24)count25++;
        }
    }
    ans+=count15*(count5-1);
    ans+=count5*(count5-1)*(count3-2)/2;
    ans+=count75;
    ans+=count25*(count3-1);
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct a{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, a;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a,int b){ return a < b ? a:b; }

int main(){
  int A = 0, z;
  int i, q;
  P u;
  scanf("%d %d", &a, &q);

  for ( i = 1; i <= a; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = a + 1;

  while( head != tail ){
    u = dequeue();
    z = min(q , u.t);
    u.t -= z;
    A += z;
    if( u.t > 0) enqueue(u);
    else{
        printf("%s %d\n",u.name, A);
    }
  }
  return 0;
}



Measured memory_bytes: 11848
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll n,d;
    cin >> n >> d;
    ll res = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(x*x + y*y <= d*d)res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>

int main(){
  int n,a,b[200005],i;
  scanf("%d",&n);
  b[0]=0;
  for(i=1;i<n;i++){
    scanf("%d",&a);
    b[i]=0;
    b[a-1]++;
  }
  for(i=0;i<n;i++){
    printf("%d\n",b[i]);
  }
  return(0);
}

Measured memory_bytes: 2508
package main

import "fmt"

func main() {
	var k, cnt int
	fmt.Scan(&k)
	for i := 1; i <= k; i++ {
		for j := 1; j != i && j <= k; j++ {
			if (i%2 == 0 && j%2 == 1) ||
				(j%2 == 0 && i%2 == 1) {
				// fmt.Println("(i,j)", i, j)
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vl vector<long long>
#define fin(ar,k,n) for(int i=k;i<n;i++) cin>>ar[i]
#define fout(ar,k,n) for(int i=k;i<n;i++) cout<<ar[i]<<' '
#define all(z) z.begin(),z.end()
#define mcc ((int)1e9+7)
#define mcf 998244353
#define mi map<int,int>
#define mem(a,n) memset(a,n,sizeof(a))
using namespace std;

//ll maxl(ll a,ll b) {return (a>b)? a:b;}
//ll minl(ll a,ll b) {return (a<b)? a:b;}
//ll gcdl(ll a,ll b) {return b ? gcdl(b,a%b):a;}
//bool sortc(const vi &v1,const vi &v2) {return v1[0]>v2[0];}


void solve()
{
    string s;
    cin>>s;
    ll dp[2][2019],ans=0;
    mem(dp,0);
    dp[0][s[0]-'0']=1;
    for (int i=1;i<s.length();i++)
    {
        for (int j=0;j<2019;j++)
        {
            int nxt=(j*10+s[i]-'0')%2019;
            dp[1][nxt]+=dp[0][j];
        }
        ans+=dp[1][0];
        memcpy(dp[0],dp[1],sizeof(dp[1]));
        mem(dp[1],0);
        dp[0][s[i]-'0']++;
    }
    cout<<ans<<endl;
}

#if 1
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
#endif

//------------------------Google-------------------
#if 0
int main()
{
    #ifdef __WIN32
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,ct=0;
    cin>>t;
    while(t--)
    {
        cout<<"Case #"<<++ct<<": ";
        solve();
    }
    return 0;
}
#endif


Measured memory_bytes: 3764
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	k, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	a := make([]int, n)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	max := 0
	for i := range a {
		if i == len(a)-1 {
			sub := k + a[0] - a[len(a)-1]
			if max < sub {
				max = sub
			}
			continue
		}
		sub := a[i+1] - a[i]
		if max < sub {
			max = sub
		}
	}
	fmt.Println(k - max)
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
long long a,b,c;
int main()
{
	scanf("%lld%lld.%lld",&a,&b,&c);
	b=b*100+c;
	printf("%lld\n",a*b/100); 
return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    for(int i = 0; i < n; i++){
        cin >> q[i];
    }
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        a[i] = i + 1;
    }
    map<vector<int>, int> mp;
    do{
        mp[a] = mp.size();
    }while (next_permutation(a.begin(), a.end()));

    int ans = abs(mp[p] - mp[q]);

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

Measured memory_bytes: 8604
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long N; cin >> N;
    map<long long, long long> cnt;

    for (long i = 0; i < N; ++i) {
        long long in; cin >> in;
        cnt[in] += 1;
    }

    long long ans = 0;
    for (auto &c : cnt) {
        if (c.first == c.second) continue;
        if (c.first <= c.second) ans += (c.second - c.first);
        else ans += c.second;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6272
# -*- coding: utf-8 -*-

n = int(input())
s = list(input())

a = [0] * n

cnt = 0
for i in range(n-1,-1,-1):
    if s[i] == ".":
        cnt += 1
    a[i] = cnt

needs = [n]
cnt = 0
for i in range(n):
    if s[i] == "#":
        need = 0
        cnt += 1
        need += a[i]
        needs.append(need + cnt - 1)
need = min(needs)

black = 0
for i in range(n):
    if s[i] == "#":
        black += 1

print(min(black,need))


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

#define REP(i,n) for(int i=0;i<(n);++i)
const long long INF = 1LL<<60;
const long long mod=1e9+7;

int main(){
    string S;
    cin >> S;
    string T;
    cin >> T;
    reverse(S.begin(), S.end());
    reverse(T.begin(), T.end());
    int res = 0;
    int pos = 0;
    bool key = false;
    int m[S.size()];
    REP(i,S.size()){
        for(int j = i; j < i + T.size(); ++j){
            if(S[j] == T[j-i] || S[j] == '?') key = true;
            else key = false;
            if(!key) break;
        }
        if(key){
            for(int k = i; k < i + T.size(); ++k){
                S[k] = T[k-i];
            }
            break;
        }
    }
    if(!key) cout << "UNRESTORABLE" << endl;
    else {
        reverse(S.begin(), S.end());
        REP(i,S.size()){
            if(S[i] == '?') S[i] = 'a'; 
        }
        cout << S << endl;
    }
}

Measured memory_bytes: 256
s = list(input())
l = len(s)
 
s1 = s[:int(l/2)]
s2 = s[-int(l/2):]
s2.reverse()
 
dif = 0
for i in range(int(l/2)):
  if s1[i] != s2[i]:
    dif += 1
 
print(dif)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef long long ll;

int main(void){
    int n, a[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    
    int ans = 0, len = 0, dir = 0;
    for (int i = 0; i < n; i++) {
        if (len == 0) {
            len++;
        }
        else if (dir == 0) {
            if (a[i] - a[i - 1] > 0) dir = 1;
            else if (a[i] - a[i - 1] < 0) dir = -1;
            len++;
        }
        else {
            if (dir == 1 && a[i] - a[i - 1] < 0) {
                ans++;  len = 1;  dir = 0;
            }
            else if (dir == -1 && a[i] - a[i - 1] > 0) {
                ans++;  len = 1;  dir = 0;
            }
            else len++;
        }
    }
    
    if (len > 0) ans++;
    
    cout << ans << endl;
    
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	double a,b,x;
	cin>>a>>b>>x;
    double S = a*a;
    double V = S*b;
    double ans;
    
    if(x*2<V){
        ans = atan((a*b*b)/(2*x))/M_PI_2*90;
    }else{
        ans = atan((2*(V-x))/pow(a,3))/M_PI_2*90;
        // cout<<atan((2*(V-x))/pow(a,3))<<"\n";
    }
    // cout<<M_PI_4<<"\n";
    cout<<fixed<<setprecision(10)<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 384
#include "iostream"
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod = 1000000007

int main(int argc, char const *argv[]) {
  string a,b,c;
  std::cin >> a >> b >> c;

  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0])printf("YES");

  else printf("NO");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int Bsearch(int[],int,int);
int main(){
  int i,j,n,A[100000+1],sum=0,key;

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

  

  scanf("%d",&j);
  for(i=0;i<j;i++){
    scanf("%d",&key);
    if(Bsearch(A,n,key))sum++;
  }
  printf("%d\n",sum);
  return 0;
}

int Bsearch(int A[],int n,int key){
  int r=n;
  int l=0;
  int m;
  while(l<r){
    m=(l+r)/2;
    if(key==A[m])return 1;
    else if(key>A[m])l=m+1;
    else  r=m;
  }
  return 0;
}


  

 

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

int main() {
    while (true) {
        int n, m, p;
        cin >> n >> m >> p;
        if ((n | m | p) == 0) {
            break;
        }
        vector<int> x(n);
        int sum = 0;
        for (int i = 0; i < n; i++) {
            cin >> x[i];
            sum += x[i];
        }
        int result = (x[m - 1] > 0) ? sum * (100 - p) / x[m - 1] : 0;
        cout << result << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define vec(j,n) vector<int>(j(n))
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main(){
    int n,x,t,ans;
    cin >>n >>x>>t;
    if(n%x==0){
        ans = n / x;
    }else{
        ans = (n /x) +1;
    }
    int ans1 = ans *t;
    cout << ans1 << endl;
    return 0;  
}

Measured memory_bytes: 3592
# include<iostream>
using namespace std;
char s[300005];
int a[300005];
int b[300005];
int main(void)
{
    int n, i;
    cin >> n;
    cin >> s;
    a[0] = 0;
    for(i = 1; s[i] != '\0'; ++i)
    {
        if(s[i-1] == 'E')
            a[i] = a[i-1]+1;
        else
        {
            if(i == 1)
                a[i] = 0;
            else
                a[i] = a[i-1];
        }
    }
    b[n-1] = 0;
    for(i = n-2; i >= 0; --i)
    {
         if(s[i+1] == 'W')
            b[i] = b[i+1]+1;
        else
        {
            if(i == n-2)
                b[i] = 0;
            else
                b[i] = b[i+1];
        }
    }
    int sum = 1000000000;
    for(i = 0; s[i] != '\0'; ++i)
    {
        if(sum > n-1-(a[i]+b[i]))
            sum = n-1-(a[i]+b[i]);
    }
    cout << sum <<endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main() {
    long n;
    cin >> n;
    long sum = 0;

    for (long i = 1; i <= n - 1; i++) {
        sum += i;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
W_list = list(map(int, input().split()))

min_abs = -1
for n in range(N):
    S1 = W_list[:n+1]
    S2 = W_list[n+1:]
    tmp_abs = abs(sum(S1) - sum(S2))
    if min_abs == -1:
        min_abs = tmp_abs
    elif min_abs > tmp_abs:
        min_abs = tmp_abs

print(min_abs)

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
using namespace std;
long long i,len,x,y;
bool f;
char a[13],b[13],c;
int main(){
    cin>>a>>c>>b;
    if(c=='-'){
        f=1;
    }
    len=strlen(a);
    for(i=0;i<len;i++){
        x+=a[i]-'0';
        x*=10;
    }
    x/=10;
    len=strlen(b);
    for(i=0;i<len;i++){
        y+=b[i]-'0';
        y*=10;
    }
    y/=10;
    if(f){
        cout<<x-y;
    }
    else{
        cout<<x+y;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
 int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  sort(arr,arr+n);
  int sum=0;
  for(int i=0;i<k;i++)
    sum+=arr[i];
  cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3624
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    c = 0
    for i in range(n):
        for j in range(i + 1, n):
            ij = i + j + 3
            for k in range(j + 1, n):
                if k + ij == x:
                    c += 1
    print(c)



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 2e6 + 5;

ll fac[maxn], ifac[maxn], inv[maxn];

ll nck(ll n, ll k) {
    if (n<k) return 0;
    return fac[n]*ifac[k]%mod*ifac[n-k]%mod;
}

void gen_inv() {
    fac[0]=inv[0]=ifac[0]=1;
    fac[1]=inv[1]=ifac[1]=1;

    for (int i=2; i<maxn; i++) {
	fac[i]=fac[i-1]*i%mod;
	inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	ifac[i]=ifac[i-1]*inv[i]%mod;
    }

    assert(nck(4,2)==6);
}

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}



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

    gen_inv();

    int k, n;
    string s;
    cin>>k;
    cin>>s;
    n = s.length();

    int len = n+k;
    
    ll res = pw(26, len);

    for (int m=0; m<n; m++) {
	ll cur = nck(len, m)*pw(25, len-m)%mod;
	res += (mod-cur);
	res %= mod;
    }

    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 51132
#include <stdio.h>

int main(void)
{
int P=0;
int Q=0;
int R=0;
int vx[5]={ };

scanf("%d%d%d", &P,&Q,&R);

vx[0]=(P+Q);
vx[1]=(R+Q);
vx[2]=(P+R);
vx[3]=(Q+R);
vx[4]=(R+P);
vx[5]=(Q+P);

int i;
int min=vx[0];
for (i=1; i<6; i++) {
if(vx[i]<min)
min=vx[i];
}

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

return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
md = 60
ans = 0
for d in range(md):
    cnt1 = sum([1 for i in a if ((i>>d)&1)]) # a内の全ての要素の d bit目の1の個数を数える
    ans += cnt1 * (n-cnt1) * (1<<d)          # 求めるべきは (0の個数)*(1の個数)をd bit目にそのまま収めたものを足し合わせたもの (?)
    ans %= mod                               # mod 取っておく

print(ans%mod)

    

Measured memory_bytes: 42156
def count_two_div(num: int):
    count = 0
    while True:
        if num % 2 == 0:
            count += 1
            num /= 2
        else:
            break
    return count


if __name__ == '__main__':
    n = int(input())
    c = list(map(int, input().split()))
    div_count_list = list(map(count_two_div, c))
    print(min(div_count_list))


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();


    int n;
    string s;
    cin>> n>> s;

    if(n &1)
    {
        cout << "No\n";
        return 0;
    }

    cout<<  ( s.substr (0, n/2) == s.substr (n/2, n/2) ? "Yes\n" : "No\n");

    return 0;
}




Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	ll n, k, a, ans = 0;
	vector<int>h;
	cin >> n >> k;
	rep(i, n) {
		cin >> a;
		h.push_back(a);
	}
	sort(h.begin(), h.end());
	rep(i,  n-k) {
		ans = ans + h[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main() {

  int n;
  cin >> n;
  vector<int> A(n), B(n), C(n);
  for (int i=0; i<n; i++) {
    cin >> A[i];
  }
  for (int i=0; i<n; i++) {
    cin >> B[i];
  }
  for (int i=0; i<n; i++) {
    cin >> C[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  long long sum = 0;

  for (int i=0; i<n; i++) {
    vector<int>::iterator  ITerB = upper_bound(C.begin(), C.end(), B[i]);
    vector<int>::iterator  ITerA = lower_bound(A.begin(), A.end(), B[i]);
    sum += (n - (ITerB - C.begin())) * (ITerA - A.begin());
  }
  cout << sum << endl;

}



Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
tr = str.maketrans('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
                   ,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
input_text = input().translate(tr)

print(input_text)


Measured memory_bytes: 5548
#include <iostream>

using namespace std;

int main(int argc, char** argv){
	int a, n;
	int data[10];
	
	while(1){
		cin >> n;
		
		if(n==0) break;		
	
		for(int i=0; i<10; i++){
			data[i] = 0;
		}
	
		for(int i=0; i<n; i++){
			cin >> a;
			data[a]++;
		}
		
		for(int i=0; i<10; i++){
			if(data[i]==0) cout << "-";
			for(int j=0; j<data[i]; j++){
				cout << "*";
			}
			cout << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

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

    for(int i = 0; i < 1; i = 0) {
      String line = sc.nextLine();
      String[] l = line.split(" ");
      int m = Integer.parseInt(l[0]);
      int f = Integer.parseInt(l[1]);
      int r = Integer.parseInt(l[2]);

      if(m == -1 && f == -1 && r == -1) {
        break;
      }

      char c = 0;
      if(m == -1 || f == -1) {
        c = 'F';
      } else if(m + f >= 80) {
        c = 'A';
      } else if(m + f >= 65) {
        c = 'B';
      } else if(m + f >= 50) {
        c = 'C';
      } else if(m + f >= 30) {
        if(r >= 50) {
          c = 'C';
        } else {
          c = 'D';
        }
      } else {
        c = 'F';
      }

      System.out.println(c);
    }
  }
}

Measured memory_bytes: 26040
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&c^-1;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int main(){
int n=read();
write(n*n+n>>1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[200005];
ll b[100005];
ll modpow(ll a,ll n,ll tmp){
	ll res=1ll;
	while(n){
		if(n%2)res=(res*a)%tmp;
		a=(a*a)%tmp;
		n/=2ll;
	}
	return res;
}
bool cmp(ll a,ll b){
	return abs(a)>abs(b);
}
int main(){
    ll n,k;
    ll mod=1e9+7;
    boost;
    cin>>n>>k;
    ll neg=0,ze=0;
    
	for(ll i=1;i<=n;i++)cin>>a[i],neg+=(a[i]<0);
    sort(a+1,a+n+1);
   
    
    ll ans=1;
    if(k==n){
    	for(ll i=1;i<=n;i++)ans=(ans*a[i])%mod;
    	cout<<(ans+mod)%mod;
    	return 0;
	}
	if(neg==n){
		
		if(k%2==0)for(ll i=1;i<=k;i++)ans=(ans*a[i])%mod;
		else {
			reverse(a+1,a+n+1);
			for(ll i=1;i<=k;i++)ans=(ans*a[i])%mod;
		}
		cout<<(ans+mod)%mod;
		return 0;
	}
	
    if(k%2 && a[n]==0){
    	cout<<0;
    	return 0;
    }
    
    if(k%2 && a[n]>0){
    	ans=a[n];
    	k--;
    	n--;
	}
			
	ll i=1;
	ll j=n;
	ll itr=k/2ll;
	
	for(ll loop=1;loop<=itr;loop++){
		if(a[i]*a[i+1]>a[j]*a[j-1]){
			ans=(ans*a[i])%mod;
			ans=(ans*a[i+1])%mod;
			i+=2;
			
		}else{
			ans=(ans*a[j])%mod;
			ans=(ans*a[j-1])%mod;
			j-=2;
		}
	}
	
	cout<<((ans+mod)%mod)<<endl;		
			
			
}

Measured memory_bytes: 5204
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	bool t = true;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			if (s[i] == 'L')t = false;
		}
		if (i % 2 == 1){
			if (s[i] == 'R')t= false;
		}
	}
	if (t)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include<stdio.h>

enum Diceface {
	DICETOP,
	DICEFRONT,
	DICERIGHT,
	DICELEFT,
	DICEBACK,
	DICEBOTTOM,
	DICENUM
};

void roll( int *dice, char cmd )
{
	int t;
    if( 'E' == cmd ) {
        t = dice[DICETOP];
        dice[DICETOP] = dice[DICELEFT];
        dice[DICELEFT] = dice[DICEBOTTOM];
        dice[DICEBOTTOM] = dice[DICERIGHT];
        dice[DICERIGHT] = t;
    } else if( 'N' == cmd ) {
        t = dice[DICETOP];
        dice[DICETOP] = dice[DICEFRONT];
        dice[DICEFRONT] = dice[DICEBOTTOM];
        dice[DICEBOTTOM] = dice[DICEBACK];
        dice[DICEBACK] = t;
    } else if( 'S' == cmd ) {
        t = dice[DICETOP];
        dice[DICETOP] = dice[DICEBACK];
        dice[DICEBACK] = dice[DICEBOTTOM];
        dice[DICEBOTTOM] = dice[DICEFRONT];
        dice[DICEFRONT] = t;
    } else if( 'W' == cmd ) {
        t = dice[DICETOP];
        dice[DICETOP] = dice[DICERIGHT];
        dice[DICERIGHT] = dice[DICEBOTTOM];
        dice[DICEBOTTOM] = dice[DICELEFT];
        dice[DICELEFT] = t;
    } else if( 'M' == cmd ) {
        t = dice[DICEBACK];
        dice[DICEBACK] = dice[DICERIGHT];
        dice[DICERIGHT] = dice[DICEFRONT];
        dice[DICEFRONT] = dice[DICELEFT];
        dice[DICELEFT] = t;
    }
    return;
}

int isEqualDice( int *dice, int *dice2 )
{
	int i, j;
	char cmd[] = "MMMMNMMMMWMMMMWMMMMWMMMMNMMMM";

	for( i=0; '\0'!=cmd[i]; i++ ) {		
		if( dice[ DICETOP ]== dice2[ DICETOP ] ) {
			for( j=0; j<DICENUM; j++ ) {
				if( dice[j] != dice2[j] ) { break; }
			}
			if( DICENUM == j ) { return 1; }
		}
		roll( dice2, cmd[i] );
	}
	return 0;
}

int main( int argc, char *argv[] ) 
{
    int dice[101][7];
    int i,j;
    int n;
     
    scanf( "%d", &n );
    for( i=0;  i<n; i++ ) {
        for( j=0;  j<6; j++ ) {
            scanf( "%d", &dice[i][j] );
        }
    }
    int cnt = 0;
    for( i=0; i<n-1; i++ ) {
        for( j=i+1; j<n; j++ ) {
            cnt += isEqualDice( dice[i], dice[j] );
        }
    }
	 if( cnt ) {
        printf( "No\n" );
    } else {
        printf( "Yes\n" );
    }
   
    return 0;
}

Measured memory_bytes: 584
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let s = read::<String>();
    let mut cs = s.chars().collect::<Vec<char>>();
    let n = read::<u32>();

    for _ in 0..n {
        let v = read_vec::<String>();
        let cmd = &v[0];
        let start = v[1].parse::<usize>().unwrap();
        let end = v[2].parse::<usize>().unwrap();

        if cmd == "replace" {
            let repword = v[3].chars().collect::<Vec<char>>();
            for (i, &c) in repword.iter().enumerate() {
                cs[start + i] = c;
            }
        } else if cmd == "reverse" {
            let revword = cs[start..end + 1]
                .iter()
                .rev()
                .map(|c| *c)
                .collect::<Vec<char>>();
            for (i, &c) in revword.iter().enumerate() {
                cs[start + i] = c;
            }
        } else if cmd == "print" {
            let out = cs[start..end + 1].iter().map(|c| *c).collect::<String>();
            println!("{}", out);
        }
    }
}



Measured memory_bytes: 5032
N, T = map(int, input().split())
t = list(map(int, input().split()))
t.append(10000000000)
ans = 0
for i in range(N):
    if t[i] + T <= t[i+1]:
        ans += T
    else:
        ans += t[i+1] - t[i]
print(ans)


Measured memory_bytes: 26708
#include<stdio.h>
int main(){
  char s[4];
  int a=0,b=0,c=0;
  scanf("%s",s);
  for(int i=0;i<=2;i++){
    if(s[i]=='a' && a==0)a=1;
    if(s[i]=='b' && b==0)b=1;
    if(s[i]=='c' && c==0)c=1;
  }
  if(a==1 && b==1 && c==1){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))

X1by2 = 0
for i in range(N):
  if i%2 ==0:
    X1by2 += A[i]
  else:
    X1by2 -= A[i]

X = []

X.append(X1by2)
for i in range(len(A)-1):
  X.append((A[i]-X[i]/2)*2)

print(" ".join(repr(int(e)) for e in X))


Measured memory_bytes: 18376
#include <stdio.h>

int main()
{
        char a, b;

        scanf("%c %c",&a,&b);

        if(a=='H')
        {
                printf("%c\n",b);
        }
        else if(a=='D')
        {
                printf("%c\n",b=='H'?'D':'H');
        }

        return 0;
}

Measured memory_bytes: 128
package main

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

var ReadString func() string

func init() {
	ReadString = newReadString()
}

/*------ scan ------*/

func newReadString() func() string {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), 2048)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}

func ReadInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("scanできなかった")
		panic(err.Error())
	}
	return int64(i)
}

func ReadInt() int {
	i := ReadInt64()
	return int(i)
}

func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}

func ReadInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

/*------ number util ------*/

func GetIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func Atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func FindMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}

func FindMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}


func main() {
  n := ReadInt()
  if n < 3 {
    fmt.Println(0)
  } else {
    fmt.Println((n - 2) * 180)
  }
}

Measured memory_bytes: 640
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (1000000007)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> Q;




int main(void){
    ll a,b,v,w;
    cin>>a>>v;
    cin>>b>>w;
    ll T;
    cin>>T;
    if(a<b){
        if(w-v>=0){
            cout<<"NO"<<endl;
        }
        else{
            ll V = v-w;
            ll d = b-a;
            if(V*T>=d){
                cout<<"YES"<<endl;
            }
            else cout<<"NO"<<endl;
        }
    }
    else{
        if(w-v>=0){
            cout<<"NO"<<endl;
        }
        else{
            ll V = v-w;
            ll d = a-b;
            if(V*T>=d){
                cout<<"YES"<<endl;
            }
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> a;
    for(int i = 0; n > i; i++){
        int t,m;cin>>t>>m;
        a.push_back(t*60+m);
    }
    int m; cin>>m;
    for(int i = 0; m> i; i++){
        int t,m;cin>>t>>m;
        a.push_back(t*60+m);
    }
    sort(a.begin(),a.end());

    for(int i = 0; a.size() > i; i++){
        if(i+1 != a.size() && a[i+1]==a[i])continue;
        cout << a[i]/60 << ":";
        if(a[i]%60 < 10)cout <<  "0";
        cout << a[i]%60;
        if(i+1 != a.size())cout << " ";
    }
    cout << endl;
}



Measured memory_bytes: 3124
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


int main() {
	int n;
	string s, t;
	cin >> n >> s >>t;
	rep(i, n) {
		cout << s[i] << t[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int n;
	while(cin>>n){
		if(n==-1)break;
		string str="";
		while(true){
			stringstream ss;
			ss <<n%4;
			n /=4;
			str =ss.str()+str;
			if(n==0)break;
		}
		cout <<str<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    double ans=0;
    for(int i=0;i<n;i++){
        double a;
        cin >> a;
        ans += 1/a;
    }
    cout << fixed << setprecision(6);
    cout << 1/ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<string> vec;
int main(){
  int n,ans=1; cin>>n;
  vec s(n);
  rep(i,n) cin>>s[i];
  
  sort(s.begin(), s.end());
  
  for(int i=1;i<n;i++){if(s[i]!=s[i-1])ans++;}
  
  cout<<ans<<endl;
}

Measured memory_bytes: 9600
h, w, k = map(int, input().split())
mp = []
wh = 0
bk = 0
cnt = 0
for i in range(h):
    mp.append(list(input()))
    for j in range(w):
        if mp[i][j] == ".":
            wh += 1
        else :
            bk += 1
for i in range(2 ** h):
    wkH = []
    for n in range(h):
        if ((i>>n) & 1):
            wkH.append(n)
    for j in range(2 ** w):
        wkW = []
        wkBk = bk
        for m in range(w):
            if ((j>>m) & 1):
                wkW.append(m)
        for o in range(len(wkH)):
            for p in range(w):
                if mp[wkH[o]][p] == "#":
                    wkBk -= 1
        for o in range(len(wkW)):
            for p in range(h):
                if p in(wkH):
                    continue
                if mp[p][wkW[o]] == "#":
                    wkBk -= 1
        if wkBk == k:
            cnt += 1
print(cnt)


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

int main(){
	int a, b;
	int e = 0;
	char op;
	while (1){
		cin >> a >> op >> b;
		switch (op){
		case '?':
			e = 1;
			break;
		case '+':
			cout << a + b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
		case '*':
			cout << a * b << endl;
			break;
		case '/':
			cout << a / b << endl;
			break;
		default:
			break;
		}
		if (e == 1){
			break;
		}
	}
}

Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int i = 0;
  int k = 0;
  int j = 0;
  int n;
  int input;
  int *num;
  int temp;

  scanf("%d", &n);
  num = (int *)malloc(n * sizeof(int));

  for(i = 0; i < n; i++){
    scanf("%d", &input);
    num[i] = input;
  }

  for(i = 0; i < n; i++){
    printf("%d", num[i]);
    if(i < n-1){
      printf(" ");
    }
  }
  printf("\n");

  for(i = 1; i < n; i++){
    for(k = i; k > 0; k--){
      if(num[k] < num[k-1]){
        temp = num[k-1];
        num[k-1] = num[k];
        num[k] = temp;
      }else {
        break;
      }
    }
    for(j = 0; j < n-1; j++){
      printf("%d ", num[j]);
    }
    printf("%d", num[n-1]);
    printf("\n");
  }
}

Measured memory_bytes: 2664
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;

int mem[1005][1005];

void pre(int x,int y){
  for(int i=0;i<=x;i++){
    for(int j=0;j<=y;j++){
      mem[i][j]=0;
    }
  }

  return;
}

main(){
  int n;
  string temp;
  string x,y;

  cin >> n;
  
  for(int cnt=0;cnt<n;cnt++){
    
    x="0";
    y="0";
    cin >> temp;
    x+=temp;
    cin >> temp;
    y+=temp;

    pre((int)x.size(),(int)y.size());

    for(int i=1;i<=x.size();i++){
      for(int j=1;j<=y.size();j++){

	if(x[i]==y[j]){
	  mem[i][j]=mem[i-1][j-1]+1;
	}
	mem[i][j]=max(mem[i][j],max(mem[i-1][j],mem[i][j-1]));

      }
    }

    cout << mem[x.size()][y.size()]-1 << endl;
  }

  return (0);
}



Measured memory_bytes: 7124
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


x,n = map(int,input().split())
if x == 1 and n == 1:
    print(1)
    exit()
fct = factorize(n)


divlist=[]
for div in divisorize(fct):
    divlist.append(num(div))

divlist.sort()
ans = 1
for i in range(0,len(divlist)):
    if divlist[i] <= n/x:
        ans = divlist[i]
print(ans)

Measured memory_bytes: 3188
// おなじ色で一列に並んだ個数をaとすると、その区間はa/2個色を変えればいいから、
// それぞれの区間のa/2を足す。
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    int prev = -1;
    int len = 1;
    while (N--) {
        int a;
        cin >> a;
        if (a != prev) {
            prev = a;
            ans += len / 2;
            len = 1;
        } else {
            ++len;
        }
    }
    ans += len / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int h,w;
	cin>>h>>w;
	if( h % 3 == 0 || w % 3 == 0 ){
		cout<<0<<endl;
		return 0;
	}
	int ans = min(h,w);
	for(int i=1;i<=h-1;i++){
		int p1 = w*i;
		int p2,p3;
		if( w%2==0 ){
			p2 = p3 = (h-i)*(w/2);
		}
		else{
			p2 = (h-i)*(w/2);
			p3 = (h-i)*(w/2+1);
		}
		int tmp = max( abs(p1-p2), max( abs(p1-p3), abs(p2-p3) ));
		if( ans > tmp ){
			ans = tmp;
			//cout<<tmp<<" "<<p1<<" "<<p2<<" "<<p3<<endl;
		}
	}
	for(int i=1;i<=w-1;i++){
		int p1 = h*i;
		int p2,p3;
		if( h%2==0 ){
			p2 = (w-i)*(h/2);
			p3 = (w-i)*(h/2);
		}
		else{
			p2 = (w-i)*(h/2);
			p3 = (w-i)*(h/2+1);
		}
		int tmp = max( abs(p1-p2), max(abs(p1-p3), abs(p2-p3) ));
		if( ans > tmp ){
			ans = tmp;
			//cout<<tmp<<" "<<p1<<" "<<p2<<" "<<p3<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())

M = []
for _ in range(N):
    A = int(input())
    state = []
    for _ in range(A):
        x, y = map(int, input().split())
        x -= 1
        state.append((x, y))
    M.append(state)

ans = 0
for mask in range(1 << N):
    can = True
    for i, s in enumerate(M):
        if (mask & (1 << i)) != 0:
            for x, y in s:
                v = 1 if (mask & (1 << x)) != 0 else 0
                if v != y:
                    can = False
                    break
    if can:
        cnt = 0
        for i in range(N):
            if (mask & (1 << i)) != 0:
                cnt += 1
        ans = max(ans, cnt)

print(ans)

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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i=0; i<N; i++){
    cin >> H.at(i);
  }
  H.at(0)--;
  for(int i=1; i<N; i++){
    if(H.at(i)>H.at(i-1)){
      H.at(i)--;
    }
  }
  for(int i=0; i<N-1; i++){
    if(H.at(i)>H.at(i+1)){
      cout << "No" << endl;
      goto finish;
    }
  }
  cout << "Yes" << endl;
  finish: N=0;
}

Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using ll = long long;
using P = pair<int, int>;

// --------------------------------------------------------------------------------

int f(int x)
{
    if (x % 100 != 0)
        return 0;
    return f(x / 100) + 1;
}

void solve()
{
    int d, n;
    cin >> d >> n;
    int cnt = 0;
    for (int i = 1;; i++)
    {
        if (d == f(i))
            cnt++;
        if (cnt == n)
        {
            cout << i << endl;
            return;
        }
    }
}

// --------------------------------------------------------------------------------

int main()
{
    // srand((unsigned)time(NULL));
    // int bt = clock();
    solve();
    // double et = 1.0 * (clock() - bt) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(){
  int n,m,l;
  scanf("%d %d %d",&n,&m,&l);
  if(n==m)printf("%d",l);
  if(n==l)printf("%d\n", m);
  if(m==l)printf("%d\n", n);
  return 0;
}


Measured memory_bytes: 128
n=int(input())
arr1=[0]*n
arr2=[0]*n
for i in range(n):
    x,y=map(int, input().split())
    arr1[i]=x+y
    arr2[i]=x-y

arr1=sorted(arr1)
p=arr1[-1]-arr1[0]
arr2=sorted(arr2)
q=arr2[-1]-arr2[0]
print(max(p,q))

Measured memory_bytes: 27000
import math

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

checked = [False]*N

def dfs(L, s):
    if len(L) == N:
        k = 0
        for i in range(len(L)-1):
            a1, b1 = XY[L[i]]
            a2, b2 = XY[L[i+1]]
            k += math.sqrt((a1-a2)**2+(b1-b2)**2)
        return s+k
    for i in range(N):
        if not checked[i]:
            checked[i] = True
            s = dfs(L+[i], s)
            checked[i] = False
    return s

ans = dfs([], 0)
for n in range(1, N+1):
    ans /= n
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

    ll n;
    cin>>n;
    ll ar[n],br[n-1];
    ll ans=0;
    for(ll i=0;i<n-1;++i)
    {
        cin>>br[i];
    }
    ar[0]=br[0];
    for(ll i=0;i<n-1;++i)
    {
        ar[i+1]=br[i];
        ar[i]=min(ar[i],br[i]);
    }
    for(ll i=0;i<n;++i){ans+=ar[i];}
    cout<<ans<<endl;

	return(0);
}


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

int digit(int i) {
  int cnt = 0;
  while (i > 0) {
    i /= 10;
    cnt++;
  }
  return cnt;
}

int main(){
  int a, b;
  while (cin >> a >> b) {
    cout << digit(a + b)  << endl;
  }
}


Measured memory_bytes: 3052
#include<stdio.h>
long long Dc(long long a)
{
    if(a<0) return -a;
    else    return a;
}
int main(void)
{
    long long n,i,x,num=0,num1=0,num2;
    scanf("%lld",&n);
    long long a[n];
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        num+=a[i];
    }
    x=Dc(num-2*a[0]);
    for(i=0;i<n-1;i++)
    {
        num1+=a[i];
        num2=num-num1;
        if(Dc(num1-num2)<x)    x=Dc(num1-num2);
    }
        printf("%lld\n",x);
        return 0;
}


Measured memory_bytes: 1664
import java.util.*;

public class Main {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		if (A-B-B >= 0) {
			System.out.println(A-B-B);
		} else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 23124