akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
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(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

signed main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;

	int od = 0, ev = 0;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 2) {
			od++;
		}
		else {
			ev++;
		}
	}

	if (od % 2) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())

p=0
for y in range(n//7+1):
  x=n/4 - 7*y/4
  if x.is_integer() == True and x>-1:
    p += 1
    break
  else:
    continue
if p == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main() {
  for (;;) {
    string a, b;
    if (!(cin >> a)) return 0;
    cin >> b;
    int result = 0, dp[4001];
    fill(dp, dp+b.length()+1, 0);
    for (int i = 0; i < a.length(); i++)
      for (int j = b.length()-1; j >= 0; j--)
        if (a[i] == b[j]) {
          dp[j+1] = dp[j] + 1;
          if (dp[j+1] > result)
            result = dp[j+1];
        } else dp[j+1] = 0;
    cout << result << endl;
  }
}

Measured memory_bytes: 952
let S = readLine()!.characters
var ans = (0..<S.count).map{_ in 0}
var a = [0, 0]
for (i, c) in S.enumerate() {
    if c == "R" {
        a[i%2]++
    } else {
        ans[i] += a[i%2]
        ans[i-1] += a[i%2^1]
        a = [0, 0]
    }
}
for (i, c) in S.enumerate().reverse() {
    if c == "L" {
        a[i%2]++
    } else {
        ans[i] += a[i%2]
        ans[i+1] += a[i%2^1]
        a = [0, 0]
    }
}
ans.forEach{print($0, terminator: " ")}

Measured memory_bytes: 6308
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#include <fstream>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    string S;
    cin >> S;
    ll N = S.size() + 1;

    vector<char> run;
    vector<ll> length;

    if (S[0] == '<') {
        run.push_back('>');
        length.push_back(0);
    }

    ll tmp = 1;
    Rep (i, N-2) {
        if (S[i] == S[i+1]) {
            tmp++;
        } else {
            run.push_back(S[i]);
            length.push_back(tmp);
            tmp = 1;
        }
    }
    run.push_back(S[N-2]);
    length.push_back(tmp);

    ll n = run.size();
    ll ans = 0;
    Rep (i, n-1) {
        if (run[i] == '<') {
            if (length[i] < length[i+1]) {
                length[i]--;
            } else if (length[i]  >= length[i+1]) {
                length[i+1]--;
            }
        }
        ans += length[i] * (length[i]+1) / 2;
    }

    ans += length[n-1] * (length[n-1] + 1) / 2;
    cout << ans << endl;
}

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

int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s, t;
	cin >> s >> t;
	
	int ans = 2e9;
	for(int i = 0; i < s.size(); i++) {
		if(i + t.size() - 1 >= s.size()) break;
		int cur = 0;
		
		for(int j = 0; j < t.size(); j++) {
			if (s[i + j] != t[j]) cur++;
		}
		ans = min(ans, cur);
	}
	
	cout << ans << '\n';
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;
    vector<ll> ans(N, 0);
    Graph graph(N);
    rep(i, N - 1) {
        graph[i].push_back(i + 1);
        graph[i + 1].push_back(i);
    }
    graph[X].push_back(Y);
    graph[Y].push_back(X);
    rep(i, N) {
        vector<ll> dist(N, -1);
        queue<P> que;
        que.push(make_pair(i, 0));
        dist[i] = 0;
        while (!que.empty()) {
            P p = que.front();
            que.pop();
            for (ll v: graph[p.first]) {
                if (dist[v] == -1) {
                    dist[v] = p.second + 1;
                    que.push(make_pair(v, dist[v]));
                }
            }
        }
        rep2(j, i + 1, N) {
            ans[dist[j]]++;
        }
    }
    rep2(i, 1, N) {
        cout << ans[i] << '\n';
    }
}

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


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

int main()
{
  string S;
  cin>>S;
  bool flag = true;
  for(int i=0;i<3;i++)
  {
    if(S[i]==S[i+1])
    {
      flag = false;  
  	  break;
    }
  }
    if(flag)
      cout<<"Good\n";
    else
      cout<<"Bad\n";
    
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ll MOD = 1000000007;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  double a, b;
  int h, m; cin >> a >> b >> h >> m;
  double theta = min(360-(m*6.0-(h*60+m)*0.5), m*6.0-(h*60+m)*0.5);
  double radian = theta/180.0*Pi;
  double ans = sqrt(a*a+b*b-2*a*b*cos(radian));
  printf("%.9f\n", ans);
}


Measured memory_bytes: 4216
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

int n, ans = 0, indx;
string str;


int main () {
    cin >> n >> str;
    indx = n - 1;
    for (int i = 0; i < indx; i++) {
        if (str[i] == 'W') {
            while (str[indx] == 'W' && i < indx) indx--;
            if (str[indx] == 'R') {
                str[indx] = 'W';
                str[i] = 'R';
                ans++;
            }
        }
    }
    printf("%d", ans);
    return 0;
}

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



def main():
    num = input()
    sseq = input().split()
    iseq = map(int, sseq)
    ssat = input().split()
    svns = input().split()
    
    ans =0
    for i, s in enumerate(iseq):
        ans = ans + int(ssat[s-1])
        if (i < (int(num)-1)):
            if(int(sseq[i+1]) - int(sseq[i]) ==1):
                ans = ans + int(svns[s-1])
    print(ans)    
if __name__ == "__main__" :
    main()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a[ohara],b,c,d,cmp=1,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    map<ll,ll> mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    sort(a,a+n);
    reverse(a,a+n);
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cmp*=a[i];
            cnt++;
            i++;
            if(cnt==2)break;
        }
    }
    if(mp[1]<4)if(cmp==1)cmp=0;
    Cout(cmp);
    return 0;
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> d(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &d[i]);
  }

  sort(all(d));

  int middle = N / 2;

  if (d[middle - 1] == d[middle]) {
    cout << 0 << endl;
    return 0;
  }

  cout << d[middle] - d[middle - 1] << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
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);
	ll n, x, t;
	cin >> n >> x >> t;
	ll have = (n / x);
	if (n % x != 0)have++;
	cout << have*t << endl;

}

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

int main() {
    long long a,b,c,d, max;
    cin >> a >> b >> c >> d;
    max = a * c;
    if(a * d > max){
        max = a * d;
    }
    if(b * c > max){
        max = b * c;
    }
    if(b * d > max){
        max = b * d;
    }
    cout << max << endl;
    return 0;
}

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

namespace abc_153c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string[] input2 = Console.ReadLine().Split(' ');
            List<monster> monsters = new List<monster>();

            fennec Fennec = new fennec(long.Parse(input[1]));

            for (int i = 0; i < long.Parse(input[0]); i++)
            {
                monster monster = new monster(int.Parse(input2[i]));
                monsters.Add(monster);
            }
            
            monsters.Sort((a, b) => b.HP - a.HP);

            long Attack = 0;

            for(int i = 0;i< int.Parse(input[0]); i++)
            {
                if (Fennec.LethalWeapon != 0)
                {
                    Fennec.LethalWeapon -= 1;
                    monsters[i].HP = lethalweapon(Fennec, monsters[i]);
                }
                else
                {
                    Attack += monsters[i].HP;
                }
            }

            Console.WriteLine(Attack);

            Console.Read();
        

        }
        static public int lethalweapon(fennec fennec, monster monster)
        {
            monster.HP = 0;

            return monster.HP;
        }

    }
    class fennec
    {
        internal long LethalWeapon { get; set; }
        public fennec(long LW)
        {
            LethalWeapon = LW;
        }
        
    }
    class monster
    {
        internal int HP { get; set; }
        public monster(int hp)
        {
            HP = hp;
        }
        
    }
}


Measured memory_bytes: 39804
n, m = map(int, input().split())
a = list(map(int, input().strip().split()))

c = 0
s = sum(a)
for i in range(n):
    if a[i] >= (s / (4 * m)):
        c += 1

if c >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
package main

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

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	n, r := scanInt(), scanInt()
	if n < 10 {
		fmt.Println(r + (100 * (10 - n)))
	} else {
		fmt.Println(r)
	}
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanTexts(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanText()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {

	if a < b {
		a, b = b, a
	}

	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
int c[10][10];
int H, W, A, res;
int main()
{
    scanf("%d %d ", &H, &W);
    rep(i, 10) rep(j, 10) scanf("%d ", &c[i][j]);
    rep(k, 10) rep(i, 10) rep(j, 10) if (c[i][j] > c[i][k] + c[k][j]) c[i][j] = c[i][k] + c[k][j];
    rep(i, H) rep(j, W)
    {
        scanf("%d ", &A);
        if (A >= 0)
            res += c[A][1];
    }
    printf("%d \n ", res);
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

void swap(int *a, int *b);

int judge(int p[51], int N); // 昇順なら1, そうでないなら0を返す

int main(void)
{
    int N, p[51], i, j, k, r=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> p[i];
    }

    if(judge(p, N) == 1){
        r = 1;
    }

    for(i=1; i<=N-1; i++){
        for(j=i+1; j<=N; j++){
            swap(&p[i], &p[j]);

            if(judge(p, N) == 1){
                r = 1;
                break;
                break;
            }

            swap(&p[i], &p[j]);
        }
    }

    if(r == 1){
        cout << "YES" << endl;
    }

    else{
        cout << "NO" << endl;
    }

    return 0;
}

void swap(int *a, int *b)
{
    int tmp;
    
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int judge(int p[51], int N)
{
    int i, j=1;

    for(i=1; i<=N-1; i++){
        if(p[i] > p[i+1]){
            j = 0;
        }
    }

    return j;
}

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


int main(){
int X;
  cin >> X;
  bool a=false;
  
  while(a!=true){
    a=sq(a,X);
    X++;
  }

  cout << X-1 << endl;
}
bool sq(bool a,int X){
  bool b=true;
  for(int i=2;i<sqrt(X);i++){
    if(X%i==0)
      b=false;
  }
  if(b==true)
    return true;
  else
    return false;
}

Measured memory_bytes: 256
#include <stdio.h>
void solve(void)
{
	int k,s;
	int x,y,z;
	int count=0;
	scanf("%d %d", &k, &s);
	for(x=(k<s?k:s);x>=0;--x){
		if(s-x > k+k){
			break;
		} else if( s-x < k ){
			count += s-x+1;
		} else {
			count += (k+k) - (s-x) + 1;
		}
	}
	printf("%d\n", count);
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    vector<int> A(N);
    REP(i,N-1) {
        int a; cin >> a;
        a--;
        A[a]++;
    }
    REP(i,N) OUT(A[i])

    return 0;
}

Measured memory_bytes: 3972
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  int n;
  cin >> n;
  if(n==1){
    cout << "No" << endl;
    return 0;
  }
  if(n%2==1){
    cout << "Yes" << endl;
    cout << 1 << " " << 2 << endl;
    cout << 2 << " " << 3 << endl;
    cout << 3 << " " << 1+n << endl;
    cout << 1+n << " " << 2+n << endl;
    cout << 2+n << " " << 3+n << endl;
    for(int i=4;i<=n;i++){
      if(i%2==0) cout << i << " " << i+1 << endl;
      else cout << i << " " << 2 << endl;
    }
    for(int i=n+4;i<=2*n;i++){
      if(i%2==1) cout << 3 << " " << i << endl;
      else cout << i << " " << i-1 << endl;
    }
  }
  else{
    int count = 0;
    int n2 = n;
    while(n2%2!=1){
      count ++;
      n2/=2;
    }
    if(n2 == 1){
      cout << "No" << endl;
      return 0;
    }
    int l = pow(2,count+1)-1;
    cout << "Yes" << endl;
    for(int i=1;i<=l-1;i++){
      cout << i << " " << i+1 << endl;
    }
    cout << l << " " << n+1 << endl;
    for(int i=n+1;i<=n+l-1;i++){
      cout << i << " " << i+1 << endl;
    }
    for(int i=l+1;i<=n-1;i++){
      if(i%2==1) cout << i-1 << " " << i << endl;
      else cout << i << " " << 2 << endl;
    }
    for(int i=n+l+1;i<=2*n-1;i++){
      if(i%2==0) cout << i << " " << i+1 << endl;
      else cout << l << " " << i << endl;
    }
    cout << n << " " << l << endl;
    int kk = n^l;
    kk += n;
    cout << 2*n << " " << kk << endl;
  }
  return 0;
}


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

int main() {
	int N, M, a, b;
	cin >> N >> M;
	vector<int> ans(N);
	for (int i = 0; i < M; ++i) {
		cin >> a >> b;
		++ans[a - 1];
		++ans[b - 1];
	}
	for (int& i : ans) cout << i << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
struct ${$(){ios_base::sync_with_stdio(0);cin.tie(0);}}$;

const int N = 200005;

int main() {
   int n, x;
   cin >> n;
   map <int, int> m;
   for(int i = 0; i < n; i++) {
      cin >> x;
      m[x]++;
   }
   int ans = 0;
   for(auto t: m) {
      int a = t.first;
      int b = t.second;
      if(b >= a) ans += b - a;
      else ans += b;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){


double T,X;
cin >> T >>X;
double answer;

answer=T/X;

cout <<answer<<endl;  

 return 0;
}
/*
8 3

2.6666666667

99 1
99.0000000000

1 100
0.0100000000
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int shi_to_other(int a,int n){
	int t=0,t10=1;
	while(n>0){
		t++;
		n/=a; 
	}
	return t;
} 
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int n,k;
	cin>>n>>k;
	cout<<shi_to_other(k,n);

}


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

using namespace std;


int main() {
    int N; cin >> N;
    vector<int> P(N),Q(N);
    for(auto& p : P) cin >> p;

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

    int ans = 1;
    int len = 1;
    for(int i=0;i<N-1;i++) {
        if(Q[i] < Q[i+1]){
            len++;
        } else {
            ans = max(ans, len);
            len = 1;
        }
    }

    ans = max(ans, len);
    cout << N - ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	int ret=0;
	for (int i=1; i*i<=N; i++) {
		int j=(N-1)/i;
		ret+=2*(j-(i-1));
		if(j>=i) ret--;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
long long int a,b,n,t,ar[100000],c,r,p,sum,i;
string s;
int main()
{
cin>>s;
s[0]='2';
s[1]='0';
s[2]='1';
s[3]='8';



    cout<<s<<endl;
return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }
  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    String s = sc.next();
    StringBuilder sb = new StringBuilder();
    for (int i = s.length() - 1; i >= 0; i--) {
      sb.append(s.charAt(i));
    }
    s = sb.toString();
    int[] count = new int[2019];
    int result = 0;
    int num = 0;
    int x = 1;
    for (int i = 0; i < s.length(); i++) {
      count[num]++;
      num += Character.getNumericValue(s.charAt(i)) * x;
      num %= 2019;
      result += count[num];
      x = (x * 10) % 2019;
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 36904
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    bool a[n+1];
    ll dp[n+1];
    for(int i=1;i<=n;i++){
        a[i]=true;
    }
    ll b;
    for(int i=0;i<m;i++){
        cin>>b;
        a[b]=false;
    }
    dp[0]=1;
    for(int i=1;i<=n;i++){
        if(a[i]==false){
            dp[i]=0;
        }
        else if(i==1){
            dp[1]=dp[0];
        }
        else{
            dp[i]=dp[i-1]+dp[i-2];
            dp[i]%=mod;
        }
    }
    cout << (dp[n]%mod)<<endl;
    return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int Z;
int W;
int A[2123];
int X[2123];
int Y[2123];
int idx;
int ans;

int main(){
	
	cin>>N>>Z>>W;
	REP( i, N ) cin>>A[i];
	
	idx = N-1;
	
	
	//X, Yがidxからカードをとるときの答え
	while( idx ){
		X[idx] = Y[idx] = abs( A[idx-1]-A[N-1] );
		FOR( i, idx+1, N ){
			X[idx] = max( X[idx], Y[i] );
			Y[idx] = min( Y[idx], X[i] );
		}
		idx--;
	}
	
	X[0] = abs( A[N-1]-W );
	FOR( i, 1, N ) X[0] = max( X[0], Y[i] );
	
	cout<<X[0]<<endl;
	
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 5005
#define M 200005
#define seed 23333
#define Mo 1000000007

using namespace std;
int i,j,m,n,p,k,f[N][N],ans;
char c[N];
int power(int x,int y)
{
		int sum=1;
		for (;y;y>>=1)
		{
				if (y&1) sum=1ll*sum*x%Mo;
				x=1ll*x*x%Mo;
		}
		return sum;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",c); m=strlen(c);
	f[0][0]=1;
	for (i=1;i<=n;++i)
	{
			(f[i][0]+=f[i-1][0])%=Mo;
			for (j=0;j<i;++j)
			{
					(f[i][j+1]+=f[i-1][j]*2%Mo)%=Mo;
					if (j)
					(f[i][j-1]+=f[i-1][j])%=Mo;
			}
	}
	printf("%d\n",1ll*f[n][m]*power(power(2,m),Mo-2)%Mo);
}


Measured memory_bytes: 96384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2115;
const ll inf=1e17;
int n,tt,cc,S,T,hd[N],iter[N],vis[N];ll ans,dis[N];queue<int>q;
struct E{int v,nxt,w;ll c;}e[N*10];
inline void add(int u,int v,int w,ll c){e[++cc]=(E){v,hd[u],w,c};hd[u]=cc;e[++cc]=(E){u,hd[v],0,-c};hd[v]=cc;}
inline bool spfa()
{
	for(int i=1;i<=tt;i++)iter[i]=hd[i],dis[i]=inf;
	dis[S]=0;vis[S]=1;q.push(S);
	while(!q.empty())
	{
		int x=q.front();q.pop();vis[x]=0;
		for(int i=hd[x];i;i=e[i].nxt)
		{
			int y=e[i].v;
			if(e[i].w&&dis[y]>dis[x]+e[i].c)
			{
				dis[y]=dis[x]+e[i].c;
				if(!vis[y]){vis[y]=1;q.push(y);}
			}
		}
	}
	return dis[T]<inf;
}
int dfs(int x,int f)
{
	if(x==T||!f)return f;
	int sf=0;vis[x]=1;
	for(int &i=iter[x];i;i=e[i].nxt)
	{
		int y=e[i].v;if(vis[y]||dis[y]!=dis[x]+e[i].c)continue;
		int w=dfs(y,min(f,e[i].w));
		if(w){e[i].w-=w;e[i^1].w+=w;sf+=w;f-=w;ans+=1ll*w*e[i].c;}
		if(!f)break;
	}
	vis[x]=0;return sf;
}
int main()
{
	scanf("%d",&n);tt=2*n+6;S=tt-1;T=tt;int t1=2*n+1,t2=t1+1,t3=t2+1,t4=t3+1;cc=1;
	for(int i=1,x,y,w;i<=n;i++){scanf("%d%d%d",&x,&y,&w);add(S,i,w,0);add(i,t1,w,x+y);add(i,t2,w,x-y);add(i,t3,w,-x+y);add(i,t4,w,-x-y);}
	for(int i=1,x,y,w;i<=n;i++){int t=n+i;scanf("%d%d%d",&x,&y,&w);add(t,T,w,0);add(t1,t,w,-x-y);add(t2,t,w,-x+y);add(t3,t,w,x-y);add(t4,t,w,x+y);}
	ans=0;while(spfa())dfs(S,1e7);printf("%lld\n",-ans);return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
int main(){
    int n,i,j,cards[4][13]={}; // 絵柄のランクとカードの番号を記憶
    char m[4] = {'S','H','C','D'};
    int num;
    char mark;
    scanf("%d", &n);
    for(i = 0;i < n; i++){
        scanf(" %c %d", &mark, &num);
        if(mark == 'S') cards[0][num-1] = 1;
        else if(mark == 'H') cards[1][num-1] = 1;
        else if(mark == 'C') cards[2][num-1] = 1;
        else if(mark == 'D') cards[3][num-1] = 1;
    }
    for(i = 0;i < 4;i++){
        for(j = 0;j<13; j++){
            if(cards[i][j] == 0) printf("%c %d\n",m[i], j + 1);
        }
    }
    return 0;
}



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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0; i<n; i++){
        cin>>a.at(i);
    }
    bool check= true;
    for(int i=0; i<n; i++){
        if(a.at(i)%2==0){
            if(a.at(i)%3!=0 and a.at(i)%5!=0) check=false;
        }
    }
    if(check) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}

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

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

bool check_seats(vector<ll> &v, ll idx, string s) {
    if (s == "Male") {
        v[idx] = 1;
        return false;
    } else if (s == "Female") {
        v[idx] = -1;
        return false;
    }

    return true;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> seats(N);

    string ans;
    cout << 0 << endl;
    cin >> ans;

    if (check_seats(seats, 0, ans)) return 0;

    cout << N - 1 << endl;
    cin >> ans;
    if (check_seats(seats, N - 1, ans)) return 0;

    bool is_end = false;
    ll l = 0, r = N - 1;
    ll mid;
    while (!is_end) {
        mid = (l + r) / 2;
        cout << mid << endl;
        cin >> ans;
        is_end = check_seats(seats, mid, ans);
        if ((mid - l) % 2 == 1 && seats[l] * seats[mid] > 0 ||
            (mid - l) % 2 == 0 && seats[l] * seats[mid] < 0) {
            r = mid;
        } else
            l = mid;
    }
    return 0;
}


Measured memory_bytes: 4016
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define double long double
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
int ans;
    for(int i=1;i<=5;i++)
    {
        int x;
        cin>>x;
        if(x==0)ans=i;
    }
    cout<<ans<<endl;
}


return 0;
}





Measured memory_bytes: 3612
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] az = new int[n];
    int[] bz = new int[n];
    for(int i = 0; i < n; i++) {
      int p = sc.nextInt() - 1;
      az[p] += i;
      bz[0] += i;
      if(p < n - 1) bz[p + 1] -= i;
    }
    for(int i = 1; i < n; i++) {
      az[i] += az[i - 1];
      bz[i] += bz[i - 1]; 
    }
    for(int i = 0; i < n; i++) {
      System.out.print((i + 1) + az[i]);
      if(i < n - 1) System.out.print(" ");
    }
    System.out.println();
    for(int i = 0; i < n; i++) {
      System.out.print((n - i) + bz[i]);
      if(i < n - 1) System.out.print(" ");
    }
    System.out.println();
  }
}

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

typedef long long ll;
typedef unsigned long long ull;

#define int long long
#define endl "\n"
#define all(x) x.begin(), x.end()
#define deb(x) cout << #x << " --> " << (x) << endl
#define pb push_back
#define mod 1000000007  // 1e9 + 7
#define prec(x, y) fixed << setprecision(y) << x
#define print(v)                       \
    for (auto x : v) cout << x << " "; \
    cout << endl

int s(int i, int n, int k, int *h, int *dp) {
    if (i == n) return 0;
    int ans = INT_MAX;
    if (dp[i] != -1) {
        return dp[i];
    }
    for (int jump = 1; jump <= k; ++jump) {
        if (i + jump <= n) ans = min(ans, abs(h[i + jump] - h[i]) + s(i + jump, n, k, h, dp));
    }
    return dp[i] = ans;
}

void solve() {
    int i, j, n, k;
    cin >> n >> k;
    int h[n + 1], dp[n + 1];
    for (int i = 1; i <= n; ++i) cin >> h[i];
    memset(dp, -1, sizeof(dp));
    cout << s(1, n, k, h, dp) << endl;
}

//Fuck Ratings
//Once a Charas always a Charas

int32_t main() {
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int _t = 1;

    // cin >> _t;
    while (_t--)
        solve();
}

Measured memory_bytes: 14508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		string str = cin.next();
		Console.WriteLine(str.Substring(0,4) + " " + str.Substring(4));
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 2776
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace ABC099C_StrangeBank
{
	// DP, メモ探索, BFS など、様々な解法で実装
	// https://atcoder.jp/contests/abc099/tasks/abc099_c
	// https://qiita.com/drken/items/ace3142967c4f01d42e9#%E8%A7%A3%E6%B3%95-1-1-%E3%83%88%E3%83%83%E3%83%97%E3%83%80%E3%82%A6%E3%83%B3%E3%81%AB-n-%E3%82%92%E9%99%8D%E4%B8%8B%E3%81%97%E3%81%A6%E3%81%84%E3%81%8F%E3%83%A1%E3%83%A2%E5%8C%96%E5%86%8D%E5%B8%B0
	public class Solver
	{
		virtual protected string ReadLine() => Console.ReadLine();
		virtual protected int ReadInt() => int.Parse(ReadLine());
		virtual protected long ReadLong() => long.Parse(ReadLine());
		virtual protected string[] ReadStringArray() => ReadLine().Split(' ');
		virtual protected int[] ReadIntArray() => ReadLine().Split(' ').Select<string, int>(s => int.Parse(s)).ToArray();
		virtual protected long[] ReadLongArray() => ReadLine().Split(' ').Select<string, long>(s => long.Parse(s)).ToArray();
		virtual protected void WriteLine(string line) => Console.WriteLine(line);
		virtual protected void WriteLine<T>(T value) where T : IFormattable => Console.WriteLine(value);

		[Conditional("DEBUG")]
		void Dump<T>(IEnumerable<T> array) {
			var sb = new StringBuilder();
			foreach (var item in array) {
				sb.Append(item);
				sb.Append(", ");
			}
			// Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。
			Console.WriteLine(sb.ToString());
			//_writer.WriteLine(sb.ToString());
		}

		int N;
		int UpperW;

		readonly int[] Sixes = { 1, 6, 36, 216, 1296, 7776, 46656 };
		readonly int[] Nines = { 1, 9, 81, 729, 6561, 59049 };
		readonly int[] Items = { 1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049 };

		public void Run() {
			UpperW = ReadInt();
			N = Items.Length;

			// 個数制限なしナップサックDPで解く
			var ans = DpSolve();
			// メモ探索で解く
			//var ans = MemoizeRecursive();
			// 全探索で解く
			//var ans = SearchAll(0, UpperW);
			WriteLine(ans);
		}

		// 個数制限なしナップサックDP
		int DpSolve() {
			int[,] DP = new int[N + 1, UpperW + 1];
			for (int i = 0; i < N + 1; i++) {
				for (int j = 0; j < UpperW + 1; j++) {
					DP[i, j] = 1 << 29;	// INF
				}
			}
			// 左端は全部0に
			for (int i = 0; i < N + 1; i++) {
				DP[i, 0] = 0;
			}

			for (int i = 0; i < N; i++) {
				for (int w = 0; w < UpperW + 1; w++) {
					if (w < Items[i]) {
						// 現在の重さより左側は現在のアイテム（金額）を使えないので
						// 上から下ろす or 既に有る値
						DP[i + 1, w] = Math.Min(DP[i, w], DP[i + 1, w]);
					} else {
						// 現在の重さ以上の部分（右側）は
						// 重さ分左のvalue + 現在value or 下ろすだけ
						DP[i + 1, w] = Math.Min(DP[i + 1, w - Items[i]] + 1, DP[i, w]);
						//引き出し金額が 1円, 6円, 9円 の順にDPした場合の例
						//※空欄はINF
						//  w->0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18...
						//0    0                                             ...
						//1    0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18...
						//6    0 1 2 3 4 5 1 2 3 4  5  6  2  3  4  5  6  7  3...
						//9    0 1 2 3 4 5 1 2 3 1  2  3  2  3  4  2  3  4  2...
					}
				}
			}

			return DP[N, UpperW];
		}

#if !MYHOME
		public static void Main(string[] args) {
			new Solver().Run();
		}
#endif
	}
}


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

int N;
std::vector<int> v(101);

int main()
{
    cin>>N;
    bool flag=true;
    for (int i=0; i<N; i++) {
        cin>>v.at(i);
        if (v.at(i)%2==0){
            if (v.at(i)%3==0 || v.at(i)%5==0) flag=true;
            else {
                flag=false;
                break;
            }
        }
    }
    if (flag) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
    return 0;
}


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

int main(){
   int x1,y1,x2,y2;
   cin >> x1 >> y1 >> x2 >> y2;
   // ベクトルを90度回転させる、
   int x = x2 - x1;
   int y = y2 - y1;
   int turnedx = -1 * y;
   int turnedy = x;
   cout << x2 + turnedx << " " << y2 + turnedy << " " << x1 + turnedx << " " << y1 + turnedy << endl;
}

Measured memory_bytes: 256
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end


# 入力値を文字列で返却する
def gets_s()
  gets.chomp
end

N, M = gets_i_list
S = gets_s
T = gets_s

lcm =  N.lcm(M)

n_index = N.times.map do |i|
  i * (lcm/N) + 1
end

m_index = M.times.map do |i|
  i * (lcm/M) + 1
end

list = n_index & m_index

list.each do |i|
  if S[n_index.index(i)] != T[m_index.index(i)]
    puts -1
    exit
  end
end
puts lcm

Measured memory_bytes: 9596
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main ()
{
	int x[20000],y[20000];
	int X,Y;
	int W,H,N;
	cin>>W>>H>>N;
	int count=0;
	
	for(int i=0;i<N;i++)
	{
		cin>>x[i]>>y[i];
	}
	X=x[0];Y=y[0];
	for(int i=1;i<N;i++)
	{
		
		while(1){
			if(X==x[i]&&Y==y[i])break;
			if(X<x[i]&&Y<y[i]){
				X+=1;Y+=1;
				count++;
			}else if(X>x[i]&&Y>y[i]){
				X-=1;Y-=1;
				count++;
			}else if(X<x[i]){
				X++;
				count++;
			}else if(Y<y[i]){
				Y++;
				count++;
			}else if(X>x[i]){
				X--;
				count++;
			}else if(Y>y[i]){
				Y--;
				count++;
			}
		}
	}
	cout<<count<<endl;
	
	
	
return 0;
}

Measured memory_bytes: 1180
#include<cstdio>
using namespace std;
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=1000;i++)
	{
		if(n*i%m==k)
		{
			printf("YES");
			return 0;
		}
	}
	printf("NO");
	return 0;
}

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

int main() {
	int K, A, B;
	cin >> K >> A >> B;

	for (int i = A; i <= B; i++) {
		int num = i % K;
		if (num == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";

}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(void)
{
    int H1, M1;
    int H2, M2;
    int K;

    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int h_diff = H2 - (H1+1);
    int m_diff = (60 - M1) + M2;

    int total_minute = h_diff * 60 + m_diff;
    int study_able_time = total_minute - K;

    cout << study_able_time << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


vector<int> Zalgo(const string& S){
    int N=(int)S.size();
    vector<int> res(N);
    res[0]=N;
    int i=1, j=0;
    while(i<N){
        while(i+j<N && S[j]==S[j+i]) ++j;
        res[i]=j;
        if(j==0) {++i; continue;}
        int k=1;
        while(i+k<N && k+res[k]<j) res[i+k]=res[k], ++k;
        i += k, j -= k;
    }
    return res;
}

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

    int n; cin >> n;
    string s; cin >> s;
    int ans=0;

    rep(i, n-1){
        string T=s.substr(i);
        vector<int> lcp=Zalgo(T);
        rep(j, (int)T.size()) chmax(ans, min(lcp[j], j));
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
#define cons 1000000007 
using namespace std;


signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    
    int a, b;
    cin>>a>>b;
    if((a+b)%2==0)
        cout<<(a+b)/2<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;

}




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

namespace AtCoder
{
    class Abc166B
    {
        public static void Main()
        {
            var nk = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var n = nk[0];
            var k = nk[1];

            var sunuke = new bool[n];

            for (int i = 0; i < k; i++)
            {
                var d = int.Parse(Console.ReadLine());
                var a = Console.ReadLine().Split(' ').Select(j => int.Parse(j) - 1).ToArray();
                for (int j = 0; j < a.Length; j++)
                    sunuke[a[j]] = true;
            }
            Console.WriteLine(sunuke.Count(i => !i));
        }
    }
}


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

int main(void)
{
   char a[11],b[11],c[11];

   scanf("%s%s%s",a,b,c);
   if ((a[strlen(a)-1]==b[0])&&(b[strlen(b)-1]==c[0]))
   printf("YES\n");
   else printf("NO\n");
   return 0;
}


Measured memory_bytes: 128