akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int D = scn.nextInt();
        long[] c = new long[26];
        long[][] s = new long[D][26];
        long sumC = 0;
        int maxNum = 0;
        //long score =0;

        for(int i=0;i<26;i++){
            c[i]=scn.nextLong();
            sumC += c[i];
        }
        for(int i=0;i<D;i++){
            long max = -3000;
            for(int j=0;j<26;j++){
                s[i][j]=scn.nextLong();
                long tmp = s[i][j];
                long su = tmp - sumC*i+c[j]*i;
                if(max < su){
                    max = su;
                    maxNum = j;
                }
            }
            //score += max;
            System.out.println(maxNum+1);
        }

        //System.out.println(score);

        scn.close();

    }


}


Measured memory_bytes: 37928
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	string ans = "Yes";
	if (a == b  && a== c) {
		ans = "No";
	}
	if (a != b && a != c && b != c) {
		ans = "No";
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
for i, bb in enumerate(b):
    use = min(a[i], b[i])
    ans += use
    a[i] -= use
    b[i] -= use

    if b[i] == 0:
        continue

    use = min(a[i + 1], b[i])
    ans += use
    a[i + 1] -= use

print(ans)


Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll Q=1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> L(N+1,0);
  L[N]=10000;
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  sort(L.begin(),L.end());
  ll count=0;
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      //binary search for each (L[i],L[j])
      // C(x) = L[j]-L[i]<L[x]<L[j]+L[i]
      int DN=j,UP=N,x;// x must be in j<x<N
      bool exist = false;
      while(UP-DN>1){
        x=(UP+DN)/2;
        if(L[x]<=L[j]-L[i]){
          DN=x;
        }else if(L[j]+L[i]<=L[x]){
          UP=x;
        }else{
          exist=true;
          break;
        }
      }
      if(exist){
        int shita=x,ue=x;
        while(true){
          if(shita<=j||L[shita]<=L[j]-L[i]){
            break;
          }else{
            shita --;
          }
        }
        while(true){
          if(ue>=N||L[ue]>=L[j]+L[i]){
            break;
          }else{
            ue ++;
          }
        }
        count += (ue)-(shita)-1;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 100005
#define INF 1000000005LL

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

int n;
ll K;
int T[SIZE];

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&T[i]);
	sort(T,T+n);
	reverse(T,T+n);
	int a[2]={-1,-1};
	int j=0;
	for(int i=0;i<(n-1);i++){
		if(T[i]==T[i+1]){
			a[j]=T[i];
			j++;
			i++;
		}
		if(j==2)break;
	}
	if(a[0]==-1||a[1]==-1)printf("0\n");
	else printf("%lld\n",(ll)a[0]*a[1]);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
ll fact[1000007]={0}; // returns factorial of that number
bool sv[maxx]={0};    // returns if a num is prime or not
int sp[maxx]={0};     // gives smallest prime factor of the number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
void Sieve() {for(int i= 2; i< maxx; i+= 2)sp[i] = 2;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
*/
using namespace std;
signed main(){
  fast;
  //usefile;
  //test
  {
    string str;
    cin>>str;
    for(auto i: str){
        cout<<'x';
    }
  }
  //time("");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int AB, BC, CA;
    cin >> AB >> BC >> CA;
    cout << ((AB * BC) / 2) << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define str string
#define pi pair
#define tup tuple
#define vec vector
#define temp template
#define tn typename
#define fc function

#define ff first
#define ss second
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rsz resize
#define ins insert
#define fr front 
#define bc back
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define FOR(i, a, b) for (int i = a; i <= b; i++) 
#define ROF(i, a, b) for (int i = b; i >= a; i--)
#define trav(a, x) for (auto &a : x)
#define popcount __builtin_popcount
#define ctz __builtin_ctz
#define clz __builtin_clz
#define gcd __gcd

temp <tn T> void DBG(T v) { cerr << v; }
temp <tn T> void DBG(vec<T> v) {
  cerr << '{'; 
  bool f = true;
  FOR(i,0, sz(v) - 1) {
    if (!f) cerr << ", ";
    DBG(v[i]);
    f = false;
  }
  cerr << '}';
}
temp <tn T> void DBG(set<T> s) {
  vec<T> v;
  trav(x, s) { v.pb(x); }
  DBG(v);
}
temp <tn T> void DBG(multiset<T> s) {
  vec<T> v;
  trav(x, s) { v.pb(x); }
  DBG(v);
}
temp <size_t N> void DBG(bitset<N> b) {
  FOR(i, 0, N - 1) { cerr << b[i]; }
}
temp <tn A, tn B> void DBG(pi<A, B> p) { cerr << '(' << p.ff << ", " << p.ss << ')'; }
temp <tn A, tn B, tn C> void DBG(tup<A, B, C> t) {
  cerr << '(' << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << ')'; 
}
temp <tn T> void _dbg(T v) { DBG(v); cerr << endl; }
temp <tn H, tn... T>
void _dbg(H h, T... t) { _dbg(h); _dbg(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl; _dbg(__VA_ARGS__)

// MODULAR OPERATIONS
const ll md = (ll) 1e9 + 7;
ll nrm(ll x) { while (x < (ll) 0) x += md; x %= md; return x; }
ll sum() { return (ll) 0; }
temp <tn H, tn... T> ll sum(H h, T... t) { return nrm(nrm(h) + sum(t...)); }
ll mul() { return (ll) 1; }
temp <tn H, tn... T> ll mul(H h, T... t) { return nrm(nrm(h) * mul(t...)); }
ll power(ll a, ll b) {
  ll res = 1;
  while (b) { if (b & 1) res = mul(res, a); a = mul(a, a); b >>= 1; }
  return res;
}
ll inv(ll x) { return power(x, md - 2); }

// pay attention to md's value first!
// use normalized form of modular integers for output!

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int k;
  cin >> k;
  auto Sum = [&](int x) {
    return mul(x, sum(x, 1), inv(2));
  };
  auto F = [&](int n, int k) {
    int x = Sum(k - 1);
    int y = (k == n + 1 ? Sum(n) : sum(Sum(n), mul(-1, Sum(n - k))));
    return sum(y, mul(-1, x), 1);
  };
  int ans = 0;
  for (int i = k; i <= n + 1; i++) {
    ans = sum(ans, F(n, i));
  }
  cout << nrm(ans) << '\n';
  return 0;
}

Measured memory_bytes: 3656
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

# 鬼よりBが左
if A > B:
    if A - V*T <= B - W*T:
        print("YES")
    else:
        print("NO")
else:
    if A + V*T >= B + W*T:
        print("YES")
    else:
        print("NO")

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


void solve(long long N){
    vector<int> divisors(N+1);
    long long ans = 0;
    for (long long i = 1; i <= N; i++) {
        for (int j = i; j <= N; j += i) {
            divisors[j]++;
        }
        ans += i * divisors[i];
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 42352
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

int n;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		int ans=0;
		n=1000-n;
		ans+=n/500;
		n%=500;
		ans+=n/100;
		n%=100;
		ans+=n/50;
		n%=50;
		ans+=n/10;
		n%=10;
		ans+=n/5;
		n%=5;
		ans+=n;
		cout<<ans<<endl;
	}
}

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

using namespace std;

int main() {
  int H, W, N;

  cin >> H >> W >> N;

  int m = max(H, W);
  int ans = N % m == 0 ? (N / m) : (N / m) + 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1000000000;
int gcd(int p, int q){
  while(q != 0){
  int r = p % q;
  p = q;
  q = r;
  }
  return p;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  rep(i,n-1){
    if(a[i]==a[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map {it.toInt()}
    val ps = ArrayList<Pair<Int, Int>>()

    for (i in 0 until M) {
        val (a, b) = readLine()!!.split(" ").map {it.toInt()}
        ps.add(Pair(a, b))
    }

    ps.sortWith(Comparator { a, b -> a.second - b.second })

    var res = 0
    var q = 0

    for (p in ps) {
        if (q <= p.first) {
            ++res
            q = p.second
        }
    }

    println(res)
}


Measured memory_bytes: 63112
N,Y = map(int,input().split())

flag = 0



for i in range(0,N+1):
    for j in range(0,N-i+1):
        k = N-i-j
        sum = i * 10000 + j * 5000 + k * 1000
        if sum == Y:
            num1 = i
            num2 = j
            num3 = k
            flag = 1
        #print(i+j+k)

if flag == 1:
    print(num1, num2, num3)
else:
    print('-1 -1 -1')


Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    while (1) {
        int n, r, Cards[51], tmp[51], i;
        scanf("%d %d", &n, &r);

        if ( n == 0 && r == 0) { break; }

        for (i = 0; i < n; i++) { Cards[i] = n-i; }

        while (r--) {
            int p, c;
            scanf("%d %d", &p, &c);
            for (i = 0; i < c; i++) {
                tmp[i] = Cards[p+i-1];
            }
            for (i = c; i < p+c-1; i++) {
                tmp[i] = Cards[i-c];
            }
            for (i = p+c-1; i < n; i++) {
                tmp[i] = Cards[i];
            }
            for (i = 0; i < n; i++) { Cards[i] = tmp[i]; }
        }
        printf("%d\n", Cards[0]);
    }

    return 0;
}


Measured memory_bytes: 2020
/*
問題文
今日の曜日を表す文字列 S が与えられます。
S は SUN,MON,TUE,WED,THU,FRI,SAT のいずれかであり、
それぞれ日曜日、月曜日、火曜日、水曜日、木曜日、金曜日、土曜日を表します。

次の日曜日 (あす以降) が何日後か求めてください。

制約
S は SUN,MON,TUE,WED,THU,FRI,SAT のいずれか

*/

function Main(input) {
    var S = input.split('\n')
    
    var map = {
        "SUN":7,
        "MON":6,
        "TUE":5,
        "WED":4,
        "THU":3,
        "FRI":2,
        "SAT":1,
    }
	console.log(map[S[0]]);
}
 
//*編集不可。標準入出力から一度に読み込み、Mainを呼び出す
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
n = int(input())
if n == 1:
  print(0)
  exit()
  
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

chk = factorization(n)
ans = 0
for num,k in chk:
  now = 1
  while True:
    if k < now:
      break
    ans += 1
    k -= now
    now += 1

print(ans)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll score = 0;
    vector<ll> sum;
    rep (i, n) {
        int a, b;
        cin >> a >> b;
        sum.push_back(a + b);
        score -= b;
    }
    sort(sum.begin(), sum.end(), greater<ll>());
    rep (i, n) {
        if (!(i % 2)) score += sum[i];
    }
    cout << score << endl;
    
    return 0;
}



Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,a,b;
    set<int>st;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&a,&b);
        set<int>::iterator it;
        if(a==0)
        {
            st.insert(b);
            printf("%d\n",st.size());
        }
        else if(a==1)
        {
            it = st.find(b);
            if(it!=st.end()) printf("1\n");
            else  printf("0\n");
        }
        else st.erase(b);
    }
    return 0;
}




Measured memory_bytes: 12536
#include <bits/stdc++.h> 
using namespace std;
int main(){
  vector<int> Nums(3);
  for(int i=0;i<3;i++)	cin>>Nums[i];
  sort(Nums.begin(), Nums.end());
  if((Nums[0]==5)&&(Nums[1]==5)&&(Nums[2]==7)) cout<<"YES";
  else cout<<"NO";
  return 0;
}

  
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <string>
#include <cstdio>
#include <math.h>
using namespace std;

const long long int INF = 1000000007;

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

    if (N % 2 == 0)
    {
        long long ans = 0;
        for (long long i = 5; i <= N; i*=5)
        {
            ans += N / (i * 2);
        }
        
        cout << ans << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3524
import java.util.Arrays;
import java.util.Scanner;


public class Main {

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

		int N = sc.nextInt();
		int H = sc.nextInt();

		int[] S = new int[N+1];
		int[] T = new int[N+1];

		for(int i = 1 ; i <= N ; i++){
			S[i] = sc.nextInt();
			T[i] = sc.nextInt();
		}

		sc.close();

		Arrays.sort(S);
		Arrays.sort(T);

		long[] U = new long[N+1];

		for(int i = 1 ; i <= N ; i++){
			U[i] = U[i-1] + T[i];
		}

		long tmp = 0;
		long ans = 1000000000;
		for(int i = N ; i >= 0 ; i--){
			tmp = i;

			if((H-(U[N]-U[N-i])) > 0){
				tmp += (H-(U[N]-U[N-i]))/S[N];
				if((H-(U[N]-U[N-i]))%S[N]!=0){
					tmp++;
				}
			}

			ans = Math.min(ans, tmp);

			//System.out.println(i + "回刀を投げて" + tmp);
		}
		System.out.println(ans);

	}
}

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> s;
	if(s[0] != 'A'){
		cout << "WA";
		return 0;
	}
	f = 0;
	l = 0;
	REP(i, 2, s.size()-1){
		if(s[i] == 'C'){
			++f;
			l = i;
		}
	}
	if(f != 1){
		cout <<  "WA";
		return 0;
	}

	rep(i, s.size()){
		if(i == 0 || i == l) continue;
		if(isupper(s[i])){
			cout<< "WA";
			return 0;
		}
	}

	cout << "AC" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll a, b, c;
  vector<ll> xs(3);
  cin >> xs[0] >> xs[1] >> xs[2];
  auto res = 0;
  while (true) {
    sort(xs.begin(), xs.end(), greater<ll>());
    if (xs[0] == xs[2]) break;
    if (xs[0] == xs[1]) xs[2] += 2;
    else xs[0]--;
    res++;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string line = Console.ReadLine();
        int numX = int.Parse(line);
        int len = line.Length;

        int sum = 0;
        for(int i = 0; i < len; i++)
        {
            int num = int.Parse(line.Substring(i, 1));
            sum = sum + num;
        }
        string ans = "";
        if (numX % sum == 0)
        {
            ans = "Yes";
        }else{
            ans = "No";
        }
        Console.WriteLine(ans);
    }
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  int p = upper_bound(s.begin(), s.end(), 'p') - lower_bound(s.begin(), s.end(), 'p');
  cout << s.size() / 2 - p << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "


const int N = 3e6+1;
const int mod = 1e9+7;
ll pw(ll base, ll p)
{
  ll ret = 1;
  while (p)
    {
      if (p&1) ret = ret * base % mod;
      base = base * base % mod;
      p >>= 1;
    }
  return ret;
}
ll inverse(ll x)
{
  return pw(x, mod-2);
}
ll f[N], inv[N];
void init()
{
  f[0] = 1;
  for (ll i = 1; i < N; ++i) f[i] = f[i-1] * i % mod;
  inv[N-1] = inverse(f[N-1]);
  for (int i = N-1; i >= 1; --i) inv[i-1] = inv[i] * i % mod;
}
ll cb(ll n, ll k)
{
  if (n < 0 || k < 0 || n < k) return 0;
  return f[n] * inv[k] % mod * inv[n-k] % mod;
}
int main()
{
  init();
  ll r1, c1, r2, c2;
  while (cin >> r1 >> c1 >> r2 >> c2)
    {
      ll ans = 0;
      for (ll r = r1; r <= r2; ++r)
	{
	  (ans += cb(r+c2+1, c2) - cb(r+c1, c1-1)) %= mod;
	}
      cout << (ans + mod) % mod << endl;
    }
}


Measured memory_bytes: 47104
#include <iostream>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
using namespace std;

class card{
public:
  char p;
  int v;
  bool operator<(const card &another) const{
    return v < another.v;
  }
};

int n;
card a[100000], b[100000];

int part(int l, int r){
  card x = a[r - 1];
  int j = l - 1;
  for(int i = l; i < r - 1; i++){
    if(a[i].v <= x.v){
      j++;
      card t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }
  j++;
  card t = a[j]; a[j] = x; a[r - 1] = t;
  return j;
}

void q(int l, int r){
  if(l + 1 >= r) return;
  int p = part(l, r);
  q(l, p);
  q(p + 1, r);
  return;
}

void solve(){
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i].p >> a[i].v;
    b[i] = a[i];
  }
  q(0, n);
  stable_sort(b, b + n);
  bool ok = true;
  for(int i = 0; i < n; i++){
    if(a[i].p != b[i].p) ok = false;
  }
  if(ok) cout << "Stable\n";
  else cout << "Not stable\n";
  /*for(int i = 0; i < n; i++){
    cout << b[i].p << " " << b[i].v << endl;
  }*/

  for(int i = 0; i < n; i++){
    cout << a[i].p << " " << a[i].v << endl;
  }
  return;
}

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



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int INF = 1000100100;

int main()
{
    int n, k; cin >> n >> k;
    int p[n], c[n];

    ll csum = 0;
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> c[i];
    // rep(i,n) csum += c[i];
    rep(i,n) --p[i];

    ll ans = -INF;

    rep(i,n){
        // まずはループするまでの回数とコストの合計値を求める
        int iti = i;
        int ori_iti = i;
        ll csum = 0;
        ll cnt = 0;
        rep(_,n){
            csum += c[p[iti]];
            iti = p[iti]; 
            cnt++;
            if(iti == ori_iti) break;
        }  

        if(csum <= 0){
            ll sum = 0;
            iti = i;
            rep(_,n){
                sum += c[p[iti]];
                iti = p[iti];

                ans = max(sum, ans);
            }
        }else{
            ll sum = 0;
            sum += (k / cnt)*csum;
            sum -= csum;
            ans = max(sum, ans);

            ll roop = k % cnt;
            iti = ori_iti;

            rep(_,cnt){
                sum += c[p[iti]];
                iti = p[iti];

                ans = max(sum, ans);
            }

            rep(_,roop){
                sum += c[p[iti]];
                iti = p[iti];

                ans = max(sum, ans);
            }
        }
    }

    /*
    rep(i,n){   // このループは、初期位置の決め方
        if(csum > 0){
            ll sum = 0;
            sum += (k / n)*csum;
            ans = max(sum, ans);

            ll roop = k % n;
            int iti = i;

            rep(_,roop){
                sum += c[p[iti]];
                iti = p[iti];

                ans = max(sum, ans);
            }

            ans = max(sum, ans);

        }else{
            
        }
        
    }
    */


    cout << ans << endl;

}

Measured memory_bytes: 3668
class Node:
    def __init__(self, left, right):
        self.left_node_no = left
        self.right_node_no = right


def preorder_tree_walk(nodes, node_no, order):
    if node_no not in nodes:
        return
    order.append(node_no)
    preorder_tree_walk(nodes, nodes[node_no].left_node_no, order)
    preorder_tree_walk(nodes, nodes[node_no].right_node_no, order)
    return


def inorder_tree_walk(nodes, node_no, order):
    if node_no not in nodes:
        return
    inorder_tree_walk(nodes, nodes[node_no].left_node_no, order)
    order.append(node_no)
    inorder_tree_walk(nodes, nodes[node_no].right_node_no, order)
    return

def postorder_tree_walk(nodes, node_no, order):
    if node_no not in nodes:
        return
    postorder_tree_walk(nodes, nodes[node_no].left_node_no, order)
    postorder_tree_walk(nodes, nodes[node_no].right_node_no, order)
    order.append(node_no)
    return

def main():
    n = int(input())
    nodes = {}
    for i in range(n):
        node_no, left, right = [int(x) for x in input().split()]
        nodes[node_no] = Node(left, right)

    children = set([val.left_node_no for val in nodes.values()] + [val.right_node_no for val in nodes.values()])
    root_node_no = list(set(nodes.keys()) - children)[0]

    preorder = []
    preorder_tree_walk(nodes, root_node_no, preorder)
    print("Preorder")
    print(" " + " ".join(map(str, preorder)))

    inorder = []
    inorder_tree_walk(nodes, root_node_no, inorder)
    print("Inorder")
    print(" " + " ".join(map(str, inorder)))

    postorder = []
    postorder_tree_walk(nodes, root_node_no, postorder)
    print("Postorder")
    print(" " + " ".join(map(str, postorder)))
    return


main()


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int N,A,B;
int h[100010];

signed main(){
  cin>>N>>A>>B;
  for(int t=0;t<N;t++)cin>>h[t];

  int b=0,e=1000000000;
  while(e-b>1){
    int m=(b+e)/2;

    int sum=0;
    for(auto x:h){
      if(x-(m*B)>0){
        sum+=(x-m*B+A-B-1)/(A-B);
      }
      if(sum>m)break;
    }

    if(sum>m)b=m;
    if(sum<=m)e=m;
  }
  cout<<e<<"\n";
  return 0;
}


Measured memory_bytes: 1024
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
ls = ril()
left = 0
s0 = 0
s1 = 0
res = 0
for right, x in enumerate(ls):
    s0 += x
    s1 ^= x
    while left <= right and s0 != s1:
        s0 -= ls[left]
        s1 ^= ls[left]
        left += 1
    res += right - left + 1
print(res)

Measured memory_bytes: 23980
N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng == 1: break
  m = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    now_cost += max(a-(m//f), 0)
  if now_cost <= K:
    ok = m
  else:
    ng = m
    
print(ok)

Measured memory_bytes: 119260
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int i;
  string s;
  cin>>s;
  if(s[2]==s[3] && s[4]==s[5])
       cout<<"Yes";
  else 
       cout<<"No";
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ATableTennisTraining {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int n, a, b;
        cin >> n >> a >> b;
        int d = b - a;
        if (d % 2 == 0) {
            cout << d / 2 << endl;
        } else {
            int res = INF;
            {
                int tmp = n - b + 1;
                res = min(res, (n - (a + tmp)) / 2 + tmp);
            }
            {
                int tmp = a - 1 + 1;
                res = min(res, (b - (1 + tmp)) / 2 + tmp);
            }
            cout << res << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ATableTennisTraining solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {


    static int[] arr;

    static long N;
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        long k = s.nextLong();



        if (k < 2) {

            if (k == 0) {
                System.out.println(4);

                System.out.println("3 3 3 3");
            } else {

                System.out.println(3);

                System.out.println("1 0 3");
            }
        } else if ( k < 50){

            System.out.println(k);
            for (long i = 0; i < k; i++) {



                System.out.print(k + " ");
            }
        } else {

            System.out.println(50);

            long l = k / 50;



            long left = k%50;

            long a = (l+1)*50 -(k-l) + 50;

            long b = l*50 -(k-l) + 49;

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

                System.out.print(a + " ");
            }

            for (int i = 0; i < 50-left; i++) {

                System.out.print(b +" ");
            }
        }


    }





}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){
	vector<ll> div;
	for(int i=1;i*i<=x;i++){
		if(i*i!=x && x%i==0){
			div.pb(i);
			div.pb(x/i);
		}
		else if(x%i==0) div.pb(i);
	}
	return div;
}
vector<ll> vectorprime(ll x){
	vector<bool> is_prime(x+1);
	vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){
		if(is_prime[i]){
			prime.pb(i);
		}
		for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
	}
	return prime;
}

//a,b x
int main(){
	string s; cin>>s;
	ll ans=0;
	rep(i,s.sz){
		ll tmp;
		if(s[i]=='g') tmp=0;
		else tmp=1;

		if(i%2==0) ans+=(-tmp);
		else ans+=(1-tmp);
	}
	cout<<ans;
}

Measured memory_bytes: 512
# coding: utf-8
# Your code here!

while True:
    H, W = map(int,input().split())
    if H == 0 and W == 0 :
        break
    
    for i in range(H):
        for j in range(W):
            if (i+j)%2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7008
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    int64_t tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (int64_t)value;
    return output;
}

int64_t imax(const int64_t a, const int64_t b) { return std::max(a, b); } // std::max, std::min は型が違うとエラーになるため、ラッパーを作る。
int64_t imin(const int64_t a, const int64_t b) { return std::min(a, b); }

#define rep(i, begin, end) for(int64_t i = ((int64_t)begin); i <= ((int64_t)end); i++)
#define rev(i, begin, end) for(int64_t i = ((int64_t)begin); ((int64_t)end) <= i; i--)

#define input1(begin, end, v1) v1.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i]; }
#define input2(begin, end, v1, v2) v1.resize((end)+1); v2.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i]; } 
#define input3(begin, end, v1, v2, v3) v1.resize((end)+1); v2.resize((end)+1); v3.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i] >> v3[i]; } 

std::vector<int> irange(const int begin, const int end) {
    std::vector<int> ret; for (int i = begin; i <= end; i++) { ret.push_back(i); }
    return ret;
}

template <typename T>
void printvec(const std::vector<T>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

//int ;
//int128_t X, Y;
//std::vector<int> ;
//std::vector<int128_t> ;
std::string S;
//std::vector<std::string> ;
//double ;
//std::vector<double> ;

int main(int argc, char **argv) {
    std::cin >> S;
    
    int ret = S.size();
    rep (i, 0, S.size() - 2) {
        if (S[i+1] != S[i]) {
            ret = imin(ret, imax(i+1, S.size() - (i+1)));
        }
    }

    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 512
function main(input){
  const S=parseInt(input,10);
  if( (Math.floor(S/100)>=13 || Math.floor(S/100)==0) && ( ((S%100)>=13) ||(S%100)==0)){
    console.log("NA");
  }else if(Math.floor(S/100)>=13 || Math.floor(S/100)==0){
    console.log("YYMM");
  }else if((S%100)>=13 || (S%100)==0){
    console.log("MMYY");
  }else{
    console.log("AMBIGUOUS");
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ll n,k;
  cin>>n>>k;
  vecll dp(k+1, 0);
  dp[0] = 1;
  constexpr ll MOD = 1000000007;
  for(auto&& i:irange(0l,n)) {
    int a;
    cin>>a;
    vecll tmp(k+1, 0);
    ll sum = 0;
    for(auto&& j:irange(0l,k+1)) {
      sum += dp[j];
      sum %= MOD;
      if (j > a) {
        sum += MOD - dp[j-a-1];
        sum %= MOD;
      }
      tmp[j] = sum;
    }
    swap(dp, tmp);
  }
  cout<<dp[k]<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
template<typename T> ostream& operator<<(ostream& os, vector<T> a){os<<"( ";for(T &x:a)os<<x<<" ";os<<")\n";return os;}
template<typename T> ostream& operator<<(ostream& os, set<T> a){os<<"( ";for(T x:a)os<<x<<" ";os<<")\n";return os;}
template<typename T> ostream& operator<<(ostream& os, pair<T,T> a){os<<"("<<a.first<<" "<<a.second<<") ";return os;}
template<typename T> ostream& operator<<(ostream& os, complex<T> a){os<<"(r="<<a.real()<<" i="<<a.imag()<<") ";return os;}
typedef long long ll;
typedef double dd;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;
#define all(a) a.begin(),a.end()
#define DEBUG 1
#define debug(a) if(DEBUG)cout<<#a<<" = "<<a<<endl
#define x first
#define y second
//===========================Head=========================//

int main(int argc,char** argv){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,G;
    cin>>n>>G;
    G/=100;
    vi p(n),c(n), m(n);
    for (int i=0;i<n;++i){
        cin>>p[i]>>c[i];
        c[i]/=100;
    }
    int ans=1000000000;
    for (int k=0;k<(1<<n);++k){
        int sum=0, cnt=0;
        for (int i=0;i<n;++i) if ((k>>i)&1){
            sum+=c[i]+p[i]*(i+1);
            cnt+=p[i];
        }
        for (int i=n;i--;) if (sum<G&&((k>>i)&1)==0){
            int t=min(p[i],(G-sum+i)/(i+1));
            cnt+=t;
            sum+=t*(i+1);
        }
        ans=min(ans,cnt);
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cstdlib>
#include <map>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <time.h>
using namespace std;
int main(){
    long long int x,y;
    scanf("%lld%lld",&x,&y);
    long long int ans=abs(x-y);
    if(ans>1){
        printf("Alice\n");
    }
    else {
        printf("Brown\n");
    }
    return 0;
}


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

#define mp make_pair
#define pb push_back
const int INF = 1000000000;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

vi arr;
vii oddMin;
vii evenMin;

void buildTree(int n, int lb, int rb){
    
    if(lb + 1 == rb){
        if(lb % 2 == 0){
            evenMin[n] = mp(arr[lb], lb);
        } else {
            oddMin[n] = mp(arr[lb], lb);
        }
    } else {
        int mb = (lb+rb)/2;
        buildTree(2*n, lb, mb);
        buildTree(2*n+1, mb, rb);
        evenMin[n] = min(evenMin[2*n], evenMin[2*n+1]);
        oddMin[n] = min(oddMin[2*n], oddMin[2*n+1]);
    }
}

ii rmq(int l, int r, bool even, int lb, int rb, int n = 1){
    //cout << l << " " << r << endl;
    if(l == r) return mp(INF, -1);
    if(l <= lb && r >= rb){
        return even ? evenMin[n] : oddMin[n];
    } else {
        int mb = (lb + rb) / 2;
        if(r <= mb){
            return rmq(l, r, even, lb, mb, 2*n);
        } else if (l >= mb){
            return rmq(l, r, even, mb, rb, 2*n+1);
        } else {
            return min (rmq(l, r, even, lb, mb, 2*n), rmq(l, r, even, mb, rb, 2*n+1));
        }
    }
}
int N;
vvi adj;
vi neigh;
// normally:
// rmq(rev) -> odd indeces;
// rmq(!rev) -> even indeces
int getAdj(int lb, int rb, bool rev){
    if(lb == rb) return INF;
    auto em = rmq(lb, rb, !rev, 0, N).second;
    auto om = rmq(em, rb, rev, 0, N).second;
    neigh[em] = om;
    int a = getAdj(lb, em, rev);
    int b = getAdj(em+1, om, !rev);
    int c = getAdj(om+1, rb, rev);
    if(a != INF) adj[em].pb(a);
    if(b != INF) adj[em].pb(b);
    if(c != INF) adj[em].pb(c);
    return em;
}

vi nodes;

int main(){
    cin >> N;
    arr.assign(N, 0);
    for(int i = 0; i < N; i++){
        int p;
        cin >> p;
        arr[i] = p;
    }
    oddMin.assign(4*N, mp(INF, -1));
    evenMin.assign(4*N, mp(INF, -1));    
    vi v;
    buildTree(1, 0, N);
    adj.assign(N, v);
    neigh.assign(N, 0);
    int start = getAdj(0, N, false);
    
    

    priority_queue<ii, vii, greater<ii>> q;
    q.push(mp(arr[start], start));
    while(!q.empty()){
        auto t = q.top(); q.pop();
        nodes.pb(t.second);
        for(auto k : adj[t.second]){
            q.push({arr[k], k});
        }
    }
    for(auto k : nodes){
       cout << arr[k] << " " << arr[neigh[k]] << " ";
    }
    printf("\n");
}

Measured memory_bytes: 31736
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int32_t main()
{
	IOS;
	int a, b, h;
	cin>>a>>b>>h;
	int ans=h*(a+b)/2;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int r,c,a[101][101],i,j,sum,sumall,row[101]={0};
  scanf("%d %d",&r, &c);
  sumall=0;
  for(i=0;i<r;i++){
    sum=0;
    for(j=0;j<c;j++){
      scanf("%d",&a[i][j]);
      sum=sum+a[i][j];
      row[j]=row[j]+a[i][j];
    }
    a[i][c]=sum;
    sumall=sumall+sum;
  }
  for(j=0;j<c;j++){
    a[r][j]=row[j];
  }
  a[r][c]=sumall;

  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      if(j) printf(" ");
      printf("%d",a[i][j]);
    }
  printf("\n");
  }
  return 0;
}

Measured memory_bytes: 644
#include <cstdio>
char str[4005], ans[4005]; 
int st[4005]; 
inline bool query(int x, int y)
{
	printf("? %d %d\n", x, y);
	fflush(stdout); 
	scanf("%s", str); 
	return str[0] == 'Y'; 
}
int main()
{
	int a, b; 
	scanf("%d%d", &a, &b); 
	if (a <= b)
	{
		puts("Impossible"); 
		return 0; 
	}
	int n = a + b, tp = 0; 
	for (int i = 0; i < n; i++)
	{
		if (tp && !query(st[tp - 1], i))
		{
			tp--; 
			continue; 
		}
		st[tp++] = i; 
	}
	for (int i = 0; i < n; i++)
		ans[i] = query(st[tp - 1], i) + '0';
	printf("! %s\n", ans);
	return 0; 
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int len(int n)
{
	string s;
	stringstream ss;
	ss<<n;
	ss>>s;
	ss.clear();
	return s.length();
}
string num(int n)
{
	string s;
	stringstream ss;
	ss<<n;
	ss>>s;
	ss.clear();
	return s;
}

int main()
{	
	int n,m,a,b;
	string z[6]={"","0","00","000","0000","00000"};
	cin>>n>>m;
	vector<pair<int,int>>v[n+1];
	vector<string>ans(m+1);
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		v[a].push_back(make_pair(b,i+1));
	}
	for(int i=1;i<=n;i++)
	{
		if(v[i].size()==0)continue;
		sort(v[i].begin(),v[i].end());
		for(int j=0;j<v[i].size();j++)
		{	
			string number="";
			int p=len(i);
			int x=len(j+1);
			number+=z[6-p]+num(i)+z[6-x]+num(j+1);
			ans[v[i][j].second]=number;
		}
	}
	for(int i=1;i<=m;i++)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 12416
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<30)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;
 
int a[220000];
int ans[220000];
vector<int> dp(220000, INF);

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> s;
    vector<int> ord(n, -1);
    int c = 1, l = 0;
    {
        int v = 0;
        while (ord[v] == -1) {
            ord[v] = s.size();
            s.push_back(v);
            v = a[v] - 1;
        }
        c = s.size() - ord[v];
        l = ord[v];
    }

    if (k < l) cout << s[k] + 1 << endl;
    else {
        k -= l;
        k %= c;
        cout << s[l+k] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 6248
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

X,Y=input_int()
count=0
while X<=Y:
    count+=1
    X*=2
print(count)

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

int a,b;

int main(){
	cin>>a>>b;
	if(b%a==0) cout<<a+b<<endl;
	else cout<<b-a<<endl;
}

Measured memory_bytes: 256
s = input()
cal = ["+",""]
ans = 0
if len(s) == 1:
  print(s)
elif len(s) == 2:
  for i in cal:
    ans += eval(s[0]+i+s[1])
  print(ans)
elif len(s) == 3:
  for i in cal:
    for j in cal:
      ans += eval(s[0]+i+s[1]+j+s[2])
  print(ans)
elif len(s) == 4:
  for i in cal:
    for j in cal:
      for k in cal:
        ans += eval(s[0]+i+s[1]+j+s[2]+k+s[3])
  print(ans)
elif len(s) == 5:
  for i in cal:
    for j in cal:
      for k in cal:
        for l in cal:
          ans += eval(s[0]+i+s[1]+j+s[2]+k+s[3]+l+s[4])
  print(ans)
elif len(s) == 6:
  for i in cal:
    for j in cal:
      for k in cal:
        for l in cal:
          for m in cal:
            ans += eval(s[0]+i+s[1]+j+s[2]+k+s[3]+l+s[4]+m+s[5])
  print(ans)
elif len(s) == 7:
  for i in cal:
    for j in cal:
      for k in cal:
        for l in cal:
          for m in cal:
            for n in cal:
              ans += eval(s[0]+i+s[1]+j+s[2]+k+s[3]+l+s[4]+m+s[5]+n+s[6])
  print(ans)
elif len(s) == 8:
  for i in cal:
    for j in cal:
      for k in cal:
        for l in cal:
          for m in cal:
            for n in cal:
              for o in cal:
                ans += eval(s[0]+i+s[1]+j+s[2]+k+s[3]+l+s[4]+m+s[5]+n+s[6]+o+s[7])
  print(ans)
elif len(s) == 9:
  for i in cal:
    for j in cal:
      for k in cal:
        for l in cal:
          for m in cal:
            for n in cal:
              for o in cal:
                for p in cal:
                  ans += eval(s[0]+i+s[1]+j+s[2]+k+s[3]+l+s[4]+m+s[5]+n+s[6]+o+s[7])
  print(ans)
elif len(s) == 10:
  for i in cal:
    for j in cal:
      for k in cal:
        for l in cal:
          for m in cal:
            for n in cal:
              for o in cal:
                for p in cal:
                  for q in cal:
                    ans += eval(s[0]+i+s[1]+j+s[2]+k+s[3]+l+s[4]+m+s[5]+n+s[6]+o+s[7]+p+s[8]+q+s[9])
  print(ans)

Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

ll p(ll n) {
	if (n == 0) { return 1; }
	else { return 10 * p(n - 1); }
}

long double s(ll n) {
	ll k = 0;

	for (ll m = n; m > 0; m /= 10) {
		k += m % 10;
	}

	return (long double)n / (long double)k;
}

int main() {

	ll N, D;
	cin >> N >> D;

	vector<vector<ll>> X(N + 1, vector<ll>(D + 1));

	repn(i, N) repn(j, D) cin >> X[i][j];

	ll ans = 0;

	repn(i, N) {
		for (int j = i+1; j <= N; j++) {
			ll dis = 0;
			repn(k, D) {
				dis += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
			}

			//cout << dis << endl;

			for (int k = 0; k*k <= dis; k++) {
				if (k*k == dis) { ans++; }
			}
		}
	}

	cout << ans;
	

	system("PAUSE");

	

}


Measured memory_bytes: 504
lista = []
lista.append(int(input()))
lista.append(int(input()))
lista.append(int(input()))
lista.append(int(input()))
lista.append(int(input()))

sum = 0
sorted_list = []
for l in lista:
    diff = 10-int(str(l)[len(str(l))-1])
    if diff == 10:
        diff = 0
    sorted_list.append((diff, l))
sorted_list.sort()
pos = 0
for s in sorted_list:
    if pos < len(sorted_list)-1:
        sum+=(s[0]+s[1])
    else:
        sum+=s[1]
    pos+=1
print(sum)

Measured memory_bytes: 3064