akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long            ll;
typedef unsigned long long   ull;
typedef vector<int>          vi;
typedef vector<ll>           vl;
typedef pair<int, int>       pi;
typedef pair<ll, ll>         pl;
typedef vector<pi>           vpi;
typedef vector<pl>           vpl;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define read        freopen("in.c", "r", stdin)
#define write       freopen("out.c", "w", stdout)
#define all(a)      a.begin(), a.end()
#define UNI(a)      a.resize(unique(all(a), a.begin()) - a.begin())
#define bye         exit(0)
#define mp          make_pair
#define ff          first
#define ss          second
#define L(x)        ((x) << 1)
#define R(x)        ((x) << 1 | 1)
#define SZ(a)       (ll)(a).size()
#define pb          push_back
#define eb          emplace_back
#define eps         1e-9
#define inf         (1000000000)
#define infl        (1000000000000000000LL)
#define cs(p)       printf("Case %d:", (p)++)
#define ptc(c)      putchar(c)
#define gtc()       getchar()
#define nl          puts("")
#define sp          printf(" ")
#define out(a)      printf("%lld", (ll)(a))
#define SET(a, x)   memset((a), x, sizeof(a))
#define dbg(x)      cout << "--- " << #x << " = " << (x) << '\n'

ll bgm(ll a, ll b, ll m) {
    b = (b == -1) ? (m - 2) : b;
    a %= m;
    ll rem = 1;
    while(b != 0) {
        if(b&1) {
            rem = (rem * a) % m;
        }
        a = (a * a) % m;
        b >>= 1;
    }
    return rem;
}

inline ll in() {
    ll a;
    assert(scanf("%lld", &a) != EOF);
    return a;
}

const int MAX = 100000 + 5;
const int LEN = 50;
const ll MOD = 1000000007;

int n;
int h[MAX];

int dp[MAX];

int main() {
    n = in();
    for(int i = 1; i <= n; i++) {
        h[i] = in();
    }
    dp[0] = inf;
    dp[1] = 0;
    for(int i = 2; i <= n; i++) {
        dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2]);
    }
    out(dp[n]), nl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var a = ReadSplitInt();

            var sum = 0;
            for (int i = 0; i < N; i++)
            {
                sum += a[i] - 1;
            }
            Println(sum);
        }

        static List<int> ReadLines(int n)
        {
            var l = new List<int>();
            for (int i = 0; i < n; i++)
            {
                l.Add(ReadInt());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a * b / Gcd(a, b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11348
n,m=map(int,input().split())
w,u=3*m,n-1
o,f,i=998244353,[1],1
while i<w+n:f+=[f[-1]*i%o];i+=1
c=lambda n,k=u:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
a=c(w+u)-n*c(n+m-2)
while~-n>m<w:m+=2;a-=c(n,m)*c(2*u+w-m>>1)
print(a%o)

Measured memory_bytes: 115684
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC037A
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] n = Console.ReadLine().Split(' ');
			int a = int.Parse(n[0]);
			int b = int.Parse(n[1]);
			int c = int.Parse(n[2]);
 
			if (a == (b + c))
				Console.WriteLine("Yes");
 
			else if (b == (a + c))
				Console.WriteLine("Yes");
 
			else if (c == (a + b))
				Console.WriteLine("Yes");
 
			else
				Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 13140
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 2005;
const int INF = 1 << 30;

int N, Z, W;
int v[MAX];
int dpA[MAX] = { 0 };
int dpB[MAX] = { 0 };

int solveB(int n);

int solveA(int n) {
	if (dpA[n] != -1)return dpA[n];

	int m = 0;
	for (int i = n; i < N; i++) {
		if (i == N - 1)m = max(m, abs(v[n - 1] - v[i]));
		else m = max(m, solveB(i + 1));
	}
	return dpA[n] = m;
}
int solveB(int n) {
	if (dpB[n] != -1)return dpB[n];

	int m = INF;
	for (int i = n; i < N; i++) {
		if (i == N - 1)m = min(m, abs(v[i] - v[n - 1]));
		else m = min(m, solveA(i + 1));
	}
	return dpB[n] = m;
}

int main() {
	for (int i = 0; i < MAX; i++) {
			dpA[i] = -1;
			dpB[i] = -1;
	}

	cin >> N >> Z >> W;
	v[0] = W;
	for (int i = 0; i < N; i++) {
		cin >> v[i + 1];
	}
	N += 1;

	cout << solveA(1) << endl;
	return 0;
}

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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	cin >> n >> m;
	if(m%2)
		cout << "No\n";
	else
	{
		m/=2;
		b=m-n;
		a=n-b;
		if(a >=0 && b >=0)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3616
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n;cin>>n;
    int ans = 0;
    rep(i, 1, n+1){
        if (i%3!=0 && i%5!=0){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

int const mod = 1e9 + 7;
int const maxn = 21;

vector<int> v[maxn];
int dp[maxn][1<<maxn];

int solve(int mask, int x) {
    if (x == -1) {
        return mask == 0;
    }

    int &d = dp[x][mask];

    if (d != -1) {
        return d;
    }

    d = 0;

    for (int i : v[x]) {
        if ((1<<i)&mask) {
            d += solve(mask^(1<<i), x-1);

            if (d >= mod) d -= mod;
        }
    }

    return d;
}

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int ok;
            cin >> ok;

            if (ok == 1) {
                v[i].push_back(j);
            }
        }
    }

    memset(dp, -1, sizeof(dp));

    cout << solve((1<<n)-1, n-1) << "\n";
}

Measured memory_bytes: 172288
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

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

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll H,W;
  cin>>H>>W;
  char s[H+2][W+2];

  FOR(i,0,H+1){
    FOR(j,0,W+1){
      s[i][j]='.';
    }
  }

  FOR(i,0,H-1){
    FOR(j,0,W-1){
      cin>>s[i+1][j+1];
    }
  }
  int flag=0;



  FOR(i,0,H-1){
    FOR(j,0,W-1){
      if(s[i][j]=='#'){
        if(s[i-1][j]=='.'&&s[i+1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.'){
          flag=1;
        }

      }


    }
  }
  if(flag==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

}
 


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

int main(){
    ll n, m;
    cin >> n >> m;
    if(n==1 && m==1){
        cout << 1 << endl;
    }else if(n==1 || m==1){
        cout << max(n,m)-2 << endl;
    }else{
        cout << (n-2)*(m-2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func gcd(x, y int) int {
	if y == 0 {
		return x
	}

	return gcd(y, x%y)
}

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	fmt.Println(gcd(x, y))
}



Measured memory_bytes: 1156
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
#define what(x) cerr << #x << " is " << x << endl;

int main(){
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 1010;
typedef pair<int, int> pii;

pii q[N * N];
char s[N];
int dis[N][N], mx[4] = {0, 0, 1, -1}, my[4] = {1, -1, 0, 0};
bool g[N][N];

int up(int a, int b) { return a % b ? a / b + 1 : a / b;}

int main()
{
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	int tx, ty;
	Rep(i, h){
		scanf("%s", s + 1);
		Rep(j, w){
			if (s[j] == '.') g[i][j] = 1;
			else if (s[j] == 'S') tx = i, ty = j;
		}
	}
	
	memset(dis, -1, sizeof(dis));
	int he = 0, ta = 0;
	q[++ ta] = mp(tx, ty), dis[tx][ty] = 0;
	while (he != ta) {
		he ++;
		int x = q[he].first, y = q[he].second;
		if (dis[x][y] == k) continue;
		Rep0(i, 3) if (g[x + mx[i]][y + my[i]] && dis[x + mx[i]][y + my[i]] == -1) {
			dis[x + mx[i]][y + my[i]] = dis[x][y] + 1;
			q[++ ta] = mp(x + mx[i], y + my[i]);
		}
	}
	int ans = 1e9;
	Rep(i, h) Rep(j, w) if (dis[i][j] != -1) {
		//printf("%d %d\n", i, j);
		ans = min(ans, up(min(i - 1, h - i), k));
		ans = min(ans, up(min(j - 1, w - j), k));
	}
	
	printf("%d\n", ans + 1);
	
	return 0;
}

Measured memory_bytes: 10240
#include<iostream>

using namespace std;

int main(){
	int N;
	cin>>N;
	int p=N;
	for(int i=0;i<=N;i++){
		int c=0;
		int t=i;
		while(t>0)c+=t%6,t/=6;
		t=N-i;
		while(t>0)c+=t%9,t/=9;
		if(c<p)p=c;
	}

	cout<<p<<endl;

	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2019/12/08.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll ans = 0;				// "No"
	ll point;

	REP(i, 3) {
		cin >> point;
		ans += point;
	}

	if (ans >= 22 ) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll chk(vector<ll> a,vector<ll> b,ll n,ll k,ll mid){
	for(ll i=0;i<n;i++){
			while(a[i]*b[i]>mid&&k>0){
				int x=a[i]-mid/b[i];
				a[i]=mid/b[i];
				k=k-x;
				if(k<0)return 0;
			}
			if(a[i]*b[i]>mid)return 0;
	}
	return 1;
}
int main(){
	ios;
	ll n,k;cin>>n>>k;
	vector<ll> a(n),b(n);
	for(ll i=0;i<n;i++)cin>>a[i];
	for(ll i=0;i<n;i++)cin>>b[i];
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(a.begin(),a.end());
	ll s=0,e=1e15,mid,ans;
	while(s<=e){
		mid=(s+e)/2;
		//cout<<mid<<endl;
		//cout<<(a,b,n,k,mid)<<endl;
		if(chk(a,b,n,k,mid)){
			ans=mid;
			e=mid-1;
		}
		else{
			s=mid+1;
		}
	}
	//cout<<k<<endl;
//	for(int i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6576
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int m=-2;
void p(int n)
{
int k=n%m;n=n/m;
if (k<0) k-=m,n++;
if (n!=0) p(n);
putchar(k>9?k+55:k+48);
}

int main(){
int n=read();
p(n);
}

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

using namespace std;

struct Dice{
	int q1,q2,q3,q4,q5,q6;
};

int main(){
	Dice d;
	char od;
	
	scanf("%d %d %d %d %d %d", &d.q1, &d.q2, &d.q3, &d.q4, &d.q5, &d.q6);
	
	while( scanf("%c", &od) != EOF ){
		if(od=='N'){
			int tmp=d.q1;
			d.q1=d.q2;
			d.q2=d.q6;
			d.q6=d.q5;
			d.q5=tmp;
		}
		else if(od=='E'){
			int tmp=d.q1;
			d.q1=d.q4;
			d.q4=d.q6;
			d.q6=d.q3;
			d.q3=tmp;
		}
		else if(od=='W'){
			int tmp=d.q1;
			d.q1=d.q3;
			d.q3=d.q6;
			d.q6=d.q4;
			d.q4=tmp;
		}
		else if(od=='S'){
			int tmp=d.q1;
			d.q1=d.q5;
			d.q5=d.q6;
			d.q6=d.q2;
			d.q2=tmp;
		}
	}
	
	printf("%d\n", d.q1);
	
	return 0;
}


Measured memory_bytes: 3172
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int):
    k = 1
    while k < N:
        k *= 2
    if N == k:
        print(NO)
        return
    print(YES)

    if N % 2 == 0:
        n = N - 1
        even = True
    else:
        n = N
        even = False

    for i in range(2, n+1):
        if i % 2 == 0:
            print(1, i)
            print(N+i+1, N+i)
        else:
            print(i, i-1)
            print(N+i, 1)
    print(3, N+1)
    if even:
        k //= 2
        print(N, k)
        a = N ^ k ^ 1
        print(a + N, N * 2)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 54076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=654321;
ll n,num;
ll x[maxn];
map<ll,int>q;
int main()
{
    cin>>n>>num;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i];
        q[x[i]]=1;
    }
    x[n+1]=1e10;
    ll tim=0;
    for(int i=1;i<=n;i++)
    {
        ll ans=x[i]+num;
        if(ans>=x[i+1])
        {
            tim+=x[i+1]-x[i];
        }
        else
        {
            tim+=num;
        }
    }
    cout<<tim<<endl;
    return 0;
}


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

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

  cin >> A >> B >> C;
  if (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

using namespace std;

#define PI			3.14159265
#define OO			1e9
#define SS       	second
#define FF       	first
#define Trace(n)  	cout<< #n <<" = "<< n << endl; 
#define ll			long long
#define endl		"\n"
#define EPS		    1e-9
//#define MOD         1e9 + 7	    
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { -1, 1, 0, 0, 1, -1, 1, -1 };

void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main()
{
	fast();
	ll n;
	cin >> n;
	vector<ll> v(n + 1);
	for (int i = 0; i < n + 1; i++)
		cin >> v[i];
	vector<ll> b(n);
	for (int i = 0; i < n; i++)
		cin >> b[i];

	ll ans = 0, mn;
	for (int i = n - 1; i >= 0; i--)
	{
		mn = min(b[i], v[i + 1]);
		ans += mn;
		b[i] -= mn;
		v[i + 1] -= mn;
		mn = min(b[i], v[i]);
		ans += mn;
		b[i] -= mn;
		v[i] -= mn;
	}
	cout << ans;
}

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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<ll> vec(n);

    for(int i = 0; i < n; i++)
        cin >> vec[i];

    vector<pair<ll, ll> > vpf(n, {0, 0}), vpb(n, {0, 0});
    vector<int> pl(n), pr(n);
    vpf[1] = {vec[0], vec[1]};
    pl[1] = 1;
    vpb[n - 2] = {vec[n - 2], vec[n - 1]};
    pr[n - 2] = n - 2;

    for(int i = 2; i < n; i++)
    {
        ll lsum = vpf[i - 1].first, rsum = vpf[i - 1].second;
        int sp = pl[i - 1];
        rsum += vec[i];
        ll ans = abs(rsum - lsum);

        while(abs(lsum + (2 * vec[sp]) - rsum) < ans)
        {
            lsum += vec[sp];
            rsum -= vec[sp];
            sp++;
            ans = abs(rsum - lsum);
        }

        vpf[i] = {lsum, rsum};
        pl[i] = sp;
    }

    for(int i = (n - 3); i >= 0; i--)
    {
        ll lsum = vpb[i + 1].first, rsum = vpb[i + 1].second;
        int sp = pr[i + 1];
        lsum += vec[i];
        ll ans = abs(lsum - rsum);

        while(abs(rsum + (2 * vec[sp]) - lsum) < ans)
        {
            lsum -= vec[sp];
            rsum += vec[sp];
            sp--;
            ans = abs(lsum - rsum);
        }

        vpb[i] = {lsum, rsum};
        pr[i] = sp;
    }

    ll ans = 1e18;

    for(int i = 1; i < (n - 2); i++)
    {
        set <ll> st;
        st.insert(vpf[i].first);
        st.insert(vpf[i].second);
        st.insert(vpb[i + 1].first);
        st.insert(vpb[i + 1].second);
        ans = min(ans, (*st.rbegin() - (*st.begin())));
    }

    cout << ans <<"\n";
    return 0;
}


Measured memory_bytes: 9600
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<vector<int> > graph(n);
  REP(_, n - 1) {
    int a, b; cin >> a >> b; --a; --b;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }
  vector<int> p(n, -1);
  int k; cin >> k;
  while (k--) {
    int v; cin >> v; --v;
    cin >> p[v];
  }
  vector<int> lb(n, -INF), ub(n, INF);
  function<void(int)> solve = [&](int root) {
    function<void(int, int)> dfs = [&](int par, int ver) {
      for (int e : graph[ver]) {
        if (e == par) continue;
        dfs(ver, e);
        chmax(lb[ver], lb[e] - 1);
        chmin(ub[ver], ub[e] + 1);
      }
      if (ub[ver] < lb[ver]) {
        cout << "No\n";
        exit(0);
      }
      if (p[ver] != -1) {
        if (lb[ver] <= p[ver] && p[ver] <= ub[ver]) {
          lb[ver] = ub[ver] = p[ver];
        } else {
          cout << "No\n";
          exit(0);
        }
      }
    };
    dfs(-1, root);
    // REP(i, n) cout << lb[i] << ' ' << ub[i] << '\n';
    vector<int> ans(n);
    ans[root] = p[root];
    function<void(int, int)> dfs2 = [&](int par, int ver) {
      for (int e : graph[ver]) {
        if (e == par) continue;
        if (lb[e] <= ans[ver] + 1 && ans[ver] + 1 <= ub[e]) {
          ans[e] = ans[ver] + 1;
        } else if (lb[e] <= ans[ver] - 1 && ans[ver] - 1 <= ub[e]) {
          ans[e] = ans[ver] - 1;
        } else {
          cout << "No\n";
          exit(0);
        }
        dfs2(ver, e);
      }
    };
    dfs2(-1, root);
    cout << "Yes\n";
    REP(i, n) cout << ans[i] << '\n';
  };
  REP(i, n) {
    if (p[i] != -1) {
      solve(i);
      break;
    }
  }
  return 0;
}


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

string y;

void replace(int a,int b,string x){
    y.replace(a,b-a+1,x);
}

void reverse(int a,int b){
    string t;
    t=y[b];
    for(int i=b-1;i>=a;i--){
        t+=y[i];
    }
    replace(a,b,t);
}
void print(int a,int b){
    string ans;
    ans=y[a];
    for(int i=a+1;i<=b;i++){
        ans+=y[i];
    }
    cout<<ans<<endl;
}

int main(){
    int n;
    cin>>y>>n;
    for(int i=0;i<n;i++){
        string order;
        cin>>order;
        if(order=="replace"){
            int a,b;
            string x;
            cin>>a>>b>>x;
            replace(a,b,x);
        }
        else if(order=="reverse"){
            int a,b;
            cin>>a>>b;
            reverse(a,b);
        }
        else if(order=="print"){
            int a,b;
            cin>>a>>b;
            print(a,b);
        }
    }
    return 0;
}


Measured memory_bytes: 3208
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>

using namespace std;

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

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

struct Edge {
	int src, dst, cost;
	Edge(int s, int d, int c) : src(s), dst(d), cost(c) {}
	Edge() {}
	bool operator<(const Edge& e)const {
		return cost > e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

Edges prim(const Graph& g)
{
	Edges T;
	vector<int> visited(g.size(), 0);
	visited[0] = 1;

	priority_queue<Edge> Q;
	rep(i, g[0].size())
		Q.push(g[0][i]);

	while(!Q.empty()){
		Edge e = Q.top();
		Q.pop();
		if(visited[e.dst])
			continue;
		T.push_back(e);
		visited[e.dst] = 1;
		rep(i, g[e.dst].size()){
			if(!visited[g[e.dst][i].dst])
				Q.push(g[e.dst][i]);
		}
	}
	return T;
}

int main()
{
	int n, m;
	while(scanf("%d", &n), n){
		scanf("%d", &m);
		Graph g(n);
		rep(i, m){
			int a, b, d;
			scanf("%d,%d,%d", &a, &b, &d);
			g[a].push_back(Edge(a, b, d));
			g[b].push_back(Edge(b, a, d));
		}
		Edges t = prim(g);
		int ans = 0;
		rep(i, t.size())
			ans += t[i].cost / 100 - 1;
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	N := nextInt()
	A := nextInts(N)
	b := make([]int, N)
	pcnt := 0
	for i := 0; i < N; i++ {
		if A[i] < 0 {
			pcnt++
		}
		b[i] = abs(A[i])
	}
	if pcnt%2 == 0 {
		fmt.Println(sum(b))
	} else {
		sort.Ints(b)
		fmt.Println(sum(b) - b[0]*2)
	}
}

var dy = []int{1, 0, -1, 0, 0}
var dx = []int{0, 1, 0, -1, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}
func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


Measured memory_bytes: 3840
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];
	vector<pair<ll, ll>> path(m);
	rep(i, m) cin >> path[i].first >> path[i].second;
	rep(i, m) {
		path[i].first--;
		path[i].second--;
	}

	map<ll, vector<ll>> ab;
	rep(i, m) {
		ab[path[i].first].push_back(path[i].second);
	}
	rep(i, m) {
		ab[path[i].second].push_back(path[i].first);
	}
	ll cnt = 0;
	rep(i, n) {
		if (ab[i].size() == 0) {
			cnt++;
			continue;
		}
		bool isgood = true;
		for (ll k = 0; k < ab[i].size(); k++) {
			if (h[i] <= h[ab[i][k]]) isgood = false;
		}
		if (isgood) cnt++;

	}
	cout << cnt << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

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

    ll ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i] == 0 && ans == 0) continue;
        if (a[i] == 0 && ans > 0 && b[i] == 1) continue;
        if (a[i] > 0 && b[i] == 1) continue;
        if ((a[i] + ans) % b[i] == 0) continue;

        ll t = (a[i] + ans) / b[i];
        ans += (t + 1) * b[i] - (a[i] + ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
struct UnionFind{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int root(int x) {
    if (x == par[x]) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sizes[root(x)];
  }
};
int main(){
	int N,M,A[200001],B[200001];
	scan(N>>M);
	UnionFind uf(N);
	rep(i,M){
		scan(A[i]>>B[i]);
		A[i]--; B[i]--;
		uf.unite(A[i],B[i]);
	}
	int ans=0;
	rep(i,N){
		ans=max(ans,uf.size(i));
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 6364
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 1e6
using namespace std;
typedef long long ll;
ll w,h,v,t,x,y,p,q;

ll fabs(ll a){
	if(a<0)return -a;
	return a;
}
ll dist(ll a,ll b){
	return a*a+b*b;
}

bool CL(ll c,ll sx,ll sy){
	ll nx=-w*2LL*(c/2LL);
	if(c%2==0)nx+=sx;
	else nx-=sx;
	if(fabs(nx-p)>v*t)return false;
	return dist(nx-p,sy-q)<=v*v*t*t;
}

bool CR(ll c,ll sx,ll sy){
	ll nx=w*2LL*((c+1LL)/2LL);
	if(c%2==0)nx+=sx;
	else nx-=sx;
	if(fabs(nx-p)>v*t)return false;
	return dist(nx-p,sy-q)<=v*v*t*t;
}

int main(void){
	scanf("%lld%lld%lld%lld%lld%lld%lld%lld",&w,&h,&v,&t,&x,&y,&p,&q);
	ll cnt=0;
	ll i=0;
	while(1){
		ll yy=-h*2LL*(i/2LL);
		if(i%2==0)yy+=y;
		else yy-=y;
		if(dist(x-p,yy-q)>v*v*t*t)break;
		cnt++;
		ll l=0,r=INF;
		for(int j=0;j<30;j++){
			ll mid=(l+r)/2LL;
			if(CL(mid,x,yy))l=mid;
			else r=mid;
		}
		cnt+=l;
		l=0,r=INF;
		for(int j=0;j<30;j++){
			ll mid=(l+r)/2LL;
			if(CR(mid,x,yy))l=mid;
			else r=mid;
		}
		cnt+=l;
		i++;
	}
	i=1;
	while(1){
		ll yy=h*2LL*((i+1)/2LL);
		if(i%2==0)yy+=y;
		else yy-=y;
		if(dist(x-p,yy-q)>v*v*t*t)break;
		cnt++;
		ll l=0,r=INF;
		for(int j=0;j<30;j++){
			ll mid=(l+r)/2LL;
			if(CL(mid,x,yy))l=mid;
			else r=mid;
		}
		cnt+=l;
		l=0,r=INF;
		for(int j=0;j<30;j++){
			ll mid=(l+r)/2LL;
			if(CR(mid,x,yy))l=mid;
			else r=mid;
		}
		cnt+=l;
		i++;
	}
	printf("%lld\n",cnt);
	return 0;
}

Measured memory_bytes: 1028
import sys
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
p = 1
B = [-1]*N
B[0] = 0
count = 1
while K >= count:
	p = A[p-1]
	if B[p-1] != -1:
		break
	B[p-1] = count
	count += 1
if K < count:
	print(p)
	sys.exit()
K -= count
K = K % (count-B[p-1])
for i in range(K):
	p = A[p-1]
print(p)

	


Measured memory_bytes: 32272
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        int N,M;
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();

        for (int p = M/N; p >= 1; p--){
            if (M % p != 0) {
                continue;
            }

            System.out.println(p);
            return;

        }


    }
}


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

using namespace std;

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

long long cnt = 0,num = 1,bf=-1;

for (long long i = 0; i < N; i++)
{
  if (a[i] == num)
  {
    cnt+=i-bf-1;
    bf = i;
    num++;
  }
}
cnt += N-1 - bf;
if (num == 1)
{
 cnt = -1;
}

cout << cnt;

}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n;
  while(cin >> n && n){
    int s = 0;
    for(int i = 1; i*i <= n; i++){
      if(n%i) continue;
      s += i;
      if(i*i < n) s += n/i;
    }
    s -= n;
    if(n == s){
      cout << "perfect number" << endl;
    }else if(n > s){
      cout << "deficient number" << endl;
    }else{
      cout << "abundant number" << endl;
    }
  }
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 100050;
int N;
int num[MAX_N];

int calc(const int R) {
    //std::cout << R << std::endl;
    if (num[R] != -1) {
        return num[R];
    }
    if (R == 0) {
        num[R] = 0;
        return 0;
    }

    int ret = N;
    if (R < 6) {
        ret = std::min(ret, 1 + calc(R - 1));
    }
    
    int tmp = 6;
    for (int i = 0; i <= N; i++) {
        if (R < tmp) {
            break;
        }
        ret = std::min(ret, 1 + calc(R - tmp));
        tmp = tmp * 6;
    }

    tmp = 9;
    for (int i = 0; i <= N; i++) {
        if (R < tmp) {
            break;
        }
        ret = std::min(ret, 1 + calc(R - tmp));
        tmp = tmp * 9;
    }

    num[R] = ret;
    return ret;
}


int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 0; i <= N; i++) {
        num[i] = -1;
    }

    std::cout << calc(N) << std::endl;
    
    return 0;

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
ll sg[100001],yg[100001];
int n;
ll a[100001];
int main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	sg[0]=a[0];
	yg[n-1]=a[n-1];
	forn(i,1,n){
		sg[i]=__gcd(sg[i-1],a[i]);
	}
	for(int i=n-2;i>=0;i--){
		yg[i]=__gcd(yg[i+1],a[i]);
	}
	ll ans=0;
	rep(i,n){
		if(i==0){
			ans=yg[i+1];
		}else{
			if(i==n-1)
			ans=max(ans,sg[i-1]);
			else
			ans=max(ans,__gcd(sg[i-1],yg[i+1]));
		}
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
const int mod=1e9+7;
const int M=1e6+9;

map<int,int>cnt,vis;
int a[N];

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int ans=n;
    int tot=n;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	cnt[a[i]]++;
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
    	int cur=a[i];
    	if(cnt[cur]==0)continue;
    	for(ll j=cur;j<=M;j+=cur){
    		if(cnt[j]>0){
    			if(j==cur){
    				if(cnt[j]>1){
    				ans-=cnt[j];
    				cnt[j]=0;
    			   }
    			}
    		    else {
                    if(cnt[j]>0){
	    				ans-=cnt[j];
	    				cnt[j]=0;
	    				//cout<<cur<<" "<<j<<endl;
    				} 
    			}
    		}
    	}
    }
    cout<<ans<<'\n';
   

    
    
   

}
    

Measured memory_bytes: 51184
using System;

class Program{
  static void Main(){
    string[] s = Console.ReadLine().Split(' ');
    int[] a = new int[3];
    int ans = 0;
    for(int i = 0;i<a.Length;i++){
      a[i] = int.Parse(s[i]);
    }
    if(a[0]/2>=a[1]){                       // 1Lの水の500mLあたりの値段が
      while(a[2]>0){                        // 500mLの水の値段より大きければ
        a[2] -= 500;                        // 500mLの水のみを買う。
        ans += a[1];
      }
    }else{
      while(a[2]>0){
        if(a[2]>=1000){                     // 必要な水の量が1L以上あるときは
          ans += a[0];                      // 1Lの水を買う。
          a[2] -= 1000;
        }else if(a[2]<1000 && a[2]>500){    // 500mL < 必要な水の量 < 1000の時は、
          ans += a[0];                      // 1Lの水を買う。
          a[2] -= 1000;
        }else{                              // 必要な水の量が500mL以下で
          if(a[0]>a[1]){                    // 1Lの水の値段 > 500mLの水の値段の時、
            ans += a[1];                    // 500mLの水を買う。
            a[2] -= 500;
          }else{                            // 1Lの水のほうが安ければ、
            ans += a[0];                    // 1Lの水を買う。
            a[2] -= 1000;
          }
        }
      }
    }
    Console.WriteLine("{0}",ans);
  }
}



Measured memory_bytes: 18048
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
    ci(n>>m)
  ll ans=0;
  ll now=n;
  ll two=2;
  FOR(i,0,100){
    if(now<=m) {
      ans++;
    now*=2;
  }
    else break;
  }
  co(ans)
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        aa: [i64; n]
    }
    let contains_zero = aa.contains(&0);
    let is_minus_even = aa.iter().filter(|&a| a < &0).count() % 2 == 0;
    let sum = aa.iter().map(|&a| if a > 0 { a } else { -a }).fold(0, |sum, a| sum + a);
    let result = if contains_zero || is_minus_even {
        sum
    } else {
        let minimum = aa.iter().map(|&a| if a > 0 { a } else { -a }).min().unwrap();
        sum - (2 * minimum)
    };

    println!("{}", result);
}


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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		
		String[] tmpArray = input.split(" ");
		
		if(tmpArray[1].equals(tmpArray[2])){
			System.out.println(tmpArray[0]);
		}
		if(tmpArray[2].equals(tmpArray[0])){
			System.out.println(tmpArray[1]);
		}
		if(tmpArray[1].equals(tmpArray[0])){
			System.out.println(tmpArray[2]);
		}
		
	}

}


Measured memory_bytes: 21204
import java.util.Scanner;

class Main {
	static final String CODE = "012345024135031425043215103254120534135024152304201453215043240513254103304152310542345012351402402351425031430521453201513240521430534120542310";

	static class Dice {
		private int[] dig;
		private int[] pat;
		public Dice(Scanner s) {
			dig = new int[6];
			for (int i = 0; i < dig.length; i++) {
				dig[i] = s.nextInt();
			}
			pat = new int[CODE.length()];
			for (int i = 0; i < pat.length; i++) {
				int p = CODE.charAt(i) - '0';
				pat[i] = dig[p];
			}
		}
		public boolean eq(Dice d) {
			for (int p = 0; p < pat.length; p += 6) {
				boolean hit = true;
				for (int i = 0; i < 6; i++) {
					if (d.dig[i] != pat[p + i]) {
						hit = false;
						break;
					}
				}
				if (hit) {
					return true;
				}
			}
			return false;
		}
	}

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			Dice l = new Dice(sc);
			Dice r = new Dice(sc);
			System.out.println(l.eq(r) ? "Yes" : "No");
		}
	}
}



Measured memory_bytes: 26288
#include<bits/stdc++.h>
using namespace std;
int k,n,l;
long long res,MOD=1000000007,p25[2000100],comb;
long long inv[2000100];
void init_math(int N){
	inv[1]=1LL;
	for(int i=2;i<=N;i++)
		inv[i]=(MOD-((MOD/i)*inv[MOD%i])%MOD);
}
string s;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>k>>s;
	n=s.size()+k;
	l=s.size();
	init_math(n);
	p25[0]=1;
	for(int x=1;x<=n;x++)
		p25[x]=(p25[x-1]*25LL)%MOD;
	comb=1;
	for(int x=1;x<=n;x++){
		comb=(comb*(long long)(n-x+1))%MOD;
		comb=(comb*inv[x])%MOD;
		if(x>=l)
			res=(res+comb*p25[n-x]%MOD)%MOD;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 35512
var lines = [];

var readline = require('readline')
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});


rl.on('line', (x) => {
    lines.push(x)
});

rl.on('close', () => {
    var N = Number(lines[0].split(" ")[0])
    var M = Number(lines[0].split(" ")[1])
    lines.shift()

    var LR = lines.map(i => i.split(" ").map(i => Number(i)));
    var start = 1; var goal = Infinity;

    for (var i = 0; i < M; i++) {
        var l = LR[i][0]; var r = LR[i][1];

        start = Math.max(start, l);
        goal = Math.min(goal, r);
    }

    console.log(Math.max(goal - start + 1, 0))
});

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

int main() {
    int n,a,b,c,d;
    cin>>n;
    a=n/1000;
    b=n%1000/100;
    c=n%100/10;
    d=n%10;
    
   
    if (a==b && b==c){
        cout<<"Yes"<<endl;
    }
    else if (b==c&& c==d){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256