akhauriyash/Code-Regression huggingface dataset:
/*
 * Problem Description: Recursion / Divide and Conquer - Merge Sort
 * Category:
 * Author: Khan
 * Date: 15th October, 2017
 */

#include <iostream>

using namespace std;

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; ++i)
        L[i] = A[left + i];
    for (int i = 0; i < n2; ++i)
        R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for(int k = left; k < right; ++k)
    {
        cnt++;
        if(L[i] <= R[j])
            A[k] = L[i++];
        else
            A[k] = R[j++];
    }
}

void mergeSort(int A[], int n, int left, int right)
{
    if(left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int A[MAX], n;
    cnt = 0;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> A[i];
    mergeSort(A, n, 0, n);

    for (int i = 0; i < n; ++i)
    {
        if(i)
            cout << " ";
        cout << A[i];
    }
    cout << endl << cnt << endl;
    return 0;
}

Measured memory_bytes: 6972
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    int n, m, a;
    cin >> n >> m;

    priority_queue<int> q;
    for (int i = 0; i < n; i++) {
        cin >> a;
        q.push(a);
    }

    for (int i = 0; i < m; i++) {
        a = q.top();
        q.pop();
        q.push(a / 2);
    }
    ll sum = 0;
    while (!q.empty()) {
        a = q.top();
        q.pop();
        sum += a;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3400
#include <iostream>
#include <vector>
#include <map>

using namespace std;
using vi = vector<int>;

#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}

template<int MOD> struct MInt {
  long long val;
  MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt operator*(const MInt& n) const { return MInt(val) *= n; }
  MInt operator/(const MInt& n) const { return MInt(val) /= n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  MInt& operator*=(const MInt& n) { val = (val * n.val) % MOD; return *this; }
  MInt& operator/=(const MInt& n) { val = (*this * n.inv()).val; return *this; }
  MInt inv() const {
    MInt pow = val, ans = 1;
    for (int p = MOD - 2; p > 0; p >>= 1) {
      if (p & 1) ans *= pow;
      pow *= pow;
    }
    return ans;
  }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
const int MOD = 1e9+7;
using mint = MInt<MOD>;

int main() {
  int in(N);

  map<int,int> factor;
  vi A(N);

  rep(i, N) {
    int in(a); A[i] = a;
    for (int j = 2; j * j <= a; ++j) {
      int count = 0;
      while (a % j == 0) {
        a /= j; ++count;
      }
      if (count > 0)
        chmax(factor[j], count);
    }
    if (a > 1)
      chmax(factor[a], 1);
  }
  mint gcd = 1;
  for (const auto& e : factor)
    rep(i, e.second)
      gcd *= e.first;

  mint ans = 0;
  rep(i, N)
    ans += gcd / A[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
using std::cin;
using std::cout;
int main()
{
	int *a,n,i,j;
	scanf("%d",&n);
	a = new int[n+1];
	for(i=1;i<=n;i++){
		scanf("%d",&j);
		a[j]=i;
		}
	for(i=1;i<=n;i++)
		printf("%d ",a[i]);
	return 0;
	
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  ll n, q; cin >> n >> q;
  string s; cin >> s;
  Vi L(q), R(q);
  REP(i, q) cin >> L[i] >> R[i];
  Vi cum_sum(n);
  //cum_sum[i + 1] = s[0]-s[i+1]の中の'AC'の個数
  cum_sum[0] = 0;
  REP(i, n - 1){
    (s[i] == 'A' && s[i+1] == 'C') ? cum_sum[i + 1] = cum_sum[i] + 1 : cum_sum[i + 1] = cum_sum[i];
  }
//  REP(i, n) cout << "i = " << i << ", " << cum_sum[i] << endl;
  REP(i, q){
    cout << cum_sum[R[i] - 1] - cum_sum[L[i] - 1] << endl;
  }

}


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

using namespace std;

int main()
{
	string s;
	bool flag = false;
	cin >> s;
	int arr[27] = {0};
	for(int i = 0; i < s.size(); i++) {
	    arr[s[i] - 'a']++;
	}
	for(int i = 0; i < 27; i++) {
		if(arr[i] % 2 != 0)
		{
		 	flag = true;
		 	break;
		}
	}

	if(flag) {
		puts("No");
	}
	else
		puts("Yes");

	return 0;
}	

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for (int i = (a); i < (int)(n); i++)
#define repc(i, a, n) for (int i = (a); i <= (int)(n); i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init)                                              \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
#define DBG(str) cerr << (str) << endl;
bool isPrime(int n) {
  // returns whether n is prime number or not
  // n should be in range [0, lim].
  // to see detail, search "Sieve of Eratosthenes"
  static int lim = 1e5;
  static bool done = false;
  static vector<bool> isp(lim + 1, 1);
  if (!done) {
    isp[0] = isp[1] = false;
    for (int i = 2; i <= lim; i++) {
      if (isp[i]) {
        for (int j = i + i; j <= lim; j += i) {
          isp[j] = false;
        }
      }
    }
    done = true;
  }
  return isp[n];
}

int main() {
  int n;
  cin >> n;
  ll sum = 0;

  vector<int> p(n, 0);
  int i = 0;
  int index = 0;
  while (1) {
    if (isPrime(i) && i % 5 == 1) {
      p[index] = i;
      sum += i;
      index++;
    }
    i++;
    if (index == n)
      break;
  }

  rep(i, 0, n) cout << p[i] << " ";

  return 0;
}


Measured memory_bytes: 256
def isStorage(max_shelf):
	i,cur_shelf,num = 0,0,1
	while i < n:
		if num > m:
			return False
		if cur_shelf + book[i] > max_shelf:
			num += 1
			cur_shelf = 0
		else:
			cur_shelf += book[i]
			i += 1
	else:
		return True
			
while 1:
	m,n = map(int,raw_input().split())
	if m==0: break
	book = [int(raw_input()) for i in range(n)]
	max_shelf = len = sum(book)
	while len:
		len /= 2
		max_shelf -= len if isStorage(max_shelf) else -len
	max_shelf += 10
	while isStorage(max_shelf-1):
		max_shelf -= 1
	print max_shelf

Measured memory_bytes: 4240
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
#define MAXN 100005
#define LL long long
#define INF 1e18
int N,M,S,T,u,v;
LL a,b,f=1e15,ans[MAXN];
LL Min(LL x,LL y)
{
	if(x>y) return y;
		return x;
}
struct graph{
	int cnt,head[MAXN],vis[MAXN];
	LL dis[MAXN];
	struct Edge
	{
		int next,to;LL dis;
	}edge[2*MAXN];
	queue<int> q;
	
	void addedge(int from,int to,LL dis)
	{
		edge[++cnt].next=head[from];
		edge[cnt].to=to;
		edge[cnt].dis=dis;
		head[from]=cnt;
	}
	
	void spfa(int s)
	{
		for(int i=1;i<=N;i++)
			dis[i]=INF;
		memset(vis,0,sizeof(vis));
		q.push(s); vis[s]=1; dis[s]=0;
		while(!q.empty())
		{
			int x=q.front(); q.pop();
			vis[x]=0;
			for(int i=head[x];i;i=edge[i].next)
			{
				int to=edge[i].to;
				if(dis[to]>dis[x]+edge[i].dis)
				{
					dis[to]=dis[x]+edge[i].dis;
					if(!vis[to]) q.push(to),vis[to]=1;
				}
			}
		}
	}
}g1,g2;
int main()
{
	scanf("%d %d %d %d",&N,&M,&S,&T);
	for(int i=1;i<=M;i++)
	{
		scanf("%d %d %lld %lld",&u,&v,&a,&b);
		g1.addedge(u,v,a); g1.addedge(v,u,a);
		g2.addedge(v,u,b); g2.addedge(u,v,b);
	}
	g1.spfa(S); g2.spfa(T);
	ans[N+1]=INF;
	for(int i=N;i>=1;i--) ans[i]=Min(ans[i+1],g1.dis[i]+g2.dis[i]);
	for(int i=1;i<=N;i++)
		printf("%lld\n",f-ans[i]);
	return 0;
}

Measured memory_bytes: 12032
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        int[] hen = new int[101];
        Scanner scanner = new Scanner(System.in);

        int ans1 = scanner.nextInt();
        int ans2 = scanner.nextInt();
        int ans3 = scanner.nextInt();

        if(ans1 == ans2){
            if(ans1 == ans3){
                System.out.println("1");
            }else{
                System.out.println("2");
            }
        }else if(ans2 == ans3){
            System.out.println("2");
        }else if(ans1 == ans3){
            System.out.println("2");
        }else{
            System.out.println("3");
        }

    }
}


Measured memory_bytes: 9684
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MAX = 8000000;

void solve(int n, int m) {
    int cnt = 0, ans = n;
    vector<bool> v(MAX, true);
    for (long long i = n; i < MAX; i++) {
        if (v[i]) {
            cnt++;
            for (int j = i; j < MAX; j += i) v[j] = false;
        }
        if (cnt == m) { ans = i; break; }
    }
    
    for (int i = ans; i < MAX; i++) {
        if (v[i]) { ans = i; break; }
    }
    cout << ans << endl;
    return;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    while (cin >> n >> m) {
        if (n && m) solve(n, m);
    }
    return 0;
}


Measured memory_bytes: 4092
/**
 *    author:  tourist
 *    created: 25.01.2020 20:28:32       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<vector<int>> dist(n, vector<int>(n, -1));
  for (int start = 0; start < n; start++) {
    vector<int> que(1, start);
    dist[start][start] = 0;
    for (int b = 0; b < (int) que.size(); b++) {
      for (int u : g[que[b]]) {
        if (dist[start][u] == -1) {
          que.push_back(u);
          dist[start][u] = dist[start][que[b]] + 1;
        }
      }
    }
  }
  int ans = 0;
  if (k % 2 == 0) {
    for (int v = 0; v < n; v++) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        cnt += (dist[v][i] <= k / 2);
      }
      ans = max(ans, cnt);
    }
  } else {
    for (int v = 0; v < n; v++) {
      for (int u : g[v]) {
        int cnt = 0;
        for (int i = 0; i < n; i++) {
          cnt += (min(dist[v][i], dist[u][i]) <= k / 2);
        }
        ans = max(ans, cnt);
      }
    }
  }
  cout << n - ans << '\n';
  return 0;
}


Measured memory_bytes: 16128
/*
2020-04-22
atcoder ABC
D - String Formation / 
*/

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

string reversedString(string s) {
    reverse(s.begin(), s.end());
    return s;
}

int main() {
    //変数定義, 入力処理
    // vector<vector<int>> data(3, vector<int>(4)); //二次元配列
    string S, reveresedS, leftSide = "", rightSide = "";
    bool isReversed = false;
    int Q;
    cin >> S >> Q;
    reveresedS = reversedString(S);

    //処理
    rep(i, Q) {
        int t, f;
        char c;
        cin >> t;
        // cout << "left: " << leftSide << endl;
        // cout << "right: " << rightSide << endl;
        
        if (t == 1) {
            isReversed = !isReversed;
            continue;
        } else {
            cin >> f >> c;
            if (f == 1) {
                if (!isReversed) {
                    leftSide = c + leftSide;
                } else {
                    rightSide = rightSide + c;
                }
            } else {
                if (isReversed) {
                    leftSide = c + leftSide;
                } else {
                    rightSide = rightSide + c;
                }
            }
        }
    }
    if (!isReversed) {
        cout << leftSide + S + rightSide << endl;
    } else {
        reverse(leftSide.begin(), leftSide.end());
        reverse(rightSide.begin(), rightSide.end());
        cout << rightSide + reveresedS + leftSide << endl;
    }
    return 0;
}


Measured memory_bytes: 1516
#include<iostream>
#include<algorithm>
#define MAX 120
#define INFTY (1 << 21)
#define WHITE -1
#define GRAY 0
#define BLACK 1

using namespace std;

int A[MAX], M[MAX][MAX];
int n;
int color[MAX], d[MAX], p[MAX];

void prim(){
    int u, mini;
    
    for(int i=0; i<n; i++){
        color[i] = WHITE;
        d[i] = INFTY;
        p[i] = -1;
    }//すべて初期化する
    
    d[0] = 0;
    
    while(1){
        mini = INFTY;
        
        for(int i=0; i<n; i++){
            if( color[i] != BLACK && d[i] < mini){
                mini = d[i];
                u=i;
            }
        }
        
        if(mini == INFTY){
            break;
        }
        
        color[u] = BLACK;
        
        for(int v=0; v<n; v++){
            if(color[v] != BLACK && M[u][v] != -1){
                if(M[u][v] < d[v]){
                    d[v]  = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
        
    }
    
    int sum = 0;
    
    for(int i=0; i<n; i++){
        if(p[i] != -1){
            sum = sum + M[i][p[i]];
        }
    }
    cout << sum << endl;
}

int main(){
    
    cin >> n;
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j] = -1;
        }
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin >> M[i][j];
        }
    }
    
    prim();
    
    /*for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cout << M[i][j] << " ";
        }
        cout << endl;
        
    }*/
    
    return 0;
}


Measured memory_bytes: 3140
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
    long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    bool answer = true;
    long numberMemo = nums[0]-1;

    for(int i = 1; i < n; i++)
    {
      if(nums[i] < numberMemo) answer = false;
      else if(nums[i] > numberMemo) numberMemo = nums[i]-1;
      else numberMemo = nums[i];
    }

		Console.WriteLine(answer?"Yes":"No");
	}
}

Measured memory_bytes: 25052
class Combination:
    """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""
    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
        self.MOD = MOD

    def inverse(self, k):
        """kの逆元を求める O(1)"""
        return (self.inv_fact[k] * self.fact[k - 1]) % self.MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD

    def combination2(self, k, r):
        """kCrを求める O(r)
        kが大きいが、r <= nを満たしているときに使用
        """
        if k < r:
            return 0
        res = 1
        for l in range(r):
            res *= (k - l)
            res %= self.MOD
        return (res * self.inv_fact[r]) % self.MOD


k = int(input())
s = input()
MOD = 10 ** 9 + 7
comb = Combination(2 * 10 ** 6, MOD)

ans = 0

box = len(s)
for top in range(k + 1):
    ptn = pow(26, top, MOD)
    
    ball = k - top
    ptn *= comb.combination(ball + box - 1, ball) 
    ptn %= MOD
    ptn *= pow(25, ball, MOD)
    ptn %= MOD
    ans += ptn
    ans %= MOD
print(ans % MOD)

Measured memory_bytes: 166064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

// Debug Vector
template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------

int rate[9];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
////    CLion Standard Input for DEBUG
////    --------------------------------------------------------------------------
//    ifstream in("./in.txt");
//    cin.rdbuf(in.rdbuf());
////    ------------------------------------------------------------------------

    int n;
    cin >> n;
    int a;
    for(int i = 0; i < n; i++){
        cin >> a;

        if(1 <= a && a <= 399){
            rate[0]++;
        }
        else if(400 <= a && a <= 799){
            rate[1]++;
        }
        else if(800 <= a && a  <= 1199){
            rate[2]++;
        }
        else if(1200 <= a && a <= 1599){
            rate[3]++;
        }
        else if(1600 <= a && a <= 1999){
            rate[4]++;
        }
        else if(2000 <= a && a  <= 2399){
            rate[5]++;
        }
        else if(2400 <= a && a <= 2799){
            rate[6]++;
        }
        else if(2800 <= a && a <= 3199){
            rate[7]++;
        }else{
            rate[8]++;
        }
    }

    int res = 0;
    for(int i = 0; i < 8; i++){
        if (rate[i]) res++;
    }

    if(res == 0 && rate[8]) cout << 1 << endl;
    else cout << res << endl;
    int max = res + rate[8];
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#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 rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int i, j;
	int n;

	cin >> n;

	if (n == 25) {
		cout << "Christmas" << endl;
	}
	else if (n == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (n == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (n == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}

















	getchar();
	getchar();
	return 0;
}

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

#define MAX 100001

typedef struct{
  int parnodnm;
  int depth;
  int typ;
  int chilnm;
  int *child;
  // int child[100];
}Node;

Node T[MAX];

int calcudepth(int u){
  int d = 0;
  while(T[u].parnodnm != -1){
    u = T[u].parnodnm;
    d++;
  }
  return d;
}

int main(){
  int nm, i, j, nodnm;
  int D[MAX];

  scanf("%d", &nm);

  for(i = 0; i < nm; i++) T[i].parnodnm = -1; //parnod initialize
  
  for(i = 0; i < nm; i++){
    scanf("%d", &nodnm);
    scanf("%d", &T[nodnm].chilnm);
    if(T[nodnm].chilnm > 0){
      T[nodnm].child = (int *)malloc(T[nodnm].chilnm * sizeof(int));
      T[nodnm].typ = 2;  //0:root 1:leaf 2:internal node 
      for(j = 0; j < T[nodnm].chilnm; j++){
	scanf("%d", &T[nodnm].child[j]);
	T[T[nodnm].child[j]].parnodnm = nodnm;
      }
    }
    else if(T[nodnm].chilnm == 0) T[nodnm].typ = 1;
  }

  for(i = 0; i < nm; i++)
    if(T[i].parnodnm == -1) T[i].typ = 0;

  for(i = 0; i < nm; i++) T[i].depth = calcudepth(i);

  for(i = 0; i < nm; i++){
    if(T[i].typ == 0)
      printf("node %d: parent = %d, depth = %d, root, ", i, T[i].parnodnm, T[i].depth);
    else if(T[i].typ == 1)
      printf("node %d: parent = %d, depth = %d, leaf, ", i, T[i].parnodnm, T[i].depth);
    else if(T[i].typ == 2)
      printf("node %d: parent = %d, depth = %d, internal node, ", i, T[i].parnodnm, T[i].depth);
    printf("[");
    if(T[i].chilnm > 0){ 
    for(j = 0; j < T[i].chilnm-1; j++) printf("%d, ", T[i].child[j]);
    printf("%d]\n", T[i].child[j]);
    }
    else printf("]\n");
  }
   
  return 0;
}



Measured memory_bytes: 4512
def has_duplicates(seq):
    return len(seq) != len(set(seq))

N = int(input())
W = [input() for i in range(N)]
flag = True
#print(W)
#print(W[0][0])

if has_duplicates(W) == True:
    flag = False


for i in range(N - 1):
    if W[i][-1:] != W[i+1][0]:
        flag = False

if flag == True:
    print("Yes")
else:
    print("No")  

Measured memory_bytes: 3064
// ARC109
// A - ABC333

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

int A, B;

bool solve() { return (A * B) % 2 == 1; }

int main() {
    cin >> A >> B;

    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;

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

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

int main(void) {
  int i,j;
  int n,t;
  while(1){
    cin>>t;
    if(t==0)break;
    cin>>n;
    int sum=0;
    rep(i,n){
      int s,f;
      cin>>s>>f;
      sum+=f-s;
    }
    if(t<=sum)
      cout<<"OK"<<endl;
    else
      cout<<t-sum<<endl;
  }
}

Measured memory_bytes: 3076
n,m,k = map(int,input().split())
num = [1 for _ in range(n)]
pre = [i for i in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  num[a] += 1
  num[b] += 1
  A = [a]
  B = [b]
  la = 1
  lb = 1
  while a != pre[a]:
    a = pre[a]
    A.append(a)
    la += 1
  while b != pre[b]:
    b = pre[b]
    B.append(b)
    lb += 1
  #print(a,b)
  if a != b:
    if la > lb:
      pre[b] = a
      for aa in A:
        pre[aa] = a
      for bb in B:
        pre[bb] = a
    else:
      pre[a] = b
      for aa in B:
        pre[aa] = b
      for bb in B:
        pre[bb] = b
root = []
cnt = [0 for _ in range(n)]
for i in range(n):
  I = int(i)
  while I != pre[I]:
    I = pre[I]
  root.append(I)
  cnt[I] += 1
#print(pre)
#print(root)
#print(cnt)
ans = []
for i in range(n):
  ans.append(cnt[root[i]]-num[i])
#print(ans)
for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  if root[a] == root[b]:
    ans[a] -= 1
    ans[b] -= 1
print(' '.join(map(str,ans)))

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n;
  cin >> n;

  vector< string > strs(n);
  string s;
  for(int i=0;i<n;i++){
    cin >> s;
    sort(s.begin(),s.end());
    strs[i] = s;
  }
  sort(strs.begin(),strs.end());
  
  int64_t totalCount = 0;
  int64_t count = 0;
  s = strs[0];
  for(int i=1;i<n;i++){
    if(strs[i]==s){
      count++;
    }
    else{
      if(count>=1){
        totalCount += (count+1)*(count)/2;
      }
      count = 0;
    }
    s = strs[i];
  }
  if(count>=1){
     totalCount += (count+1)*(count)/2;
  }

  cout << totalCount << endl;

  return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const ll N = 100005;
const ll INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

ll n, k, h[N], dp[N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> h[i];
	
	fill(dp, dp + n, INF);

	dp[0] = 0;
	for(int i = 1; i < n; i++)
		for(int j = 1; j <= k && i >= j; j++)
			dp[i] = min(dp[i], dp[i - j] + llabs(h[i] - h[i - j]));

	cout << dp[n - 1] << endl;
}




Measured memory_bytes: 1792
import java.util.Scanner;
 
class Main {
 
	public static void main(String[] args) {
 
		Scanner scan = new Scanner(System.in);
		int a= scan.nextInt();
		int b= scan.nextInt();
		scan.close();
 
		if( (1<=a && a<10) && (1<=b && b<10) )
		System.out.println(a*b);
		else
		System.out.println(-1);
	}
}

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

class C {
    static class T implements Comparable<T>{
        long A, B, S;

        public T(long a, long b) {
            A = a;
            B = b;
            S = A + B;
        }

        @Override
        public int compareTo(T o) {
            return -Long.compare(S, o.S);
        }
    }

    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final T[] ts = new T[N];
        final long[] B = new long[N];
        for(int i = 0; i < N; i++)
            ts[i] = new T(sc.nextLong(), sc.nextLong());
        Arrays.sort(ts);
        long ans = 0;
        for(int i = 0; i < N; i++)
            if(i % 2 == 0)
                ans += ts[i].A;
            else
                ans -= ts[i].B;
        System.out.println(ans);
    }
}
public class Main {
    public static void main(String... args) {
        C.main();
    }
}


Measured memory_bytes: 96244
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
      
       if(B/A>C) {
    	   System.out.println(C);
       }
       else {
		System.out.println(B/A);
       }
	}

}


Measured memory_bytes: 22996
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(a, b, c, d):
    print(max(a * c, a * d, b * c, b * d))


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    a, b, c, d = map(int, input().split())
    # Ai = [int(i) for i in input().split()]
    # Bi = [int(i) for i in input().split()]
    # ABi = [[int(i) for i in input().split()] for _ in range(N)]
    solve(a, b, c, d)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


Measured memory_bytes: 9148
import * as fs from 'fs';

function Picker(input) {
  var lines = input.split('\n');
  var fields = lines.reduce(function(all, line) { return all.concat(line.split(' ')); }, []);
  var p = 0;

  return {
    int: function() {
      return parseInt(fields[p++], 10);
    },
    float: function() {
      return parseFloat(fields[p++]);
    },
    str: function() {
      return fields[p++];
    }
  };
}

const input = fs.readFileSync("/dev/stdin", "utf8");
const pick = Picker(input);

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

var [n, k] = [pick.int(), pick.int()];
console.log(n - k + 1);

Measured memory_bytes: 7500
n=int(input())
if n==1:
    print('a')
    exit()
ans=['a']
al=list('abcdefghijklmnopqrsruvwxyz')
for i in range(n-1):
    tmp=[]
    for j in ans:
        sn=len(set(j))
        for k in range(sn+1):
            tmp.append(j+al[k])  
    ans=tmp
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 56284
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int n;
	cin >> n;
	int a = n / 100, b = n % 100;
	bool flag1, flag2;
	flag1 = (1 <= a && a <= 12);
	flag2 = (1 <= b && b <= 12);
	if(flag1 && flag2)cout << "AMBIGUOUS" << endl;
	else if(flag1 && !flag2)cout << "MMYY" << endl;
	else if(!flag1 && flag2)cout << "YYMM" << endl;
	else cout << "NA" << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

set<int> s;
int a[3];

int main(int argc, const char * argv[]) {
  cin >> a[0] >> a[1] >> a[2];
  s.insert(a[0]);
  s.insert(a[1]);
  s.insert(a[2]);

  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int64_t x=1;
  for(int i=0;i<n;i++){
    int64_t a;
    cin>>a;
    if(a==0){
      x=0;
      break;
    }
    if(x<=1000000000000000000/a){
      if(x!=-1){
        x*=a;
      }
    }
    else{
      x=-1;
    }
  }
  cout<<x<<endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//
int def(ll a){
  string c = to_string(a);
  ll bc = c.length();
  ll n = bc/2ll;
  rep(i,n){
    if(c[i] != c[bc-i-1]) return 0;
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  string s;
  cin >> s;
  ll ans=0;
  ll ans2=0;
  rep(i,s.length()){
    if(i%2==0){
    if(s[i]=='0'){
      ans++;
    }else{
      ans2++;
    }
    }else{
    if(s[i]=='0'){
      ans2++;
    }else{
      ans++;
    }
    }
  }
  pri(min(ans,ans2));
  return 0;
}


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

int main() {

  int N, K;
  cin >> N >> K;

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

  sort(H.begin(), H.end(), std::greater<int>());

  long long answer = 0;

  for (int i = K; i < N; i++) {
    answer += H[i];
  }

  cout << answer << endl;

}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
// Description: グラフの型定義(これは最小費用流)
// Verifyed: Many Diffrent Problem 

//Appropriately Changed
using edge=struct{int to;};
using G=vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph,int from,int to){ 
	graph[from].push_back({to});
	graph[to].push_back({from});
}

ll num[100010];
ll childsum[100010];
ll childup[100010];
ll childin[100010];

#define error(args...) { vector<string> _debug = split(#args, ',');err(begin(_debug), args);}

vector<string> split(const string& s, char c){
	vector<string> v;stringstream ss(s);string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {cerr << endl;}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a,Args... args){
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << " ",err(++it, args...);
}

bool dfs(const auto &graph,int v,int p){
	bool leaf=true;
	bool ret=true;

	childsum[v]=0LL;

	vector<ll> ary;

	for(auto &e:graph[v]){
		if(e.to==p) continue;
 		ret&=dfs(graph,e.to,v);
 		ary.push_back(childup[e.to]);
		childsum[v]+=childup[e.to];
		leaf=false;
	}

	if(leaf){
		childup[v]=num[v];
		return true;
	} 
	

	childin[v]=childsum[v]-num[v];
	childup[v]=num[v]-childin[v];
	if(childin[v]<0 or childup[v] <0) ret&=false;

	sort(rbegin(ary),rend(ary));
	if(min(childsum[v]/2LL,childsum[v]-ary[0])<childin[v]) ret&=false;
	
	return ret;
}


int main(void){
	int n;
	cin >> n;
	rep(i,n) cin >> num[i];

	G graph(n);

	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		add_edge(graph,a-1,b-1);
	}

	int root=-1;
	rep(i,n) if(int(graph[i].size())==1) root=i;

	bool ok=dfs(graph,root,-1);

	ok&=(childup[root]==num[root]);

	if(ok)
		puts("YES");
	else
		puts("NO");

	return 0;
}

Measured memory_bytes: 22912
// +build ignore
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	N := sc.nextInt()
	M := sc.nextInt()

	m := N / 2
	if N%2 == 0 {
		for i := 0; i < M; i++ {
			if i < m/2 {
				fmt.Println(m-i, m+i+1)
			} else {
				fmt.Println(m-i-1, m+i+1)
			}
		}
	} else {
		for i := 0; i < M; i++ {
			fmt.Println(m-i, m+i+1)
		}
	}

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 3288
#define taskname ""
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxN = 1e5 + 1;
const ll mod1 = 1e9 + 7;
const ll mod2 = 1e9 + 9;
const ll base = 31;

int n;
string a[maxN];
ll freq[maxN][26];

ll hs[maxN];
ll ht[maxN];

int id[maxN];

ll res = 0;

void prep()
{
    memset(freq, 1, sizeof(freq));
    for (int i = 1; i <= n; ++i)
    {
        id[i] = i;
        for (auto &c: a[i])
        {
            ++freq[i][c - 'a'];
        }
        hs[i] = freq[i][0];
        ht[i] = freq[i][0];
        for (int j = 1; j < 26; ++j)
        {
            hs[i] = (hs[i] * base + freq[i][j]) % mod1;
            ht[i] = (ht[i] * base + freq[i][j]) % mod2;
        }
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    prep();
    sort(id + 1, id + n + 1, [](int x, int y)
         {
             return hs[x] < hs[y];
         });
    ll cnt = 1;
    for (int i = 2; i <= n; ++i)
    {
        if (hs[id[i]] == hs[id[i - 1]] && ht[id[i]] == ht[id[i - 1]])
        {
            ++cnt;
        }
        else
        {
            res += (cnt - 1) * cnt / 2;
            cnt = 1;
        }
    }
    res += (cnt - 1) * cnt / 2;
    cout << res;
    return 0;
}


Measured memory_bytes: 28032
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba

def run():
    a = input()
    b = a.lower()
    if a == b:
        print('a')
    else:
        print('A')

if __name__ == "__main__":
    run()

Measured memory_bytes: 9096
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  map<long long, long long> mp;
  long long sum = 0;
  ++mp[sum];
  while (n--) {
    int a; cin >> a;
    sum += a;
    ++mp[sum];
  }
  long long ans = 0;
  for (auto pr : mp) ans += pr.second * (pr.second - 1) / 2;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;

int main() {
	int n;
	cin >> n;
	vi a(n + 1);
	rep2(i, 1, n) {
		cin >> a[i];
	}
	vector<bool> x(n + 1, false);
	int y = 1;
	int ans = 0;
	rep(i, 0, n) {
		x[y] = true;
		if (x[2]) {
			break;
		}
		y = a[y];
		ans++;
	}
	if (x[2]) {
		cout << ans << endl;
	}
	else {
		cout << "-1\n";
	}
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  char s[200010],t[200010];
  int i,c=0;
  scanf("%s %s",s,t);
  for(i=0;s[i];i++){
    if(s[i]-t[i])c++;
  }
  printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 2120
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    reep(i,1,10){
        reep(j,1,10){
            cout<<i<<"x"<<j<<"="<<i*j<<endl;
        }
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
      cout<<fixed<<setprecision(20);
    mainmain();
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 100001


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n , a , s = 0;
    cin >> n >> a;
    vector<ll> vec;
    ll v;
    for (int i = 0; i < n; i++) {
        cin >> v;
        vec.pb(v);
    }
    sort(all(vec));
    int ans = 0;
    for (int i = 0; i < n; i++) {
        s += vec[i];
        if (s <= a) {
            ans++;
        }
        if (i == n - 1 && s < a) {
            if (ans) ans--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256