akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int simArray[10];
int n,a[10];
void makeArray(int z){
    if(z==n){

    }
    return ;
}
int main(){
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    //3^10だから全探索できる
    //全探索しなくても表現可能な数列から偶数を含む数列を引けばいいかも？
    int b=1;
    for(int i=0; i<n; i++){
        b*=3;
    }
    int even=1;
    for(int i=0; i<n; i++){
        if(!(a[i]%2)) even*=2;
    }
    cout << b-even << endl;
    
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    ll res = 0;
    if (a >= k) {
        cout << k * 1 << endl;
        return 0;
    } else {
        res = a * 1;
        k -= a;
    }
    if (b >= k) {
        cout << res << endl;
        return 0;
    } else {
        k -= b;
    }
    cout << res - (k * 1) << endl;

    return 0;
}

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

int main()
{
    int N;
    int count = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        int tmp_c = 0;
        while (!(A % 2))
        {
            tmp_c++;
            A /= 2;
        }
        if (i == 0 || tmp_c < count)
        {
            count = tmp_c;
        }
    }
    cout << count << endl;
}


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

int main() {
  int n; cin >> n;
  vector<int> t(n+1,0),x(n+1,0),y(n+1,0);
  for(int i=1; i<n+1; i++) {
    cin >> t[i] >> x[i] >> y[i];
    int dt=t[i]-t[i-1];
    int dx=abs(x[i]-x[i-1]);
    int dy=abs(y[i]-y[i-1]);
    if(dt%2==(dx+dy)%2 && dt>=(dx+dy)) continue;
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 4576
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007


int main()
{
   int n,x;
   cin>>n>>x;
   int arr[n];
   for(int i=0;i<n;i++)
      cin>>arr[i];
   int sum = 0,count = 1;
   for(int i=0;i<n;i++)
   {
      sum += arr[i];
      if(sum<=x)
         count++;
   }
   cout<<count;
   return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }
ll mini(ll a,ll b) {if(a<b) return a; else return b;}

int main(){
  ll x,y,tmp;
	cin>>x>>y;

	ll g = gcd(x,y);

	for(ll i=2; i<= g / i; i++)
		if(g%i==0)
			{
				tmp++;
				while(g%i == 0) g /= i;
			}

	if(g>1)tmp++;
	cout<<tmp+1<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
   int n, r = 0, t;
  scanf("%d", &n);
 
   t = n;
 
   while (t != 0)
   {
      r = r * 10;
      r = r + t%10;
      t = t/10;
   }
 
   if (n == r)
      printf("Yes");
   else
      printf("No");
 
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define ma 100000000
#define mod 1000000007
const ll  INF=10000000000000;
using namespace std;
int h[200005] ;

void add(ll& a , ll b){
    a += b ;
    a %= mod ;
}
void sub(ll& a , ll b){
    a -= b ;
    if(a<0) a += mod ;
}
void multiply(ll& a , ll b){
    b %= mod ;
    a *= b;
    a %=mod ;
}
ll segmt[1000000];
ll dp[200005] ;
ll query(int p , int l , int r , int H){
    if(H >= r) return segmt[p];
    if(l > H) return 0;
    if(l == r) return segmt[p];
    int mid = (l + r ) / 2;
    return max(query(2 * p + 1, l , mid , H), query(2 * p + 2, mid  + 1 , r , H));
}
void update(int p , int l , int r , int  H){
    if(H > r || H < l ) return ;
    segmt[p] = max(segmt[p] , dp[H]);
    if(l == r) return;
    int mid = (l + r) / 2;
    update(2 * p + 1, l , mid , H);
    update(2 * p + 2 , mid  + 1 ,r  , H);
}
int main()
{
    int n ; cin >> n;
    ll a[n] ;
    memset(segmt , 0 , sizeof segmt) ;
    for(int i = 0 ; i < n ; i++) {cin >> h[i] ; h[i] --;}
    for(ll& x:a) cin >> x;
    memset(dp , 0 , sizeof dp );
    for(int i = 0 ; i < n; i++){
        dp[h[i]] = a[i];
        dp[h[i]] += query(0 , 0 , n - 1, h[i]);
        update(0 , 0 , n - 1, h[i]) ;
    }
    cout << *max_element(dp , dp + n);
    return 0;
}


Measured memory_bytes: 11904
#include <stdio.h>

int main(void)
{
	int n, i, j;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 10 == 3) {
			printf(" %d", i);
		} else {
			j = i;
			while (j > 0) {
				j /= 10;
				if (j % 10 == 3) {
					printf(" %d", i);
					break;
				}
			}
		}
	}
	printf("\n");
}



Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string s;
	cin >> s;
	
	if (s.back() != 's') s += 's';
	else s += "es";
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3620
import java.util.*;

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

        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();

        if(a>=k){
            a = a - k;
        }
        else if(a<k && b>=(k-a)){
            b = b-(k-a);
            a = 0;
        }
        else{
            a = 0;
            b = 0;
        }
        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 23380
#include<cstdio>
#include <utility>
#include <vector>
#include<algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
	ull N;
	scanf("%llu", &N);
	if(N == 1){
		printf("0\n");
		return 0;
	}
	vector<pair<ull, unsigned> > res;
	ull _n = N;
	for(ull i = 2; i*i <= _n; ++i){
		unsigned count = 0;
		while(N % i == 0){
			count++; // 素数i^{res[i]}
			N /= i;
		}
		if(count) res.push_back(make_pair(i,count));
	}
	if(N != 1) res.push_back(make_pair(N, 1));
	unsigned answer = 0;
	unsigned triangle[8] = {1,3,6,10,15,21,28,36};
	for (int i = 0; i < res.size(); ++i){
		answer += distance(triangle, upper_bound(triangle, triangle + 8, res[i].second));
	}
	printf("%u\n", answer);
	return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll x, k, d; cin >> x >> k >> d;

    if(abs(x)<d){
        if(k%2==0){
            cout << abs(x) << endl;
        }
        else{
            cout << abs(abs(x+d)<abs(x-d)?abs(x+d):abs(x-d)) << endl;
        }
        return 0;
    }

    ll a = abs(x)/d;
    if(k-a<0){
        cout << abs(abs(x-k*d)<abs(x+k*d)?abs(x-k*d):abs(x+k*d)) << endl;
        return 0;
    }

    k -= a;
    if(k%2 == 0){
        cout << abs(abs(x)%d) << endl;
    }
    else{
        cout << abs(((abs(x)%d)-d)<((abs(x)%d)+d)? ((abs(x)%d)-d):((abs(x)%d)+d)) << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
	string str;
	cin >> str;
	int n = stoi(str);
	int len = str.size();
	int sum = 0;
	for (int i = 0; i < len; i++) {
		sum += str[i] - '0';	
	}
	if (n % sum == 0) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<utility>
#include<queue>
using namespace std;
int main(){
  int n,q,time,cnt_time = 0;
  string name;
  queue<pair<string,int> > que;
  cin >> n >> q;
  for(int i=0;i<n;i++){
    cin >> name >> time;
    que.push(make_pair(name,time));
  }
  while(!que.empty()){
    pair<string,int> top = que.front();
    que.pop();
    if(top.second <= q){
      cnt_time += top.second;
      cout << top.first << " " << cnt_time << endl;
    }else{
      cnt_time += q;
      que.push(make_pair(top.first,top.second-q));
    }
  }
}

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

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

  	
  if ((A+B) == (C+D)) {
    cout << "Balanced" << endl;
  }
  else if((A+B) > (C+D)){
    cout << "Left" << endl;
  }
  else{
   cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from math import log,ceil
    n,k=map(int,input().split())
    p=[0]*(n+1)
    for i in range(1,n+1):
        p[i]=max(0,ceil(log(k/i)/log(2)))
    ans=0
    for i in range(1,n+1):
        ans+=2**(-p[i])
    print(ans/n)
resolve()

Measured memory_bytes: 41840
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

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

int h, w;
struct xydata {
    int px; int py; int nex; int ney;
};

int main() {
    cin >> h >> w;
    vector< vector<int> > amap(h, vector<int>(w, 0));
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> amap.at(i).at(j);
        }
    }

    int n = 0;
    vector<xydata> xyvec;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(amap.at(i).at(j)%2 != 0) {
                // そのマスが奇数ならまずは周囲を確認する
                bool flg = false;
                for(int k = 0; k < 4; ++k) {
                    int nx = j+dx[k]; int ny = i+dy[k];
                    if(nx >= 0 && nx < w && ny >= 0 && ny < h) {
                        if(amap.at(ny).at(nx)%2 != 0) {
                            flg = true;
                            n++;
                            xydata indata;
                            indata.px = j; indata.py = i;
                            indata.nex = nx; indata.ney = ny;
                            xyvec.emplace_back(indata);
                            amap.at(i).at(j)--;
                            amap.at(ny).at(nx)++;
                            break;
                        }
                    }
                }
                if(!flg) {
                    for(int k = 2; k < 4; ++k) {
                        int nx = j+dx[k]; int ny = i+dy[k];
                        if(nx >= 0 && nx < w && ny >= 0 && ny < h) {
                            n++;
                            xydata ndata;
                            ndata.px = j; ndata.py = i;
                            ndata.nex = nx; ndata.ney = ny;
                            xyvec.emplace_back(ndata);
                            amap.at(i).at(j)--;
                            amap.at(ny).at(nx)++;
                            break;
                        }
                    }
                }
            }
        }
    }

    cout << n << endl;
    for(int i = 0; i < n; ++i) {
        xydata ans = xyvec.at(i);
        cout << ans.py+1 << " " << ans.px+1 << " " << ans.ney+1 << " " << ans.nex+1 << endl;
    }
}

Measured memory_bytes: 5232
#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: 888
#include<iostream>
using namespace std;

static const int MAX = 10000;

int P[MAX], H[MAX];

void unite(int u1, int u2) {
	while (P[u1] != u1) u1 = P[u1];
	while (P[u2] != u2) u2 = P[u2];
	if (H[u1] < H[u2]) P[u2] = u1;
	else P[u1] = u2;
} 

int same(int n1, int n2) {
	while (P[n1] != n1) n1 = P[n1];
	while (P[n2] != n2) n2 = P[n2];
	if (n1 == n2) return 1;
	else return 0;
}

int main() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++)	{
		P[i] = i;
		H[i] = 0;
	}

	for (int i = 0 ; i < q; i++) {
		int cmd, f, s;
		cin >> cmd >> f >> s;
		if (cmd) cout << same(f, s) << endl;
		else unite(f, s);
	}
	return 0;
}

Measured memory_bytes: 1240
N = int(input())
a = list(map(int, input().split()))

box = [-1] * (N + 1)
ball_in_list = []
# 箱について(i = N, N-1, ..., 1)
for i in range(N, 0, -1):
    cnt = 0
    # (N//i)*i, ..., 3*i, 2*i
    for j in range((N // i) * i, 2 * i - 1, -i):
        cnt += box[j]

    # 偶奇が同じならボールは入れない
    if cnt % 2 == a[i - 1]:
        box[i] = 0
    # 偶奇が異なる時、ボールを入れる、その行為を記録
    else:
        box[i] = 1
        ball_in_list.append(i)

print(len(ball_in_list))
print(*ball_in_list)


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

typedef pair<int,int> pii;

const int mx = 200005;

pii I[mx];
int B[mx];
int n;

void input(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> I[i].first;
        I[i].second = i;
    }
    sort(I,I+n);
}

void pro(){
    for(int i = 0; i < n; i++){
        B[I[i].second] = (i <= (n-2)/2 ? I[n/2] : I[(n-2)/2]).first;
    }
}

void output(){
    for(int i = 0; i < n; i++){
        cout << B[i] << '\n';
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    input();
    pro();
    output();
}


Measured memory_bytes: 4608
import sys;input=sys.stdin.readline
n=int(input())
s=input()
num=2**(n-1).bit_length()
def segfunc(x,y):return x|y
seg=[0]*(2*num-1)
for i in range(n):seg[i+num-1]=2**(ord(s[i])-97)
for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])
def update(i,x):
  i+=num-1;seg[i]=x
  while i:i=(i-1)//2;seg[i]=segfunc(seg[i*2+1],seg[i*2+2])
def query(l,r):
  l+=num-1;r+=num-1
  if l==r:return seg[l]
  s=seg[l];l+=1
  while r-l>1:
    if ~l%2:s=segfunc(seg[l],s)
    if r%2:s=segfunc(seg[r],s);r-=1
    l//=2;r=(r-1)//2
  if l==r:return segfunc(s,seg[l])
  return segfunc(s,segfunc(seg[l],seg[r]))
for _ in range(int(input())):
  quer=input().split()
  if quer[0]=="1":
    _,i,c=quer
    update(int(i)-1,2**(ord(c)-97))
  else:
    _,l,r=quer
    print(sum(map(int,bin(query(int(l)-1,int(r)-1))[2:])))

Measured memory_bytes: 87768
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int a, b;
	cin >> a >> b;
	put(6 - a - b);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){

int H,W,i,j;

    for(;;){
        scanf("%d %d\n",&H,&W);
        if(H==0&&W==0)break;
        for(j=1;j<=H;j++){
            for(i=1;i<=W;i++){
                if(1<i&&i<W&&1<j&&j<H){
                    putchar('.');
                }else{
                    putchar('#') ;
                }    
            }
            putchar('\n');
        }
        putchar('\n');
    }
    
    return 0;
    
}



Measured memory_bytes: 2036
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] t = new int[n+1];
      int sum = 0;
      for(int i = 1;i <= n;i++){
        t[i]=sc.nextInt();
        sum += t[i];
      }
      int m = sc.nextInt();
      int[] p = new int[m+1];
      int[] x = new int[m+1];
      for(int i = 1;i <= m;i++){
      	p[i] = sc.nextInt();
        x[i] = sc.nextInt();
      }
      for(int i = 1;i <= m;i++){
      	System.out.println(sum-t[p[i]]+x[i]);
      }
    }
}

Measured memory_bytes: 22228
n = int(input())
H=[]
for i in range(n):
  H.append(float(input()))
c1=0
c2=0
c3=0
c4=0
c5=0
c6=0

for j in range(n):
  if H[j]< 165.0:
    c1+=1
  elif 165.0<= H[j]<170.0:
    c2+=1
  elif 170.0<= H[j]<175.0:
    c3+=1
  elif 175.0<= H[j]<180.0:
    c4+=1
  elif 180.0<= H[j]<185.0:
    c5+=1    
  else:
    c6+=1
    

print("1:"+ c1*"*", sep="")
print("2:"+ c2*"*", sep="")
print("3:"+ c3*"*", sep="")
print("4:"+ c4*"*", sep="")
print("5:"+ c5*"*", sep="")
print("6:"+ c6*"*", sep="")



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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	vector<pair<LL,LL>> P;
	LL miny = 1e12, maxy = -1;
	repp(i,0,N){
		LL x,y; cin >> x >> y;
		if(x > y) swap(x,y);
		miny = min(miny,y);
		maxy = max(maxy,y);
		P.push_back(make_pair(x,y));
	}
	sort(P.begin(),P.end());
	LL ans = (P[N-1].first-P[0].first)*(maxy-miny);
	LL s = max(P[0].second,P[N-1].first), t = P[0].second;
	repp(i,1,N){
		ans = min(ans,(maxy-P[0].first)*(s-min(t,P[i].first)));
		s = max(s,P[i].second);
		t = min(t,P[i].second);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {

    vector<vector<char>> c(2, vector<char>(3));
    rep(i, 2) {
        rep(j, 3) {
            cin >> c[i][j];
        }
    }

    if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) {
        out("YES");
    }
    else {  
        out("NO");
    }

    re0;
}

Measured memory_bytes: 764
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	lst := make([]int, 4)
	for i := 0; n > 0; i++ {
		lst[i] = n % 10
		n /= 10
	}

	if (lst[0] == lst[1] && lst[1] == lst[2]) || (lst[1] == lst[2] && lst[2] == lst[3]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
n = int(input())
li = [int(input()) for _ in range(n)]

liuse = [0]*n
liuse[0] = 1
for i in range(1,n):
  liuse[i] = li[liuse[i-1]-1]
if 2 in liuse:
  print(liuse.index(2))
else:
  print(-1)

Measured memory_bytes: 7852
s = input()
t = input()
N = len(s)
s2 = s + s
cs = set(t)
#print(cs)
table = {}
for c in cs:
  if s.find(c) < 0:
    table[c] = [-1]*N
    continue
  l = [-2] * N
  p = 0
  while p < N:
    i = s2.find(c, p)
    while p <= i:
      if p < N:
        l[p] = i-p
      p += 1
  table[c] = l
#print(table)
r = 0
for c in t:
  d = table[c][r%N]
  if d < 0:
    print(-1)
    exit()
  r += d+1
print(r)


Measured memory_bytes: 102260
/*
Author：Owen_Q
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 1e7+5;

vector<int> col;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //freopen(".txt","r",stdin);
    string s;
    int k;
    cin >> s >> k;
    col.clear();
    int len = s.size();
    int num = 1;
    char c = s[0];
    int sum = 0;
    for(int i=1;i<len;i++)
    {
        if(s[i]==c)
            num++;
        else
        {
            col.push_back(num);
            sum += num/2;
            num = 1;
            c = s[i];
        }
    }
    col.push_back(num);
    int siz = col.size();
    if(siz==1)
    {
        cout << (ll)(len)*(ll)(k)/2LL << "\n";
    }
    else if(s[0]==s[len-1])
    {
        sum -= col[0]/2;
        cout << (ll)(sum)*(ll)(k) + (ll)(col[0]/2) + (ll)(col[siz-1]/2) + (ll)((col[0]+col[siz-1])/2) * (ll)(k-1);
    }
    else
    {
        sum += col[siz-1]/2;
        cout << (ll)(sum)*(ll)(k) << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
N = input()
a = input().split()
N = int(N)
a = [int(s) for s in a]
Alice = 0
Bob = 0
a.sort()
a.reverse()
for num in range(N):
	if num % 2 == 0:
		Alice += a[num]
	else:
		Bob += a[num]
print(int(Alice - Bob))


Measured memory_bytes: 3060
from collections import defaultdict
N = int(input())
dic = defaultdict(list)
for n in range(N - 1):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)
c_list = sorted(map(int, input().split()))
M = sum(c_list[:-1])
d_list = [False] * N
for i in range(1, N + 1):
    if len(dic[i]) == 1:
        break
blank = N
q = [i]
while blank:
    i = q.pop(0)
    if not d_list[i - 1]:
        q += dic[i]
        d_list[i - 1] = c_list[blank - 1]
        blank -= 1
print(M)
print(' '.join(map(str, d_list)))

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

int main(){
  ll N,A,B;cin>>N>>A>>B;
  vector<ll>d(N-1);
  
  ll a1,a2;
  cin>>a2;
  for(ll i=0;i<N-1;i++){
    a1=a2;
    cin>>a2;
    
    d.at(i)=a2-a1;
  }
  
  long long res=0;
  
  for(int i=0;i<N-1;i++){
    res+=min(B,A*d.at(i));
  }
  
  cout<<res;
}
  

Measured memory_bytes: 1024
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		Set<String> m = new HashSet<>();
		m.add("eraser");
		m.add("dreamer");
		m.add("dream");
		m.add("erase");
		boolean[] a = new boolean[s.length() + 1];
		a[0] = true;
		for (int i = 5; i <= s.length(); i++) {
			if (a[i - 5] && m.contains(s.substring(i - 5, i))) a[i] = true;
			if (i - 6 >= 0 && a[i - 6] && m.contains(s.substring(i - 6, i))) a[i] = true;
			if (i - 7 >= 0 && a[i - 7] && m.contains(s.substring(i - 7, i))) a[i] = true;
		}

		if (a[s.length()]) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 32076
//بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيمِ
//لا إله إلا الله محمد رسول الله

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")

#define ll long long
#define pb push_back
#define fr first
#define sc second
#define in freopen("input.txt", "r" , stdin)
#define out freopen("snakes.out", "w", stdout)
using namespace std;
ll mod = 1e9 + 7;
ll dp[1005][1005];
ll n , m;
char c[1005][1005];
int main(){
    //in;
    //out;

    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> c[i][j];
        }
    }

    dp[1][1] = 1;
    for (int i = 2; i <= m; i++) {
        if (c[1][i] == '#') dp[1][i] = 0;
        else dp[1][i] = dp[1][i-1];
    }

    for (int i = 2; i <= n; i++) {
        if (c[i][1] == '#') dp[i][1] = 0;
        else dp[i][1] = dp[i-1][1];
    }

    for (int i = 2; i <= n; i++) {
        for (int j = 2; j <= m; j++) {
            if (c[i][j] == '.') {
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                dp[i][j] %= mod;
            }
        }
    }
    cout << dp[n][m];
}




Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin>>n;
  long long a[n+1],b[n+1];
  for(long long i=0;i<n;i++)
  {
    cin>>a[i];
    b[i]=a[i];
  }
  sort(a,a+n);
  long long m1=a[n-1];
  long long m2=a[n-2];
  for(long long i=0;i<n;i++)
  {
    if(b[i]==m1)
      cout<<m2<<endl;
    else
      cout<<m1<<endl;
  }
  return 0;
}


Measured memory_bytes: 4736
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

def no_agc(last4):
    for i in range(4):
        cp_last4 = list(last4)
        if i >= 1:
            cp_last4[i-1], cp_last4[i] = cp_last4[i], cp_last4[i-1]
        cp_last_sent = "".join(cp_last4)
        if cp_last_sent.count("AGC") >= 1:
            return False
    return True

ans = 0
memo = [{} for i in range(N+1)]
def dfs(idx, last3):
    if last3 in memo[idx]:
        return memo[idx][last3]
    if idx == N:
        return 1
    ret = 0
    for c in "AGCT":
        if no_agc(last3 + c):
            ret = (ret + dfs(idx + 1, (last3 + c)[1:])) % mod
    memo[idx][last3] = ret
    # print(memo[idx], last3)

    return ret

print(dfs(0, "TTT"))


Measured memory_bytes: 5940
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const ll INF = 1LL << 40;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> T(N), D(N);
    rep(i, 0, N) {
        cin >> T[i] >> D[i];
    }
    vector<vector<ll>> values(N);
    rep(i, 0, N) {
        values[T[i] - 1].push_back(D[i]);
    }
    rep(i, 0, N) {
        values[i].push_back(-INF);  // 番兵
        sort(all(values[i]));
        reverse(all(values[i]));
    }
    sort(all(values));
    reverse(all(values));
    ll ans = (ll)K * (ll)K;
    priority_queue<ll, vector<ll>, greater<ll>> que1;
    priority_queue<ll> que2;
    rep(i, 0, K) {
        ans += values[i].front();
        que1.push(values[i].front());
        rep(j, 1, values[i].size()) {
            que2.push(values[i][j]);
        }
    }
    rep(i, K, N) for (auto& v : values[i]) {
        que2.push(v);
    }
    ll sum = ans;
    rrep(x, K, 1) {
        ll now = que1.top();
        que1.pop();
        ll next = que2.top();
        que2.pop();
        que1.push(next);
        sum += next - now + (ll)x * (ll)x - (ll)(x + 1) * (ll)(x + 1);
        chmax(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    vector<int> a(3);
    for(int i=0;i<3;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    if(a.at(0)==a.at(1)&&a.at(0)!=a.at(2)){
        cout << "Yes";
    }
    else if(a.at(0)!=a.at(1)&&a.at(1)==a.at(2)){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 256
/**
 *    Author:  Oak_limy
 *    Created: 2020-08-29 20:02:07
**/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
       if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
    char c = getchar(); int w = 1; int x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
inline ll readll() {
    char c = getchar(); ll w = 1; ll x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
void fl(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
          dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<((a<=b*c)?("Yes"):("No"))<<endl;
    return 0;
}
/* stuff to remember
    * int overflow, array bounds
    * special cases (n=1? n=0?)
    * do something instead of nothing and stay organized
    * USE STATIC ARRAYS
    * DEFINING ARRAYS BEFORE main()
    * DO NOT DEFINE ARRAYS IN main()
    * USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{
	string s;
	int a[200];
	for (int i = 0; i < 200; i++) {
		a[i] = 0;
	}
	while (getline(cin, s)) {
		for (char c : s) {
			if (c <= 'z' && c >= 'a') {
				++a[c];
			}
			else if (c <= 'Z' && c >= 'A') {
				++a[c + ('a' - 'A')];
			}
		}
	}
	for (char i = 'a'; i <= 'z'; i++) {
		cout << i <<" "<< ':' <<" "<< a[i] << endl;
	}
}




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

typedef long long int ll;

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define endl "\n"

int main()
{
     fast;
     ll n,i,temp,sum=0;
     cin>>n;
     for(i=1;i<=n;i++)
     	if(i%3==0 || i%5==0 || i%15==0)
     		continue;
     	else
     		sum+=i;
     cout<<sum;
  

     return 0;
}

Measured memory_bytes: 3652
def main():
    n,m = map(int,input().split())
    g = {}
    for i in range(1,n+1):
        g[i] = []
    for i in range(m):
        a,b = map(int,input().split())
        g[a] += [b]
        g[b] += [a]
    G = [-1 for i in range(n)]
    c = 0
    for i in range(n):
        if G[i] !=-1:
            continue
        que = [i]
        G[i] = c
        while len(que) > 0:
            q = que.pop(0)
            for v in g[q+1]:
                if G[v-1]!=-1:
                    continue
                G[v-1] = c
                que.append(v-1)
        c += 1
    memb_cnt = [0 for i in range(c)]
    for i in range(n):
        memb_cnt[G[i]] += 1
    print(max(memb_cnt))

if __name__ == "__main__":
    main()


Measured memory_bytes: 60796
#include <iostream>
using namespace std;
int main(void){
    int sur1, sur2, sur3, sur4, sur5, sur6, sur_pro;
    char dir;
    cin >> sur1 >> sur2 >> sur3 >> sur4 >> sur5 >> sur6;
    
    
    while(cin >> dir){
        if(dir == 'N'){
            sur_pro = sur1;
            sur1 = sur2;
            sur2 = sur6;
            sur6 = sur5;
            sur5 = sur_pro;
        }
        else if(dir == 'S'){
            sur_pro = sur1;
            sur1 = sur5;
            sur5 = sur6;
            sur6 = sur2;
            sur2 = sur_pro;
        }
        else if(dir == 'W'){
            sur_pro = sur1;
            sur1 = sur3;
            sur3 = sur6;
            sur6 = sur4;
            sur4 = sur_pro;
        }
        else if(dir == 'E'){
            sur_pro = sur1;
            sur1 = sur4;
            sur4 = sur6;
            sur6 = sur3;
            sur3 = sur_pro;
        }
        else break;
    }
    cout << sur1 << endl;
    return 0;
}



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


int main(void){
  int A, B;
  scanf("%d%d", &A, &B);
  int count = 0;

  int i;

  for (i = A; i <= B; i++) {
    int s = i % 10;
    int t = i / 10000 % 10;
    int u = i / 10 % 10;
    int v = i / 1000 % 10;

    if (s==t && u==v) {
      count++;
    }
  }

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

}


Measured memory_bytes: 128
#include<iostream>
main(){int n,X,Y,W,H,N,x,y;for(std::cin>>n;std::cin>>X>>Y>>W>>H>>N;printf("%d\n",n))for(n=N;N-->0;n-=X>x|x>X+W|Y>y|y>Y+H)std::cin>>x>>y;}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string S; cin >> S;
  ll K; cin >> K;
  if(S[0] != '1'){
    cout << S[0];
  }
  else{
    rep(i,K){
      if(S[i] != '1'){
        cout << S[i] << endl;
        break;
      }
      if(i==K-1){
        cout << '1' <<endl;
        break;
      }
    }
  }
  return 0;
}


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

typedef long long ll;

main()
{
    int n, m, k, c = 0, a;
    cin >> n >> m;
    int arr[m+1] = {0};
    for(int i = 0; i < n; i++){
        cin >> k;
        for(int j = 0; j < k; j++){
            cin >> a;
            arr[a]++;
        }
    }
    for(int i = 1; i < m+1; i++){
        if(arr[i] == n){
            c++;
        }
    }
    cout << c;

}





///promy_pompom
//hello world


Measured memory_bytes: 3592
H, N = map(int, input().split())
A = [0]*N
B = [0]*N

for i in range(N):
    A[i], B[i] = map(int, input().split())

#i番目までの魔法を使い, モンスターの体力をj以上減らすのに必要な魔力の最小値(個数制限なしナップザック)
dp = [[float("inf")]*(H+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(1, N+1):
    for j in range(H+1):
        if j < A[i-1]:
            dp[i][j] = min(dp[i-1][j], B[i-1])
        else:
            dp[i][j] = min(dp[i-1][j], dp[i][j-A[i-1]]+B[i-1])

print(dp[N][H])

Measured memory_bytes: 285192
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], const int n){
  int i;
  for (i = 0; i < n; i++) {
      int v = A[i];
      int j = i - 1;
      while ((j >= 0) && (A[j] > v)) {
          A[j + 1] = A[j];
          j -= 1;
      }
      A[j + 1] = v;
      trace(A, n);
  }
}

int main(){
  int n, i, j;
  int A[N+1];
  scanf("%d", &n);

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

  return 0;
}

Measured memory_bytes: 608
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        while(sc.hasNext()){
        a=a+sc.nextLine();
        }
        String alpha = "abcdefghijklmnopqrstuvwxyz";
        String s = a.toLowerCase();
        int[] lst = new int[26];
        
        char x;
        for(int i=0;i<s.length();i++){
            x=s.charAt(i);
            for(int j=0;j<26;j++){
                if(x==alpha.charAt(j))lst[j]+=1;
            }
        }
        for(int i=0;i<26;i++){
            System.out.printf("%s : %d\n",alpha.charAt(i),lst[i]);
        }
    }
}


Measured memory_bytes: 26476
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vl a;

int main(){
	cin>>n;
	a=vl(n+1);
	for(int i=0;i<n;i++) cin>>a[i+1];
	for(int i=1;i<=n;i++) a[i]+=a[i-1];
	map<ll,ll> m;
	ll res=0;
	for(int i=0;i<=n;i++){
		res+=m[a[i]];
		m[a[i]]++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll power(ll a,ll b,ll mod){return b?power(a*a%mod,b/2,mod)*(b%2?a:1)%mod:1;}
//inline ll power(ll a,ll b,ll mo)
//{
//    ll ans=1;
//    a%=mo;
//    while (b)
//    {
//        if (b&1) ans=ans*a%mo;
//        b>>=1;
//        a=a*a%mo;
//    }
//    return ans;
//}
int main(){
    ll n,cnt=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='1') cnt++;
    }
    //cout<<cnt<<endl;
    ll ans1=0,ans2=0,ans;
    if(cnt>1){
        for(ll i=0;i<n;i++){
            if(s[i]=='1') ans1=(ans1+power(2,n-i-1,cnt-1))%(cnt-1),ans2=(ans2+power(2,n-i-1,cnt+1))%(cnt+1);
        }
        //cout<<ans1<<" "<<ans2<<endl;
        for(ll i=0;i<n;i++){
            if(s[i]=='0'){
                ans=(ans2+power(2,n-i-1,cnt+1))%(cnt+1);
                int cnt=1;
                while(ans){
                    ans=ans%__builtin_popcount(ans);
                    cnt++;
                }
                cout<<cnt<<endl;
            }else{
                ans=(ans1+((cnt-1)-power(2,n-i-1,cnt-1)%(cnt-1))%(cnt-1))%(cnt-1);
                int cnt=1;
                while(ans){
                    ans=ans%__builtin_popcount(ans);
                    cnt++;
                }
                cout<<cnt<<endl;
            }
        }
    }else if(cnt==1){
        for(int i=0;i<n;i++){
            if(s[i]=='1') ans2=(ans2+power(2,n-i-1,cnt+1))%(cnt+1);
        }
        for(ll i=0;i<n;i++){
            if(s[i]=='0'){
                ans=(ans2+power(2,n-i-1,cnt+1))%(cnt+1);
                int cnt=1;
                while(ans){
                    ans=ans%__builtin_popcount(ans);
                    cnt++;
                }
                cout<<cnt<<endl;
            }else{
                cout<<0<<endl;
            }
        }
    }else{
        for(int i=0;i<n;i++) cout<<1<<endl;
    }
	return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; ll k; cin>>n>>k;
  vector<pii> s(n);
  rep(i,n){
    int a,b; cin>>a>>b;
    s[i]=pii(a,b);
  }
  sort(s.begin(),s.end());
  ll t=0;
  rep(i,n){
    t+=(ll)s[i].second;
    if(t>=k){
      cout<<s[i].first<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	bool flag = true;
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	int tmp = 1, cnt = 0, hoge = 0;
	while (hoge + 1 < n && a[hoge] == a[hoge + 1]) tmp++, hoge++;
	hoge++;
	while (hoge < n) {
		cnt = 1;
		while (hoge + 1 < n && a[hoge] == a[hoge + 1]) cnt++, hoge++;
		hoge++;
		if (tmp != cnt) {
			flag = false;
			break;
		}
	}
	if (a[0] == 0 && (tmp == n || tmp * 2 == count(a.begin(), a.end(), a[tmp]))) cout << "Yes" << endl;
	else if (n % 3 || !flag) cout << "No" << endl;
	else {
		a.erase(unique(a.begin(), a.end()), a.end());
		flag = true;
		if (a.size() != 3) flag = false;
		else if ((a[0] ^ a[1] ^ a[2]) != 0) flag = false;
		if (flag) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 640