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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < (Int)n; i++) {
        cin >> a[i];
    }
    sort(all(a), greater<Int>());
    if (n % 2 == 0) {
        vector<Int> b(n / 2);
        for (Int i = 0; i < n / 2; i++) {
            b[i] = a[i];
        }
        Int res = 0;
        for (Int i = 0; i < n / 2 - 1; i++) {
            res += b[i];
        }
        for (Int i = 1; i < n / 2; i++) {
            res += b[i];
        }
        res += b[n / 2 - 1];
        print(res);
    } else {
        vector<Int> b(n / 2 + 1);
        for (Int i = 0; i < n / 2 + 1; i++) {
            b[i] = a[i];
        }
        Int res = 0;
        for (Int i = 0; i < n / 2; i++) {
            res += b[i];
        }
        for (Int i = 1; i < n / 2 + 1; i++) {
            res += b[i];
        }
        print(res);
    }
    return 0;
}

Measured memory_bytes: 5600
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e3+10, mod=1e9+7;

int main ()
{
    FASTIO
    double r;
    cin >> r;
    cout << setprecision(15) << 2*Pi*r << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 3760
K = int(input())
total = 0

def gcd(a, b):
    if(a > b):
        a, b = b, a

    while(b > 0):
        r = a % b
        a = b
        b = r

    return a

dp = [[0 for i in range(K+1)] for j in range(K+1)]

for a in range(1, K+1):
    for b in range(1, K+1):
        if(dp[a][b] == 0):
            dp[a][b] = gcd(a, b)

        res = dp[a][b]

        for c in range(1, K+1):
            if(dp[res][c] == 0):
                dp[res][c] = gcd(res, c)

            total += dp[res][c]


print(total)

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

#define ull unsigned long long

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5]) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : July 05, 2020
##################################################### SOURCE START #####################################################

import heapq
import collections

N = int(input().strip())
As = list(map(lambda s: -int(s), input().strip().split()))

heapq.heapify(As)

g  = 0
gs = collections.deque()

for n in range(N):

    a = - heapq.heappop(As)

    if n == 0:
        gs.append(a)    
    else:
        g += gs.popleft()
        gs.append(a)
        gs.append(a)

print(g)

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

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

const long long INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n; cin>>n;
  int res = 0;
  
  rep(i,n) {
    int l,r; cin>>l>>r;
    
    res += (r-l)+1;
  }
  cout<<res;
}



Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

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

//const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	ll N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	ll diff = abs(A - B);
	for (ll i = 0; i < N - 1; i++){
		ll i_min = C*(N - i - 1) - D*i;
		ll i_max = D*(N - i - 1) - C*i;
		if (diff >= i_min && diff <= i_max){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int a[N];
int m[N];

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

	int n;
	cin >> n;

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

	for (int i = 0; i < n; i++) {
		m[i] = a[i] * 2;
	}

	int mm = m[0];
	for (int i = 1; i < n; i++) {
		mm += (i % 2 == 0 ? 1 : -1) * m[i];
	}

	mm /= 2;

	cout << mm << " ";
	for (int i = 0; i < n - 1; i++) {
		m[i] -= mm;
		cout << m[i] << " ";
		mm = m[i]; 
	}

    return 0;
}


Measured memory_bytes: 2944
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  cin>>n>>m;
  ll s = 0;
  for(int i=0;i<m;i++){
    int x;
    cin>>x;
    s+=x;
  }
  if(s>n)cout<<-1<<endl;
  else cout<<n-s<<endl;
  return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Stack;
import java.util.Scanner;
import java.util.Queue;

/**
 * @author yoshikyoto
 */



class Main{
	static final boolean DEBUG = false;
	static Scanner sc = new Scanner(new InputStreamReader(System.in));
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String args[]) throws Exception{
		for(int i = 1; i <= 9; i++)
			for(int j = 1; j <= 9; j++)
				p(i + "x" + j + "=" + (i*j));
	}

	public static void pa(Object[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(int[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(double[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(boolean[] arr){System.out.println(Arrays.toString(arr));}
	public static void p(Object o){System.out.println(o.toString());}
	public static void d(Object o){if(DEBUG)System.out.println(o.toString());}
	public static int[] parseInt(String[] arr){
		int[] res = new int[arr.length];
		for(int i = 0; i < arr.length; i++)res[i] = Integer.parseInt(arr[i]);
		return res;
	}
	public static int parseInt(Object o){return Integer.parseInt(o.toString());};
}

class MyHashMap<E> extends HashMap<E, Integer>{
	ArrayList<E> keyArray = new ArrayList<E>();
	public void add(E key){add(key, 1);}
	public void add(E key, Integer value){
		if(containsKey(key)){
			value += get(key);
		}else{
			keyArray.add(key);
		}
		put(key, value);
	}
}

Measured memory_bytes: 17164
n=int(input())
a=list(map(int,input().split()))
sai=max(a)

if sai%2==0:
  b=sai//2
  hantei=10**9+1
  suuji=0
  for i in a:
    if abs(b-i)<hantei and i!=sai:
      hantei=abs(b-i)
      suuji=i
  print(sai,suuji)
else:
  b1=sai//2
  b2=sai//2+1
  hantei=10**9
  suuji=0
  for i in a:
    if min(abs(b1-i),abs(b2-i))<hantei:
      hantei=min(abs(b1-i),abs(b2-i))
      suuji=i
  print(sai,suuji)
  
  
      
    

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

int main() {
	int n,k,l,c=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
	    int a;
	    cin>>a;
	    if(a==1){
	        l=i+1;
	        i=n;
	        c=(l+k-3)/(k-1);
	        l=c*(k-1)+1;
	    }
	}
	while(l<n){
	    l+=k-1;
	    c++;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("sse4.2")

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <sstream>
#include <deque>
#include <queue>
#include <complex>
#include <random>
#include <cassert>
#include <chrono>

using namespace std;

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FIXED cout << fixed << setprecision(12)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define graph vector<vector<int>>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define f first
#define s second
#define hashmap unordered_map
#define hashset unordered_set
#define eps 1e-9
#define mod 1000000007
#define inf 3000000000000000007ll
#define sz(a) signed(a.size())
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#ifdef DEBUG
    mt19937 gen(857204);
#else
    mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

#ifdef DEBUG
    template<class T> T to_dbg(T x) { return x; }
    template<class T, class U> string to_dbg(pair<T, U> p) {
        stringstream ss;
        ss << '{' << p.f << ',' << p.s << '}';
        return ss.str();
    }
    string to_dbg(string s) { return "\"" + s + "\""; }
    template<class T> string to_dbg(vector<T> a) {
        stringstream ss;
        ss << '{';
        if (sz(a)) ss << to_dbg(a[0]);
        for (int i = 1; i < sz(a); ++i)
            ss << "," << to_dbg(a[i]);
        ss << '}';
        return ss.str();
    }
    template<class T>
    void dbgout(T x) { cout << to_dbg(x) << endl; }
    template<class T, class... U>
    void dbgout(T t, U... u) {
        cout << to_dbg(t) << ", ";
        dbgout(u...);
    }
    #define dbg(...) cout << "[" << #__VA_ARGS__ << "] = ", dbgout(__VA_ARGS__);
#else
    #define dbg(...) 0
#endif

template<class T, class U> inline void checkmin(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void checkmax(T &x, U y) { if (y > x) x = y; }
template<class T, class U> inline bool ifmax(T &x, U y) { if (y > x) return x = y, true; return false; }
template<class T, class U> inline bool ifmin(T &x, U y) { if (y < x) return x = y, true; return false; }
template<class T> inline void sort(T &a) { sort(all(a)); }
template<class T> inline void rsort(T &a) { sort(rall(a)); }
template<class T> inline void reverse(T &a) { reverse(all(a)); }
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.f >> p.s; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }
template<class T> inline T sorted(T a) { sort(a); return a; }

signed main() {
    FAST; FIXED;
    ll a, b, n;
    cin >> a >> b >> n;
    ll mx;
    if (n >= b - 1) mx = b - 1;
    else mx = n;
    cout << (a * mx) / b;
    #ifdef DEBUG
        cerr << "Runtime is: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}

Measured memory_bytes: 3612
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N;
    string S; 
    cin >> N >> S;
    int left=0, right=0;
    
    for(auto c : S){
        if(c=='(') right++;
        else if(right>0) right--;
        else left++;
    }

    cout << string(left, '(');
    cout << S;
    cout << string(right, ')');
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,s=0; cin>>n>>m;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i],s+=a[i];
  sort(a.rbegin(),a.rend());
  for(int i=0;i<m;i++) if(a[i]*(4*m)<s){cout<<"No"; return 0;}
  cout<<"Yes";
}

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

#define repr(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define irepr(i,a,b) for(int i=a, i##_len=(b); i>=i##_len; --i)
#define irep(i,n) for(int i=n; i>=0; --i)

#define printline(str) cout << str << "\n"

#define lint long long

template<class T,std::size_t N>

void printArray(T (&arr)[N], string del = {','}){
  cout << arr[0];
  repr(i, 1, N){
    cout << del << arr[i];
  }
  cout << "\n";
}

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

std::vector<int> divisor(int n)//nの約数を列挙
{
	std::vector<int> ret;
  ret.reserve(n/2+1);
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
  sort(ret.begin(), ret.end(), greater<int>());
	return ret;
}

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

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

  vector<int> A(N);
  int sumA = 0;
  rep(i,N){
    cin >> A[i];
    sumA += A[i];
  }
  std::sort(A.begin(), A.end(), greater<int>());

  auto div = divisor(sumA);
  if(sumA - A[0] <= K){
    printline(sumA);
    return 0;
  }
  for(const auto d : div){
    if( sumA%d==0){
      lint inc = 0;
      lint dec = 0;
      vector<int> M(N);
      rep(i,N){
        M[i] = A[i]%d;
      }
      sort(M.begin(), M.end(), greater<lint>());

      inc += d-M[0];
      repr(i,1,N){
        dec += M[i];
      }

      if( inc == dec){
        if( dec <= K){
          printline(d);
          return 0;
        }
      }
      repr(i,1,N){
        inc += d-M[i];
        dec -= M[i];
        if( inc == dec){
          if( inc <= K){
            printline(d);
            return 0;
          }
        }
      }
    }
  }
  printline(1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 2005;
const int INF = 0x3f3f3f3f;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

char s[MAXN];
int n;
int siz[MAXN], sum[MAXN], dp[MAXN];
vector<int> e[MAXN];

void DFS(int u, int fa) {
	siz[u] = (s[u] == '1');
	sum[u] = dp[u] = 0;
	int mx = 0;
	for (auto v : e[u]) {
		if (v == fa) continue;
		DFS(v, u);
		siz[u] += siz[v];
		sum[u] += sum[v];
		if (!mx || dp[v] > dp[mx]) {
			mx = v;
		}
	}
	if (sum[u] - sum[mx] >= dp[mx]) {
		dp[u] = sum[u] & 1;
	} else {
		dp[u] = dp[mx] - (sum[u] - sum[mx]);
	}
	sum[u] += siz[u];
	dp[u] += siz[u];
}

void init() {
	read(n);
	scanf("%s", s + 1);
	for (int i = 1, u, v; i < n; ++i) {
		read(u); read(v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
}

void solve() {
	int ans = INF;
	for (int i = 1; i <= n; ++i) {
		DFS(i, 0);
		if ((sum[i] - siz[i]) & 1) continue;
		if (dp[i] == siz[i]) {
			ans = min(ans, (sum[i] - siz[i]) / 2);
		}
	}
	printf("%d\n", (ans == INF)? -1 : ans);
}

int main() {
	init();
	solve();
	return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> v(n), p(n), q(n);
	for(int i = 0; i < n; i++) cin >> p[i];
	for(int i = 0; i < n; i++) cin >> q[i];
	for(int i = 0; i < n; i++) v[i] = i + 1;
	int a, b, cnt = 1;
	do{
	    bool P = true, Q = true;
	    for(int i = 0; i < n; i++){
	    	if(p[i] != v[i]) P = false;
	    	if(q[i] != v[i]) Q = false;
	    }
	    if(P) a = cnt;
	    if(Q) b = cnt;
	    cnt++;
	} while(next_permutation(v.begin(), v.end()));
	cout << abs(a - b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxX = 1e6;
bool notPrime[maxX + 1];
vector<int> primes;
vector<pair<lli, int>> primeFactors[maxX + 1];

vector<pair<lli, int>> getPrimeFactors(lli num)
{
  if (num <= maxX) return primeFactors[num];
  vector<pair<lli, int>> pf;
  for (lli i: primes)
  {
    if (i > num) break;
    if (num % i == 0)
    {
      int p = 0;
      while (num % i == 0) num /= i, p ++;
      pf.push_back({i, p});
    }
  }
  if (num != 1)
    pf.push_back({num, 1});
  return pf;
}

const int maxN = 1e6; int n;
int a[maxN];
vector<pair<lli, int>> pf[maxN];

int main()
{
  notPrime[0] = notPrime[1] = true;
  for (int i = 2; i <= maxX; i ++)
  {
    if (!notPrime[i]) primes.push_back(i), primeFactors[i].push_back({i, 1});
    for (int j = 0; i*primes[j] <= maxX; j ++)
    {
      notPrime[i*primes[j]] = true;
      int p = 0, num = i * primes[j];
      while (num % primes[j] == 0) num /= primes[j], p ++;
      primeFactors[i * primes[j]].push_back({primes[j], p});
      primeFactors[i * primes[j]].insert(primeFactors[i * primes[j]].end(), primeFactors[num].begin(), primeFactors[num].end());
      if (i % primes[j] == 0) break;
    }
  }

  while (scanf("%d", &n) != EOF)
  {
    for (int i = 0; i < n; i++)
    {
      scanf("%d", &a[i]);
      pf[i] = getPrimeFactors(a[i]);
    }

    map<int, int> cnt;
    for (int i = 0; i < n; i++)   
      for (auto &p: pf[i])
      {
        if (!cnt.count(p.first))
          cnt[p.first] = 0;
        cnt[p.first]++;
      }

    bool notCoprime = false;
    for (auto &c: cnt)
      if (c.second == n)
        notCoprime = true;
    if (notCoprime)
    {
      printf("not coprime\n");
      continue;
    }

    bool setWise = false;
    set<int> prv;
    for (int i = 0; i < n; i++)
    {
      for (auto &p: pf[i])
      {
        if (prv.count(p.first))
          setWise = true;
        prv.insert(p.first);
      }
    }
    printf("%s\n", setWise ? "setwise coprime" : "pairwise coprime");
  }

  return 0;
}

Measured memory_bytes: 209840
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll INF = 1001001001001001001;
struct edge{ int from, to, cost; };


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<edge> ev;
    ll dist[1010];
    fill(dist, dist + 1010, INF);
    REP(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        c = -c;
        ev.push_back({a, b, c});
    }

    dist[1] = 0;
    ll prev_dist;
    REP(i, n){
        for(auto &e : ev){
            if(dist[e.from] == INF) continue;
            if(dist[e.to] > dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
            }
        }
        if(i == n - 1 && dist[n] < prev_dist) {
            cout << "inf" << "\n";
            return 0;
        }
        prev_dist = dist[n];
    }
    cout << -dist[n] << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define min(a,b)a<b?a:b
#define N 1000010
int o[200],s[200],dp1[N],dp2[N],n,i,j,k,x;;

void f(int t[200],int dp[N])
{
	int i,j;
	dp[0]=0;
	for(i=0;t[i];i++)
		for(j=0;j<=N;j++)
			if(j>=t[i])
				dp[j]=min(dp[j],dp[j-t[i]]+1);
}

int main()
{
	for(i=1,j=k=0;i*(i+1)*(i+2)/6<=N;i++)
	{
		x=i*(i+1)*(i+2)/6;
		if(x%2)
			o[j++]=x;
		s[k++]=x;
	}
	memset(dp1,0x7f,sizeof(dp1));
	memset(dp2,0x7f,sizeof(dp2));
	f(s,dp1);
	f(o,dp2);
	for(;scanf("%d",&n),n;)
		printf("%d %d\n",dp1[n],dp2[n]);
	return 0;
}

Measured memory_bytes: 8420
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto i = (m).begin(); i != (m).end(); ++i)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] += a[i][k] * b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;
#define REV(T) greater<T>()

ll pow_(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1)
      x = (x * a) % MOD;
    a = (a * a) % MOD;
    n >>= 1;
  }
  return x;
}

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);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> 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;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll mo[52] = {};
ll ful[52] = {};

ll po(ll X, ll N) {
  ll c = 0;
  if (N < 0)
    return 0;
  if (mo[N] == X && ful[N] != 0) {
    return ful[N];
  }

  ll yo = mo[N] >> 1;
  if (X > yo) {
    c++;
    c += (po(X - yo - 1, N - 1) + po(yo - 1, N - 1));
  } else {
    c += po(X - 1, N - 1);
  }
  if (mo[N] == X)
    ful[N] = c;
  return c;
}

int main() {
  for (int i = 0; i <= 51; i++) {
    mo[i] = ((ll)1 << (i + 2)) - 3;
    ful[i] = 0;
  }

  ll N, X;
  vector<ll> A;
  cin >> N >> X;
  cout << po(X, N)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    for (int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        if (x &1){
            puts("first");
            return 0;
        }
    }
    puts("second");
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


int main(){
	int N;
	ll K;
	cin >> N >> K;
	vector<ll> A(N), F(N);// 計算に使うんでllにします
	for(int i=0; i<N; i++) cin >> A[i];
	for(int i=0; i<N; i++) cin >> F[i];

	sort(A.rbegin(), A.rend());
	sort(F.begin(), F.end());
	ll left = -1, right = 1e12+1;
	while(right - left > 1){
		ll mid = (left+right) / 2;
		bool is_ok = true;
		ll sumK = 0;
		for(int i=0; i<N; i++){
			sumK += max(A[i]-mid/F[i], (ll)0);
		}
		if(sumK > K) is_ok = false;
		// ll tmpK = K;
		// for(int i=0; i<N; i++){
		// 	tmpK -= max(A[i] - mid/F[i], (ll)0);
		// }
		// if(tmpK < 0) is_ok = false;
		if(is_ok) right = mid;
		else left = mid;
		// cout << " left: " << left << " mid: " << mid << " right: " << right << endl;
	}
	cout << right << endl;
	return 0;
}



Measured memory_bytes: 6416
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextLong()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem167d(n, k, a))
}

fun problem167d(n: Int, k: Long, a: List<Int>): Int {
    val visited = hashMapOf<Int, Int>()
    visited[1] = 0
    var loopPoint = -1 to -1
    var current = 1
    for (i in 0 until n) {
        val next = a[current - 1]
        if (i.toLong() >= k - 1) {
            return next
        }
        if (visited.contains(next)) {
            loopPoint = next to i + 1 - visited[next]!!
            break
        }
        visited[next] = i + 1
        current = next
    }

    val loopIndex = (k - visited[loopPoint.first]!!) % loopPoint.second
    current = loopPoint.first
    for (i in 0 until loopIndex) {
        current = a[current - 1]
    }
    return current
}

Measured memory_bytes: 66464
#include <algorithm>
#include <iostream>
#include <limits>
#include <stack>
#include <vector>
using namespace std;
using ll = long long;

// ----- LIS -----

template <typename T>
class LIS
{
  struct Cache_LIS
  {
    typename vector<T>::iterator it;
    T value;
  };

  int n; // fixed
  T infty;
  vector<T> dp;
  stack<Cache_LIS> st;

public:
  LIS() {}
  LIS(int n, T infty = numeric_limits<T>::max()) : n{n}, infty{infty}, dp(n, infty) {}

  T query(T a)
  {
    auto it{lower_bound(dp.begin(), dp.end(), a)};
    auto value{*it};
    st.push(Cache_LIS{it, value});
    *it = a;
    return lower_bound(dp.begin(), dp.end(), infty) - dp.begin();
  }

  bool rollback()
  {
    if (st.empty())
    {
      return false;
    }
    auto const &c{st.top()};
    *c.it = c.value;
    st.pop();
    return true;
  }

private:
};

#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D&lang=jp"

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto i{0}; i < n; ++i)
  {
    cin >> a[i];
  }
  LIS<int> lis(n);
  for (auto i{0}; i < n - 1; ++i)
  {
    lis.query(a[i]);
  }
  cout << lis.query(a[n - 1]) << endl;
}



Measured memory_bytes: 5184
n = int(input())
*a, = map(int, input().split())
q = int(input())
*m, = map(int, input().split())

# DP
nq = 20*200+1
f = [[False for _ in range(nq)] for i in range(n+1)]
f[n][0] = True

for i in range(n-1, -1, -1):
    for j in range(sum(a)+1):
        v1 = f[i+1][j]
        v2 = f[i+1][j-a[i]] if j >= a[i] else False
        f[i][j] = v1 or v2

for t in m:
    print("yes" if f[0][t] else "no")


Measured memory_bytes: 6320
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        
        int b = sc.nextInt();
        
        int c = sc.nextInt();
        
        if(a < b && b < c){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
    
}

 


Measured memory_bytes: 26312
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> xls(m);
	for(auto& x : xls) cin >> x;
	sort(xls.begin(), xls.end());

	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}

	vector<pair<int, int>> xDiff(m - 1);
	for (int i = 1; i < m; ++i) {
		xDiff[i - 1] = pair<int, int>(i, xls[i] - xls[i - 1]);
	}
	sort(xDiff.begin(), xDiff.end(), [](auto & l, auto & r) {
		return l.second > r.second; });
	xDiff.resize(n - 1);

	int sum = xls[m - 1] - xls[0];
	for (auto x: xDiff) {
		sum -= x.second;
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	int N,rate[8]={},rainbow=0,r;
	cin>>N;	
	for(int i=0;i<N;i++){
		cin>>r;
		if(r<=399){
			rate[0]++;
		}else if(r<=799){
			rate[1]++;
		}else if(r<=1199){
			rate[2]++;
		}else if(r<=1599){
			rate[3]++;
		}else if(r<=1999){
			rate[4]++;
		}else if(r<=2399){
			rate[5]++;
		}else if(r<=2799){
			rate[6]++;
		}else if(r<=3199){
			rate[7]++;
		}else{
			rainbow++;
		}
	}
	r=0;
	for(int i=0;i<8;i++){
		if(rate[i]!=0){
			r++;
		}
	}
	if(r!=0){
		cout<<r<<" "<<r+rainbow<<endl;
	}else{
		cout<<"1"<<" "<<rainbow<<endl;
	}
	
}

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

int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	if(a > b)
		printf("a > b\n");
	else if(a < b)
		printf("a < b\n");
	else
		printf("a == b\n");
}



Measured memory_bytes: 3160
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int numInt = Integer.parseInt(br.readLine());
    
    String[] data = br.readLine().split(" ");
    
    for(String s: data){
      int num = Integer.parseInt(s);
      if(num % 2 == 0 && num % 3 != 0 && num % 5 != 0){
        System.out.println("DENIED");
        return;
      }
    }
    System.out.println("APPROVED");
  }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

int main(){
    int n, k;
    cin >> n >> k;
    int MIN = k;

    int a[n];
    rep(i, n){
        cin >> a[i];
        MIN = min(MIN, a[i]);
    }

    bool dp[100005];

    rep(i, k){
        dp[i] = false;
    }
    rep(i, n){
        dp[a[i]-1] = true;
    }

    for (int i = MIN; i < k; i++){        
        rep(j, n){
            if(i-a[j]>=0){
                if(!dp[i-a[j]]){
                    dp[i] = true;
                    break;
                }
            }
        }
    }

    if(dp[k-1]){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
    // printf("%d\n", N);
    return 0;
}

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

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int x;
	cin>>x;
	if(x>=30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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


int main() {
  int N, M, temp = 0;
  
  
  
  cin >> N;
  vector<string> s(N);
  for(int i = 0; i < N; i++){
	cin >> s.at(i);
  }
  cin >> M;
  vector<string> t(M);
  for(int i = 0; i < M; i++){
	cin >> t.at(i);
  }
  for(int i = 0; i < N; i++){
    int count = 1;
	string a = s.at(i);
    for(int j = i+1; j < N; j++){
	  if(s.at(j) == a){
		count++;
      }
    }
    for(int j = 0; j < M; j++){
	  if(t.at(j) == a){
        count--;
      }
    }
    if(temp < count){
      temp = count;
    }
  }
  cout << temp << endl; 
}



Measured memory_bytes: 256
A,B,C,D = map(int,input().split())

def gcd(a,b):
  while b:
    a,b = b,a%b
  return a

def F(N,C,D):
  x = N
  x -= N//C
  x -= N//D
  lcm = C*D//gcd(C,D)
  x += N//lcm
  return x

answer = F(B,C,D) - F(A-1,C,D)
print(answer)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tokuten;
		String line;
		while (!(line = br.readLine()).equals("0")) {
			int n = Integer.parseInt(line);
			tokuten = br.readLine().split(" ");

			double ave = 0;
			for (int i = 0; i < n; i++) {
				ave += Integer.parseInt(tokuten[i]);
			}
			ave = ave / n;

			double sd = 0;
			for (int i = 0; i < n; i++) {
				sd += (Math.pow(Integer.parseInt(tokuten[i]) - ave, 2.0)) / n;
			}

			sd = Math.sqrt(sd);
			System.out.println(sd);
		}
	}
}

Measured memory_bytes: 25120
#include <iostream>

using namespace std;

const int N = 123456 * 2;

bool isPrime[N];

void makePrime()
{
    for (int i = 0; i < N; i++)
    {
        isPrime[i] = true;
    }
    isPrime[0] = isPrime[1] = false;
    for (int i = 0; i < N; i++)
    {
        if (!isPrime[i])
        {
            continue;
        }
        for (int j = 2; j * i < N; j++)
        {
            isPrime[i * j] = false;
        }
    }
}

int main()
{
    int n;
    makePrime();
    while (cin >> n, n)
    {
        int count = 0;
        for (int i = n + 1; i < n * 2 + 1; i++)
        {
            if (isPrime[i])
            {
                count++;
            }
        }
        cout << count << endl;
    }
}


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


int main(){
  int k;cin>>k;
  queue<unsigned long long> lunluns;
  for (unsigned long long i = 1; i < 10; i++)
  {
    lunluns.push(i);
  }
  for (int i = 1; i < k; i++)
  {
    unsigned long long tmp = lunluns.front();
    lunluns.pop();
    if (tmp % 10 != 0)
    {
      lunluns.push(tmp * 10 + (tmp % 10) - 1);
    }
      lunluns.push(tmp * 10 + (tmp % 10));
    if (tmp % 10 != 9)
    {
      lunluns.push(tmp * 10 + (tmp % 10) + 1);
    }
  }
  cout << lunluns.front() << endl;
  
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    vector<int> A(n, 0);
    for(int i = 1; i < n; i++)
    {
        int x; cin >> x;
        x--;
        A[x]++;
    }
    for(int i = 0; i < n; i++)
    {
        cout << A[i] << endl;
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3992
fun main(args: Array<String>) {
    readLine()!!
    val str = readLine()!!

    var count = 0
    for (i in (str.lastIndex - 2) downTo 0 ) {
        if (str[i] == 'A' && str[i + 1] == 'B' && str[i + 2] == 'C') {
            count += 1
        }
    }

    println(count)
}

Measured memory_bytes: 33596
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const int N = 1e5 + 10;
string s;
int n;

void solve() {
	int n, W;
	cin >> n >> W;
	vector <ll> w(n), val(n);
	for (int i = 0; i < n; ++i) {
		cin >> w[i] >> val[i];
	}
	ll dp[n + 1][W + 1];
	memset(dp, 0, sizeof dp);
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= W; ++j) {
			if (j - w[i - 1] >= 0) {
				dp[i][j] = max(dp[i - 1][j - w[i - 1]] + val[i - 1], dp[i - 1][j]);
				// cout << val[i - 1] + dp[i - 1][j - w[i - 1]] << " ";
			}
			else
				dp[i][j] = dp[i - 1][j]; 
		}
	}
	// ll ans = 0LL;
	// for (int i = 0; i <= n; ++i) {
	// 	for (int j = 0; j <= W; ++j)
	// 		cout << dp[i][j] << " ";
	// 	cout << "\n";
	// }

	cout << dp[n][W];
}
int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                  

Measured memory_bytes: 79232
a,b,k = map(int,input().split())
t = max(a-k,0)
 
if t == a-k:
  print(t,b)
  exit()
else:
  b -= abs(a-k)
  if b <= 0:
    print(0,0)
    exit()
    
print(0,b)
 

Measured memory_bytes: 2940
//   PIGMEISTER™   //

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

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    ll n;
    cin >> n;
    ll h[n];
    sidha (i, 0, n) cin >> h[i];

    ll dp[n] = {0};
    dp[1] = abs(h[1]-h[0]);
    sidha (i, 2, n) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout << dp[n-1] << '\n';
    
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	int N, M;

	cin >> N >> M;
	if (N % 2 == 1) {
		for (int i = 0; i < M; i++) {
			cout << 1 + i << " " << N - i << "\n";
		}
	}
	else if (N == 4) {
		cout << "1 2";
	}
	else {
		if (N % 4 == 0) {
			int p = N / 4;
			if (p > M) { p = M; }
			for (int i = 0; i < p; i++) {
				cout << 1 + i << " " << N - i << "\n";
			}
			for (int i = p; i < M; i++) {
				cout << 1 + i << " " << N - i - 1 << "\n";
			}
		}
		else {
			int p = (N - 2) / 4;
			if (p > M) { p = M; }
			for (int i = 0; i < p; i++) {
				cout << 1 + i << " " << N - i << "\n";
			}
			for (int i = p; i < M; i++) {
				cout << 1 + i << " " << N - i - 1 << "\n";
			}
		}
	}

}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI                acos(-1)
#define pb                emplace_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

typedef long long       ll;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = ll(1e9 + 7);

const ll tam = 100010;

vector<ll> G[tam];
ll val[tam];
bool vis[tam];

ll sum;
void dfs(ll v)
{
	//cout << "(" << v << "," << val[v] << ") ";
	sum += (val[v] + 26);
	sum %= 26;
	vis[v] = true;
	for (ll u : G[v])
	{
		if ( vis[u] ) continue;
		dfs(u);
	}
}

ii E[tam];

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    string s;
    cin >> s;
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
    {
    	cin >> E[i].F >> E[i].S;
    }
    if (s.size() == 1)
    {
    	cout << "YES" << '\n';
    	return 0;
    }
    s = "a" + s + "a";

    //cout << s << endl;
	for (ll i = 0; i < s.size()-1; i++)
    {
    	val[i] = (s[i+1] - s[i] + 26) % 26;
    	//cout << "(" << val[i] << "[" << i << "," << i+1 << "]) ";
    }
    //cout << endl;

    for (ll i = 0; i < n; i++)
    {
    	//val[ E[i].F-1 ] = (val[ E[i].F-1 ] + 1) % 26;
    	//val[ E[i].S ] = (val[ E[i].S ] - 1 + 26) % 26;
    	G[E[i].F-1].pb( E[i].S );
    	G[ E[i].S ].pb(E[i].F-1);
    }
    /*
    for (ll i = 0; i < s.size()-1; i++)
    {
    	cout << "(" << val[i] << "[" << i << "," << i+1 << "]) ";
    }
    cout << endl;
    */
    for (ll i = 0; i < s.size()-1; i++)
    {
    	G[i].pb( s.size()-2-i );
    }
    clr(vis, false);
    bool poss = true;
    for (ll i = 0; i < s.size()-1; i++)
    {
    	if (vis[i]) continue;
    	//cout << "component: " << endl;
    	sum = 0;
    	dfs(i);
    	//cout << endl << "===============" << endl;
    	if (sum != 0) poss = false;
    }
    if (poss) cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}
// PLUS ULTRA!

Measured memory_bytes: 11500
n = int(input())
a=input().split()
l=n - n %2-1
e=[i for i in a[l::-2]]  
o=[i for i in a[::2]]
e.extend(o)
if n==1:
  print(*a)
elif n % 2 ==0:
  print(*e)
else:
  print(*e[::-1])



Measured memory_bytes: 25412
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        x: usize
    }
    let mut ans = 0;
    for i in 0..a + 1 {
        for j in 0..b + 1 {
            let t = x - 500 * i - 100 * j;
            if t % 50 == 0 && t / 50 <= c {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n;
  vector<int> a(n);
  for (int& x : a) {
    cin >> x;
  }
  int ans = inf;
  for (int i = 1; i <= 100; ++i) {
    int cur = 0;
    for (int x : a) {
      cur += (x - i) * (x - i);
    }
    ans = min(ans, cur);
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B,kotae,i,j,hitoketa,yonketa,hutaketa;
    cin >> A >> B ;
    for (i = A;i <= B;i++){
        for (j = i;j>10;j = j -10) {
            hitoketa = j;
        }
        hitoketa = j;
        for (j = i/1000;j>10;j = j - 10){
            yonketa = j;
        }
        yonketa = j;
        for (j = i/10;j>10;j = j - 10){
            hutaketa = j;
        }
        hutaketa = j;
        if (i/10000 == hitoketa && yonketa == hutaketa){
            kotae ++;
        }
    }
    cout << kotae <<endl;
}

Measured memory_bytes: 384