akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
using namespace std;

// A - Day of Takahashi
int main(){
    int a, b;
    cin >> a >> b;
    int ans=a-1;
    for (int i=1;i<=a;++i){
        if(i==a && i<=b){++ans;}
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int a,b;
  cin>>a>>b;
  int ans=a*b-a-b+1;
  cout(ans);
  return 0;
}

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

int main() {
    deque<int> a;
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int t, d;
        cin >> t >> d;
        if (t == 0) {
            int x;
            cin >> x;
            if (d == 0) a.push_front(x);
            else a.push_back(x);
        } else if (t == 1) {
            cout << a[d] << endl;
        } else {
            if (d == 0) a.pop_front();
            else a.pop_back();
        }
    }
}



Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <sstream>
using namespace std;

#define MAX_N 10

int n, k;
vector<int> cs;
set<string> ps;

string to_s(int r) {
	ostringstream os;
	os << r;
	return os.str();
}

bool used[MAX_N];
void enumerate(int k_) {
	if (k_ == k) {
		vector<string> part;
		for (int i = 0; i < n; i++) {
			if (used[i]) {
				part.push_back(to_s(cs[i]));
			}
		}
		sort(part.begin(), part.end());
		do {
			string p = "";
			for (int i = 0; i < k; i++) p.append(part[i]);
			ps.insert(p);
		} while (next_permutation(part.begin(), part.end()));
		return;
	}
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			used[i] = true;
			enumerate(k_ + 1);
			used[i] = false;
		} 
	}
}

int main() {
	while (cin >> n >> k) {
		if (n == 0 && k == 0) break;
		cs.clear();
		cs.resize(n);
		ps.clear();
		for (int i = 0; i < MAX_N; i++) used[i] = false;
		for (int i = 0; i < n; i++) cin >> cs[i];
		enumerate(0);
		cout << ps.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 1480
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;

int check_prime(ll);

int main(){
    ll X;
    cin >> X;
    while(1){
        if(check_prime(X) == 1) break;
        X += 1;
    }
    cout << X << endl;
}

int check_prime(ll x){
    //if x is prime number, return 1. otherwise return 0.
    for(ll i=2; i*i<=x; i++){
        if(x%i == 0) return 0;
    }
    return 1;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String s=sc.next();
        int k=sc.nextInt()-1;
        String output="";
        char remove=s.charAt(k);
        for(int i=0;i<n;i++){
            if(remove==s.charAt(i)){
                output+=remove;
            }else{
                output+="*";
            }
        }
        System.out.println(output);
    }
}

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

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

    ll Ecnt=0, Wcnt=0;
    for(int i=0; i<n; i++){
        if(s.at(i)=='E') Ecnt++;
        else Wcnt++;
    }

    ll ecnt=0, wcnt=0;
    ll ans=1000000000;
    for(int now=0; now<n; now++){
        ll tmp = 0;
        if(s.at(now)=='E'){
            ecnt++;
        }
        else wcnt++;

        if(s.at(now)!='E') tmp = wcnt + Ecnt - ecnt - 1;
        else tmp = wcnt + Ecnt - ecnt;
        ans = min(tmp, ans);
    }

    cout << ans << endl;
}


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

using namespace std;

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

  int tmp;
  bool ok = true;
  for (int i= 0; i< N; ++i) {
    cin >> tmp;
    if (tmp % 2 == 0 && !(tmp % 3 == 0 || tmp % 5 == 0)) {
      ok = false;
      break;
    }
  }
  cout << (ok ? "APPROVED" : "DENIED") << endl;
  return 0;
}

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

int main(void){
    int n, m, lim, flag;
    char **np, **mp; 

    scanf("%d %d", &n, &m);

    np = malloc(sizeof(char *) * n);
    for(int i = 0; i < n; i++) np[i] = malloc(sizeof(char) * n + 1);

    mp = malloc(sizeof(char *) * m);
    for(int i = 0; i < n; i++) mp[i] = malloc(sizeof(char) * m + 1);

    for(int i = 0; i < n; i++) scanf("%s", np[i]);
    for(int i = 0; i < m; i++) scanf("%s", mp[i]);
    
    lim = n - m + 1;
    for(int i = 0; i < lim; i++){
        for(int j = 0; j < lim; j++){
            if(np[i][j] == mp[0][0]){
                flag = 0;
                for(int k = 0; k < m; k++){
                    for(int l = 0; l < m; l++){
                        if(np[i + k][j + l] != mp[k][l]){
                            flag = 1; 
                            break;
                        }
                    }
                    if(flag == 1) break;
                }
                if(flag == 0){
                    printf("Yes");
                    flag = 2;
                }
            }
            if(flag == 2) break;
        }
        if(flag == 2) break;
    }

    if(flag != 2) printf("No");
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

int gcd(int a, int b){
    if (b == 0) {
        return a;
    }
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

void solve(){
    string S;
    cin >> S;
    int len = S.size();

    for (int i = len-1; i >= 0; i--) {
        // cout << i << endl;
        if (S[i] == 'm') {
            if (S.compare(i-4, 5, "dream") == 0) {
                i -= 4;
            } else {
                cout << "NO" << endl;
                return;
            }
        } else if (S[i] == 'e') {
            if (S.compare(i-4, 5, "erase") == 0) {
                i -= 4;
            } else {
                cout << "NO" << endl;
                return;
            }
        } else if (S[i] == 'r'){
            if (S.compare(i-5, 6, "eraser") == 0) {
                i -= 5;
            } else if (S.compare(i-6, 7, "dreamer") == 0) {
                i -= 6;
            } else {
                cout << "NO" << endl;
                return;
            }
        }
    }

    cout << "YES" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var abc = ReadLine().Split().Select(int.Parse).ToArray();
        var k = int.Parse(ReadLine());
        Array.Sort(abc);
        var d = (int)Math.Pow(2, k);
        WriteLine(abc[2] * d + abc[0] + abc[1]);
    }
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;

int main(){
    int N,M,ans=0;
    cin >> N >>M;
    vector<int> A(M);
    rep(i,M) cin >> A[i];

    rep(i,M)
        ans += A[i];
    
    if(ans > N) ans = -1;
    else ans = N -ans;
    
    cout << ans;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<cstdlib>
#define INF 1001001001001001001
#define MAX 2001001

#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main() {
	int h, w, ch, cw, dh, dw;
	cin >> h >> w >> ch >> cw >> dh >> dw;
	vector<vector<char>>s(h, vector<char>(w));
	rep(i, 0, h)rep(j, 0, w)cin >> s[i][j];

	ch--; cw--; dh--; dw--;
	vector<pair<int, int>>m{ {0,1},{1,0},{0,-1},{-1,0} };
	vector<vector<bool>>been(h, vector<bool>(w, 0));
	vector<vector<int>>warp(h, vector<int>(w, MAX));
	queue<pair<int, int>>que, quew;
	quew.push({ ch,cw });
	warp[ch][cw] = 0;
	while (!quew.empty()) {
		int a, b;
		a = quew.front().first;
		b = quew.front().second;
		if (been[a][b]) {
			quew.pop();
			continue;
		} 
		que.push({ a,b });
		been[a][b] = true;
		while (!que.empty()) {
			int x, y;
			x = que.front().first;
			y = que.front().second;
			rep(i, 0, 5)rep(j, 0, 5) {
				int nx, ny;
				nx = x + i - 2;
				ny = y + j - 2;
				if (i == 2 && j == 2)continue;
				if (nx >= 0 && nx < h && ny >= 0 && ny < w) {
					if (s[nx][ny] == '#')continue;
					warp[nx][ny] = min(warp[nx][ny], warp[x][y] + 1);
					quew.push({ nx,ny });
				}
			}
			rep(i, 0, 4) {
				int nx, ny;
				nx = x + m[i].first;
				ny = y + m[i].second;
				if (nx >= 0 && nx < h && ny >= 0 && ny < w) {
					if (s[nx][ny] == '#')continue;
					if (been[nx][ny])continue;
					been[nx][ny] = true;
					warp[nx][ny] = min(warp[nx][ny],warp[x][y]);
					que.push({ nx,ny });
				}
			}
			que.pop();
		}
		quew.pop();
	}
	if (warp[dh][dw] == MAX)cout << -1 << endl;
	else cout << warp[dh][dw] << endl;
}

Measured memory_bytes: 9524
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,a,b,c,d;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    long long t1,t2;
    int i;
    long long x=a-b;
    for (i=0;i<=n-1;i++)
    {
        t1=(long long)c*i-(long long)d*(n-1-i);
        t2=(long long)d*i-(long long)c*(n-1-i);
        if ((t1<=x)&&(x<=t2))
        {
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
} 


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  if(s[k-1]=='A'){
    s[k-1]='a';
  }else if(s[k-1]=='B'){
    s[k-1]='b';
  }else{
    s[k-1]='c';
  }
  cout<<s;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[5];
		for (int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
		}
		int k = sc.nextInt();
		System.out.println((a[4]-a[0]<=k)?"Yay!":":(");
		sc.close();
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B;
  cin >> A >> B;
  if(A%3==0 || B%3==0 || (A+B)%3==0){
  cout << "Possible" << endl;
  }
  else{
  cout << "Impossible" << endl;
  }
}

  


  



Measured memory_bytes: 256
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};

ll const MAX = 1e5 + 5;
ll v[MAX], w[MAX];
ll dp[105][MAX];

int main() {
	cin.tie(0);
	ll n, W;
	cin >> n >> W;
	REP(i, 1, n) {
		cin >> w[i] >> v[i];
	}
	dp[0][0] = 0;
	REP(j, 1, 1e5) {
		dp[0][j] = 1e17;
	}
	REP(i, 1, n) {
		REP(j, 0, 1e5) {
			if (j >= v[i]) {
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	ll ans = 0;
	REP(j, 0, 1e5) {
		if (dp[n][j] <= W) {
			ans = j;
		}
	}
	cout << ans << endl;
}

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

int main(){
  int m, h;
  string str;
  while(1){
      cin >> str;
      if(str == "-") break;
      cin >> m;
      for(int i=0; i<m; i++){
          cin >> h;
          str+=str.substr(0,h);
          str.erase(0,h);
      }
      cout << str << endl;
  }
  return 0;
}


Measured memory_bytes: 3168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		ArrayList<ArrayList<Integer>> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}

		int p[] = new int[m];
		int y[] = new int[m];

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");
			p[i] = Integer.parseInt(str[0]);
			y[i] = Integer.parseInt(str[1]);

			list.get(p[i] - 1).add(y[i]);
		}

		for (int i = 0; i < n; i++) {
			Collections.sort(list.get(i));
		}

		for (int i = 0; i < m; i++) {
			String s = "";
			int front = p[i];

			int left = 0;
			int right = list.get(p[i] - 1).size();

			while (right - left > 1) {
				int mid = (right + left) / 2;

				if (y[i] < list.get(p[i] - 1).get(mid)) {
					right = mid;
				} else if (y[i] > list.get(p[i] - 1).get(mid)) {
					left = mid;
				} else {
					right = mid;
					left = mid;
				}
			}

			int back = left + 1;

			if (front < 10) {
				s = "00000" + front;
			} else if (front < 100) {
				s = "0000" + front;
			} else if (front < 1000) {
				s = "000" + front;
			} else if (front < 10000) {
				s = "00" + front;
			} else if (front < 100000) {
				s = "0" + front;
			} else if (front == 100000) {
				s = "" + front;
			}

			if (back < 10) {
				s += "00000" + back;
			} else if (back < 100) {
				s += "0000" + back;
			} else if (back < 1000) {
				s += "000" + back;
			} else if (back < 10000) {
				s += "00" + back;
			} else if (back < 100000) {
				s += "0" + back;
			} else if (back == 100000) {
				s += "" + back;
			}

			System.out.println(s);
		}
	}
}


Measured memory_bytes: 82452
import java.util.*;

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

    int sec = sc.nextInt();

    int h = sec / 3600;
    int m = (sec % 3600) / 60;
    int s = (sec % 3600) % 60;

    System.out.println(h + ":" + m + ":" + s);
  }
}



Measured memory_bytes: 26400
s = input()
l = [0]*(len(s)+1)
for i in range(len(s)):
    if s[i] == "<":
        l[i+1] = l[i]+1
for i in range(len(s)-1, -1, -1):
    if s[i] == ">":
        l[i] = max(l[i], l[i+1]+1)
print(sum(l))

Measured memory_bytes: 74036
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define fi first
#define se second
using namespace std;
int x,y,n,u,v;
const int mod=1000000007;
int64_t pw(int64_t u,int c){
    int64_t kq=1;
    while(c){
        if (c&1) kq=(kq*u)%mod;
        u=(u*u)%mod;
        c>>=1;
    }
    return kq;
}
int main(){
    scanf("%d%d",&x,&y);
    int64_t tmp;
    for (int i=0;i*2<=x;++i)
    if ((x-i*2)*2==y-i){
        n=i+(x-i*2);
        u=i,v=n-i;
        tmp=1;
        for (int j=1;j<=u;++j)
            tmp=(tmp*j)%mod;
        for (int j=1;j<=v;++j)
            tmp=(tmp*j)%mod;
        tmp=pw(tmp,mod-2);
        for (int j=1;j<=n;++j)
        tmp=(tmp*j)%mod;
        cout<<tmp;
        return 0;
    }
    printf("%d",0);
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main(void)
{
    int X, Y;
    cin >> X >> Y;

    for(int i=0; i<=X; i++){
        if(2*(i+2*(X-i))==Y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
    
}


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

// Caleb Faith Adnaka XI105
int main() {

    int N,R;
    cin >> N;
    cin >> R;

    if (N >= 10){
        cout << R << "\n";
    }
    else{
        cout << R + (100 * (10-N)) << "\n";
    }

}

Measured memory_bytes: 3584
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define INF 10000000000
#define M 1000000007

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	char str[] = "CODEFESTIVAL2016";
	char S[128];
	int i;
	int ans = 0;
	
	scanf("%s", S);
	for(i=0;i<strlen(S);i++) {
		if(S[i] != str[i]) ans++;
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
#define N 100005
int n, m, p[N], y[N];//n個の県にm個の市。市iはy[i]年に誕生していて県p[i]に属している
vector<int> vt[N];

int main(){
    int i, k;
    cin >> n >> m;
    for(i=0; i<m; i++){//県ごとのvector
        cin >> p[i]>> y[i];
        vt[p[i]].push_back(y[i]);
    }

    for(i=1; i<=n; i++){//それぞれの県ごとに年で昇順ソートする
        sort(vt[i].begin(), vt[i].end());
    }

    for(i=0; i<m; i++){
        k = lower_bound(vt[p[i]].begin(), vt[p[i]].end(), y[i]) - vt[p[i]].begin();//何番目に若いかを返す(0スタート)
        cout << setfill('0') << right << setw(6) << p[i];
        cout << setfill('0') << right << setw(6) << k+1 << endl;;
    }
    return 0;
}

Measured memory_bytes: 7808
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  cin>>n;
  string s;
  cin>>s;
  int a=0,b=0;
  rep(i,n)
    if(s[i]==')'){
      if(b==0)a++;
      else b--;
    }else{
      b++;
    }
  rep(i,a)cout<<"(";
  cout<<s;
  rep(i,b)cout<<")";
  cout<<endl;
}


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

ll binpow(ll a, ll b, ll mod){
    if(b==0){
        return 1ll;
    }
    ll temp = binpow(a,b/2,mod);
    temp = (temp*temp)%mod;
    if(b%2){
        return (temp*a)%mod;
    }
    return temp;
}

ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    return gcd(b,a%b);
}

int main(){
    map<pair<ll,ll>,ll> cnt;
    ll n, a, b, zero=0, temp;

    const ll mod = 1000000007;

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        if(a==0 && b==0){
            zero++;
        }
        else if(a==0){
            cnt[{1,0}]++;
        }
        else if(b==0){
            cnt[{0,1}]++;
        }
        else{
            temp = gcd(a,b);
            if(temp<0){ temp*=-1;}
            a /= temp;
            b /= temp;

            if(b<0){ b*=-1; a*=-1;}
            cnt[{a,b}]++;
 
        }
    }

    ll answ = 1ll;
    answ = (answ + (binpow(2,cnt[{0,1}],mod)-1) + (binpow(2,cnt[{1,0}],mod)-1))%mod;
    cnt[{0,1}] = 0;
    cnt[{1,0}] = 0;

    for(auto p:cnt){    
        ll last = answ%mod;
        a = p.first.first; b = p.first.second;
        
        if(a<0){
            a*=-1ll;
            b*=-1ll;
        }       
        
        if(p.second){
            answ = (last + (1ll*last*(binpow(2ll,p.second,mod)+mod-1ll))%mod)%mod;
            if(cnt[{-1ll*b,a}]){
                answ = (answ + (1ll*last*(binpow(2ll,cnt[{-1ll*b,a}],mod)+mod-1ll))%mod)%mod;
            }
        }

        cnt[{-b,a}] = 0;
    }
    cout << (answ+zero-1+mod)%mod << '\n';

    return 0;
}

Measured memory_bytes: 28596
#include<stdio.h>
#define MAX 1000010

int is_prime[MAX];

void sieve(){
  int i,j;
  for(i=0;i<=MAX;i++)is_prime[i]=1;
  is_prime[0]=is_prime[1]=0;
  for(i=2;i<=MAX;i++){
    if(is_prime[i]){
      for(j=2*i;j<=MAX;j+=i)is_prime[j]=0;
    }
  }
}

int main(){
  int a,i;
  int sum[MAX];
  sieve();
  for(i=0;i<MAX;i++)sum[i]=0;
  for(i=1;i<MAX;i++)sum[i]=sum[i-1]+is_prime[i];
  while(scanf("%d",&a)!=EOF){
    printf("%d\n",sum[a]);
  }
  return 0;
}

Measured memory_bytes: 10392
# 各クエリに対して,二分探索で解を求める

def bs(x,li):
    # 値xがliの2連続した値a,b達が作る[a,b)のどこに入るか
    # aを返す
    # liはソート済みとする
    left,right=0,len(li)
    while left+1<right:
        mid = (left+right)//2
        if li[mid]<=x:
            left=mid
        else:
            right=mid
    return left

def get(L):
    ret=[-10**13]
    for _ in range(L):
        ret.append(int(input()))
    ret.append(10**13)
    return ret

A,B,Q=map(int,input().split())
S=get(A)
T=get(B)
for _ in range(Q):
    x=int(input())

    # sn,sp,tn,tpを二分探索で出す
    sn,tn=bs(x,S),bs(x,T)

    # これらの経路の組み合わせの中に最小値が含まれている
    # 全部で8パターンあるので全探索してminをansとして保持
    ans=10**13
    for s in [S[sn],S[sn+1]]:
        for t in [T[tn],T[tn+1]]:
            d=abs(s-x)+abs(t-s)
            e=abs(t-x)+abs(s-t)
            ans=min([ans,d,e])
    print(ans)

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

int main() {
  int n; cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p.at(i);

  int ans = 0;

  for (int i = 1; i < n - 1; i++)
  {
    int bigMum = max(p.at(i-1), p.at(i+1));
    int minMum = min(p.at(i-1), p.at(i+1));
    if(bigMum > p.at(i) && p.at(i) > minMum) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 ll n,k;
 cin>>n>>k;
 for(int i=0;i<n;i++)
 {
     cin>>A[i];
 }
 for(int i=0;i<n;i++)
 {
     if(i>=k)
     {
         if(A[i-k]<A[i])
         {
             cout<<"Yes"<<endl;
         }
         else
         {
             cout<<"No"<<endl;
         }
     }
 }

return 0;
}


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

int main() {
	int n;
	string s1, s2;
	int a = 0, b = 0;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s1 >> s2;
		if (s1 > s2) a += 3;
		else if (s1 < s2) b += 3;
		else {
			a++;
			b++;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 3192
def d_grid_coloring(H, W, N, A):
    # 方針:数字を「うなぎ」のようにくねくね並べれば、
    # 条件を満たすものが1つ見つかる

    # 1から順にそれで塗る回数だけ書き込む
    tmp = []
    for i, a in enumerate(A):
        tmp.extend([str(i + 1)] * a)
    # tmpをW文字ごとに分割
    tmp = [tmp[i:i + W] for i in range(0, len(tmp), W)]
    # 奇数行目は「折り返す」
    tmp = [row if i % 2 == 0 else row[::-1] for i, row in enumerate(tmp)]

    # 出力形式に合わせて整形
    ans = []
    for s in tmp:
        ans.append(' '.join(s))
    ans = '\n'.join(ans)
    return ans

H,W = [int(i) for i in input().split()]
N = int(input())
A = [int(i) for i in input().split()]
print(d_grid_coloring(H, W, N, A))

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

int main(void){
    int N, K, tmp, d[11] = {0};
    cin >> N >> K;
    rep(i, K) {
        cin >> tmp;
        d[tmp] = 1;
    }

    for(int a=N; ; ++a) {
        int t = a;
        bool flag = true;
        while(t > 0) {
            if(d[t%10] == 1) {
                flag = false; break;
            } else {
                t /= 10;
            }
        }
        if(flag) {
            cout << a << endl;
            break;
        }
    }


    return 0;
}

Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
const int mx = 1000 * 100 + 5;
int a[mx], b[mx], ar[mx];
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, ans = 0, s = 0, s2 = 0, sum = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		s += a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
		s2 += b[i];
		ar[i] = a[i] - b[i];
		if(a[i] < b[i]){
			sum += b[i] - a[i];
			ans++;
		}
	}
	if(s - s2 < 0){
		cout << -1 << endl;
		return 0;
	}
	sort(ar , ar + n);
	for(int i = n - 1; i >= 0; i--){
		if(sum > 0){
			ans++;
			sum -= ar[i];
		}
		else
			break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

N,_=gets.chomp.split(' ').map{|n| n.to_i}
A = Array.new(N)
0.upto(N-1){|d|
	A[d],_=gets.chomp.split(' ').map{|n| n.to_i}
}

mode = :NONE
start_i = nil
# v_final and v when start section
start_v_final = nil
start_v = nil
# the last value of left forward
left_v = nil
# the last values of right forward
right_v = nil
for i in 0..(N-1)
	v = A[i]
	v_final = i+1
	dputs "searching A[#{i}], #{A[i]}"
	case mode
	when :NONE
		dputs "NONE"
		if(v==v_final)
			next
		elsif((v-v_final)%2==0)
			mode = :STARTED
			# 3 5 7 9 1
			# 5 7 9 1 3
			# 9 1 3 5 7
			right_v = v
			left_v = nil
			start_i = i
			start_v_final = v_final
			next
		else
			puts "No"
			exit(0)
		end
	else
		dputs "mode = #{mode}"
		if((i-start_i) % 2 != 0)
			if(v==v_final)
				dputs "pivot ok"
				next
			else
				dputs "pivot NG"
				puts "No"
				exit(0)
			end
		else
			if(mode == :STARTED)
				if(v < v_final)
					if(left_v.nil? || left_v < v)
						left_v = v
						if(right_v == v_final)
							mode = :NONE
						end
						next
					else
						puts "No"
						exit(0)
					end
				elsif(v > v_final)
					if(right_v < v)
						right_v = v
						next
					else
						puts "No"
						exit(0)
					end
				else
					puts "No"
					exit(0)
				end
			end
		end
	end
end
puts "Yes"


Measured memory_bytes: 6780
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
    int sum;
    string s;   
    while(true){
        cin >> s;
        if (s == "0") break;
        for (int i = 0; i < s.size(); i++){
            int c = s[i];
            sum += c -'0';
        }
        cout << sum << endl;
        sum = 0;
    }
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
const long long INF = 1LL << 60;
using namespace std;

int main(int argc, char const *argv[])
{
    ll n, c;
    cin >> n >> c;
    ll last = n - 1;
    ll x[n], v[n];
    rep(i, n) cin >> x[i] >> v[i];
    ll sushir[n], sushil[n];
    sushir[0] = v[0];
    rep(i, 1, n) sushir[i] = sushir[i - 1] + v[i];

    sushil[last] = v[last];
    rep(i, 1, n) sushil[last - i] = sushil[last - i + 1] + v[last - i];

    ll sumr[n], suml[n];
    rep(i, n) sumr[i] = sushir[i] - x[i];
    rep(i, n) suml[last - i] = sushil[last - i] - (c - x[last - i]);

    ll posr[n], posl[n];
    ll bestr[n], bestl[n];
    bestr[0] = max(0ll, sumr[0]);
    posr[0] = x[0];

    rep(i, 1, n) if (bestr[i - 1] < sumr[i])
    {
        bestr[i] = sumr[i];
        posr[i] = x[i];
    }
    else
    {
        bestr[i] = bestr[i - 1];
        posr[i] = posr[i - 1];
    }

    bestl[n - 1] = max(0ll, suml[n - 1]);
    posl[last] = c - x[last];
    rep(i, 1, n) if (bestl[last - i + 1] < suml[last - i])
    {
        bestl[last - i] = suml[last - i];
        posl[last - i] = c - x[last - i];
    }
    else
    {
        bestl[last - i] = bestl[last - i + 1];
        posl[last - i] = posl[last - i + 1];
    };
/*
    rep(i, n) cerr << "sushiR" << i << ":" << sushir[i] << endl;
    rep(i, n) cerr << "sushiL" << i << ":" << sushil[i] << endl;
    rep(i, n) cerr << "sumR" << i << ":" << sumr[i] << endl;
    rep(i, n) cerr << "sumL" << i << ":" << suml[i] << endl;
    rep(i, n) cerr << "bestR" << i << ":" << bestr[i] << endl;
    rep(i, n) cerr << "bestL" << i << ":" << bestl[i] << endl;
    rep(i, n) cerr << "posR" << i << ":" << posr[i] << endl;
    rep(i, n) cerr << "posL" << i << ":" << posl[i] << endl;
*/
    ll ans = 0;
    rep(i, n - 1)
    {
        cerr << bestr[i] << " " << bestl[i + 1] << endl;
        ans = max(ans, bestr[i] + bestl[i + 1] - min(posr[i], posl[i + 1]));
    }
    rep(i, n)
    {
        ans = max(ans, bestr[i]);
        ans = max(ans, bestl[i]);
    }
    cout << ans << endl;
    return 0;
}


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

 class UnionFind {
   // まとめる 判定 サイズを知る
  public:
   // Aから見た親の番号を格納する。rootだったら-1*その集合のサイズ。
   vector<int> Parent;
 
   // 初期化
   UnionFind(int N) {
     Parent = vector<int>(N, -1);
   }
 
   // Aのrootを調べる
   int root(int A) {
     if (Parent[A] < 0) return A;  // マイナスならそれはroot
     return Parent[A] = root(Parent[A]);
   }
 
   // rootの値をプラスに戻して返す(サイズ)
   int size(int A) {
     return -Parent[root(A)];
   }
 
   // くっつける関数
   bool connect(int A, int B) {
     // AとBのroot同士をくっつける
     A = root(A);  // ここのAは、"rootの場所"の意味
     B = root(B);
     if (A == B) return false;  // 既にくっついている
     if (size(A) < size(B))
       swap(A, B);            // 大きい方にくっつけるために中身交換
     Parent[A] += Parent[B];  // 中身更新
     Parent[B] = A;
     return true;
   }
 };

int main() {
    int n, m, a, b, ans = 0;
    cin >> n >> m;
    UnionFind uf(n);
    for(int i = 0; i < m; ++i) {
        cin >> a >> b;
        uf.connect(a, b);
    }
    for(int i = 0; i < n; ++i) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4044
import java.util.Scanner; 
public class Main {
	static int W, H, m=11, turn=0;
	static int[][] field;
	static int[] dx={1, 0, -1, 0};
	static int[] dy={0, 1, 0, -1};
	
	static void dfs(int nowh,int noww) {
		if(turn>10)	return;
		turn++;
		for(int d=0; d<4; d++) {
			if(nowh+dy[d]<0||nowh+dy[d]>=H||noww+dx[d]<0||noww+dx[d]>=W) {
				continue;
			}
			if(field[nowh+dy[d]][noww+dx[d]]==1) {
				continue;
			}
			for(int i=1; ; i++) {
				if(nowh+dy[d]*i<0||nowh+dy[d]*i>=H||noww+dx[d]*i<0||noww+dx[d]*i>=W) {
					break;
				}
				if(field[nowh+dy[d]*i][noww+dx[d]*i]==1) {
					field[nowh+dy[d]*i][noww+dx[d]*i]=0;
					dfs(nowh+dy[d]*(i-1), noww+dx[d]*(i-1));
					field[nowh+dy[d]*i][noww+dx[d]*i]=1;
					break;
				}
				if(field[nowh+dy[d]*i][noww+dx[d]*i]==3) {
					m=Math.min(m, turn);
					break;
				}
			}
		}
		turn--;
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			W=sc.nextInt();
			H=sc.nextInt();
			if(W+H==0)  break;
			field=new int[H+1][W+1];
			int sh=0, sw=0;
			for(int i=0; i<H; i++){
				for(int j=0; j<W; j++){
					field[i][j]=sc.nextInt();
					if(field[i][j]==2){
						sh=i;   sw=j;
					}
				}
			}
			m=11;	turn=0;
			dfs(sh, sw);
			System.out.println((m==11)? -1:m);
			//System.out.println(m);
			
		}

	}
}


Measured memory_bytes: 46348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S, T;
    cin >> S >> T;
    int size = S.size();
    map<char, int> s, t;
    int num1 = 0;
    int num2 = 0;
    rep(0, i, size)
    {
        if (s[S[i]])
        {
            S[i] = (char)((int)'a' + s[S[i]]);
        }
        else
        {
            num1++;
            s[S[i]] = num1;
            S[i] = (char)((int)'a' + num1);
        }

        if (t[T[i]])
        {
            T[i] = (char)((int)'a' + t[T[i]]);
        }
        else
        {
            num2++;
            t[T[i]] = num2;
            T[i] = (char)((int)'a' + num2);
        }
    }

    if (S == T)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main(){
	int a,b;
	for(int i=1;i>=1;i++){
		cin>> a >> b ;
		if((a==0)&&(b==0)){
		    break;
		}
		for(int i=0;i<b;i++){
			cout << "#";
		}
		cout <<endl;
			for(int j=0;j<a-2;j++){
				cout << "#";
				for(int i=0;i<b-2;i++){
					cout << ".";
			}
cout << "#";
			cout << endl;
		}	
				for(int i=0;i<b;i++){
			cout << "#";	
		}
		cout << endl << endl;;
	}
	return 0;
}


Measured memory_bytes: 1152
fun main(args: Array<String>) {
    when(val n = readLine()!!.toInt()) {
       in 1..1000 -> {
           println(1000 -n)
       }
        in 1001..2000 -> {
            println(2000 -n)
        }
        in 2001..3000 -> {
            println(3000 -n)
        }
        in 3001..4000 -> {
            println(4000 -n)
        }
        in 4001..5000 -> {
            println(5000 -n)
        }
        in 5001..6000 -> {
            println(6000 -n)
        }
        in 6001..7000 -> {
            println(7000 -n)
        }
        in 7001..8000 -> {
            println(8000 -n)
        }
        in 8001..9000 -> {
            println(9000 -n)
        }
        in 9001..10000 -> {
            println(10000 -n)
        }
    }
}

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

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


int main(void)
{
    ll x; cin>>x;
    bool dp[110000];
    dp[0]=true;
    rep(i,x)rep(j,6){
        if(dp[i]==true) dp[i+100+j]=true;
    }
    cout<<dp[x]<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <limits>
using namespace std;

struct TCard{
	int Number;
	char Mark;
};

int Partition(vector<TCard>& A, int p, int r)
{
	int i = p-1;
	for(int j = p; j < r; j++){
		if(A[j].Number <= A[r].Number){
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i+1], A[r]);
	return i+1;
}

void QuickSort(vector<TCard>& A, int p, int r){
	if(p < r){
		int q = Partition(A, p, r);
		QuickSort(A, p, q-1);
		QuickSort(A, q+1, r);
	}
}

void merge(vector<TCard> &A, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    vector<TCard> L, R;
    L.resize(n1 + 1);
    R.resize(n2 + 1);
    for(int i = 0; i < n1; i++){
        L[i] = A[left + i];
    }
    for(int i = 0; i < n2; i++){
        R[i] = A[mid + i];
    }
    L[n1].Number = numeric_limits<int>::max();
    R[n2].Number = numeric_limits<int>::max();
    int i = 0;
    int j = 0;
    for(int k = left; k < right; k++){
        if(L[i].Number <= R[j].Number){
            A[k] = L[i];
            i = i + 1;
        }else{
            A[k] = R[j];
            j = j + 1;
        }
    }
}
  
void mergeSort(vector<TCard> &A, int left, int right)
{
    if(left+1 >= right){
        return;
    }
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
}


bool IsStable(const vector<TCard>& A, const vector<TCard>& B)
{
	for(int i = 0; i < A.size(); i++){
		if(A[i].Mark != B[i].Mark){
		    return false; 
		}
	}
	return true;
}

int main()
{
	int n;
	cin >> n;
	vector<TCard> A(n);
	for(int i = 0; i < n; i++){
		cin >> A[i].Mark >> A[i].Number;
	}
	vector<TCard> B = A;
	mergeSort(B, 0, n);
	QuickSort(A, 0, n-1);
	if(IsStable(A, B)){
		cout << "Stable" << endl;
	}else{
		cout << "Not stable" << endl;
	}
	for(int i = 0; i < n; i++){
		cout << A[i].Mark << ' ' << A[i].Number << endl;
	}
	return 0;
}

Measured memory_bytes: 5040
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	if (A <= 8 && B <= 8) cout << "Yay!" << endl;
	else cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, k;
	cin >> n >> k;
	vector<double> pr(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		int s = x * (x + 1) / 2;
		pr[i] = (double)s / x;
	}
	vector<double> ps(n + 1);
	for (int i = 0; i < n; i++) {
		ps[i + 1] = ps[i] + pr[i];
	}
	double ans = 0;
	for (int i = 0; i + k <= n; i++) {
		ans = max(ans, ps[i + k] - ps[i]);
	}
	cout << fixed << setprecision(16) << ans << endl;
}


Measured memory_bytes: 3456
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

#define INF 1000000000000000000LL

ll h,w;

ll fmx(ll a, ll b, ll c){
    ll mx = max(a,max(b,c));
    return mx;
}

ll fmn(ll a, ll b, ll c){
    ll mn = min(a,min(b,c));
    return mn;
}

ll f(){
    ll mn = 1000000000000000000LL;
    ll a,b,c;
    rep(i,1,h){
        a = i*w;
        b = ((h-i)/2)*w;
        c = ((h-i)/2+(h-i)%2)*w;
        mn = min(mn,fmx(a,b,c)-fmn(a,b,c));
    }
    rep(i,1,h){
        a = i*w;
        b = (h-i)*(w/2);
        c = (h-i)*(w/2+w%2);
        mn = min(mn,fmx(a,b,c)-fmn(a,b,c));
    }
    return mn;
}

int main() {
    cin>>h>>w;
    ll mn = 1000000000000000000LL;
    mn = min(mn,f());
    swap(h,w);
    mn = min(mn,f());
    printf("%lld\n",mn);
    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();

    let a: Vec<usize> = read_vec();
    let mut ans = vec![0; n];
    for i in a.iter() {
        ans[*i - 1 as usize] += 1;
    }

    for i in ans.iter() {
        println!("{}", i);
    }
}


Measured memory_bytes: 4984
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let a:u64 = read();
    let b:u64 = read();
    let f: f64 = a as f64 / b as f64;
    println!("{} {} {}", a/b, a%b, f);

}


Measured memory_bytes: 5052
from collections import deque         
N = int(input())
G = {}
E = {}
E1 = []
for _ in range(N-1):
    a,b = map(int,input().split())
    if a not in G:
        G[a] = []
    G[a].append(b)
    if b not in G:
        G[b] = []
    G[b].append(a)
    E[(a,b)] = 0
    E[(b,a)] = 0
    E1.append((a,b))
col = 0
for x in G:
    col = max(col,len(G[x]))
hist = [0 for _ in range(N+1)]
heap = deque([(1,0)])
while heap:
    x = heap.popleft()
    hist[x[0]] = 1
    if x[1]!=0:
        c = E[(x[0],x[1])]
    else:
        c = 0
    for y in G[x[0]]:
        if hist[y]==0:
            c = c%col+1
            E[(x[0],y)] = c
            E[(y,x[0])] = c
            heap.append((y,x[0]))
print(col)
for i in range(N-1):
    print(E[E1[i]])

Measured memory_bytes: 115288
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  ll N; cin >> N;
  vector<int> a;
  int cnt = 0;
  while (N>0){
    if (N%26==0) {
      a.push_back(26);
      N-=26;
    }
    else a.push_back(N%26);
    N /= 26;
  }

  string s = "";
  rep(i,a.size()) {
    char c = 'a' + (a[i]-1)%26;
    s = c + s;
  }

  cout << s << endl;
  
  
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3620