akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[100005],b[100005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n+1;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&b[i]);
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		a[i]=max(0LL,a[i]);
		if(b[i]>=a[i]){
			ans+=a[i];
			b[i]-=a[i];
			a[i]=0;
		}else{
			ans+=b[i];
			a[i]-=b[i];
			b[i]=0;
		}
		ans+=min(b[i],a[i+1]);
		a[i+1]-=b[i];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
/* 
 * Project: AtCoder Beginners Contest 170 C - Forbidden List
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/14
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int x;
int n;
int p[100];

bool check_num(int num) {
    for (int i=0;i<n;i++) {
        if (p[i] == num) {
            return true;
        }
    }
    return false;
}

void solve() {

    int max = *max_element(p, p+n);
    if (x > max) {
        max = x;
    }
    int diff = 100;
    int min = 0;
    for (int i=0;i<=max+1;i++) {
        if (check_num(i))
            ;
        else {
            if (diff > abs(i-x)) {
                diff = abs(i-x);
                min = i;
            }
        }
    }

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

}

int main() {

    scanf("%d", &x);
    scanf("%d", &n);
    if (n == 0) {
        printf("%d\n",x);
        return 0;
    }
    for (int i=0;i<n;i++) {
        scanf("%d", &p[i]);
    }

    solve();
}

Measured memory_bytes: 3240
import math
import sys
def risoku(k):
  return(k+k//100)
x=int(input())
min=math.floor(math.log(x//100,1.01))
k=100
for i in range(min):
  k=risoku(k)
for i in range(min,3761):
  k=risoku(k)
  if (k>=x):
    print(i+1)
    sys.exit()

Measured memory_bytes: 9316
_ = input()
data = list(map(int, input().split()))

result = []
pos = min(len(data), max(data)) - 1

while pos >= 0:
    if data[pos] == pos + 1:
        x = data.pop(pos)
        #print('remove {0} {1}'.format(x, data))
        result.append(x)
        if len(data) == 0:
            break
        pos = min(len(data), max(data)) - 1
    else:
        pos -= 1

if len(data) == 0:
    result.reverse()
    for res in result:
        print(res)
else:
    print(-1)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	char a[7];
	for(int i=1;i<=6;i++){
		cin>>a[i];
	}
	if(a[1]==a[6]&&a[2]==a[5]&&a[3]==a[4]) printf("YES");
	else printf("NO");
	return 0;
}

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

const int INF = 1e9 + 1;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int N; cin >> N;
    vector<int> a( N );
    REP( i, N ) cin >> a[i];

    int cnt = 0, cur = 1;
    REP( i, N ){
        if( cur == a[i] ) cur++;
        else cnt++;
    }
    if( cnt == N ) cout << -1 << endl;
    else cout << cnt << endl;
}

/*

*/

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_set>

using namespace std;

int main()	{
  long long n = 0;
  cin >> n;
  char x = 'A';
  long long count = 0;
  long long val = 0;
  unordered_set<string> colors;
  for (int i = 0; i < n; i++)	{
    cin >> val;
    if (val >= 1 && val <= 399)
      colors.insert("grey");
    else if (val >= 400 && val <= 799)
      colors.insert("brown");
    else if (val >= 800 && val <= 1199)
      colors.insert("green");
    else if (val >= 1200 && val <= 1599)
      colors.insert("cyan");
    else if (val >= 1600 && val <= 1999)
      colors.insert("blue");
    else if (val >= 2000 && val <= 2399)
      colors.insert("yellow");
    else if (val >= 2400 && val <= 2799)
      colors.insert("orange");
    else if (val >= 2800 && val <= 3199)
      colors.insert("red");
    else
      count++;
  }
  if (colors.size() > 0)
    cout << colors.size() << " " << colors.size() + count << endl;
  else if (count > 0)
    cout << 1 << " " << count << endl;
  else
    cout << 0 << " " << 0 << endl;
  return 0;
}

Measured memory_bytes: 3616
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int main()
{

    string x;
    cin >> x ;
    for (int i =0 ; i < SZ(x) ;i++)
        cout <<"x";

}


Measured memory_bytes: 256
/*input
4 1111
1 10 100 1000
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
int a[maxn];
int main()
{
	int n,x;
	cin>>n>>x;
	ll ans=0;
	REP(i,n) cin>>a[i];
	sort(a,a+n);
	REP(i,n-1){
		if(x>=a[i]){
			x-=a[i];
			ans++;
		}
	}
	if(x==a[n-1]) ans++;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(void) {
	int a,b;
	scanf("%d %d",&a,&b);
	if (a < b) {
		for (int x = 0; x < b; x++)	printf("%d", a);
	}
	else {
		for (int x = 0; x < a; x++)	printf("%d", b);
	}
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!
N = int(input())
S = input()
open_cnt = 0
cnt = 0
open_flg = True
for i in range(N):
    if S[i] == '(':
        if not open_flg:
            if cnt < 0:
                cnt = 0
        cnt += 1
    else:
        open_flg = False
        cnt -= 1
        if cnt < 0:
            open_cnt += 1
cnt = 0
close_flg = True
close_cnt = 0
for i in range(N-1, -1, -1):
    if S[i] == ')':
        if not close_flg:
            if cnt < 0:
                cnt = 0
        cnt += 1
    else:
        close_flg = False
        cnt -= 1
        if cnt < 0:
            close_cnt += 1
print('(' * open_cnt + S + ')' * close_cnt)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#define inf 0x3f3f3f3f
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
int n;
int mins=inf;
int mid;
long long ans=0;
struct edge{
	int to;
	int wi;
	int ne;
}e[200060];
int h[100001],cnt=0;
void add(int a,int b,int c) {
	e[++cnt]=(edge){b,c,h[a]};
	h[a]=cnt;
	return ;
}

int dfs_time=0;
int in[100050],out[100050],son[100050],zhong[100050];
void dfs(int x,int fa,int w){
	in[x]=++dfs_time;
	int maxi=0;
	for(int i=h[x];i;i=e[i].ne) {
		int v=e[i].to;
		if(v==fa) continue;
		dfs(v,x,e[i].wi);
		son[x]+=son[v]+1;
		maxi=max(maxi,son[v]+1);
	}
	out[x]=dfs_time;
	int mini=min(out[x]-in[x]+1,n-out[x]+in[x]-1);
	ans+=(long long) mini*w*2;
	maxi=max(maxi,n-1-son[x]);
	zhong[x]=maxi;
	if(maxi<mins){
		mins=maxi;
		mid=x;
	}
	return ;
}

int main(){
	int a,b,c;
	scanf("%d",&n);
	for(int i=1;i<n;++i) {
		scanf("%d%d%d",&a,&b,&c);
		add(a,b,c);
		add(b,a,c);
	}
	dfs(1,0,0);
	int lowe=0x3f3f3f3f;
	for(int i=h[mid];i;i=e[i].ne){
		int v=e[i].to;
		lowe=min(lowe,e[i].wi);
		if(zhong[v]==zhong[mid]){
			ans-=e[i].wi;
			printf("%lld\n",ans);
			return 0;
		}
	}
	printf("%lld\n",ans-lowe);
	return 0;
}

Measured memory_bytes: 11264
#include<iostream>
using namespace std;
int main() {
	float x, a, b, c, d;
	cin >> x >> a >> b;
	c = a - x;
	d = b - x;
	if (c < 0) {
		c *= -1;
	}
	if (d < 0) {
		d *= -1;
	}
	if (c > d) {
		cout << 'B' << endl;
	}else{
		cout << 'A' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;


//ABC160_C
int main() {
	int k, n;
	cin >> k >> n;
	int A[200100];
	for (int i=0; i<n; i++) {
		cin >> A[i];
	}
	int B[n-1];
	for (int i=0; i<n-1; i++) {
		B[i] = A[i+1] - A[i];
	}
	B[n-1] = k - A[n-1] + A[0];
	sort(B, B+n);
	int ans = accumulate(B, B+n-1, 0);

	cout << ans << endl;
}

Measured memory_bytes: 1792
x = input()
x = int(x)
y1 = x // 11 * 2
p = x % 11
y2 = 0
if p > 0:
  y2 = 1
if p > 6:
  y2 = 2
# print("y1,y2,y=",y1,y2,y1+y2)
print(y1+y2)

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  string ans = s;
  for (int i = 0; i < s.length(); i++) {
    s[i] = s[i] + n;
    if ('[' <= s[i]) {
      s[i] += 6;
    }
  }
  transform(s.cbegin(), s.cend(), s.begin(), ::toupper);
  cout << s << endl;
  return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,k,a,memo[40],km[40],cnt[40],ks,ans;
pair<int,int> mm[40];

signed main() {
    int hoge=1;
    rep(i,40) memo[i] = hoge,hoge*=2;
    cin >> n;
    rep(i,n+1) {
        string tmp;
        cin >> a;
        if (!i) a++;
        while(a) {
            tmp.pb(a%2+'0');
            a/=2;
        }
        if (i) {rep(j,tmp.size()) if (tmp[j]-'0') cnt[j]++;}
        else {rep(j,tmp.size()) km[j] = tmp[j]-'0';ks = tmp.size();}
    }
    rep(i,40) mm[i] = mp(cnt[i]*memo[i], (n-cnt[i])*memo[i]);
    rep(i,ks) {
        if (!km[i]) continue;
        int tmpans=0;
        rep(j,40) if (i^j) {
            if (km[j] || i > j) tmpans += max(mm[j].fi, mm[j].se);
            else tmpans += mm[j].fi;
        }
        tmpans += mm[i].fi;
        ans = max(ans,tmpans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;
	scanf("%d",&a);
	scanf("%d", &b);

	if ((a >= -1000) && (b <= 1000))
	{


		if (a > b)
		{
			printf("a > b\n");
		}

		if (a == b)
		{
			printf("a == b\n");
		}

		if (a < b)
		{
			printf("a < b\n");
		}
	}
	return 0;

}


Measured memory_bytes: 2624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BResistorsInParallel solver = new BResistorsInParallel();
        solver.solve(1, in, out);
        out.close();
    }

    static class BResistorsInParallel {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            double ans = 0;
            for (int i = 0; i < n; i++) {
                ans += (double) 1 / in.nextInt();
            }
            out.println(1 / ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



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

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<int> cnt;
  if (S[0] == '0') cnt.push_back(0);
  int k = 1;
  rep(i, N) {
    if (i == 0) continue;
    if (S[i] == S[i-1]) {
      k++;
    }
    else {
      cnt.push_back(k);
      k = 1;
    }
  }
  cnt.push_back(k);
  if (S.back() == '0') cnt.push_back(0);
  int s = cnt.size();
  
  vector<int> cumsum(s);
  rep(i, s) {
    if (i == 0) cumsum[i] = cnt[i];
    else cumsum[i] = cumsum[i-1] + cnt[i];
  }
  int ans = cumsum[0];
  for (int i = 0; i <= 2*K; i += 2) {
    if (i >= s) continue;
    ans = max(ans, cumsum[i]);
  }
  for (int i = 1; i < s; i += 2) {
    if (i + 2*K + 1 < s) {
      ans = max(ans, cumsum[i + 2*K + 1] - cumsum[i]);
    }
    else {
      ans = max(ans, cumsum[s-1] - cumsum[i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    double L;
    cin >> L;

    double x = L / 3;

    print(x * x * x);
    return 0;
}

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

#define I inline void 

using ll = long long ; 
using ld = long double ; 

using namespace std ; 

const int N = 500 + 7 , mod = 1e9 + 7 ; 

int n; 

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

	//freopen("in.in" , "r" , stdin) ;  


	string s ; 
	cin >> s; 
	int ans = 0 , k = 0 ; 
	for(int i = 0 ; i< 3 ;i++){
		if(s[i] == 'R')
			k++ ; 
		else{
			ans = max(ans , k) ;
			k = 0 ;  
		}
	}	
	cout<< max(ans , k) ;

	return 0 ; 
}

Measured memory_bytes: 3648
import sys


def input():
    return sys.stdin.readline().rstrip()



def main():
    N = int(input())

    dp = [0] * (N + 1)
    rt = int(N ** 0.5) + 1
    for i in range(1, rt):
        ii = i ** 2
        for j in range(1, rt):
            iji = ii + j * j + i * j

            if iji + 1 + i + j > N:
                break
            for k in range(1, rt):
                kk = k ** 2
                case = int(iji + kk + i * k + j * k)
                if case <= N:
                    dp[case] += 1
                else:
                    break

    print(*dp[1:N + 1], sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 68792
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  int w,h,n;
  cin>>w>>h>>n;
  int x,y,a,xmin=0,xmax=w,ymin=0,ymax=h;
  for(int i=0;i<n;i++){
    cin>>x>>y>>a;
    if(a==1){
      xmin=max(x,xmin);
    }
    if(a==2){
      xmax=min(x,xmax);
    }
    if(a==3){
      ymin=max(y,ymin);
    }
    if(a==4){
      ymax=min(y,ymax);
    }
  }
  cout<<max(0,xmax-xmin)*max(0,ymax-ymin)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
void trace(int A[], int N){
    int i;
    for(i=0;i<N;i++){
        if(i>0){
            printf(" ");
        }
            printf("%d",A[i]);
    }
    printf("\n");
}
void insertionSort(int A[],int N){
    int i,j,v;
    for( i = 1; i < N; i++)
    {
        v = A[i];
     j = i - 1;
     while (j >= 0 && A[j] > v){
       A[j+1] = A[j];
       j--;
     }
     A[j+1] = v;
     trace(A, N);
    }
}
int main(void){
int N,i,j;
int A[100];
scanf("%d",&N);
for( i = 0; i < N; i++)
{
    scanf("%d",&A[i]);
}
trace(A,N);
insertionSort(A, N);
return 0;
}


Measured memory_bytes: 2148
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;


int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<bool>>path(h, vector<bool>(w));
	pair<int, int>start;
	bool first = true;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c;
			cin >> c;
			if (c == '#') {
				path[i][j] = false;
			}
			else {
				path[i][j] = true;
				if (first) {
					first = false;
					start.first = i;
					start.second = j;
				}
			}
		}
	}
	int dx[] = { 0,1,0,-1 };
	int dy[] = { 1,0,-1,0 };
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			vector<vector<int>>dp1(h, vector<int>(w));
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					dp1[i][j] = INF;
				}
			}
			start.first = i;
			start.second = j;
			if (!path[i][j])continue;
			dp1[start.first][start.second] = 0;
			priority_queue<pair<int, int>>todo;
			todo.push(start);
			while (todo.empty() != 1) {
				pair<int, int> tmp = todo.top();
				todo.pop();
				for (int i = 0; i < 4; i++) {
					if (tmp.first + dy[i] >= 0 && tmp.first + dy[i] < h&&tmp.second + dx[i] >= 0 && tmp.second + dx[i] < w) {
						if (path[tmp.first + dy[i]][tmp.second + dx[i]]) {
							if (dp1[tmp.first + dy[i]][tmp.second + dx[i]] > dp1[tmp.first][tmp.second] + 1) {
								dp1[tmp.first + dy[i]][tmp.second + dx[i]] = dp1[tmp.first][tmp.second] + 1;
								todo.push(pair<int, int>(tmp.first + dy[i], tmp.second + dx[i]));
							}
						}
					}
				}
			}
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (path[i][j]) {
						if (dp1[i][j] >= ans) {
							ans = dp1[i][j];
							start.first = i;
							start.second = j;
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a,b;
	scanf("%c %c",&a,&b);
	if(a=='H'&&b=='H')
	printf("H");
	else if(a=='H'&& b=='D')
	printf("D");
	else if(a=='D'&&b=='H')
	printf("D");
	else
	printf("H");
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 101
 
int main(void){
    int a[MAX][MAX], r, c, i, j;
    scanf("%d %d", &r, &c); 
    a[r][c] = 0;
    for(i = 0; i < r; i++){
        for(j = 0; j < c; j++){
            scanf("%d", &a[i][j]);
            a[r][c] += a[i][j];
        }
    }
 
    for(i = 0; i < r; i++){
            a[i][c] = 0;
        for(j = 0; j < c; j++){
            a[i][c] += a[i][j]; 
        }
    }
 
    for(j = 0; j < c; j++){
            a[r][j] = 0;
        for(i = 0; i < r; i++){
            a[r][j] += a[i][j];
        }
    }
     
    for(i = 0; i <= r; i++){
        for(j = 0; j <= c; j++){
            if(j < c){
                printf("%d ", a[i][j]);
            }
            else{
                printf("%d\n", a[i][j]);
            }
        }
    }
     
    return 0;
}
 

 

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


def solve(S: str):
    print(S.count("+") - S.count("-"))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var S = inputArray[0];
			var T = retreiveStringArray()[0];

			//まず文字数の条件を満たすか
			if(S.Length +1 != T.Length) {
				Console.WriteLine("No");
				return;
			}




			var hantei = true;
			for (int i = 0; i < S.Length; i++) {
				if(S[i] != T[i]) {
					hantei = false;
				}

			}

			//答えの出力
			var ans = hantei ? "Yes":"No";
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 25892
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	string base;
	int sum,tmp,count;
	
	
	while(getline(cin,base)){
		if(base[0]=='0')break;
		base+=' ';
		count=sum=tmp=0;
		for(int i=0;i<base.size();i++){
			if(base[i]==' '){
				if(tmp>10)tmp=10;
				if(tmp==1)count++,tmp+=10;
				sum+=tmp;
				tmp=0;
			}
			else{
				tmp*=10;
				tmp+=(base[i]-'0');
			}
		}
		
		while(sum>21 && count>0){
			sum-=10;
			count--;
		}
		if(sum>21)cout<<0<<endl;
		else cout<<sum<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1176
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

ll	n , k;
vector<int> a(1000001),f(1000001);

// 二分探索法
// index が条件を満たすかどうか
bool isOK(ll index) {
	ll  c = 0;
	for(int i=0;i<n;i++) {
		c += max(0ll , (a[i] - index / f[i]) );
		if (c>k) return false;
	}
    return true;
}
// 汎用的な二分探索のテンプレ
ll binary_search(ll m) {
    ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll right = m; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        ll mid = right + (left - right) / 2;

        if (isOK(mid)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

int main() {
	ll		b,c,d,w,h,i,j,l,m,x,y,z;
	ll		ans = 0;
	string	s;
	cin >> n >> k;
	vector<int>	aa(n),ff(n);
	for(i=0;i<n;i++) cin >> aa[i];
	for(i=0;i<n;i++) cin >> ff[i];

	sort(aa.begin(),aa.end());
	sort(ff.begin(),ff.end());
	reverse(aa.begin(),aa.end());
	for(i=0;i<n;i++) {
		a[i] = aa[i];
		f[i] = ff[i];
	}

	ans = binary_search((ll)a[0]*f[n-1]+1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12688
import numpy as np

N, M = map(int, input().split())
A = [1]*(N+1)
for _ in range(M):
    A[int(input())] = 0

step0 = 1
step1 = A[1]

ans = [step0, step1]
for i in range(2, N+1):
    now = (ans[-1] + ans[-2]) * A[i]
    ans.append(now)
print(ans[-1] % 1000000007)


Measured memory_bytes: 472388
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
ll dp[305][305][305];
vector <pii > v[305];
int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.out", "w", stdout);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,x;
		cin>>l>>r>>x;
		v[r].pb(mp(l,x));
	}
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<i;j++)
		{
			for(int k=0;k<i;k++)
			{
				dp[i][j][k]+=dp[i-1][j][k];
				dp[i][j][k]%=MOD;
				
				if(i>1)
				{
					dp[i][i-1][k]+=dp[j][i-1][k];
					dp[i][i-1][k]%=MOD;

					dp[i][j][i-1]+=dp[j][k][i-1];
					dp[i][j][i-1]%=MOD;
				}

				
				dp[j][i][k]+=dp[j][i-1][k];
				dp[j][i][k]%=MOD;
				
				if(i>1)
				{
					dp[i-1][i][k]+=dp[i-1][j][k];
					dp[i-1][i][k]%=MOD;

					dp[j][i][i-1]+=dp[k][j][i-1];
					dp[j][i][i-1]%=MOD;
				}


				dp[k][j][i]+=dp[k][j][i-1];
				dp[k][j][i]%=MOD;
				
				if(i!=1)
				{
					dp[k][i-1][i]+=dp[k][i-1][j];
					dp[k][i-1][i]%=MOD;

					dp[i-1][j][i]+=dp[i-1][k][j];
					dp[i-1][j][i]%=MOD;
				}
			}
		}
		for(int j=0;j<i;j++)
		{
			for(int k=0;k<i;k++)
			{
				bool flag=true;
				for(int x=0;x<v[i].size();x++)
				{
					int clr=1;
					if(j>=v[i][x].FF)
						clr++;
					if(k>=v[i][x].FF)
						clr++;
					if(clr!=v[i][x].SS)
					{
						flag=false;
						break;
					}
				}
				if(!flag)
				{
					//cout<<i<<endl;
					dp[i][j][k]=0;
					dp[j][i][k]=0;
					dp[j][k][i]=0;
				}
			}
		}
	}
	ll ans = 0;
    for (int x = 0; x < n; x++)
        for (int y = 0; y < n; y++)
        {
            ans = ans+ dp[n][x][y];
            ans = ans+ dp[x][n][y];
            ans = ans+ dp[x][y][n];
            ans%=MOD;
        }
    printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 219392
#include <iostream>
#include <algorithm>
using namespace std;
long long int n;
long long int dp[100001];
long long int dp2(int n2){
	if(dp[n2] > -1){
		return dp[n2];
	}
	long long int ans = n2;
	for(int i = 6;i <= n2;i *= 6){
		ans = min(ans, dp2(n2 - i) + 1);
	}
	for(int i = 9;i <= n2;i *= 9){
		ans = min(ans, dp2(n2 - i) + 1);
	}
	dp[n2] = ans;
	return ans;
}
int main(){
	cin >> n;
	for(int i = 1;i < 100001;i++){
		dp[i] = -1;
	}
	dp[0] = 0;
	cout << dp2(n) << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

long long trib(int n)
{
	if (n == 0) return (1);
	if (n == 1) return (1);
	if (n == 2) return (2);
	return (trib(n - 1) + trib(n - 2) + trib(n - 3));
}

int main(void)
{
	long long res;
	int n;

	while (scanf("%d", &n), n){
		printf("%lld\n", (trib(n) + 3649) / 3650);
	}

	return (0);
}

Measured memory_bytes: 600
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var p = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        if (a.All(x => x % 2 == 0)) Console.WriteLine(p == 0 ? Math.Pow(2, n) : 0);
        else Console.WriteLine(Math.Pow(2, n - 1));
    }
}


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

int main(){
    
    vector<ll>v(3);
    for(ll i = 0; i < 3; i++)cin >> v[i];
    ll k;
    cin >> k;
    sort(v.begin(), v.end(), greater<ll>());
    v[0] *= (1LL << k);
    cout << v[0] + v[1] + v[2] << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[10];
int main(){
	scanf( "%s", s ); int len = strlen(s);
	for( int i = 0; i <= len - 1; i++ ) if( s[i] == 'A' && s[i+1] == 'C' ){
		printf( "Yes" ); return 0;
	}
	puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

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

  int x = 0; //4の倍数の個数
  int y = 0; //奇数の個数

  REP(i, N){
    int a;
    cin >> a;
    if(a%4 == 0) x++;
    if(a%2 == 1) y++;
  }

  int z = N - x - y;

  if(z == 0 && x >= y-1){
    cout << "Yes" << endl;
    return 0;
  }
  if(z >= 1 && x >= y) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0;i<n;i++)
#define rev(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
#define f first
#define s second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int,int>>
ll n,m;
vector<ll>dp;
vector<ll>adj[100001];
vector<bool>vis;
void dfs(ll x){

    vis[x]=true;
    for(auto i:adj[x]){
        if(!vis[i]){
            dfs(i);
        }
        dp[x]=max(dp[x],1+dp[i]);
    }
}

int main()
{
    ll n,m;
    cin>>n>>m;

   
    ll x,y;
    rep(i,m)
    {
        cin>>x>>y;
        adj[x].push_back(y);
    }
    dp=vector<ll>(n+1,0);
    vis=vector<bool>(n+1,0);
    ll ans=-1;
    
    for(int i=1;i<=n;i++){
        if(!vis[i])
        dfs(i);
    }
    for(int i=1;i<=n;i++){
        ans=max(ans,dp[i]);

    }
    cout<<ans<<endl;
    

}

Measured memory_bytes: 8576
# -*- coding: utf-8 -*-

S = input()

odd = {'R', 'U', 'D'}
even = {'L', 'U', 'D'}

for (i, step) in enumerate(S):
    if i % 2:
        if step not in even:
            print("No")
            exit()
    else:
        if step not in odd:
            print("No")
            exit()

print("Yes")


Measured memory_bytes: 2940
N, K = map(int, input().split())
L = list(map(int, input().split()))

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

flag = False
for i in range(N):
    if L[i] >= K:
        flag = True
        
if flag:
    g = L[0]
    for i in range(N):
        g = gcd(g, L[i])
        
    if gcd(g, K) == g:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
    
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)

int main()
{
    string S;
    cin >> S;
    string target = "abc";
    ll length = S.length();
    repi(i,length,0){
        repi(j,target.length(),0){
            if(S.at(0) == target.at(j)){
                S.erase(S.begin());
                target.erase(target.begin()+j);
            }
        }
    }
    if(S.length() == 0){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }


int main(void){
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  int ans=0;
  rep(i,n+1)
    for(int j=0;j<=n&&n>=r*i+g*j;++j){
        if((n-(r*i+g*j))%b==0)
          ans++;
    }

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


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int D[303];
ll mo=1000000007;
int is1;
ll from[303][603];
ll to[303][603];
ll fact[303];


ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>D[i];
		if(D[i]==1) is1++;
	}
	
	fact[0]=1;
	for(i=1;i<=300;i++) fact[i]=fact[i-1]*i%mo;
	
	
	ll ret=0;
	if(is1==0) {
		ret=fact[N-1]*((mo+1)/2)%mo;
		cout<<ret<<endl;
		return;
	}
	
	from[0][0]=1;
	FOR(i,N) {
		FOR(x,302) FOR(y,602) if(from[x][y]) {
			// in cycle
			if(D[i]>1) {
				(to[x+1][y+D[i]-2] += (D[i]-1)*from[x][y])%=mo;
			}
			(to[x][y] += from[x][y])%=mo;
		}
		swap(from,to);
		ZERO(to);
	}
	
	for(x=3;x<=N;x++) FOR(y,602) if(from[x][y]) {
		ret+=y*fact[x-1]%mo*from[x][y]%mo*fact[N-x-1]%mo;
	}
	ll Q=2;
	FOR(i,N) Q=Q*fact[D[i]-1]%mo;
	
	cout<<ret%mo*modpow(Q)%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;
const int N = 4e4 + 4;
int n;
int a[N] , b[N] , c[N];
int p[N];
int rnk[N];
int rnc[N];
pair < double , int > arr[N];
int bit[N];
void update(int idx){
	while(idx <= n){
		++bit[idx];
		idx += idx & -idx;
	}
}
int query(int idx){
	int res = 0;
	while(idx){
		res += bit[idx];
		idx -= idx & -idx;
	}
	return res;
}
bool get(){
	memset(bit , 0 , sizeof(bit));
	int res = 0;
	for(int i = 1 ; i <= n ; ++i){
		res += query(arr[i].second - 1);
		update(arr[i].second);	
	}
	int tmp = n * (n - 1);
	tmp >>= 1;
	return res >= (tmp + 1 >> 1);
}
bool checkx(double x){
	for(int i = 1 ; i <= n ; ++i){
		arr[i].first = c[i] - a[i] * x;
		arr[i].first /= b[i];
		arr[i].second = rnk[i];
	}
	sort(arr + 1 , arr + 1 + n);
	return get();
}
double solvex(){
	double l = -1e9;
	double r = +1e9;
	for(int i = 0 ; i < 100 ; ++i){
		double mid = (l + r) / 2;
		if(checkx(mid)){
			r = mid;
		}
		else{
			l = mid;
		}
	}
	return (l + r) / 2;
}
bool checky(double y){
	for(int i = 1 ; i <= n ; ++i){
		arr[i].first = c[i] - b[i] * y;
		arr[i].first /= a[i];
		arr[i].second = n - rnc[i] + 1;
	}
	sort(arr + 1 , arr + 1 + n);
	return get();
}
double solvey(){
	double l = -1e9;
	double r = +1e9;
	for(int i = 0 ; i < 100 ; ++i){
		double mid = (l + r) / 2;
		if(checky(mid)){
			r = mid;
		}
		else{
			l = mid;
		}
	}
	return (l + r) / 2;
}
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d %d %d" , a + i , b + i , c + i);
		p[i] = i;
	}
	sort(p + 1 , p + 1 + n , [](int x , int y){
		int a1 = -a[x];
		int b1 = b[x];
		int a2 = -a[y];
		int b2 = b[y];
		if(b1 < 0){
			b1 = -b1;
			a1 = -a1;
		}
		if(b2 < 0){
			b2 = -b2;
			a2 = -a2;
		}
		return a1 * b2 < a2 * b1;
	});
	for(int i = 1 ; i <= n ; ++i){
		rnk[p[i]] = i;
	}
	sort(p + 1 , p + 1 + n , [](int x , int y){
		int a1 = b[x];
		int b1 = a[x];
		int a2 = b[y];
		int b2 = a[y];
		if(b1 < 0){
			b1 = -b1;
			a1 = -a1;
		}
		if(b2 < 0){
			b2 = -b2;
			a2 = -a2;
		}
		return a1 * b2 < a2 * b1;
	});
	for(int i = 1 ; i <= n ; ++i){
		rnc[p[i]] = i;
	}
	printf("%.9lf %.9lf\n" , solvex() , solvey());
}

Measured memory_bytes: 1920
n, k = gets.split.map(&:to_i)
nums = {}
n.times do
  a, b = gets.split.map(&:to_i)
  if nums[a].nil?
    nums[a] = b
  else
    nums[a] += b
  end
end
nums = nums.sort_by { |key, value| key }
current = 0
nums.each do |key, value|
  current += value
  if current >= k
    puts key
    break
  end
end


Measured memory_bytes: 10488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    ll n;
    cin >> n;

    double l = log2(n);
    if (l - floor(l) == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;

        printf("%lld %lld\n", 1LL, 2LL);
        printf("%lld %lld\n", 2LL, 3LL);
        printf("%lld %lld\n", 3LL, 1 + n);
        printf("%lld %lld\n", 1 + n, 2 + n);
        printf("%lld %lld\n", 2 + n, 3 + n);

        for (ll i = 4; i < n; i += 2)
        {
            printf("%lld %lld\n", i, i + 1);
            printf("%lld %lld\n", i + 1, 1LL);
            printf("%lld %lld\n", 1LL, i + n);
            printf("%lld %lld\n", i + n, i + 1 + n);
        }

        if (n % 2 == 0)
        {
            ll x, y;
            for (ll i = 2; i < n; i++)
            {
                x = i;
                y = (n + 1) ^ i;
                if (1 < y && y < n)
                {
                    break;
                }
            }

            if (x % 2 == 0)
            {
                x += n;
            }
            if (y % 2 == 0)
            {
                y += n;
            }

            printf("%lld %lld\n", x, n);
            printf("%lld %lld\n", y, n + n);
        }
    }

    return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<vector>

int main(){
    int N, M;
    //int count=0;
    std::cin >> N >> M;
    std::vector<int> H(N);
    std::vector<bool> result(N);
    std::fill(result.begin(), result.end(), true);
    for(int i=0;i<N;i++){
        std::cin >> H[i];
    }
    for(int j=0; j<M; j++){
        int tmp1, tmp2;
        std::cin >> tmp1 >> tmp2;
        tmp1--; tmp2--;
        if(H[tmp1]>=H[tmp2]) result[tmp2] = false;
        if(H[tmp1]<=H[tmp2]) result[tmp1] = false;
    }
    int count=0;
    for(int i=0; i<N; i++){
        if(result[i]) count++;
    }
    std::cout << count << "\n";
    return 0;
}

Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
#define vec vector<int>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return -123;
	}
}

int main(){
  vec A(4);
  string w;
  cin>>w;
  for(int i=0;i<4;i++){
    A[i]=ctoi(w[i]);
  }
  for(int s=0;s<(1<<4);++s){
    int ret=A[0];
    for(int i=0;i<3;i++){
      if(s&(1<<i)){
        ret+=A[i+1];
      }
      else{
        ret-=A[i+1];
      }
    }
    if(ret==7){
      cout<<A[0];
      for(int i=0;i<3;i++){
        if(s&(1<<i)){
          cout<<"+"<<A[i+1];
        }
        else{
          cout<<"-"<<A[i+1];
        }
      }
      cout<<"="<<7<<endl;
      exit(0);
    }
  }
}


Measured memory_bytes: 256
// Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define rep(i, N) for(int i=0; i<(int)N; i++)
#define rrep(i, N) for(int i=(int)N-1; i>=0; i--)

// Type
template <typename T> using P = pair<T, T>;
using ll = long long;
using ull = unsigned long long;

// Constants
const ll INF = 1e18;
const ll MOD = 1000000007;

int main() {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;

  ll A[X];
  ll B[Y];
  ll C[Z];
  rep(i, X) cin >> A[i];
  rep(i, Y) cin >> B[i];
  rep(i, Z) cin >> C[i];

  sort(A, A+X, greater<ll>());
  sort(B, B+Y, greater<ll>());
  sort(C, C+Z, greater<ll>());

  vector<ll> x;
  rep(i, X) {
    rep(j, Y) {
      rep(k, Z) {
        if((i + 1)*(j + 1)*(k + 1) <= K) x.push_back(A[i] + B[j] + C[k]);
        else break;
      }
    }
  }

  sort(x.begin(), x.end(), greater<ll>());
  rep(i, K) cout << x[i] << endl;

  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define vec_push(to,from) copy(all(to),back_inserter(from))
#define vec(x) vector<x>
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define MOD = 1000000007; 
#define DEBUG true

int main(){
    ll num[50],k;
    cin >> k;
    ll t = k / 50;
    for(int i = 0;i < 50;i ++) num[i] = k / 50;
    k %= 50;
    rep(i,50){
      if(i != (50 - k)) num[i] += i;
      else num[i] += 50; 
    }
    cout << "50" << endl;
    rep(i,49) cout << num[i] << " ";
    cout << num[49] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d[] = new int[n];
		for (int i = 0; i < d.length; i++) {
			d[i] = sc.nextInt();
		}
		Set<String> set = new HashSet<String>();
		for (int i = 0; i < d.length; i++) {
			String val = Integer.toString(d[i]);
			set.add(val);
			for (int j = i + 1; j < Math.min(d.length, i + 10); j++) {
				val += d[j];
				set.add(val);
			}
		}
		for (long i = 0; i < Long.MAX_VALUE; i++) {
			if (!set.contains(Long.toString(i))) {
				System.out.println(i);
				break;
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 33152
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll mod = 1000000007;
const ll Mod = 998244353;
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p = mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m;
int d[100];
signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> d[i];
	}
	for (int i = n;; i++) {
		string s = to_string(i);
		for (int j = 0; j < s.size(); j++) {
			for (int z = 0; z < m; z++) {
				if ((int)(s[j] - '0') == d[z]) goto loop;
			}
		}
		cout << i << endl;
		return 0;
	loop:;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



void solve(){
    int n;
    set<int> s;
    cin>>n;
    f(i,n){
        int k;
        cin>>k;
        s.insert(k);
    }
    if(s.size() == n)cout<<"YES";
    else cout<<"NO";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;//*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
	while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
vector<int> v;
void solve(ll n){
	if(n==1){
//		cout << v.size() << endl;
		return;
	}
	else if(n&1){
		solve(n-1);
		v.insert(v.begin(),v.size()+1);
//		debug(v[0]),debug(v.size());
	}else {
		solve(n/2);
		v.pb(v.size()+1);
	}
	
}
int main(){
#ifdef flukehn
	freopen("test.txt","r",stdin);
#endif
	ll n;
	cin>>n;
	solve(n+1);
	int tmp=v.size();
	printf("%d\n",tmp*2);
	for(auto u:v)printf("%d ",u);
	rep(i,1,tmp)printf("%d%c",i," \n"[i==tmp]);
}

Measured memory_bytes: 256