akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

ll mul(ll a, ll b)
{
    ll res = 0;
    while(b > 0)
    {
        if(b & 1)
            res = (res + a) % mod;
        a = (a + a) % mod;
        b = b / 2;
    }
    return res%mod;
}

void cp()
{
    int n, k;
    cin >> n >> k;
    vector<ll> arr(n);
    for(ll &x : arr)
        cin >> x;
    ll res = 1;
    sort(all(arr));
    // If we have to pick odd amount and largest number is 0
    // It is better to have answer = 0 than answer = -ve
    if(arr.back() == 0 && (k & 1))
    {
        cout << 0;
        return;
    }
    // If Numbers are less than zero and we have to pick odd numbers
    // Answer is going to be -ve/zero
    // Pick largest k -ve numbers
    if (arr.back() <= 0 && (k & 1))
    {
        for (int i = n - 1; i >= n - k; i--)
            res = mul(res, (arr[i] + mod) % mod);
        cout << res;
        return;
    }
    int i = 0;
    int j = n - 1;
    // If we have to pick odd numbers just pick 1 +ve number
    if (k & 1)
    {
        res = (arr[j]) % mod;
        j--;
        k--;
    }
    // Else we can pick -ve numbers and +ve numbers in pairs greedily deciding which one to keep
    k /= 2;
    for (int it = 0; it < k; it++)
    {
        ll lp = arr[i] * 1LL * arr[i + 1];
        ll rp = arr[j] * 1LL * arr[j - 1];
        if (lp > rp)
        {
            res = mul(res, (lp + mod) % mod);
            i += 2;
        }
        else
        {
            res = mul(res, (rp + mod) % mod);
            j -= 2;
        }
    }
    cout << res;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 4768
#include <iostream>

using namespace std;

int main(){
     int data[10000], i;
     while(1){
         cin >> data[i];
         if(data[i]==0)
            break;
        i++;
     }
     for(int j=0; j<i; j++){
         cout << "Case " << j+1 << ": " << data[j] << endl;
     }
     return 0;
}

Measured memory_bytes: 3028
#include<stdio.h>
int main()
{
    int n,i,j;
    scanf("%d",&n);
    int a[n],s[n];
    s[n-1]=0;
    for(int i=0;i<n-1;i++)
    {
        s[i]=0;
        scanf("%d",&a[i]);
    }
    for( i=0;i<n-1;i++)
    {
        s[a[i]-1]++;

    }
    for( i=0;i<n;i++)
    {
        printf("%d\n",s[i]);
    }
    return 0;


}


Measured memory_bytes: 3288
N, K = map(int, input().split())
a = 7*N // 11
ans = a
for i in range(a*11+1, 7*N+1):
    if 9*i % 11 == K:
        ans += 1

ans -= N//11*2
for i in range(N//11*11, N):
    if (7*i + 1)*9 % 11 == K:
        ans -= 1
    if (7*i + 7)*9 % 11 == K:
        ans -= 1
for i in range(2, 7):
    if i*9 % 11 == K:
        ans -= 1
    if N > 1 and (7*N + i - 7)*9 % 11 == K:
        ans -= 1
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	ll n, k;
	cin >> n >> k;
	vi a(n);
	cin >> a;
	for(int &x : a)
		x--;
	vi v;
	int cur = 0;
	v.push_back(0);
	map<int, int> m;
	m[0] = 0;
	while(!m.count(a[cur]))
	{
		cur = a[cur];
		v.push_back(cur);
		m[cur] = v.size() - 1;
	}
	if(v.size() >= k + 1)
		ret(v[k] + 1);
	// cerr << v << '\n';
	cur = a[cur];
	k -= v.size();
	int s = m[cur], t = v.size() - 1;
	// cerr << s << ' ' << t << ' ' << k << '\n';
	k %= t - s + 1;
	// cerr << k << '\n';
	ret(v[s + k] + 1);
}


Measured memory_bytes: 13916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(ll n){
    cout << n << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll d(n);
    rep(i, n){
        cin >> d[i];
    }
    d.emplace_back(0);
    n++;
    sort(ALL(d));
    vll cnt(13, 0);
    rep(i, n){
        cnt[d[i]]++;
    }
    if(cnt[0] >= 2) pr(0);
    if(cnt[12] >= 2) pr(0);
    repr(i, 1, 12){
        if(cnt[i] >= 3) pr(0);
    }
    vll prob;
    ll c = 0;
    rep(i, n){
        if(d[i] > 0 && d[i] < 12 && cnt[d[i]] == 1){
            c++;
            prob.emplace_back(d[i]);
        }
    }
    rep(i, n){
        if(d[i] == 0 || d[i] == 12){
            prob.emplace_back(d[i]);
        }
    }
    repr(i, 1, 12){
        if(cnt[i] == 2){
            prob.emplace_back(i);
            prob.emplace_back(24-i);
        }
    }
    ll m = 1ll << c;
    ll ans = 0;
    rep(i, m){
        vll e{prob};
        rep(j, c){
            if((i >> j) & 1){
                e[j] = 24 - e[j];
            }
        }
        dump(e);
        sort(ALL(e));
        ll tmp = INF;
        rep(i, n-1){
            chmin(tmp, e[i+1]-e[i]);
        }
        chmin(tmp, e[0]-e[n-1]+24);
        chmax(ans, tmp);
    }
    pr(ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>;
int main(){
	int a,b,c,count;
	while(scanf("%d %d",&a,&b)!=EOF){
		c=a+b;
		count=1;
		while(c>=10){
			c/=10;
			count++;
		}
		printf("%d\n",count);
	}
return 0;
}

Measured memory_bytes: 0
# AtCoder Beginner Contest 132
# C - Divide the Problems

N=int(input())
d=list(map(int,input().split()))

d.sort()

l=d[(N//2)-1]
r=d[(N//2)]
if l==r:
    print(0)
    exit()

print(r-l)

# print(d)
# print(l,r)



Measured memory_bytes: 20536
<?php
/*
    http://code-festival-2016-quala.contest.atcoder.jp/tasks/codefestival_2016_qualA_c

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// a 097
// z 122

fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%d", $K);
$arr = str_split($s);
$len = strlen($s);
$num = array();
foreach ($arr as $key => $val) {	
	// echo ord($val). PHP_EOL;
	$num[$key] = 123 - ord($val);
	if ($num[$key] == 26) $num[$key] = 0;
}
$allA = true;
for ($i = 0; $i < $len; $i++) {
	if ($num[$i] <= $K) {
		$arr[$i] = 'a';
		$K -= $num[$i];
		// echo $K . PHP_EOL;
	} else {
		$allA = false;
	}
}

if ($allA === true) {
	$K %= 26;
}
$arr[$len-1] = chr(ord($arr[$len-1]) + $K);
$K -= $K;

if (ord($arr[$len-1]) >= 123) {
	$arr[$len-1] = chr(ord($arr[$len-1]) - 26);
};

echo implode("", $arr) . PHP_EOL;
// var_dump($allA);
// echo $K;


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

char s[maxn];
int n;

int main() {
    scanf("%s",s+1);int cnt=0;ll ans=0;n=strlen(s+1);
    for(int i=1;i<=n;i++)
        if(s[i]=='A') cnt++;
        else if(s[i]=='B') {
            if(s[i+1]=='C') i++,ans+=cnt;
            else cnt=0;
        } else cnt=0;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > v;
    rep(i, 1, m) {
        int s, c;
        cin >> s >> c;
        v.pb({s, c});
    }
    int hi = 1;
    rep(i, 1, n) {
        hi *= 10;
    }
    hi--;
    rep(i, 0, hi) {
        string s = to_string(i);
        if(s.size() != n) continue;
        bool ok = true;
        rall(p, v) {
            if(s[p.fi - 1] - '0' != p.se) {
                ok = false;
                break;
            }
        }
        if(!ok) continue;
        cout << i << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#define MAX 10000
#define NIL -1

typedef struct {
	int p, l, r;
} Node;

Node T[MAX];
int n;

void preParse(int u) {
	if (u == NIL) return;
	printf(" %d", u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u) {
	if (u == NIL) return;
	inParse(T[u].l);
	printf(" %d", u);
	inParse(T[u].r);
}

void posParse(int u) {
	if (u == NIL) return;
	posParse(T[u].l);
	posParse(T[u].r);
	printf(" %d", u);
}

int main() {
	int i, v, l, r, root;

	scanf("%d", &n);
	for (i = 0; i < n; i++) T[i].p = NIL;

	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].l = l;
		T[v].r = r;
		if (l != NIL) T[l].p = v;
		if (r != NIL) T[r].p = v;
	}
	
	for (i = 0; i < n; i++) {
		if (T[i].p == NIL) {
			root = i;
		}
	}

	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	posParse(root);
	printf("\n");

	return 0;
}


Measured memory_bytes: 2104
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	sc.Split(bufio.ScanWords)

	var x, y string

	x = nextStr()
	y = nextStr()

	if x < y {
		fmt.Println("<")
	} else if x == y {
		fmt.Println("=")
	} else {
		fmt.Println(">")
	}
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int count = 0;
  for(int i = 1; i < 4; i++){
    if(s.at(i-1) == s.at(i)){
      count++;
    }
  }
  if(count > 0){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;

const int N=100000+5;
int n,v[N];

bool ok(int ind)
{
    ll cur=v[ind];
    for(int j=n;j>=1;j--)
    {
       // cout<<cur<<" "<<j<<"\n";
        if(j==ind)
            continue;
        if(2*cur<v[j])
            return 0;
        cur+=v[j];
    }
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    reverse(v+1,v+n+1);
    int r=0,pas=(1<<30);
    while(pas)
    {
        if(r+pas<=n && ok(r+pas))
            r+=pas;
        pas/=2;
    }
    cout<<r<<"\n";
    return 0;
}


Measured memory_bytes: 640
n, w = list(map(int, raw_input().split()))
weights = []
values = []

for _ in range(n):
    wi, vi = list(map(int, raw_input().split()))
    weights.append(wi)
    values.append(vi)

dp = [[0 for __ in range(w+1)] for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, w+1):
        dp[i][j] = max(dp[i-1][j], dp[i-1][j-weights[i-1]] + values[i-1] if weights[i-1] <= j else 0)

print(dp[n][w])

Measured memory_bytes: 151452
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int dp[1001][1001];
int q;

void solve(){
  char x[1001],y[1001];
  scanf("%s %s",x,y);
  int lx = strlen(x);
  int ly = strlen(y);
  for(int i=0;i<=lx;i++){
    for(int j=0;j<=ly;j++){
      if(i==0||j==0) dp[i][j] = 0;
      else if(x[i-1]==y[j-1]) dp[i][j] = dp[i-1][j-1]+1;
      else dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
    }
  }
  printf("%d\n",dp[lx][ly]);
  return;
}


int main(){
  scanf("%d",&q);
  for(int i=0;i<q;i++) solve();
  return 0;
}

Measured memory_bytes: 4940
#include<bits/stdc++.h>
using namespace std;
const unsigned int mod = 1000000007; 

int main(){
    int h, w;
    long long int ans;
    char inp;
    cin >> h >> w;
    vector<vector<char> > grid(h , vector<char> (w));
    vector<vector<long long int> > dp(h , vector<long long int> (w, 0));

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> inp; 
            grid[i][j] = inp;
        }
    }
    
    for(int i=0;i<w;i++)
        if(grid[0][i] == '#')
            break;
        else
            dp[0][i] = 1;
    
    for(int i=0;i<h;i++)
        if(grid[i][0] == '#')
            break;
        else
            dp[i][0] = 1;

    for(int i=1;i<h;i++)
        for(int j=1;j<w;j++)
            if(grid[i][j] == '.')
                dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;

    cout << dp[h-1][w-1] << "\n";
    return 0;
}

Measured memory_bytes: 9088
# Problem D - Remainder Reminder

# input
N, K = map(int, input().split())

# initialization
class_count = 0
for i in range(1, N+1):
    c_1 = (N//i) * max(0, i-K)
    c_2 = max(0, (N%i + 1 - K))

    class_count += c_1 + c_2

if K==0:
    class_count -= N
# output
print(class_count)


Measured memory_bytes: 39792
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const ll MOD=1e9+7;

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

    int n;
    cin >> n;
    vector<vector<int>> r(n);
    rep(i,n) {
        int u,k,v;
        cin >> u >> k;
        rep(j,k) {
            cin >> v;
            r[i].push_back(v-1);
        }
    }
    queue<int> q;
    vector<int> cost(n,-1);
    q.push(0);
    cost[0]=0;
    while (!q.empty()) {
        int now=q.front();
        q.pop();
        rep(i,r[now].size()) {
            int next=r[now][i];
            if (cost[next]==-1) {
                cost[next]=cost[now]+1;
                q.push(next);
            }
        }
    }
    rep(i,n) cout << i+1 << ' ' << cost[i] << endl;
    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define OPEN 0
using namespace std;
vector<int> cost;
vector<int> val;
const int MAXN = 3010;
int dp[MAXN][2 * MAXN];
int dp2[MAXN][2 * MAXN];
int main() {
#if OPEN
	freopen("in.txt", "r", stdin);
#endif
	int n, t; cin >> n >> t;
	cost.assign(n, 0);
	val.assign(n, 0);
	for (int i = 0; i<n; i++) {
		cin >> cost[i] >> val[i];

	}
	memset(dp, 0, sizeof(dp));
	memset(dp2, 0, sizeof(dp2));
	for(int j=cost[0];j<t;j++)
	dp[0][j] = val[0];
	for (int i = 1; i<n; i++)
		for (int j = 0; j<t; j++) {
			dp[i][j] = dp[i - 1][j];
			if ((j - cost[i] >= 0)) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - cost[i]] + val[i]);
			}
		}
	reverse(cost.begin(), cost.end());
	reverse(val.begin(), val.end());
	for (int j = cost[0]; j<t; j++)
	dp2[0][j] = val[0];
	for (int i = 1; i<n; i++)
		for (int j = 0; j<t; j++) {
			dp2[i][j] = dp2[i - 1][j];
			if ((j - cost[i] >= 0)) {
				dp2[i][j] = max(dp2[i][j], dp2[i - 1][j - cost[i]] + val[i]);
			}
		}
	int ans = dp[n - 1][t - 1];
	reverse(cost.begin(), cost.end());
	reverse(val.begin(), val.end());

	for (int i = 0; i<n; i++)
		for (int j = 0; j<t; j++)
			if (!i) {
				ans = max(ans, dp2[n - 2][t - 1] + val[0]);
			}
			else if (i == n - 1) {
				ans = max(ans, dp[n - 2][t - 1] + val[n - 1]);
			}
			else {
				//cerr << ans << endl;
				ans = max(ans, dp[i - 1][j] + dp2[n - 2 - i][t - 1 - j] + val[i]);
				//cerr << i << " " << j << " "<<val[i]<<" "<<ans<<" " << dp[i - 1][j] << " " << dp2[n - 2 - i][t - 1 - j] << endl;
				assert(ans != 80);
			}




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

Measured memory_bytes: 142332
object Main {
  def main(args: Array[String]): Unit = {
    solve2
  }

  def solve2(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val x = sc.nextLong
    val a = new Array[Long](n)
    for (i <- 0 until n) {
      a(i) = (sc.nextLong - x).abs
    }

    var divisor = a(0)
    for (i <- 1 until n) {
      divisor = gcd(a(i), divisor)
    }
    println(divisor)
  }


  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val x = sc.nextLong
    val a = new Array[Long](n)
    for (i <- 0 until n) {
      a(i) = sc.nextLong
    }

    val abss = a.map(v => (v - x).abs).sorted
    var divisor = abss.min
    for (i <- 1 until n) {
      if (abss(i) % divisor != 0) {
        divisor = gcd(abss(i), divisor)
      }
    }
    println(divisor)
  }

  def gcd(x: Long, y: Long): Long = {
    if (x == 0) y
    else gcd(y % x, x)
  }

}


Measured memory_bytes: 51940
N = int(input())
A = [0] * N
XY = [0] * N
for i in range(N):
  A[i] = int(input())
  XY[i] = [list(map(int, input().split())) for _ in range(A[i])]

count = lambda x: sum([(x>>i)&1 for i in range(15)])
ans = 0
for i in range(1<<N):
  ok = True
  for j in range(N):
    if (i>>j)&1 == 0: continue
    for k in range(A[j]):
      if (i>>(XY[j][k][0]-1)&1)^XY[j][k][1]:
        ok = False
        break
  ans = max(ans, count(i)) if ok else ans
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(10);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
////////////////

void solve(){
  ini(N);
  string e = "E869120";
  int ans = 0;
  rep(i , N){
    ins(S);
    if(S == e) ans++;
  }
  out(ans);
}


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

#define int long long 
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define ALL(v) v.begin(),v.end()

int h[1010], w[1010];
void solve() {
	int N;
	REP(i, 105) {
		w[i] = h[i] = 0;
	}
	cin >> N >> w[0] >> h[0];
	if (N == 0 && w[0] == 0)exit(0);
	int idx = 1;
	REP(i, N) {
		int id, s; cin >> id >> s;
		id--;
		int H = h[id], W = w[id];
		s %= (H + W);
		//cout << "s:" << s << endl;
		FOR(j,id+1,i+1){
			h[j-1]=h[j];
			w[j-1]=w[j];
		}
		if (s<W) {
			int w1 = s, w2 = W - s;
			if (w1>w2)swap(w1, w2);
			w[i] = w1;
			h[i] = H;
			w[i+1] = w2;
			h[i+1] = H;
		}
		else {
			s -= W;
			int h1 = s, h2 = H - s;
			if (h1>h2)swap(h1, h2);
			h[i] = h1;
			w[i]=W;
			h[i+1] = h2;
			w[i+1] = W;
		}
	}
	vector<int>v;
	REP(i, N+1) {
		v.push_back(h[i] * w[i]);
	}
	sort(ALL(v));
	int M = v.size();
	REP(i, M) {
		cout << v[i];
		if (i != M - 1)cout << " ";
	}
	cout << endl;
	//cout << "+++++" << endl;
}
signed main() {
	while (true)
		solve();
}



Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    
    out(a*min(n, b-1)/b);
    re0;
}

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

int main(void){
  string s; cin >> s;

  if(s == "ABC") s="ARC";
  else s="ABC";
  cout << s << endl;
  
  return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A1 = sc.nextInt();
    int A2 = sc.nextInt();
    int A3 = sc.nextInt();
    int max = Math.max(Math.max(A1,A2),Math.max(A2,A3));
    int min = Math.min(Math.min(A1,A2),Math.min(A2,A3));
    int mid = A1 + A2 + A3 - min -max;
    System.out.println(Math.abs(min-mid) + Math.abs(mid-max));
  }
}

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

#define endl '\n'
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define SORT(v) sort(all(v))
#define SORTD(v) sort(all(v), greater<int>())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<30
#define v(T) vector<T>
#define vv(T) v(v(T))
#define print(x) cout<<x<<endl
#define printv(v) for(auto i : v){cout<<i<<" ";}cout<<endl
#define printu(v) for(auto i : v){print(i);}
#define readv(v, n) for (int i=0;i<n;i++)cin >> v[i]
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

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

int i, j, k;
int imos[100002];
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int k1;
		int k2;
		cin >> k1 >> k2;
		imos[k1] += 1;
		imos[k2 + 1] -= 1;
	}
	rep(i, n) {
		imos[i + 1] = imos[i + 1] + imos[i];
	}
	int count = 0;
	REP(i, 1, n + 1) {
		if (imos[i] == m) count++;
	}
	print(count);
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
int64 N;
vector<int64> G[112345];

int64 dfs(int64 v, int64 p) {
  int64 gr = 0;
  multiset<int64> st;
  REP(i, G[v].size()) {
    if (G[v][i] == p) continue;
    st.insert(dfs(G[v][i], v)+1);
  }
  if (st.size() == 0) return 0;
  if (st.size() == 1) {
    return *st.begin();
  } else {
    for (auto &x : st) {
      gr ^= x;
    }
  }
  return gr;
}

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

  cin >> N;
  REP(i, N-1) {
    int64 x, y;
    cin >> x >> y;
    x--; y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  if (dfs(0, -1)) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob" << endl;
  }
}


Measured memory_bytes: 18560
N = int(input())
W = list(map(int,input().split()))
lst = []

for i in range(N):
  left = 0
  right = 0
  compare = []
  left = sum(W[0:i])
  right = sum(W[i:])
  compre = abs(left - right)
  lst.append(compre)
print(min(lst))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	string s[10010];

	int ans=0;
	int la=0;
	int fb=0;
	int ryo=0;

	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> s[i];
		
		for(int j=0;j<s[i].size()-1;j++)
		{
			if(s[i][j]=='A' && s[i][j+1]=='B')
				ans++;
		}
		if(s[i][s[i].size()-1]=='A' && s[i][0]=='B')ryo++;
		else if(s[i][s[i].size()-1]=='A')la++;
		else if(s[i][0]=='B')fb++;
	}

	if(ryo>0)
	{
		ans+=(ryo-1);
		if(la>0)
		{
			ans++;
			la--;
		}
		if(fb>0)
		{
			ans++;
			fb--;
		}

	}
	ans+=min(la,fb);
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 768
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int maxn = 1e5 + 10;

int N;

int a[maxn];
long long tree[maxn];
int cnt[maxn];
pair<int, int> p[maxn];
long long ans[maxn];
long long q[maxn];

void add(int x, long long val)
{
	while (x <= N)
	{
		tree[x] += val;
		++cnt[x];
		x += x & -x;
	}
}

long long query(int x, int &c)
{
	c = 0;
	long long ret = 0;
	while (x > 0)
	{
		ret += tree[x];
		c += cnt[x];
		x -= x & -x;
	}
	return ret;
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i)
		scanf("%d", &a[i]);
	long long sum = 0;
	for (int i = 0; i < N; ++i)
		p[i] = make_pair(a[i], i), sum += a[i];
	sort(p, p + N);
	for (int i = N - 1; i >= 0; --i)
	{
		int x = N - p[i].second;
		int c;
		ans[p[i].second] = query(x, c);
		ans[p[i].second] -= 1ll * c * p[i].first;
		add(x, p[i].first);
	}
	q[0] = sum - ans[0];
	for (int i = 1, j = 0; i < N; ++i)
	{
		if (a[i] > a[j])
			q[i] = ans[j] - ans[i], j = i;
		else
			q[i] = 0;
	}
	for (int i = 0; i < N; ++i)
		printf("%lld\n", q[i]);
	return 0;
}


Measured memory_bytes: 4864
def mi():
    return map(int, input().split())

def main():
    N = int(input())
    T, A = mi()
    H = list(mi())
    tmps = [abs(T-h*0.006-A) for h in H]
    print(tmps.index(min(tmps))+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
def subtract_lst (lst1, lst2):
    ans = 0
    for i in range(len(lst1)):
        e1 = lst1[i]
        e2 = lst2[i]
        if e1 != e2:
            ans += 1
    return ans

if __name__ == '__main__':
    s = input()
    lenS = len(s)
    a = ""
    b = ""
    for i in range(lenS // 2):
      a = a + "10"
      b = b + "01"
    if lenS % 2 == 1:
        a = a + "1"
        b = b + "0"
    aAns = subtract_lst (a, s)
    bAns = subtract_lst (b, s)
    print (min(aAns, bAns))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  dump(min(a+b, min(b+c, a+c)));
  return 0;
}


Measured memory_bytes: 256
n = int(input())
start = input()
words = [start]
last = start[-1]
ans = 'Yes'
for i in range(n - 1):
  inp = input()
  if inp in words or last != inp[0]:
    ans = 'No'
    break
  words.append(inp)
  last = inp[-1]
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define MOD 1000000007
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define FOR(i, n) for (int i = 0; i < n; i++)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define input_arr(a, n) \
  for (int i = 0; i < n; i++) cin >> a[i];
#define print_arr(a, n) \
  for (int i = 0; i < n; i++) cout << a[i] << ;
#define deb(n) cerr << #n << "=" << n << \n;

int main() {
  int red, green, blue, k;
  cin >> red >> green >> blue >> k;
  for (int i = 0; i <= k; i++) {
    if (blue * pow(2, i) > green * pow(2, k - i) &&
        green * pow(2, k - i) > red) {
      // cout << i << " " << k - i << endl;
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
// -----------------------------------------------------------------------------

int main() {
    int n; cin >> n; int _n = n;
    vector<int> ans = {2, 3, 25};
    n -= 3;
    int i = 0, j = 31;
    while (i < n) {
        if (i + 2 > n || j > 29970) break;
        if (j % 2 == 0 || j % 3 == 0 || j % 5 == 0) {
            ans.push_back(j);
            ans.push_back(j - 2 * (j % 30) + 30);
            i += 2;
        }
        if (j % 30 == 14) j += 17;
        else j++;
    }
    j = 30;
    while (i < n) {
        ans.push_back(j);
        j += 30;
        i++;
    }
    assert (ans.size() == _n);
    FOR (i, 0, ans.size())
        printf("%d%c", ans[i], i == _i - 1 ? '\n' : ' ');
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
b = [0]*n
for i in range(n):
  if a[i]%2:
    b[i] = 1
  elif a[i]:
    b[i] = 2
a.append(0)
b.append(0)
n += 1
DP = [[[10**18 for i in range(3)] for j in range(3)] for k in range(n+1)]
for i in range(3):
  for j in range(3):
    DP[0][i][j] = 0
for i in range(1,n+1):
  for k in (0,2):
    DP[i][0][k] = min(DP[i][0][k],DP[i-1][0][k]+abs(a[i-1]))
  for l in (1,2):
    DP[i][0][2] = min(DP[i][0][2],DP[i-1][l][2]+abs(a[i-1]))
  DP[i][0][2] = min(DP[i][0][2],DP[i-1][2][1]+abs(a[i-1]))

  DP[i][1][2] = min(DP[i][1][2],DP[i-1][0][0]+abs(b[i-1]-1))
  DP[i][1][2] = min(DP[i][1][2],DP[i-1][1][2]+abs(b[i-1]-1))
  DP[i][1][2] = min(DP[i][1][2],DP[i-1][2][1]+abs(b[i-1]-1))

  for k in (1,2):
    DP[i][2][k] = min(DP[i][2][k],DP[i-1][2][k]+abs(b[i-1]-2))
  DP[i][2][2] = min(DP[i][2][2],DP[i-1][1][2]+abs(b[i-1]-2))
  DP[i][2][1] = min(DP[i][2][1],DP[i-1][0][0]+abs(b[i-1]-2))
print(min(*DP[n][0]))

Measured memory_bytes: 126428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int INT_INF = 1001001001;

int kaisu(int n){//2で何回割れるかをカウントする
    int cnt = 0;
    while(n>0){
        if(n%2==0){
            n /= 2;
            cnt++;
        }else{
            break;
        }
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    int ans = INT_INF;
    for(int i=0;i<n;i++){
        ans = min(ans,kaisu(A[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MAXN 100000
#define MAXK 1000
using namespace std;
struct node
{
	int x,y,opt;
}poi[MAXN+5];
int dp[MAXK+5][MAXK+5],ctr[MAXK+5][MAXK+5];
int n,k;
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int a,b,tot=0,optnum;
		char opt;
		scanf("%d %d %c",&a,&b,&opt);
		if(opt=='B')		optnum=1;
		else if(opt=='W')	optnum=0;
		tot+=a/k; a%=k;
		tot+=b/k; b%=k;
		poi[i].x=a; poi[i].y=b;
		if(tot%2==1)		poi[i].opt=(optnum+1)%2;
		else				poi[i].opt=optnum;
	}
	for(int i=1;i<=n;i++)
	{
		int x=poi[i].x,y=poi[i].y,opt=poi[i].opt;
		if(poi[i].opt==1)
			ctr[k][k]++,ctr[x][k]--,ctr[k][y]--,ctr[x][y]+=2;
		else
			ctr[x][k]++,ctr[k][y]++,ctr[x][y]-=2;
	}
	int ans=0;
	for(int y=k;y>=0;y--)
		for(int x=k;x>=0;x--)
		{
			dp[x][y]=dp[x][y+1]+dp[x+1][y]-dp[x+1][y+1]+ctr[x][y];
			ans=max(ans,max(dp[x][y],n-dp[x][y]));
		}
	printf("%d\n",ans);
	return 0;
}
/*
4 3
5 3 B
0 1 W
1 2 W
5 4 B

*/

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

void CountingSort(const vector<int> &A, vector<int> &B, int k)
{
	int n = A.size();
	vector<int> C;
	C.resize(k+1);
	for(int i = 0; i <= k; i++){
		C[i] = 0;
	}
	/* C[i] ??? i ???????????°????¨?????????? */
	for(int j = 0; j < n; j++){
		C[A[j]]++;
	}
	/* C[i] ??? i ??\????????°???????????°????¨??????????*/
	for(int i = 1; i <= k; i++){
		C[i] = C[i] + C[i-1];
	}
	
	for(int j = n-1; j >= 0; j--){
		B[C[A[j]] - 1] = A[j];
		C[A[j]]--;
	}	
}
int main()
{
	int n;
	int k = 10000;
	cin >> n;
	vector<int> A;
	vector<int> B;
	A.resize(n);
	B.resize(n);
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	CountingSort(A, B, k);
	for(int i = 0; i < n-1; i++){
		cout << B[i] << ' ';
	}
	cout << B.back() << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    ll ans = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; j < n-1; j++) {
            for (int k = j+1; k < n; k++) {
                if (l[i]+l[j] > l[k]) ans++;
                else break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int o(int x, int y) {
	if (x < y) return x;
	else return y;
}

int main() {
	vector<int> a(3);
	rep(i, 3) {
		cin >> a[i];
	}
	int x = a[0] + a[1];
	rep(i, 3) {
		rep(j, 3) {
			if (i != j) {
				x = o(x, a[i] + a[j]);
			}
		}
	}
	cout << x << endl;
}

Measured memory_bytes: 256
// B - Shift only

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

int N;
char S[100];
int solve();

int main() {
  // ここにプログラムを追記

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

int solve(){
  for(int i =0; i<N; i++){
    if(S[i] == 'Y'){
        cout << "Four" << endl;
        return 0;
    }

  }
  cout << "Three" << endl;
  return 0;
}


Measured memory_bytes: 256
def resolve():
    N, M = list(map(int, input().split()))
    A = sorted(list(map(int, input().split())), reverse=True)
    total = sum(A)
    choose = 0
    th = total/(4*M)
    for a in A:
        if a < th:
            continue
        choose += 1
    print("Yes" if choose >= M else "No")



if '__main__' == __name__:
    resolve()

Measured memory_bytes: 61860
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[20];
	int i,len;
	scanf("%s",s);
	len=strlen(s);
	for(i=len-1;i>=0;i--){
		printf("%c",s[i]);
	}
	printf("\n");
	return 0;
}



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

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	vector<int> s{ A,B,C };

	int count5 = 0;
	int count7 = 0;

	for (int i = 0; i < s.size(); ++i) {
		if (s.at(i) == 5) count5++;
		else if(s.at(i) == 7) count7++;
		//cout << "5 =" << count5 << endl;
		//cout << "7 = " << count7 << endl;
	}

	bool flag = false;
	if (count5 == 2 && count7 == 1) flag = true;

	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

A, B, C, D = map(int, input().split())
total = 0

if B <= C or A >= D:
    pass
elif B <= D and A <= C:
    total = B - C
elif B <= D and A > C:
    total = B - A
elif B > D and A <= C:
    total = D - C
else:
    total = D - A

print(total)

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

using namespace std;

int main()
{
   ios_base::sync_with_stdio(false);
   string str1,str2;
   cin>>str1>>str2;
   int cnt=0;
   for(int i=0;i<(int)str1.size();++i)
   {
      if(str1[i]!=str2[i])cnt++;
   }
   cout<<cnt;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main()
{
  int stoneNum;
  string stones;
  cin >> stoneNum >> stones;
  
  int iterW,iterR;
  int cntR = 0;
  int ans = 0;
  
  rep(i,stoneNum)
  {
    if(stones[i] == 'R')
    {
      cntR++;
    }
  }
  rep(i,cntR)
  {
    if(stones[i] == 'W')
    {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3728
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
double P[200000];
double value[200000];

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    int k;
    in >> N >> k;
    for (size_t i = 0; i < N; i++)
    {
        in >> P[i];
    }
    for (size_t i = 0; i < N; i++)
    {
        value[i] = (1 + P[i]) / 2;
    }
    double sum_max = 0;
    double sum = 0;
    int count = 0;
    for (size_t i = 0, j = 0; i < N;)
    {
        while (count < k && i < N) { sum += value[i++]; ++count; }
        if (count != k) {
            break;
        }
        sum_max = std::max(sum_max, sum);
        sum -= value[j++]; --count;
    }

    out
        << std::fixed << std::setprecision(9) << sum_max << endl;

    return 0;
}
#endif


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2 2");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1 10");
            //10
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("10 8");
            //322828856
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();

        long N = wkArr[0];
        long K = wkArr[1];

        long Answer = K;
        for (long I = 2; I <= N; I++) {
            Answer *= K - 1;
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 3032
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut solver = Solver::new(n);
    for _ in 0..n - 1 {
        let a: usize = scan(tokens);
        let b: usize = scan(tokens);
        solver.add_edge(a - 1, b - 1);
    }
    solver.solve();
}

struct Solver {
    n: usize,
    neighbors: Vec<Vec<usize>>,
    color: Vec<bool>,
}

impl Solver {
    fn new(n: usize) -> Solver {
        Solver {
            n: n,
            neighbors: vec![Vec::new(); n],
            color: vec![false; n],
        }
    }
    fn add_edge(&mut self, i: usize, j: usize) {
        self.neighbors[i].push(j);
        self.neighbors[j].push(i);
    }
    fn solve(&mut self) {
        self.give_color(0, 0, false);
        let n = self.n;
        let nt = self.color.iter().filter(|&&c| c).count();
        let nf = n - nt;
        let (nr, r) = if nt <= nf { (nt, true) } else { (nf, false) };
        let n3 = n / 3;
        let mut res = vec![0; n];
        let mut p1 = 1;
        let mut p2 = 2;
        let mut p3 = 3;
        if nr <= n3 {
            for i in 0..n {
                if self.color[i] == r {
                    res[i] = p3;
                    p3 += 3;
                } else if p1 <= n {
                    res[i] = p1;
                    p1 += 3;
                } else if p2 <= n {
                    res[i] = p2;
                    p2 += 3;
                } else {
                    res[i] = p3;
                    p3 += 3;
                }
            }
        } else {
            for i in 0..n {
                if self.color[i] == r {
                    if p1 <= n {
                        res[i] = p1;
                        p1 += 3;
                    } else {
                        res[i] = p3;
                        p3 += 3;
                    }
                } else {
                    if p2 <= n {
                        res[i] = p2;
                        p2 += 3;
                    } else {
                        res[i] = p3;
                        p3 += 3;
                    }
                }
            }
        }
        for i in 0..n {
            if i != 0 {
                print!(" ");
            }
            print!("{}", res[i]);
        }
        println!("");
    }
    fn give_color(&mut self, i: usize, p: usize, c: bool) {
        self.color[i] = c;
        for j in self.neighbors[i].clone() {
            if j != p {
                self.give_color(j, i, !c);
            }
        }
    }
}


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

int main() {
    // your code goes here
    ll h,w,n,ans;
    cin >> h >> w >> n;
    if(h<w) swap(h,w);
    if(n%h==0) ans=n/h;
    else ans=n/h+1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256