akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

vector<ll> answer;

void helper(ll i,vector<ll>cost, vector<vector<ll>>arr,ll N,ll M,ll X){
    if(i<N){
        vector<ll> tempCost=cost;
        for(int j=0;j<=M;j++)
            cost[j]+=arr[i][j];

        bool flag=false;
        for(int j=1;j<=M;j++){
            if(cost[j]<X){
                flag=true; break;
            }
        }
        if(flag){
            //including
            helper(i+1,cost,arr,N,M,X);
            //excluding
            helper(i+1,tempCost,arr,N,M,X);
        }
        else{
            answer.push_back(cost[0]);
            helper(i+1,tempCost,arr,N,M,X);
        }
    }
}
int main(){
   ll N,M,X;
       cin>>N>>M>>X;
       vector<ll> cost(M+1,0);
       vector<vector<ll>> arr(N,vector<ll>(M+1,0));
       for(int i=0;i<N;i++)
        for(int j=0;j<=M;j++)
            cin>>arr[i][j];
       helper(0,cost,arr,N,M,X);
       if(answer.size()==0){
        cout<<-1;
        return 0;
       }
       cout<<*min_element(answer.begin(),answer.end());
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    int sup[] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
    int fre = 0;
    int cnt[8] = {};
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        for (int i = 0; i <= 8; i++) {
            if (i < 8 && x < sup[i]) {
                cnt[i]++; break;
            }
            if (i == 8) fre++;
        }
    }
    int base = 0;
    for (int i = 0; i < 8; i++) {
        base += cnt[i]>0;
    }
    cout << max(1,base) << ' ' << (base+fre);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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 a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = 1;
  rep(i, N) {
    if(ans * 2 < ans + K) {
      ans *= 2;
    } else {
      ans += K;
    }
  }

  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3612
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int m1 = scan.nextInt();
        int d1 = scan.nextInt();
        int m2 = scan.nextInt();
        int d2 = scan.nextInt();
        System.out.println(m1 == m2 ? 0 : 1);
        scan.close();
    }
}

Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n, m);
    Cins2(int, n, sx, sy);
    Cins2(int, m, cx, cy);
    For(i, n){
        int x = sx[i], y = sy[i];
        int ansi = 0;
        int ans = abs(x-cx[ansi]) + abs(y-cy[ansi]);
        for(int j = 1; j < m; j ++){
            int ant = abs(x-cx[j]) + abs(y-cy[j]);
            if(ant < ans){
                ans = ant, ansi = j;
            }
        }
        Cout(ansi+1);
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;

const int inf=1e8;
const double eps=1e-9;

const int MN=100;

double mat[MN+1][MN+1];
int N;

void swapRows(int i,int j){
	for(int k=0;k<=N;k++){
		swap(mat[i][k],mat[j][k]);
	}
}

void swapCols(int i,int j){
	for(int k=0;k<=N;k++){
		swap(mat[k][i],mat[k][j]);
	}
}

void sweep(int i,int j){
	if(mat[i][j]<eps) return;
	for(int k=0;k<N;k++){
		if(i==k) continue;
		if(abs(mat[k][j])>eps){
			double coe=mat[k][j]/mat[i][j];
			for(int m=0;m<=N;m++){
				mat[k][m]-=coe*mat[j][m];
			}
		}
	}
}

void toOne(int i,int j){
	if(abs(mat[i][j])<eps) return;
	double a=mat[i][j];
	for(int k=0;k<=N;k++){
		mat[i][k]/=a;
	}
}

void solve(){
	for(int i=0;i<N;i++){
		if(abs(mat[i][i])<eps){
			bool flg=false;
			for(int j=i;j<N;j++) for(int k=i;k<N;k++){
				if(abs(mat[j][k])>eps){
					flg=true;
					if(i!=j) swapRows(i,j);
					if(i!=k) swapCols(i,k);
					break;
				}
			}
			if(flg==false) break;
		}
		toOne(i,i);
		sweep(i,i);
	}
}

int g[MN][MN];
int dis[MN][MN];

bool exiSign[MN];

int main(){
	while(true){
		int S,T;
		scanf("%d%d%d",&N,&S,&T);
		if(N==0&&S==0&&T==0) break;
		S--;T--;
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				dis[i][j]=inf;
			}
		}
		for(int i=0;i<N;i++){
			int in;
			scanf("%d",&in);
			if(in==0) exiSign[i]=false;
			else exiSign[i]=true;
		}
		for(int i=0;i<N;i++) for(int j=0;j<N;j++){
			scanf("%d",&g[i][j]);
			if(g[i][j]>0) dis[i][j]=g[i][j];
			if(i==j) dis[i][j]=0;
		}
		for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++){
			dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
		}
		if(dis[S][T]==inf){
			printf("impossible\n");
			continue;
		}
		for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) mat[i][j]=0;
		for(int i=0;i<N;i++) mat[N][i]=i;
		for(int i=0;i<N;i++){
			if(i==T){
				for(int j=0;j<=N;j++) mat[i][j]=0;
				mat[i][i]=1;
				continue;
			}
			for(int j=0;j<=N;j++) mat[i][j]=0;
			for(int j=0;j<N;j++){
				if(g[i][j]==0) continue;
				if(exiSign[i]&&g[i][j]>0&&dis[i][T]!=dis[j][T]+g[i][j]) continue;
				mat[i][N]+=g[i][j];
				mat[i][j]-=1;
				mat[i][i]+=1;
			}
		}
		solve();
		double ans=0;
		for(int i=0;i<N;i++){
			if(mat[N][i]==S){
				ans=mat[i][N];
			}
		}
		printf("%.9f\n",ans);
	}
	return 0;
}

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

int main(){
	int e;
	while(true){
		cin >> e;
		if(e==0){
			break;
		}
		int x=0,y=0,z=0;
		
		int ans = e;

		for(z=0;z*z*z <= e;z++){
			for(y=0;y*y+z*z*z <= e; y++){
				int buf = e - (y*y+z*z*z);
				ans = min(ans,buf+y+z);
			}
		}


		cout << ans <<endl;
		/*
		for(x=0;x<=e;x++){
			for(y=0;y*y+x<=e;y++){
				for(z=0;z*z*z+y*y+x<=e;z++){
					if(z*z*z+y*y+x==e){
						ans = min(ans,x+y+z);
					}
				}
			}
		}
		cout << ans << endl;
		*/
	}
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int h,a,r;
    cin>>h>>a;
    if(h%a==0)
    {
        r=h/a;
    }
    else{
            if(h<a)
            {
                cout<<1<<endl;
                return 0;
            }
        r=h/a;
        r++;
    }
    cout<<r<<endl;


    return 0;
}


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

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

    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    for (int r = 0; r * R <= N; ++r) {
        for (int g = 0; g * G <= N; ++g) {
            int res = N - r * R - g * G;
            if (res < 0) continue;
            if (res % B) continue;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
Alist=list(map(int,input().split()))
Alist.sort()
ans=1
err=0
for i in range(N):
  ans=ans*Alist[i]
  if ans>10**18:
    print(-1)
    err=1
    break
if err==0:
  print(ans)

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


int main() {
  int a, b;
  cin >> a >> b;
  cout << (((a*b)%2==0)?"No":"Yes") << endl;
  return 0;
  
}

Measured memory_bytes: 256
import itertools
import sys

n, m, x = map(int, input().split())
num = list(list(map(int, input().split())) for i in range(n))

s = [i for i in range(n)]
t = []
list_num = []

for i in range(n):
  t.append(list(map(list, itertools.combinations(s, i + 1))))


for i in t:
  for j in i:
    k = [0] * (m + 1)
    for z in j:
      k = tuple(x + y for (x,y) in zip(k, num[z]))
    list_num.append(k)


list_num = list(sorted(list_num, key =lambda w : w[0]))
q = []

flag2 = 0

for i in list_num:
  flag = 1
  for j in range(1, m + 1):
    if(i[j] < x):
      flag = 0
  if(flag == 1):
    q.append(i[0])
    flag2 = 1

if(flag2 == 1):
  print(min(q))
else: 
  print(-1)   


Measured memory_bytes: 71020
#include <iostream>
using namespace std;
int main()
{
	long long lucas[100];
	lucas[0]=2;
	lucas[1]=1;
	for(int i=2;i<=86;i++)
	{
		lucas[i]=lucas[i-1]+lucas[i-2];
	}
	int n;
	cin>>n;
	cout<<lucas[n];
	return 0;
}

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

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<long long> a(n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	std::vector<long long> dp(n + 1);
	std::stack<std::pair<int, int>> free;
	dp[1] = 1;
	long long left{-2 * a[0]};
	for (int i = 2; i <= n; i++)
	{
		long long next{-2 * a[i - 1]};
		dp[i] = dp[i - 1] + 1;
		while (left > next)
		{
			if (free.empty())
				dp[i] += 2 * (i - 1);
			else
			{
				free.top().second--;
				dp[i] += 2 * (i - free.top().first);
				if (free.top().second == 0)
					free.pop();
			}
			left *= 4;
		}
		if (left <= 4 * next)
		{
			free.push({i, 0});
			long long tmp{next};
			while (left <= 4 * tmp)
			{
				free.top().second++;
				tmp *= 4;
			}
		}
		left = next;
	};
	std::vector<long long> dp_rev(n + 1);
	std::stack<std::pair<int, int>> free_rev;
	long long right{a[n - 1]};
	for (int i = n - 2; i >= 0; i--)
	{
		long long next{a[i]};
		dp_rev[i] = dp_rev[i + 1];
		while (next > right)
		{
			if (free_rev.empty())
				dp_rev[i] += 2 * (n - 1 - i);
			else
			{
				free_rev.top().second--;
				dp_rev[i] += 2 * (free_rev.top().first - i);
				if (free_rev.top().second == 0)
					free_rev.pop();
			}
			right *= 4;
		}
		if (4 * next <= right)
		{
			free_rev.push({i, 0});
			long long tmp{next};
			while (4 * tmp <= right)
			{
				free_rev.top().second++;
				tmp *= 4;
			}
		}
		right = next;
	}
	long long min{(long long)1 << 60};
	for (int i = 0; i < n + 1; i++)
		min = std::min(min, dp[i] + dp_rev[i]);
	printf("%lld\n", min);

	return 0;
}

Measured memory_bytes: 4992
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M= map(int, readline().split())
H = [0] + list(map(int,readline().split()))
data = [[] for _ in range(N+1)]
for _ in range(M):
    a,b = map(int,readline().split())
    data[a].append(b)
    data[b].append(a)
flag = [True]*(N+1)
for i in range(1,N+1):
    if flag[i] == False:
        continue
    for k in data[i]:
        if  H[i] > H[k]:
            flag[k] = False
        else:
            flag[i] = False
print(flag.count(True)-1)  

Measured memory_bytes: 29872
#include<iostream>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
int dp[22][1<<22];
int a[22][22];
int main(){
    int n;scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) scanf("%d",&a[i][j]);
    }
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int x=0;x<(1<<n);x++)if(dp[i][x]){
            for(int j=0;j<n;j++)if(x>>j&1){}
            else if(a[i][j]){
                int&t=dp[i+1][x|(1<<j)];
                t+=dp[i][x];
                if(t>=mod) t-=mod;
            }
        }
    }
    printf("%d",dp[n][(1<<n)-1]);
}


Measured memory_bytes: 178432
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int N, M, X, Y, A, B, C;
string S;

void solve() {

	double T;
	cin >> A >> B >> T;
	int ans=0;
	int i = 1;
	while (i * A <= T + 0.5) {
		ans += B;
		i++;
	}

	cout << ans << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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

bitset <(1 << 22)> dp;

int main(){
	int n, sum, x;
	scanf("%d",&n);
	sum = 0;
	dp[0] = 1;
	for (int i = 1; i <= n; i++){
		scanf("%d",&x);
		dp |= dp << x;
		sum += x;
	}
	for (int i = (sum + 1) / 2; ; i++){
		if (dp[i]){
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}

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


int main() {
string w;
cin >> w;
vector<int> vec;
for (int i = 'a'-'0';i <= 'z'-'0';i++) {
    int cnt = 0;
    for (int j = 0;j < w.size();j++) {
        if (w.at(j)-'0' == i) cnt++;
    }
    if (cnt % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
}

cout << "Yes" << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;


int main() {

    long long int N; cin >> N;
     long double n = (double)N / 3;
    cout << setprecision(9) << n * n * n << endl;
}


Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

q = deque([0])
d = [-1 for _ in range(N)]
d[0] = 0
ans = [0]*N
while q:
    p = q.popleft()
    for node in G[p]:
        if d[node] == -1:
            d[node] = d[p] + 1
            q.append(node)
        else:
            if d[node] + 1 == d[p]:
                ans[p] = node + 1
print('Yes')
for i in range(1, N):
    print(ans[i])

Measured memory_bytes: 37816
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];for(int i=0;i<n;i++)cin>>a[i];
  double s=0;
  for(int i=0;i<n;i++)s+=a[i];
  s=s/(n*1.0);
  double m=100000000;
  int ans;
  for(int i=0;i<n;i++){
    if(abs(a[i]-s)<m){
      ans=i;
      m=abs(a[i]-s);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,m;
  cin >> n >> m;
  vl a(n);
  rep(i,n) cin >> a[i];
  vp cb;
  rep(i,m) {
    ll x,y;
    cin >> x >> y;
    cb.push_back(make_pair(y,x));
  }
  rep(i,n) cb.push_back(make_pair(a[i],1));
  sort(cb.begin(),cb.end());
  ll sum=0;
  vl d;
  rep(i,cb.size()){
    if(sum <= n){
      rep(j,cb[cb.size()-1-i].second) d.push_back(cb[cb.size()-1-i].first);
    }
    sum += cb[cb.size()-1-i].second;
  }
  sort(all(d));
  
  
  ll ans = 0;
  rep(i,n) { 
    
    ans += d[d.size()-1-i];
    
  }
    cout << ans;
  
 return 0;
}

Measured memory_bytes: 8044
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
#define SIZE 200000
class unionfind
{
public:
	int par[SIZE];
	int ran[SIZE];
	int ren[SIZE];
	void init()
	{
		for(int i=0;i<SIZE;i++)
		{
			par[i]=i;
			ran[i]=0;
			ren[i]=1;
		}
	}
	int find(int a)
	{
		if(a==par[a])return a;
		else return par[a]=find(par[a]);
	}
	void unite(int a,int b)
	{
		a=find(a);
		b=find(b);
		if(a==b)return;
		if(ran[a]>ran[b])
		{
			par[b]=a;
			ren[a]+=ren[b];
		}
		else
		{
			par[a]=b;
			ren[b]+=ren[a];
		}
		if(ran[a]==ran[b])ran[b]++;
	}
};
unionfind uf;
int main()
{
	uf.init();
	int num,gen;
	scanf("%d%d",&num,&gen);
	for(int i=0;i<num;i++)
	{
		int z;
		scanf("%d",&z);
		for(int j=0;j<z;j++)
		{
			int a;
			scanf("%d",&a);
			a--;
			uf.unite(i,a+100000);
		}
	}
	int t=uf.find(0);
	for(int i=0;i<num;i++)
	{
		if(t!=uf.find(i))
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
}

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

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    
    if(A == 1 || B == 1){
        if(A == 1 && B == 1){
            cout << "Draw\n";
        }
        else if(A != 1){
            cout << "Bob\n";
        }
        else{
            cout << "Alice\n";
        }
    }
    else{
        if(A > B){
            cout << "Alice\n";
        }
        else if(A == B){
            cout << "Draw\n";
        }
        else{
            cout << "Bob\n";
        }
    }
}

Measured memory_bytes: 256
# N = gets.chomp.to_i
A, B = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

cand = []

0.upto(10000).each do |p|
  if ((p * 0.08).to_i == A) && ((p * 0.1).to_i == B)
    cand << p
  end
end

if cand.size > 0
  p cand[0]
else
  p(-1)
end

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  string s;
  cin >> s;
  replace(ALL(s), ',', ' ');
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
using vc = vector<char>; using vvc = vector<vc>;
using vp = vector<pair<int,int>>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main(){
  ll d,t,s;cin >> d >> t >> s;
  if(d > t*s) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String W, temp, smallW, smallt;
        ArrayList<String> t = new ArrayList<String>();
        int count = 0;

        W = sc.next();

        while(true){
            temp = sc.next();
            if(temp.equals("END_OF_TEXT")) break;
            t.add(temp);
        }

        for(int i = 0; i < t.size(); i++){
            smallW = W.toLowerCase();
            smallt = t.get(i).toLowerCase();
            if(smallt.equals(smallW)) count++;
        }

        System.out.println(count);

        sc.close();
    }
}


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


int main() 
{
    int A, B;
    scanf("%d %d", &A, &B);

    int vacant = 1;
    int tap = 0;
    while (vacant < B) {
        tap++;
        vacant += (A - 1);
    }
    printf("%d\n", tap);

    return 0;
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll n;
  cin>>n;
  vll v(n);
  vll ve(n);
  FOR(i,0,n){
    cin>>v[i];
    ve[i]=v[i];
  }
  SORT(ve);
  
  FOR(i,0,n){
    if(v[i]!=ve[n-1]){
      co(ve[n-1]);
    }
    if(v[i]==ve[n-1]){
      co(ve[n-2]);
    }
  }
}
        

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    while(a>0 && c>0){
        c = c - b;
        a = a - d;
    }
    
    if(c <= 0){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var pqr = CinTAr();
            Array.Sort(pqr);
            Cout(pqr[0] + pqr[1]);
            Cin();
        }


        static string Cin() { return Console.ReadLine(); }
        static string[] CinAr() { return Console.ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void Cout(object s) { Console.WriteLine(s); }
        static void DbShowE<Type>(IEnumerable<Type> types)
        {
            foreach(var i in types)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
using namespace std;
int bo[26];
string s;
main() {
	while (1) {
		getline(cin, s);
		if (!s.size()) break;
		for (int i = 0; i < s.size(); ++i) {
			if ('a' <= s[i] && s[i] <= 'z') bo[s[i]-'a']++;
			else if ('A' <= s[i] && s[i] <= 'Z') bo[s[i]-'A']++;
		}	
	}
	for (char c = 'a'; c <= 'z'; ++c) {
		cout << c << " : " << bo[c-'a'] << endl;
	}
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
long long gcd(long long a,long long b){
    while(a&&b){
        if(a>b) a = a%b;
        else b = b%a;
    }
    return a+b;
}


int main()
{
    int a,b,c;
    std::cin >> a >> b >> c;
    int tmp = gcd(a,b);
    std::cout << (c % tmp ? "NO" : "YES") << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NOT_FOUND -1

int linearSearch(int[],int);

int n;

int main(){
    int q,count = 0;
    int S[MAX],T[MAX];

    scanf("%d",&n);
    for(int i = 0;i < n;i++)scanf("%d",&S[i]);

    scanf("%d",&q);
    for(int i = 0;i < q;i++)scanf("%d",&T[i]);

    for(int i = 0;i < q;i++)if(linearSearch(S,T[i]) >= 0)count++;

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

    return 0;
}

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


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

int main() {
    int n,x[100]={0},y[100]={0};
    double t,D1,D2,D3,D4;
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=0;i<n;i++){
        cin >> y[i];
    }
    
    D1=D2=D3=D4=0;

    for(int i=0;i<n;i++){
        t = fabs(x[i]-y[i]);
        D1 += t;
        D2 += pow(t,2);
        D3 += pow(t,3);
        if(D4 < t) D4 = t;
    }
    
    cout << fixed;
    cout.precision(6);
    cout << D1 << endl << sqrt(D2) << endl << cbrt(D3) << endl << D4 << endl;
    
}


Measured memory_bytes: 3424
#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;
#define ll long long int

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

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

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}



int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int h,n;
cin>>h>>n;
int a[n];
ll s=0;
for(int i=0;i<n;i++)
{
    cin>>a[i];
    s+=a[i];
}
if(s>=h)
{
    cout<<"Yes";
}
else
{
    cout<<"No";
}
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();

		int min = Math.min(p+q, Math.min(p+r,q+r));
		System.out.println(min);

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <queue>
#include <set>
#include <utility>
#include <string>
using namespace std;

int main() {
    queue<pair<int,pair<int,int>>> q;
    set<pair<int,int>> p;
    int h,w;
    cin >> h >> w;
    string buf;
    for(int y = 0;y < h;y++) {
        cin >> buf;
        for(int x = 0;x < w;x++) {
            if(buf[x] == '#') {
                q.push(make_pair(0,make_pair(x,y)));
            } else {
                p.insert(make_pair(x,y));
            }
        }
    }
    int res = 0;
    int f[4][2] = {{0,1},{0,-1},{1,0},{-1,0}};
    while(!q.empty()) {
        auto& c = q.front().second;
        int n = q.front().first;
        res = max(res,n);
        for(int i = 0;i < 4;i++) {
            auto d = p.find(make_pair(c.first+f[i][0],c.second+f[i][1]));
            if(d != p.end()) {
                q.push(make_pair(n+1,make_pair(c.first+f[i][0],c.second+f[i][1])));
                p.erase(d);
            }
        }
        q.pop();
    }
    cout << res << endl;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main() {
    fastio;
    int t,n=0;
    cin>>t;
    int a[t];
    for(int i=0;i<t;i++) cin>>a[i];
    sort(a,a+t);
    cout<<a[t/2]-a[(t/2)-1];
    return 0;
    }


Measured memory_bytes: 640
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define IL inline
#define reg register
#define LL long long
#define N 200010
#define INF 0x3f3f3f3f
using namespace std;

int n,i,j;
int ans=INF;
set <int> S[N*4];

struct Data{
	int x,y;
	char c;
}a[N];

IL int Abs(int x){return (x<0)?-x:x;}
IL void Swap(int &a,int &b){a^=b^=a^=b;}
IL int Min(int a,int b){return (a<b)?a:b;}
IL int Max(int a,int b){return (a>b)?a:b;}

IL int read(){
	int p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	n=read();
	for (i=1;i<=n;i++){
		a[i].x=read();	a[i].y=read();	a[i].c=getchar();
	}
	if (n==1){
		puts("SAFE");
		return 0;
	}

	for (i=1;i<=n;i++)
		if (a[i].c=='U')	S[a[i].x+a[i].y].insert(a[i].x);
	
	for (i=1;i<=n;i++){
		if (a[i].c=='R'){
			if (!S[a[i].x+a[i].y].size())	continue;
			j=*(--S[a[i].x+a[i].y].end());
			if (j<a[i].x)	continue;
			j=*S[a[i].x+a[i].y].upper_bound(a[i].x);
			ans=Min(ans,j-a[i].x);
		}
	}
	for (i=0;i<4*N;i++)	S[i].clear();
	//U--R

	for (i=1;i<=n;i++)
		if (a[i].c=='D')	S[a[i].x+a[i].y].insert(a[i].x);
	
	for (i=1;i<=n;i++){
		if (a[i].c=='L'){
			if (!S[a[i].x+a[i].y].size())	continue;
			j=*S[a[i].x+a[i].y].begin();
			if (j>a[i].x)	continue;
			j=*(--S[a[i].x+a[i].y].upper_bound(a[i].x));
			ans=Min(ans,a[i].x-j);
		}
	}
	for (i=0;i<4*N;i++)	S[i].clear();
	//D--L


	for (i=1;i<=n;i++)
		if (a[i].c=='R')	S[a[i].y-a[i].x+N].insert(a[i].x);
	
	for (i=1;i<=n;i++){
		if (a[i].c=='D'){
			if (!S[a[i].y-a[i].x+N].size())	continue;
			j=*S[a[i].y-a[i].x+N].begin();
			if (j>a[i].x)	continue;
			j=*(--S[a[i].y-a[i].x+N].upper_bound(a[i].x));
			ans=Min(ans,a[i].x-j);
		}
	}
	for (i=0;i<4*N;i++)	S[i].clear();
	//D--R
	

	for (i=1;i<=n;i++)
		if (a[i].c=='L')	S[a[i].y-a[i].x+N].insert(a[i].x);
	
	for (i=1;i<=n;i++){
		if (a[i].c=='U'){
			if (!S[a[i].y-a[i].x+N].size())	continue;
			j=*(--S[a[i].y-a[i].x+N].end());
			if (j<a[i].x)	continue;
			j=*S[a[i].y-a[i].x+N].upper_bound(a[i].x);
			ans=Min(ans,j-a[i].x);
		}
	}
	for (i=0;i<4*N;i++)	S[i].clear();
	//D--R
	if (ans!=INF)	ans*=2;


	for (i=1;i<=n;i++)
		if (a[i].c=='R')	S[a[i].y].insert(a[i].x);
	
	for (i=1;i<=n;i++){
		if (a[i].c=='L'){
			if (!S[a[i].y].size())	continue;
			j=*S[a[i].y].begin();
			if (j>a[i].x)	continue;
			j=*(--S[a[i].y].upper_bound(a[i].x));
			ans=Min(ans,a[i].x-j);
		}
	}
	for (i=0;i<4*N;i++)	S[i].clear();
	//L--R

	for (i=1;i<=n;i++)
		if (a[i].c=='U')	S[a[i].x].insert(a[i].y);
	
	for (i=1;i<=n;i++){
		if (a[i].c=='D'){
			if (!S[a[i].x].size())	continue;
			j=*S[a[i].x].begin();
			if (j>a[i].y)	continue;
			j=*(--S[a[i].x].upper_bound(a[i].y));
			ans=Min(ans,a[i].y-j);
		}
	}
	for (i=0;i<4*N;i++)	S[i].clear();
	//U--D

	if (ans==INF)	puts("SAFE");
	else cout<<ans*5<<endl;	
	return 0;
}

Measured memory_bytes: 52472
from itertools import combinations as comb
import numpy as np


def main():
    p, q, r = map(int, input().split())
    abc_comb = np.array(list(comb([p, q, r], 2)))
    print(np.min(np.sum(abc_comb, axis=1)))


if __name__ == "__main__":
    main()


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

int main() {
  int N,A,B,C,D;
  cin >> N;
  A=N/1000;
  B=(N-1000*A)/100;
  C=(N-1000*A-100*B)/10;
  D=N-1000*A-100*B-10*C;
  if (A==B && B==C) {
    cout << "Yes" << endl;
  }
  else if (B==C && C==D) {
    cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/*
AtCoderBeginnerContest167
Problem B - Easy Linear Programming /
Time Limit: 2 sec / Memory Limit: 1024 MB
Score :
200
points
*/

#include <iostream>

int main()
{
    int A, B, C, K;
    std::cin >> A >> B >> C >> K;
    int slack = K - (A+B);
    if (slack <= 0)
    {
        if (K < A)
        {
            std::cout << K << "\n";
        }
        else
        {
            std::cout << A << "\n";
        }
    }
    else
    {
        std::cout << (A - slack) << "\n";
    }
}


Measured memory_bytes: 3600
package main

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

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	var a [5]int
	for i := 0; i < 5; i++ {
		a[i], _ = io.nextInt()
	}
	k, _ := io.nextInt()

	if a[4]-a[0] > k {
		io.PutString(":(")
		return
	}
	io.PutString("Yay!")
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 640
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt

    ((N + 1) / 2).toString
  }
}


Measured memory_bytes: 25916
#include <bits/stdc++.h>
using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)

int main(void) {
  int n, k, INF = 1e9 + 7;
  cin >> n >> k;
  vector <int> v(n);
  ffor(n) cin >> v[i];
  vector <int> dp(n, INF);
  dp[0] = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < min(i + 1 + k, n); j++) {
      dp[j] = min(dp[j], dp[i] + abs(v[j] - v[i]));
    }
  }
  cout << dp.back() << '\n';
}

Measured memory_bytes: 4016
using System;
public class P{
  public static void Main(){
    string a="";
    var s=Console.ReadLine().ToCharArray();
    foreach (char x in s){if(x!='B')a+=x;else if(a!="")a=a.Substring(0,a.Length-1);}
    Console.WriteLine(a);
  }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
const int N=2e5;
int main()
{
	int A,B;
	cin>>A>>B;
	int ans=B*10;
	while(floor(ans*0.08)!=A&&floor(ans*0.1)==B){
		ans++;
	}
	if(floor(ans*0.08)==A&&floor(ans*0.1)==B){
		cout<<ans;
	}
	else {
		cout<<-1;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;import java.util.Collections;

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
	    String str=reader.readLine();
	    String s[]=str.split(" ");
	    int h=Integer.parseInt(s[0]);
	    int r=Integer.parseInt(s[1]);

	    int top=h+r;
	    int bottom=h-r;
	    if(top<0){
		System.out.println("-1");
	    }else if(top==0){
		System.out.println("0");
	    }else if(top>0){
		System.out.println("1");
	    }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



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

int main(){
	int n, m; scanf("%d%d", &n, &m);
	int z = (n-1)/2;
	int a = z - (z+1)%2, b = z - z%2;
	DEBUG("a=%d b=%d\n", a, b);
	for(int i = 1; i <= a; i += 2) {
		printf("%d %d\n", (a+1)/2 - i/2, (a+3)/2 + i/2);
		if(!--m) return 0;
	}
	int d = a + 1 + b/2 + 1;
	for(int i = 2; i <= b; i += 2) {
		printf("%d %d\n", d-i/2, d+i/2);
		if(!--m) return 0;
	}
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    double arr[55];

    cin>>n;

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

    sort(arr, arr + n);
    double prev = arr[0];
    for(int i = 1; i < n; i++){
        double curr = (prev + arr[i]) / 2;
        prev = curr;
    }

    cout<<setiosflags(ios::fixed)<<setprecision(10);
    cout<<prev<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n,t[195],m,p[195],q[195],ans=0;
cin>>n;
for(int i=0;i<195;i++){
t[i]=0;
p[i]=0;
q[i]=0;
}
for(int i=1;i<=n;i++){
cin>>t[i];
ans+=t[i];
}
cin>>m;
for(int i=0;i<m;i++){
cin>>p[i]>>q[i];
cout<<ans-t[p[i]]+q[i]<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int W;
	int H;
	int x;
	int y;
	int r;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if(x+r <= W && x+r > 0 && y+r <= H && y+r > 0){
		printf("Yes\n");
	}else if(x+r > W || x+r <= 0 || y+r > H || y+r <= 0){
		printf("No\n");
	}return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <cmath>

int n, a[100005], b[100005], c[100005];
long long dp[100005][3];
int main() {
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i] >> b[i] >> c[i];

	for (int i = 0; i < n; ++i) {
		dp[i + 1][0] = std::max(dp[i][1] + a[i], dp[i][2] + a[i]);
		dp[i + 1][1] = std::max(dp[i][0] + b[i], dp[i][2] + b[i]);
		dp[i + 1][2] = std::max(dp[i][0] + c[i], dp[i][1] + c[i]);
	}

	long long ans = 0;
	for (int i = 0; i < 3; ++i)
		ans = std::max(ans, dp[n][i]);

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


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pr;
typedef vector<ll> vll;
typedef vector<vector<int>> vv;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = a * x + b * y;
  if (x > y)
    ans = min(ans, c * y * 2 + a * (x - y));
  else
    ans = min(ans, c * x * 2 + b * (y - x));
  ans = min(ans, max(x, y) * c * 2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int N,B[100010],x;

int main(){
  cin>>N;
  for(int i=0;i<N-1;i++){
    cin>>B[i];
  }
  x=B[0];
for(int i=0;i<N-2;i++){
  if(B[i]<=B[i+1]){
    x=x+B[i];
  }else{
    x=x+B[i+1];
  }
}
x=x+B[N-2];
cout<<x;

 return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int n;
LL A, B, C, D;

int main()
{
	while (~scanf("%d%lld%lld%lld%lld", &n, &A, &B, &C, &D)) {
		bool flag = false;
		for (int m = 0; m <= n; m++) {
			LL L = C * m - D * (n - 1 - m) + A;
			LL R = D * m - C * (n - 1 - m) + A;
			if (L <= B && B <= R) flag = true;
		}
		if (flag) printf("YES\n"); else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define N 101

int main(){

  int i,j,n=0,x=0,y=0,z=0;
  int Adj[N][N];

  scanf("%d",&n);

  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){

      Adj[i][j] = 0;

    }
  }

  for(i=1 ; i<=n ; i++){
    scanf("%d%d",&x,&y);
    for(j=1 ; j<=y ; j++){
      scanf("%d",&z);
      Adj[x][z]=1;
    }
  }

    for(i=1 ; i<=n ; i++){
      for(j=1 ; j<=n ; j++){
	printf("%d",Adj[i][j]);
	if(j!=n){
	  printf(" ");
	}
      }
      printf("\n");
    }

    return 0;
  } 

Measured memory_bytes: 640
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define int long long
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int INF = 1e18;
const int M = 1e9 + 7;





signed main()
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	int n, m;
	scanf("%lld%lld", &n, &m);
	int tot = (n - 1) * (n - 2) / 2;
	if(m > tot) {
		cout << -1 << endl;
		return 0;
	}
	int res = n - 1 + (tot - m);
	cout << res << endl;
	for(int i = 1; i < n; ++i){
		printf("%lld %lld\n", n, i);
	}
		for(int i = 1; i < n; ++i){
			for(int j = i + 1; j < n; ++j){
				if(tot > m) {
					printf("%lld %lld\n", i, j);
					--tot;
				}
				if(tot == m) return 0;
			}
		}




    
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

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

//********************************template END****************************************//

void solve(void){

	int N;
	cin >> N;
	vecll vs(N), rs(N, 0), xs(N);
	rep(N, i) cin >> vs[i];

	sort(all(vs));
	rs = vs;
	xs = vs;
	reverse(all(rs));

	ll ans = 0, res = 0;

	/*
	do
	{
		cout << xs;
		ll tmp = 0;
		rep(N-1, i)
		{
			tmp += abs(xs[i]-xs[i+1]);
		}
		cout << tmp << endl;
		res = max(res, tmp);
	} while(next_permutation(all(xs)));

	//cout << res << endl;
	*/


	rep(N/2, i)
	{
		if (i == 0)
		{
			ans += abs(vs[0]-rs[0]);
			ans += abs(vs[1]-rs[0]);
			continue;
		}
		ans += abs(vs[i-1]-rs[i]);
		ans += abs(vs[i+1]-rs[i]);
	}

	ll cp = 0;

	rep(N/2, i)
	{
		if (i == 0)
		{
			cp += abs(rs[0]-vs[0]);
			cp += abs(rs[1]-vs[0]);
			continue;
		}
		cp += abs(rs[i-1]-vs[i]);
		cp += abs(rs[i+1]-vs[i]);
	}

	ans = max(ans, cp);

	cout << ans << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    
    vector<int> val;
    val.push_back(1);
    int t_val = 6;
    while(t_val <= n) { val.push_back(t_val); t_val *= 6; }
    t_val = 9;
    while(t_val <= n) { val.push_back(t_val); t_val *= 9; }


    vector<int> tbl(n + 1);
    int v_len = val.size();
    for(int i = 0; i < v_len; i++)
    {
        for(int j = val[i]; j < n + 1; j++)
        {
            if(i == 0) tbl[j] = tbl[j - 1] + 1;
            tbl[j] = (tbl[j] < tbl[j - val[i]] + 1) ? (tbl[j]) : (tbl[j - val[i]] + 1);
        }
    }
    cout << tbl[n] << endl;
}

Measured memory_bytes: 640
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, Q = sc.nextInt()
    sc.nextLine()
    val S = sc.nextLine()
    val leftAc = new Array[Int](N+1) // 左からi文字目までのACの数
    def leftAcCount(i: Int, acm: Int): Unit =
      if (i < N)
        if (S(i-1) == 'A' && S(i) == 'C') {
          leftAc(i) = acm + 1
          leftAcCount(i + 1, acm + 1)
        } else {
          leftAc(i) = acm
          leftAcCount(i + 1, acm)
        }
      else {}
    leftAc(0) = 0
    leftAcCount(1, 0)

    val results = (0 until Q) map { _ =>
      val l, r = sc.nextInt()
      leftAc(r-1) - leftAc(l-1)
    }
    println(results.mkString("\n"))
  }

}

Measured memory_bytes: 77596
#include<stdio.h>
int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key)i++;
  return i!=n;
}
int main(){
  int i,n,A[10000+1],q,key,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key))sum++;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 636