akhauriyash/Code-Regression huggingface dataset:
// AOJ 1367: Rearranging a Sequence
// 2017.10.9 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

typedef struct { int id, a; } T;
T tbl[200002];

char buf[100], *p;

int getInt(void)
{
	int n = 0;
//	if (*p == ' ') p++;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ - '0');
	return n;
}

int rint2sz(int n, int off)
{
    int k;
    if ((k = n / 10) != 0) off = rint2sz(k, off);
    *(p + off) = n % 10 + '0';
    return off+1;
}

int cmp(T *a, T *b) { return b->id - a->id; }	// for qsort()

int main()
{
	int n, m, i, j;
	register T *tp;

	fgets(p = buf, 50, stdin); n = getInt(), p++, m = getInt(); 
//	scanf("%d%d", &n, &m);
	for (tp = tbl+1, j = n, i = 1; i <= n; i++, tp++) tp->id = j--, tp->a = i;
	while (m-- > 0) {
		fgets(p = buf, 50, stdin); j = getInt();
//		scanf("%d", &j);
		tbl[j].id = i++;
	}
	qsort(tbl+1, n, sizeof(T), cmp);
	p = buf, tp = tbl; while (n-- > 0) {
		tp++;
		*(p + rint2sz(tp->a, 0)) = 0;
		puts(p);
//		printf("%d\n", tp->a);
	}
	return 0;
}

Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
struct query{
  int type;//0=empty, 1=set
  ll value;
  query(int a=0,ll b=0):type(a),value(b) {}
};
 
query s[(1<<18)];
ll t[(1<<18)];
 
void compute(int k,int l,int r){
  query q=s[k];
  s[k].type=0;
  if(q.type==0||r-l==1)return;
  s[k*2+1]=s[k*2+2]=q;  
  t[k*2+1]=t[k*2+2]=q.value;
}
 
void Set(int a,int b,ll x,int k=0,int l=0,int r=(1<<17)){
  if(b<=l || r<=a)return;
  compute(k,l,r);
  if(a<=l && r<=b){
    s[k]=query(1,x);
    t[k]=x;
  }else{
    int m=(l+r)/2;
    Set(a,b,x,k*2+1,l,m);
    Set(a,b,x,k*2+2,m,r);
    t[k]=min(t[k*2+1],t[k*2+2]);
  }
}
 
ll Get(int a,int b,int k=0,int l=0,int r=(1<<17)){
  if(b<=l || r<=a)return (1LL<<60);
  compute(k,l,r);
  if(a<=l && r<=b){
    return t[k];
  }else{
    int m=(l+r)/2;
    ll lv=Get(a,b,k*2+1,l,m);
    ll rv=Get(a,b,k*2+2,m,r);
    return min(lv,rv);
  }
}
 
 
 
int main(){
  int n,q,type,a,b,x;
  Set(0,(1<<17),2147483647);
  scanf("%d %d",&n,&q);
  while(q--){
    scanf("%d",&type);
    if(type==0){
      scanf("%d %d %d",&a,&b,&x);
      b++;
      Set(a,b,x);
    }else{
      scanf("%d %d",&a,&b);
      b++;
      printf("%lld\n",Get(a,b));
    }
  }
  return 0;
}


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

int main() {
  ll n;
  cin >> n;
  string ans = "";
  while(n) {
    n--;
    ans += (char)('a'+ (n % 26));
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <assert.h>
#include <sstream>
#include <type_traits>
#define SET(x,y) x |= (1 << y)
#define CLEAR(x,y) x &= ~(1<< y)
#define READ(x,y) ((0u == (x & (1<<y)))?0u:1u)
#define TOGGLE(x,y) (x ^= (1<<y))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pF first
#define pS second
#define CL(a,b) memset(a,b,sizeof(a))
#define sqr(x) ((x)*(x))
#define intLIMIT numeric_limits<int>
#define longLIMIT numeric_limits<long long>
#define GCD(a,b) __gcd((a),(b))
#define dbl(x) (double)(x)
#define vi vector <int>
#define vii vector < pair <int, int> >
#define vll vector <long long>
#define allof(x) (x).begin(), (x).end()
#define fastCin cin.sync_with_stdio(0);cin.tie(0)
#define scanUnsigned(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define printArr(a,l) cout<<#a<<": ";for(int i=0;i<(l);i++){cout<<a[i]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(int i=0;i<(r);i++){for(int j=0;j<(c);j++){cout<<a[i][j]<<" ";}cout<<endl;}
char _;
using namespace std;
void PRINT (int x, int y) { for (int i = y-1; i >= 0; i--) { cout << READ(x,i); } cout << endl; }

vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#ifdef LOCAL_DBG
#define dbg(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...) 42
#endif

int main () {
	fastCin;
	int n;
	cin >> n;
	vi a(n);
	ll ans = 0;
	for (int x = 0; x < n; x++) {
		cin >> a[x];
		if (x > 0) {
			if (a[x] < a[x-1]) {
				ans += a[x-1]-a[x];
				a[x] = a[x-1];
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3620
def main():

    S = input()
    n = len(S)
    memo = dict()
    def recursive(S, i, j):
        if i == j: return 0
        if (i, j) not in memo:
            v = int(S[i:j])
            for k in range(i+1, j):
                v += int(S[i:k])*pow(2, j-k-1) + recursive(S, k, j)
            memo[(i, j)] = v
        return memo[(i, j)]

    return recursive(S, 0, n)

if __name__ == '__main__':
    print(main())


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

int main() {
  int M, D; cin >> M >> D;
  int ans = 0;
  for (int i = 1; i <= M; i++) {
    for (int j = 1; j <= D; j++) {
      int m = i;
      int d1 = j / 10;
      int d10 = j % 10;
      if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

void push_string(vector<string>& ss, set<string>& hoge){
  do{
    string tmp="";
    for(int i=0; i<ss.size(); i++)
      tmp += ss[i];
    //    cout << tmp << "\n";
    hoge.insert(tmp);
  }while(next_permutation(ss.begin(),ss.end()));
}


int main(){

  while(1){
    int n,k; cin >> n >> k;
    if(n==0 && k==0) break;
    vector<string> ss;
    set<string> hoge;
    for(int i=0; i<n; i++){
      string x; cin >> x;
      ss.push_back(x);
    }
    sort(ss.begin(),ss.end());
    switch(k){
    case 2:
      for(int i=0; i<n; i++){
	for(int j=i+1; j<n; j++){
	  vector<string> tmp;
	  tmp.clear();
	  tmp.push_back(ss[i]);
	  tmp.push_back(ss[j]);
	  push_string(tmp,hoge);
	}
      }
      break;
    case 3:
      for(int i=0; i<n; i++){
	for(int j=i+1; j<n; j++){
	  for(int k=j+1; k<n; k++){
	    vector<string> tmp;
	    tmp.push_back(ss[i]);
	    tmp.push_back(ss[j]);
	    tmp.push_back(ss[k]);
	    push_string(tmp,hoge);
	  }
	}
      }
      break;
    case 4:
      for(int i=0; i<n; i++){
	for(int j=i+1; j<n; j++){
	  for(int k=j+1; k<n; k++){
	    for(int l=k+1; l<n; l++){
	      vector<string> tmp;
	      tmp.push_back(ss[i]);
	      tmp.push_back(ss[j]);
	      tmp.push_back(ss[k]);
	      tmp.push_back(ss[l]);
	      push_string(tmp,hoge);
	    }
	  }
	}
      }
      break;
    }
    cout << hoge.size() << "\n";

  }

}

Measured memory_bytes: 3364
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    p = [i for i in range(1, n+1)]
    idx = m-1
    while len(p) != 1:
        v = p.pop(idx)
        idx = (idx+m-1) % len(p)
    print(*p)

Measured memory_bytes: 7720
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse4,avx,avx2")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <chrono>
#include <random>
#include <string>
#include <queue>
#include <tuple>
#include <unordered_map>
#include <sstream>
#include <numeric>
#include <complex>
#include <immintrin.h>
#include <unordered_set>

using namespace std;

using ll = long long;
using ld = long double;
using VectorType = ld;
using ull = unsigned long long;

const ll INF = 1e15;
const ld eps = 1e-7;
const ld pi = atan2(0, -1);
const ll mod = 1e9 + 7;
const ll P = 179, Q = 239;
const ll A = 26;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

ll sign(ll a) {
	if (a < 0) return -1;
	if (a == 0) return 0;
	return 1;
}

bool equal(ld a, ld b) {
	return abs(a - b) < eps;
}

struct query {
	ll l, r, i;

	query(ll l = 0, ll r = 0, ll i = 0) : l(l), r(r), i(i) {};
};

bool mini(ll &a, ll b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

bool maxi(ll &a, ll b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool mini(ld &a, ld b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

ll mmax(ll a, ll b) {
	if (a > b) return a;
	return b;
}

ll mmin(ll a, ll b) {
	if (a < b) return a;
	return b;
}

ld mmax(ld a, ld b) {
	if (a > b) return a;
	return b;
}

ld mmin(ld a, ld b) {
	if (a < b) return a;
	return b;
}

bool maxi(ld &a, ld b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

ll sub(ll a, ll b) {
	a -= b;
	if (a < 0) {
		a += mod;
	}
	return a;
}

ll add(ll a, ll b) {
	a += b;
	if (a > mod) {
		a -= mod;
	}
	return a;
}

ll mul(ll a, ll b) {
	return (a * b) % mod;
}

ll n, m;
ll k;
vector <vector <ll>> vec;
vector <bool> used;
vector <vector <ll>> g;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector <ll> p(a), q(b), r(c);
	for (auto &x : p) {
		cin >> x;
	}
	for (auto &y : q) {
		cin >> y;
	}
	for (auto &z : r) {
		cin >> z;
	}
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	sort(r.begin(), r.end());
	multiset <ll> ca, cb;
	ll cnt = 0, ptr = a - 1;
	while (cnt < x) {
		ca.insert(p[ptr--]);
		++cnt;
	}
	cnt = 0, ptr = b - 1;
	while (cnt < y) {
		cb.insert(q[ptr--]);
		++cnt;
	}
	for (auto &el : r) {
		if (el > *ca.begin() && el > *cb.begin()) {
			ll da = el - *ca.begin();
			ll db = el - *cb.begin();
			if (da > db) {
				ca.erase(ca.begin());
				ca.insert(el);
			}
			else {
				cb.erase(cb.begin());
				cb.insert(el);
			}
		}
		else if (el > *ca.begin()) {
			ca.erase(ca.begin());
			ca.insert(el);
		}
		else if (el > *cb.begin()) {
			cb.erase(cb.begin());
			cb.insert(el);
		}
	}
	ll ans = 0;
	for (auto &x : ca) {
		ans += x;
	}
	for (auto &x : cb) {
		ans += x;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << (n / (a + b)) * a + min(n % (a + b), a) << endl;
}

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

int main(){
    ll n,k;
    cin >> n >> k;
    vector<pii> x(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        x[i].first = a;
        x[i].second = b;
    }
    sort(x.begin(),x.end());
    rep(i,n){
        k -= x[i].second;
        if(k <= 0){
            cout << x[i].first << endl;
            return 0;
        }
        else continue;
    }
}

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

int main()
{
  string s;
    cin>>s;
    int x  =s.size();
    for(int i=0;i<x;i++)
    {
if(x==19&&s[5]==','&&s[13]==',')
    replace( s.begin(), s.end(), ',', ' ');
    }


    cout<<s;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n;
int a[N];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    int ans=0;
    int tot=0,temp=a[n];
    for(int i=n-1;i>=1;i--){
        if(temp<=a[i]){
            tot++;
            ans=max(tot,ans);
        }
        else{
            tot=0;
        }
        temp=a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main()
{
    char s[20];
    int i,n,place;
    n=0;
    scanf("%s",&s);
    if(s[0]!='A' || s[1]=='C'){
            printf("WA\n");return 0;
    }
    for(i=2;i<strlen(s)-1;i++)
    {
        if(s[i]=='C')
        {
            n++;
            place=i;
        }
    }
    if(n!=1)
        {
            printf("WA\n");return 0;
    }
    for(i=1;i<strlen(s);i++)
    {
        if(i==place)continue;
        if(s[i]>='A' && s[i]<='Z'){
            printf("WA\n");return 0;
    }
    }
    printf("AC\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
 
int lc( int a , int b ) {
    int c;
    while ( b > 0 ) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}
int main (void) {
    int a , b , min , max, tmp;     
    while ( scanf("%d %d",&a,&b) != EOF ) {
		if ( a > b ) {
        tmp = a;
        a = b;
        b = tmp;
		}
        max = lc(a,b);
        min = a / max * b;       
        printf("%d %d\n",max,min);
    }
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,l;
  string s;
  cin >> k >> s;
  l=s.size();
  if(l<=k){
    cout << s;
    return 0;
  }
  for(int i=0;i<k;i++){
    cout << s.at(i);
  }
  cout << "...";
}

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

int cnt_digits(ll n) {
  int digits = 0;
  while (n > 0) {
    n /= 10;
    digits++;
  }
  return digits;
}

ll divisor(ll n) {
  int F = 10;
  for (ll i = 1LL; i * i <= n; i++) {
    if (n % i != 0) continue;
    F = min(F, max(cnt_digits(i), cnt_digits(n / i)));
  }
  return F;
}

main() {
  ll N; cin >> N;
  cout << divisor(N) << endl;
}

Measured memory_bytes: 256
N, *TA = [int(_) for _ in open(0).read().split()]
x, y = TA[:2]
for t, a in zip(TA[2::2], TA[3::2]):
    m = 1 + max((x - 1) // t, (y - 1) // a)
    x = m * t
    y = m * a
print(x + y)


Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    int k;
    cin>>k;
    vi v(n);
    rep(i,0,n)cin>>v[i];
    ll ans=-INF;
    rep(r,0,k+1){
        rep(l,0,k+1-r){
                if(r+l>n)continue;
                priority_queue<int,vi,greater<int>> q;
                ll ta=k-(r+l);
                ll res=0;
                rep(i,0,r)q.push(v[n-1-i]),res+=v[n-1-i];
                rep(i,0,l)q.push(v[i]),res+=v[i];
                rep(i,0,ta){
                    if(!q.empty()&&q.top()<0){
                        int minus=q.top();
                        q.pop();
                        res-=minus;
                    }
                }
                chmax(ans,res);
            }
        }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    ll takahashi = 1, aoki = 1;
    for(int i=0; i<n; i++){
        ll t, a; cin>>t>>a;
        ll num1 = (takahashi + t - 1) / t;
        ll num2 = (aoki + a - 1) / a;

        takahashi = t * max(num1, num2);
        aoki = a * max(num1, num2);
    }

    cout << takahashi + aoki << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std ;

char C[100010] ;
char D[100010] ;

long long N , M ;

long long Gcd( long long A , long long B ) { return B ? Gcd( B , A % B ) : A ; }

int main() {
	
	char Reg ;
	scanf( "%lld%lld%s%s" , &N , &M , C , D ) ;
//	do { Reg = getchar() ; } while( Reg > 'z' or Reg < 'a' ) ;
//	for(register int i = 0 ; i < N ; C[i] = Reg , Reg = getchar() ) ;
//	do { Reg = getchar() ; } while( Reg > 'z' or Reg < 'a' ) ;
//	for(register int i = 0 ; i < M ; D[i] = Reg , Reg = getchar() ) ;
	
	long long Gcdd = Gcd( N , M ) ;
	long long Len1 = N / Gcdd ;
	long long Len2 = M / Gcdd ;
	
	for(register int i = 0 ; i < Gcdd ; i++ )
		if( C[ i * Len1 ] != D[ i * Len2 ] ) return not printf( "-1\n" ) ;
	return not printf( "%lld\n" , N * M / Gcdd ) ;
	
} 

Measured memory_bytes: 384
#!/usr/bin/python3
# -*- coding: utf-8 -*-



def solve():
  MOD = 2019
  L,R = map(int, input().split())
  ans = set()
  for i in range(L+1,R+1):
    for j in range(L,i):
      ans.add((i*j)%MOD)
    if min(ans)==0:
      return 0
  return min(ans)


def main():
  print(solve())


if __name__ == "__main__":
  main()

Measured memory_bytes: 40812
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
/*
\x*8/100/  =A
\x*10/100/ =B

*/

int main() {

	long long  a, b; cin >> a >> b;

	long long  lo = 1, hi = 1e18, ans = -1;
	while (lo <= hi) {
		long long  x = lo + (hi - lo) / 2;

		if (((x * 8) / 100) == a and (x / 10) == b) ans = x, hi = x - 1;
		else if (((x * 8) / 100) < a or (x / 10) < b) lo = x + 1;
		else if (((x * 8) / 100) > a or (x / 10) > b) hi = x - 1;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3160
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines

def main():
    a, b, c, d = map(int, input().split())
    while a > 0 and c > 0:
        c -= b
        if c <= 0:
            print('Yes')
            sys.exit()
        a -= d
        if a <= 0:
            print('No')
            sys.exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 8816
n = gets.to_i
ss = n.times.map { gets.to_i }
sum_max = ss.reduce(&:+)
dp = Array.new(n) { Array.new(sum_max+1) { false } }
# dp[i][j]: i番目までの問題でj点が取れるか

dp[0][0], dp[0][ss[0]] = true, true
1.upto(n-1).each do |i|
  si = ss[i]
  0.upto(sum_max).each do |j|
    if dp[i-1][j]
      dp[i][j], dp[i][j+si] = true, true
    end
  end
end

10000.downto(0).each do |j|
  if (dp[n-1][j] && j%10 != 0) || j == 0
    puts j
    break
  end
end

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

int main () {
    char str[3];
    scanf("%s", str);

    if ( strcmp( str, "ooo" ) == 0 ) printf( "1000\n" );
    if ( strcmp( str, "xoo" ) == 0 ) printf( "900\n" );
        if ( strcmp( str, "oxo" ) == 0 ) printf( "900\n" );
        if ( strcmp( str, "oox" ) == 0 ) printf( "900\n" );
        if ( strcmp( str, "oxx" ) == 0 ) printf( "800\n" );
        if ( strcmp( str, "xox" ) == 0 ) printf( "800\n" );
        if ( strcmp( str, "xxo" ) == 0 ) printf( "800\n" );
        if ( strcmp( str, "xxx" ) == 0 ) printf( "700\n" );
    return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long li;
typedef pair <li, li> pi;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

const li mod = 1e9 + 7;

li dp[41][1 << 18];
int nextv[1 << 18][12];

int main() {
    li n, x, y, z;
    cin >> n >> x >> y >> z;

    const int one = x;
    const int two = x + y;
    const int three = x + y + z;

    auto st = [&](const int i) {
        if (i < one) {
            return 1;
        } else if (i == one) {
            return 1 + 2;
        } else if (i < two) {
            return 2;
        } else if (i == two) {
            return 2 + 4;
        } else if (i < three) {
            return 4;
        } else if (i == three) {
            return 4 + 8;
        }
        return 0;
    };

    rep(mask, 1 << (three + 1)) {
        for (int len = 1; len <= 10; ++len) {
            int nmask = 1;
            rep(posit, three) {
                if ((mask >> posit) & 1) {
                    const int cst = st(posit);
                    const int nposit = posit + len;
                    if (cst & st(nposit)) {
                        nmask |= 1 << nposit;
                    }
                    if ((mask >> three) & 1) {
                        nmask |= 1 << three;
                    }
                }
            }
            nextv[mask][len] = nmask;
        }
    }

    dp[0][1] = 1;
    rep(i, n) {
        rep(mask, 1 << (three + 1)) {
            for (int len = 1; len <= 10; ++len) {
                dp[i + 1][nextv[mask][len]] += dp[i][mask];
                dp[i + 1][nextv[mask][len]] %= mod;
            }
        }
    }
    li ans = 0;
    rep(mask, 1 << (three + 1)) {
        if (mask & (1 << three)) {
            ans = (ans + dp[n][mask]) % mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 94464
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <tuple>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vll ab(n);
    ll ans = 0;
    REP(i,n){
        ll a,b;
        cin >> a >> b;
        ans += a;
        ab[i] = a + b;
    }
    sort(rALL(ab));
    REP(i,n){
        if(i%2==1){
            ans-=ab[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a,b,c,d,e,f,g,h,i,N, k;
  cin>> a>>b>>c>>d>>e>>f>>g>>h>>i>>N;
  for(int j;j<N;j++){
    cin>>k;
    if(k==a)
      a=0;
    if(k==b)
      b=0;
    if(k==c)
      c=0;
    if(k==d)
      d=0;
    if(k==e)
      e=0;
    if(k==f)
      f=0;
    if(k==g)
      g=0;
    if(k==h)
      h=0;
    if(k==i)
      i=0;
  }
  if(a==b&&b==c)
    cout << "Yes"<< endl;
  else if(d==e&&e==f)
    cout << "Yes"<< endl;
  else if(i==h&&h==g)
    cout << "Yes"<< endl;
  else if(a==d&&d==g)
    cout << "Yes"<< endl;
  else if(h==e&&e==b)
    cout << "Yes"<< endl;
  else if(c==f&&f==i)
    cout << "Yes"<< endl;
  else if(a==e&&e==i)
    cout << "Yes"<< endl;
  else if(g==e&&e==c)
    cout << "Yes"<< endl;
  else cout<<"No"<<endl;
  
}

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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Restaurant[] rs = new Restaurant[N];
		for (int i = 0; i < N; i++) {
			rs[i] = new Restaurant(i + 1, sc.next(), Integer.parseInt(sc.next()));
		}
		sc.close();

		Arrays.sort(rs, new Comparator<Restaurant>() {
			public int compare(Restaurant r1, Restaurant r2) {
				int c = r1.s.compareTo(r2.s);
				if (c != 0) {
					return c;
				}
				return r2.p - r1.p;
			}
		});

		for (int i = 0; i < N; i++) {
			System.out.println(rs[i].id);
		}

	}

	static class Restaurant {
		String s;
		int p;
		int id;

		Restaurant(int id, String s, int p) {
			this.s = s;
			this.p = p;
			this.id = id;
		}
	}

}

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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    int a, b;
    cin >> a >> b;


    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    b -= a;
    int ans = 1;
    ans += (b + a - 2) / (a-1);

    cout << ans << endl;

    return 0;
}



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

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var a = long.Parse(Console.ReadLine());

            var result = 30 <= a ? "Yes" : "No";



            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27472
x = int(input())

def is_prime(x):
    if x % 2 == 0:
        return False

    for i in range(3, x, 2):
        if x % i == 0:
            return False

    return True


def func(x):
    if is_prime(x):
        return x
    else:
        if x % 2 == 0:
            for i in range(x+1, 10**5+100, 2):
                #print(i)
                if is_prime(i):
                    return i

        else:
            for i in range(x, 10**5+100, 2):
                #print(i)
                if is_prime(i):
                    return i




if x == 2:
    print(x)
else:
    print(func(x))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int r, g, b;

    cin >> r >> g >> b;

    if ((100 * r + 10 * g + b) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

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

int main() {
	
	int i, j, h, w, cnt = 0;
	scanf("%d%d", &h, &w);
	int **a = (int **)malloc(sizeof(int *)*h);
	int *base = (int *)malloc(sizeof(int)* h * w);
	for (i = 0; i < h; i++) {
		a[i] = &base[i * w];
	}
	for (i = 0; i < h*w; i++) {
		scanf("%d", base + i);
	}
	char **s = (char **)malloc(sizeof(char *)*h*w);
	char *sbase = (char *)malloc(sizeof(char)*h*w * 17);
	for (i = 0; i < h*w; i++) {
		s[i] = &sbase[i * 17];
		s[i][0] = '\0';
	}

	for (i = 0; i < h - 1; i++) {
		for (j = 0; j < w; j++) {
			if (a[i][j] % 2) {
				a[i][j]--;
				a[i + 1][j]++;
				sprintf(s[cnt], "%d %d %d %d\n", i + 1, j + 1, i + 2, j + 1);
				cnt++;
			}
		}
	}
	for (j = 0; j < w - 1; j++) {
		if (a[i][j] % 2) {
			a[i][j]--;
			a[i][j + 1]++;
			sprintf(s[cnt], "%d %d %d %d\n", i + 1, j + 1, i + 1, j + 2);
			cnt++;
		}
	}

	printf("%d\n", cnt);
	for (int i = 0; s[i][0] != '\0'; i++) {
		printf("%s", s[i]);
	}

	return 0;
}

Measured memory_bytes: 9088
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
    std::cin >> N;
    std::vector<int64_t> s(N);
    for (auto& v : s) std::cin >> v;

    std::sort(s.begin(), s.end());

    int64_t sum_s = 0;
    for (auto v : s) sum_s += v;

    int64_t ans;
    if (sum_s % 10 != 0) ans = sum_s;
    else
    {
        bool all_10 = true;
        for (auto v : s)
        {
            if (v % 10 != 0)
            {
                ans = sum_s - v;
                all_10 = false;
                break;
            }
        }
        if (all_10) ans = 0;
    }

    std::cout << ans << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])puts("Yes");
    else puts("No");
    
    return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())    
A =[input() for _ in range(n)]
if len(A)!=len(set(A)):
    print('No')
    sys.exit()
for i in range(1,n):
    if A[i-1][-1] != A[i][0]:
        print('No')
        sys.exit()
print('Yes')

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A <= C && C <= B) || (B <= C && C <= A)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def S(x1,y1,x2,y2,x3,y3):
    return abs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2.0

while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split())
        flag = S(x1,y1,x2,y2,xp,yp)+S(x1,y1,x3,y3,xp,yp)+S(x3,y3,x2,y2,xp,yp)-S(x1,y1,x2,y2,x3,y3) > 0.0000001
        print "NO" if flag else "YES"
    except:
        break

Measured memory_bytes: 4248
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const double pi = acos(-1.0);

int main() {
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    for (int i = 0; i < n; i++) {
        vector<double> ang;
        for (int j = 0; j < n; j++) {
            if (i != j) {
                ang.push_back(atan2(y[j] - y[i], x[j] - x[i]));
            }
        }

        sort(ang.begin(), ang.end());

        double mx = 0.0;
        for (int j = 0; j < n-2; j++) {
            mx = max(mx, ang[j+1] - ang[j]);
        }
        mx = max(mx, ang[0] + 2 * pi - ang[n-2]);

        double res = (mx > pi ? (mx - pi) / (2 * pi) : 0.0);
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll N;
    string A, B, C;

    cin >> N;
    cin >> A >> B >> C;
    ll cnt = 0;
    rep(i, N) {
        if (A[i] == B[i] && A[i] == C[i]) {
            continue;
        } else if ((A[i] == B[i] && A[i] != C[i]) ||
                   (A[i] == C[i] && A[i] != B[i]) ||
                   (B[i] == C[i] && A[i] != C[i])) {
            cnt += 1;
        } else {
            cnt += 2;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int A[20000000],B[20000000],C[20000000];
int n;

void CountingSort(int k)
{
  int i,j;
  for(i=0;i<=k;i++)
    {
      C[i]=0;
    }
  for(j=1;j<=n;j++)
    {
      C[A[j]]++;
    }
  for(i=1;i<=k;i++)
    {
      C[i]=C[i]+C[i-1];
    }
  for(j=n;j>=1;j--)
    {
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }
}

main(){
  int i,k=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d",&A[i]);
      if(k<A[i])
	k=A[i];
    }
  CountingSort(k+1);
  for(i=1;i<=n;i++)
    {
      printf("%d",B[i]);
      if(i<n)
	printf(" ");
    }
  printf("\n");
  return 0;

}

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll N, K;
  cin >> N >> K;

  vector<ll> as;
  rep(i, N){
    as.push_back(il());
  }

  REP(i, K+1, N+1){
    ll idx = i - 1;
    // i : K+1 ~ N
    // idx : K ~ N-1


    if (as[idx] > as[idx-K]) cout << "Yes" << endl;
    else cout << "No" << endl; 
  }



  
}

Measured memory_bytes: 5424
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 101010
#define DEBUG_OUT true

#define ALL(x) (x).begin(), (x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int n,m;cin>>n>>m;
  if(n%2 == 1)
  {
    for (int i = 0; i < m; i++)
    {
      cout<<i+1<<" "<<n -i <<endl;
    }
    
  }
  else
  {
    bool flag = false;
    int cnt = 0;
    for (int l = 1,r = n -1 ; l < r; l++,r--)
    {
      if(!flag and r - l <= n/2)
      {
        --r;
        flag = true;
      }
      cout<<l<<" "<<r<<endl;
      cnt++;
      if(cnt == m)break;

    }
    
  }
  


  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  // std::ios::sync_with_stdio(false);
  // std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

using namespace std;

vector <vector <int> > mv;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int n,m;
	int u,v;
	cin>>n>>m;
	mv.resize(n);
	int h[n];
	for(int i=0;i<n;i++)cin>>h[i];
	while(m--){
		cin>>u>>v;
		u--;v--;
		mv[u].push_back(v);
		mv[v].push_back(u);
	}
	int res = 0;
	for(int i=0;i<n;i++){
		if(mv[i].size()==0){
			res++;
			continue;
		}
		int j;
		for(j = 0;j<mv[i].size();j++)if(h[mv[i][j]]>=h[i])break;
		if(j<mv[i].size())continue;
		res++;
	}
	cout<<res<<endl;
	
	return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  double ans = 0;
  REP (i, n) {
    double x;
    string s;
    cin >> x >> s;

    if (s == "JPY") ans += x;
    else ans += x * 380000.0;
  }

  printf("%.10lf\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n, T;
    cin >> n >> T;
    vector<pair<double,P>> v;
    vector<ll> u;
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        if(a == 0){
            u.push_back(b+1);
            continue;
        }
        pair<double,P> p;
        p.second.first = a; 
        p.second.second = b;
        p.first = (double)a / (b+1);
        v.push_back(p);
    }
    sort(v.begin(), v.end(), greater<pair<double,P>>());
    sort(u.begin(), u.end());
    n = v.size();
    int m = u.size();

    const ll INF = 1001001001001001001;
    ll dp[50] = {};
    srep(i,1,50) dp[i] = INF;

    

    rep(i,n){
        ll a = v[i].second.first;
        ll b = v[i].second.second;
        // cout << i << ' ' << a << ' ' << b << endl;
        drep(j,49){
            if(dp[j] >= T) continue;
            ll tmp = (dp[j] + 1) + (dp[j] + 1) * a + b;
            dp[j+1] = min(dp[j+1], tmp);
        }
    }
    /*
    rep(i,10) cout << dp[i] << ' ';
    cout << endl;
    */

    ll sum[m+1] = {};
    rep(i,m) sum[i+1] = sum[i] + u[i];

    int ans = 0;
    rep(i,m+1){
        if(sum[i] > T) break;
        int j = 0;
        while(true){
            if(sum[i] + dp[j+1] <= T){
                j++;
            }else{
                break;
            }
        }
        ans = max(ans, i+j);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define int long long
#define len(x) x.size()
#define rep(i,a) for(int i=0;i<a;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

signed main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(a + b >= k) cout<<min(k, a);
	else{
		cout<<a - (k - (a + b));
	}
	return 0;
}

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

int main(){
	int N, M;
  cin >> N >> M;
  vector<int> v(N+1);
  int a, b;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    v.at(a)++;
    v.at(b)++;
  }
  for(int i = 1; i <= N; i++){
    cout << v.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char **argv)
{
    int n;
    char s[124];
    scanf("%d %s", &n, s);

    int x = 0;
    int max = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'I') {
            x++;
        } else {
            x--;
        }
        if (x > max) {
            max = x;
        }
    }
    printf("%d\n", max);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<int> dp(n + 1, 1e9);
	dp[0] = 0;
	rep(i,n - 1){
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(a.at(i + 1) - a.at(i)));
		if(i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(a.at(i + 2) - a.at(i)));
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int x,y;
    while(1)
    {
        cin>>x>>y;
        if(x==0&&y==0)
            break;
        if(x>y) cout<<y<<" "<<x<<endl;
        else cout <<x<<" "<<y<<endl;
    }

    return 0;
}



Measured memory_bytes: 3004
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int x = x2-x1, y = y2-y1;
  cout << x2-y << " " << y2+x << " " << x1-y << " " << y1+x << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

h,w,m = map(int,input().split())
Ms = []

h_scores = [0 for i in range(h)]
w_scores = [0 for i in range(w)]

record = set()

for i in range(m):
  h,w = map(int,input().split())
  record.add((h-1,w-1))
  h_scores[h-1] += 1
  w_scores[w-1] += 1

max_h = max(h_scores)
max_w = max(w_scores)
max_h_poss = [i for i,v in enumerate(h_scores) if v == max_h]
max_w_poss = [i for i,v in enumerate(w_scores) if v == max_w]

out_pos_count = 0 

c = False

for i in max_h_poss:
    for j in max_w_poss:
        if (i,j) not in record:
            c = True
            break        

if c:
    print(max(h_scores) + max(w_scores))
else:
    print(max(h_scores) + max(w_scores)-1)

Measured memory_bytes: 83864
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long ll;

int main() {
    string s;   cin >> s;
    bool can = true;
    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

typedef vector <int> vi;
typedef vector <long long> vl;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define ll long long
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#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 um unordered_map
#define F first
#define S second

ll modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int n;
    cin >> n;
    if (n == 1)
    	cout << "Hello World" << endl;
    else
    {
    	int a,b;
    	cin >> a >> b;
    	cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256