akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll d;
ll x[200100], y[200100];

int solve() {
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (x[i] * x[i] + y[i] * y[i] <= d * d)
            res++;
    }
    return res;
}

void input() {
    cin >> n >> d;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 6292
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.14159265358979311600
#define loop(i, n) for(int i = 0; i < n; i++)
#define loop1(i, a, n) for(int i = a; i < n; i++)
using namespace  std;

using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef complex<ll> G;
const int q=2e5+5;
#define x first
#define y second
const int INF = 1e9;

void done() {
    int n, k;
    cin >> n >> k;
    vector<int>a(n+1);
    for(int i =1;i <= n;i++) {
        cin >> a[i];
    }
    vector<int>pos;
    int ok = 0;
    for(int i =2;i < n;i++) {
        if(a[i] > a[i-1] && a[i] > a[i+1])pos.push_back(i);
    }
    int cnt = 0, d = 1, ans = 1;
    for(int i=0, j=0;i < pos.size();i++) {

        int q = pos[i];
        while((pos[j]-q)+2 <= k && j < pos.size()) {
            j++;
        }
        if(j-i > d) {
            ans = pos[i]-1;
            cnt = j-i+1;
            d = j-i;
            ok = 1;
        }
    }
    cout << cnt << " " << ans << '\n';

}
void solve() {
    int n, m;
    cin >> n >> m;
    int k;cin >> k;
    char a[n][m];
    int cnt = 0;
    for(int i=0;i < n;i++) {
        for(int j = 0;j < m;j++) {
            cin >> a[i][j];
            if(a[i][j]=='#')cnt++;
        }
    }
    int ave = cnt-k;
    if(ave < 0) {
        cout << 0 << '\n';
        return;
    }
    if(ave==0) {
        cout << 1 << '\n';
        return;
    }





}
void another() {
    ll n;cin >> n;
    vector<int>a(n);
    for(int i=0;i < n;i++) {
        cin >> a[i];
    }
    ll sum = 0;
    sort(a.rbegin(), a.rend());
    for(int i=1;i < n;i++) {
        sum += a[i/2];
    }
    cout << sum << '\n';


}
void test_case() {
    int t;
    cin >> t;
    while( t--)done();
}
int main() {

     fast;
    another();

}



Measured memory_bytes: 3972
n,a,b = map(int,input().split())
p = 10**9 + 7
def comb(n,k):
    child = 1
    mother = 1
    for i in range(k):
        child = child * (n-i)%p
        mother = mother * (i+1)%p
    return child * pow(mother,p-2,p) % p
ans = pow(2,n,p) - 1 - comb(n,a) - comb(n,b)
print(ans%p)

Measured memory_bytes: 3188
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

typedef pair<int,int> pii;

int main(){
  char s[1000001];
  vector<pii> v;
  cin >> s;
  int l = strlen(s);
  int cnt = 0;
  int x;
  for(int i=0;i<l;i++){
    if(i>0&&s[i]!=s[i-1]){
      v.push_back(pii(x,cnt));
      cnt = 0;
    }
    switch(s[i]){
      case 'J':
        x = 0;
        break;
      case 'O':
        x = 1;
        break;
      case 'I':
        x = 2;
        break;
    }
    cnt++;
  }
  v.push_back(pii(x,cnt));
  int ans = 0;
  for(int i=0;i<(int)v.size()-2;i++){
    if(i<(int)v.size()-2&&v[i].first==0&&v[i+1].first==1&&v[i+2].first==2&&v[i].second>=v[i+1].second&&v[i+1].second<=v[i+2].second){
      ans = max(ans,v[i+1].second);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12196
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

int beki(int x, int p) {
    int ans = 1;
    while (p != 0) {
        ans *= x;
        p--;
    }
    return ans;
}

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

    int x;
    cin >> x;

    int ans = 1;
    FOR(i, 1, 100) {
        FOR(j, 2, 100) {
            int tmp = beki(i, j);
            if (tmp <= x) {
                ans = max(ans, tmp);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

"""
参考：https://img.atcoder.jp/arc064/editorial.pdf
・最終的には両端にある2種類の文字か、両端が同じ文字ならそれとそれ以外のもう1文字以外は残らない。
・なので残った文字数の偶奇は分かる。
・そこから総ターン数が分かるので、偶奇で勝敗が分かる。
"""

import sys
from collections import deque, Counter, defaultdict
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, product, combinations, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial

def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()
N = len(S)

# この条件はxorを使うとスッキリまとまる
if (S[0] == S[-1]) ^ (N % 2 == 0):
    print('Second')
else:
    print('First')


Measured memory_bytes: 3908
#include <iostream>

using namespace std;

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

	for (int i = a; i <= b; i++) {
		if (c%i == 0) counter++;
	}

	cout << counter << endl;

	return 0;
}



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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int H, W;

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

    std::cin >> H >> W;

    if(H > W){
        std::swap(H, W);
    }

    ll cnt;

    if(H == 1 && W == 1){
        cnt = 1;
    }else if(H == 1){
        cnt = W - 2;
    }else{
        cnt = 1ll * (H - 2) * (W - 2);
    }

    std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;


int main(){
	char A[50][51];
	char B[50][51];

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> B[i];
	}
	bool flg = false;
	for (int i = 0; i < n - m + 1; i++) {
		for (int j = 0; j < n - m + 1; j++) {
			bool cnt = true;
			for (int r = 0; r < m; r++) {
				for (int c = 0; c < m; c++) {
					if (A[i + r][j + c] != B[r][c]) {
						cnt = false;
						break;
					}
				}
				if (!cnt)break;
			}
			if (cnt) {
				flg = true;
				break;
			}
		}
		if (flg)break;
	}
	cout << (flg ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

struct segment_tree {
	int n;
	vector<ll> tree, mod;

	inline void resize(int n_) {
		n = n_;
		tree.resize(4 * n);
		mod.resize(4 * n);
	}

	inline void push(int v, int vl, int vr) {
		if (!mod[v]) {
			return;
		}
		tree[v] += (ll)(vr - vl) * mod[v];
		if (vr - vl > 1) {
			mod[2 * v + 1] += mod[v];
			mod[2 * v + 2] += mod[v];
		}
		mod[v] = 0;
	}

	inline void update(int L, int R, int del) {
		update(0, 0, n, L, R, del);
	}

	void update(int v, int vl, int vr, int L, int R, int del) {
		push(v, vl, vr);
		if (R <= vl || vr <= L) {
			return;
		}
		if (L <= vl && vr <= R) {
			mod[v] += del;
			return;
		}
		int vm = (vl + vr) / 2;
		update(2 * v + 1, vl, vm, L, R, del);
		update(2 * v + 2, vm, vr, L, R, del);
		push(2 * v + 1, vl, vm);
		push(2 * v + 2, vm, vr);
		tree[v] = tree[2 * v + 1] + tree[2 * v + 2];
	}

	inline ll get(int L, int R) {
		return get(0, 0, n, L, R);
	}

	ll get(int v, int vl, int vr, int L, int R) {
		push(v, vl, vr);
		if (R <= vl || vr <= L) {
			return 0;
		}
		if (L <= vl && vr <= R) {
			return tree[v];
		}
		int vm = (vl + vr) / 2;
		return get(2 * v + 1, vl, vm, L, R) + get(2 * v + 2, vm, vr, L, R);
	}
};

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<vector<int>> g(n);
	vector<int> deg(n, 0);
	for (int i = 1; i < n; i++) {
		int v, u;
		cin >> v >> u;
		v--, u--;
		if (v > u) {
			swap(v, u);
		}
		g[v].push_back(u);
		deg[u]++;
	}
	segment_tree tree;
	tree.resize(n);
	for (int i = 0; i < n; i++) {
		tree.update(i, n, deg[i]);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += (ll)(n - i) * (n - i + 1) / 2;
		ans -= tree.get(i, n);
		for (auto v : g[i]) {
			tree.update(v, n, -1);
		}
	}
	cout << ans;
}

Measured memory_bytes: 27504
#include <stdio.h>
#define ll long long int
int main(void){
	int n,i,m;
	scanf("%d",&n);
	ll t[n],allTime=0;
	for(i=0;i<n;i++){
		scanf("%lld",&t[i]);
		allTime+=t[i];
	}
	scanf("%d",&m);
	int p;
	ll x;
	for(i=0;i<m;i++){
		ll time = allTime;
		scanf("%d %lld",&p,&x);
		time -= t[p-1];
		time += x;
		printf("%lld\n",time);
	}
	
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
bool cmp(long long int a,long long int b)
{
	return a>b;
}
int main()
{
	int x,y,n,m,l;
	cin>>x>>y>>n>>m>>l;
	long long int a[n],b[m],c[l];
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<m;i++)
		cin>>b[i];
	for(int i=0;i<l;i++)
		cin>>c[i];
	sort(a,a+n,cmp);
	sort(b,b+m, cmp);
	sort(c,c+l,cmp);
	priority_queue<long long int> pq;
	long long int sum=0;
	for(int i=0;i<x;i++)
	{
		sum+=a[i];
		pq.push(-a[i]);
	}
	for(int i=0;i<y;i++)
	{
		sum+=b[i];
		pq.push(-b[i]);
	}
	
	for(int i=0;i<l;i++)
	{
		long long cur=pq.top();
		pq.pop();
		cur*=-1;
		if(cur>=c[i])break;
		sum-=cur;
		sum+=c[i];
		pq.push(-c[i]);
	}
	cout<<sum<<endl;
	
}

Measured memory_bytes: 4724
#include <iostream>

int main() {
  int N;
  std::cin >> N;

  char s;

  std::cout << N-1 << '\n';
  std::cin >> s;
  std::cin.ignore(16, '\n');
  if (s == 'V') return 0;

  std::cout << 0 << '\n';
  std::cin >> s;
  std::cin.ignore(16, '\n');
  if (s == 'V') return 0;  

  int lb=0, ub=N-1;
  while (ub-lb > 1) {
    int mid=(lb+ub)>>1;
    std::cout << mid << '\n';

    char t;
    std::cin >> t;
    std::cin.ignore(16, '\n');
    if (t == 'V') return 0;
    ((mid&1)^(s==t)? lb:ub) = mid;
  }
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
const int maxn=2e3+10;
int A[maxn];
int n,a,b,huan,l,r;
void check1()
{
		for(int i=1;i<=l;i++){
			int w=(huan-1)/2;
			for(int j=1;j<=w;j++){
				if(j==1)A[i+j]--;
				A[i+j]+=2;
			}
		}
		for(int i=1;i<=r;i++){
			int w=(huan-1)/2;
			for(int j=1;j<=w;j++){
				if(j==1)A[i+j]--;
				A[i+j]+=2;
			}
		}
}
void check2()
{
	for(int i=1;i<=l;i++){
			int w=(huan)/2;
			for(int j=1;j<=w;j++){
				if(j==1||j==w)A[i+j]--;
				A[i+j]+=2;
			}
		}
		for(int i=1;i<=r;i++){
			int w=(huan)/2;
			for(int j=1;j<=w;j++){
				if(j==1||j==w)A[i+j]--;
				A[i+j]+=2;
			}
		}
}
int main()
{
	
	cin>>n>>a>>b;
	huan=a-1+n-b;
	huan=n-huan;
	l=a-1,r=n-b;
	if(huan&1){
	check1();
	}else{
		check2();
	}
	for(int i=1;i<=l+r+1;i++){
		A[l+r+2-i]+=i;
	}
	A[1]--;
	if(huan&1){
		for(int i=1;i<=huan/2;i++){
			A[i]+=huan;
		} 
	} else{
		for(int i=1;i<=huan/2;i++){
			if(i==huan/2)A[i]+=huan/2;
			else A[i]+=huan;
		} 
	}
	for(int i=1;i<n;i++){
		cout<<A[i]<<endl;
	}
 	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a,j,count=0,i;
   scanf("%d",&a);
   for(i=1;;i++){
   for(j=a;j>=1;j--){
        if(a%j==0){
            count++;
        }
        if(count>2){
            break;
        }
   }
   if(count==2){
    break;
   }
   a=a+1;
   count=0;
    }
   if(count==2){
    printf("%d",a);
   }

   }



Measured memory_bytes: 1736
from collections import *
mod=10**6+3
fac=[0 for i in range(mod)]
fac[0]=1
for i in range(0,len(fac)-1):
    fac[i+1]=(fac[i]*(i+1))%mod
fac[0]=0
Q=int(input())
for q in range(Q):
    x,d,n=map(int,input().split())
    if d>0:
        D=pow(d,mod-2,mod)
        a=(x-d%mod)*D%mod
        b=(a+n)%mod
        if a<b and a+n<mod:
            if a>0:
                value=fac[b]*pow(fac[a],mod-2,mod)*pow(d,n,mod)
            else:
                value=fac[b]*pow(d,n,mod)
            print(value%mod)
        else:
            print(0)
    else:
        print(pow(x,n,mod))


Measured memory_bytes: 114032
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
    string s;
    int cnt=0,ans=0;
    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]=='o') cnt++;

    }
    ans=700+100*cnt;
    p(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

bool linearsearch(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while (A[i] != key) i++;
    return i != n;
}

int binarysearch(int A[], int n, int key){
    int left = 0;
    int right = n;
    while (left < right){
        int mid = (left + right) / 2;
        if (A[mid] == key) return 1;
        else if (key < A[mid]) right = mid;
        else left = mid + 1;
    }

    return 0;
}

int main() {
    int i, n, A[100000+1], q, key, sum = 0;

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

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

    return 0;

}

Measured memory_bytes: 3512
object Main {
  import scala.io.StdIn.readLine

  def multi(a:Long, b:Long):Long = a * b
  def divide(a: Long, b: Long):Long = a / b
  def remain(a: Long, b: Long):Long = a % b

  def primes(max:Int): List[Int] = {
    (1 to (max / 6).toInt).foldLeft(List(2,3)){(acc,c) => {
      val a = c*6-1
      val b = c*6+1
      val sq = acc.takeWhile(a=> a <= math.sqrt(b).toInt+1)
      val k=if(sq.foldLeft(true){(acc, c) => if(acc && remain(a, c) != 0) true else false}) List(a) else List()
      val v=if(sq.foldLeft(true){(acc, c) => if(acc && remain(b, c) != 0) true else false}) List(b) else List()
      acc++k++v
    }}
  }

  def input[A](change: String => A) = readLine.split(" ").map(change(_))
  def main(args: Array[String]): Unit = {
    val n = input(_.toInt).head
    val primeList = primes(n).filter(a => a <= n)
    if(n == 1 || n == 2) {
      println(n)
    } else if(primeList.lastOption.contains(n)) {
      println(n)
    } else {
      var loop = true
      var i = n
      while(loop) {
        if(primeList.find(a => i % a == 0).isEmpty) {
          println(i)
          loop = false
        }
        i = i + 1
      }
    }
  }
}


Measured memory_bytes: 115900
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    int a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    int t=min(a,k);
    ans=t;
    k-=t;
    t=min(max(0,k),b);
    k-=t;
    t=min(max(0,k),c);
    ans-=t;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
// Problem : C - Vacation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define tc ll t;cin>>t;while(t--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007

int main()
{
	io;
	ll n;
	cin>>n;
	vll a(n),b(n),c(n);
	
	FOR(i,0,n)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	
	vvll dp(3,vll(n,0));
	dp[0][0]=a[0];
	dp[1][0]=b[0];
	dp[2][0]=c[0];
	
	FOR(i,1,n)
	{
		dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i];
		dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b[i];
		dp[2][i]=max(dp[1][i-1],dp[0][i-1])+c[i];
	}
	cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
	return 0;
}


Measured memory_bytes: 5760
#include<iostream>

using namespace std;

int main(){
  char c;
  cin >> c;
  if( c == 'a' || c == 'o' || c == 'u' || c == 'i' || c == 'e' ){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
  return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)

int n,a,x[60];
ll dp[60][60][10000]={};

int main(){
  cin >> n >> a;
  rep(i,n){
  cin >> x[i];
  }

  rep(i,60){
    dp[i][0][0]=1;
  }

  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      for(int k=0; k<=a*n; k++){
        if(k-x[i-1]<0){
          dp[i][j][k] = dp[i-1][j][k];
        }else{
          dp[i][j][k] = dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]];
        }
      }
    }
  }
  ll ans=0;
  for(int j=1; j<=n; j++){
    ans += dp[n][j][a*j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 252160
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
    ll a, b;
    cin >> a >> b;
    rp(i, 1, 100000)
    {
        if (ll(i * 0.08) == a && ll(i * 0.1) == b)
        {
            cout << i << endl;
            break;
        }
        if (i == 100000 - 1)
        {
            cout << -1 << endl;
        }
    }
}


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

typedef long long ll;
const int N = 2000006;



int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int a,b,c;
	cin>>a>>b>>c;
	if(a + b + c >= 22){
		cout<<"bust";
	}else{
		cout<<"win";
	}
	
	return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
using namespace std;
int main(void){
	char s[3];
	int cnt;
	int x;
	scanf("%s",s);
	cnt=0;
	if(s[0]=='o')	cnt++;
	if(s[1]=='o')	cnt++;
	if(s[2]=='o')	cnt++;
	x=700+100*cnt;
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 5005
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n;
int cnt1[26], cnt2[26];
int main() {
  cin>>n;
  memset(cnt1, 0, sizeof(cnt1));
  for (int i = 0; i < n; ++i) {
  	string s;
    cin>>s;
    memset(cnt2, 0, sizeof(cnt2));
    for (int j = 0; j < s.size(); ++j) {
    	cnt2[s[j]-'a']++;
    }
    if (i == 0) {
    	for (int j = 0; j < 26; ++j) {
        	cnt1[j] = cnt2[j];
        }
    } else {
    	for (int j = 0; j < 26; ++j) {
        	cnt1[j] = min(cnt1[j], cnt2[j]);
        }
    }
  }
  string ans="";
  for (int i = 0; i < 26; ++i) {
  	for (int j = 1; j <= cnt1[i]; ++j) {
    	ans.push_back('a' + i);
    }
  }
  sort(ans.begin(), ans.end());
  cout<<ans<<endl;
	return 0;
}

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

int main(){
    ll n, m; cin >> n >> m;
    if(m - 2*n < 0){
        cout << m / 2 << endl;
        return 0;
    }
    ll x = (m - 2 * n) / 4;
    cout << n + x << endl;
}

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

int main(){
    double x1, y1, x2, y2, dis;
    cin >> x1 >> y1>> x2 >> y2;
    dis = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
    printf("%f\n",dis);
    
    return 0;
}


Measured memory_bytes: 3200
import Control.Monad
main = print =<< ((pure count) <*> getInput)

getInts :: IO [Int]
getInts = (pure ((map read) . words)) <*> getLine

getInput :: IO [[Int]]
getInput = replicateM 2 getInts

count :: [[Int]] -> Int
count [[n, m], as]
        | foldl step False bs = 0
        | otherwise = (`div` 2) $ (+) 1 $ div m k
    where bs = map (`div` 2) as
          k = foldl lcm 1 bs
          step a x = a || even (div k x)



Measured memory_bytes: 88444
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################

signed main(){
    int x,y,z,k;cin >> x >> y >> z >> k;
    vector<int> a(x),b(y),c(z);
    rep(i,x)cin >> a[i];
    rep(i,y)cin >> b[i];
    rep(i,z)cin >> c[i];
    priority_queue<int> pq,ans;
    rep(i,x)rep(j,y){
        pq.push(a[i]+b[j]);
    }
    vector<int> res;
    for(int t = 0;t < k && pq.size();t++){
        res.push_back(pq.top());
        pq.pop();
    }
    
    rep(i,res.size())rep(j,z){
        // ans.push(P(res[i].first*c[j],res[i].second + c[j]));
        ans.push(res[i] + c[j]);
    }
    
    
    rep(_,k){
        // trace(ans.top());
        cout << ans.top() << "\n";
        ans.pop();
    }
    return 0;
}

Measured memory_bytes: 44160
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

struct Point{
	double x, y;
};


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

	int n;
	cin >> n;

	vi A(n), B(n);
	REP(i, n) {
		cin >> A[i] >> B[i];
	}

	LL ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		LL diff = (ans + A[i]) % B[i];
		if (diff) {
			ans += B[i] - diff;
		}
	}

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

Measured memory_bytes: 1152
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int a;
    int b;
    int c;
    int x;
    int y;
    vector<int> ans(3);

    cin >> a >> b >> c >> x >> y;
    ans[0] = a*x+b*y;
    if(x>y){
        ans[1] = c*2*y+(x-y)*a;
    }else{
        ans[1] = c*2*x+(y-x)*b;
    }
    if(x>y){
        ans[2] = c*2*x;
    }else{
        ans[2] = c*2*y;
    }
    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a[3];
  int i,j,r,tmp;
  
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  
  for(i=0;i<3;i++){
    for(j=1;j<3;j++){
      if(a[i]>=a[j]){
        tmp = a[0];
        a[0] = a[1];
        a[1] = tmp;
      }
    }
  }
  
  printf("%d\n",(a[0]*a[1])/2);
  
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

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

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int A, B, T;

  cin >> A >> B >> T;

  cout << T / A * B << endl;
  return 0;
}

Measured memory_bytes: 3636
# ABC084C - Special Trains
def main():
    N, *A = map(int, open(0).read().split())
    CSF = [i for i in zip(*[iter(A)] * 3)]
    ans = []
    for i in range(N):
        cur = 0
        for c, s, f in CSF[i:]:
            if cur <= s:
                cur = s + c
            else:
                cur = (cur + f - 1) // f * f + c
        ans.append(cur)
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#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(){
   double l; cin>>l;
   double a=l/3;
   double ans=pow(a,3);
   printf("%.10f\n",ans);
   return 0;
}

   


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            //Main2(str);
            MainSS(str);

        }

        static void MainSS(string str)
        {
            for (int i = 2; i < str.Length; i+=2)
            {
                if (JudgeGu(str.Substring(0, str.Length - i)))
                {
                    Console.WriteLine(str.Length - i);
                    break;
                }
            }
        }

        static bool JudgeGu(string str)
        {
            if (str.Length % 2 != 0) return false;

            string sub = str.Substring(0, str.Length / 2);
            return (sub + sub) == str;
        }

        static void Main2(string str)
        {
            var kakaku = str.Split().Select(int.Parse).ToArray();
            Array.Sort(kakaku);
            Console.WriteLine(kakaku[0] + kakaku[1]);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
    #include <string>
    #include <set>  
    #include <stack>
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
    #include <ctime>
using namespace std;
#define for1(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,maxn) for1(i,0,maxn)
#define ford(i,b,a) for(int i=(int)(b)-1;i>=a;--i)
typedef long long ll;
typedef pair<int,int> pii;
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define dprintf(...) printf(__VA_ARGS__)
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=46;
const int maxm=(1<<17);
int n,x,y,z;
int dp[maxn][maxm]; 
int lstbit[maxm];
int main()
{
	scanf("%d %d %d %d",&n,&x,&y,&z);
	int aim=(1<<(x+y+z-1))|(1<<(y+z-1))|(1<<(z-1));
	int mx=(1<<(x+y+z));
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	rep(i,n)
		rep(j,mx)
			if(dp[i][j])
				for1(nxt,1,11)
				{
					int nw=((j<<nxt)|(1<<(nxt-1)))&(mx-1);
					if((nw&aim)!=aim)
						dp[i+1][nw]=(dp[i+1][nw]+dp[i][j])%mod;
				}
	ll ans=1;
	rep(i,n)
		ans=ans*10%mod;
	rep(i,mx)
	{
		ans=(ans-dp[n][i]+mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 23936
H,W=map(int,input().split())
S=[list(input()) for i in range(H)]
T=[[None]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            tmp=0
            for k in range(j-1,j+2):
                if 0<=i-1<=H-1 and 0<=k<=W-1 and S[i-1][k]=="#":
                    tmp+=1
                if 0<=i+1<=H-1 and 0<=k<=W-1 and S[i+1][k]=="#":
                    tmp+=1
                if 0<=i<=H-1 and 0<=k<=W-1 and k!=j and S[i][k]=="#":
                    tmp+=1
            T[i][j]=tmp
        else:
            T[i][j]="#"
for i in range(H):
    for j in range(W):
        print(T[i][j],end="")
    print("\n")
    

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

#define N 200010
#define inf 0x3f3f3f3f
int n;
int seg[N],used[N],fa[N],cir[N];
int first[N],cnt=0;
struct edge{
	int u,v,nxt;
}e[N<<1];

inline void add(int u,int v){e[++cnt].u=u;e[cnt].v=v;e[cnt].nxt=first[u];first[u]=cnt;}

inline void dfs(int u){
	for(int i=first[u];i;i=e[i].nxt){
		int v=e[i].v;
		if(!cir[v]) dfs(v);
	}
	for(int i=first[u];i;i=e[i].nxt){
		int v=e[i].v;
		if(!cir[v]) used[seg[v]]=1;//由外向树的叶子节点向环上点更新 
	}
	for(;used[seg[u]];seg[u]++);//到此说明u的子树已经被统计完了,要满足条件2,[0,u)要包含u所有子节点的权值 
	for(int i=first[u];i;i=e[i].nxt){
		int v=e[i].v;
		if(!cir[i]) used[seg[v]]=0;//标记清0 
	}
}

int main(){
	scanf("%d",&n);
	for(int p,i=1;i<=n;i++){scanf("%d",&p);add(p,i);fa[i]=p;}
	int now=1;
	for(;!used[now];now=fa[now]) used[now]=1;
	for(;!cir[now];now=fa[now]) cir[now]=1;
	memset(used,0,sizeof(used));
	int num=0,maxi=-inf,mini=inf;
	for(int i=1;i<=n;i++)
		if(cir[i]){
			dfs(i);
			num++;
			maxi=max(maxi,seg[i]);
			mini=min(mini,seg[i]);
		}
	if(maxi==mini&&num%2) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;


int main()
{
	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	sort(a.begin(), a.end());
	if (a[0] == a[1] and a[1] != a[2]) cout << "Yes";
	else if (a[0] != a[1] and a[1] == a[2]) cout << "Yes";
	else cout << "No";
	
}

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

string S;
int dp[100000];

bool daydream(int now){
    if(now == S.size()){
        return true;
    }else if(dp[now] != -1){
        return dp[now];
    }else{
        int ans = false;
        if(now <= S.size() - 5){
            if(S.substr(now, 5) == "dream"){
                ans |= daydream(now + 5);
            }
            if(S.substr(now, 5) == "erase"){
                ans |= daydream(now + 5);
            }
        }
        if(now <= S.size() - 6){
            if(S.substr(now, 6) == "eraser"){
                ans |= daydream(now + 6);
            }
        }
        if(now <= S.size() - 7){
            if(S.substr(now, 7) == "dreamer"){
                ans |= daydream(now + 7);
            }
        }
        return dp[now] = ans;
    }
}

int main(){
    cin >> S;
    fill(dp, dp + 100000, -1);
    if(daydream(0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll q,h,s,d,n;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>q>>h>>s>>d>>n;
    ll m=min(4*q,min(2*h,s));
    if(m*2<d){
        cout <<m*n<<"\n";
    }
    else{
        cout <<d*(n/2)+m*(n%2)<<"\n";
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#define int long long
using namespace std;

int digit(int u) {
  int t = 0;
  while(u != 0) {
    t += u % 10;
    u /= 10;
  }
  return t;
}

signed main() {
  int K; cin >> K;
  int ans = 1, r = 1;
  for(int i = 0; i < K; ++i) {
    cout << ans << endl;
    if((ans + 1) % (r*10) == 0 && digit(ans + r) * r <= (ans + r)) r *= 10;
    ans += r;
  }

  return 0;
}


Measured memory_bytes: 256
import sys

for s in sys.stdin:
  p,q=map(int,s[:-1].split())
  F={}
  A=[]
  X=[]
  p%=q
  while 1:
    c=10*p
    if p in F or p==0: break
    a,b=divmod(c,q)
    X.append(a)
    A.append(p)
    F[p]=1
    p=b
  n=i=len(X)
  if p!=0: i=A.index(p)
  print "".join(map(str,X))
  if n!=i: print " "*i+"^"*(n-i)

Measured memory_bytes: 4236
#include<stdio.h>

#define MAX 100000
#define SENTINEL 2000000000

typedef struct  
{
    char suit;
    int value;
}Card;

Card L[MAX/2 + 2];
Card R[MAX/2 + 2];

void merge(Card A[], int n, int left, int mid, int right)
{
    int i,k,j;
    int n1 = mid - left;
    int n2 = right - mid;

    for(i=0;i<n1;i++)
    {
        L[i] = A[left + i];
    }
    for(i=0;i<n2;i++)
    {
        R[i] = A[mid + i];
    }

    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;

    for(k=left ; k < right ; k++)
    {
        if(L[i].value <= R[j].value)
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
        }
    }
}

void mergeSort(Card A[], int n, int left, int right)
{
    int mid;
    if(left + 1 < right)
    {
        mid = (left + right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int partition(Card A[], int n, int p, int r)
{
    int i,j;
    Card t,x;

    x = A[r];
    i = p-1;

    for(j=p ; j<r ; j++)
    {
        if(A[j].value <= x.value)
        {
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }

    t = A[i+1];
    A[i+1] = A[r];
    A[r] = t;

    return i+1;
}

void quickSort(Card A[], int n, int p, int r)
{
    int q;
    if(p < r)
    {
        q = partition(A,n,p,r);
        quickSort(A,n,p,q-1);
        quickSort(A,n,q+1,r);
    }
}

int main()
{
    int i,n,v;
    Card A[MAX];
    Card B[MAX];
    char s[10];
    int stable = 1;

    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
       scanf("%s %d",s,&v);

       A[i].suit = B[i].suit = s[0];
       A[i].value = B[i].value = v; 
    }

    mergeSort(A,n,0,n);
    quickSort(B,n,0,n-1);

    for(i=0;i<n;i++)
    {
        if(A[i].suit != B[i].suit) stable = 0;
    }

    if(stable == 1) printf("Stable\n");
    else printf("Not stable\n");

    for(i=0;i<n;i++)
    {
        printf("%c %d\n",B[i].suit,B[i].value);
    }

    return 0;
}



Measured memory_bytes: 4148
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;

  reverse(b.begin(), b.end());
  if (a == b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

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

int main(){
    int n, a[100001], b[100000];
    cin >> n;
    for(int i=0;i<=n;++i) cin >> a[i];
    for(int i=0;i<n;++i) cin >> b[i];

    int64_t ans = 0;
    for(int i=0;i<n;++i){
        if(a[i] <= b[i]){
            ans += a[i];
            b[i] -= a[i];
            ans += min(a[i+1], b[i]);
            a[i+1] -= min(a[i+1], b[i]);
        }else{
            ans += b[i];
        }
    }    

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

Measured memory_bytes: 1024
n = int(input())
creature_list = [ int(v) for v in input().split() ]

def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist
creature_list = sorted(creature_list)
creature_list_0 = list(reversed(creature_list))
creature_list = cumsum(creature_list)
creature_list = list(reversed(creature_list))

ans = None
for i in range(1,n):
    if creature_list_0[i-1] > creature_list[i] * 2:
        ans = i
        break
if ans == None:
    ans = n
print(ans)

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

int main() {
  int i, num;
  char a[3];

  if(scanf("%s", a) != 1) exit(0);
  num = strlen(a);

  if(num == 2) {
    printf("%s\n", a);
  }
  else if(num == 3) {
    for(i=0; i < num; i++) {
      printf("%c", a[num-i-1]);
    }
    printf("\n");
  }
  return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

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

    cout << max({A + B , A - B , A * B}) ;



    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll n,Ans = 1e13;  cin >> n;
    for(ll i = 1;i*i<=n;i++){
        if(n % i == 0){
            Ans = min(Ans , i + n/i - 2);
        }
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	while (cin >> n && n) {
		vi p(n), j(n-1);
		int sum = 0;
		rep(i, 0, n) {
			cin >> p[i];
			sum += p[i];
		}
		rep(i, 0, n - 1) cin >> j[i];
		sort(all(j));
		reverse(all(j));
		vi sumj(n);
		sumj[0] = 0;
		rep(i, 1, n) {
			sumj[i] = sumj[i - 1] + j[i - 1];
		}
		int MAX = 0;
		rep(i, 0, n) {
			MAX = max(MAX, (sum + sumj[i])*(n - i));
		}
		cout << MAX << endl;
	}
}

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

int main(){
	int k, x, start, end;
	cin >> k >> x;
	start = max(x - k + 1, -1000000);
	end = min(x + k - 1, 1000000);
	for(int i=start; i<=end; i++){
		cout << i << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
int main() {
  vector<int> a(3);
  for(int i=0;i<3;i++) cin >> a[i];
  swap(a[0], a[1]);
  swap(a[0], a[2]);
  for(int i=0;i<3;i++) {
    cout << a[i];
    if(i == 2) cout << endl;
    else cout << " ";
  }
}

Measured memory_bytes: 256
require 'prime'

N=gets.chomp.to_i


def num(a)
  k=1
  for temp in a do
    k *= temp[1]+1
  end

  return k

end

k=0

N.times do |i|
  if num((i+1).prime_division) == 8 && (i+1)%2 != 0
     k+=1
  end
end

puts k

Measured memory_bytes: 3964
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

string wall_01[5];
string wall_02[4];

char wall_1(int x, int y){
	if(x <= -1 || y <= -1 || x >= 4 || y >= 5){
		return '0';
	}
	return wall_01[y][x];
}

char wall_2(int x, int y){
	if(x <= -1 || y <= -1 || x >= 5 || y >= 4){
		return '0';
	}
	return wall_02[y][x];
}

int main(){
	
	for(int i = 0; i < 9; i++){
		if(i % 2 == 0){
			cin >> wall_01[i / 2];
		}else{
			cin >> wall_02[i / 2];
		}
	}
	
	int pos_x = 0;
	int pos_y = 0;
	
	char dir_list[4] = {'R', 'D', 'L', 'U'};
	
	char dir = 'R';
	
	while(true){
		
		//cout << pos_x << pos_y << dir << endl;
		
		if(dir == 'R'){
			if(wall_2(pos_x, pos_y - 1) == '1'){
				cout << "U";
				pos_y--;
				dir = 'U';
			}else if(wall_1(pos_x, pos_y) == '1'){
				cout << "R";
				pos_x++;
			}else if(wall_2(pos_x, pos_y) == '1'){
				dir = 'D';
			}else{
				dir = 'L';
			}
		}else if(dir == 'D'){
			if(wall_1(pos_x, pos_y) == '1'){
				cout << "R";
				pos_x++;
				dir = 'R';
			}else if(wall_2(pos_x, pos_y) == '1'){
				cout << "D";
				pos_y++;
			}else if(wall_1(pos_x - 1, pos_y) == '1'){
				dir = 'L';
			}else{
				dir = 'U';
			}
		}else if(dir == 'L'){
			if(wall_2(pos_x, pos_y) == '1'){
				cout << "D";
				pos_y++;
				dir = 'D';
			}else if(wall_1(pos_x - 1, pos_y) == '1'){
				cout << "L";
				pos_x--;
			}else if(wall_2(pos_x, pos_y - 1) == '1'){
				dir = 'U';
			}else{
				dir = 'R';
			}
		}else if(dir == 'U'){
			if(wall_1(pos_x - 1, pos_y) == '1'){
				cout << "L";
				pos_x--;
				dir = 'L';
			}else if(wall_2(pos_x, pos_y - 1) == '1'){
				cout << "U";
				pos_y--;
			}else if(wall_1(pos_x, pos_y) == '1'){
				dir = 'R';
			}else{
				dir = 'D';
			}
		}
		
		if(pos_x == 0 && pos_y == 0){
			cout << endl;
			break;
		}
	}
	
	return 0;
}

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

using namespace std;
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


/*void solve(string s){
    for(int i =0; i<s.size() ;i++){
        if(s[i]=='g' && s[i+1] =='o' && s[i+2] == 'o' && s[i] == 'g'){
                ans++;
                ans%=m;
               i+=2;

        }
        if(i==s.size()-1)break;
    }
    cout << ans << endl;
    }*/
map <int,int> m;
signed main(){
    IOS;
    int n,ans=0;
    cin >> n;
    for(int i = 1;i<=n;i++){
            int num = i;
            int dig =0;
        while(num){
            num/=10;
            dig++;
        }
        if(dig%2)ans++;
    }
    cout << ans <<endl;
return 0;}
///...


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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n;cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    int ans = 0;
    rep(i,n){
        if (a[i]==b[i] && b[i]==c[i]){
        }
        else if (a[i]==b[i] || b[i]==c[i] || c[i]==a[i]){
            ans++;
        }
        else{
            ans += 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256