akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <queue>
 
#define fr first
#define sc second
#define mk make_pair
 
using namespace std;
 
struct st{
    int color, w, ind;
};
 
int n, x, y, dsu[1000001], kol[1000001];
long long f[1000001];
vector<st> vec[1000001];
vector<int>vc[1000001];
st ar[1000001];
 
bool cmp(st a, st b)
{
    return (a.w >= b.w) ? 0 : 1;
}
 
int get_dsu(int x)
{
    if(dsu[x] == x)
        return x;
    return dsu[x] = get_dsu(dsu[x]);
}
 
long long mod = 1e9 + 7;
 
long long binpow(long long a, long long b)
{
    if(b == 0)
        return 1;
    if(b % 2 == 1)
        return a * binpow(a, b - 1) % mod;
    else
    {
        long long h = binpow(a, b / 2);
        return h * h % mod;
    }
}
 
int main()
{
    f[0] = 1;
    for(int i = 1; i <= 1e6; i++)
    {
        dsu[i] = i;
        f[i] = f[i - 1] * i % mod;
    }
    cin >> n >> x >> y;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d%d", &ar[i].color, &ar[i].w);
        ar[i].ind = i;
        vec[ar[i].color].push_back(ar[i]);
    }
 
    for(int i = 1; i <= n; i++)
        if(vec[i].size() != 0)
        {
            sort(vec[i].begin(), vec[i].end(), &cmp);
            for(int j = 0; j < vec[i].size(); j++)
                if(vec[i][j].w + vec[i][0].w <= x)
                {
                    dsu[get_dsu(vec[i][j].ind)] = get_dsu(vec[i][0].ind);
                }
        }
 
    sort(ar + 1, ar + n, &cmp);
 
    int mn = 1e9;
    for(int i = 1; i <= n; i++)
    {
        if(ar[i].color != ar[1].color && ar[1].w + ar[i].w <= y)
        {
            dsu[get_dsu(ar[i].ind)] = get_dsu(ar[1].ind);
        }
        if(ar[i].color != ar[1].color)
            mn = min(mn, i);
    }
    if(mn != 1e9)
    for(int i = 1; i <= n; i++)
        if(ar[i].color == ar[1].color && ar[mn].w + ar[i].w <= y)
            dsu[get_dsu(ar[i].ind)] = get_dsu(ar[mn].ind);
 
    for(int i = 1; i <= n; i++)
    {
        kol[get_dsu(ar[i].ind)]++;
        vc[get_dsu(ar[i].ind)].push_back(ar[i].color);
    }
 
 
    long long ans = 1;
    for(int i = 1; i <= n; i++)
    {
        if(dsu[i] == i)
        {
            long long k = 1;
            for(long long j = 0; j < kol[i]; j++)
            {
                k *= (j + 1);
                k = k % mod;
            }
            int l = 0, r = 0;
            sort(vc[i].begin(), vc[i].end());
 
            while(vc[i].size() > l)
            {
                while(vc[i][l] == vc[i][r + 1] && r < vc[i].size() - 1)
                {
                    r++;
                }
                k = k * binpow(f[r - l + 1], mod - 2) % mod;
                l = r + 1;
            }
            //cout << i << " " << k << endl;
            ans = ans * k % mod;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 76160
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll a_I, ll a_O, ll a_T, ll a_J, ll a_L, ll a_S, ll a_Z) {
  ll res1 = 0, res2 = 0;

  res1 += (a_I / 2) * 2;
  res1 += a_O;
  res1 += (a_J / 2) * 2;
  res1 += (a_L / 2) * 2;

  if (a_J > 0 && a_L > 0 && a_I > 0) {
    res2 += 3;
    res2 += ((a_I - 1) / 2) * 2;
    res2 += a_O;
    res2 += ((a_J - 1) / 2) * 2;
    res2 += ((a_L - 1) / 2) * 2;
  }
  cout << max(res1, res2) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll a_S;
	ll a_J;
	ll a_L;
	ll a_I;
	ll a_O;
	ll a_Z;
	ll a_T;
	scanf("%lld", &a_I);
	scanf("%lld", &a_O);
	scanf("%lld", &a_T);
	scanf("%lld", &a_J);
	scanf("%lld", &a_L);
	scanf("%lld", &a_S);
	scanf("%lld", &a_Z);
	solve(a_I, a_O, a_T, a_J, a_L, a_S, a_Z);
	return 0;
}


Measured memory_bytes: 256
for t in range(int(input())):
	a,b,c,d=map(int,input().split(' '));l,x,y,o=(a+b)//(min(a,b)+1),a+b,0,""
	if a*l<=b:x,y=0,a+b
	elif b*l>a:x,y=(a*l-b)//(l-1),(b*l-a)//(l-1)
	for i in range(c,d+1):o+="AB"[i%(l+1)==0] if i<=x else "BA"[(a+b-i+1)%(l+1)==0] if a+b-i+1<=y else "AB"[a-x+x//(l+1)-y//(l+1)==0]
	print(o)

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;

public class Main{
	static void main() throws Exception{
		long x=sc.nextLong(),k=sc.nextLong(),d=sc.nextLong();
		long wanted;
		if(x>=0) {
			long dif=x;
			wanted=dif/d;
		}
		else {
			long dif=-x;
			wanted=(dif+d-1)/d;
		}
		wanted=Math.min(wanted, k);
		if(x>=0) {
			x-=(wanted*d);
		}
		else {
			x+=(wanted*d);
		}
		k-=wanted;
		
		k=(k&1);
		if(k>0) {
			x-=d;
		}
		pw.println(Math.abs(x));
	}
	public static void main(String[] args) throws Exception{
		sc=new MScanner(System.in);
		pw = new PrintWriter(System.out);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 25464
#include<iostream>
#include<stdio.h>

using namespace std;
int main(){
    int a,b;
    string op;
    while (cin >> a >> op >>b && op!="?" ){
        if (op =="+"){
            cout << a+b << endl;
        } else if (op=="-"){
            cout << a-b << endl; 
        } else if (op=="*"){
            cout << a*b << endl;
        } else{
            cout << a/b << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	
	int n,m;
	cin>>n>>m;
	vector<ll> a(n),b(n);
	rep(i,n){
		cin>>a[i];
		a[i] = a[i]%m;
	}
	b[0]=a[0];
	rep(i,n-1){
		b[i+1] = b[i]+a[i+1];
		b[i+1] = b[i+1]%m;
	}
	ll ans=0;
	sort(b.begin(),b.end());
	ll x;
	ll c=0;
	rep(i,n){
		if(i==0){
			x=b[0];
			c++;
			continue;
		}
		if(b[i]==x){
			c++;
		}else{
			if(x==0){
				ans += c;
			}
			if(c>0){
				ans += (c*(c-1))/2;
			}

			x=b[i];
			c=1;
		}
	}
	if(x==0){
		ans += c;
	}
	if(c>1){
		ans += (c*(c-1))/2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int x;
    cin >> x;
    REP(i, x, x + 101){
        if(isPrime(i)){
            print(i);
            return 0;
        }
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll L, R;
    cin >> L >> R;
    ll ans = 2019;
    for(ll i=L; i<R; ++i){
        for(ll j=i+1; j<=R; ++j){
            ans = min(ans, (i*j)%2019);
            if(ans==0){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

N, K = MAP()
A = LIST()
B = LIST()

A.sort(reverse=True)
B.sort()

def check(m):
    k = 0
    for i, a in enumerate(A):
        b = B[i]
        k += max(ceil(a - m/b), 0)
        if k > K:
            return False
    return True

print(bisearch_min(-1, 10**12, check))


Measured memory_bytes: 113408
n = int(input())

s = []

a = n
b = 0

while (a !=0):
    if a%-2 ==0:
        b = a % -2
        a = a//-2
        s.insert(0,str(b))
    elif a%-2==-1:
        b = abs(a % -2)
        a = a//-2+1
        s.insert(0,str(b))

print(''.join(s) if len(s)!=0 else 0)


Measured memory_bytes: 3060
#157b
a_array = []
a_array.append(list(map(int, input().split())))
a_array.append(list(map(int, input().split())))
a_array.append(list(map(int, input().split())))

N = int(input())
b_set = set()

for i in range(N):
    b_set.add(int(input()))
    
bingos = [[a_array[0][0],a_array[0][1],a_array[0][2]],
         [a_array[1][0],a_array[1][1],a_array[1][2]],
         [a_array[2][0],a_array[2][1],a_array[2][2]],
         [a_array[0][0],a_array[1][0],a_array[2][0]],
         [a_array[0][1],a_array[1][1],a_array[2][1]],
         [a_array[0][2],a_array[1][2],a_array[2][2]],
         [a_array[0][0],a_array[1][1],a_array[2][2]],
         [a_array[0][2],a_array[1][1],a_array[2][0]]]

for bingo in bingos:
    if bingo[0] in b_set and bingo[1] in b_set and bingo[2] in b_set:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
int A[100005],B[100005],C[100005];

int V1[100005],V2[100005];
int ans;


void Input(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>A[i];
    for(int i=0;i<N;++i)cin>>B[i];
    for(int i=0;i<N;++i)cin>>C[i];
}

int TopStage(int *P,int *Q,int it){
    int right=lower_bound(Q,Q+N,P[it])-Q;
    return right;

}

int UnderStage(int *P,int *Q,int it){
    int left=upper_bound(Q,Q+N,P[it])-Q;
    return N-left;
}


signed main(){
    Input();
    sort(A,A+N);
    sort(B,B+N);
    sort(C,C+N);
    for(int i=0;i<N;++i)V1[i]=TopStage(B,A,i);
    for(int i=0;i<N;++i)V2[i]=UnderStage(B,C,i);
    for(int i=0;i<N;++i)ans+=V1[i]*V2[i];
    cout<<ans<<endl;
}


Measured memory_bytes: 4096
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int top = n/100;
        int ans = 0;
        if(n-top*100>top*10+top){
            ans = (top+1)*100+(top+1)*10+(top+1);
        }else{
            ans = top*100+top*10+top;
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 22228
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  const int N = 10;
  
  int dp[1<<N][331] = {};
  int res = 0;
  REP(i,N) {
    dp[1<<i][i] = 1;
  }
  REP(S,1<<N) {
    vector<int> se;
    REP(j,N)
      if ((S>>j) & 1) {
        se.push_back(j);
        // cout << j << " ";
      }
    FOR(it, se) {
      REP(i,331) {
        if (i + (*it)*se.size() >= 331) break;
        dp[S][i + (*it)*se.size()] += dp[S - (1<<*it)][i];
      }
    }
    // REP(i,331) {
    //   if (dp[S][i])cout << i << " ";
    // }cout << endl;
  }
  int table[11][331] = {};
  for (int i=1; i<=N; ++i) {
    int comb = (1<<i) - 1;
    while (comb < 1 << 10) {
      REP(j,331) {
        table[i][j] += dp[comb][j];
      }
      
      int x = comb & -comb, y = comb + x;
      comb = ((comb & ~y) / x >> 1) | y;
    }
    // if (i == 3) {
    //   REP(j,331) {
    //     cout << table[i][j] << endl;
    //   }
    // }
    // cout << table[i][10] << endl;
  }

  int n, s;
  while(cin >> n >> s) {
    if (n < 0 || n > 10 || s <0 || s >= 331) cout << 0 << endl;
    else    cout << table[n][s] << endl;
  }
}

Measured memory_bytes: 0
cal :: [String] -> Int
cal (a:op:b:_)
    | op == "+" = read a + read b
    | op == "-" = read a - read b
    | op == "*" = read a * read b
    | op == "/" = read a `div` read b

main=do
       xs <- fmap (map words . lines) getContents
       mapM putStrLn . map show . map cal $ takeWhile (\(_:op:_) -> op /= "?") xs


Measured memory_bytes: 4080
n=int(input())
arr=[int(input()) for _ in range(n)]
l=0
flag=True
for i in range(n):
  if arr[i]==0:
    l=1
  else:
    if arr[i]>l:
      flag=False
      break
    l+=1
  if i!=0:
    if arr[i]-arr[i-1]>=2:
      flag=False
      break
if flag==False:
  print(-1)
else:
  ans=arr[-1]
  tmp=arr[-1]
  for i in range(n-2,-1,-1):
    if arr[i]<tmp:
      tmp=arr[i]
    else:
      ans+=arr[i]
      if tmp!=arr[i]:
        tmp=arr[i]
  print(ans)

Measured memory_bytes: 11176
import math
n,m = map(int,input().split())
mod = 10**9+7
if abs(n-m) > 1:
  print(0)
else:
  if n==m:
    print((math.factorial(n)%mod * math.factorial(m)%mod)*2%mod)
  else:
    print((math.factorial(n)%mod * math.factorial(m)%mod)%mod)

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

vector<ll> a, p;

ll dfs(ll n, ll x) {
    if (n == 0)
        return x <= 0 ? 0 : 1;
    else if (x <= a[n - 1] + 1)
        return dfs(n - 1, x - 1);
    else
        return p[n - 1] + 1 + dfs(n - 1, x - 2 - a[n - 1]);
}

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

    a.push_back(1), p.push_back(1);
    rep(i, n) {
        a.push_back(a[i] * 2 + 3);
        p.push_back(p[i] * 2 + 1);
    }

    cout << dfs(n, x) << endl;
    return 0;
}


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

int main(void){
  int N,Y;
  cin >> N >> Y;
  Y/=1000;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      if(N-i-j>=0 && Y==i*10+j*5+(N-i-j)){
        cout << i << " " << j << " " << (N-i-j) << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
/* ex 9_1
   riverstone */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//スタックに格納するデータの数
#define SIZE 20

//スタックの定義
typedef struct stack{
    int size;//格納最大数
    int count;//現在のデータ数
    char data[SIZE];//データ配列
    char *top;//topへのポインタ
} stack;


void initialize_stack(stack *stk);
void push(stack *stk, char elem);
char pop(stack *stk);
void print_stack(stack *stk);


int main(void){
    int i=0;
    char string[SIZE];
    stack stk;
 
    //スタックを初期化
    initialize_stack(&stk);
 
    //入力を受け取る
    scanf("%s", string);

    //stringの中身を一文字ずつ見ていく
    for(i=0;i<strlen(string);i++){
        //入力文字が0か1の場合
        if(string[i]=='0' || string[i]=='1'){
            //スタックにプッシュする
            push(&stk,string[i]);
        }

        //入力文字がBの場合
        else if(string[i]=='B' && stk.count>0){
            //スタックから一文字popする
            pop(&stk);
        }
    } 

    //stackの中身を出力
    print_stack(&stk);
    printf("\n");
    return 0;
}


//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;//個数を0にセット
    stk->size = SIZE;//格納最大数はSIZEに
    stk->top = &(stk->data[SIZE]);//topは配列の最終要素の手前
}

//データの追加
void push(stack *stk, char elem){
    //最大要素数stk->sizeより多くの要素を追加使用とした場合エラー
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        //topを1つ上に上げる(=topを1つ手前に移動する)
        stk->top--;
        //1つ上げたtopにデータを格納する
        *(stk->top) = elem;
        //データ数を1つ増やす
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    //要素数が0以下になった場合取り出せない
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        //topの位置からデータを取り出す
        latest = *(stk->top);
        //topを1つ下に下げる
        stk->top++;
        //データ数を1つ減らす
        stk->count--;
        return latest;
    }
}

//出力
void print_stack(stack *stk){
    int i;
    //先頭の位置から、新しいデータに向かって順番にprint
    for (i=0;i < stk->count;i++){
        printf("%c",stk->data[SIZE-i-1]);
    }
    printf("\n");
}

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

using namespace std;

int N, K;

int main(){
    cin>>N>>K;
    int h[N+1];
    int dp[N+1];
    for(int i=1; i <= N; i++){
        cin>>h[i];
    }

    dp[1] = 0;

    for(int i=2; i <= N; i++){
        dp[i] = INT_MAX;
        for(int j = 1; j <= K; j++){
            if(i - j >= 1){
                dp[i] = min(dp[i], (dp[i-j] + abs(h[i] - h[i-j])));
            }
        }

    }
    cout<<dp[N];

    return 0;
}



Measured memory_bytes: 4384
#include <iostream>

using namespace std;

int main()
{
    int v[1001],n,i,mini,maxi;

   cin>>n;

   for (int i=1;i<=n;i++)
    cin>>v[i];

    mini=v[1];
    maxi=v[1];
   for (int i=1;i<=n;i++)
   {
       if(v[i]>maxi)
        maxi=v[i];
       if (v[i]<mini)
       mini=v[i];
   }

    cout<<maxi-mini;




    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    vector<int> cumf(n), cumb(n);
    rep(i, n) {
        if (i == 0) cumf[i] = A[i];
        else {
            cumf[i] = max(A[i], cumf[i - 1]);
        }
    }
    rep(i, n) {
        if (i == 0) cumb[n - i - 1] = A[n - i - 1];
        else {
            cumb[n - i - 1] = max(A[n - i - 1], cumb[n - i]);
        }
    }
    rep(i, n) {
        if (i == 0) cout << cumb[1] << endl;
        else if (i == n - 1) cout << cumf[n - 2] << endl;
        else cout << max(cumf[i - 1], cumb[i + 1]) << endl;
    }

    return 0;
}

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

const int N = 1e5 + 5;
const int mod = 1e9 + 7;

int n;
string s;
int f[N], sum[N];
int nxt[N][3], eq[N];

void add(int &x,int y) {
	x += y; if (x >= mod) x -= mod;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> s; n = s.size(); s = '~' + s;
	for (int i = 1; i <= n; ++i) {
		sum[i] = (sum[i - 1] + (s[i] == 'a' ? 1 : 2)) % 3;
	}
	for (int i = 0; i < 3; ++i) nxt[n + 1][i] = n + 1;
	for (int i = n; i >= 1; --i) {
		for (int j = 0; j < 3; ++j) {
			nxt[i][j] = nxt[i + 1][j];
		}
		nxt[i][sum[i]] = i;
	} 
	eq[n] = n;
	for (int i = n - 1; i >= 1; --i) {
		if (s[i] == s[i + 1]) eq[i] = i;
		else eq[i] = eq[i + 1];
	}
	if (eq[1] == n) return cout << 1 << '\n',0;
	f[0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int t = 1; t <= 2; ++t) {
			int want = (sum[i] + t) % 3;
			if (sum[i + 1] == want) add(f[i + 1], f[i]);
			else {
				int pos = nxt[eq[i] + 1][want];
				if (pos <= n) add(f[pos], f[i]);
			}
		}
	}
	int res = 0;
	for (int i = 1; i <= n; ++i) if (sum[i] == sum[n]) add(res, f[i]);
	cout << res << '\n';
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k;cin>>n>>k;
  cout<<n-k+1<<endl;

  return 0;
}


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



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scaner sc = new Scaner();
        write wr = new write();

        var x=sc.IntArr;
        int N=x[0];
        var A=sc.IntArr;
        var min=new int[N];
        for(int i=0;i<N;++i)min[i]=INF;
        min[0]=A[0];

        for(int i=1;i<N;++i){
            min[i]=Math.Min(min[i-1],A[i]);
        }

        int maxsa=0;
        for(int i=0;i<N;++i){
            int sa=A[i]-min[i];
            maxsa=Math.Max(sa,maxsa);
        }

        int ans=0;
        for(int i=0;i<N;++i){
            if(A[i]-min[i]==maxsa){
                ans++;
            }
        }
        wr.wri(ans);
    }


    static int factmod(int X){
        int ret=1;
        for(int i=1;i<=X;++i){
            ret*=i;
            ret%=MOD;
        }
        return ret;
    }
}





class Scaner
{
    public string Str => Console.ReadLine();

    public string[] StrArr => Str.Split(' ');

    public long[] LongArr => StrArr.Select(long.Parse).ToArray();
    public int[] IntArr => StrArr.Select(int.Parse).ToArray();
    public char[] CharArr => Str.ToArray();
    public long Long1 => LongArr[0];
    public int Int1 => IntArr[0];
    
}



class write
{
    public  void wri<T>(T x)
    {
        Console.WriteLine(x);
    }
}



Measured memory_bytes: 22112
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    A = list(map(int,input().split()))
    for i in A:
        if (i % 2)==0:
            if (i % 3)!=0 and (i % 5)!=0:
                print('DENIED')
                return
    print('APPROVED')

if __name__ == '__main__':
    main()

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

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

  string str[50];
  for (int i = 0; i < h; i++){
    cin >> str[i];
  }

  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      if (str[i][j] != '#'){
        int count = 0;
        for (int u = -1; u <= 1; u++){
          for (int v = -1; v <= 1; v++){
            if (i+u < 0 || j+v < 0) continue;
            if (i+u >= h || j+v >= w) continue;
            if (str[i+u][j+v] == '#') count++;
          }
        }
        printf("%d", count);
      } else printf("%c", str[i][j]);
    }
    printf("\n");
  }

  return 0;
}

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

const int N = 300010;

int X, Y, Z;
int A[N], B[N], C[N];
int n;
long long ans;
priority_queue < int, vector<int>, greater<int> > q;
vector <int> V;

bool cmp(int u, int v) {
	return (A[u] + B[v] > A[v] + B[u] || (A[u] + B[v] == A[v] + B[u] && u < v));
}

long long l[N], r[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> X >> Y >> Z;
	n = X + Y + Z;
	for (int i = 1; i <= n; ++i) {
		cin >> A[i] >> B[i] >> C[i];
		ans += C[i];
		V.push_back(i);
	}

	sort(V.begin(), V.end(), cmp);
	for (int i = 1; i <= n; ++i) A[i] -= C[i], B[i] -= C[i];

	long long cur = 0; l[0] = -1e18;
	for (int i = 1; i <= n; ++i) {
		int p = V[i-1];
		q.push(A[p]);
		cur += A[p];
		if ((int)q.size() > X) {
			int pa = q.top(); q.pop();
			cur -= pa;
		}
		l[i] = (int)q.size() >= X ? cur : -1e18;
	}

	cur = 0; r[n + 1] = -1e18; q = priority_queue < int, vector<int>, greater<int> >();
	
	for (int i = n; i >= 1; --i) {
		int p = V[i-1];
		q.push(B[p]);
		cur += B[p];
		if ((int)q.size() > Y) {
			int pb = q.top(); q.pop();
			cur -= pb;
		}
		r[i] = (int)q.size() >= Y ? cur : -1e18;
	}

	long long res = -1e18;
	for (int i = 0; i <= n; ++i) {
		res = max(res, l[i] + r[i + 1]);
	}

	cout << ans + res << endl;
}

Measured memory_bytes: 8056
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=100005;
int a[maxn],b[maxn],op[maxn],n,m,ans[maxn],ori[maxn],tmp[maxn];
i64 res[maxn];
i64 k;
int main(){
    read(n);
    rep(i,1,n)read(a[i]);
    read(m);cin>>k;
    rep(i,1,m)read(op[i]);
    rep(i,1,n)b[i]=a[i]-a[i-1];
    rep(i,1,n)ori[i]=i;
    rep(i,1,n)ans[i]=i;
    rep(i,1,m)
    	swap(ori[op[i]],ori[op[i]+1]);
    for(;k;k>>=1){
    	if(k&1)rep(i,1,n)ans[i]=ori[ans[i]];
    	rep(i,1,n)tmp[i]=ori[ori[i]];
    	rep(i,1,n)ori[i]=tmp[i];
    }
    res[1]=a[1];
    rep(i,2,n)res[i]=res[i-1]+b[ans[i]];
    rep(i,1,n)printf("%lld.0\n",res[i]);
    return 0;
}


Measured memory_bytes: 4608
import Data.List

main = do
    s <- getLine
    t <- getLine
    let n = length s
        m = length t
    putStrLn . reply . sort $ map qtoa [take (n - length s') s ++ t ++ drop m s' | s' <- tails s, check s' t]

check _ [] = True
check [] _ = False
check (s:ss) (t:ts) | s == '?' || s == t = check ss ts
                    | otherwise = False

qtoa [] = []
qtoa (x:xs) | x == '?' = 'a' : qtoa xs
            | otherwise = x : qtoa xs

reply [] = "UNRESTORABLE"
reply xs = head xs

Measured memory_bytes: 636
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void)
{
    int N, i, f=0;
    long long int A[200002];

    scanf("%d",&N);
    for(i=0; i<N; i++){
        scanf("%lld",&A[i]);
    }

    qsort(A,N,sizeof(long long int),compare_int);

    for(i=0; i<N-1; i++){
        if(A[i] == A[i+1]){
            f=1;
        }
        //printf("%lld ",A[i]);
    }

    if(f==1){
        printf("NO\n");
    } else {
        printf("YES\n");
    }

    return 0;
}

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

// NOTE TO SELF // try to simplyfy the problem
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define sz(n) (int)n.size()

#define ll long long int
using namespace std;



int main()
{
    int n;
    cin>>n;
    
    vector<int> h(n);
    
    for(auto &it:h)
        cin>>it;
    
    const int INF=1e9+5;
    
    vector<int> dp(n,INF);
    
    dp[0]=0;
    
    for(int i=0;i<n;i++)
    {
        for(int j:{i+1,i+2})
        {
            if(j<n)
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            
            
            
        }
        
        
    }
    
    cout<<dp[n-1]<<endl;
    
    
}


Measured memory_bytes: 3996
#include<stdio.h>
main()
{
	int a,b,c,d,s1,s2;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	s1=a*b;
	s2=c*d;
	if(s1>=s2)
	{
		printf("%d",s1);
	}
	else
	{printf("%d",s2);}
}

Measured memory_bytes: 128
import java.util.Scanner;
class Main{
public static void main(String[]args){

Scanner sc=new Scanner(System.in);
  String moji=sc.nextLine();
  
  char[] S=new char[6];
  for(int i=0; i<6; i++){
  S[i]=moji.charAt(i);
  }
  if(S[2]==S[3] && S[4]==S[5]){
    System.out.println("Yes");
  }else{
    System.out.println("No");
  }
}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    int n;

    cin>>n;

    if(n%2==0){
        printf("%.10lf",0.5);
    }else{
        printf("%.10lf",(double)(n+1)/(2*n));
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

int main(){
	//mahakal();fast;
	ll n ;
	cin>> n ;
	string str ;
	cin>>str;
	ll cnt=0;
	for(ll i=0;i<=n-3;i++){
		if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C')cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())


def main():
    N, M = map(int, input().split())

    uf = UnionFind(N)

    for m in range(M):
        A, B = map(int, input().split())
        A, B = A-1, B-1
        uf.union(A, B)
    
    print(uf.group_count() - 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 75092
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 



int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n);
    map<ll,ll>m;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        m[a[i]]++;
    }
    ll sum = 0;
    for(auto itr = m.begin();itr!=m.end();++itr){
        ll v = itr->second;
        sum+=v*(v-1)/2;
    }
    for(ll i=0;i<n;i++){
        ll num = m[a[i]];
        cout<<sum-num*(num-1)/2+(num-1)*(num-2)/2<<endl;
    }
    return 0;

}



Measured memory_bytes: 11008
fun main() = ABC162C.main()

object ABC162C {
    fun log(message: Any?) {
        //println(message)// TODO: ←消す
    }

    fun main() {
        val K = readInt()
        var ans = 0
        (1..K).forEach { a ->
            (1..K).forEach { b ->
                (1..K).forEach { c ->
                    ans += Gcd.get(a, Gcd.get(b, c))
                }
            }
        }

        println(ans)
        log("calcCount=${Gcd.calcCount}")
    }


    /*####################################################################################*/
    object Gcd {
        var calcCount = 0
            private set
        private val cache = hashMapOf<Pair<Int, Int>, Int>()

        fun get(a: Int, b: Int): Int {
            val m = if (a > b) a else b
            val n = if (a < b) a else b
            val cached = cache[m to n]
            return if (cached == null) {
                val gcd = calc(m, n)
                cache[m to n] = gcd
                gcd
            } else cached
        }

        private fun calc(m: Int, n: Int): Int { // m > n
            //assert(m > n)
            var m = m
            var n = n
            while (n != 0) {
                val r = m % n
                m = n
                n = r
            }
            calcCount++
            return m
        }
    }

    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
}

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

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	ll X, Y, A, B, C;
	cin >>X >>Y >>A >>B >>C;
	vector<vector<ll>> P;
	ll v;
	Rep0(i, A) {
		cin >>v;
		P.push_back({v, 2});
	}
	Rep0(i, B) {
		cin >>v;
		P.push_back({v, 1});
	}
	Rep0(i, C) {
		cin >>v;
		P.push_back({v, 0});
	}
	Sort(P);
	Rev(P);
	ll S=0;
	ll ixa=X;
	ll ixb=Y;
	ll ix=X+Y;
	ll i=0;
	while(ix>0) {
		ll G=P.at(i).at(1);
		ll V=P.at(i).at(0);
		i++;
		if (G==2) {
			if (0==ixa)
				continue;
			S+=V;
			ixa--;
		} else if (G==1) {
			if (0==ixb)
				continue;
			S+=V;
			ixb--;
		} else {
			S+=V;
		}
		ix--;
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 22572
#B - Multiplication 2
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 1
for i in range(N):
    if A[i] == 0:
        print(0)
        exit()
    else:
        pass
    ans *= A[i]
    if ans <= 1000000000000000000:
        pass
    else:
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 21708
#include<stdio.h>
int main(void)
{
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H ,&W);
        if(H == 0 && W == 0){
            break;
        }
         for(i=1;i<=H;i++){
      for(j=1;j<=W;j++){
      if(i > 1 && i < H && j < W && j > 1)
      {
      printf(".");
      }else {
      printf("#");
      }
    }
      printf("\n");
    }
  printf("\n");
     
       }
  return 0;
    }



Measured memory_bytes: 1988
#include<iostream>

using namespace std;

int main(){
  int N;
  int A[111111],B[111111];
  cin >> N;
  int i;
  for(i=1;i<=N;i++)
    cin >> A[i];
  for(i=1;i<=N;i++)
    B[A[i]] = i;
  for(i=1;i<=N;i++)
    cout << B[i] << endl;
}



Measured memory_bytes: 1664
#include<stdio.h>
int main()
{
	int r=0;
	double a,i=1.0;
	scanf("%lf",&a);
	if(a==0.0){
		printf("%d\n",0);
	}else{
		while(a>=i){
			r++;
			i*=2.0;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 2760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] firstRow = br.readLine().split("\\s");

        // ????´???°
        int elementNum = Integer.parseInt(firstRow[0]);
        // ???????????????
        int quantum = Integer.parseInt(firstRow[1]);

        // ????????\?????????????????????????????????????????????FIFO
        // ?????????stack,dequeue??§?????£????????§?????????queue??§???????????????????????£???????????????????????????
        Queue<Process> que = new LinkedList<Process>();
        for (int i = 0; i < elementNum; i++) {
            String[] stringArray = br.readLine().split("\\s");
            // ???p1 150?????????????????¢?????§stringArray????????????????????????
            // p1?????????????????????,150?????????????????????????????????????????????????????¨??????????????????
            // ????????£??¨??????????????????????????????????????????
            Process process = new Process(stringArray[0],
                    Integer.parseInt(stringArray[1]));
            que.offer(process);
        }

        // ??????????¨???????
        int resultTime = 0;
        while (que.size() > 0) {
            Process process = que.poll();
            // ????¨???????????????¨????????????
            resultTime += quantum;
            // ???????????????????????????
            if ((process.processTime = process.processTime - quantum) > 0) {
                // ??????????????????????????????????????????????????????????????´??????
                // ???????°?????????????????????¨??????????????????
                que.offer(process);
                continue; // else??????????????§
            }
            // processTime???(-20)??????????????£???????????°????????????????????????
            // ??????????¨??????????????????????
            resultTime += process.processTime;
            // ?????????????????????????????????????????´???????????????????????¨??????????????§???????????£?????????
            // ??¨???????????????????????????
            System.out.println(process.name + " " + resultTime);
        }

    }

    /**
     * Process???????????????
     */
    private final static class Process {
        // ??????????????????public????????????
        public String name = null;
        public int processTime = 0;

        public Process(String name, int processTime) {
            this.name = name;
            this.processTime = processTime;
        }
    }
}

Measured memory_bytes: 77400
#include<stdio.h>

int main(void){
    int a,b,c,buf;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
        buf=a; a=b; b=buf;
    }
    if(a>c){
        buf=a; a=c; c=buf;
    }
    if(b>c){
        buf=b; b=c; c=buf;
    }
    printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2752
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


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


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


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


def mt(f):
    import time

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

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

    return wrap


def eratosthenes(n):
    p = [1]
    t = [True] * n

    t[1] = True
    for i in range(2, int(math.ceil(math.sqrt(n)))):
        if t[i]:
            p.append(i)
            for j in range(2*i, n, i):
                t[j] = False

    for j in range(i+1, n):
        if t[j]:
            p.append(j)

    return p, t


@mt
def slv(Q, LR):
    N = 100000
    p, t = eratosthenes(N)
    qt = [0] * N
    for i in range(3, N):
        qt[i] = qt[i-1]
        if t[i] and t[(i+1)//2]:
            qt[i] += 1

    for l, r in LR:
        print(qt[r] - qt[l-1])


def main():
    Q = read_int()
    LR = [read_int_n() for _ in range(Q)]
    slv(Q, LR)


if __name__ == '__main__':
    main()


Measured memory_bytes: 89172
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Pair implements Comparable<Pair> {
    int price;
    int stock;

    public Pair(int price, int stock){
        this.price = price;
        this.stock = stock;
    }

    @Override
    public int compareTo(Pair other) {
        return Integer.compare(this.price, other.price);
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];

        List<Pair> shoplist = new ArrayList<Pair>();
        for (int i = 0; i < N; i++) {
            Pair p = new Pair(sc.nextInt(), sc.nextInt());
            shoplist.add(p);
        }

        Collections.sort(shoplist);

        long sum = 0;
        long cnt = M;
        for (Pair p : shoplist) {
            sum += Math.min(p.stock, cnt) * p.price;
            cnt -= Math.min(p.stock, cnt);
            if (cnt == 0) break;
            //if (cnt > p.stock) {
            //} else {
            //    // cnt <= p.stock
            //    sum += cnt * p.price;
            //    break;
            //}
        }

        System.out.println(sum);
        return;
    }

}

Measured memory_bytes: 94556
s=input()
if s=='AKIHABARA' or s=='KIHABARA' or s=='AKIHBARA' or s=='AKIHABRA' or s=='AKIHABAR' or s=='KIHBARA' or s=='KIHABRA' or s=='KIHABAR' or s=='AKIHBAR' or s=='AKIHABR' or s=='AKIHBRA' or s=='KIHBRA' or s=='KIHBAR' or s=='KIHABR' or s=='AKIHBR' or s=='KIHBR':
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060