akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcd(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

int main()
{
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, x4, y3, y4;

    if (y1 > y2)
    {
        x3 = x2 + abs(y1 - y2);
        x4 = x1 + abs(y1 - y2);
    }
    else if (y1 < y2)
    {
        x3 = x2 - abs(y1 - y2);
        x4 = x1 - abs(y1 - y2);
    }
    else
    {
        x3 = x2;
        x4 = x1;
    }
    if (x1 > x2)
    {
        y3 = y2 - abs(x1 - x2);
        y4 = y1 - abs(x1 - x2);
    }
    else if (x1 < x2)
    {
        y3 = y2 + abs(x1 - x2);
        y4 = y1 + abs(x1 - x2);
    }
    else
    {
        y3 = y2;
        y4 = y1;
    }
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
ll mod = 1000000007;
ll big(ll b, ll p){
	if (p == 1) return b;
	ll h = big(b, p / 2);
	ll res = (h * h) % mod;
	if (p % 2 == 1) res = (res * b) % mod;
	return res;
}
ll c[1000001];
int main(){
	ll n, b = 1, a, ans = 0;
	fill(c, c + 1000001, 0ll);
	scanf("%lld", &n);
	ll d[n];
	for (int i = 0; i < n; i++){
		scanf("%lld", &d[i]);
		a = d[i];
		for (int j = 2; j <= 1000; j++){
			ll cc = 0;
			while (a % j == 0){
				a /= j;
				cc++;
			}
			c[j] = max(c[j], cc);
		}
		if (a > 1){
			c[a] = max(c[a], 1ll);
		}
	}
	for (int i = 2; i <= 1000000; i++){
		if (c[i] == 0) continue;
		b = (b * big(i, c[i])) % mod;
	}
	for (int i = 0; i < n; i++){
		ans += (b * big(d[i], mod - 2)) % mod;
		ans %= mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 8064
s=input()
ls=len(s)-1
ans=0
for i in range(2**ls):
    mask=str(bin(i))[2:]
    mask=mask.zfill(ls)
    a=""
    for j in range(ls):
        a+=s[j]
        if mask[j]=='1':
            a+="+"
    a+=s[-1]
    ans+=eval(a)
print(ans)

Measured memory_bytes: 3064
n,m,l = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
B = [list(map(int,input().split())) for _ in range(m)]
C = [[0 for j in range(l)] for i in range(n)]

for i in range(n):
    for j in range(l):
        cij = 0
        for k in range(m):
            cij += A[i][k]*B[k][j]
        C[i][j] = cij

for c in C:
    print(*c)


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

int main()
{
    string S;
    cin >> S;

    if (S == "Sunny")
        cout << "Cloudy" << endl;
    if (S == "Cloudy")
        cout << "Rainy" << endl;
    if (S == "Rainy")
        cout << "Sunny" << endl;

    return 0;
}

Measured memory_bytes: 256
s=input()
q=int(input())

from collections import deque

deq=deque(s)

cnt=0
for _ in range(q):
    query=input().split()
    if int(query[0])==1:
        cnt+=1
    elif int(query[0])==2:
        if int(query[1])==1:
            if cnt%2==0:
                deq.appendleft(query[2])
            else:
                deq.append(query[2])
        else:
            if cnt%2==0:
                deq.append(query[2])
            else:
                deq.appendleft(query[2])

if cnt%2==0:
    ans=''.join(list(deq))
else:
    ans=''.join(list(deq)[::-1])

print(ans)

Measured memory_bytes: 10356
#include<stdio.h>
int main(void)
{
	int w,h,x,y,r,a,b,c,d;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	a=x+r;
	b=y+r;
	if(a<=w && b<=h && x>=0 && y>=0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2692
#include <stdio.h>
#include <string.h>
#define N 100
void insertionSort(int*,int);
int main (){
  int A[N],a,b,i;
  
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&A[i]);
  }
  insertionSort(A,b);

  return 0;
}

void insertionSort(int *a,int b){
  int i,j,k,v;
  for(k=0;k<b;k++){
      printf("%d",*(a+k));
      if(k!=b-1) printf(" ");
      else printf("\n");
    }
  for(i=1;i<b;i++){
    v = *(a+i);
    j=i-1;
    while(j>=0 && *(a+j)>v){
      *(a+j+1) = *(a+j);
      j--;
      *(a+j+1) = v;
    }
    for(k=0;k<b;k++){
      printf("%d",*(a+k));
      if(k!=b-1) printf(" ");
      else printf("\n");
    }
  }
}



Measured memory_bytes: 2084
import sys


# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    H, A = map(int, input().split())
    print((H+A-1)//A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli h, w,m;
    cin >> h >> w>>m;
    vi hv(h,0);
    vi wv(w,0);
    set<pii> check;
    rep(i,m){
        lli hi, wi;
        cin >> hi >> wi;
        check.insert(pii(hi-1, wi-1));
        hv[hi - 1]++;
        wv[wi - 1]++;
    }
    lli hmax = *max_element(all(hv));
    lli wmax = *max_element(all(wv));
    set<lli> hp,wp;
    rep(i,h){
        if(hv[i]==hmax){
            hp.insert(i);
        }
    }
    rep(i,w){
        if(wv[i]==wmax){
            wp.insert(i);
        }
    }
    lli ans = hmax + wmax - 1;
    bool c = true;
    for(lli a:hp){
        for(lli b:wp){
            if(!check.count(pii(a,b))){
                ans = hmax + wmax;
                c = false;
                break;
            }
        }
        if(!c){
            break;
        }
    }
    out(ans);
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N;
string S;

int main(void) {
    cin >> N >> S;
    ll R = 0, G = 0, B = 0;
    rep(i, N) {
        if (S[i] == 'R') R++;
        if (S[i] == 'G') G++;
        if (S[i] == 'B') B++;
    }

    ll ans = R * G * B;

    for (int i = 0; i < N; ++i) {
        for (int d = 0; d < N; ++d) {
            int j = i + d;
            int k = j + d;

            if (k >= N) break;

            if ((S[i] != S[j]) && (S[j] != S[k]) && (S[i] != S[k])) ans--;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 100005;

int n, m;
int pref[N];

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    pref[x]++;
    pref[y + 1]--;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    pref[i] += pref[i - 1];
    ans += (pref[i] == m);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))
print(*a)
for i in range(1, n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j -= 1
    a[j + 1] = v
    print(*a)


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

int main(){
  int n;
  cin>>n;
  int ans=0;

  int a,adj=1;
  cin>>a;
  for(int i=1; i<n; i++){
    int b;
    cin>>b;
    if(a==b)adj++;
    else{
      ans+=adj/2;
      adj=1;
    }
    if(i==n-1)ans+=adj/2;
    a=b;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# 1. 両端にaもbも含まれないもしくは「先頭がaで末尾がb」は分けて考える 最後にテキトーに加えてやる
# 2. 「先頭がb」「末尾がa」「先頭がbで末尾がa」
# cca
# caa
# bac
# bbc
# bccca < -これは連結したほうがよさそう連結したあとに左にooa右にbooを加える
# あまったooaとbooで適当にくっつける
n = int(input())
ans = 0
both = 0
a, b = 0, 0
for _ in range(n):
    s = input()
    if s[0] != "B" and s[-1] != "A":
        ans += s.count("AB")
    else:
        if s[0] == "B" and s[-1] == "A":
            both += 1
            ans += s.count("AB")
        elif s[0] == "B":
            b += 1
            ans += s.count("AB")
        elif s[-1] == "A":
            a += 1
            ans += s.count("AB")
# 両脇にあるやつを連結
if both > 0:
    ans += both - 1
    # 連結したやつの先頭に加えられたら加える
    if a > 0:
        ans += 1
        a -= 1
    # 同じく末尾
    if b > 0:
        ans += 1
        b -= 1
# 余ったやつで作成
ans += min(a, b)
print(ans)


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(100);
  A.at(0) = 2;
  A.at(1) = 1;
  for (int i = 2; i < 100; i++) {
    A.at(i) = A.at(i - 1) + A.at(i - 2);
  }
  cout << A.at(N) << endl;  
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=1e5+5;
int b[N],d[N],st[N],c[2],n;ll res;
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&b[i]),d[i]=b[i];
	sort(d+1,d+1+n);
	fp(i,1,n)st[i]=lower_bound(d+1,d+1+n,b[i])-d,c[st[i]&1]+=((st[i]&1)^(i&1));
	printf("%lld\n",max(c[0],c[1]));
	return 0;
}

Measured memory_bytes: 1408
import math

N = int(input())
n = int(math.sqrt(N))
fact = [0] * (N + 1)
MOD = 10 ** 9 + 7

for i in range(2, N + 1):
    tmp = i
    for j in range(2, n + 1):
        if tmp % j == 0:
            while tmp % j == 0:
                fact[j] += 1
                tmp = tmp // j

    if tmp != 1:
        fact[tmp] += 1
ans = 1
for f in fact[1:]:
    ans *= f + 1
    ans %= MOD

print(ans)


Measured memory_bytes: 3064
N = gets.to_i
NB = N.to_s(2)
NL = NB.length

MOD = 10**9+7

dp = Array.new(NL){Array.new(3)}
dp[0] = [1, 1, 0]

(1...NL).each do |i|
    if NB[i] == '0'
        dp[i][0] = dp[i - 1][0] + dp[i - 1][1]
        dp[i][1] = dp[i - 1][1]
        dp[i][2] = dp[i - 1][1] + 3 * dp[i - 1][2]
    else
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = dp[i - 1][0] + dp[i - 1][1]
        dp[i][2] = 2 * dp[i - 1][1] + 3 * dp[i - 1][2]
    end
    dp[i].map!{|v| v % MOD}
end

puts dp[NL - 1].inject(:+) % MOD

Measured memory_bytes: 1788
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 500000
#define mod 998244353
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int main()
{
    int k; scanf("%d",&k);
    rep(i,1,k) printf("%s","ACL");
    puts("");
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> as(n);
    for (auto &a: as) {
        cin >> a;
    }

    multiset<int> ss(as.begin(), as.end());
    int d = *ss.rbegin();

    for (int i = 0; i <= d; i++) {
        int cd = max(d - i, i);
        auto it = ss.find(cd);
        if (it == ss.end())
        {
            cout << "Impossible" << endl;
            // cerr << "1" << endl;
            return 0;
        }
        ss.erase(it);
    }

    int hi = d;
    int lo = (d + 1) / 2 + 1;

    for (auto &a: ss) {
        if (!(a >= lo && a <= hi)) {
            cout << "Impossible" << endl;
            // cerr << "2: " << a << endl;
            return 0;
        }
    }

    cout << "Possible" << endl;

    return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
vw = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]

for i in range(N):
    for j in range(W + 1):
        v, w = vw[i]

        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

        if j >= w:
            dp[i + 1][j] = max(dp[i + 1][j - w] + v, dp[i][j])


print(dp[N][W])



Measured memory_bytes: 42468
#include<bits/stdc++.h>
#define MAXN 100005
#define inf 1000000000001
using namespace std;

int main (){
	
	//freopen("t.txt","r",stdin);
	long long n;
	cin>>n;
	cout<<(n-1+1)*(n-1)/2;
	return 0;
}

Measured memory_bytes: 256
S = input()+"E"

c = 0
p_ss = "S"
n_ss = S[0]
for i in range(1, len(S)):
    #print(i, c, n_ss, p_ss)                                                             
    if n_ss != p_ss:
        c += 1
        p_ss = n_ss
        n_ss = S[i]
    else:
        n_ss += S[i]
print(c)

Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define BP 1000000007

using namespace std;

typedef unsigned long long ull;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

typedef vector<pair<long, long> > vpl;
typedef vector<pair<int, int> > vpi;

typedef queue<long> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    ll n, m; cin >> n >> m;

    if (abs(n - m) > 1) {
        cout << 0 << endl;
        return 0;
    }

    ull ans = 1;
    if (n == m) {
        for (ull i = 2; i <= n; ++i) ans = (ans * i) % BP;
        ans = (ans * ans) % BP;
        ans = (ans * 2) % BP;
        cout << ans << endl;
    } else {
        ll mini = min(n, m);
        for (ull i = 2; i <= mini; ++i) ans = (ans * i) % BP;
        ans = (ans * ans) % BP;
        ans = (ans * max(n, m)) % BP;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//UTF-8でコーディングしています
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A*B*C==5*5*7){
  	cout << "YES" << "\n";
  }else{
    cout << "NO" << "\n";
  }
  
}

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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define s second

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


template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
	friend ostream& operator<<(ostream& os, P p) {
		return os << "(" << p.x << "," << p.y << ")"; }
};

typedef Point<double> P;
double ccRadius(const P& A, const P& B, const P& C) {
	return (B-A).dist()*(C-B).dist()*(A-C).dist()/
			abs((B-A).cross(C-A))/2;
}
P ccCenter(const P& A, const P& B, const P& C) {
	P b = C-A, c = B-A;
	return A + (b*c.dist2()-c*b.dist2()).perp()/b.cross(c)/2;
}

pair<P, double> mec(vector<P> ps) {
	shuffle(all(ps), mt19937(time(0)));
	P o = ps[0];
	double r = 0, EPS = 1 + 1e-8;
	rep(i,0,sz(ps)) if ((o - ps[i]).dist() > r * EPS) {
		o = ps[i], r = 0;
		rep(j,0,i) if ((o - ps[j]).dist() > r * EPS) {
			o = (ps[i] + ps[j]) / 2;
			r = (o - ps[i]).dist();
			rep(k,0,j) if ((o - ps[k]).dist() > r * EPS) {
				o = ccCenter(ps[i], ps[j], ps[k]);
				r = (o - ps[i]).dist();
			}
		}
	}
	return {o, r};
}

int n;
vector<Point<double>> p;
int main(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        Point<double> a;
        cin >> a.x >> a.y;
        p.push_back(a);
    }
    cout << setprecision(10) << fixed;
    cout << mec(p).s;
}

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

D = {}
for a in A:
    if a not in D:
        D[a] = 1
    else:
        D[a] += 1
E = sorted(D.values())
c = 0
i = 0
l = len(D)
while l > K:
    c += E[i]
    l -= 1
    i += 1
print(c)

Measured memory_bytes: 32184
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    w = input()
    cnt = Counter(w)
    ans = 'Yes'
    for i in cnt.values():
        if i&1:
            ans = 'No'
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
n,w=map(int, input().split())
m=10**5+1
x=[list(map(int, input().split())) for i in range(n)]
dp=[[float('inf')]*m for i in range(n+1)]
dp[0][0]=0
for i in range(n):
    for j in range(m):
        if j>=x[i][1]:
            dp[i+1][j]=min(dp[i][j],dp[i][j-x[i][1]]+x[i][0])
        else:
            dp[i+1][j]=dp[i][j]
ans=0
for i in range(m):
    if dp[-1][i]<=w:ans=max(ans,i)
print(ans)

Measured memory_bytes: 310808
#include <stdio.h>

int A[2000000],B[2000001];/*なぜここが中にはいると、セグルのか*/

int main(int argc, char *argv[]){
    int n,k=0;
    int i,j;
    
    int C[10000]={0};
    
    scanf("%d",&n);
    
    
    
    if(1>n || n>2000000)return 0;
    
    
  //  int B[n];
    
    /* incert */
    for(i=1;i<=n;i++){
        scanf("%d",&A[i]);
        if(A[i]>=k)k=A[i];
    }
    
    for(i=0;i<k;i++){
        C[i]=0;
    }
    
    for(j=1;j<=n;j++){
        C[A[j]]++;
    }
    
    for(i=1;i<=k;i++){
        C[i]=C[i]+C[i-1];
    }
    
    for(j=n;j>=1;j--){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
    for(i=1;i<n;i++){
        printf("%d ",B[i]);
    }
    printf("%d\n",B[n]);
    /**/
    return 0;
}// End main

Measured memory_bytes: 16272
#include<iostream>
#include<string>
using namespace std;
 
int main() {
    int N;
    char a,b;
    cin >> a >> b;
    if(a == '9' || b == '9'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    
    return 0;
}

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

int main(){
  
    int N;
    cin>>N;
    vector<int> S(100001,100000);
    S.at(0)=0;
    vector<int> A{1,6,36,216,1296,7776,46656,9,81,729,6561,59049};
    for(int i=1;i<100001;i++){
        for(int j=0;j<12;j++){
            if(i-A.at(j)>=0){
                S.at(i)=min(S.at(i),(S.at(i-A.at(j))+1));
            }
        }
    }
    cout<<S.at(N)<<endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  const ll mod = 1e9+7;
  cin>>n;
  vector<ll> t(n);
  vector<ll> a(n);
  rep(i,n)cin>>t[i];
  rep(i,n)cin>>a[i];
  if(n==1) {
    if(t[0]==a[0]) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }
  vector<ll> h(n);
  ll ans=1;
  ll h0=t[0];
  if(a[0]>a[1]) {
    if(a[0]==h0) {
      ans*=1;
    } else {
      ans*=0;
    }
  } else {
    if(h0<=a[0]) {
      ans*=1;
    } else {
      ans*=0;
    }
  }
  repeat(i,1,n-1) {
    if(t[i-1]<t[i]) {
      ll h = t[i];
      if(a[i]>a[i+1]) {
        if(a[i]==h) {
          ans*=1;
        } else {
          ans*=0;
        }
      } else {
        if(h<=a[i]) {
          ans*=1;
        } else {
          ans*=0;
        }
      }
    } else {
      // h<=t[i]
      if(a[i]>a[i+1]) {
        ll h = a[i];
        if(h<=t[i]) {
          ans*=1;
        } else {
          ans*=0;
        }
      } else {
        ans*=min(a[i],t[i]);
      }
    }
    ans%=mod;
  }
  ll hn1=a[n-1];
  if(t[n-1]>t[n-2]) {
    if(t[n-1]==hn1) {
      ans*=1;
    } else {
      ans*=0;
    }
  } else {
    if(hn1<=t[n-1]) {
      ans*=1;
    } else {
      ans*=0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
X,N=map(int,input().split())
p=list(map(int,input().split()))



x = y = X
true=[]
jud = True
while jud:
    if x not in p:
        true.append(x)
        break
    x += 1
while jud:
    if y not in p:
        true.append(y)
        break
    y -= 1

abs=[abs(t-X) for t in true]
#print(true[abs.index(min(abs))])
true_list=[i for i,a in enumerate(abs) if a==min(abs)] #絶対値が小さいものの添字リスト
true_list2=[true[i] for i in true_list]
print(min(true_list2))


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 1e14
#define N 500001
#define K 4
#define ALPHA 1.5
#define BETA 1.0



int32_t main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int d;
    cin >> d;
    vector<int> c(26);
    double average = 0.0;
    int mxc = 0;

    for(int i = 0;i < 26;i++)
    {

        cin >> c[i];
        mxc = max(mxc,c[i]);
    }
    vector<vector<int>> v(d,vector<int>(26,0));
    for(int i = 0;i < d;i++)
    {
        for(int j = 0;j < 26;j++)
        {
            cin >> v[i][j];
            average += v[i][j];
        }
    }
    average /= (d * 26);
    vector<int> last(26,-1);
    for(int i = 0;i < d;i++)
    {
        double mxgain = -inf;
        int ind = -1;

        for(int j = 0;j < 26;j++)
        {
            double gain = pow(v[i][j],BETA) + pow((i - last[j]) * c[j],1.0 + (double)c[j] / mxc);
            // cerr << j << " " << gain << endl;
            if(gain > mxgain)
            {
                mxgain = gain;
                ind = j;
            }
        }
        last[ind] = i;
        cout << ind + 1 << endl;
    }

    
    return 0;    
} 



Measured memory_bytes: 4296
S = input()
T = []
tmp = '1'
for i in range(len(S)-1):
    if tmp[-1] == '0':
        tmp += '1'
    else:
        tmp += '0'
T.append(tmp)
tmp = '0'
for i in range(len(S)-1):
    if tmp[-1] == '0':
        tmp += '1'
    else:
        tmp += '0'
T.append(tmp)
ans = float('inf')
for j in range(2):
    cnt = 0
    for i in range(len(S)):
        if S[i] != T[j][i]:
            cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)


Measured memory_bytes: 3316
#include <stdio.h>

int main(void) {
	int l,m,n,i,y;
	while(scanf("%d",&l),l!=0){
		y=1;
		for(i=1;i<=12;i++){
			scanf("%d%d",&m,&n);
			l-=m-n;
			if(l<=0&&y==1){
				printf("%d\n",i);
				y=0;
			}
		}
		if(y) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

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; }

vector<vector<int>> tos;
ll dp[100010];

ll rec(int s)
{
	if (dp[s] != -1) {
		return dp[s];
	}
	ll res = 0;
	for (auto to : tos[s]) {
		res = max(res, rec(to) + 1);
	}
	return dp[s] = res;
}

void Main()
{
	int N, M; cin >> N >> M;
	rep(i,N) {
		vector<int> v;
		tos.push_back(v);
	}
	rep(i,M) {
		int x, y; cin >> x >> y;
		--x; --y;
		tos[x].push_back(y);
	}
	memset(dp, -1, sizeof(dp));
	rep(i,N) {
		if (dp[i] == -1) {
			rec(i);
		}
	}
	ll res = 0;
	rep(i,N) {
		chmax(res, dp[i]);
	}
	cout << res << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


Measured memory_bytes: 9072
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e4 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}



int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

      bool flag=false;

      string str;


       cin>>n;

     vector<plll>v;

       for(i=0; i<n; i++)
       {
           cin>>a>>b>>c;

          v.pb({a+b,{a,c}});
       }

       sort(vll(v));

       ll mx=0,dp[Max+2]={};



     for(auto x : v)
     {
         ll solid=x.F,w=x.S.F,v=x.S.S;

         for(i=solid-w; i>=0; i--)
         {
              dp[i+w]=max(dp[i+w],dp[i]+v);

              mx=max(mx,dp[i+w]);
         }
     }

     cout<<mx<<endl;




}

Measured memory_bytes: 3816
#include "bits/stdc++.h"
using namespace std;
#define OUT(x) cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }
 
static const int MOD = 1000000007;
#define int long long
 
long long inv(long long x) {
        long long  y = 1;
        while (y % x) y += MOD;
        return y / x;
}
 
long long nCr(long long n, long long r) {
        if (n < r) return 0;
        if (n - r < r) r = n - r;
        long long ret = 1;
        rep(i, r) {
                ret = ret * n % MOD;
                n --;
                ret = ret * inv(i + 1) % MOD;
        }
        return ret;
}
 
long long nHr(long long n, long long r) {
        return nCr(n + r - 1, r);
}
 
signed main() { 
        int n, m;
	cin >> m >> n;
        if (n < 0) n *= -1;
        int ans = 1;
        for (int i = 2; i * i <= n; i ++) if (n % i == 0) {
                int cnt = 0;
                while (n % i == 0) {
                        n /= i;
                        cnt ++;
                }
                ans = ans * nHr(m, cnt) % MOD;
        }
        if (n > 1) ans = ans * nHr(m, 1) % MOD;
        // rep(i, m - 1) ans = ans * 2 % MOD;
        cout << ans << endl;
        return 0;
}   

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k,  m, y, q ;
string s, t;
ld w;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n ;
	vll a(n) ;
	for(ll i=0;i<n;i++) cin>>a[i];
	ll ans = 0;
	for(ll i=0;i<n;i++) {
		for(ll j=i+1;j<n;j++) {
			ans += a[i] * a[j];
		}
	}
	cout<<ans;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
     
using namespace std;
     
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int n, m;

int f(pair<pair<int, int>, int> a)
{
    if (a.fi.se == 0)
        return a.fi.fi;
    else if (a.fi.fi == n)
        return n + a.fi.se;
    else if (a.fi.se == m)
        return n + m + (n - a.fi.fi);
    else
        return n + m + n + (m - a.fi.se);
}

bool comp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b)
{
    return f(a) < f(b);
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int k;
    cin >> n >> m >> k;
    vector<pair<pair<int, int>, int> > a;
    rep(i, 0, k)
    {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if ((x1 == 0 || x1 == n || y1 == 0 || y1 == m) && (x2 == 0 || x2 == n || y2 == 0 || y2 == m))
        {
            a.push_back({{x1, y1}, i});
            a.push_back({{x2, y2}, i});
        }
    }
    sort(a.begin(), a.end(), comp);
    vector<int> xxx;
    for (auto it : a)
        if (sz(xxx) > 0 && xxx.back() == it.se)
            xxx.pop_back();
        else
            xxx.push_back(it.se);
    cout << (sz(xxx) == 0 ? "YES\n" : "NO\n");
    return 0;
}

Measured memory_bytes: 4852
S = input()
T = input()

n = len(S)
m = len(T)
ans = 0
for i in range(n-m+1):
    tmp = 0
    for j in range(m):
        if S[i+j] == T[j]:
            tmp += 1
    ans = max(ans,tmp)
print(m-ans)


Measured memory_bytes: 9120
n,p=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]=a[i]%2
one=sum(a)
zero=n-one
if p==1 and one==0:
    print(0)
    exit()
if p==0 and one==0:
    print(2**n)
    exit()
print(2**(n-1))

Measured memory_bytes: 9164
using System;

public class Hello
{
    public static int flag = 0;
    public static void Main()
    {
        var readline = Console.ReadLine();
        var split = readline.Split(' ');
        int a = int.Parse(split[0]);
        int b = int.Parse(split[1]);
        int sum = a + b;
        if (sum % 2 != 0) sum++;
        Console.WriteLine(sum / 2);
        ;
    }
    
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n = 0;
    cin >> n;
    int l[n];
    for(int i = 0;i<n;i++) cin >> l[i];
  	sort(l,l+n);
    int ans = 0;
    for(int i = 0;i<n;i++){
    	for(int j = 0;j<i;j++){
        	for(int k = 0;k<j;k++){
            	if(l[i] != l[j] && l[i] != l[k] && l[k] != l[j] && l[j] +l[k] >l[i]){
                  ans++;
                }
            }
        }  
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int cost[100001];
int h[100001];
int abs(int a) {
	if(a<0) return -a;
	return a;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	for(int i = 0; i < n; ++i) {
		cin>>h[i];
	}
	cost[0] = 0;
	cost[1] = abs(h[0] - h[1]);
	for(int i = 2; i < n; ++i) {
		cost[i] = min(cost[i-2]+abs(h[i] - h[i-2]),cost[i-1]+abs(h[i] - h[i-1]));
	}
	cout<<cost[n-1]<<"\n";
	return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;  cin>>n;
  int a[n];
  int hasha[n]={0};
  for(int i=0;i<n;i++)  hasha[i]=0;
  long long int ans=0,mod=1000000007;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    ++hasha[a[i]];
    if(hasha[a[i]]>2)
    ans=-1;
  }
  
  if((n%2 && hasha[0]!=1) || (n%2==0 && hasha[0]!=0) || ans==-1)
  {
    cout<<"0";
  }
  else
  {
    for(int i=1;i<n;i++)
    {
      if(!(hasha[i]==0 || (hasha[i]==2)))
      {
        ans = -1;
        break;
      }
    }
    if(ans!=-1)
    {
      n=n>>1;ans=1;
      for(int i=0;i<n;i++)
      {
        ans*=2;
        ans%=mod;
      }
      cout<<ans;
    }
    else if(ans==-1)
    cout<<"0";
  }
  
  return 0;
}

Measured memory_bytes: 4392
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)
int board[10001];
int pop(int x){int n = 0;while(x!=0){n=n+1;x=x&(x-1);}return n;}

int main() {int n,i,j,k,r,c;while(scanf("%d %d",&r,&c),r|c) {memset(board,0,sizeof(board));rep(i,r)rep(j,c){scanf("%d",&k);if(k)board[j]|=(1<<i);}int ans=0,tt,t;rep(i,(1<<r)){t=0;rep(j,c){tt=pop(board[j]^i);t+=max(tt,r-tt);}ans=max(ans,t);}printf("%d\n",ans);}}

Measured memory_bytes: 804
//intのオーバーフローに気をつけろ,AGCはだいたいlongにしておけ
//毎回余りを求めることでオーバーフローしなくなる
//nextLineよりnextだ
//charは''で囲うんだぞ
//読み込みは先に全部やっておけ
//for文を回す回数に気をつけろ
	//for文は10^3の三重はTLE,10^5の二重はTLE,10^9のforはTLE
//貪欲は使えるか？？試した？？

import java.util.Scanner;

public class Main {

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

		    int n = sc.nextInt();
		    //2*nが連続する2整数の積で表されたとき行けるっぽい.
		    int i = 1;
		    int count = 0;
		    while(i * (i+1) <= 2*n) {
		    	if(i*(i+1)==2*n) {
		    		count++;
		    		break;
		    	}else {
		    		i++;
		    		continue;
		    	}
		    }

	    	int[][] array  = new int[i][i+1];
		    if(count == 0 ) {
		    	System.out.println("No");
		    }else {
		    	System.out.println("Yes");
		    	System.out.println(i+1);
		    	for(int j = 0; j < i; j++) {
		    		for(int k = 0; k < i+1; k++) {
		    			if( j >= k)//オリジナル
		    				array[j][k] = j + i*k - k*(k+1)/2 + 1;
		    			
		    		}
		    	}
		    	for(int j = 0; j < i; j++) {
		    		for(int k = 0; k < i+1; k++) {
		    			if( j < k)
		    				array[j][k] = array[k-1][j];
		    			
		    		}
		    	}

			    for(int k = 0; k < i+1; k++) {
			    	System.out.print(i);
			    	for(int j = 0; j < i; j++) {
			    		System.out.print(" "+ array[j][k]);
			    	}
			    	if(k < i) {
			    			System.out.print("\n");
			    		}
			    }
		    }
		    
		    
		    
		    sc.close(); }

	public static void saiki(int a, String b) {
		//再帰コーディングのお手本

		if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		}
	}

	public static  int gcd(int a, int b) {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;
	}
}


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

void solve(){
    string sa, sb, sc;
    cin >> sa;
    cin >> sb;
    cin >> sc;
    reverse(sa.begin(), sa.end());
    reverse(sb.begin(), sb.end());
    reverse(sc.begin(), sc.end());
    char c = sa.back();
    sa.pop_back();
    int sign;
    while(true){
        if(c == 'a'){
            c = sa.back();
            if(c == '\0'){
                sign = 1;
                break;
            }
            sa.pop_back();
            continue;
        }
        if(c == 'b'){
            c = sb.back();
            if(c == '\0'){
                sign = 2;
                break;
            }
            sb.pop_back();
            continue;
        }
        if(c == 'c'){
            c = sc.back();
            if(c == '\0'){
                sign = 3;
                break;
            }
            sc.pop_back();
            continue;
        }
    }
    if(sign == 1) cout << "A" << endl;
    if(sign == 2) cout << "B" << endl;
    if(sign == 3) cout << "C" << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define FST first
#define SCD second
#define modp 1000000007
#define MODP 1000000
#define EPS 1e-7
#define INF 0x3f3f3f3f
#define MAX2 113
#define MAX3 5013
#define MAX4 10013
#define MAX5 100013
#define MAX6 2000013
#define MAXN 100013
#define MANX MAXN
using namespace std;
typedef long long LL;
typedef unsigned int UI;
const UI tb[32] = {13, 0, 27, 1, 28, 18, 23, 2, 29, 21, 19, 12, 24, 9, 14, 3, 30, 26, 17, 22, 20, 11, 8, 13, 25, 16, 10, 7, 15, 6, 5, 4};
#define LOG(x) tb[(UI(x) * (UI)263572066) >> 27]
typedef pair<int,int> PA;
typedef pair<PA,PA> PF;
typedef pair<double,double> PAf;

int n,m,tot;

struct E
{
    int a, nxt;
    // E(){}
    // E(int x, int y, int z) : a(x), nxt(y), c(z) {}
};


int main()
{
#ifndef ONLINE_JUDGE
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    int TT = 1;
    // scanf("%d",&TT);
    for (int ci=1;ci<=TT;++ci) {
    // while (scanf("%d", &n)!=EOF) {
        // scanf("%d", &n);
        LL X,Y;
        int cnt = 1;
        cin>>X>>Y;
        while ((X<<1)<=Y) X<<=1, ++cnt;
        cout<<cnt<<endl;

    }
    return 0;
}

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

using namespace std;

//https://atcoder.jp/contests/abc061/tasks/abc061_b

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

    vector<int> city(N);

    for(int i=0;i<M;i++){
        int tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        
        city.at(tmp1-1) += 1;
        city.at(tmp2-1) += 1;
    }

    for(int i=0;i<N;i++){
        cout << city.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

LL r,D,n;

void dane() {
	cin>>r>>D>>n;

	F(i,0,10) {
		n = r*n - D;
		cout<<n<<endl;
	}

}   


int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

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

int main(int argc, char const *argv[]) {
  int N, p[100], i,swap,j,key[100],k;
  char S[100][11], tmp[11];

  scanf("%d\n", &N);
  for (i = 0; i < N; i++) {
    scanf("%s ", S[i]);
    scanf("%d\n", &p[i]);
  }

  for (i = 0; i < N; i++) {
    key[i] = i+1;
  }

  for(i=1;i<N;i++){
    for(j=1;j<N;j++){
      if(strcmp(S[j-1], S[j])>0){
        strcpy(tmp, S[j-1]);
        strcpy(S[j-1], S[j]);
        strcpy(S[j], tmp);
        swap = p[j-1];
        p[j-1] = p[j];
        p[j] = swap;
        swap = key[j-1];
        key[j-1] = key[j];
        key[j] = swap;
      }
    }
  }

  for (i = 1; i < N; i++) {
    if (strcmp(S[i-1], S[i]) == 0) {
      for (j = i; strcmp(S[j-1], S[j]) == 0; j++) {
        for(k = i; strcmp(S[k-1], S[k]) == 0; k++){
          if(p[k-1] < p[k]){
            swap = p[k-1];
            p[k-1] = p[k];
            p[k] = swap;
            swap = key[k-1];
            key[k-1] = key[k];
            key[k] = swap;
          }
        }
      }
      i=j;
    }
  }

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


  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define em emplace
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int h, w, k;
int board[33][33];

void change(int board[33][33]){
    for (int j = 0; j < w; j++) {
        for (int _ = 0; _ < h; _++) {
            bool flag = 1;
            for (int i = 0; i < h - 1; i++) {
                if(board[i][j] == 0) {
                    swap(board[i + 1][j], board[i][j]);
                    flag = 0;
                }
            }
            if(flag) break;
        }
    }
    return;
}

int start(int y, int x){
    int score = 0;
    int grid[33][33];
    rep(i, 33) rep(j, 33) grid[i][j] = board[i][j];

    grid[y][x] = 0;
    change(grid);

    for (int l = 0; l < 40; l++) {
        int sum = 0;
        for (int i = 0; i < h; i++) {
            int last = grid[i][0], idx = 0, cnt = 0;
            while(idx < w) {
                while (last == grid[i][idx]) {
                    idx++;
                    cnt++;
                }
                if (cnt >= k) {
                    sum += last * cnt;
                    for (int j = idx - 1; cnt; cnt--, j--) grid[i][j] = 0;
                }
                cnt = 0;
                last = grid[i][idx];
            }
        }
        if(sum == 0) break;
        score += sum * pow(2, l);
        change(grid);
    }

    return score;
}

int main(){
    cin >> h >> w >> k;
    memset(board, -1, sizeof board);
    for (int i = h - 1; i >= 0; i--) for (int j = 0; j < w; j++) {
        char c;
        cin >> c;
        board[i][j] = c - '0';
    }
    int ans = 0;
    rep(i, h) rep(j, w) chmax(ans, start(i, j));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main
import (
	"fmt"
)
func main() {
	var n int
	fmt.Scanf("%d", &n)
	answer := maxMove(n)
	fmt.Println(answer)
}

func maxMove(n int) int {
	currentCount := 0
	max := 0
	var prev int
	for i:= 0; i < n; i++ {
		var h int
		fmt.Scanf("%d", &h)
		if i == 0 {
			prev = h
			continue
		}
		if prev >= h {
			currentCount++
			if currentCount > max {
				max = currentCount
			}
		} else {
			currentCount=0
		}
		prev = h
	}
	return max
}


Measured memory_bytes: 5504
# if true

# include <iostream>

using Int = int;


Int count(Int val)
{
    Int result{};

    for (Int i{1}; i <= val; ++i)
    {
        if (val % i == 0) ++result;
    }

    return result;
}

int main() 
{

    Int N;
    std::cin >> N;

    Int result{};
    for (Int i{1}; i <= N; i += 2)
    {
        if (count(i) == 8)
        {
            ++result;
        }
    }

    std::cout << result;

}

# endif

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

constexpr unsigned long opposite(unsigned long v){
    return (~(~0LL << 64 - __builtin_clzl(v)) ^ v) + 1;
}

int main(){
    using namespace std;

    unsigned long N;
    cin >> N;
    deque<pair<unsigned long, bool>> A(N, {0, 1});
    for(auto& i : A)cin >> i.first;
    sort(A.begin(), A.end());

    unsigned long ans{0};
    auto i = A.back();
    for(A.pop_back(); !A.empty(); i = A.back(), A.pop_back())if(i.second && binary_search(A.begin(), A.end(), pair<unsigned long, bool>({opposite(i.first), 1})) && ++ans)A[lower_bound(A.begin(), A.end(), pair<unsigned long, bool>({opposite(i.first), 1})) - A.begin()].second = false;

    cout << ans << endl;
}

Measured memory_bytes: 3456