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

public class Main{

	public static void main(String[] args) {
		int m=0,n=0;
		String s=null;
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			s=br.readLine();
			StringTokenizer st = new StringTokenizer(s, " ");
			m=Integer.parseInt(st.nextToken());
			n=Integer.parseInt(st.nextToken());
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println(m*n+" "+2*(m+n));
		
		
	}
}



Measured memory_bytes: 24424
T=!!0
F=!T
[T,F].map{|c|
class<<c
alias:%:==
def!=x
!self|x
end
end
}
until/#/=~gets
puts (0..2047).all?{|x|
eval$_.tr"-=>*+abcdefghijk","!%=&|"+("%011b"%x).tr("01","TF")
}?'YES':'NO'
end

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

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

	long long N; cin >> N;
	long long a[55];
	long long cnt = 1;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	long long ans = 0;
	while (cnt > 0) {
		cnt = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] >= N) {
				cnt = a[i] / N;
				a[i] %= N;
				for (int j = 0; j < i; j++) {
					a[j] += cnt;
				}
				for (int j = i + 1; j < N; j++) {
					a[j] += cnt;
				}
				ans += cnt;
			}
		}
	}
	cout << ans;
}

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

char C[66][66];
int H,W;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int main(){
  cin>>H>>W;
  rep(i,H) rep(j,W) cin>>C[i+1][j+1];
  rep(i,H) rep(j,W) if(C[i+1][j+1]=='#'){
    bool flag=1;
    rep(k,4) if(C[i+1+dx[k]][j+1+dy[k]]=='#') flag=0;
    if(flag){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

using namespace std;

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

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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

vp interval_scheduling(vp J) {
    vp A;
  sort(all(J));
  int f = -INF;
  for (int i = 0; i < J.size(); ++i) {
    if (J[i].second >= f) {
      A.push_back(J[i]);
      f = J[i].first;
    }
  }
  return A;
}


signed main(void) {
    int n;
    cin >> n;
    vp v(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        v[i] = pii(a+b,a-b);
    }
    sort(all(v));
    vp ans = interval_scheduling(v);

    cout << ans.size() << endl;
}


Measured memory_bytes: 5620
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬╬╬██╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓▓█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef pair<int,int> P;
typedef vector<vector<P>> Graph;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  sort(a.begin(),a.end());

  int tmp = accumulate(a.begin(),a.end(),0LL);

  cout << tmp - a[n-1]/2 << endl;

  return 0;
}

Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : April 15 2020 15:16:09 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;
/*

    Lets try to assign a grundy number for each state f(n,k)
    let us assume k is odd
    if n < k : terminal state -> 0
    n = k + 0 : 1
    n = k + 1 : 0
    n = k + 2 : 1
    .............
    ............
    n = k + k-1 : 1
    
    n = 2*k + 0 : 2
    
    n = 2*k + 1 : 0

    n = 2*k + 2 : 1 

    n = 2*k + 3 : 2


    n = 3*k   : 3
*/
ll get(ll n,ll k){
    if(n < k) return 0;
    if(n%k == 0) return n/k;
    int d = n/k + 1;
    int to = k*(d-1);
    n -= (n-to+d-1)/d*d;
    return get(n,k);
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    int x = 0;
    fori(i,n){
        int a,b;
        cin >> a >> b;
        x ^= get(a,b);
    }
    if(x) cout << "Takahashi" << endl;
    else cout << "Aoki" << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  int A, B, C;

  cin >> A >> B >> C;

  bool flag = false;

  for(int i=0; i < B; i++){
    if((A*i)%B == C) flag =  true;
  }

  if (flag)  cout << "YES" << "\n";
  else cout << "NO" << "\n";
}


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

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string s; cin>>s;
	int N = s.size();
	if(s == "zyxwvutsrqponmlkjihgfedcba"){cout<<-1<<endl; return 0;}
	if(N < 26){
		vector<int> chars(26,0);
		rep(i,N){
			int t = s[i] - 'a';
			chars[t] = 1;
		}
		char c;
		rep(i,26){
			if(chars[i] == 0){
				c = (char)('a'+i);
				break;
			}
		}
		cout<<s+c<<endl;
		return 0;
	}
	string ans = "zyxwvutsrqponmlkjihgfedcba";
	for(int k = 25; k> 0; --k){
		char c = s[k];
		int pos = k-1;
		int ok = inf;
		for(; pos>=0; --pos){
			if(s[pos]<c){
				ok = pos;
				break;
			}
		}
		if(ok != inf){
			string e_ans = s.substr(0,ok) + c;
			ans = min(ans, e_ans);
		}
	}
	cout<<ans<<endl;
	// char c = s[25];
	// int pos = 24;
	// for(; pos>=0; --pos){
	// 	if(s[pos]<c){
	// 		break;
	// 	}
	// }
	// cout<<s.substr(0,pos) + c<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
   ,##.                   ,==.
 ,#    #.                 \ o ',
#        #     _     _     \    \
#        #    (_)   (_)    /    ; 
 `#    #'                 /   .'  
   `##'                   "=="
*/

#include <bits/stdc++.h>
#define ll long long
#define null NULL

using namespace std;

const ll MOD = 1e9 + 7;

int a, b, c;

int main() {
	cin >> a >> b >> c;
	int d = max(a, max(b, c));
	if ((a + b + c) % 2 != d % 2) {
		d++;
	}
	cout << (d * 3 - a - b - c) / 2 << endl;
}

Measured memory_bytes: 256
def main():
    cards = {'a': '', 'b': '', 'c': ''}

    cards['a'] = input()
    cards['b'] = input()
    cards['c'] = input()

    current = 'a'
    next = ''

    while True:
        # ToDO 1回目に先頭削るのおかしい
        if not cards[current]:
            print(current.upper())
            return
        next = cards[current][0]
        cards[current] = cards[current][1:]
        current = next

if __name__ == "__main__":

    main()


Measured memory_bytes: 3064
s = input()
q = int(input())

is_reverse = False
before = ""
after = ""

for _ in range(q):
  lst = input().split()
  if lst[0] == "1":
    is_reverse = not is_reverse
  else:
    _, f, c = lst
    if f == "1":
      if not is_reverse:
        before = c + before
      else:
        after = after + c
    else:
      if not is_reverse:
        after = after + c
      else:
        before = c + before

if is_reverse:
  s = s[::-1]
  before, after = after[::-1], before[::-1]

print(before + s + after)


Measured memory_bytes: 4428
#include <iostream>
using namespace std;
int main(void){
    
    int a,b,c;
    cin >> a >> b;
    
    if(a <= 9 && b <= 9)
        {
        int ans;
        ans = a * b;
        cout << ans << endl;
        }
    else
        cout << "-1" << endl;

}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int h,w,ans=0;
	cin >> h >> w;
	Vec(a,h);
	REP(i,h){
		cin >> a[i];
	}
	REP(i,h){
		REP(j,w){
			if(a[i][j] == '#'){
				ans ++;
			}
		}
	}
	(ans == h+w-1)? cout << "Possible" << endl : cout << "Impossible" << endl;
    return 0;
}

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

using namespace std;

const int MAX_N = 1050;

int n, sum, ai[MAX_N], res[MAX_N], candid[MAX_N], pos[MAX_N];
int upper, lower, sa[MAX_N], sb[MAX_N], ans[MAX_N], ansptr;

bool compare(const int &x, const int &y)
{
    if ((ai[x] == lower) == (ai[y] == lower))
        return x < y;
    else
        return (ai[x] == lower) < (ai[y] == lower);
}

void solve(int len)
{
    bool found = false;
    for (int i = 1; i <= len; i++)
        ai[pos[i]]--;
    int min_val = *min_element(ai + 1, ai + 1 + n), max_val = *max_element(ai + 1, ai + 1 + n);
    if ((min_val << 1) >= max_val)
    {
        for (int i = 1; i <= len; i++)
            res[i] = pos[i];
        sort(res + 1, res + 1 + len), found = true;
    }
    else if (((min_val << 1) | 1) == max_val)
    {
        upper = max_val, lower = min_val;
        int ptra = 1, ptrb = 1, la = 0, lb = 0, ptr = 0;
        for (int i = 1; i <= len; i++)
            if (ai[pos[i]] == min_val || ai[pos[i]] == max_val)
                sa[++la] = pos[i];
            else
                sb[++lb] = pos[i];
        sort(sa + 1, sa + 1 + la, compare), sort(sb + 1, sb + 1 + lb);
        // merge;
        while (ptra <= la && ptrb <= lb)
            if (sa[ptra] < sb[ptrb])
                res[++ptr] = sa[ptra++];
            else
                res[++ptr] = sb[ptrb++];
        while (ptra <= la)
            res[++ptr] = sa[ptra++];
        while (ptrb <= lb)
            res[++ptr] = sb[ptrb++];
        found = true;
        for (int i = len + 1; i <= n; i++)
            if (ai[pos[i]] == min_val)
                found = false;
        found |= (ai[sa[1]] == max_val);
    }
    for (int i = 1; i <= len; i++)
        ai[pos[i]]++;
    if (!found)
        res[1] = 0;
}

bool lexicographicalCompare(int *s1, int *s2)
{
    int ptr = 1;
    while (s1[ptr] == s2[ptr])
        ptr++;
    return s1[ptr] < s2[ptr];
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &ai[i]), sum += ai[i], pos[i] = i;
    if (((*min_element(ai + 1, ai + 1 + n)) << 1) < *max_element(ai + 1, ai + 1 + n))
        puts("-1"), exit(0);
    solve(n);
    for (int i = 1; i <= n; i++)
        ans[++ansptr] = res[i], ai[res[i]]--, pos[i] = res[i];
    while (ansptr < sum)
    {
        memset(candid, 0, sizeof(candid)), candid[1] = n + 1;
        int len = 0;
        for (int i = 1; i <= n; i++)
        {
            solve(i);
            if (res[1] != 0 && lexicographicalCompare(res, candid))
            {
                len = i;
                for (int j = 1; j <= i; j++)
                    candid[j] = res[j];
            }
        }
        for (int i = 1; i + len <= n; i++)
            pos[i] = pos[i + len];
        for (int i = 1; i <= len; i++)
            ans[++ansptr] = pos[n - len + i] = candid[i], ai[candid[i]]--;
    }
    for (int i = 1; i <= ansptr; i++)
        printf("%d ", ans[i]);
    puts("");
    return 0;
}

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),m=nxt();
    set <int> s2;
    for(int i=0;i<n;i++)
        s2.insert(i);
    vector <pair<int,int>> ans;
    int x=(m+1)/2;
    for(int i=1;i<=x;i++)
    {
        ans.push_back({i,2*x-i+1});
    }
    x=(m)/2;
    for(int i=n;i>n-x;i--)
    {
        ans.push_back({i,n-2*x+(n-i)});
    }
    for(int i=0;i<ans.size();i++)
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    
    
    return 0;   
}




 
 


Measured memory_bytes: 12632
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	std::vector<vector<int>> a(3,std::vector<int>(3));
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)scanf("%d",&a[i][j]);

	int n;

	scanf("%d",&n);
	std::vector<bool> wa(101);
	for(int i=0,x;i<n;i++)scanf("%d",&x),wa[x]=1;

	for(int i=0;i<3;i++){
		bool ok = true;
		for(int j=0;j<3;j++){
			if(!wa[a[i][j]])ok=false;
		}
		if(ok)return!printf("Yes\n");
	}
	for(int j=0;j<3;j++){
		bool ok = true;
		for(int i=0;i<3;i++){
			if(!wa[a[i][j]])ok=false;
		}
		if(ok)return!printf("Yes\n");
	}

	if(wa[a[0][0]] && wa[a[1][1]] && wa[a[2][2]])return !printf("Yes\n");
	if(wa[a[0][2]] && wa[a[1][1]] && wa[a[2][0]])return !printf("Yes\n");

	printf("No\n");
}		



Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <complex>
#include <cmath>
using namespace std;


int main(int argc, char const *argv[]) {
    string s;cin>>s;
    int n=s.length();
    if(s[n-1]=='1'){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[n-2-i]){
            cout<<-1<<endl;
            return 0;
        }
    }
    if(s[0]=='0'){
        cout<<-1<<endl;
        return 0;
    }
    int l = 1, i = 2;
    for(;i<=n;++i){
        cout << l << " " << i <<endl;
        if(s[i-2]=='1'){
            l = i;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vi X(N);
    rep(i,N) cin>>X.at(i);
    int answer=1000000;
    sort(X.begin(),X.end());
    for(int i=X.at(0); i<=X.at(N-1); i++) {
        int counter=0;
        rep(j,N) {
            int h=abs(X.at(j)-i);
            counter+=h*h;
        } 
        answer=min(answer,counter);
        counter=0;
    }
    cout<<answer<<endl;
}

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

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	#ifndef ONLINE_JUDGE
	#endif
	string s;
	cin>>s;
	for(auto c: s)
	{
		if(isalpha(c))
		{
			cout<<c;
		}
		else
		{
			cout<<' ';
		}
	}
}	

Measured memory_bytes: 764
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;
 
//#include "atcoder.hpp"
 
long long gcd(long long a, long long b) {
    if (a>b) swap(a,b);
    
    auto r = b % a;
    
    return (r ? gcd(r, a) : a);
}
 
int main() {
    long long X, Y, Z, K;
    
    cin >> X >> Y >> Z >> K;
    long long A[1000], B[1000], C[1000];
    
    REP(i,X)
        cin >> A[i];
    REP(i,Y)
    cin >> B[i];
    REP(i,Z)
    cin >> C[i];
    
    priority_queue<long long, deque<long long>> XY;
    
    REP(i,X) REP(j,Y) {
        long long tmp = A[i] + B[j];
        XY.push(tmp);
    }
    
    priority_queue<long long, deque<long long>> XYZ;
    int cnt = 3000;
    while (cnt-- && !XY.empty()) {
      auto value = XY.top();
    REP(i,Z) {
        XYZ.push(value + C[i]);
    }
      XY.pop();
    }
    
    while (K--) {
    cout << XYZ.top() << endl;
        XYZ.pop();
    }
    
    return 0;
}

Measured memory_bytes: 33076
#include<stdio.h>
#define N 100000

int search(int);

int A[N];
int n;

int main(){
  int i, q, key, count=0;

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

  scanf("%d", &q);
  for (i=0;i<q;i++){
    scanf("%d",&key);
    if(search(key)){
      count++;
    }
  }
  printf("%d\n",count);

  return 0;
}


int search(int key){
  int left = 0;
  int right = n;
  int mid;
  while( left < right ){
    mid = (left + right ) /2;
    if ( key == A[mid] ) return 1;
    if ( key > A[mid] ) left = mid+1;
    else if ( key < A[mid] ) right = mid;
  }
  return 0;
}

Measured memory_bytes: 988
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
//#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define N  1000000007 
#define MAXN   200005
int main()
{
ios_base::sync_with_stdio(false);
 cin.tie(0);
 cout.tie(0);
ll int n,a,b;
cin>>n;
vi v1,v2,v3;
cin>>a>>b;
vi v(n);
rep(i,0,n)
{cin>>v[i];
if(v[i]<=a)
	v1.pb(v[i]);
else if(v[i]>=a+1 && v[i]<=b)
	v2.pb(v[i]);
else
	v3.pb(v[i]);
}
cout<<min(min(v1.size(),v2.size()),v3.size());
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  if(S[S.size()-1] == 's') cout << S << "es" << endl;
  else cout << S << "s" << endl;
  
  return 0;
}



Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <utility>
#include <ctime>
#include <cassert>
#include <climits>

using namespace std;

#define TRACE
 
#ifdef TRACE
template<class T, class U>
ostream& operator<<(ostream& out, const pair<T,U>& a){out<<"["<<a.first<<" "<<a.second<<"]";return out;}
template<class T>
ostream& operator<<(ostream& out, const vector<T>& a){out<<"[ ";for(auto &it:a)out<<it<<" ";out<<"]";return out;}
template<class T>
ostream& operator<<(ostream& out, const set<T>& a){out<<"[ ";for(auto &it:a)out<<it<<" ";out<<"]";return out;}
template<class T>
ostream& operator<<(ostream& out, const multiset<T>& a){out<<"[ ";for(auto &it:a)out<<it<<" ";out<<"]";return out;}
template<class T,class U>
ostream& operator<<(ostream& out, const map<T,U>& a){for(auto &it:a)out<<it.first<<" -> "<<it.second<<" | ";return out;}
template<class T,class U>
ostream& operator<<(ostream& out, const multimap<T,U>& a){for(auto &it:a)out<<it.first<<" -> "<<it.second<<" | ";return out;}
#define pra(a,n) cerr<<#a<<" : ";for(int i=0;i<n;++i)cerr<<a[i]<<" ";cerr<<endl;
#define praa(a,n,m) cerr<<#a<<" : "<<endl;for(int i=0;i<n;++i){for(int j=0;j<m;++j)cerr<<a[i][j]<<" ";cerr<<endl;}
#define pr(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
} 
#else
#define pr(...)
#define pra(a,n)
#define praa(a,n,m)
#endif
#define int long long

void Main()	{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if((a[0] % 2) * (a[1] % 2) * (a[2] % 2) == 0)	{
		cout << "0\n";
		return;
	}
	cout << a[0] * a[1] << "\n";
}

#undef int
int main()	{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	Main();
}



























Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
   
    int i,N,a,b,c;
    scanf("%d",&N);
    for(i=0; i<N; i++){
    scanf("%d %d %d",&a,&b,&c);
    if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b)
        printf("YES\n");
    
    else
        printf("NO\n");
    }    
    return 0;
    
}


Measured memory_bytes: 2072
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

#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 FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

int N, K;
double p;

int main() {
  scanf("%d %d", &N, &K);

  if (N >= K) {
    p = N - K + 1;
  } else {
    p = 0.0;
  }

  int po = 2;
  for (int i = min(N, K - 1); i >= 1; i--) {
    int y = i * po;
    while (y < K) {
      po *= 2;
      y = i * po;
    }

    double z = 1.0 / po;
    p += z;
  }
  p /= N;
  printf("%.10lf\n", p);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
const int MOD = 1000000007;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  rep(i, 0, N) cin >> L[i];
  vector<int> S(N+1);
  rep(i, 0, N) S[i+1] = S[i] + L[i];
  int ans = 0;
  rep(i, 0, N + 1) if(S[i] <= X) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

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

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		int n; scanf("%d", &n);
		if (n == 0) break;
		set<vector<pair<int, int>>> s;
		ll res = 0;
		{
			int m; scanf("%d", &m);
			vector<int> x(m), y(m);
			for (int i = 0; i < m; i++) scanf("%d %d", &x[i], &y[i]);
			for (int i = 1; i < m; i++) x[i] -= x[0], y[i] -= y[0];
			x[0] = 0;
			y[0] = 0;
			vector<pair<int, int>> vp(m);
			for (int i = 0; i < m; i++) vp[i] = { x[i],y[i] };
			s.emplace(vp);
		}
		for (int loop = 1; loop <= n; loop++) {
			int m; scanf("%d", &m);
			vector<int> x(m), y(m);
			for (int i = 0; i < m; i++) scanf("%d %d", &x[i], &y[i]);
			for (int i = 1; i < m; i++) x[i] -= x[0], y[i] -= y[0];
			x[0] = 0;
			y[0] = 0;
			vector<pair<int, int>> vp(m);
			bool flag = false;
			for (int _ = 0; _ < 4; _++) {
				for (int i = 0; i < m; i++) vp[i] = { x[i],y[i] };
				flag |= (s.find(vp) != s.end());
				for (int i = 0; i < m; i++) {
					tie(x[i], y[i]) = make_pair(y[i], -x[i]);
				}
			}
			reverse(x.begin(), x.end()), reverse(y.begin(), y.end());
			for (int i = 1; i < m; i++) x[i] -= x[0], y[i] -= y[0];
			x[0] = 0;
			y[0] = 0;
			for (int _ = 0; _ < 4; _++) {
				for (int i = 0; i < m; i++) vp[i] = { x[i],y[i] };
				flag |= (s.find(vp) != s.end());
				for (int i = 0; i < m; i++) {
					tie(x[i], y[i]) = make_pair(y[i], -x[i]);
				}
			}
			if (flag) printf("%d\n", loop);
		}

		puts("+++++");
	}
	return 0;

}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int res=1e9;
int cnt=0;
vector<int> compare;
vector<int> v;
void dfs(int pos,int num){
	if(pos==compare.size()){
		if(num>=cnt)res=min(res,num);
		return ;
	}
	for(int i=0;i<v.size();i++)dfs(pos+1,num*10+v[i]);
}
int main(){
	int n,t;
	cin>>n>>t;
	set<int> s;
	for(int i=0;i<t;i++){
		int garbage;
		cin>>garbage;
		s.insert(garbage);
	}
	int N=n;
	for(int i=0;i<10;i++){
		if(s.find(i)==s.end()){
			v.push_back(i);
		}
	}
	while(N){
		compare.push_back(N%10);
		N=N/10;
	}
	reverse(compare.begin(),compare.end());
	int ans=0;
	for(int i=0;i<compare.size();i++){
		cnt=cnt*10+compare[i];
	}
	for(int i=0;i<compare.size();i++){
		ans=ans*10+v[v.size()-1];
	}
	if(ans<cnt){
		if(v[0]==0)cout<<v[1];
		if(v[0]!=0)cout<<v[0];
		for(int i=0;i<compare.size();i++)cout<<v[0];
		cout<<endl;
		return 0;
	}
	dfs(0,0);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    int N;
    int count=0;
    string s;
    cin>>N;
    cin>>s;
    while(s.find("ABC")<N && s.find("ABC")>=0)
    {
        s.replace(s.find("ABC"),3,"");
        count++;

    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
        int[] s = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int[] x = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int[] y = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        
        int N = s[0];
        int M = s[1];
        int X = s[2];
        int Y = s[3];
        int xmax = -110;
        int ymin = 110;
        
        for(int i = 0; i < N; i++)
        {
            xmax = Math.Max(xmax, x[i]);
        }
        
        for(int i = 0; i < M; i++)
        {
            ymin = Math.Min(ymin, y[i]);
        }
        
        int Z = xmax + 1;
        while(Z <= ymin)
        {
            if(X < Z && Z <= Y)
            {
                Console.WriteLine("No War");
                return;
            }
            Z++;
        }
        Console.WriteLine("War");
    }
}

Measured memory_bytes: 13268
n=gets.to_i
a=gets.split.map(&:to_i)

def modu(m,a)
    f=0
    a.each do|ele|
        f+=m%ele
    end
    return f
end
class Array
def lcm
    self.inject{|a,b| a.lcm(b)}
end
end
ret=0
unchi=a.lcm
for i in unchi-10..unchi
    s=modu(i,a)
    if ret<s
        ret=s
    end
end
p ret

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e18 + 7, N = 51, MAGIC = 2555;

V<array<int, 3>> G[N];
int dist[N][MAGIC];
int cur[N];
int c[N], d[N];

signed main()
{
	IO_OP;
	
	memset(dist, 0x3f, sizeof dist);

	int n, m, s;
	cin >> n >> m >> s;
	if(s > MAGIC - 1) s = MAGIC - 1;
	for(int i = 0; i < m; i++) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		G[u].PB({v, a, b});
		G[v].PB({u, a, b});
	}
	for(int i = 1; i <= n; i++) {
		cin >> c[i] >> d[i];
	}
	// priority_queue<pair<int, pi>, V<pair<int, pi>>, greater<pair<int, pi>>> pq;
	for(int i = 0; i <= s; i++) dist[1][i] = 0;
	// pq.push({dist[1][s] ,{1, s}});
	while(true) {

		// auto tt = pq.top(); pq.pop();
		pi u;
		int dd = INF;		
		for(int i = 1; i <= n; i++) {
			int j = cur[i];
			if(j < MAGIC && dist[i][j] < dd) {
				dd = dist[i][j];
				u = {i, j};
			}
		}
		if(dd == INF) break;
		// cout << u.F << " , " << u.S << endl;
		// cout << u.F << " " << u.S << endl;
		for(int i = u.S + 1; i < MAGIC; i++) {
			int nwd = dist[u.F][u.S] + (i - u.S + c[u.F] - 1) / c[u.F] * d[u.F];
			if(nwd < dist[u.F][i]) {
				dist[u.F][i] = nwd;
			}
		}
		for(auto e:G[u.F]) {
			int v = e[0], aa = e[1], bb = e[2];
			if(aa > u.S) continue;
			if(dist[v][u.S-aa] > dist[u.F][u.S] + bb) {
				dist[v][u.S-aa] = dist[u.F][u.S] + bb;
				// pq.push({dist[v][u.S-aa], {v, u.S-aa}});
			}
		}
		cur[u.F]++;
	}
	for(int i = 2; i <= n; i++) {
		int mn = INF;
		for(int j = 0; j < MAGIC; j++)
			mn = min(mn, dist[i][j]);
		cout << mn << endl;
	}

}





Measured memory_bytes: 4720
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val s = Scanner.next.map(_ == 'R')
	val n = s.size
	val a = Array.fill(n)(0)

	var acc = 0
	var bcc = 0

	loop(0, n) { i =>
		if (s(i)) {
			if (s(i+1)) acc += 1
			else {
				a(i)   += (acc / 2) + 1
				a(i+1) += (acc / 2.0).ceil.toInt
				acc = 0
			}
		}
		if (!s(n-1-i)) {
			if (!s(n-2-i)) bcc += 1
			else {
				a(n-1-i) += (bcc / 2) + 1
				a(n-2-i) += (bcc / 2.0).ceil.toInt
				bcc = 0
			}
		}
	}

	loop(0, n) { i => pw.print(s"${a(i)} ") }
	pw.println()
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 58932
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a.at(0)<<b.at(0)<<c.at(0)<<endl;
	
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,x,t,cnt;
    cnt = 0;
    scanf("%d %d %d",&n,&x,&t);
    while(n > 0)
    {
        n -= x;
        cnt += t;
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void a_hashira(void) {
	int a, b, c;
	cin >> a >> b >> c;

	cout << (b - a == c - b ? "YES" : "NO") << endl;
}

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

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i < (int)n; i++)
#define Loopr(i, n) for(int i= (int)n - 1; i >= 0; i--)
using namespace std;
typedef long long int ll;

struct node {
	int parent, left, right;
};

int n, root, buf;
vector<node> nodes(41, { -1,-1,-1 });
vector<int> pre(41, -1), in(41, -1);

void finding(int p, int l, int r) {
	int a = pre[buf];
	nodes[a].parent = p;
	buf++;
	if (r - l != 1) {
		for (int i = l;i < r;i++) {
			if (in[i] == a) {
				if (l != i) {
					nodes[a].left = pre[buf];
					finding(a, l, i);
				}
				if (i + 1 != r) {
					nodes[a].right = pre[buf];
					finding(a, i + 1, r);
				}
				break;
			}
		}
	}
}

void print_post(int a) {
	if (a != -1) {
		print_post(nodes[a].left);
		print_post(nodes[a].right);
		if (a == root) 	cout << a << endl;
		else cout << a << " ";
	}
}

int main() {
	cin >> n;
	Loop(i, n) cin >> pre[i];
	Loop(i, n) cin >> in[i];
	root = pre[0];
	buf = 0;
	finding(-1, 0, n);
	print_post(root);
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main() {
	long long int a, b, ans;
	cin >> a >> b;
	if (a == 1 && b == 1) ans = 1;
	else if (a == 1 && b != 1) ans = b - 2;
	else if (a != 1 && b == 1) ans = a - 2;
	else ans = (a - 2)*(b - 2);
	cout << ans << endl;
}


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

public class Main {
    int MAX = 100000;
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ds = new int[MAX + 1];

        for (int i = 0; i < n; i++) {
            ds[sc.nextInt()]++;
        }
        n /= 2;
        int cnt = 0;
        for (int i = 1; i <= MAX; i++) {
            ds[i] += ds[i - 1];
            if (ds[i] == n) cnt++;
        }
//        debug(ds);
        System.out.println(cnt);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

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

int m=0, a=0, r=0, c=0, h=0;

signed main(){

	int N;
	cin >> N;

	for (int i = 0; i < N; i++){
		string s;
		cin >> s;
		switch (s[0]){
		case 'M': m++; break;
		case 'A': a++; break;
		case 'R': r++; break;
		case 'C': c++; break;
		case 'H': h++; break;
		}
	}
	int result = m*a*r + m*a*c + m*a*h 
		+ m*r*c + m*r*h + m*c*h
		+ a*r*c + a*r*h +a*c*h
		+ r * c * h;

	cout << result << endl;


	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

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

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int N,K,sum=0;
    cin>>N>>K;
    vi X(N);
    rep(i,N){
        int x;
        cin>>x;
        int y=abs(K-x);
        sum=sum+min(x*2,y*2);
    }
    cout<<sum<<endl;
    return 0;
}

//a=97,z=122

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int ans[200002];

signed main() {
	int n, q;
	vector<int>d[200002];
	cin >> n >> q;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		d[a - 1].push_back(b - 1);
		d[b - 1].push_back(a - 1);
	}
	rep(i, q) {
		int p, x;
		cin >> p >> x;
		ans[p - 1] += x;
	}
	queue<int>que;
	que.push(0);
	bool visit[200002];
	rep(i, n) visit[i] = false;
	visit[0] = true;
	while (!que.empty()) {
		int now = que.front(); que.pop();
		rep(i, d[now].size()) {
			if (!visit[d[now][i]]) {
				ans[d[now][i]] += ans[now];
				que.push(d[now][i]);
				visit[d[now][i]] = true;
			}
		}
	}
	rep(i, n) {
		cout << ans[i] << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 18032
N = int(input())
E=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    E[a-1].append((b-1,i))
    E[b-1].append((a-1,i))

C = [0] * (N-1)
stack=[0]
parent_e=[0]*N
max_c=0
while stack:
    n=stack.pop()
    c=1
    for to,i in E[n]:
        if n!=0 and parent_e[n]==i:
            continue
        c+=1 if n!=0 and C[parent_e[n]]==c else 0
        C[i]=c
        max_c=max(max_c,c)
        c+=1
        stack.append(to)
        parent_e[to]=i

print(max_c)
print('\n'.join(map(str,C)))

Measured memory_bytes: 45416
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

x=[a,b,c,d,e]

l10=[int(i) for i in x if i % 10==0]
res=x
for n in l10:
    res.remove(n)

if not len(l10)==5:
    min_d=9
    for i in res:
        if int(str(i)[-1])<=min_d:
            min_d=int(str(i)[-1])
            min_num=i
    
    re2=res
    
    re2.remove(min_num)
    
    s=0
    for si in re2:
        if len(str(si))==2:
            s+=int(str(si)[0])*10+10
        elif len(str(si))==1:
            s+=10
        else:
            s+=int(str(si)[:-1])*10+10 
    print(sum(l10)+min_num+s)
else:
    print(sum(l10))
    
    

    


Measured memory_bytes: 3064
using System;

namespace PracticeForAtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            string s = Console.ReadLine();
            int n = s.Length;
            for(int i = 0; i < n; i++)
            {
                Console.Write("x");
            }
            Console.WriteLine();


            //ここまで
        }
    }
}


Measured memory_bytes: 13140