akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 100
#define INFTY 2000000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
void bfs(void);
void enqueue(int);
int dequeue();
int isEmpty();
int n,M[MAX][MAX];
int head=0,tail=0,q[MAX];

void bfs(){
  int color[MAX],d[MAX],i,j;

  for(i=0;i<n;i++){
    color[i]=WHITE;
    d[i]=INFTY;

  }
  color[0]=GRAY;
  d[0]=0;
  enqueue(0);

  while(!isEmpty()){
    int u;
    u=dequeue();

    for(j=0;j<n;j++){
      if(M[u][j]&&color[j]==WHITE){
	color[j]=GRAY;
	d[j]=d[u]+1;
	enqueue(j);
      }
    }

    color[u]=BLACK;
  }

  for(i=0;i<n;i++){
    printf("%d ",i+1);
    if(d[i]==INFTY) printf("-1\n");
    else printf("%d\n",d[i]);
  } 
}

void enqueue(int tmp){
  q[tail]=tmp;
  if(tmp+1==MAX) tail=0;
  else tail++;
}

int dequeue(){
  int tmp=q[head];
  if(head+1==MAX) head=0;
  else head++;
  return tmp;
}

int isEmpty(){
  if(head==tail) return 1;
  else return 0;
}

int main()
{
  int u,k,v,i,j;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  bfs();

  return 0;
}

Measured memory_bytes: 636
package main

import (
  "fmt"
)

func main() {
  var a, b, c int
  
  fmt.Scanf("%d %d %d", &a, &b, &c)
  
  ans := "NO"
  if b - a == c - b {
    ans = "YES"
  }
  fmt.Printf("%s", ans)
}

Measured memory_bytes: 1832
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
int main() {
    int N;
    int ans = 0;
    cin >> N;
    vector<long long>H(N);
    rep(i, 0, N){
        cin>>H[i];
    }
    int count = 0;
    long long l = 0;
    rep(i, 0, N-1){
        l = H[i];
        count++;
        if (l < H[i+1]){
            count = 0;
            continue;
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
    return 0;
}


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

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


return 0;
}

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

int main() {
  string raw;
  cin >> raw;
  string initial = raw.substr(0, 1);
  string last = raw.substr(raw.length() - 1, 1);
  string middle = raw.substr(1, raw.length() - 2);
  cout << initial + to_string(raw.length() - 2) + last << endl;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ll>ans; 
    while(true){
        cin>>n;
        if(n==0)break;
        vector<ll> a(n);
        double sum=0;
        rep(i,n){
            cin>>a[i];
            sum+=a[i];
        }
        sum=sum/n;
        ll count=0;
        rep(i,n){
            if(a[i]<=sum){
                count++;
            }
        }
        ans.push_back(count);
    }
    rep(i,ans.size()){
        cout<<ans[i]<<"\n";
    }
}



Measured memory_bytes: 3264
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main(){

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

  int ans = 0;
  for(int i = 0; i < N; i++){
    int c;
    cin >> c;
    a[i] -= c;
    if(a[i] > 0){
      ans += a[i];
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
  
  
 
  rep(i,1,n+1){
   ll ans=0;
    ll m=sqrt(double(i))+1.0;
    rep(x,1,m+1){
      rep(y,1,m+1){
        ll w=i-(x*x+y*y+x*y);
        w+=(x+y)*(x+y)/4;
        if(w<0) continue;
        ll z=-(x+y)/2+sqrt(double(w));
        if(z>0&&x*x+y*y+z*z+x*y+y*z+z*x==i) ans++;
        z=-(x+y)/2-sqrt(double(w));
        if(z>0&&x*x+y*y+z*z+x*y+y*z+z*x==i) ans++;
      }
    }
    cout << ans << endl;
  }
  
  
}

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

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
map<pair<ll,ll>,pair<ll,ll>> M;
int Z;
ll p2[202020];
const ll mo=1000000007;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	FOR(i,201010) p2[i+1]=p2[i]*2%mo;
	
	
	cin>>N;
	FOR(i,N) {
		ll X,Y;
		cin>>X>>Y;
		if(X==0 && Y==0) Z++;
		else if(X==0) {
			M[{0,0}].first++;
		}
		else if(Y==0) {
			M[{0,0}].second++;
		}
		else {
			if(Y<0) X=-X,Y=-Y;
			ll g=__gcd(abs(X),abs(Y));
			X/=g;
			Y/=g;
			if(X<0) M[{Y,-X}].first++;
			else M[{X,Y}].second++;
			
		}
	}
	ll ret=1;
	FORR(m,M) {
		ll a=p2[m.second.first]+p2[m.second.second]-1;
		ret=(ret*a)%mo;
	}
	
	cout<<(ret+Z+mo-1)%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 20708
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int x, a, b; cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b)) {
    outl("A");
  } else {
    outl("B");
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,x,m,ans=0; cin>>n>>x>>m;
    vector<ll> me(0);
    set<ll> st;
    ll cur=x%m;
    rep(_,m+1){
        if(st.count(cur)){
            break;
        }
        st.insert(cur);
        me.push_back(cur);
        cur=cur*cur%m;
    }
    ll idx=0,N=me.size();
    rep(i,m+1){
        if(cur==me[i]){
            idx=i;
            break;
        }
        ans+=me[i];
    }
    if(n<idx){
        ll aa=0;
        rep(i,n) aa+=me[i];
        cout<<aa<<endl;
        return 0;
    }
    ll roop=N-idx;
    ll roopsum=0;
    for(int i=idx;i<N;i++) roopsum+=me[i];
    ans+=roopsum*((n-idx)/roop);
    rep(i,(n-idx)%roop) ans+=me[idx+i];
    cout<<ans<<endl;
}

Measured memory_bytes: 5988
#include<stdio.h>
#include<string.h>
int main(){
  char s[1010],*c,d[1000][33];
  int i,r,max,maxl,mi,ml,l,b[1000]={0};
  fgets(s,1001,stdin);
  c=strtok(s," \n");
  maxl=strlen(c);
  max=1;
  b[ml=mi=0]=r=1;
  while(c=strtok(NULL," \n")){
    for(i=0;i<r;i++){
      if(strcmp(d[i],c)==0)break;
    }
    if(i-r){
      b[i]++;
      if(b[i]>max)max=b[mi=i];
    }
    else {
      l=strlen(c);
      if(maxl<l){
	ml=r;
	maxl=l;
      }
      b[i]=1;
      strcpy(d[r++],c);
    }
  }
  printf("%s %s\n",d[mi],d[ml]);
  return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2 - x1;
  int dy = y2 - y1;

  int x3 = x2 + -dy;
  int y3 = y2 + dx;

  int x4 = x3 + -dx;
  int y4 = y3 + -dy;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++)
			h[i] = sc.nextInt();

		sc.close();
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (k <= h[i])
				ans++;
		}

		System.out.println(ans);

	}
}

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

int main(void){
    int N;
    cin>>N;
    ll cnt=0;
    bool over=false;
    for(int i=1;i<N;i++){
        over=false;
        for(int j=1;j<(N/i)+1;j++){
            if(i*j<N){
                cnt++;
            }
            else{
                over=true;
                continue;
            }
        }
        if(over==true){
            continue;
        }
    }
    cout<<cnt<<endl;
   
   
}


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

int main() {
  int N,A,B;
  cin >>N >> A >> B;  
  int a=0;
  int b=0;
  int c=0;
  for(int i=0;i<N;i++){
    int p;
    cin >> p ;
    if (p<=A){
      a++;
    }
    else if (p<=B){
      b++;
    }
    else {
      c++;
    }
  }
      cout << min(a,min(b,c))<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair < int, int >
#define pll pair < ll, ll >
#define pb push_back
#define maxn 100005
#define mod 1000000007
using namespace std;

int main()
{
    int n;

    cin >> n;

    ll sum = 0;

    for(int i = 1; i <= n; i++){
        if(i % 5 && i % 3) sum += i;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

#define MAX_NUM 1000000

// プロセス構造体
typedef struct {
    char name[11];
    int time;
    int end;
} proc;

// キューの定義
static proc queue[MAX_NUM];
// キューの先頭
int head = 0;
// キューの末尾
int tail = 0;

// エンキュー
void enq(proc p)
{
    tail++;
    queue[tail - 1] = p;
}

// デキュー
proc deq(void)
{
    head++;
    return queue[head - 1];
}

int main(void)
{
    int n;
    int q;
    proc work;
    int elapsed;
    
    // 入力
    scanf("%d %d", &n, &q);
    
    for ( int i = 0; i < n; i++ ) {
        scanf("%s %d", &work.name[0], &work.time);
        enq(work);
    }
    
    // プロセス処理開始
    elapsed = 0;

    while ( head != tail ) {
        work = deq();
        work.time -= q;
        elapsed += q;
        if ( work.time > 0 ) {
            enq(work);
        } else {
            if ( work.time < 0 ) {
                elapsed += work.time;
            }
            work.end = elapsed;
            printf("%s %d\n", work.name, work.end);
        }
    }

    return 0;
}


Measured memory_bytes: 5464
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve()
{
    int n,di,dj,c=0,d=0;
    cin>>n;
    while(n--){
        cin>>di>>dj;
        if(di==dj) c++;
        else{
            if(c==3) d=1;
            else c=0;
        }
    }
    if(d==1||c>=3){
        cout<<"Yes"<<endl;return;
    }
    cout<<"No"<<endl;return;
}
int main()
{
    solve();
}

Measured memory_bytes: 3632
import java.math.BigInteger;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		long N = sc.nextLong();
		
		BigInteger K = BigInteger.valueOf(N);
		BigInteger b = BigInteger.ZERO;
		for (char c: S.toCharArray()) {
			if (c == '1') {
				b = b.add(BigInteger.ONE);
			} else {
				long val = Long.valueOf(String.valueOf(c));
				BigInteger tmp = BigInteger.valueOf(val).pow(100_000_0);
				BigInteger tmp2 = BigInteger.valueOf(val).pow(10);
				b = b.add(tmp.multiply(tmp).multiply(BigInteger.valueOf(5L).multiply(tmp2)));
			}
			
			if (b.compareTo(K) >= 0) {
				System.out.println(c);
				return;
			}
		}
		
	}
	
}

Measured memory_bytes: 188312
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int x[9];
  REP(i,9) cin>>x[i];
  int d1,d2,d3,c1,c2,c3;
  d1 = x[0];
  d2 = x[1];
  d3 = x[2];
  c1 = 0;
  c2 = x[3] - d1;
  c3 = x[6] - d1;
  if(x[4]==c2+d2 && x[5]==c2+d3 && x[7]==c3+d2 && x[8]==c3+d3) {
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

vector<int> V[100010];
bool visited[100010];
int parents[100010];

typedef tuple<int, int, int> state; // now, d, from

int main () {
  int N;
  cin >> N;
  for (auto i = 0; i < N-1; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  stack<state> S;
  S.push(state(0, 0, -1));
  int cut;
  int D;
  fill(visited, visited+N, false);
  while (!S.empty()) {
    int now = get<0>(S.top());
    int d = get<1>(S.top());
    int from = get<2>(S.top());
    S.pop();
    if (!visited[now]) {
      // cerr << "now = " << now << ", d = " << d << endl;
      visited[now] = true;
      parents[now] = from;
      if (now == N-1) {
        D = d;
        break;
      }
      for (auto x : V[now]) {
        if (!visited[x]) {
          S.push(state(x, d+1, now));
        }
      }
    }
  }
  stack<state> SS;
  SS.push(state(N-1, 0, parents[N-1]));
  int cnt = 0;
  cut = N-1;
  for (auto i = 0; i < (D-1)/2; ++i) {
    cut = parents[cut];
  }
  fill(visited, visited+N, false);
  while (!SS.empty()) {
    int now = get<0>(SS.top());
    int d = get<1>(SS.top());
    SS.pop();
    if (!visited[now]) {
      visited[now] = true;
      cnt++;
      for (auto x : V[now]) {
        if (!visited[x] && x != parents[cut]) {
          SS.push(state(x, d+1, now));
        }
      }
    }    
  }
  int su = cnt - 1;
  int fa = N - 2 - su;
  cerr << "D = " << D << endl;
  cerr << "cut = " << cut << endl;
  cerr << "cnt = " << cnt << endl;
  cerr << "su = " << su << ", fa = " << fa << endl;
  if (fa > su) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
}


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

typedef complex<double> P;

const double eps = 1e-8;

bool equals(double a, double b) {
  return abs(a-b) < eps;
}

namespace std {
  bool operator < (const P &a, const P &b) {
    if(!equals(a.real(), b.real())) return a.real() < b.real();
    if(!equals(a.imag(), b.imag())) return a.imag() < b.imag();
    return false;
  }
  bool operator == (const P &a, const P &b) {
    return !(a < b) && !(b < a);
  }
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

int ccw(P p, P a, P b) {
  a -= p;
  b -= p;
  if(cross(a,b) > eps) return 1;
  if(cross(a,b) < -eps) return -1;
  if(dot(a,b) < -eps) return 2;
  if(norm(b)-norm(a) > eps) return -2;
  return 0;
}

bool isParallel(P a, P b) {
  return equals(cross(a,b), 0);
}

bool isIntersect(P a1, P a2, P b1, P b2) {
  return ( ccw(a1,a2,b1) * ccw(a1,a2,b2) <= 0 &&
           ccw(b1,b2,a1) * ccw(b1,b2,a2) <= 0 );
}

P getCrossP(P a1, P a2, P b1, P b2) {
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1 - a1)/cross(b, a);
}

double heron(double a, double b, double c) {
  double s = (a+b+c)/2;
  return sqrt(s*(s-a)*(s-b)*(s-c));
}

double heron(P a, P b, P c) {
  return heron(abs(a-b), abs(a-c), abs(b-c));
}

int main() {
  while(1) {
    vector<P> a(3), b(3);
    for(int i = 0; i < 3; ++i) {
      cin >> a[i].real() >> a[i].imag() >> b[i].real() >> b[i].imag();
      if(a[i].real() == 0 && a[i].imag() == 0 && b[i].real() == 0 && b[i].imag() == 0) return 0;
    }
    vector<P> ps;
    for(int i = 0; i < 3; ++i) {
      for(int j = i+1; j < 3; ++j) {
        P s = b[i] - a[i];
        P t = b[j] - a[j];
        if(!isParallel(s,t) && isIntersect(a[i],b[i],a[j],b[j])) {
          ps.push_back(getCrossP(a[i],b[i],a[j],b[j]));
        }
      }
    }
    sort(ps.begin(), ps.end());
    ps.erase(unique(ps.begin(), ps.end()), ps.end());
    double S = -1;
    if(ps.size() == 3) S = heron(ps[0], ps[1], ps[2]);
    if(S < 0) cout << "kyo" << endl;
    else if(S < 100000) cout << "syo-kichi" << endl;
    else if(S < 1000000) cout << "kichi" << endl;
    else if(S < 1900000) cout << "chu-kichi" << endl;
    else cout << "dai-kichi" << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=210;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int n,p[N];VI ans;
inline void move(int k) {
	ans.pb(k);
	for (int i=k;i<n;i++)
		swap(p[i],p[i-k]);
}
int main()
{
	n=gi();
	for (int i=0;i<n;i++) p[i]=gi();
	while (!is_sorted(p,p+n))
		if (p[0]&&p[0]<p[n-1])
			move(n-1);
		else
			move(1);
	cout<<ans.size()<<endl;
	for (int t:ans)
		cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#define inf -2147483647
using namespace std;
struct info
{
    int l,r,d;
}s[400005];
int n,m;
int flag = 1;
int dis[100005],visited[100005];
int first[400005],nexti[400005];
void dfs(int t)
{
    if(!flag)return;
    int k = first[t];
    while(k != -1)
    {
        if(!flag)return;
        if(!visited[s[k].r])
        {
            dis[s[k].r] = dis[s[k].l] + s[k].d;
            visited[s[k].r] = 1;
            dfs(s[k].r);
        }
        else if(s[k].d + dis[s[k].l] != dis[s[k].r])
        {
            flag = 0;
            return;
        }
        k = nexti[k];
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    memset(first,-1,sizeof(first));
    //memset(dis,2000000000,sizeof(dis));
    for(int i = 0;i < m;i ++)
    {
        scanf("%d%d%d",&s[i].l,&s[i].r,&s[i].d);
        nexti[i] = first[s[i].l];
        first[s[i].l] = i;
        s[i + m].r = s[i].l;
        s[i + m].l = s[i].r;
        if(s[i].d)s[i + m].d = - s[i].d;
        else s[i].d = 0;
        nexti[i + m] = first[s[i + m].l];
        first[s[i + m].l] = i + m;
    }
    for(int i = 1;i <= n;i ++)
    {
        if(!visited[i])
        {
            visited[i] = 1;
            dfs(i);
        }
    }
    if(flag)printf("Yes");
    else printf("No");
}


Measured memory_bytes: 9728
H, W = map(int, input().split())
X = []
res = []
F = [True] * W

for i in range(H):
  x = list(input())
   
  if x.count("#") != 0:
    X.append(x)

  for j in range(W):
    if x[j] == "#":
      F[j] = False

for k in range(len(X)):
  r = ""
  for l in range(W):
    if not F[l]:
      r += (X[k][l])
  print(r)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


int main() {
	string s; cin >> s;
	int k; cin >> k;
    //それぞれaに持っていくまでに何回の操作が必要なのかの配列を作る
	int key[100100];
	REP(i, s.size()) {
		if (s[i] == 'a')key[i] = 0;
		else {
			key[i] = (int)('z' - s[i]) + 1;
		}
	}
	string ans = s;
	for (int i = 0; i < s.size(); ++i) {
		if (key[i] <= k) {
			ans[i] = 'a';
			k -= key[i];
		}
		else {
			continue;
		}
	}
	k %= 26;
	ans[s.size() - 1] = char(ans[s.size() - 1] + k);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, m;
    cin >> a >> b >> m;
    vector<ll> va(a);
    vector<ll> vb(b);
    vector<ll> x(m), y(m), c(m);
    ll amin = 1000001, bmin = 1000001;
    rep(i, a) {
        cin >> va[i];
        amin = min(amin, va[i]);
    } 
    rep(i,b) {
        cin >> vb[i];
        bmin = min(bmin, vb[i]);
    }
    ll ans = amin + bmin;
    rep(i,m) {
        cin >> x[i] >> y[i] >> c[i];
    }
    rep(i,m) {
        ans = min(ans, va[x[i]-1] + vb[y[i]-1] - c[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int linersearch(int n, int A[], int key){
    
    int i = 0;
    
    A[n] = key;
    while(A[i] != key){
        i++;
    }
    
    return i != n;
}

int main(){
    int n, A[10000+1], key, q;
    int sum = 0;
    
    cin >> n;
    for(int j=0; j<n; j++){
        cin >> A[j];
    }
    
    cin >> q;
    for(int k=0; k<q; k++){
        cin >> key;
        
        if(linersearch(n, A, key)){
            sum++;
        }
    }
    
    cout << sum << endl;
    
    return 0;
    
}


Measured memory_bytes: 3124
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-O2")


using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, m, mark[N], cnt[N][2], num[N];
vector<int> V;
vector<int> G[N];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++){
		char c;
		cin >> c;
		num[i] = c - 'A';
	}
	for (int i = 0; i < m; i++){
		int v, u;
		cin >> v >> u;
		G[v].pb(u), G[u].pb(v);
		cnt[u][num[v]]++;
		cnt[v][num[u]]++;
	}
	for (int i = 1; i <= n; i++){
		if (cnt[i][0] == 0 || cnt[i][1] == 0) V.pb(i), mark[i] = 1;
	}
	while (V.size()){
		int fr = V.back();
		V.pop_back();
		for (auto u:G[fr]){
			cnt[u][num[fr]] --;
			if (cnt[u][num[fr]] == 0 && mark[u] == 0) mark[u] = 1, V.pb(u);
		}
	}
	for (int i = 1; i <= n; i++) if (!mark[i]) return cout << "Yes\n", 0;
	cout << "No";







	return 0;
}


Measured memory_bytes: 13816
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
bool sortbyval(const tuple<string,int,int>&a,const tuple<string,int,int>&b)
{
if( get<0>(a)!=get<0>(b))
    {
        return  (get<0>(a)<get<0>(b));
    }

    return  get<1>(a)>get<1>(b);
}




int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    vector<tuple<string,int,int>>mp;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
l(i,1,n+1)    {
        cin>>s1>>m;
       mp.pb(make_tuple(s1,m,i));
    }
    sort(all(mp),sortbyval);
    for(auto x:mp)
    {
        cout<<get<2>(x)<<endl;
    }

    }


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int a, b;
  string str;
  cin >> a >> b >> str;
  rep(i,a)
  {
    if (!(str[i] >= '0' && str[i] <= '9')) {
      cout << "No";
      return 0;
    }
  }
  if (str[a] != '-') {
    cout << "No";
    return 0;
  }
  rep(i,b)
  {
    if (!(str[i + a + 1] >= '0' && str[i + a + 1] <= '9')) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}


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

using namespace std;

int main() {
    int n, a, b, flag = 0, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        if (ans >= 3) {
            flag = 1;
        }
        if (a == b) {
            ans++;
        } else {
            ans = 0;
        }
    }
    if (ans >= 3) {
        flag = 1;
    }
    if (flag == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string S;
string T;
ll dp[3001][3001];

int main(void){
  
  IN(S);
  IN(T);

  REP(i, T.size()) {
    REP(j, S.size()) {
      char c1 = T[i];
      char c2 = S[j];
      if (i == 0 || j == 0) {
        dp[i][j] = (c1 == c2) ? 1 : 0;
        if (i > 0) CHMAX(dp[i][j], dp[i-1][j]);
        if (j > 0) CHMAX(dp[i][j], dp[i][j-1]);
      } else {
        if (c1 == c2) dp[i][j] = dp[i-1][j-1] + 1;
        else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
      // DEBUG(dp[i][j]);
    }
    // LN();
  }

  ll lcs = dp[T.size()-1][S.size()-1];
  ll k = T.size() - 1;
  ll l = S.size() - 1;
  vector<char> vc(lcs);
  while (lcs > 0) {
    while (k > 0 && dp[k][l] == dp[k-1][l]) k--;
    while (l > 0 && dp[k][l] == dp[k][l-1]) l--;
    lcs--;
    vc[lcs] = S[l];
    k--;
    l--;
  }
  REP(i, vc.size()) cout << vc[i];
  cout << endl;

}


Measured memory_bytes: 70656
n = int(input())
c = []
d = []
if(n == 1):
  print(int(n))
  exit()

for i in range(1,n+1):
  x = 0
  j = 0
  k = 0
  if(i%2 == 0):
    x = i
    while True:
      x = int(x/2)
      k = k + 1
      if(x == 0 or x%2 == 1):
        c.append(k)
        d.append(i)
        break
  else:
    continue

c_m = max(c)
u = c.index(c_m)
print(d[u])      
    

Measured memory_bytes: 38384
/*
[abc150] E - Change a Little Bit
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 2e5;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(gf x) { return gf((n + x.n) % MOD); }
    gf operator-(gf x) { return gf((n - x.n + MOD) % MOD); }
    gf operator*(gf x) { return gf((1LL * n * x.n) % MOD); }
    gf& operator+=(gf x) { return *this = (*this + x); }
    gf& operator-=(gf x) { return *this = (*this - x); }
    gf& operator*=(gf x) { return *this = (*this * x); }
};

int N;
int C[MAX_N];

ll solve() {
    sort(C, C + N);

    gf p = 1;
    for (int i = 0; i < 2 * N - 2; i++) {
        p *= 2;
    }

    gf ans = 0;
    for (int i = 0; i < N; i++) {
        ans += p * C[i] * (N - i + 1);
    }

    return ans.n;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1024
import math


def main():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 0
    prev = 0

    for i in range(n):
        if prev > a[i]:
            ans += prev - a[i]
        else:
            prev = a[i]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32964
#include<stdio.h>

#define N 500000
#define INFTY 10000000000

int count=0;

void merge(int A[],int left,int mid,int right);
void mergeSort(int A[],int left,int right);

int main()
{
  int A[N];
  int n,i;
  
  scanf("%d",&n);

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

  mergeSort(A,0,n);

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i < n-1)printf(" ");
  }

  printf("\n");
  printf("%d\n",count);

  return 0;
}

void merge(int A[],int left,int mid,int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1],R[n2];

  for(i = 0;i <= n1 - 1;i++){
    L[i] = A[left+i];
  }

  for(j = 0;j <= n2 - 1;j++){
    R[j] = A[mid+j];
  }

  L[n1] = INFTY;
  R[n2] = INFTY;

  i = 0;
  j = 0;

  for(k = left; k <= right-1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
      count++;
    }

    else{
      A[k] = R[j];
      j++;
      count++;
    }
  }
}

void mergeSort(int A[],int left,int right){
  int i,mid;

  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4508
#include <iostream>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    char c;
    cin>>c;
    if(c>='A' && c<='Z')
        cout<<'A';
    else
        cout<<'a';
}

Measured memory_bytes: 3628
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 30/12/2017 15:27:49
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	int a, b, r = 0;
	cin>>a>>b;
	string str;
	cin>>str;
	for(int i = 0; i < str.size(); i++){
		if(str[i] == '-') r++;
	}
	if(str[a] == '-' &&  r == 1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
  int n, m;
  cin >> n >> m;
  if (n % 2)
  {
    rep(i,m){
      cout << i + 1 << " " << n - i << "\n";
    }
  }
  else{
    if(n%4){
      rep(i,m/2){
        cout << i + 1 << " " << n - i << "\n";
      }
      for (int i = m / 2; i < m;++i){
        cout << i + 1 << " " << n - i - 1 << "\n";
      }
    }
    else{
      rep(i,m/2+1){
        cout << i + 1 << " " << n - i << "\n";
      }
      for (int i = m / 2+1; i < m;++i){
        cout << i + 1 << " " << n - i - 1 << "\n";
      }
    }
  }
}

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



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

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

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll N) {
    
    for (int i = 0; i * 4 <= N; i++) {
        if ((N - 4 * i) % 7 == 0) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}


void main_(istream &cin) {
    ll N;
    cin >> N;
    solve(N);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
use std::cmp;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    };

    println!("{}", cmp::min(c, b / a));
}


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

#define int long long

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

	char c = s[0];
	int ccnt = 0;
	for (int i = 0; i < s.size(); ++i) if (s[i] == c) ++ccnt;
	if (ccnt == s.size()) {
		long long a = (long long) (k * ccnt) / 2;
		cout << a << endl;
		return 0;
	}

	s.push_back('X');
	long long ans = 0;
	bool first = true;
	int cnt = 1, cntf = 0, cntb = 0;
	for (int i = 0; i < s.size() - 1; ++i) {
		if (s[i] == s[i + 1]) cnt++;
		else {
			if (first) {
				cntf = cnt;
				cnt = 1;
				first = false;
			}
			else if (s[i + 1] == 'X') {
				cntb = cnt;
			}
			else {
				ans += (long long) k * (cnt / 2);
				cnt = 1;
			}
		}
		//cout << i << "  " << ans << endl; 
	}

	

	//cout << cntf << " " << cntb << endl;
	//cout << ans << endl;



	if (s[0] != s[s.size() - 2]) ans += (long long)k * (cntf / 2 + cntb / 2);
	else ans += (long long)(k - 1) * ((cntf + cntb) / 2) + cntf / 2 + cntb / 2;

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  ll dist = abs(a - b);
  ll nige = w - v;
  if (nige >= 0) {
    cout << "NO" << endl;
    return 0;
  } else {
    if (dist > -nige * t)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}


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

//https://codeforces.com/blog/entry/12079
#define ll unsigned long long
#define FASTIO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

const ll maxn = 1e8;
const int MOD = 1e9+7;

int main(){
    FASTIO
    
    int n,m;cin >> n >> m;
    vector<bool> wrong(n+1);
    for(int i=0;i<m;i++){
    	int x;cin >> x;
    	wrong[x] = true;
    }
	vector<ll> ans(n+1);
	ans[0] = 1;
  	if(!wrong[1]) ans[1] = 1;
	for(int i=2;i<=n;i++){
		
		ans[i] = (ans[i-1] + ans[i-2])%MOD;
		if(wrong[i]) ans[i] = 0;
	}
	cout << ans[n];
}

Measured memory_bytes: 1024
// A - Pair
// https://abc108.contest.atcoder.jp/tasks/abc108_a

import scala.io.StdIn.readLine

object Main extends App {

  val k = readLine.toInt

  val odd = k / 2
  val even = (k + 1) / 2

  val c = odd * even

  println(c)

}

Measured memory_bytes: 25412
#include <iostream>
#include<math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)

int P[200010];
int main() {
    int N;
    cin >> N;
    rep(i, N)cin >> P[i];

    int min = 200010;
    int c = 0;
    for (int i = 0; i < N; i++) {
        if (min > P[i]) {
            min = P[i];
            c ++;
     }
    }
    cout << c << endl;
    return 0;
}

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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	multiset<int> S;
	rep(i,n){
		int a; scanf("%d",&a);
		S.emplace(a);
	}

	int m; scanf("%d",&m);
	rep(i,m){
		int a; scanf("%d",&a);
		auto it=S.find(a);
		if(it==S.end()) return puts("NO"),0;
		S.erase(it);
	}
	puts("YES");

	return 0;
}


Measured memory_bytes: 9600
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

template<typename T>
struct SegmentTree {
private:
	int sz, n;
	vector<T> data;
	function<T(T, T)> f;
	T identity_element;
public:
	/* constructor */
	SegmentTree() { }
	SegmentTree(
		vector<T> v, // initial data
		T identity_element, // identity element
		function<T(T, T)> f // operation
	) {
		sz = v.size();
		n = 1; while (n < sz) n <<= 1;
		this->f = f;
		this->identity_element = identity_element;
		data.resize(2 * n - 1, identity_element);
		for (int i = 0; i < sz; ++i)
			data[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; --i)
			data[i] = f(data[2 * i + 1], data[2 * i + 2]);
	}
	/* update query */
	void update(int idx, const T val) {
		idx += n - 1;
		data[idx] = val;
		while (idx) {
			idx = (idx - 1) >> 1;
			data[idx] = f(data[2 * idx + 1], data[2 * idx + 2]);
		}
	}
	/* get query */
	T get(int left, int right, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (r <= left || right <= l) return identity_element;
		if (left <= l && r <= right) return data[k];
		T val_l = get(left, right, 2 * k + 1, l, (l + r) / 2);
		T val_r = get(left, right, 2 * k + 2, (l + r) / 2, r);
		return f(val_l, val_r);
	}
};

int N;
vector<int> a;
vector<vector<int>> g;

void input() {
	cin >> N;
	a.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> a[i];
	map<int, int> com;
	int t = 0;
	for (auto ai : a)
		com[ai] = 0;
	for (auto& e : com)
		e.second = t++;
	for (int i = 0; i < N; ++i)
		a[i] = com[a[i]];
	g.resize(N);
	for (int i = 0; i < N - 1; ++i) {
		int u, v; cin >> u >> v;
		--u, --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
}

vector<int> res;
vector<int> dif;

SegmentTree<int> rmq;

void setup() {
	res.resize(N);
	dif.resize(N);
	rmq = SegmentTree<int>(
		vector<int>(N, 0),
		0,
		[](int a, int b) {
			return max(a, b);
		}
	);
}

void dfs(int s = 0, int p = -1) {
	int ai = a[s];
	int tmp = rmq.get(0, ai) + 1;
	dif[s] = rmq.get(ai, ai + 1);
	rmq.update(ai, tmp);
	/*
	cout << s << ":" << endl << "    ";
	for (int i = 0; i < N; ++i)
		cout << rmq.get(i, i + 1) << " ";
	cout << endl;
	*/
	res[s] = rmq.get(0, N);
	for (auto nx : g[s])
		if (nx != p)
			dfs(nx, s);
	rmq.update(ai, dif[s]);
}

int main() {
	input();
	setup();
	dfs();
	for (auto ri : res)
		cout << ri << endl;
	return 0;
}


Measured memory_bytes: 127992
import itertools as it

N, M = map(int, input().split())
graph = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    graph[a].append(b)
    graph[b].append(a)
ans = 0
for path in it.permutations(range(N)):
    if path[0] != 0:
        break
    is_connected = True
    for ith_edge in range(len(path) - 1):
        if path[ith_edge + 1] not in graph[path[ith_edge]]:
            is_connected = False
            break
    if is_connected:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <cstdio>

int main()
{
	char S[10];
	scanf("%s", S);

	int ans = 0;
	for (int i = 0; i < 4; ++i) {
		if (S[i] == '+') ++ans;
		else --ans;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128