akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque
//stack…FILO
//queue…FIFO
//priority_queue…格納された最大値から順に取り出す
//pair…二つの値を一組
//tuple…複数の値を一組

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}

template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}

template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

ll ans = 0;
/*
int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}
*/
int main() {
    int n, x;
    cin >> n >> x;
    vector<int> L(n);
    rep(i, 0, L.size()-1) cin >> L[i];
    int ans = 0, sum = 0;
    rep(i, 0, L.size()-1) {
        sum += L[i];
        if (sum <= x)
            ans++;
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 256
import bisect
s=int(input())
a=[]
ans=1
x=s
def coll(x):
  if x%2==0:
    return x//2
  else:
    return x*3+1

while x not in a:
  bisect.insort_left(a,x)
  ans+=1
  x=coll(x)

print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    string s, t;
    cin >> s >> t;

    li ans = t.size();
    for (int fr = 0; fr < s.size() - t.size() + 1; ++fr) {
        li cnt = 0;
        for (int i = 0; i < t.size(); ++i) {
            if (t[i] != s[fr + i]) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  int a[9][10] = {0}, ans = 0;
  for (int i=1; i<=n; i++) {
    int b = i;
    while (b%10 != b) b /= 10;
    a[b-1][i%10]++;
  }
  for (int i=0; i<9; i++) {
    for (int j=0; j<9; j++) {
      ans += a[i][j+1] * a[j][i+1];
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ng = []
po = []

if sum(A) < sum(B): print(-1)
else:
    ans = 0
    for i in range(N):
        d = A[i] - B[i]
        if d < 0:
            ans += 1
            ng.append(d)
        elif d > 0: po.append(d)
    ng.sort()
    po.sort()
    s = sum(ng)
    while po and s < 0:
        s += po.pop()
        ans += 1
    if s < 0: print(-1)
    else: print(ans)

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

int main(){
  int H,W;
  cin >>H>>W;
  
  char a[H][W];
  rep(i,0,H) rep(j,0,W) cin >>a[i][j];
  
  char ans[H+2][W+2];
  rep(i,0,H+2) rep(j,0,W+2) ans[i][j] = '#';
  rep(i,0,H) rep(j,0,W) ans[i+1][j+1] = a[i][j]; 
  rep(i,0,H+2){
    rep(j,0,W+2) cout <<ans[i][j];
    cout <<endl;
  } 
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define pr(x) cout<<#x<<" "<<x;
#define pl(x) cout<<#x<<" "<<x<<endl;
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
bitset <10000> a[10];
int str[10];
void change(int x){
    memset(str,0,sizeof(str));
    for(int i = 0;x>0;i++){
        str[i] = x%2;//pl(str[i]);
        x = x/2;
    }


}
int main(){
    int r,c;


    while(cin>>r>>c&&r!=0){
            int ans =0;
        for(int i = 0;i<r;i++){
            for(int j = 0;j<c;j++){
                bool b;
                cin>>b;
                a[i][j] = b;
            }
        }

        for(int i = 0;i<pow(2,r);i++){
        int anss=0;
        change(i);
        for(int j = 0;j<r;j++){
            if(str[j]==1){a[j].flip();}
        }
        for(int k = 0;k<c;k++){
                int ccount =0;
            for(int i =0;i<r;i++){
                if(a[i][k]==1){ccount++;}
            }
            //pl(ccount);
            anss +=max(ccount,r-ccount);
        }
        ans = max(ans,anss);

        for(int j = 0;j<r;j++){
            if(str[j]==1){a[j].flip();}
        }

    }

    cout<<ans<<endl;



    }

}

Measured memory_bytes: 3300
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	ll ma, mb;
	if(n%2 == 1){
		ma = a[n/2];
		mb = b[n/2];
	}
	else{
		ma = a[(n-1)/2] + a[n/2];
		mb = b[(n-1)/2] + b[n/2];
	}
	ll ans = mb - ma + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N, K;
    while (cin >> N >> K) {
    vector<vector<int>> dp(K*6+1, vector<int>(K*6+1, 0));
    for (int i = 0; i < N; ++i) {
        int x, y; char c;
        cin >> x >> y >> c;
        int qx = x / K, qy = y / K;
        if ((qx+qy) % 2 == 0) x = x%K, y = y%K;
        else x = x%K, y = y%K + K;
        if (c == 'W') x += K;
        for (int d = 0; d < 4; ++d) {
            for (int e = 0; e < 4; ++e) {
                if ((d+e) % 2 != 0) continue;
                dp[x + d*K][y + e*K]++;
                dp[x + (d+1)*K][y + e*K]--;
                dp[x + d*K][y + (e+1)*K]--;
                dp[x + (d+1)*K][y + (e+1)*K]++;
            }
        }
        //cout << make_pair(x, y) << endl;
    }
    for (int i = 0; i < K*6; ++i) for (int j = 0; j <= K*6; ++j)
        dp[i+1][j] += dp[i][j];
    for (int i = 0; i <= K*6; ++i) for (int j = 0; j < K*6; ++j)
        dp[i][j+1] += dp[i][j];
    int res = 0;
    for (int i = 0; i <= K*6; ++i) for (int j = 0; j <= K*6; ++j)
        chmax(res, dp[i][j]);
    cout << res << endl;
    }
}

Measured memory_bytes: 141184
#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;
typedef vector<vector<int> > Graph;

int main() {
    int a,b;
    cin >> a >> b;
    if (a+b==3) cout << 3 << endl;
    else if (a+b==4) cout << 2 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
    while(1){
        int b,r,g,c,s,t;
        cin >> b >> r >> g >> c >> s >> t;
        if(b == 0 && r == 0 && g == 0 && c == 0 && c == 0 && s == 0 && t == 0) break;
        int ans = 100;
        ans += b * 13 * 5 + r * 13 * 3;
        ans += b * 15 + r * 15;
        t -= b * 5 + r * 3;
        t -= s;
        ans += g * 7 + c * 2;
        ans -= t * 3;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import numpy as np

dp = np.zeros((105,4,2),dtype=np.int32)

s = input()
n = len(s)
K = int(input())

dp[0][0][0] = 1
for i in range(n):
    for j in range(4):
        for k in range(2):
            nd = int(s[i])
            for d in range(10):
                ni = i + 1
                nj = j 
                nk = k
                if d != 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]
ans = dp[n][K][0] + dp[n][K][1]
print(ans)

Measured memory_bytes: 13308
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
string s;
char a[100010];
char Other(char c){
    return (c=='S')?'W':'S';
}
bool Able(){
    for(ll i=1;i<N-1;i++){
        ll l=i-1;
        ll r=(i+1);
        if(a[i]=='S' ^ s[i]=='o'){
            a[i+1]=Other(a[i-1]);
        }else{
            a[i+1]=a[i-1];
        }
    }
    bool f1=(a[0]=='S'^s[0]=='o')^(a[1]==a[N-1]);
    bool f2=(a[N-1]=='S'^s[N-1]=='o')^(a[0]==a[N-2]);
    return f1 && f2;
}
int main(){
    cin>>N>>s;
    for(ll i=0;i<4;i++){
        a[0]=(i/2==0)?'S':'W';
        a[1]=(i%2==0)?'S':'W';
        if(Able()){
            for(ll i=0;i<N;i++) cout<<a[i];
            return 0;
        } 
    }
    cout<<-1;
    return 0;
}

Measured memory_bytes: 640
ans=0
s=[int(i) for i in input()[::-1]]+[0]
i=0
while i<len(s):
    t=s[i]
    if t<=4:
        ans+=t
        i+=1
    elif t==5:
        if s[i+1]>=5:
            ans+=6
            i+=1
            t=s[i]
            while t>=4:
                if t==4:
                    if s[i+1]<5:
                        ans+=4
                        i+=1
                        break
                ans+=9-t
                i+=1
                t=s[i]
        else:
            ans+=5
            i+=1
    elif t>5:
        ans+=11-t
        i+=1
        t=s[i]
        while t>=4:
            if t==4:
                if s[i+1]<5:
                        ans+=4
                        i+=1
                        break
            ans+=9-t
            i+=1
            t=s[i]
print(ans)

Measured memory_bytes: 118756
# -*- coding: utf-8 -*-
S = input()

import collections
c_indices_dict = collections.defaultdict(list)
for i, c in enumerate(S):
    c_indices_dict[c].append(i)

len_S = len(S)
ret = float('inf')
for indices in c_indices_dict.values():
    v = max(indices[0], len_S - indices[-1] - 1)
    # print(indices)
    for i in range(len(indices)-1):
        v = max(v, indices[i+1] - indices[i] - 1)
        # print(indices[i+1], indices[i])
    ret = min(ret, v)
print(ret)

Measured memory_bytes: 38384
/*
  Contest 095
  A - Something on It
  Rakesh Kumar --> 23/09/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    std::string s;
    std::getline(std::cin, s);
    int total = 700;
    for (char c : s)
        if (c == 'o')
            total += 100;
    std::cout << total << std::endl;

    return 0;
}


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



Measured memory_bytes: 2104
#!/usr/bin/env python3
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = min(A) + min(B)
for i in range(m):
    x, y, c = map(int, input().split())
    ans = min(ans, A[x-1]+B[y-1]-c)
print(ans)


Measured memory_bytes: 18736
n = int(input())
a = list(map(int, input().split()))
a.sort()
if not n % 3 == 0:
    if a[n - 1] == 0:
        print("Yes")
    else:
        print("No")
else:
    x, y, z = a.count(a[0]), a.count(a[n // 3]), a.count(a[2 * (n // 3)])
    if x == y == z == n // 3:
        if a[0] ^ a[n // 3] ^ a[2 * (n // 3)] == 0:
            print("Yes")
        else:
            print("No")
    elif a[0] == 0 and x == n // 3 and y == z == 2 * (n // 3):
        print("Yes")
    elif a[n - 1] == 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14212
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(void){
    // Here your code !
    int n;
    cin >> n;
    string a;
    bool run[3]={false, false, false};
    int out=0, e=0;
    int point[50] = {};
    int j=0;
    int k=0;
    while(cin >> a) {
        if(a=="HIT") {
            if(run[2]) {
                point[e]++;
                run[2] = false;
            }
            if(run[1]) {
                run[2] = true;
                run[1] = false;
            }
            if(run[0]) {
                run[1] = true;
                run[0] = false;
            }
            run[0] = true;
        } else if(a=="OUT") {
            out++;
            if(out==3) {
                out = 0;
                run[0] = false;
                run[1] = false;
                run[2] = false;
                e++;
            }
        } else {
            k=0;
            if(run[0]) k++;
            if(run[1]) k++;
            if(run[2]) k++;
            run[0] = false;
            run[1] = false;
            run[2] = false;
            REP(i,k) {
                point[e]++;
            }
            point[e]++;
        }
        j++;
    }
    REP(i,n) {
        cout << point[i] << endl;
    }

}

Measured memory_bytes: 3140
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e4+2;
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n,d,a;
	cin>>n>>d>>a;
	vector<int> v;
	map<int,int> ma1;
	map<int,int> ma2;
	for(int i=0;i<n;i++)
	{
		int x,h;
		cin>>x>>h;
		v.pb(x);
		ma1[x]+=h;
	} 
	// cout<<"*";
	// return 0;
	sort(all(v));
	int s=0;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int x=v[i];
		ma1[x]-=s;
		if(ma1[x]<0) ma1[x]=0;
		int y=x+2*d;
		// cout<<x<<" "<<y<<"\n";
		int f=upper_bound(all(v),y)-v.begin()-1;
		// cout<<f<<"\n";
		if(f==-1)
		{
			// assert(false);
		}
		int xx=v[f];
		// cout<<xx<<"\n";
		int left=ma1[x];
		left=(left+a-1)/a;
		ans+=left;
		ma2[xx]+=left*a;
		// cout<<left<<" ";
		s+=left*a;
		ma1[x]-=left*a;
		s-=ma2[x];
	}
	// cout<<"*";
	cout<<ans;
}	
// I never lose. I either win or I learn

Measured memory_bytes: 26864
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setpercision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
template<class T> inline bool chmin(T& a, T b){
    if(a>b){a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){
    if(a<b){a=b;return true;}return false;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll info[3];
    rep(i,3)cin>>info[i];
    sort(info,info+3);
    rep(i,3){if(i)cout<<" ";cout<<info[i];}cout<<endl;
    return 0;
}


Measured memory_bytes: 3148
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] b = new int[N];
    for (int i = 0; i < N; i++) b[i] = scanner.nextInt();

    int[] op = new int[N];
    for (int i = N - 1; i >= 0; i--) {
      boolean found = false;
      int cnt = i + 1;
      for (int j = N - 1; j >= 0; j--) {
        if (b[j] == cnt) {
          op[i] = cnt;
          b[j] = -1;
          found = true;
          break;
        }
        if (b[j] >= 0) cnt--;
      }
      if (!found) {
        System.out.println(-1);
        return;
      }
    }
    for (int p : op) System.out.println(p);
  }
}


Measured memory_bytes: 22608
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;
int main(void) {
    long n, a, b, add, count, res, result;

    cin >> n >> a >> b;
    
    add = a + b;

    if (a == 0 && b == 0){
        cout << "0" << endl;
        return 0;
    }

    count = n / add;
    res = n - count * add;
    result = (res < a) ? count * a + res : (count + 1) * a;

    cout << result << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
const int MAXN = 100001;

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/


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

//-----Template---------
int n,maxA;
int a[101];
int aCount[101];
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
        aCount[a[i]]++;
        chmax(maxA,a[i]);
    }
    bool flag=true;
    for (int i = (int)ceil((double)maxA/2); i <=maxA ; ++i) {
        if(maxA%2==0 && i==maxA/2){
            aCount[i]--;
        }else{
            aCount[i]-=2;
        }
        if(aCount[i]<0){
            flag=false;
            break;
        }
    }
    for (int i = 0; i <=(int)ceil((double)maxA/2); ++i) {
        if(aCount[i]>0){
            flag=false; break;
        }
    }
    cout<<(flag? "Possible":"Impossible");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
using int64 = long long;

int main() {
    int64 x;
    cin >> x;
    int64 ans = 0;
    int64 yen = 100;
    while (yen < x) {
        yen *= 1.01;
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3188
#include <stdio.h>

int main()
{
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if (A + B + C == 17 && A * B + B * C + C * A == 95 && A * B * C == 175) printf("YES\n");
	else printf("NO\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5;
int a[maxn];
int n;
int P=1e9+7;
long long dp[300][maxn];
long long dfs(int i,int now){
    if(now==0)return 0;
    if(i<1){
        return now;
    }
    if(dp[i][now])return dp[i][now];
    if(now>=a[i])dp[i][now]=(dfs(i-1,now%a[i])+dfs(i-1,now)*(i-1)%P)%P;
    else  dp[i][now]=(dfs(i-1,now)*i)%P;
    return dp[i][now];
}
int main()
{
    int x;
    cin>>n>>x;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    cout<<dfs(n,x);
    /*for(int i=0;i<n;i++){
        cout<<dp[i][x]<<endl;
    }*/
}


Measured memory_bytes: 469248
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: [[i64; n]; n]
    }
    let mut tab: Vec<i64> = vec![0; 1 << n];
    for j in 1..n {
        let b = 1 << j;
        for i in 0..1 << j {
            tab[i | b] = tab[i];
            for k in 0..j {
                if 1 << k & i > 0 {
                    tab[i | b] += a[k][j];
                }
            }
        }
    }
    for i in 0..1 << n {
        let mut j: i64 = 0;
        loop {
            j = (j - i as i64) & i as i64;
            tab[i] = std::cmp::max(tab[i], tab[j as usize] + tab[i ^ j as usize]);
            if j as usize == i {
                break;
            }
        }
    }
    println!("{}", tab[(1 << n) - 1]);
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

/* I'm too stupid to solve this problem */

using namespace std;
#define PI 3.14159265359
#define eps 1e-7
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
const int INF = 1<<29;
typedef unsigned long long ull;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n,t;
vector<pair<int,int>> A;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
    cout.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);	
    
    cin >> n >> t;
    int res=INT_MAX,m=0;

    FOR(i,0,n){
        int a,b;
        cin >> a >> b;

        if(b<=t){
            m=max(m,b);
            res=min(res,a);
        }
    }

    if(res==INT_MAX)
        cout << "TLE\n";
    else
        cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<string> ans(h, string(w, '1'));
    for(int i = 0; i < b; i++){
        for(int j = 0; j < w; j++){
            ans[i][j] = '0';
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < a; j++){
            ans[i][j] = ans[i][j] == '1' ? '0' : '1';
        }
    }
    for(int i = 0; i < h; i++){
        cout << ans[i] << '\n';
    }
}


Measured memory_bytes: 2304
k, n = map(int, input().split())
met = list(map(int, input().split()))
d = []
     
for i in range(n-1):
  d.append(met[i+1] - met[i])
d.append((k - met[n-1]) + met[0])
     
d.remove(max(d))
d = sum(d)
print(d)


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

#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    if (n < 2 * k - 1) {
        cout << -1;
        return 0;
    }
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        c[i] = k + 2 * n + i;
    }
    int n1 = (n + 1) / 2;
    int n2 = n - n1;
    for (int i = 0; i < n1; i++) {
        a[i] = k + 2 * i;
        b[i] = k + 2 * n - n2 - i -1 ;
    }
    for (int i = 0; i < n2; i++) {
        a[n1 + i] = k + 2 * i + 1;
        b[n1 + i] = k + 2 * n - i - 1;
    }
    for (int i = 0; i < n; i++) {
        cout << a[i] << " " << b[i] << " " << c[i] << "\n";
    }

    return 0;
}


// 2 3 4  5 6 7  8 9 10
// 8 2 6
// 9 4 5
// 10 3 7

// k = 3, n = 5
// 3 .. 17

// 13 3 10    4 6 11 12
// 14 5 9
// 15 7 8
// 16 4 12
// 17 6 11

Measured memory_bytes: 3456
#include <stdio.h>
#include <string.h>

int get_sum(int num, int sum, int *num_flag){
	int combi = 0;
	int i, j;
	
	if (num == 1){
		if (0 <= sum && sum <= 9){
			for (j = i; j <= 9; j++){
					if (num_flag[j] == 1){
						if (j >= sum) return (0);
					}
			}
			return (1);
		}
		else return (0);
	}
	
	for (i = 0; i <= 9; i++){
		if (num_flag[i] == 0){
			for (j = i; j <= 9; j++){
				if (num_flag[j] == 1){
					if (j >= i) goto next;
				}
			}
			num_flag[i] = 1;
			combi += get_sum(num - 1, sum - i, num_flag);
		}
		for (j = 0; j < 10; j++){
			num_flag[j] = 0;
		}
		next:;
	}
	return (combi);
}

int main(void)
{
	int sum, num, combi, num_flag[10];
	
	while (1){
		scanf("%d%d", &num, &sum);
		
		if (num == 0 && sum == 0) break;
		
		memset(num_flag, 0, sizeof(num_flag));
		combi = get_sum(num, sum, num_flag);
		
		printf("%d\n", combi);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

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

string solve(int n) {
  if (n == 0) return "";
  int k = n % 8;
  return solve(n / 8) + "01235789"[k];
}

int main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) break;
    cout << solve(n) << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
int main(void)
{
	int a[100], i, n, j;
	scanf("%d", &n);
	for(i=0;i<n;++i) {
	scanf("%d", &a[i]);
	}
	for(j=n-1;j>0;--j) {
	printf("%d ", a[j]);
	}
	printf("%d", a[0]);
	printf("\n");
	return 0;
}



Measured memory_bytes: 2104
N, A, B = map(int, input().split())
set_ = N // (A+B)
mod = N % (A+B)
b_sum = A * set_
if mod == 0:
  print(b_sum)
elif mod >= A:
  b_sum += A
  print(b_sum)
else:
  b_sum += mod
  print(b_sum)

Measured memory_bytes: 3188
n = int(input());
l=list(map(int,input().strip().split()))
l.sort()
if l[0] == 0 : 
    print("0")
else :    
    ans = l[0]
    c=0
    for i in range(1, n) :
        if l[i]*ans >  int(1000000000000000000) :
            print("-1")
            c=1
        if c == 1 : 
            break 
        ans = ans*l[i]    
    if c == 0 : 
        print(ans)       

Measured memory_bytes: 84676
str = gets
str.chomp!
str.reverse!
a = 0
while a < str.size
  result = true
  s = 0
  if a+5 <= str.size
  if str[a,5] == "maerd"||str[a,5] == "esare"
    result = nil
    s = 5
  end
  end
  if a+6 <= str.size
    if str[a,6] == "resare"
      result = nil
      s = 6
    end
  end
  if a+7 <= str.size
    if str[a,7] == "remaerd"
      result = nil
      s = 7
    end
  end
  a += s
  if result
    puts "NO"
    exit
  end
end
puts"YES"

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+10;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m; cin >> n >> m;
    if (n&1) {
        int l = 1;
        while (m--) {
            cout << l << " " << (n+1)-l << endl;
            l++;
        }
    } else {
        int len = 0;
        vint lens;
        while (m--) {
            len = n - len;
            if (len < n/2) len++;
            else len--;
            lens.push_back(len);
        }
        sort(rall(lens));
        int l = 1;
        rep(i,lens.size()) {
            cout << l << " " << l + lens[i] << endl;
            l++;
        }
    }
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, s, mx;
    cin >> n >> s;

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

    vector<long long> accumulate(s + 1, 0);
    long long ans = 0, mod = 998244353;
    for (int i = 0; i < n; i++){
        vector<long long> cur(s + 1, 0);
        
        if (a[i] <= s)
            cur[a[i]] = i + 1;

        for (int j = a[i] + 1; j <= s; j++){
            cur[j] = accumulate[j - a[i]];
        }

        for (int j = 0; j <= s; j++)
            accumulate[j] = (accumulate[j] + cur[j]) % mod;
        
        ans = (ans + (n - i) * cur[s]) % mod;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;
const ll MOD = 1000000;
const int MAX_N = 2010;

ll comb[MAX_N + 5][MAX_N + 5], dp[MAX_N + 5], cnt[MAX_N + 5];
vector<int> G[MAX_N + 5];

ll nCr(int n, int r) {
    if(r < 0 or n < r) return 0;
    return comb[n][r];
}

ll nHr(int n, int r) {
    if(n == 0 and r == 0) return 1;
    return nCr(n+r-1, r);
}

void dfs(int cur, int par=-1) {
    dp[cur] = 1;
    cnt[cur] = 1;
    for(auto to : G[cur]) {
        if(to == par) continue;
        dfs(to, cur);
        // fprintf(stderr, "%d H %d = %lld, dp[to] = %lld\n", cnt[cur], cnt[to], 
        (dp[cur] *= nHr(cnt[cur], cnt[to]) * dp[to] % MOD) %= MOD;
        cnt[cur] += cnt[to];
    }
}

int main() {
    for(int i=0; i<MAX_N; i++) {
        comb[i][0] = 1;
        for(int j=1; j<=i; j++) {
            comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD;
        }
    }

    int N; cin >> N;
    vector<int> deg(N);
    for(int i=0; i<N-1; i++) {
        int u, v; cin >> u >> v; u--; v--;
        G[u].emplace_back(v);
        deg[v]++;
    }

    int root = min_element(deg.begin(), deg.end()) - deg.begin();
    dfs(root, -1);
    cout << dp[root] << endl;
    return 0;
}



Measured memory_bytes: 25920
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N;
	cin>>N;
	
	map<string,int> mp;
	for(int i=0;i<N;i++){
		string s;
		cin>>s;
		mp[s]++;
	}
	
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
		
	return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int i;
    int n;
    int target;
    long long unsigned int num[21];
    long long unsigned int tmp[21];
    vector<int> l;

    scanf("%d", &n);
    for (i=0;i<21;i++) {
        num[i] = 0;
        tmp[i] = 0;
    }
    num[0] = 1;
    l.push_back(0);

    for (i=0;i<n-1;i++) {
        int j;
        int d;
        scanf("%d", &d);


        vector<int>::iterator it = l.begin();
        while (it != l.end()) {
            if ((*it) + d >= 0 && (*it) + d < 21) {
                tmp[(*it)+d] += num[*it];
            }

            if (i == 0 && d == 0) break;

            if ((*it) - d >= 0 && (*it) - d < 21) {
                tmp[(*it)-d] += num[*it];
            }
            it++;
        }

        l.clear();

        for (j=0;j<21;j++) {
            if (tmp[j]) l.push_back(j);
            num[j] = tmp[j];
            tmp[j] = 0;
        }
    }

    scanf("%d", &target);
    printf("%llu\n", num[target]);
}

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

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

using namespace std;
typedef long long ll;

int main() {
  ll n, x, cnt = 0;
  vector<ll> a(n);
  cin >> n >> x;

  rep(i, n) cin >> a[i];

  rep(i, n - 1) {
    if (a[i] + a[i + 1] > x) {
      int d = (a[i] + a[i + 1] - x);
      a[i + 1] -= d;
      if (a[i + 1] < 0) {
        a[i] += a[i + 1];
        a[i + 1] = 0;
      }
      cnt += d;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	int four_cnt = 0, two_cnt = 0, odd_cnt = 0;
	int n;
	cin >> n;
	rep(i, n)
	{
		int a;
		cin >> a;
		if (a % 4 == 0)
			four_cnt++;
		else if (a % 2 == 0)
			two_cnt++;
		else
			odd_cnt++;
	}
	bool	flag;
	flag = false;
	if (odd_cnt == 0)
		flag = true;
	else if (!two_cnt)
	{
		if (odd_cnt <= four_cnt + 1)
			flag = true;
	}
	else
	{
		if (odd_cnt <= four_cnt)
			flag = true;
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
// END

int		main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int people = scan.nextInt();
		int height = scan.nextInt();
		int i;
		int count = 0;
			
		for(i = 0 ; i < people ; i++) {
			String jet_height = scan.next();
			int jet_height_num = (int) Integer.parseInt(jet_height);
	
			if(jet_height_num >= height) {
				count++;
			}
		}
		scan.close();
		System.out.println(count);
	}
}


Measured memory_bytes: 44800
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) { cin >> A[i]; }
    //色の人数は三色共に１ずつしかふえない
    vector<ll> res(N, 0LL);
    res[0] = 3;
    vector<ll> num(3, 0LL);
    num[0] = 1;
    if(A[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1; i < N; i++) {
        bool flag = false;
        if(A[i] == num[0]) {
            res[i] += res[i - 1];
            res[i] %= MOD;
            num[0]++;
            flag = true;
        }
        if(A[i] == num[1]) {
            res[i] += res[i - 1];
            res[i] %= MOD;
            if(!flag) {
                num[1]++;
                flag = true;
            }
        }
        if(A[i] == num[2]) {
            res[i] += res[i - 1];
            res[i] %= MOD;
            if(!flag) {
                num[2]++;
                flag = true;
            }
        }
        if(!flag) {
            cout << 0 << endl;
            return 0;
        }
    }
    res[N - 1] %= MOD;
    cout << res[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    //--<for debugging>
    #define whatis(x) cout << #x << " is " << x<<" ";
    #define whatisl(x) cout << #x << " is " << x<<"\n";
    #define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
    #define lline cout<<"\n";
    #define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
    #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
        
    void err(istream_iterator<string> it) {}
    template<typename T, typename... Args>
    void err(istream_iterator<string> it, T a, Args... args) {
        cout << *it << " = " << a <<" , ";
        err(++it, args...);
    }
    //--</for debugging> 
    #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
    #define testcase ll tt; cin >> tt; while(tt--)
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define pb push_back 
    #define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;string str;
    #define vll vector<ll>
    #define pll pair<ll,ll>
    #define sll set<ll>
    #define pint pair<int,int>
    const ll INF=1e9+7;
    const ll MOD=1e9+7;
    const string yes="YES\n";
    const string no="NO\n";
    int main()
    {
        boost vars
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        cin>>a>>b>>c;
        v=a/b;
        if(a%b)v++;
        cout<<v*c;
    }

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <set>
#include <unordered_map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
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

unordered_map<int, int> mp;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[200010];
    rep(i, N) {
        cin >> A[i];
        mp[A[i]]++;
    }
    int num = (1 << 30);
    int ans = 0;
    rep(k, 31) {
        rep(i, N) {
            int remain = num - A[i];
            if(remain <= 0) continue;
            if(remain != A[i] && mp[remain] > 0 && mp[A[i]] > 0) {
                ans++;
                mp[remain]--;
                mp[A[i]]--;
                //cout << remain << " " << A[i] << endl;
            } else if(remain == A[i] && mp[A[i]] > 1) {
                ans++;
                mp[A[i]] -= 2;
                //cout << remain << " " << A[i] << " " << mp[A[i]] << endl;
            }
        }
        num >>= 1;
        //cout << num << endl;

    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 33932
#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
N,M = map(int,input().split())
AB = [[int(_) for _ in input().split()] for i in range(N)]
AB.sort(key = lambda x:x[0])
cost = 0
got = 0
index = 0
s = 0
while got < M:
    got += AB[index][1]
    index += 1
g = got - AB[index-1][1]

plus = M - g

for i in range(index-1):
    cost += AB[i][0] * AB[i][1]
    

cost += plus * AB[index-1][0]    
    
print(cost)

Measured memory_bytes: 22760
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  set<int> bads;
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    if (h[a - 1] == h[b - 1]) {
      bads.insert(a); bads.insert(b);
    } else if (h[a - 1] < h[b - 1])bads.insert(a);
    else bads.insert(b);
  }
  cout << n - bads.size() << endl;
  return 0;
}

Measured memory_bytes: 6692
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(mut v: Vec<u32>) -> u32 {
    v.sort();

    let diffab = v[1] - v[0];
    if diffab % 2 == 1 {
        1 + (diffab + 1) / 2 + v[2] - v[1]
    } else {
        diffab / 2 + v[2] - v[1]
    }
}

fn main() {
    let v = parse_vec!(u32);
    println!("{}", solve(v));
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![2,5,4]), 2);
    assert_eq!(solve(vec![31,41,5]), 23);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
//typedef __int128_t Int;
#define DBG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define loop(n) rep(loop,(0),(n))
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);

  int N; cin >> N;
  vector<int> v(N); rep(i, 0, N){ cin >> v[i];v[i]-=i+1; }
  sort(all(v));
  int mid;
  if(N&1){
    mid=v[N/2];
  }
  else{
    mid = (v[N/2-1]+v[N/2])/2;
  }
  int ans=0;
  rep(i,0,N){
    ans+=abs(v[i]-mid);
  }

  cout<<ans<<endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

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

    if (s == "AKIHABARA" || s == "KIHABARA" || s == "AKIHBARA" || s == "AKIHABRA" || s == "AKIHABAR" ||
        s == "KIHBARA" || s == "KIHABRA" || s == "KIHABAR" || s == "AKIHBRA" || s == "AKIHBAR" || s == "AKIHABR" ||
        s == "KIHBRA" || s == "KIHBAR" || s == "KIHABR" || s == "AKIHBR" || s == "KIHBR") {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

vector< int > z_algorithm(vector<ll> &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}

void solve(){
    ll n;cin>>n;
    vec a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];

    vec c(3*n);
    rep(i,n){
        c[i]=a[i]^a[(i+1)%n];
        c[i+n]=c[i+2*n]=b[i]^b[(i+1)%n];
    }
    vector<int> d=z_algorithm(c);
    vector<pair<ll,ll>> ans;
    rep(i,n,2*n){
        if(d[i]>=n){
            ll k=(2*n-i)%n;
            ll x=a[0]^b[i-n];
            ans.push_back(make_pair(k,x));
        }
    }
    sort(all(ans));
    rep(i,ans.size()){
        cout<<ans[i].first<<' '<<ans[i].second<<endl;
    }
}

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


Measured memory_bytes: 16876