akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <class T>
struct segtree {
    int n;
    T ie = -1;
    vector<T> node;
    function<T(T, T)> f = [&](T a, T b) { return max(a, b); };

    segtree() : segtree(0) {}
    segtree(int _n) : segtree(vector<T>(_n, ie)) {}
    segtree(vector<T> v) {
        n = 1 << (32 - __builtin_clz((int)v.size() - 1));
        node.resize(2 * n - 1, ie);
        for (int i = 0; i < (int)v.size(); i++) {
            node[i + n - 1] = v[i];
        }
        for (int i = n - 2; i >= 0; i--) {
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    void update(int x, T v) {
        x += n - 1;
        node[x] = v;  // update
        // node[x] += v;  // add
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = f(node[2 * x + 1], node[2 * x + 2]);
        }
    }

    T get(int a, int b, int x, int l, int r) {
        if (r <= a || b <= l) {
            return ie;
        }
        if (a <= l && r <= b) {
            return node[x];
        }
        T vl = get(a, b, 2 * x + 1, l, (l + r) / 2);
        T vr = get(a, b, 2 * x + 2, (l + r) / 2, r);
        return f(vl, vr);
    }

    T get(int a, int b) {
        return get(a, b, 0, 0, n);
    }

    T get(int a) {
        return node[a + n - 1];
    }
};

template <class T>
string to_string(segtree<T> st) {
    vector<T> res(20);
    for (int i = 0; i < 20; i++) {
        res[i] = st.get(i);
    }
    return to_string(res);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int m = 300005;
    segtree<int> dp(vector<int>(m, 0));
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a++;
        int v = dp.get(max(a - k, 0), min(a + k + 1, m)) + 1;
        dp.update(a, v);
        debug(dp);
    }
    cout << dp.node[0] << '\n';
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)((a).size()))
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


inline void transpose(vector<string> &a) {

    int n = a.size();
    if (n == 0) return;
    int m = a[0].size();
    vector<string> b(m, string(n, ' '));
    fori (i, n) fori (j, m) b[j][i] = a[i][j];
    a = b;
}


template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    fori (i, SZ(a))
        out << a[i] << vector<string>{", ", "}"}[i + 1 == SZ(a)];
    return out;
}

void smain();

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


#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#define cerr cout
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\n";
    cout << "TOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}


const int N = 109, K = 1e5 + 9;
const int M = 1e9 + 7;

int dp[N][K];
int pref[N][K];
int a[N];

int get_pref(int i, int l, int r) {
    if (!l--) return pref[i][r];
    return (pref[i][r] - pref[i][l] + M) % M;
}

void smain() {

    dp[0][0] = 1;
    for (int i = 0; i < K; ++i) pref[0][i] = 1;

    int n, k;
    cin >> n >> k;
    fori (i, n) cin >> a[i + 1];
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= k; ++j) {
            int l = max(0, j - a[i]);
            dp[i][j] = get_pref(i - 1, l, j);
        }
        pref[i][0] = dp[i][0];
        for (int j = 1; j <= k; ++j) pref[i][j] = (dp[i][j] + pref[i][j - 1]) % M;
    }
    cout << dp[n][k];
}

Measured memory_bytes: 84224
#include <iostream>
#include <string>
#include <memory.h>
#include <algorithm>
#include <limits.h>
using namespace std;
const int MAXN = 2e5 + 10;
int dp[1<<26], state[MAXN];
int ret[MAXN];

int main() {
    memset(dp, -1, sizeof(dp));
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        state[i+1] = state[i];
        state[i+1] ^= 1<<(s[i]-'a');
    }
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        int cur = INT_MAX;
        for (int j = 0; j < 26; j++) {
            int tmp = (state[i] ^ (1<<j));
            if (dp[tmp] == -1) continue;
            cur = min(cur, dp[tmp] + 1);
        }
        if (dp[state[i]] != -1) {
            cur = min(cur, dp[state[i]] + 1);
        }
        ret[i] = cur;
        if (dp[state[i]] == -1) dp[state[i]] = cur;
        else dp[state[i]] = min(cur, dp[state[i]]);
    }
    cout << ret[n] << endl;


}

Measured memory_bytes: 264324
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int n;
  cin>>n;
  vin p(n);
  int m=0;
  ll ans=0;
  rep(i,0,n){
   cin>>p[i]; 
    m=max(m,p[i]);
    ans+=p[i];
  }
  cout<<ans-m/2<<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000500
using namespace std;
int n,L,a[N];
inline int rd() {int r;scanf("%d",&r);return r;}
int main() {
    n = rd(), L = rd();
    for (int i=1;i<=n;i++) a[i] = rd();

    int d = 0;
    for (int i=1;i<n;i++) if (a[i]+a[i+1] >= L) d = i;
    if (!d) {
        puts("Impossible");
    } else {
        puts("Possible");
        for (int i=1;i<d;i++) printf("%d\n",i);
        for (int i=n-1;i>d;i--) printf("%d\n",i);
        printf("%d\n",d);
    }

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define int long long
using namespace std;
signed main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        cout << s[i];
        if(i == 3) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from functools import lru_cache

import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


# @mt
def slv(N, A, B, C, D):
    @lru_cache(maxsize=None)
    def f(n):
        ans = n*D
        for i in range(-min(2, n), min(3, n)):
            m = n + i
            i = abs(i)
            if m == 0:
                continue

            if m % 5 == 0:
                ans = min(ans, f(m//5) + C + D*i)
            if m % 3 == 0:
                ans = min(ans, f(m//3) + B + D*i)
            if m % 2 == 0:
                ans = min(ans, f(m//2) + A + D*i)
        return ans

    return f(N)


def main():
    T = read_int()
    for _ in range(T):
        N, A, B, C ,D = read_int_n()
        print(slv(N, A, B, C, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 116556
#include<iostream>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

#define MAX 101000
int V,K;
vector<int> G[MAX];
vector<int> out_deg,depth,in_deg;

void dfs(int cur,int pre,int d) {
  assert( depth[cur] == 0 );
  depth[cur] = d;
  rep(i,(int)G[cur].size()) {
    int nex = G[cur][i];
    if( pre == nex ) continue;
    dfs(nex,cur,d+1);
  }
}

typedef pair<int,int> ii;
int main(){
  if( 0 ) {
    V = 100000;
    K = 100000;
    cout << V << " " << K << endl;
    rep(i,V) {
      cout << i << endl;
    }
    return 0;
  }
  cin >> V >> K;
  out_deg = vector<int>(V+1,0);
  in_deg = vector<int>(V+1,0);
  depth = vector<int>(V+1,0);
  rep(i,V) {
    int a;
    cin >> a;
    if( a == 0 ) continue;
    G[i+1].push_back(a);
    ++out_deg[i+1];
    ++in_deg[a];
  }
  rep(i,V+1) depth[i] = INT_MAX;
  deque<ii> deq;
  REP(i,1,V+1) {
    if( in_deg[i] == 0 )  {
      deq.push_back(ii(i,0));
      depth[i] = 0;
    }
  }

  while( !deq.empty() ) {
    ii v = deq.front(); deq.pop_front();
    int cur = v.first;
    int d   = v.second;
    rep(i,(int)G[cur].size()) {
      int nex = G[cur][i];
      if( depth[nex] > d + 1 ) {
	depth[nex] = d + 1;
	deq.push_back(ii(nex,d+1));
      }
    }
  }
  
  int cnt = 0;
  REP(i,1,V+1) {
    //cout << i << "-th : " << depth[i] << " in = " << in_deg[i] << ", out = " << out_deg[i];
    if( depth[i] < K || in_deg[i] == 0 || out_deg[i] == 0 ) {
      ++cnt;
      //cout << " +1";
    }
    //cout << endl;
  }
  cout << cnt << endl;
  return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    string s;
    cin >> s;

    int l = 0, r = s.size() - 1;

    bool b = true;
    int cnt = 0;

    while (l <= r) {
        if (s[l] == s[r]) {
            l++;
            r--;
        } else {
            if (s[l] == 'x' && s[r] != 'x') {
                l++;
                cnt++;
            } else if (s[l] != 'x' && s[r] == 'x') {
                r--;
                cnt++;
            } else {
                b = false;
                break;
            }
        }
    }

    if (b) {
        cout << cnt << endl;

    } else {
        cout << -1 << endl;
    }

    // vi a(26, 0);
    // rep(i, s.size()) {
    //     a[s[i] - 'a']++;
    // }

    // string ss = s;

    // reverse(ss.begin(), ss.end());

    // if (s == ss) {
    //     cout << 0 << endl;
    // } else {
    //     string s2;

    //     rep(i, s.size()) {
    //         if (s[i] != 'x') {
    //             s2 += s[i];
    //         }
    //     }

    //     string ss2 = s2;
    //     reverse(ss2.begin(), ss2.end());

    //     if (s2 == ss2) {
    //         int ans = 0;

    //         vi c(ss2.size() + 1, 0);
    //         int idx = 0;

    //         rep(i, s.size()) {
    //             if (s[i] == 'x') {
    //                 c[idx]++;
    //             } else if (s[i] == s2[idx]) {
    //                 idx++;
    //             }
    //         }

    //         for (int i = 0; i < c.size() / 2; i++) {
    //             int t1, t2;
    //             t1 = c[i];
    //             t2 = c[c.size() - 1 - i];

    //             ans += max(t1, t2) - min(t1, t2);
    //         }

    //         cout << ans << endl;

    //     } else {
    //         cout << -1 << endl;
    //     }
    // }
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  map<ll, ll> m;

  int N; cin >> N;
  ll sum = 0;
  for(int i = 0; i < N; i++){
    ll tmp; cin >> tmp;
    m[tmp]++;
    sum += tmp;
  }

  int Q; cin >> Q;
  while(Q--){
    ll b,c;
    cin >> b >> c;
    if(m.count(b) == 0 || m[b] == 0){
      cout << sum << endl;
    } else { 
      sum -= b * m[b];
      sum += c * m[b];
      cout << sum << endl;
      m[c] += m[b];
      m[b] = 0;
    }
  }
}


Measured memory_bytes: 8432
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

a, b, c, d = map(int, input().split())

if a == c or b == d:
    print(0)
    sys.exit(0)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

x = abs(a - c)
y = abs(b - d)

_gcd = gcd(x, y)
x2 = x // _gcd
y2 = y // _gcd

import math

print((x2 + y2 - 1) * _gcd)


Measured memory_bytes: 62112
#include<bits/stdc++.h>
using   namespace      std;
typedef long long      LL;
typedef vector<int>    VI;
typedef pair<int,int>  PII;

int main(){

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

	return 0;
}

Measured memory_bytes: 256
from collections import Counter
H,W=map(int,input().split())
a=[list(input()) for _ in range(H)]

tmp=[]
for j in a:
  for k in j:
    tmp.append(k)
d=dict(Counter(tmp))
#print(d)

odd=0
even_4=0
even_2=0
even_4_sum=0
odd_list=[]

for char in d:
    if d[char]%2==1:
        odd +=1
        odd_list.append(char)
    else:
        if d[char]%2==0:
            k= d[char]//4
            even_4 += k
            even_4_sum += k*4
            even_2 += (d[char]-4*k)//2
#print(odd,even_4,even_2)


ans="Yes"
if H==1 or W==1:
    m = max(H,W)
    if m%2==1:
        if odd !=1:
            ans="No"
    else:
        if odd >= 1:
            ans="No"
    
else:
    if H%2==0 and W%2==0:
        if odd>0 or even_2>0:
            ans="No"
    elif H%2==1 and W%2==1:
        if odd !=1:
            ans="No"
        else:
            s=d[odd_list[0]]
            u = s//4
            v = (s-u)//2  # s=4*u+2*v+1
            #print("even_4_sum",even_4_sum)
            #print(H,W,(H-1)*(W-1))
                  
            if even_4_sum+4*u< (H-1)*(W-1):
                ans="No"
            #else:
            #    even_4_amari = even_4_sum- (H-1)*(W-1)
            #    must_4_maxi = 4*(min(H,W)//2)
            #    print(even_4_amari, must_4_maxi)
            #    #must_4_mini = 4*(min(H,W)//2)
            #    if even_4_amari > must_4_maxi:
            #        ans="No"
                
    else:
        if odd >=1:
            ans="No"
        else:
            gu = H if H%2==0 else W
            if 2*even_2>gu:
                ans="No"

print(ans)

Measured memory_bytes: 3444
package main

import (
	"fmt"
)

func main() {
	var n int
	var k uint64

	fmt.Scan(&n)
	fmt.Scan(&k)
	a := make([]uint64, n, n)
	b := make([]int, 40, 40) // 2**39<10**12<2**40

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		for j := uint(0); j < 40; j++ {
			if a[i]&(1<<j) == 1<<j {
				b[j]++
			}
		}
	}

	op := uint64(0)
	for i := uint(0); i < 40; i++ {
		if b[i]*2 < n {
			op += 1 << i
		}
	}

	answer := uint64(0)
	for i := uint64(0); i <= 40; i++ {
		x1 := ((((1 << i) - 1) << (40 - i)) & k)
		x2 := (((1 << (40 - i)) - 1) & op)
		x := x1 + x2

		if x <= k {
			c := uint64(0)
			for j := 0; j < n; j++ {
				c += x ^ a[j]
			}
			if c > answer {
				answer = c
			}
		}
	}

	fmt.Println(answer)
}


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

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"

using namespace std;

# 1 "../Algo/NumberTheory/modulo.h" 1
class ModuloOps {
public:
    ModuloOps(long long mod): MOD(mod) {
    }

    long long binPow(long long a, long long b) {
        if (b == 0) {
            return 1;
        }
        auto prev = binPow(a, b/2);
        return mul(mul(prev, prev), b % 2 == 1 ? a : 1);
    }

    long long inv(long long a) {
        return binPow(a, MOD - 2);
    }

    inline long long add(long long a, long long b) {
        return (a + b) % MOD;
    }

    inline long long sub(long long a, long long b) {
        return (a - b + MOD) % MOD;
    }

    inline void inc(long long &a, long long b) {
        a = add(a, b);
    }

    inline long long mul(long long a, long long b) {
        return (a * b) % MOD;
    }

    inline long long div(long long a, long long b) {
        return mul(a, inv(b));
    }

private:
    long long MOD;
};
# 5 "<stdin>" 2

ModuloOps MOD(1e9+7);


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    int mx = max(a, b);
    vector<long long> fact(mx+1);
    fact[0] = 1;
    for (int i = 1; i < fact.size(); i++) {
        fact[i] = MOD.mul(fact[i-1], i);
    }
    auto C = [&] (int n, int k) {
        long long res = 1;
        for (int i = n-k+1; i <= n; i++) {
            res = MOD.mul(i, res);
        }
        return MOD.mul(res, MOD.inv(fact[k]));
    };
    long long ans = MOD.sub(MOD.binPow(2, n), 1 + MOD.add(C(n, a), C(n, b)));
    cout << ans << endl;
}


Measured memory_bytes: 1792
# coding: utf-8
import time
import re
import math

def main():
    n,start=map(int,input().split())
    X=list(map(int,input().split()))
    now=abs(X[0]-start)
    for xi in range(1,n):
        now=GCD(now,abs(X[xi]-start))
    print(now)
def GCD(a,b):
    if a%b==0:
        return b
    else:
        return GCD(b,a%b)
main()

Measured memory_bytes: 14504
S = input()
s = 'keyence'
if S[:7] == s or S[-7:] == s:
    print('YES')
    exit()

for i in range(1, 7):
    if S[:i] == s[:i] and S[-7 + i:] == s[i:]:
        print('YES')
        exit()
else:
    print('NO')


Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	a=a+b+c+d;
	cout<<a/60<<endl;
	cout<<a%60<<endl;
	return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> s(h);
  for (int i = 0; i < h; i++) cin >> s[i];

  vector<int> dh, dw;
  dh = {-1, 0, 0, 1};
  dw = {0, -1, 1, 0};

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        int c = 0;
        for (int k = 0; k < 4; k++) {
          int ni = i + dh[k], nj = j + dw[k];
          if (0 <= ni && ni < h && 0 <= nj && nj < w && s[ni][nj] != '#') c++;
          if (c == 4) {
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,n)for(i=0;i<n;i++)

int bit[100001], n, q, i;
int com, x, y; 
int sum(int i) {
	int s = 0;
	while (i > 0) {
		s += bit[i];
		i -= i&-i;
	}
	return s;
}
void add(int i, int x) {
	while (i <= n) {
		bit[i] += x;
		i += i&-i;
	}
}
int main() {
	scanf("%d%d", &n, &q);
	rep(i, q) {
		scanf("%d%d%d", &com, &x, &y);
		if (com) printf("%d\n", sum(y) - sum(x - 1));
		else add(x, y);
	}
	return 0;
}

Measured memory_bytes: 988
n = int(input())
L = [[0, 0, 0]]
for i in range(n):
    t, x, y = map(int, input().split())
    L.append([t,x,y])

flag = True
for i in range(n):
    delta_t = L[i+1][0] - L[i][0]
    dist = abs(L[i+1][1] - L[i][1]) + abs(L[i+1][2] - L[i][2])
    if delta_t < dist or delta_t % 2 != dist % 2:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 19532
int main() {
    
    int m, f, r, sum;
    
    while(1){
        scanf("%d %d %d", &m,&f,&r);
        
        if ((m == -1) && (f == -1) && (r == -1))    //m,r,f??¨???-1??\?????§??????
            break;
        sum = m + f;
        if ((m == -1) || (f == -1)){        //????????????????¬??????§F
            printf("F\n");
        }
        else if (sum >= 80){          //A
            printf("A\n");
        }
        else if ((sum >= 65) && (sum < 80)){        //B
            printf("B\n");
        }
        else if ((sum >= 50) && (sum < 65)){        //c
            printf("C\n");
        }
        else if ((sum >= 30) && (sum < 50)){        //D
            if (r >= 50){
                printf("C\n");          //????????????  C
            }else{                      //????????????  D
                printf("D\n");
            }
        }
        else if (sum < 30){        //F
            printf("F\n");
        }
    }
    return 0;
}

Measured memory_bytes: 584
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

ll N, M;

int main() {
    cin >> N >> M;

    multiset<ll, greater<ll>> price;
    REP(i,N) {
        ll a;
        cin >> a;
        price.insert(a);
    }
    ll i=0;
    while(i<=M) {
        auto x = price.begin();
        ll first = *x;
        price.erase(x);
        ll second = *price.begin();
        for(ll j = 1; (i+j) <= M;j++) {
            ll temp = first / pow(2, j);
            if(second >= temp) {
                price.insert(temp);
                i += j;
                break;
            }
        }

        if(i==M) {
            break;
        }
    }
    ll ans = 0;

    for(auto it = price.begin();it!=price.end();it++) {
        ans += *it;
    }
    print(ans);
    return 0;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int x=1,y=n;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		x=max(x,a);
		y=min(y,b);
	}
	cout<<max(y-x+1,0);
}

Measured memory_bytes: 256
import sys

# お約束
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def parse(args, *params):
    return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
    if __debug__:
        print(*v, file=sys.stderr)

# エントリーポイント
def main(args):
    N, K = parse(args, int, int)
    A = tuple(map(int, next(args).split()))

    MAX_DIG = 60
    bind, mask = True, 0
    for dig in reversed(range(MAX_DIG)):
        count = [0, 0]
        for a in A:
            count[(a & 1 << dig) != 0] += 1
        if bind:
            if count[1] < count[0]:
                if K & (1 << dig):
                    mask += 1 << dig
            else:
                if K & (1 << dig):
                    bind = False
        else:
            if count[1] < count[0]:
                mask += 1 << dig
    debug(mask)
    res = 0
    for a in A:
        res += a ^ mask
    print(res)

if __name__ == '__main__':
    main(iter(sys.stdin.read().split("\n")))


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

long long x[100000];
long long v[100000];
long long cw[100000];
long long ccw[100000];

int main() {
	long long N, C;
	scanf("%lld %lld", &N, &C);
	for (int i=0; i<N; i++) {
		scanf("%lld %lld", x+i, v+i);
	}

	long long ans = 0;

	long long sum = 0;
	for (int i=0; i<N; i++) {
		sum += v[i];
		cw[i] = max(i ? cw[i-1] : 0ll, sum - x[i]);
	}

	ans = cw[N-1];

	long long rsum = 0;
	for (int i=N-1; i>=0; i--) {
		rsum += v[i];
		ans = max(ans, (i ? cw[i-1] : 0) + rsum - (C-x[i])*2ll);
	}

	long long sum2 = 0;
	for (int i=N-1; i>=0; i--) {
		sum2 += v[i];
		ccw[i] = max(i==N-1 ? 0ll : ccw[i+1], sum2 - (C - x[i]));
	}

	ans = max(ans, ccw[0]);

	long long rsum2 = 0;
	for (int i=0; i<N; i++) {
		rsum2 += v[i];
		ans = max(ans, (i==N-1 ? 0ll : ccw[i+1] + rsum2 - x[i]*2ll));
	}

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


Measured memory_bytes: 3328
import sys
def input():
    return sys.stdin.readline()[:-1]
s=input()
if s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
elif s=="FRI":
    print(2)
elif s=="SAT":
    print(1)


Measured memory_bytes: 38384
N,M = map(int,input().split())

l = [0 for i in range(N)]

for i in range(M):
	a,b = map(int,input().split())
	l[a-1] += 1
	l[b-1] += 1

for i in l:
	if i%2 == 1:
		print("NO")
		break
else:
	print("YES")

Measured memory_bytes: 3888
#include <iostream>
#include <map>
using namespace std;
int main(void){
    // Your code here!
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(A>0 && C>0){
        C-=B;
        if(C>0){
            A-=D;
        }
    }
    if (A>C) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

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

const int INF=(1<<20);

int n;
vector<pair<int,int> >l[10000];
 
void dijkstra();

int main(){
  int k,u,v,c;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      l[u].push_back(make_pair(v,c));
    }
  }
  
  dijkstra();

  return(0);
}

void dijkstra(){
  priority_queue<pair<int,int> >pq;
  int sn[10000];
  int d[10000];
  for(int i=0;i<n;i++){
    d[i]=INF;
    sn[i]=0;
  }
  
  d[0]=0;
  pq.push(make_pair(0,0));

  while(!pq.empty()){
    pair<int,int> f=pq.top();
    pq.pop();
    int u=f.second;
    sn[u]=1;

    if(d[u]<f.first*(-1))continue;
      
      for(int j=0;j<l[u].size();j++){
	int v=l[u][j].first;
	if(sn[v]==1)continue;

	if(d[v]>d[u]+l[u][j].second){
	  d[v]=d[u]+l[u][j].second;
	  pq.push(make_pair(d[v]*(-1),v));
	}

	
      }
    
  }

  for(int i=0;i<n;i++){
    cout<<i<<" ";
    if(d[i]==INF)cout<<"-1"<<endl;
    else cout<<d[i]<<endl;
  }
}

Measured memory_bytes: 6304
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
	int n;
	string s;
	vector<string> w;
	cin >> n;
	int n2;
	for(int i = 0;i < n;i++){
		cin >> s;
		w.push_back(s);
	}
	for(int i = 1;i < n;i++){
		n2 = w[i - 1].size();
		if(w[i][0] != w[i - 1][n2 - 1]){
			cout << "No" << endl;
			return 0;
		}
	}
	for(int i = 0;i < n - 1;i++){
		for(int j = i + 1;j < n;j++){
			if(w[i] == w[j]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,m,l,i,j,k;
  scanf("%d %d %d",&n,&m,&l);
  int a[n][m];
  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      scanf("%d",&a[i-1][j-1]);
    }
  }
  int b[m][l];
  for(i=1;i<=m;i++){
    for(j=1;j<=l;j++){
      scanf("%d",&b[i-1][j-1]);
    }
  }
  long c[n][l]; //??????c???????´?????¨????
  for(i=1;i<=n;i++){
    for(j=1;j<=l;j++){
      c[i-1][j-1]=0;
      for(k=1;k<=m;k++){
        c[i-1][j-1] += a[i-1][k-1] * b[k-1][j-1];
      }
    }
  }
  for(i=1;i<=n;i++){
    printf("%ld",c[i-1][0]);
    for(j=2;j<=l;j++){
      printf(" %ld",c[i-1][j-1]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int a, b;
    cin >> a >> b;
    if (abs(a - b) % 2 == 1) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << min(a, b) + abs(a - b) / 2 << endl;
    }
}

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


Measured memory_bytes: 3648
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

long long int func(long long int x){
	int cnt=0;
	while(x%2==0){
		cnt++;
		x=x/2;
	}
	return cnt;
}

int main(){
	int N;
	cin>>N;
	vector<long long int> a(N);
	long long int ans=0;
	for(int i=0;i<N;i++){
		cin>>a[i];
		ans+=func(a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli x,a,b;
    cin3(x,a,b);
    x -= a;
    while (true) {
        if (x < 0)
            break;
        x -= b;
    }
    cout << x+b << endl;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;



int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll> e(n,0),w(n,0);
    if(s[0]=='W'){w[0]=1;}
    for(int i=1;i<n;i++){
        w[i]=w[i-1];
        if(s[i]=='W'){w[i]++;}
    }
    if(s[n-1]=='E'){e[n-1]=1;}
    for(ll i=n-2;i>=0;i--){
        e[i]=e[i+1];
        if(s[i]=='E'){e[i]++;}
    }
    ll mi=min(e[1],w[n-1]);
    for(int i=1;i<n-1;i++){
        mi=min(mi,w[i-1]+e[i+1]);
    }
    cout<<mi<<endl;
    
    return 0;
}


Measured memory_bytes: 5380
#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <iomanip>
using namespace std;

int main()
{
	int a, b, c;
	char ch;

	cin >> a >> ch >> b;

	switch (ch) {
	case '+':
		c = a + b;
			break;
	case '-':
		c = a - b;
		break;
	default:
		break;
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	double a,b,c,degree,S;
	scanf("%lf %lf %lf",&a,&b,&degree);
	S = (0.5)*a*b*sin(M_PI*degree/180);
	c = sqrt(a*a+b*b-2*a*b*cos(M_PI*degree/180));
	printf("%.8lf\n",S);
	printf("%.8lf\n",a+b+c);
	printf("%.8lf\n",2*S/a);
}



Measured memory_bytes: 2916
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include <cstring>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll s;
  cin >> s;
  vector<ll> vec;
  ll x;
  vec.push_back(s);
  REP(i,1,1000000){
    if(vec[i-1] % 2 == 0){
      x = vec[i-1]/2;
    }else{
      x = 3 * vec[i-1]+1;
    }
    if(count(all(vec),x) > 0){
      cout << i+1;
      break;
    }else{
      vec.push_back(x);
      //sort(all(vec));
    }
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<long long> X(N),Y(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i);
    Y.at(i) = X.at(i);
  }
  sort(Y.begin(),Y.end());
  
  long long left,right;
  right = Y.at(N/2);
  left = Y.at(N/2-1);
  
  for( int i=0;i<N;i++){
    if(X.at(i) < right) cout << right << endl;
    else cout << left << endl;
  }  
}

Measured memory_bytes: 5376
from itertools import permutations 
inf=10**9
n, m, r1 = map(int, input().split())
r=list(map(int, input().split()))
abc=[list(map(int, input().split())) for _ in range(m)]
d=[[inf]*n for i in range(n)]
for ai, bi, ci in abc:
    d[ai-1][bi-1]=ci
    d[bi-1][ai-1]=ci
for k in range(n):
    for i in range(n-1):
        for j in range(i, n):
            dk=d[i][k]+d[k][j]
            if d[i][j]>dk:
                d[j][i]=dk
                d[i][j]=dk
permutations(r)
ans=inf
for pi in permutations(r):
    res=0
    for i in range(r1-1):
        res+=d[pi[i]-1][pi[i+1]-1]
    if ans>res:
        ans=res
print(ans)

Measured memory_bytes: 10188
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
 
 
int main() {
	ios::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
 
	ll a, b, c;
 
	cin >> a >> b >> c;
 
 
	cout << c << " " << a << " " << b;
	
 
 
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long ans;
		ans = n / (a + b);
		ans = ans * a;
		n = n % (a + b);
		ans += Math.min(a, n);
		System.out.println(ans);
		sc.close();
	}
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll n, ans = 0;
map<ll, ll> mp;

signed main() {
  cin >> n;
  rep(i, 0, n * 3) {
    int a;
    cin >> a;
    mp[a]++;
  }
  int c = 0;
  for(map<ll, ll>::reverse_iterator it = mp.rbegin(); it != mp.rend(); it++) {
    for(int i = 0; i < it->second; i++) {
      c++;
      if(c > n * 2) break;
      if(c % 2 == 0) ans += it->first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,m,num=0;
    double a[1009],sum=0,tmp;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i],sum+=a[i];
    tmp=sum/4/m;
    for(int i=1;i<=n;i++)
        if(a[i]>=tmp)
        num++;
    if(num>=m)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n+1];
	int count=0;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		if(a[i]!=i) count++;
	}
	cout << (count>2? "NO": "YES");
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 10 03:11:43 2019

@author: Atsushi
"""

a,b = map(int,input().split())
mat = []

for i in range(a):
    mat.append(list(map(int,input().split())))
    
vec = []
for i in range(b):
    vec.append(int(input()))
    
for i in range(a):
    ans = 0
    
    for j in range(b):
       ans += mat[i][j] * vec[j]
    print(ans)


Measured memory_bytes: 6024
#include <iostream>

using namespace std;

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		for (int j = N-1; j >= i+1; j--) {
			if (A[j].value < A[j - 1].value) {
				Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
			}

		}
	}
}

void selection(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j].value < A[minj].value) minj = j;
		}
		Card t = A[i]; A[i] = A[minj]; A[minj] = t;
	}
}

void print(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

//バブルソートと選択ソートの結果を比較
bool isStable(struct Card C1[], struct Card C2[], int N) {
	for (int i = 0; i < N; i++) {
		if (C1[i].suit != C2[i].suit) return false;

	}
	return true;

}

int main() {
	Card C1[100], C2[100];
	int N;
	char ch;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C1[i].suit >> C1[i].value;
	}

	for (int i = 0; i < N; i++) C2[i] = C1[i];

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if (isStable(C1, C2, N)) {
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}

	return 0;
}


Measured memory_bytes: 3108
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Collections;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int k = Integer.parseInt(in.next());

            LinkedList<Long> A = new LinkedList<>();

            for (long i = 1; i < 10; i++) {
                dfs(1, i, A);
            }

            Collections.sort(A);
            // 出力
            out.println(A.get(k - 1));

        }

        public static void dfs(Integer keta, Long val, LinkedList<Long> A) {
            A.offerLast(val);
            if (keta == 10) {

                return;
            }

            for (int i = -1; i <= 1; i++) {
                long add = (val % 10) + i;
                if (0 <= add && add <= 9) dfs(keta + 1, val * 10 + add, A);
            }
        }

    }
}



Measured memory_bytes: 37388
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    ll h,w;
    cin >> h >> w;

    if(h%3 == 0 || w%3 == 0){
        cout << 0 << endl;
        return 0;
    }
    ll smax = 0;
    ll smin = INFL;
    ll dif = INFL;
    ll h1,h2,h3;
    ll w1,w2,w3;
    for(ll i = 1; i < h; ++i){
        h1 = i;
        h2 = (h - h1) / 2;
        h3 = h - h1 - h2;
        w1 = w / 2;
        w2 = w - w1;
        ll sa = h1 * w;
        ll sb = h2 * w;
        ll sc = h3 * w;
        smax = max({sa, sb, sc});
        smin = min({sa, sb, sc});
        dif = min(dif, smax - smin);

        sa = h1 * w;
        sb = (h - h1) * w1;
        sc = (h - h1) * w2;
        smax = max({sa, sb, sc});
        smin = min({sa, sb, sc});
        dif = min(dif, smax - smin);
    }

    for(ll i = 1; i < w; ++i){
        w1 = i;
        w2 = (w - w1) / 2;
        w3 = w - w1 - w2;
        h1 = h / 2;
        h2 = h - h1;
        ll sa = w1 * h;
        ll sb = w2 * h;
        ll sc = w3 * h;
        smax = max({sa, sb, sc});
        smin = min({sa, sb, sc});
        dif = min(dif, smax - smin);

        sa = w1 * h;
        sb = (w-w1) * h1;
        sc = (w-w1) * h2;
        smax = max({sa, sb, sc});
        smin = min({sa, sb, sc});
        dif = min(dif, smax - smin);
    }

    cout << dif << endl;
    return 0;
}

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

int main() {
  int N, n, s = 0, p = 100000000, q;
  cin >> N;
  n = N;
  for (int i = 0; i < 9; i++) {
    q = n / p;
    s += q;
    n -= q * p;
    p /= 10;
  }
  if (N % s == 0) {
    cout << "Yes";
  }
  else {
	cout << "No";
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long i,a,b;
string st;
int main()
{
	cin>>st;
	for(i=0;i<st.size();i++)
	{
		if(st[i]=='C')a=1;
		if(st[i]=='F'&&a==1)b=1;
	}
	if(a+b==2) cout<<"Yes";else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	sort(all(v));
	dump(v);
	int ans = 0;
	int maxi = v.back();
	vector<int> sum = v;
	rep(i, 0, N - 1)sum[i + 1] += sum[i];
	dump(sum);
	rrep(i, 0, N) {
		if (sum[i] * 2 >= maxi) {
			maxi = v[i];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            int[] b = new int[n];
            int[] c = new int[n];
            for (int i = 0; i < n; ++i) a[i] = in.nextInt();
            for (int i = 0; i < n; ++i) b[i] = in.nextInt();
            for (int i = 0; i < n; ++i) c[i] = in.nextInt();

            Arrays.sort(a);
            Arrays.sort(b);
            Arrays.sort(c);

            long[] dp1 = new long[n];
            Arrays.fill(dp1, 0);
            int u = 0;
            for (int d = 0; d < n; ++d) {
                while (u < n && a[u] < b[d]) ++u;
                if (d == 0) {
                    dp1[d] = u;
                } else {
                    dp1[d] = dp1[d - 1] + u;
                }
            }

            u = 0;
            long res = 0;
            for (int d = 0; d < n; ++d) {
                while (u < n && b[u] < c[d]) ++u;
                if (u > 0) {
                    res += dp1[u - 1];
                }
            }

            out.println(res);
        }

    }
}



Measured memory_bytes: 95624
N = gets.to_i
T, A = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)

ans = Float::INFINITY
min_diff = Float::INFINITY

H.each.with_index(1) do |h, i|
  diff = (A - (T - h * 0.006)).abs

  if min_diff > diff
    min_diff = diff
    ans = i
  end
end

puts ans


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

const int MAX_N = 50;
const int MAX_M = 50;
int N, M;
char A[MAX_N][MAX_N + 1], B[MAX_M][MAX_M + 1];

int solve() {
  int count = 0;
  REP(i, N - M + 1) REP(j, N - M + 1) {
    if (A[i][j] == B[0][0]) {
      REP(k, M) REP(l, M) {
        count++;
        if (A[i + k][j + l] != B[k][l]) count = 0;
        if (count == M * M) return 1;
      }
    }
  }
  return 0;
}

main() {
  cin >> N >> M;
  REP(i, N) cin >> A[i];
  REP(i, M) cin >> B[i];
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char x[11];
    int count=0,i;
    scanf("%s",&x);
    int len=strlen(x);
    if(len%2==1) printf("No\n");
    else
    {
        for(i=0; i<len; i++)
        {
            if(i%2==0 && x[i]!='h')
            {
                count=1;
                break;
            }

            else if(i%2==1 && x[i]!='i')
            {
                count=1;
                break;

            }

        }
        if(count==0)
            printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, m = map(int,input().split())
ab = []
for i in range(n):
    ab.append([int(i) for i in input().split()])
cd = []
for i in range(m):
    cd.append([int(i) for i in input().split()])

for i in range(n):
    inf = pow(10, 15)
    for j in range(m):
        if abs(cd[j][0] - ab[i][0]) + abs(cd[j][1] - ab[i][1]) < inf:
            inf = abs(cd[j][0] - ab[i][0]) + abs(cd[j][1] - ab[i][1])
            ans = j + 1
    print(ans)


Measured memory_bytes: 3064