akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);
static const int BMAX = 35;

int main() {
  int N; cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  int bit[BMAX];
  rep(i, BMAX) bit[i] = 0;

  rep(i, N) {
    rep(j, BMAX) {
      if (a[i] & (1 << j)) bit[j]++;
    }
  }

  bool flag_true = true;
  rep(i, BMAX) {
    if (bit[i] % 2 != 0) flag_true = false;
  }

  if (flag_true) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0593>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = 0;
    ll N,M; cin >> N >> M;
    vector<ll> A(N),B(M);
    for(auto& in:A) cin >> in;
    for(auto& in:B) cin >> in;
    
    vector<ll> Vote(N,0);
    for(int i = 0; i < M;i++){
        for(int j = 0; j < N;j++){
            if(A[j] <= B[i]){
                Vote[j]++;
                break;
            }
        }
    }
    res = max_element(Vote.begin(), Vote.end()) - Vote.begin()+1;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



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

int main() {
  int A,B;
  cin >> A >> B;
  
  if(A > B) {
    cout << A*2-1 << endl;
  }
  else if(A == B) {
    cout << A+B << endl;
  }
  else if(A < B) {
    cout << B*2-1 << endl;
  }
}

      

Measured memory_bytes: 256
using namespace std;
#include <stdio.h>
#include<iostream>
#include<math.h>
int main()
{   
    int k,s,cnt=0;
    cin>>k>>s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(s-x-y>=0 and s-x-y<=k) 
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
A, B, C, X, Y = input().split(" ")
A, B, C, X, Y  = int(A), int(B), int(C), int(X), int(Y)

cost_AplusB = min(A+B, 2*C)
costA = min(A, 2*C)
costB = min(B, 2*C)

flag = (X > Y)
many_pizza = max(X, Y)
few_pizza = min(X, Y)



price = cost_AplusB * few_pizza
if flag:
    price += costA * (many_pizza - few_pizza)
else:
    price += costB  * (many_pizza - few_pizza)

print(price)



Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <math.h>
#include <string.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
//#define int ll
#define INF (1LL<<60)
#define mod 1000000007


int N;
int a[100];

signed main(){

	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i];


	// 挿入ソート
	for (int i = 1; i < N; i++){
		// print
		for (int n = 0; n < N; n++){
			cout << a[n];
			if (n < N - 1)
				cout << " ";
			else
				cout << endl;
		}

		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v){
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;

	}


	// print
	for (int n = 0; n < N; n++){
		cout << a[n];
		if (n < N - 1)
			cout << " ";
		else
			cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Point
{
public:
    int y, x;
    Point(){
        y = x = 0;
    }
    Point(int y0, int x0){
        y = y0;
        x = x0;
    }
    int dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cosÆ
    }
    int cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sinÆ
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
};

/***************************************************************************************************/
// _ªÊ½p`Ìà(ÓãàÜÞ)É é©²×é
// cp : Ê½p`
// p  : _
/***************************************************************************************************/
bool convexContain(const vector<Point>& cp, const Point& p)
{
    int n = cp.size();
    bool ret1 = true;
    bool ret2 = true;
    for(int i=0; i<n; ++i){
        int a = (cp[(i+1)%n] - cp[i]).cross(p - cp[i]);
        if(a < 0)
            ret1 = false;
        if(a > 0)
            ret2 = false;
    }
    return ret1 || ret2;
}

int main()
{
    int n;
    cin >> n;

    while(--n >= 0){
        vector<Point> cp(3);
        Point a, b;
        for(int i=0; i<3; ++i)
            cin >> cp[i].x >> cp[i].y;
        cin >> a.x >> a.y >> b.x >> b.y;

        if(convexContain(cp, a) ^ convexContain(cp, b))
            cout << "OK" << endl;
        else
            cout << "NG" << endl;
    }
}

Measured memory_bytes: 908
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>

using namespace std;

long long f(long long n) {
  if (n==-1) return 0LL;
  if (n%4==0) return n;
  if (n%4==2) return n^1LL;
  if (n%4==1) return 1LL;
  if (n%4==3) return 0LL;
}

int main() {
  long long A,B; cin >> A >> B;
  cout<<(f(A-1LL)^f(B))<<endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;

    int res = s.size();
    for(int i = 0; i < s.size() - 1; ++i) {
        if(s[i] != s[i + 1]) res = min(res, max(i + 1, int(s.size()) - i - 1));
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[21001],i,j,k,n,m,f[210001],s;
int main(){
	scanf("%d",&n);memset(f,0,sizeof(f));
	for (i=1,s=0;i<=n;i++) scanf("%d",&a[i]),s+=a[i];
	for (f[0]=i=1;i<=n;i++)
	 for (j=s;j>=a[i];j--) f[j]|=f[j-a[i]];
	for (j=s;j;j--)
	 if (j%10&&f[j]) break;
	printf("%d\n",j);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
	string s;
	cin >> s;
	ll m = 2019;
	map<ll , ll>mp;
	ll val = 0;
	int j = 1;
	for (ll i = s.size() - 1; i >= 0; i--)
	{
		val = (val + (s[i] - '0') * j) % m;
		//cout << val << "\n";
		mp[val]++;
		j = (j * 10) % m;
	}
	ll ans = mp[0];
	map<ll , ll>::iterator it = mp.begin();
	for ( ; it != mp.end(); it++)
	{
		ll m = (*it).second;
		ans += m * (m - 1) / 2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3724
#include<stdio.h>
#define N 500000

int A[N],H;

int left(int i){return i*2;}
int right(int i){return (i*2)+1;}


void trade(int i,int j)
{
  int rep;
  rep = A[i];
  A[i] = A[j];
  A[j] = rep;
}

void maxHeapify(int i){

  int l,r,largest;

  l=left(i);
  r=right(i);

  if(l<=H && A[l]>A[i]){
    largest=l;
  }

  else{
    largest=i;
  }

  if(r<=H && A[r]>A[largest]){
    largest=r;
  }

  if(largest!=i){
    trade(i,largest);
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  int i;
  for(i=H/2;i>0;i--)
    maxHeapify(i);
}

int main(){
  int i;

  scanf("%d",&H);
  
  
  for(i=1;i<=H;i++){
    scanf(" %d",&A[i]);
  }

  buildMaxHeap();

  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 3644
N, D = map(int, input().split())
X = list()
for i in range(N) :
	X.append(list(map(int, input().split())))

cnt = 0
for i in range(N - 1) :
	for j in range(i + 1, N) :
		s = 0
		for k in range(D) :
			s += (X[i][k] - X[j][k]) ** 2
		d = s ** (1/2)
		if(d == int(d)) :
			cnt += 1
		else :
			pass
	
print(cnt)

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

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = 998244353;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static long maxn = 200005;

    static class up implements Comparable<up> {
        int a;
        long b;

        up(int a, long b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(up o) {
            return (int) (this.b - o.b);
        }
    }

    static void solve() {
        int n = ni();
        int m = ni();
        long sum = 0;
        long a[] = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nlo();
        }
        Arrays.sort(a);
        up p[] = new up[m];
        for (int i = 0; i < m; i++) {
            int b = ni();
            long c = nlo();
            p[i] = new up(b, c);
        }
        Arrays.sort(p);
        int cur = m - 1;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (cur >= 0 && p[cur].b > a[i]) {
                a[i] = p[cur].b;
                cnt += 1;
                if (cnt == p[cur].a) {
                    cnt = 0;
                    cur -= 1;
                }
            } else
                break;
        }
        for (int i = 0; i < n; i++)
            sum += a[i];
        out.println(sum);
    }
}

Measured memory_bytes: 46092
# 10^4程度なので愚直でOK
A = int(input())
B = int(input())
C = int(input())
X = int(input())

pattern = 0
for a500 in range(A+1) :
    for b100 in range(B+1) :
        for c50 in range(C+1) :
            if (a500 * 500 + b100 * 100 + c50 * 50 == X) :
                pattern += 1

print(pattern)


Measured memory_bytes: 3060
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	X, Y, A, B, C = getlist()
	P = sorted(getlist())
	Q = sorted(getlist())
	R = getlist()
	apple = []
	for i in range(X):
		apple.append(P[-1 - i])
	for i in range(Y):
		apple.append(Q[-1 - i])

	apple += R
	apple = sorted(apple)
	ans = 0
	for i in range(X + Y):
		ans += apple[-1 - i]
	print(ans)



if __name__ == '__main__':
	main()

Measured memory_bytes: 79524
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }





int main() {
    string s;
    cin >> s;
    if(s.size() == 3) reverse(s.begin(), s.end());
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int mod=998244353;
int a[1000010];
int main()
{
	int n;
	cin >>n;
	int x;
	cin >>x;
	int sum=x;
	for(int i=1;i<n;i++)
	{
		cin >>x;
		sum=__gcd(sum,x);
	}
	cout <<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define pb push_back
const ll mod = 1000000007;

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

    vvl G(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
    }

    ll sv, tv;
    cin >> sv >> tv;
    sv--;  tv--;

    vvl dist(n, vl(3, -1));  // dist[i][j] : 移動距離がmod3でjとなる頂点svから頂点iまでの最短距離
    queue<pll> Q;

    dist[sv][0] = 0;
    Q.push(make_pair(sv, 0));
    while(!Q.empty()) {
        ll v = Q.front().first;
        ll c = Q.front().second;
        Q.pop();
        for(auto u : G[v]) {
            ll nc = (c + 1)%3;
            if(dist[u][nc] != -1) {
                continue;
            }
            dist[u][nc] = dist[v][c] + 1;
            Q.push(make_pair(u, nc));
        }
    }
    
    ll ans = dist[tv][0];
    if(ans != -1) {
        ans /= 3;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  ll flg = 0;
  rep(i,n) {
    cin>>m;
    if(m%2==0){
      flg++;
    }
  }
  cout<<pow(3,n)-pow(2,flg)<<endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n, cnt=0;
    cin >> n;
    vector<ll> p(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    p.push_back(0);
    rep(i,n){
        if(p[i]==i){
            swap(p[i+1], p[i]);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4828
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <set>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Point {
  int x;
  int y;
  int cost;
  int str;
  Point(int x, int y, int cost, int str) : x(x), y(y), cost(cost), str(str) {;}
};

int w, h;
char field[60][60];
char str[100];
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const char move[4] = { 'R', 'D', 'L', 'U' };
char temp[100];

int main() {
  while (scanf("%d %d", &h, &w),  h|w) {
int p = 0;
char revmove[300];
  revmove[(int)'R'] = 1;
  revmove[(int)'D'] = 2;
  revmove[(int)'L'] = 3;
  revmove[(int)'U'] = 4;
set<int> prefix;
set<int> ban;
set<string> pattern;
set<int> visit[60][60];
  int sx, sy;
  REP(y, h) {
    REP(x, w) {
      scanf(" %c ", &field[y][x]);
      if (field[y][x] == 'S') { sx = x; sy = y; }
    }
  }
  scanf("%d", &p);
  REP(i, p) {
    scanf("%s", str);
    pattern.insert((string)str);
  }
  for (set<string>::iterator it1 = pattern.begin(); it1 != pattern.end();) {
    FORIT(it2, pattern) {
      if (it1 == it2) { continue; }
      if (it1->find(*it2) != string::npos) {
        pattern.erase(it1++);
        goto next;
      }
    }
    it1++;
next:;
  }
  FORIT(it, pattern) {
    int num = 0;
    REP(i, it->size()) {
      num = num * 5 + revmove[(int)(*it)[i]];
      prefix.insert(num);
    }
    ban.insert(num);
  }
  prefix.insert(2000000000);
  queue<Point> que;
  que.push(Point(sx, sy, 0, 0));
  visit[sy][sx].insert(0);
  while (!que.empty()) {
    Point p = que.front();
    que.pop();
    //cout << p.x << " " << p.y << " " << p.cost << " " << p.str << endl;
    if (field[p.y][p.x] == 'G') {
      printf("%d\n", p.cost);
goto next2;
    }
    REP(i, 4) {
      int nx = p.x + dx[i];
      int ny = p.y + dy[i];
      if (nx < 0 || nx >= w || ny < 0 || ny >= h || field[ny][nx] == '#') { continue; }
      int nstr = p.str * 5 + i + 1;
      int start = pow(5, 11);
      while (nstr != 0 && !prefix.count(nstr)) {
        nstr %= start;
        start /= 5;
      }
      if (ban.count(nstr)) { continue; }
      if (visit[ny][nx].count(nstr)) { continue; }
      visit[ny][nx].insert(nstr);
      que.push(Point(nx, ny, p.cost + 1, nstr));
    }
  }
  puts("-1");
next2:;
}
}

Measured memory_bytes: 3384
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int A, B, C; cin >> A >> B >> C;
    if(A + B + C >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;



int main(void) {
  string s;
  cin >> s;
  int n = s.length();
  // greedy
  VI dp(n + 2, 0);
  dp[n + 1] = 0;
  dp[n] = 1;
  vector<VI> next(n + 1, VI(26));
  set<char> seen;
  VI tbl(26, n + 1);
  for (int i = n - 1; i >= 0; --i) {
    tbl[s[i] - 'a'] = i + 1;
    int mi = 1e8;
    REP(j, 0, 26) {
      next[i][j] = tbl[j];
      mi = min(mi, dp[next[i][j]] + 1);
    }
    dp[i] = mi;
  }
  /*
  while (pos < n) {
    seen.insert(s[pos]);
    if (seen.size() == 26) {
      seen.clear();
      res += s[pos];
    }
    pos += 1;
  }
  for (char c = 'a'; c <= 'z'; ++c) {
    if (seen.count(c) == 0) {
      res += c;
      break;
    }
  }
  */
  string res;
  int cur = dp[0];
  int pos = 0;
  while (cur > 0) {
    REP(i, 0, 26) {
      char c = 'a' + i;
      if (dp[next[pos][i]] == cur - 1) {
	res += c;
	cur -= 1;
	pos = next[pos][i];
	break;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 27780
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

char grid[55][55];

int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)cin >> grid[i][j];

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

	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++) {
		int cnt = 0;
		for (int k = 0; k < 4; k++) {
			if (grid[i][j] == '#'|| grid[i][j] == 'x') {
				int nx = j + dx[k];
				int ny = i + dy[k];
				if (nx >= 0 && nx < w && ny >= 0 && ny < h) {
					if (grid[ny][nx] == '#'|| grid[ny][nx] == 'x') {
						grid[i][j] = 'x';
						grid[ny][nx] = 'x';
						break;
					}
				}
			}
		}
	}

	bool flag = true;
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++) {
		if (grid[i][j] == '#') {
			flag = false;
			break;
		}
	}

	cout << ((flag) ? "Yes" : "No") << endl;


	return 0;
}

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

const int mod = 1e9 + 7;
int main() {
    int n;
    cin >> n;
    int64_t ans = 1;
    for (int i = 1; i <= n; i++) {
        ans *= i;
        ans %= mod;
    }
    cout << ans << '\n';
    return 0;
}


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

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

    string S;

    cin >> S;

    bool answer = false;

    for (int i = 1; i < 4; i++) {
        if (S[i - 1] == S[i]) {
            answer = true;
        }
    }

    if (answer) {
        cout << "Bad" << '\n';
    } else {
        cout << "Good" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
/*
この問題は、ABC_042_Aである
与えられた文字数で俳句ができるか調べるコード
*/
#include<iostream>
using namespace std;

int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == 5){
    if(b == 5){
      if(c == 7){
        cout << "YES" << '\n';
      }
      else{
        cout << "NO" << '\n';
      }
    }
    else if(b == 7){
      if(c == 5){
        cout << "YES" << '\n';
      }
      else{
        cout << "NO" << '\n';
      }
    }
    else{
      cout << "NO" << '\n';
    }
  }
  else if(a == 7){
    if(b == 5){
      if(c == 5){
        cout << "YES" << '\n';
      }
      else{
        cout << "NO" << '\n';
      }
    }
    else{
      cout << "NO" << '\n';
    }
  }
  else{
    cout << "NO" << '\n';
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ans = []
if N % 2 == 1:
    l, r = 1, N - 1
    while l < r:
        ans.append((l, r))
        l += 1
        r -= 1
else:
    l, r = 1, N - 1
    flag = False
    while l < r:
        if not flag and r - l <= N // 2:
            r -= 1
            flag = True
        ans.append((l, r))
        l += 1
        r -= 1
for i in range(M):
    print(ans[i][0], ans[i][1])

Measured memory_bytes: 73316
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
struct edge {
	int to, cost;
};

signed main() {
	string s, t; cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t)puts("Yes");
	else puts("No");
}

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

bool cmp(long a, long b){
        return (a < b)?true:false;
}

int main(){
    vector<long> attryi;
    long sizey, tmp;
    cin >> sizey;
    

    for(long i = 0;i < sizey; i++){
        std::cin >> tmp;
        attryi.push_back(tmp);
    }

    sort(attryi.begin(), attryi.end(),cmp);
/*    
    for(long i=0;i<sizey;i++){
        cout << attryi.at(i) << ",";
    }
    cout << endl;
*/
    long cen = sizey/2;
    cout << attryi.at(cen) - (attryi.at(cen-1)) << endl;        
}

Measured memory_bytes: 1400
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

constexpr int MOD = 1000000007;

int main(){
    Stream io;

    string s;
    io.read(s);
    int l;
    for(l = 0; s[l] != 'A'; l++);
    int r = l;
    for(int i = l + 1; i < s.size(); i++){
        if(s[i] == 'Z') r = i;
    }
    cout << r - l + 1;
    return 0;
}

Measured memory_bytes: 640
def rsp(t):
  t=t.replace('r','P')
  t=t.replace('p','S')
  t=t.replace('s','R')
  return t

N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
T_rev=list(rsp(T))

if N<K:
  print(T_rev.count('R')*R+T_rev.count('S')*S+T_rev.count('P')*P)
else:
  for i in range(K,N):
    if T_rev[i]==T_rev[i-K]:
      T_rev[i]='x'
  print(T_rev.count('R')*R+T_rev.count('S')*S+T_rev.count('P')*P)

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

int main() {
    int t;
    cin >> t;
    int h, m, s;
    h = t / pow(60, 2);
    m = (t - h * pow(60, 2)) / 60;
    s = t - h * pow(60, 2) - m * 60;
    cout << h << ":"
         << m << ":" << s << endl;
}



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

std::string s1, s2;

int main()
{
	std::cin >> s1;
	s2 = s1;
	std::reverse(s2.begin(), s2.end());
	for(int i = 0; i < s2.size(); i ++)
	{
		if(s2[i] == 'b') s2[i] = 'd';
		else if(s2[i] == 'd') s2[i] = 'b';
		else if(s2[i] == 'p') s2[i] = 'q';
		else if(s2[i] == 'q') s2[i] = 'p';  
	}
//	std::cout << s1 << " " << s2 << "\n"; 
	if(s1 == s2)
	{
		printf("Yes");
	}
	else 
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
  int i;
  char X[200010];
  scanf("%s", X);
  int N = strlen(X);
  int count_s[200010];
  count_s[0] = 0;
  int eliminate = 0;
  for (i = 1; i < N+1; i++) {
    if (X[i-1] == 'S') {
      count_s[i] = count_s[i-1] + 1;
    } else if (count_s[i-1] > 0) {
      eliminate += 2;
      count_s[i] = count_s[i-1] - 1;
    } else {
      count_s[i] = count_s[i-1];
    }
  }
  printf("%d", N - eliminate);
  return 0;
}


Measured memory_bytes: 1152
#!/usr/bin/python3

(n, x, y) = map(int, input().split())

cs = [0 for i in range(n)]

for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        d = min(abs(j - i), abs(x - i) + 1 + abs(j - y))
        cs[d] += 1

for i in range(1, n):
    print(cs[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
#define P pair<int,int>
typedef long long ll;
using namespace std;

int main(){
    int x,y,z; cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y << endl;
return 0;
}


Measured memory_bytes: 768
<?php

//文字列の入力
fscanf(STDIN,"%d %d %d",$a,$b,$c);

//容器１に容器２から入れることのできる量
$max = $a - $b;

if ($max >= $c){
    echo 0;
}else{
    $total = $c - $max;
    echo $total;
}



Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mo 1000000007
#define mems(a,x) memset(a,x,sizeof(a))
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}



int main() 
{ 
	ll n,w;
	cin>>n>>w;
	ll a[n],b[n];
	for(int i=0;i<n;i++)
		cin>>b[i]>>a[i];
	ll dp[n+1][w+1];
	
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(i==0||j==0)
				dp[i][j]=0;

			else if(b[i-1]<=j)
				dp[i][j]=max(a[i-1]+dp[i-1][j-b[i-1]],dp[i-1][j]);
				else
					dp[i][j]=dp[i-1][j];
			
		}	

	}
	cout<<dp[n][w];
	
	

} 

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

int main(){
    long long n, q;
    cin >> n >> q;

    string s;
    cin >> s;
    
    long long counter[n];

    long long count = 0;
    long long i = 0;

    while(i < s.size()){
        if(s[i] == 'A' and s[i+1] == 'C'){
            counter[i] = count;
            count++;
            counter[i+1] = count;
        }
        else{
            counter[i] = count;
        }
        i++;
    }

    long long ans[q];
    for(long long j = 0; j < q; j++){
        long long l, r;
        cin >> l >> r;
        //printf("counter[r-1] %lld counter[l-1] %lld\n", counter[r-1], counter[l-1]);
        ans[j] = counter[r-1] - counter[l-1];
        //printf("%lld\n", ans[j]);
    }

    for(long long j = 0; j < q; j++){
        printf("%lld\n", ans[j]);
    }

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int x = c - a, y = d - b;
    printf("%d %d %d %d\n", c - y, d + x, a - y, b + x);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;
const int maxn = 1e3 + 5;
const int dir[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
int mp[maxn][maxn];
//bool vis[maxn][maxn];
int d[maxn][maxn];
struct point{
    int x,y;
};
int h,w,n;
 int dis = 0;
void bfs(point &p,int cnt)
{
   // memset(vis, 0, sizeof(vis));
    memset(d, 0, sizeof(d));
    queue<point> q;
    q.push(p);
    while (!q.empty()) {
        point t = q.front();q.pop();
        //vis[t.x][t.y] = true;
        if(mp[t.x][t.y] == cnt + 1) {dis += d[t.x][t.y];p.x = t.x,p.y = t.y;return ;}
        for (int i = 0; i < 4; i ++) {
            int tx = t.x + dir[i][0];
            int ty = t.y + dir[i][1];
            if (tx >= 0 && tx < h && ty >= 0 && ty < w && !d[tx][ty] && mp[tx][ty] != -1) {
                q.push({tx,ty});
                d[tx][ty] = 1 + d[t.x][t.y];
            }
        }
    }
}
int main()
{
    while (scanf("%d%d%d",&h,&w,&n) != EOF) {
        getchar();
        char ch;
        memset(mp, -1, sizeof(mp));
       // int sx,sy;
        point s;
        for (int i = 0; i < h; i ++) {
            for (int j = 0; j < w; j ++) {
                scanf("%c",&ch);
                if(ch == 'S') {s.x = i,s.y = j;mp[i][j] = 0;}
                else if(ch == '.') {mp[i][j] = 0;}
                else if(isdigit(ch)) {mp[i][j] = ch - '0';}
            }
            getchar();
        }
       
        dis = 0;
        for (int i = 0; i < n; i ++) {
            bfs(s,i);
        }
        printf("%d\n",dis);
    }
    return 0;
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int arr[10][10],sumr[10],sumc[10];

void solve(){
	int h,w;
	cin>>h>>w;
	int k;
	cin>>k;
	int cnt=0;
	fr(i,1,h+1){
		fr(j,1,w+1){
			char t;
			cin>>t;
			if(t=='.'){
				arr[i][j]=0;
			}
			else{
				cnt++;
				sumc[j]++;
				sumr[i]++;
				arr[i][j]=1;
			}
		}
	}
	int x=cnt-k;
	if(x<0){
		cout<<0<<endl;
		return;
	}
	int ans=0;
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			vi col;
			int del=0;
			int cc=j,rr=i;
			int kk=1;
			while(cc>0){
				if(cc&1){
					col.pb(kk);
					del+=sumc[kk];
				}
				kk++;
				cc>>=1;
			}
			kk=1;
			while(rr>0){
				if(rr&1){
					del+=sumr[kk];
					for(auto cl: col){
						if(arr[kk][cl]==1)
							del--;
					}
				}
				kk++;
				rr>>=1;
			}
			if(del==x){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 3628
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int solve_testcase() {
    int H, W; scanf("%d%d", &H, &W);
    if(H == 0 and W == 0) return 1;

    vector< vector<int> > board(H, vector<int>(W));
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            scanf("%d", &board[i][j]);
        }
    }

    int ans = 0;
    for(int h=3; h<=H; h++) {
        for(int w=3; w<=W; w++) {
            for(int lx=0; lx<H-h+1; lx++) {
                for(int ly=0; ly<W-w+1; ly++) {
                    int max_inside = -1, min_edge = 100, sum = 0;
                    for(int x=lx; x<lx+h; x++) {
                        for(int y=ly; y<ly+w; y++) {
                            bool edge = false;
                            edge |= (x == lx or x == lx+h-1);
                            edge |= (y == ly or y == ly+w-1);
                            if(edge) chmin(min_edge, board[x][y]);
                            else {
                                chmax(max_inside, board[x][y]);
                                sum += board[x][y];
                            }
                        }
                    }
                    if(max_inside < min_edge) {
                        int cand = min_edge * (h-2) * (w-2) - sum;
                        chmax(ans, cand);
                    }
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



Measured memory_bytes: 3272
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var M = parseInt(input[0].split(" ")[1]);
  C=new Array(M);
  P=new Array(0);
  for(i=0;i<M;i++){
    tmp=input[i+1].split(" ");
    Csub=[parseInt(tmp[0]),parseInt(tmp[1]),i];
    C[i]=Csub;
  }
  C.sort(function(a, b) {
		if (a[0] < b[0]) return -1;
		if (a[0] > b[0]) return 1;
		if (a[1] < b[1]) return -1;
		if (a[1] > b[1]) return 1;
		return 0;
	});
  for(i=0;i<M;i++){
    var c="";
    var y="";
    if(C[i][0]<10){
      c=`00000${C[i][0]}`;
    }else if(C[i][0]<100){
      c=`0000${C[i][0]}`;
    }else if(C[i][0]<1000){
      c=`000${C[i][0]}`;
    }else if(C[i][0]<10000){
      c=`00${C[i][0]}`;
    }else if(C[i][0]<100000){
      c=`0${C[i][0]}`;
    }else{
      c=`${C[i][0]}`;
    }
    if(i==0){
      var cnt=1;
    }else if(C[i][0]!=C[i-1][0]){
      cnt=1;
    }else{
      cnt++;
    }
    if(cnt<10){
      y=`00000${cnt}`;
    }else if(cnt<100){
      y=`0000${cnt}`;
    }else if(cnt<1000){
      y=`000${cnt}`;
    }else if(cnt<10000){
      y=`00${cnt}`;
    }else if(cnt<100000){
      y=`0${cnt}`;
    }else{
      y=`${cnt}`;
    }
    P.push([`${c}${y}`,C[i][2]]);
  }
  P.sort(function(a,b){return a[1]-b[1]});
  var ans="";
  for(i=0;i<M;i++){
    if(i!=M-1){
      ans=ans+P[i][0]+"\n";
    }else{
      ans=ans+P[i][0];
    }
  }


  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 73752
#include<stdio.h>
int main()
{
char yo[3], ji[3];
	scanf("%s", yo);
	scanf("%s", ji);

	int day = 0;
	for (int i = 0; i < sizeof(yo); i++)
	{
		if (yo[i] == ji[i])
		{
			day++;
		}
	}
	
	// 出力
	printf("%d\n", day);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    std::string s;
    cin >> s;
    cout << (s[0] == s[2] ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int edge[705][705];
int diff[705][705];
int color[705];
int count[3];
int check = -1;
int opt[705][2];
int f[705][705];

void dfs(int u,int n){
    count[color[u]]++;
    for(int i = 1; i <= n; i++){
        if(diff[u][i]){
            if(color[i]!=0 && color[i]==color[u]){ 
                check = 0;
            }
            else if(color[i]==0){
                color[i] = (color[u])%2+1;
                dfs(i,n);
            }
        }
    }
}

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i = 0; i < m; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        edge[u][v] = edge[v][u] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            if(!edge[i][j]){ 
                diff[i][j] = diff[j][i] = 1;
            }
            else diff[i][j] = diff[j][i] = 0;
        }
    }
    int ok = 1, size = 0;
    for(int i = 1; i <= n; i++){
        if(color[i]==0){
            check = 1;
            count[1] = count[2] = 0;
            color[i] = 1;
            dfs(i,n);
            if(check==0){
                ok = 0;
                break;
            }
            else{
                size++;
                opt[size][0] = count[1];
                opt[size][1] = count[2];
                //printf("count1 = %d, count2 = %d\n",count[1],count[2]);
            }
        }
    }
    if(!ok) printf("-1\n");
    else{
        f[0][0] = 1;
        for(int i = 1; i <= size; i++){
            for(int j = 0; j <= 700; j++){
                f[i][j] = 0;
                int last = j-opt[i][0];
                if(last>=0 && last<=700) f[i][j] |= f[i-1][last];
                last = j-opt[i][1];
                if(last>=0 && last<=700) f[i][j] |= f[i-1][last];
            }
        }
        int ans = n*n;
        for(int i = 0; i <= n; i++){
            if(f[size][i]){
                int  x = i, y = n-i;
                int cur = x*(x-1)/2 + y*(y-1)/2;
                ans = cur<ans?cur:ans;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 7428
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
const int N=3005,P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int f[N][N<<1],c[N],inv[N],x,n,res;
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&x),res=1;
	inv[0]=inv[1]=1;fp(i,2,n)inv[i]=mul(P-P/i,inv[P%i]);
	c[0]=1;fp(i,1,n)c[i]=1ll*c[i-1]*inv[i]%P*(n-i+1)%P;
	f[0][0]=1;fp(i,0,n-1)fp(j,0,i<<1)upd(f[i+1][j+2],f[i][j]),upd(f[i+1][j+1],f[i][j]);
	fp(i,1,n){
		int s=0;
		fp(j,0,x-1)upd(s,f[i][j]);
		for(R int j=x+1;j<=(i<<1);j+=2)if(j>=i){
			int p=i-(j-x+1),q=x-1-(j-x+1);
			if(j>=x*2)upd(s,j==(i<<1)?x&1:0);
				else upd(s,p>=0&&q>=0?f[p][q]:0);
		}
		upd(res,mul(s,c[i]));
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 69120
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a + b / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

struct UnionFind{
    public:
    vector<int> data;
    UnionFind(ll sz){
        data.assign(sz, -1);
    }
    int find(int p){
        if(data[p]<0) return p;
        return data[p]=find(data[p]);
    }
    bool unite(int X, int Y){
        X=find(X), Y=find(Y);
        if(X==Y) return false;
        if(data[X]>data[Y]) swap(X, Y);
        data[X] += data[Y];
        data[Y]=X;
        return true;
    }
    ll size(int k){
        return -data[find(k)];
    }
};

int main() {
	ll N, M;
	cin >> N >> M;
	vector<int> a(M), b(M);
	for(int i=0; i<M; ++i){
	    cin >> a[i] >> b[i];
	    --a[i];
	    --b[i];
	}
	vector<ll> ans(M);
	ans[M-1]=N*(N-1)/2;
	UnionFind uf(N);
	for(int i=M-1; i>0; --i){
	    ans[i-1]=ans[i];
	    if(uf.find(a[i])!=uf.find(b[i])){
	        ans[i-1] -= uf.size(a[i])*uf.size(b[i]);
	        uf.unite(a[i], b[i]);
	    }
	}
	for(int i=0; i<M; ++i) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3328
import math
n, k = [int(i) for i in input().split()]
sum = 0
for ni in range(1,n+1):
    if ni >= k:
        sum += 1/n
    else:
        face_times = math.ceil(math.log2(k/ni))
        sum += 1/(n*2**face_times)
print(sum)

Measured memory_bytes: 3188