akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	LL N;
	cin >> N;
	
	string S1, S2;
	cin >> S1 >> S2;

	LL sum = 1;

	for (LL i = 0; i < N;) {
		if (S1[i] == S2[i]) {

			if (i == 0) {
				sum *= 3;
			}
			else {
				if (S1[i - 1] == S2[i - 1]) {
					sum *= 2;
				}
				else {
					sum *= 1;
				}
			}

			i += 1;
		}
		else {

			if (i == 0) {
				sum *= 6;
			}
			else {
				if (S1[i - 1] == S2[i - 1]) {
					sum *= 2;
				}
				else {
					sum *= 3;
				}

			}

			i += 2;
		}
		sum = sum%mod;
	}

	cout << sum%mod << endl;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll a, b, c;
ll ans;
int main() {
	cin >> a >> b;
	if(a >= b){
		ans += a;
		a--;
	}else{
		ans += b;
		b--;
	}
	if(a >= b){
		ans += a;
		a--;
	}else{
		ans += b;
		b--;
	}
	p(ans);
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int h[n+1];
  for (int i=0;i<n;i++){
    cin >> h[i];
  }
  h[n]=0;
  int count=0;
  int a[110],b[110];
  a[0]=h[0];
  b[0]=0;
  for(int i=1;i<n;i++){
    if(h[i]<h[i-1]){
      b[i]=h[i];
    }
    else {
      b[i]=0;
    }
    if(h[i]>h[i+1]){
      a[i]=h[i];
    }
    else {
      a[i]=0;
    }
  }
  for(int i=0;i<n;i++){
    count=count+a[i]-b[i];
  }
  if(h[0]<=h[1]){
    cout << count-h[0] << endl;
  }
  else{
    cout << count << endl;
  }
}

Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n;cin>>n;
	string s;cin>>s;
	ll ans=0;
	rep(i,0,n)
	{
		string r="";
		rep(j,0,3) if(i+j<n) r+=s[j+i];
		if(r=="ABC") ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const int MAX = 4;

static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

int main() {
	double n, m, d; cin >> n >> m >> d;
	double ans;
	if (d == 0) {
		ans = (1 / n)*(m - 1);
	}
	else {
		ans = 2 * (n - d) * (m - 1) / n / n;
	}

	printf("%.10f", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    ll n,ans = 0;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    //assert(n%2 == 0);
    if(n % 2 == 0) {
        ll dp[n];
        dp[0] = a[0];
        dp[1] = a[1];
        for(int i = 2;i<n;i++) {
            if(i % 2 == 0) {
                dp[i] = dp[i-2] + a[i];
            } else {
                dp[i] = max(dp[i-3],dp[i-2]) + a[i];
            }
        }
        ans = max(dp[n-1],dp[n-2]);
    } else {
        vector<ll> l(n/2),m(n/2),r(n/2);
        l[0] = a[0];
        m[0] = a[1];
        r[0] = a[2];
        for(int i = 1;i<n/2;i++) {
            l[i] = l[i-1] +a[2*i];
            m[i] = max(l[i-1],m[i-1]) + a[2*i+1] ;
            r[i] = max(l[i-1],max(m[i-1],r[i-1])) +a[i*2+2];
        }
        ans = max(l[n/2-1],max(m[n/2-1],r[n/2-1]));
    }
    cout << ans;
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int h, w;
int a[501][501];
bool use[501][501];
vector<int> ans[4];
map<P,P> keiro;

void makeRoad(P start, P goal){
	// cout << endl;
	// cout << start.first << " " << start.second << endl;
	// cout << goal.first << " " << goal.second << endl;
	use[start.first][start.second]++;
	use[goal.first][goal.second]++;
	keiro[start] = P(-1,-1);
	while(keiro[goal] != P(-1,-1)){
		// cout << goal.first << " " <<goal.second << " " << keiro[goal].first << " " << keiro[goal].second << endl;
		ans[0].pb(goal.first);
		ans[1].pb(goal.second);
		ans[2].pb(keiro[goal].first);
		ans[3].pb(keiro[goal].second);
		use[goal.first][goal.second]++;
		goal = keiro[goal];
	}
	return;
}

int main(){
	cin >> h >> w;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> a[i][j];
		}
	}

	P start(-1,-1), finish;
	for(int i = 1; i <= h; i++){
		int sum = i%2?1:-1;
		for(int j = i%2?1:w; j != 0 && j != w+1; j+=sum){
			// cout << i << " " << j << endl;
			if((i%2 && j==1) || (i%2==0 && j == w)) keiro[P(i,j)] = P(i-1,j);
			else keiro[P(i,j)] = P(i,j-sum);

			if(a[i][j]%2){
				// cout << i << " " << j << endl;
				if(start == P(-1,-1)) start = P(i,j);
				else{
					finish = P(i,j);
					makeRoad(start, finish);
					start = P(-1,-1);
				}
			}
		}
	}


	cout << ans[0].size() << endl;
	for(int i = 0; i < ans[0].size(); i++){
		cout << ans[0][i] << " " << ans[1][i] << " " << ans[2][i] << " " << ans[3][i] << endl;
	}

	return 0;
}

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

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

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

    // start
    int n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
    // end

    return 0;
}


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


public class Main{
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------
        long MOD = 1000000007;
        //int t = sc.nextInt();
        int t = 1;
        Main sol = new Main();
        while(t -- > 0)
        {
            int n = sc.nextInt(), m = sc.nextInt();
            for(int i = 0; i < m; i++)
                n -= sc.nextInt();
            out.println(n < 0 ? -1 : n);
            //for(int ii = 0; ii <= n; ii++) System.out.println(Arrays.toString(dp[ii]));
        }
        out.close();
    }
    public String solve(String N){

        char [] c= N.toCharArray();
        int n = c.length;
        char [] c1 = new char[n], c2 = new char[n];
        for(int i = 0; i < n; i++)
        {
            c1[i] = (char)(c[i] - 1);
            if(c[i] == '4') {
                c2[i] = '1';
            }
            else c1[i]++;
        }
        boolean met = false;
        for(int i = 0; i < n; i++)
        {
            if(met) {
                if (c2[i] < '0')
                    c2[i] = '0';
            }
            else if(c2[i] > '0')
                met = true;
        }
        return new String(c1) + new String(c2).trim();
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 34112
no_of_lines = 2
lines = ""
for i in range(no_of_lines):
    lines+=input()+"\n"

lines = lines.splitlines()

N = int(lines[0])
S = lines[1]

c = 0
for i in range(N-2):
    if(S[i:i+3] == "ABC"):
        c+=1

print(c)


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

const ll N = 3*MAX5;
// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, l;
string s, t, d, c;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ld n,k;
	cin >> n >> k;
	ld ans = 0;
	for(ll i=1;i<=n;i++) {
		ld score = i;
		ld val = 1;
		ll cou = 0;
		while(score < k) cou++,score*=2;
		val /= (n);
		val /= pow(2,cou);
		ans += val;
	}
	cout<<ans;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 4152
# 24
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n, k = LI()
d = set(LI())
# 最小金額から条件を満たすまで増やしていく
while True:
    if all(int(j) not in d for j in str(n)):  # 全ての桁の数字が d に属さない
        print(n)
        exit()
    n += 1


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

typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<pii,pid> PP;

int n, a, d, m, k;
const int INF = 1 << 28;

int main() {
    cin >> n >> a >> d >> m;

    vector<int> x(m), y(m), z(m);
    for (int i = 0; i < m; i++) {
        int y_, z_;
        cin >> x[i] >> y_ >> z_;
        y[i] = min(y_, z_);
        z[i] = max(y_, z_);
    }

    cin >> k;

    vector<int> ckk(m+1);
    int ck = k;
    ckk[m] = ck;
    for (int i = m-1; i > -1; i--) {
        if (!x[i] && y[i] <= ck && ck <= z[i]) {
            ck = z[i] - (ck - y[i]);
        }
        ckk[i] = ck;

    }

    int aa = a + (ck - 1) * d;
    for (int i = 0; i < m; i++) {
        if (y[i] <= ckk[i] && ckk[i] <= z[i]) {
            if (x[i] == 1) aa++;
            if (x[i] == 2) aa /= 2;
        }
    }

    cout << aa << endl;

    return 0;
}

Measured memory_bytes: 5656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

double dp[3100][3100];

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

    ll N; cin >> N;
    vector<double> p(N);
    rep(i,N) cin >> p[i];

    dp[0][0] = 1;
    for(ll i = 1; i <= N; i++) {
        for(ll j = 0; j <= i; j++) {
            dp[i][j] += dp[i-1][j] * (1 - p[i-1]);
            if(j-1 >= 0) dp[i][j] += dp[i-1][j-1] * p[i-1];
        }
    }
    double ans = 0;
    rep(j, N+1) if(j > N-j) ans += dp[N][j];
    cout << ans << endl;
}


Measured memory_bytes: 72320
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n;
    if(n%2== 0)
    {
        cout << n << endl;
    }
    else
    {
        cout << (long long int) 2*n << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
ra = []
for i in range(n):
    x,l = map(int,input().split())
    ra.append([x-l,x+l])

ra.sort(key = lambda x:x[0])
ans = 1
t = ra[0][1]
for i in range(n):
    if ra[i][0] >= t:
        ans += 1
        t = ra[i][1]
    else:
        t = min(t,ra[i][1])

print(ans)

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    int MAX=101000;
    vector<int> Prime(MAX,1);
    Prime[1]=0,Prime[0]=0;
    //素数を求める。
    for(int i=2;i<MAX;i++){
        for(int j=i*2;j<MAX;j+=i){
            Prime[j]=0;
        }
    }
    vector<int> A(MAX,0);
    for(int i=3;i<MAX;i++){
        if(i%2==0)A[i]=A[i-1];
        if(Prime[i]&&Prime[(i+1)/2])A[i]=A[i-1]+1;
        else A[i]=A[i-1];
    }
    int Q;
    cin>>Q;
    rep(i,Q){
        int a,b;
        cin>>a>>b;
        cout<<A[b]-A[a-1]<<endl;
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  ll n,m;
  cin>>n>>m;
  VI a(n);
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  VI b(n+1);
  b[n]=0;
  for(i=n-1;i>=0;i--){
    b[i]=b[i+1]+a[i];
  }

  ll l=-1;
  ll r=202020;
  while(r-l>1){
    ll mid=(r+l)/2;
    ll cnt=0;
    for(i=0;i<n;i++){
      cnt+=a.end()-lower_bound(a.begin(),a.end(),mid-a[i]);
    }
    if(cnt>=m){
      l=mid;
    }
    else r=mid;
  }

  ll ans=0;
  ll cnt=0;
  for(i=0;i<n;i++){
    auto it=upper_bound(a.begin(),a.end(),l-a[i]);
    cnt+=a.end()-it;
    ans+=b[it-a.begin()];
    ans+=a[i]*(a.end()-it);
  }
  ans+=l*(m-cnt);
  cout<<ans<<endl;
 
  
  
  
  return 0;
}


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

int main() {
  int N;
  int P = 0;
  int W = 0;
  int G = 0;
  int Y = 0;
  int result = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    string color;
    cin >> color;
    if(color == "P") P = 1;
    else if (color == "W") W = 1;
    else if (color == "G") G = 1;
    else if (color == "Y") Y = 1;
  }
  result += P + W + G + Y;
  if(result == 3) cout << "Three" << endl;
  if(result == 4) cout << "Four" << endl;
}


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

struct UnionFind{
    vector<int> r;

    UnionFind(int N){
        r = vector<int>(N,-1);
    }

    int root(int x){
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y){
        x = root(x);
        y = root(y);

        if(x == y) return false;
        if(r[x] > r[y]) swap(x,y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x){
        return -r[root(x)];
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    UnionFind UF(n);

    for(int i=0; i<m; i++){
        int a,b;
        cin>>a>>b;
        UF.unite(a-1,b-1);
    }

    // for(int person : friends[1])
    //     cout<<person<<' ';
    int ans = 0;
    for(int i=0; i<n; i++)
        ans = max(ans, UF.size(i));

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3980
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define Temp template<typename T>
#define mem(a,b) memset(a,(b),sizeof(a))
using namespace std;
typedef long long LL;
Temp inline void chkmin(T &x,T y){if(y<x)x=y;}
Temp inline void chkmax(T &x,T y){if(y>x)x=y;}
Temp inline void read(T &x){
	x=0;T w=1,ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
	x=x*w;
}
const int maxn=100000+10;
int n;
LL ans;
LL a[maxn],b[maxn],c[maxn];
LL la[maxn],lb[maxn],slb[maxn];
inline int lower_find(int k,int x){
	int l=1,r=n+1;
	if(k==1){
		while(l<r){
			int mid=((l+r)>>1);
			if(a[mid]<=x)l=mid+1;
			else r=mid;
		}
		return l;
	}
	else if(k==2){
		while(l<r){
			int mid=((l+r)>>1);
			if(b[mid]<=x)l=mid+1;
			else r=mid;
		}
		return l;
	}
	else if(k==3){
		while(l<r){
			int mid=((l+r)>>1);
			if(c[mid]<=x)l=mid+1;
			else r=mid;
		}
		return l;
	}
}
int main(){
	read(n);
	for(Rint i=1;i<=n;i++)read(a[i]);
	for(Rint i=1;i<=n;i++)read(b[i]);
	for(Rint i=1;i<=n;i++)read(c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	for(Rint i=1;i<=n;i++)la[i]=lower_find(2,a[i])-1;
	for(Rint i=1;i<=n;i++){
		lb[i]=lower_find(3,b[i])-1;
		slb[i]=slb[i-1]+(n-lb[i]);
	}
	for(Rint i=1;i<=n;i++){
		ans+=slb[n]-slb[la[i]];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main (){
int a,b[201],c,d;
cin>>a;
for(int i=1;i<=a;i++){
cin>>b[i];}
for(int i=1;i<=10000000;i++){
for(int i1=1;i1<=a;i1++){
c=b[i1]%2;
if(c!=0){cout<<i-1;return 0;}
b[i1]/=2;
}}
}

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

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素


int main(){
    int k,a,b;
    cin>>k>>a>>b;
    int ans=a/k;
    if(a%k==0 || (ans+1)*k<=b)cout<<"OK";
    else cout<<"NG";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(ab); sll(bc); sll(ca);
	pll(ab+bc+ca - max(ab, max(bc, ca))); nl;
}


Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;

//Bowling
public class Main{

	static class T implements Comparable<T>{
		int id;
		int s;
		public T(int id, int s) {
			this.id = id;
			this.s = s;
		}
		public int compareTo(T o) {
			return s==o.s?id-o.id:o.s-s;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			PriorityQueue<T> q = new PriorityQueue<T>();
			while(n--!=0){
				int[][] p = new int[10][3];
				int x = sc.nextInt();
				boolean[] strike = new boolean[9];
				boolean[] spare = new boolean[9];
				int f = 0;
				while(f<10){
					int pin = sc.nextInt();
					p[f][0] = pin;
					if(pin==10){
						if(f<9){
							strike[f++] = true;
							continue;
						}
					}
					pin = sc.nextInt();
					p[f][1] = pin;
					if(f<9&&p[f][0]+p[f][1]==10){
						spare[f] = true;
					}
					else if(p[f][0]+p[f][1]>=10){
						p[f][2]=sc.nextInt();
					}
					f++;
				}
				int sum = 0;
				for(int i=0;i<9;i++){
					sum += p[i][0] + p[i][1];
					if(strike[i]){
						sum += p[i+1][0];
						int d = p[i+1][0];
						if(i+1<9 && d==10)sum+=p[i+2][0];
						else sum+=p[i+1][1];
					}
					else if(spare[i]){
						sum += p[i+1][0];
					}
				}
				sum += p[9][0]+p[9][1]+p[9][2];
				q.add(new T(x,sum));
			}
			while(!q.isEmpty()){
				T t = q.poll();
				System.out.println(t.id+" "+t.s);
			}
		}
	}
}

Measured memory_bytes: 12000
s = input()
n = len(s)

if s[n - 1] == '1' or s[0] == '0':
    print(-1)
    exit()

for i in range(n):
    if s[i] != s[n - i - 2]:
        print(-1)
        exit()

cur_s = 2
cur_p = 2
print(1, 2)
for i in range(n - 2):
    if s[i + 1] == '1':
        print(cur_s + 1, cur_p)
        cur_p = cur_s + 1
    else:
        print(cur_s + 1, cur_p)
    cur_s += 1

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


int main() {
  int N, M;
  cin >> N;
  
  int d1,d2,d3;
  d1 = N / 100;
  d2 = (N % 100) /10;
  d3 = (N % 10);
  
  if ( d1 == 1 )      { d1 = 9; }
  else if ( d1 == 9 ) { d1 = 1; }

  if ( d2 == 1 )      { d2 = 9; }
  else if ( d2 == 9 ) { d2 = 1; }

  if ( d3 == 1 )      { d3 = 9; }
  else if ( d3 == 9 ) { d3 = 1; }

  M = 100 * d1 + 10 * d2 + d3;
  
  cout << M << endl;
}

Measured memory_bytes: 256
def keta( num )
	return 0 if num == 0
	k = 0
	while( num > 0 )
		num /= 10
		k += 1
	end
	return k
end

def main
		answer = Array.new
		while line = $stdin.gets
			q = line.split( /\s/)
			answer << keta((q[ 0 ].to_i + q[ 1 ].to_i))
		end
		answer.each{ |a|
			puts a
		}
end

main


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

int main() {
    string s;
    cin >> s;
    int a = 0;
    for(int i = 0; i < s.size(); ++i) {
        a = i;
        if(s[i] == 'A') break;
    }
    reverse(s.begin(), s.end());
    int z = 0;
    for(int i = 0; i < s.size(); ++i) {
        z = s.size() - i;
        if(s[i] == 'Z') break;
    }
    cout << z - a << endl;
}

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

//#define int long long
#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 all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
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 (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b; cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0, a + b - n) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

int main() {
	static int aa[N];
	int n, i, min, max;

	scanf("%d", &n);
	min = 1000000001;
	max = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		if (max < aa[i])
			max = aa[i];
		if (min > aa[i])
			min = aa[i];
	}
	printf("%d\n", max - min);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#define M 5070721
#define NIL (-1)
#define L 14
typedef long long ll;
char H[M][L];

int getChar(char ch){
	if(ch=='A')return 1;
	else if(ch=='C')return 2;
	else if(ch=='G')return 3;
	else if(ch=='T')return 4;
	else return 0;
}

ll getKey(char str[]){
	ll sum=0,p=1,i;
	int len=strlen(str);
	for(i=0;i<len;i++){
		sum+=p*(getChar(str[i]));
		p*=5;
	}
	return sum;
}

int h1(int key){
	return key%M;
}

int h2(int key){
	return 1+(key%(M-1));
}

int find(char str[]){
	ll key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0)return 0;
	}
	return 0;
}

int insert(char str[]){
	ll key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0){
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}


int main(void){
	int n;
	char str[L],com[9];
	for(int i=0;i<M;i++){
		H[i][0]='\0';
	}
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s %s",com,str);
		if(com[0]=='i'){
			insert(str);
		}else{
			if(find(str)){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
	return 0;
}




Measured memory_bytes: 72000
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;

signed main() {
    string s;
    vector<int> t;
    cin>>s;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == 'B' && s[i + 1] == 'C') t.push_back(2), i++;
        else if (s[i] == 'A') t.push_back(1);
        else t.push_back(0);
    }
    int cnt = 0;
    int ans = 0;
    for (auto c: t) {
        if (c == 0) cnt = 0;
        if (c == 1) cnt++;
        if (c == 2) ans += cnt;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2680
while True:
    n, r = map(int, raw_input().split())
    if n == 0 and r == 0:
        break

    l = []
    for i in range(1, n + 1):
        l.append(i)

    for i in range(0, r):
        p, c = map(int, raw_input().split())
        tmp = l[len(l) - p + 1:len(l)]
        del l[len(l) - p + 1:len(l)]
        l[len(l) - c:len(l) - c] = tmp

    print(l[len(l) - 1])

Measured memory_bytes: 6460
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		long x = sc.nextLong();
		long b = x;		//下からN層
		long ans = 0;		//答え
		for (int i = n; i >= 0; i--) {
			long h = height(i);		//総枚数
			long mid = (h + 1) / 2;		//真ん中
			if (b == mid) {		//真ん中にぶち当たったら、とりあえず、N-1のサイズのバーガーの肉全部と一番真ん中の肉を食べられる
				ans += patties(i - 1);
				ans++;
				break;
			} else if (b == 1) {		//一番下ならパンしか食って無いので自明に0枚
				break;
			} else if (b == h) {		//上から下までまるまる食べているのならNのパティの数を加算する
				ans += patties(i);
				break;
			} else if (b < mid) {		//中央値よりも小さい時
				b--;
			} else {			//中央値よりも大きかったら、その中央値を下限としてまた計算し直す
				ans += patties(i - 1);
				ans++;
				b -= mid;
			}
		}
		System.out.println(ans);
	}
	public static long height(int n) {
		return (1L << (n + 2)) - 3;
	}
	public static long patties(int n) {
		if (n < 0) {
			return 0;
		}
		return (1L << (n + 1)) - 1;
	}
}

Measured memory_bytes: 23764
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cerr << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll dp[2][200005];
string s;

int main()
{jizz
	ll n;
	cin >> n >> s;
	for(int i=1;i<=n;++i)
		if(s[i-1]=='.')
			dp[0][i]=dp[0][i-1],dp[1][i]=min(dp[1][i-1],dp[0][i-1])+1;
		else
			dp[0][i]=dp[0][i-1]+1,dp[1][i]=min(dp[0][i-1],dp[1][i-1]);
	cout << min(dp[1][n],dp[0][n]) << "\n";
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

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

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

string s,t;
signed main(){
  cin>>s;
  rep(i,s.length())t += 'x';
  cout << t << endl;
}




Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

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

AB = []

for i in range(X):
    for j in range(Y):
        AB.append(A[i]+B[j])

AB.sort(reverse=True)

ABC = []

for i in range(min(len(AB), K)):
    for j in range(Z):
        ABC.append(AB[i]+C[j])

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])

Measured memory_bytes: 148676
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        char[] l = sc.next().toCharArray();
        HashMap<Character,Integer> map = new HashMap<>();
        for(char c : l){
            map.put(c,map.getOrDefault(c,0)+1);
        }
        if(map.size() != 2){
            System.out.println("No");
            return;
        }
        for(Map.Entry<Character,Integer> e : map.entrySet()){
            if(e.getValue() != 2){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 25288
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};

int h,w;
int d[410][410];
string s[25];

void solve(){
    cin >> h >> w;
    rep(i,h){
        cin >> s[i];
    }
    rep(i,h*w){
        rep(j,h*w){
            d[i][j]=mod;
        }
        d[i][i]=0;
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#') continue;
            rep(k,4){
                int ni=i+dy[k],nj=j+dx[k];
                if(ni<0 || ni>h-1 || nj<0 || nj>w-1) continue;
                if(s[ni][nj]=='#') continue;
                d[i*w+j][ni*w+nj]=1;
                d[ni*w+nj][i*w+j]=1;
            }
        }
    }
    rep(k,h*w){
        rep(i,h*w){
            rep(j,h*w){
                if(d[i][j]>d[i][k]+d[k][j]){
                    d[i][j]=d[i][k]+d[k][j];
                }
            }
        }
    }
    int ans=0;
    rep(i,h*w){
        rep(j,h*w){
            if(d[i][j]==mod) continue;
            ans=max(ans,d[i][j]);
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, E[150000][2], frm[150001];
vi G[150000];
double dp[150001][2], sm[150001];

double f(int e, int s) {
    double &res = dp[e][s];
    if (res > -1)return res;
    int u = E[e][s];
    res = 0;
    if (sz(G[u]) == 1)return res;
    double p = 1.0 / (sz(G[u]) - 1);

    if (sm[u] > -1) {
        res = sm[u] + (f(frm[u], E[frm[u]][0] == u) - f(e, !s))*p;
        return res;
    }

    each(ne, G[u])if (ne != e) {
        res += f(ne, E[ne][0] == u);
    }
    res = res*p + 1.0;
    sm[u] = res;
    frm[u] = e;
    return res;
}

int main() {
    scanf("%d", &N);
    rep(i, N - 1) {
        int u, v;
        scanf("%d%d", &u, &v);
        --u; --v;
        E[i][0] = u;
        E[i][1] = v;
        G[u].push_back(i);
        G[v].push_back(i);
    }

    rep(i, N) {
        sm[i] = -2;
        rep(j, 2)dp[i][j] = -2;
    }
    rep(i, N) {
        double ans = 0, p = -1;
        if (sz(G[i]))p = 1.0 / sz(G[i]);
        each(e, G[i]) {
            ans += f(e, E[e][0] == i);
        }
        if (sz(G[i]))ans = ans*p + 1;
        printf("%.8f\n", ans);
    }
}

Measured memory_bytes: 22400
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;
#define B 500
#define F first
#define S second
typedef long long ll;
typedef pair<ll,ll> P;
ll t[100005];
struct que{
  ll o,a,b;
};
struct z{
  ll x;
  bool operator <(z&q){
       if(t[x]!=t[q.x])return -t[x]<-t[q.x];
       else return x<q.x;
  }
};
int n,c;
bool v[100005];
int main(void){
    scanf("%d%d",&n,&c);
    for(int i=0;i<c;i+=B){
        set<int>o;
        vector<que>m;
        for(int k=0;k<n;k++)v[k]=false;
        for(int j=i;j<i+B&&j<c;j++){
            int x;
            scanf("%d",&x);
            if(x==0){
                ll a,b;
                scanf("%lld%lld",&a,&b);
                a--;
                v[a]=true;
                m.push_back(que{0,a,b});
            }else{
                int a;
                scanf("%d",&a);
                m.push_back(que{1,a,0});
            }
        }
        vector<z>p;
        vector<P>q;
        for(int k=0;k<n;k++){
            if(!v[k])q.push_back(P(-t[k],k));
            else p.push_back(z{k});
        }
        sort(q.begin(),q.end());
        for(int j=0;j<m.size();j++){
            ll r=m[j].o,a=m[j].a,b=m[j].b;
            if(r==0)t[a]+=b;
            else{
                sort(p.begin(),p.end());
                a--;
                bool e=false;
                for(int k=0;k<p.size();k++){
                    int h=lower_bound(q.begin(),q.end(),P(-t[p[k].x],p[k].x))-q.begin();
                    if(a<h)break;
                    else if(a==h){
                        printf("%lld %lld\n",p[k].x+1,t[p[k].x]);
                        e=true;
                        break;
                    }else a--;
                }
                if(!e){
                    printf("%lld %lld\n",q[a].S+1,-q[a].F);
                }
            }
        }
    }
}



Measured memory_bytes: 7556
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;


int main()
{
    IOS
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        sum^=x;
    }
    if(!sum)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int k,a,b;
void solve(){
	for(int i = a;i <= b;i++){
		if(i % k == 0){
			cout << "OK" << endl;
			return;
		}
	}
	cout << "NG" << endl;
	return;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> k >> a >> b;
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.rbegin(),v.rend()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define ff first
#define sc second
#define pi 3.14159265359
typedef long long ll;
using namespace std;
ll a[480007];
ll po(ll n)
{
    return n*n;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
//    freopen("test.txt","r",stdin);
    ll n,m,d,k,i,j,ans1=0,ans2=0;
    cin>>n;
    for(i=1;i<=200;i++)
       for(j=1;j<=200;j++)
            for(k=1;k<=200;k++)
       {
           d=po(i+j)+po(j+k)+po(k+i);
           a[d/2]++;
       }
    for(i=1;i<=n;i++)
    {
        cout<<a[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 5476
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next().trim());
		int B = Integer.parseInt(sc.next().trim());
		int K = Integer.parseInt(sc.next().trim());
		
		for (int i = 0;(i+A) <= B;i++) {
			if ((i < K) || ((i+K) > (B-A))) {
				System.out.println(i+A);
			}
		}
	}
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define fastio  ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0)
using namespace std;
#define ll long long
const int mod = 1'000'000'007;
int main()
{
    fastio;
    int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  long long ans = 0, tot = 0;
  for (int i : a) {
    ans = (ans + tot * i) % mod;
    tot = (tot + i) % mod;
  }
  cout << ans << endl;
    
    
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans = 700;
  if(s[0] == 'o') ans += 100;
  if(s[1] == 'o') ans += 100;
  if(s[2] == 'o') ans += 100;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[212345];

int main(){
	int n; scanf("%d%s", &n, s);
	int p = 0, q = 0;
	REP(i, n) if(s[i] == 'R') q++;
	int ans = INT_MAX;
	REP(i, n+1){
		SML(ans, max(p, q));
		if(s[i] == 'R') q--;
		if(s[i] == 'W') p++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3892
N=int(input())
D,X=list(map(int,input().split()))
a=[]
for i in range(N):
    x=int(input())
    a.append(x)

def ai_eat_num(ai,day):
    x=0
    while 1+x*ai <= day:
        x += 1
    return x

cnt=0
for i in range(N):
    cnt+=ai_eat_num(a[i],D)
print(cnt+X)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

int main()
{
    string str;
    getline(cin, str);
    cout << (str == "1 1 0" || str == "0 0 1" ? "Open" : "Close") << endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll n, d;
  cin >> n >> d;
  ll x, y, cnt = 0;
  REP(i, n) {
    cin >> x >> y;
    if(sqrt(x * x + y * y) <= d) cnt++;
  }

  cout << cnt << endl;
  return 0;
}


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

#define ll long long
#define db double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif

	string s;
	cin >> s;
	int n = s.size();
	int h = n / 2;
	for (int i = 0; i < h; i++) {
		if (s[i] != s[h - i - 1]) {
			cout << "No";
			return 0;
		}
	}
	for (int i = h + 1; i < n; i++) {
		if (s[i] != s[n - 1 - (i - (h + 1))]) {
			cout << "No";
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (s[i] != s[n - i - 1]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


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

int main(){
    int N; cin >> N;
    vector<int> s(N);
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> s[i];
        sum += s[i];
    }
    if(sum % 10 != 0){
        cout << sum << endl;
    }
    else{
        sort(s.begin(), s.end());
        for(int i = 0; i < N; i++){
            if(s[i] % 10 != 0){
                cout << sum - s[i] << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256