akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    
    // 入力処理をしつつ最大値を取得（dp配列用）
    ll n, a; cin >> n >> a;
    vi y(n+1); ll maxA = a;
    // 1-based
    repf(i, n){
        cin >> y[i];
        y[i] -= a;
        chmax(maxA, y[i]);
    }

    // y1...ynから任意の枚数選んで合計が0になる組み合わせを数える
    // dp[i][j]; y1..yiから0枚以上選んだ合計がj-n*maxAとなるような選び方
    ll sizeSum = 2*n*maxA;
    vvi dp(n+1, vi(sizeSum+1));

    // yiは負値を取る可能性があるため、0をn*maxA（Aも含めて全て最大値だった場合）にずらす
    // 1枚も選ばないで0となるパターンが1種類
    dp[0][n*maxA] = 1;
    for(ll i=1; i<=n; i++){
        for(ll j=0; j<=sizeSum; j++){
            // 範囲からはみ出る場合は1個前の結果を踏襲
            if(j-y[i]<0 || j-y[i]>sizeSum) dp[i][j] = dp[i-1][j];
            // 範囲に収まるものは選んだパターンと選ばなかったパターンを入れる
            else dp[i][j] = dp[i-1][j] + dp[i-1][j-y[i]];
        }
    }

    // 1枚も選ばないパターンを減算して出力
    cout << dp[n][n*maxA]-1 << endl;
}

Measured memory_bytes: 5280
/************************************************
 * Au: Hany01
 * Prob: agc001a
 * Email: hany01dxx@gmail.com & hany01@foxmail.com
 * Inst: Yali High School
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
#define Rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define X first
#define Y second
#define PB(a) push_back(a)
#define MP(a, b) make_pair(a, b)
#define SZ(a) ((int)(a).size())
#define ALL(a) a.begin(), a.end()
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define y1 wozenmezhemecaia

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

template <typename T> inline T read() {
	static T _, __; static char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}
//EOT

const int maxn = 205;

int n, a[maxn];
LL ans;

int main()
{
#ifdef hany01
	freopen("agc001a.in", "r", stdin);
	freopen("agc001a.out", "w", stdout);
#endif

	n = read<int>() << 1;
	For(i, 1, n) a[i] = read<int>();
	sort(a + 1, a + 1 + n);
	for (int i = 1; i <= n; i += 2) ans += a[i];
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int M, D;
    cin >> M >> D;

    int ans = 0;
    for (int m = 1; m <= M; ++m) {
        for (int d = 1; d <= D; ++d) {
            string s = to_string(d);
            if (s.size() == 2) {
                int d1 = s[1] - '0';
                int d10 = s[0] - '0';
                if (d1 >= 2 && d10 >= 2 && d1 * d10 == m)
                    ++ans;
            }   
        }   
    }   
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,p;
  string s;
  cin >> n;
  vector<pair<pair<string, int>, int>> rest(n);
  for(auto i=0;i<n;i++){
    cin>>s>>p;
    rest[i].first.first=s;
    rest[i].first.second=-p;
    rest[i].second=i+1;
  }
  sort(rest.begin(),rest.end());
  for(auto i:rest){
    cout<<i.second<<endl;
  }
}

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

int main() {
  int N, K, num = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if (num * 2 > num + K)
      num += K;
    else
      num *= 2;
  }
  cout << num << endl;
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> ADash(N);
    for(int i = 0; i < N; i++){
        cin>>A[i];
        ADash[i] = -1 * A[i];
    }

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

    for(int i : A){
        if(i * -1 == ADash[0])cout<<ADash[1] * -1<<endl;
        else cout<<ADash[0] * -1<<endl;
        // cout<<i<<" ";
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N,K;
    cin >> N >> K;
    if(K>(N-1)*(N-2)/2){
        cout << -1 << endl;
        return 0;
    }

    ll m = N - 1;
    vc<pair<ll, ll>> P;
    rep(i, m) P.eb(i, m);

    ll cnt = (N - 1) * (N - 2) / 2;
    ll s = 0;
    while(cnt>K){
        repe(i, s+1, m){
            P.eb(s, i);
            cnt--;
            if (cnt == K) break;
        }
        s++;
    }
    cout << (ll)P.size() << endl;
    for (auto &p : P) cout << p.first+1 << " " << p.second+1 << endl;

}

Measured memory_bytes: 512
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//* vamsicool007    You are never wrong to do the right thing    vamsicool007 *
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define int long long
typedef long long ll;
typedef long double ld;
const int MOD = 2019;
const int mod=1000000007;
const int N=200005;
vector<int>vis(N);
vector<vector<int>>adj(N);
void dfs(int v){vis[v]=1;for(auto i:adj[v]){if(!vis[i]){dfs(i);}}return;}
bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll ans=a>b?a:b;return ans;}
ll min(ll a,ll b){ll ans=a<b?a:b;return ans;}
int root(int a[],int i){while(a[i]!=i){a[i]=a[a[i]];i=a[i];}return i;}
void unionn(int a[],int i,int j){int root_i=root(a,i);int root_j=root(a,j);a[root_i]=root_j;return;}
// void fun()
// {
//     #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
//     #endif
// }

signed main()
{
    flash;
    //fun();
    int tt=1;
    //cin>>tt;
    while(tt--)
    { string s;
    cin >> s;
 
    reverse(s.begin(), s.end());
 
    int n = s.size();
 
    int md = 0;
    int b = 1;
    ll count[MOD] = {1, 0};

    // for(int i=0;i<100;i++)
    // 	cout<<count[i];

    //for(int i=0;i<)
    for (int i = 0; i < n; i++) {
        md = (md + (s[i]-'0') * b) % MOD;
        count[md]++;
        b = b * 10 % MOD;
        //cout<<md<<endl;
    }

    ll sum = 0;
    for (int i = 0; i < MOD; i++)
        if (count[i] >= 2) {
            sum += count[i] * (count[i]-1) / 2;
        }
 
    cout << sum << endl;
    }
 
    return 0;
}

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

int a[2001000],top=0;
char s[2001000];
main() {
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<=len;i++) {
		a[++top]=s[i];
		if(top>=2&&a[top]=='T'&&a[top-1]=='S')
			top-=2;
	}
	cout<<top<<"\n";
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int k,a,b;
	scanf("%d%d%d",&k,&a,&b);
	bool ok=false;
	for (int i=a;i<=b;++i)
		if (i%k==0) {
			ok=true;
			break;
		}
	puts(ok?"OK":"NG");
	return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
int main(void){
	
	int m,f,r;
	while(1){
		scanf("%d%d%d",&m,&f,&r);
		if(m==-1 && f==-1 && r==-1)break;
		if(m!=-1 && f!=-1){
			if(m+f>=80)printf("A\n");
			else if(m+f>=65)printf("B\n");
			else if(m+f>=50)printf("C\n");
			else if(m+f>=30)if(r>=50)printf("C\n");else printf("D\n");
			else if(m+f<30)printf("F\n");
		}else{
			printf("F\n");
		}
	}
	
	return 0;
}


Measured memory_bytes: 1900
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

inline int read(void) {
	int x = 0;
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x;
}

const int N = 100010;
int n, a[N], b[N], c[N];
long long cnt[N];

int main() {
	n = read();
	for (int i = 0; i < n; ++i) a[i] = read();
	sort(a, a + n);
	for (int i = 0; i < n; ++i) b[i] = read();
	sort(b, b + n);
	for (int i = 0; i < n; ++i) c[i] = read();
	sort(c, c + n);
	long long ans = 0;
	for (int i = 0; i < n; ++i)
		cnt[i] = (b[i] >= c[n - 1]) ? 0 : n - (upper_bound(c, c + n, b[i]) - c);
	cnt[n] = 0;
//	for (int i = 0; i < n; ++i) printf("%d ", cnt[i]); puts("");
	for (int i = n - 1; i >= 0; --i) cnt[i] += cnt[i + 1];
	for (int i = 0; i < n; ++i) {
		int pos = upper_bound(b, b + n, a[i]) - b;
		ans += cnt[pos];
	}
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n';
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    string s; cin >> s;
    REP(i,s.size()){
        if(i%2==0){if(s[i]=='L'){No; return 0;}}
        else{if(s[i]=='R'){No; return 0;}}
    }
    Yes;

    return 0;
}

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

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b && a > c) cout << b + c << endl;
  else if (b > a && b > c) cout << a + c << endl;
  else cout << a + b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
typedef long long goo;
using namespace std;
int main()
{
    char ch=0;
    int p=0,g=0;
    while(ch!='\n'){
        ch=getchar();
        if(ch=='p') p++;
        if(ch=='g') g++;
    }
    cout<<(p+g)/2-p;
    return 0;
}


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int x, y, s;
    while(cin>>x>>y>>s, x&&y&&s) {
        int ans = 0;
        for(int i=1; i<s; ++i) {
            for(int j=1; j<s; ++j) {
                int tmp = i*(100+x)/100+j*(100+x)/100;
                if(tmp!=s) continue;
                ans = max(ans, i*(100+y)/100+j*(100+y)/100);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3036
#include <deque>
#include <cstdio>
#include <algorithm>
using namespace std;

const int Maxn = 200000;

int N, K;
int A[Maxn + 5];

bool vis1[Maxn + 5], vis2[Maxn + 5];
int s[Maxn + 5];
deque<int> q;

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d %d", &N, &K);
	for(int i = 1; i <= N; i++)
		scanf("%d", &A[i]);
	for(int i = 1; i <= N; i++)
		if(A[i] > A[i - 1]) s[i] = s[i - 1] + 1;
		else s[i] = 1;
	s[N + 1] = 1;
	int tot = 0, ans = N - K + 1;
	for(int i = 1; i <= N; i++)
		if(s[i + 1] == 1 && s[i] >= K)
			tot++;
	if(tot) ans -= tot - 1;
	for(int i = N; i >= 1; i--) {
		while(!q.empty() && A[q.back()] > A[i])
			q.pop_back();
		while(!q.empty() && q.front() - i >= K)
			q.pop_front();
		q.push_back(i);
		if(i <= N - K && q.size() == 1)
			vis1[i] = true;
	}
	q.clear();
	for(int i = 1; i <= N; i++) {
		while(!q.empty() && A[q.back()] < A[i])
			q.pop_back();
		while(!q.empty() && i - q.front()>= K)
			q.pop_front();
		q.push_back(i);
		if(i > K && q.size() == 1)
			vis2[i] = true;
	}
	for(int i = 1; i + K <= N; i++)
		ans -= (vis1[i] && vis2[i + K]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(ll i = a ; i < b ; ++i)

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

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

const int MOD = 998244353  ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  

ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll power(ll a, ll n) { ll r=1;while(n){if(n&1)r=(r*a)%MOD;n>>=1;a=(a*a)%MOD;}return r%MOD;}
ll sq(int x) { ll ans = x*x ; return ans ; }
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) ; 
}
void read(vt<int> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}
void read(vt<ld> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}

bool prime(ll t) {
	for(ll i  =2 ; i*i <= t ; ++i) {
		if(t%i==0) 
			return 0 ; 
	}
	return 1 ; 
}

// ==========Start Here==============


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	
	ll n , m ; 
	cin >> n >> m ; 
	vt<int> a(n) ; 
	read(a) ; 
	ll l = 1 ; 
	vt<int> tmp(n) ; 
	rep(i,0,n) {
		l = lcm(a[i],l) ; 
		int t = 0 ; 
		int cpy = a[i] ; 
		while(cpy%2==0) {
			cpy /= 2 ; 
			t++;
		}
		//cout << t << endl ;
		tmp[i] = t ;
	}
	sort(all(tmp)) ; 
	if(tmp[0] != tmp[n-1]) {
		cout << 0 ; 
		return 0 ; 
	}
	//cout << l << endl ; 
	
	ll ans=2*m/l;
	cout<<(ans+1)/2<<endl;
 	return 0 ; 
 	
}

Measured memory_bytes: 3992
#include <cstdio>
#include <cstring>

int sn, n;
char num[11];

int main()
{
	scanf("%s", num);
	for (int i = 0; i < strlen(num); i++)
		n = n * 10 + num[i] - '0', sn += num[i] - '0';
	if (n % sn == 0) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<ll> cum(n + 1, 0);
  rep(i,n) cin >> a[i];
  rep(i,n) cum[i + 1] = cum[i] + a[i];
  for (int i = k; i < n; i++) {
    if (cum[i + 1] - cum[i - k + 1] > cum[i] - cum[i - k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
} 

Measured memory_bytes: 5632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll,ll> data;
const int mod=1e9+7;
vector<data> a[205];
ll F[205];
const ll inf=1e18+10;
int Q;
int main(){
	F[0]=F[1]=1;
	for(int i=2;i<=200;i++) F[i]=F[i-1]+F[i-2];
	a[1].push_back(mp(1,2));
	a[1].push_back(mp(1,3));
	a[1].push_back(mp(1,4));
	for(int i=1;i<=200;i++){
		for(int p=0,S=a[i].size();p<S;p++){
			ll x=a[i][p].first,y=a[i][p].second;
			x+=y;
			while(x<=F[i+3]+F[i]){
				a[i+1].push_back(mp(y,x));
				x+=y;
			}
		}
	}
	scanf("%d",&Q);
	ll n,m;
	while(Q--){
		scanf("%lld%lld",&n,&m);
		if(n>m) swap(n,m);
		int ans=1;
		while(F[ans+1]<=n&&F[ans+2]<=m) ans++;
		if(ans<=1){
			printf("%d %lld\n",ans,n*m%mod);
			continue;
		}
		ll num=0;
		for(int i=0,S=a[ans-1].size();i<S;i++){
			ll x=a[ans-1][i].first,y=a[ans-1][i].second;
			if(y<=n) num=(num+(m-x)/y)%mod;
			if(y<=m) num=(num+(n-x)/y)%mod;
		}
		printf("%d %lld\n",ans,num);
	}
	return 0;
}

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

using namespace std;

int main(){
  int n, c[100009];
  int da[100009], db[100009];
  vector<int> v[100009];
  cin >> n;
  for(int i=0;i<n-1;i++){
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  memset(da, -1, sizeof(da));
  memset(db, -1, sizeof(db));
  queue<int> q;
  da[1]=0;
  q.push(1);
  while(!q.empty()){
    int f=q.front();q.pop();
    for(int i=0;i<v[f].size();i++){
      if(da[v[f][i]]==-1){
        da[v[f][i]]=da[f]+1;
        q.push(v[f][i]);
      }
    }
  }
  db[n]=0;
  int cntb=1;
  q.push(n);
  while(!q.empty()){
    int f=q.front();q.pop();
    for(int i=0;i<v[f].size();i++){
      if(db[v[f][i]]==-1 && da[v[f][i]]>db[f]+1){
        db[v[f][i]]=db[f]+1;
        cntb++;
        q.push(v[f][i]);
      }
    }
  }
  cout << (cntb>=n-cntb?"Snuke":"Fennec") << endl;
}



Measured memory_bytes: 9920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct edge{int to, id;};

const int MAX_V = 1e5;
vector<edge> es[MAX_V];
int ans[MAX_V];

void dfs(int now, int pre, int col){
    int c = 1;
    for(auto &e: es[now]){
        if(e.to == pre) continue;
        if(c == col) c++;
        ans[e.id] = c;
        dfs(e.to, now, c);
        c++;
    }
}

int main(){
    int N;
    cin >> N;
    rep(i, N-1){
        int u, v; cin >> u >> v; u--, v--;
        es[u].eb((edge){v, i}), es[v].eb((edge){u, i});
    }
    dfs(0, -1, 0);
    int K = 0;
    rep(i, N-1) chmax(K, ans[i]);
    cout << K << endl;
    rep(i, N-1) cout << ans[i] << endl;
}

Measured memory_bytes: 9344
// Shift-JIS（シフトジス）

#include <bits/stdc++.h>
using namespace std;

int a, b, c, d, e, k;

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

    if (e - a > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
dict = {}
for i in range(0,10001):
  dict[i] = 0
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      tmp = int(((x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2) / 2)
      if tmp <= 10000:
        dict[tmp] = dict[tmp] + 1
for i in range(1,N + 1):
  print(dict[i])

Measured memory_bytes: 9684
def PrimeFact(N):
    PF = dict()
    M = N
    k = 2
    while (k*k<=N):
        od = 0
        if M % k == 0:
            while (True):
                if M % k == 0:
                    od += 1
                    M = M // k
                else:
                    break
            PF[k]=od
        else:
            k += 1
        if M == 1:
            break
    if M>1:
        PF[M]=1
    return PF

N=int(input())
A=[int(i) for i in input().split()]
#import random
#N=10**4
#A=[random.randrange(1,10**6+1) for i in range(N)]
mod=10**9+7
def inv(x):
    return pow(x,mod-2,mod)
D=dict()
for i in range(N):
    T=PrimeFact(A[i])
    for p in T:
        if not(p in D):
            D[p]=0
        D[p]=max(D[p],T[p])
ans=1
for p in D:
    ans=ans*pow(p,D[p],mod)
    ans%=mod
tmp=0
for i in range(N):
    tmp+=inv(A[i])
    tmp%=mod
ans=ans*tmp
ans%=mod
print(ans)

Measured memory_bytes: 47836
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		
		int AB = A + B;
		int CD = C + D;
		
		int ABCD = AB - CD;
		
		if(ABCD == 0) {
			System.out.println("Balanced");
		}else if(ABCD < 0) {
			System.out.println("Right");
		}else if(ABCD > 0) {
			System.out.println("Left");
		}
		
	}

}


Measured memory_bytes: 23124
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

a = input()
if a[0]=='R':
    ans=1
else:
    ans=0
res=ans
for i in range(1,3):
    if a[i]=='R':
        if a[i]==a[i-1]:
            ans+=1
        else:
            ans=1
    else:
        ans=0
    res=max(res,ans)
print(res)


Measured memory_bytes: 77368
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<vector>
#include<numeric>

using ll = long long;
using std::cin;
using std::cout;
using std::endl;


int main(){
    int a;
    std::string s;
    cin>>a>>s;
    if(a>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }
}

Measured memory_bytes: 256
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
cnt=Counter(a)
lis = sorted(list(set(a)),reverse=True)
ans1,ans2 = 0,0
for val in lis:
    if ans1==0:
        if cnt[val]>=2:
            cnt[val]-=2
            ans1=val

        if cnt[val]>=2:
            ans2=val
            break
    else:
        if cnt[val]>=2:
            ans2=val
            break
print(ans1*ans2) 

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

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

vector<ll> prime;
void eratos(const int max){
    bitset<1000000+1> isprime; isprime.set();
    isprime.reset(0); isprime.reset(1);
    for(int i = 2; i*i <= max; ++i)
        if(isprime.test(i))
            for(int j = 2; i*j <= max; ++j)
                isprime.reset(i*j);
    for(int i = 0; i <= max; ++i)
        if(isprime.test(i)) prime.emplace_back(i);
}


int main(){

    ll a, b;
    cin >> a >> b;
    vector<ll> x = calc_divisor(gcd(a, b));
    vector<ll> prime;
    int cnt = 0;
    rep(i, x.size()){
        bool flag = true;
        for(int j = 0; j < i; ++j){
            if(x[j] == 1) continue;
            if(x[i]%x[j] == 0){
                flag = false;
                break;
            }
        }
        if(flag){
            ++cnt;
        }
    }
    ppp(cnt);


    return 0;
}


Measured memory_bytes: 384
n=int(input())
v=list(input().split())
v1=v[0:n:2]
v2=v[1:n:2]
import collections
c1=collections.Counter(v1)
a1=c1.most_common()[0][0]
a2=(c1.most_common()[1][0] if len(c1)>=2 else 0)
c2=collections.Counter(v2)
b1=c2.most_common()[0][0]
b2=(c2.most_common()[1][0] if len(c2)>=2 else 0)
if a1!=b1:
    cou=0
    for i in range(n//2):
        if v1[i]!=a1:
            cou+=1
    for i in range(n//2):
        if v2[i]!=b1:
            cou+=1
    print(cou)
else:
    cou1=0
    for i in range(n//2):
        if v1[i]!=a2:
            cou1+=1
    for i in range(n//2):
        if v2[i]!=b1:
            cou1+=1
    cou2=0
    for i in range(n//2):
        if v1[i]!=a1:
            cou2+=1
    for i in range(n//2):
        if v2[i]!=b2:
            cou2+=1
    print(min(cou1,cou2))


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

vector<ll> H(N);
REP(i, N) cin >> H.at(i);

if(H.size() == 1) {
  yes;
  return 0;
}

bool flag = true;
for(int i = H.size() - 1; i >= 1; i--){ 
   if(H.at(i) < H.at(i - 1)) H.at(i - 1)--;
   if(H.at(i) < H.at(i - 1)) flag = false;
}
if(flag) yes;
else no;
 }

Measured memory_bytes: 1024
/**
 * author  : UshanGhosh
 * created : 2020-08-06 23:11:17
**/ 

#include<bits/stdc++.h>
using namespace std;

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    endl    '\n'

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    double a,b,c=0,d,e,f,i,j,k,m,n,o,x,y;
    cin>>n>>d;
    for(i=0;i<n;i++){
        cin>>a>>b;
        e=sqrt(a*a*1.0+b*b*1.0);
        if(e<=d) c++;
    }
    cout<<c<<"\n";
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    rep(i, 0, N) cin >> H.at(i);
    vector<int> A(M), B(M);
    vector<vector<int>> C(N + 1, vector<int>(0));
    rep(i, 0, M){
        cin >> A.at(i) >> B.at(i);
        C.at(A.at(i)).push_back(B.at(i));
        C.at(B.at(i)).push_back(A.at(i));
    }
    int count = 0;
    rep(i, 0, N){
        int x = H.at(i);
        bool can = false;
        rep(j, 0, C.at(i + 1).size()){
            int y = H.at(C.at(i + 1).at(j) - 1);
            //cout << x << " " << y << endl;
            if (x <= y){
                can = true;
                break;
            }
        }
        if (can) continue;
        else count++;
        //cout << "i " << i << " " << count << endl;
    }
    cout << count << endl;
}

Measured memory_bytes: 9572
import fractions
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

class Counter:
    def __init__(self):
        self.dict = {}

    def add(self,x):
        if x in self.dict: self.dict[x] += 1
        else: self.dict[x] = 1

    def decrement(self,x):
        self.dict[x] -= 1
        if self.dict[x] <= 0:
            del self.dict[x]

    def get_dict(self):
        return self.dict


INF=10**20
def main():
    K=ii()

    ans = 0
    
    counter = Counter()

    for a in range(1,K+1):
        for b in range(1,K+1):
                x = fractions.gcd(a,b)
                counter.add(x)

    count = counter.get_dict()
    for c in range(1,K+1):
        for key in count.keys():
            val = count[key]
            x = fractions.gcd(key,c)
            ans += val * x



    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 76108
#include <iostream>
#include <vector>
#include <string>

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

int main(){
    ll h, w;
    cin >> h >> w;
    vector<string> c(h);
    REP(i, h){
        cin >> c.at(i);
    }

    REP(i, h){
        cout << c.at(i) << endl;
        cout << c.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
K,N = map(int,input().split())
A = list(map(int,input().split()))

S = [0]*(N)

for i in range(N):
      
    if i==N-1:
        S[i] = K + A[0] -A[i]
    else:
        S[i] = A[i+1] - A[i]

Smax = S.index(max(S))

ans = sum(S)-S[Smax]
print(ans)

Measured memory_bytes: 25836
# -*- coding: utf-8 -*-
# import bisect
# import heapq
# import math
# import random
# from collections import Counter, defaultdict, deque
# from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache
# from itertools import combinations, combinations_with_replacement, product, permutations
# from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


# @mt
def slv(N, A, B, C, D):
    if N == 1:
        return D

    @lru_cache(maxsize=None)
    def f(n):
        ans = n*D
        for i in range(-5, 6 if n > 10 else 1):
            m = n + i
            i = abs(i)
            if m < 0:
                continue
            if m == 0:
                ans = min(ans, D*i)
                continue

            if m % 5 == 0:
                ans = min(ans, f(m//5) + C + D*i)
                # ans = min(ans, f(m//5) + 4*(m//5)*D + D*i)
            if m % 3 == 0:
                ans = min(ans, f(m//3) + B + D*i)
                # ans = min(ans, f(m//3) + 2*(m//3)*D + D*i)
            if m % 2 == 0:
                ans = min(ans, f(m//2) + A + D*i)
                # ans = min(ans, f(m//2) + (m//2)*D + D*i)
        return ans

    return f(N)


def main():
    T = read_int()
    for _ in range(T):
        N, A, B, C ,D = read_int_n()
        print(slv(N, A, B, C, D))

    # N, A, B, C, D = 29384293847243, 454353412, 332423423, 934923490, 1
    # print(slv(N, A, B, C, D))


if __name__ == '__main__':
    main()


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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int& e: a) cin >> e;
  int ans = 0;
  while (true) {
    bool isEven = true;
    for (int& e: a) {
      if (e & 1) isEven = false;
      else e /= 2;
    }
    if (isEven) ans++;
    else break;
  }
  cout << ans << endl;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll N=1e5+8;
const ll MOD=1e9+7;
const ll inf=1e18+6;
const ll M=2000;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(20);
    cout << fixed;
    ll n,k;cin>>n>>k;
    vll A(n);
    forn(i,n) cin>>A[i];
    ll x = (n<=k)?(1):((n-k)/(k-1)+((n-k)%(k-1)!=0)+1);
    cout<<x;
}


Measured memory_bytes: 1024
#include  <iostream>
#include  <string>
#include  <cstdlib>


int main(void)
{
	int N;
	std::cin >> N;

	std::string S[N];
	for(int i = 0; i < N; i++)
		std::cin >> S[i];

	int ans[4] = {0, 0, 0, 0};

	for(int i = 0; i < N; i++){
		if(S[i] == "AC")
			ans[0]++;
		else if(S[i] == "WA")
			ans[1]++;
		else if(S[i] == "TLE")
			ans[2]++;
		else if(S[i] == "RE")
			ans[3]++;
		else{
		}
	}

	std::cout << "AC x " << ans[0] << std::endl;
	std::cout << "WA x " << ans[1] << std::endl;
	std::cout << "TLE x " << ans[2] << std::endl;
	std::cout << "RE x " << ans[3] << std::endl;

	return EXIT_SUCCESS;
}


Measured memory_bytes: 6724
# 入力
N, M = map(int, input().split())

# 番号を入力
A = [int(i) for i in range(N)]

B = [] # 台No. リスト

if N % 2 == 0:
    # N が偶数の場合

    center = N // 2
    c1 = center // 2
    c2 = center + c1
    # print(c1,c2)

    for i in range(1, M+1):
        # print(i)
        j = i // 2
        # print("j", j)
        if i % 2 == 1:
            B.append((c1-j, c1+j+1))
        else:
            B.append((c2-(j-1), c2 - (j-1) + 2*j ))

else:
    # N が奇数の場合

    center = N // 2 + 1
    # print(center)
    for i in range(1, M+1):
        B.append((center - i, center + i))
        
for i in B:
    print(i[0], i[1])

Measured memory_bytes: 28040
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=1000000;



main(){
    int n=in();
    vec v;
    rep(i,n)v.pb(in());
    map<int,int> mp;
    rep(i,n)mp[v[i]]++;
    int res=0;
    int ans=0;
    for(auto e:mp){
        ans+=1;
        res+=e.second-1;
    }
    cout<<ans-(res%2 ? 1 : 0);
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

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

int a, b;

void f(int x) {
    a = x % 10;
    b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
}

signed main() {
    int X;
    cin >> X;
    int t = X / 500;
    int f = (X - t * 500) / 5;
    cout << t * 1000 + f * 5 << endl;
}

Measured memory_bytes: 256
//keep trying :)
#include <bits/stdc++.h>
#define float long double
#define int long long
#define ll long long
#define PB push_back
#define MP make_pair
#define ss second
#define ff first
#define PI 3.14159265
#define inf 9*(1e18)
#define fastrack ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
void PT(int a);
void PT1(int a);
const int M = 1e7 + 7, mod = 1e9 + 7;
int s[M];

void sve(){
    for(int i = 2; i < M; i++){
        for(int j = i; j < M; j += i)
            s[j]++;
    }
}

signed main(){
    fastrack;
    //int tt; cin >> tt; while(tt--)
    {
        int n;
        cin >> n;
        sve();
        int ans = 0;
        for(int i = 1; i <= n; i++)
            ans += (s[i] + 1) * i;
        cout << ans << "\n";
    }
    return 0;
}

void PT(int a){
    cout << a << "\n";
}

void PT1(int a){
    cout << a << " ";
}


Measured memory_bytes: 81772
#include<iostream>
using namespace std;
#include <vector>  
#include<algorithm>
#include<string>

int main()
{
	int A,B,C,D;

	

	cin >> A>>B>>C>>D;

	string result = "Yes";

	while (true) {
		C -= B;
		if (C <= 0) {
			break;
		}

		A -= D;
		if(A<=0){
			result = "No";
			break;
		}
			
	}





	
	cout << result<< endl;
}



int hyoe() {

	return 0;
}


Measured memory_bytes: 3624
N=int(input())
#li=[input() for i in range(N)]
count=0
dic={}
for i in range(N):
  s=input()
  sorted_s="".join(sorted(s))
  count += dic.get(sorted_s, 0)
  dic[sorted_s] = dic.get(sorted_s, 0) + 1
print(count)

Measured memory_bytes: 17892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    ll a,b,n;
    cin >> a>>b>>n;

    ll alpha,ganma;
    alpha = a / b;
    ganma = a % b;
    ll ans = 0;
    if(b != 1){
        if(a <= b){
            if(n >= b){
                ans = a - 1;
            }
            else{
                ans = a * n / b;
            }
        }
        else{
        
        
                if(n>=b){
                    ans = alpha*(b-1) + ganma-1;
                }
                else{
                    ans = alpha*n + ganma*n / b;
                }
            
        }
        cout << ans << endl;
        }

    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 200001
#define MAX_K 200001
#define MAX_P 1001
#define INF   1000000000000000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll p[MAX_N];
double ex[MAX_P];

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

    fill(p, p + MAX_N, 0);
    fill(ex, ex + MAX_P, 0.0);
    
    ll N, K;
    cin >> N >> K;
    for(ll i = 0; i < N; i++) cin >> p[i];

    for(ll i = 1; i < MAX_P; i++) {
      ex[i] = (ex[i-1]*((double)(i-1)) + (double)i) / ((double)i);
    }

    double ans = 0.0;
    for(ll i = 0; i < K; i++) ans += ex[ p[i] ];
    double tmp = ans;
    
    for(ll i = 0; i < (N-K); i++) {
      tmp -= ex[ p[i] ];
      tmp += ex[ p[K + i] ];
      ans = max(ans, tmp);
    }

    printf("%.12lf\n", ans);
    return 0;
}



Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,k;
	long long int a[200010];
	int i;
	long long int sum=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);	
	for(i=n-1;i>=n-k&&i>=0;i--){
		a[i]=0;
	}
	for(i=0;i<n;i++){
		sum+=a[i];
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int X;
    cin >> X;
    VEC(bool) dp(X + 1, false);
    dp[0] = true;
    FOR(i, 0, X)
        if (dp[i])
            FOR(j, 0, 6)
                if (i + 100 + j <= X)
                    dp[i + 100 + j] = true;

    cout << (dp[X] ? "1" : "0") << endl;
    return 0;
};

Measured memory_bytes: 256