akhauriyash/Code-Regression huggingface dataset:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n = i_input()
    dic = {"M":0,"A":0,"R":0,"C":0,"H":0}
    key = list(dic.keys())
    for _ in range(n):
        i = s_input()
        t = i[0]
        if t in key:
            dic[t] = dic.get(t) + 1
    ans = 0
    check = False
    l = list(dic.values())
    l = list(itertools.combinations(l, 3))
    for i in l:
        a = i[0]
        b = i[1]
        c = i[2]
        if a != 0 and b != 0 and c != 0:
            ans += a*b*c
            check = True
    if check:
        print(ans)
    else:
        print(0)


if __name__=="__main__":
    main()


Measured memory_bytes: 75764
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  int d,i,j,k;
  cin >> d;
  double a[1000]={},b[1000]={};
  for(i=0;i<d;i++) cin >> a[i];
  for(i=0;i<d;i++) cin >> b[i];
  double o1=0,o2=0,o3=0,oe=0;
  for(i=0;i<d;i++){
    o1+=fabs(a[i]-b[i]);
    o2+=fabs(a[i]-b[i])*fabs(a[i]-b[i]);
    o3+=fabs(a[i]-b[i])*fabs(a[i]-b[i])*fabs(a[i]-b[i]);
    oe=max(oe,fabs(a[i]-b[i]));
  }
  printf("%.6f\n",o1);
  printf("%.6f\n",sqrt(o2));
  printf("%.6f\n",pow(o3,1.0/3.0));
  printf("%.6f\n",oe);
  return 0;
}


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int H, W, N;

	public static void main(String[] arg) {
		System.out.println(solve() ? "YES" : "NO");
	}

	static boolean solve() {
		H = sc.nextInt();
		W = sc.nextInt();
		N = sc.nextInt();
		char[][] f = new char[H][W];
		char[][] cf = new char[H][W];
		for (int i = 0; i < H; ++i) {
			f[i] = sc.next().toCharArray();
		}
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W - 1; ++j) {
				for (int k = 0; k < H; ++k) {
					for (int l = 0; l < W; ++l) {
						cf[k][l] = f[k][l];
					}
				}
				char tmp = cf[i][j];
				cf[i][j] = cf[i][j + 1];
				cf[i][j + 1] = tmp;
				if (simulate(cf)) {
					return true;
				}
			}
		}
		return false;
	}

	static boolean simulate(char[][] f) {
		fall(f);
		while (true) {
			if (!erase(f)) {
				break;
			}
			fall(f);
		}
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (f[i][j] != '.') return false;
			}
		}
		return true;
	}

	static boolean erase(char[][] f) {
		boolean any = false;
		boolean[][] e = new boolean[H][W];
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j <= W - N; ++j) {
				if (f[i][j] == '.') continue;
				boolean ok = true;
				for (int k = 1; k < N; ++k) {
					if (f[i][j + k] != f[i][j]) {
						ok = false;
					}
				}
				if (ok) {
					any = true;
					for (int k = 0; k < N; ++k) {
						e[i][j + k] = true;
					}
				}
			}
		}
		for (int i = 0; i < W; ++i) {
			for (int j = 0; j <= H - N; ++j) {
				if (f[j][i] == '.') continue;
				boolean ok = true;
				for (int k = 1; k < N; ++k) {
					if (f[j + k][i] != f[j][i]) {
						ok = false;
					}
				}
				if (ok) {
					any = true;
					for (int k = 0; k < N; ++k) {
						e[j + k][i] = true;
					}
				}
			}
		}
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (e[i][j]) f[i][j] = '.';
			}
		}
		return any;
	}

	static void fall(char[][] f) {
		for (int i = 0; i < W; ++i) {
			int pos = H - 1;
			for (int j = H - 1; j >= 0; --j) {
				if (f[j][i] != '.') {
					f[pos--][i] = f[j][i];
				}
			}
			while (pos >= 0) {
				f[pos--][i] = '.';
			}
		}
	}

}

Measured memory_bytes: 27772
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

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

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int D;
  cin >> D;
  vi c(26);
  cin >> c;
  vector<vector<pair<int, int>>> s(D, vector<pair<int, int>>(26));
  rep(i, D) {
    rep(j, 26) {
      cin >> s[i][j].first;
      s[i][j].second = j;
    }
    sort(rall(s[i]));
  }

  rep(i, D) {
    out(s[i][0].second + 1);
  }
}


Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
#include<deque>
using namespace std;
#define pb push_back
#define F(i,a,b) for(int i=a;i<b;++i)
#define Fl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
const int MOD = 1000000007;
#define pie 3.141592653589793238462643383279

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

 	int t{},T{};
 	//cin>>t;T=t;
    t=1;
 	while(t--){
        //cout<<"------------- #"<<T-t<<endl;
        int n{},m{},ans{},k{},a{},b{},c{},f{1};
        string str;
        cin>>str;
        F(i,0,2){
            if(str[i]=='R'&&str[i+1]=='R'){
                ++ans;
            }
        }
        if(ans==0){
            if(count(all(str),'R')==0){
                cout<<0<<endl;
                return 0;
            }
                cout<<ans+1<<"\n";
                return 0;
                
           
        }
        cout<<ans+1<<"\n";
        
       
    }
    
    
	return 0;
}

Measured memory_bytes: 3608
n = int(input())
s = input()

a = {}
a['R'] = [0 for _ in range(n + 1)]
a['G'] = [0 for _ in range(n + 1)]
a['B'] = [0 for _ in range(n + 1)]

for i, si in enumerate(s):
    a['R'][i + 1] += a['R'][i]
    a['G'][i + 1] += a['G'][i]
    a['B'][i + 1] += a['B'][i]
    a[si][i + 1] += 1

ans = 0
for i, si in enumerate(s):
    if si == 'R':
        keys = ['G', 'B']
    elif si == 'G':
        keys = ['B', 'R']
    else:
        keys = ['R', 'G']
    x = a[keys[0]][-1] - a[keys[0]][i + 1]
    y = a[keys[1]][-1] - a[keys[1]][i + 1]
    ans += x * y
    for j in range(1, (n - i + 1) // 2):
        sj = s[i + j]
        sk = s[i + 2 * j]
        if sj != sk and sj in keys and sk in keys:
            ans -= 1
print(ans)


Measured memory_bytes: 68944
import java.util.*;
public class Main {
	static int modAns = (int)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int length[] = new int[3];
		for(int i = 0; i < 3; i ++) {
			length[i] = sc.nextInt();
		}
		int max = Math.max(length[0], Math.max(length[1], length[2]));
		System.out.println(length[0] * length[1] * length[2] / max / 2);
	}
}

Measured memory_bytes: 23764
N,M = map(int,input().split())

x = [False for i in range(N+1)]
y = [False for i in range(N+1)]

for i in range(M):
    a,b = map(int,input().split())
    a,b = min(a,b), max(a,b)
    if a == 1:
        x[b] = True
    if b == N:
        y[a] = True

ans = 'IMPOSSIBLE'
for i in range(N+1):
    if x[i] and y[i]:
        ans = 'POSSIBLE'
print(ans)



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

int main() {

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

    vector<int> P(N, 0);

    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        P.at(i) = p;
    }

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

    int sum = 0;
    for (int i = 0; i < K; i++) {
        sum += P.at(i);
    }

    cout << sum;

}

Measured memory_bytes: 3580
n = int(input())
a = list(input().split())

dic = {}

memo1 = 0
memo2 = 0
for i in range(len(a)):
    if a[i] in dic.keys():
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1

for i,j in dic.items():
    if j >= 2 and j<4:
        if memo1 < int(i):
            c = memo1
            memo1 = int(i)
            if memo2 < c:
                memo2 = c
        elif memo2 <= int(i):
            memo2 = int(i)
    
    elif j >= 4:
        if memo1 < int(i):
            memo1 = int(i)
        if memo2 < int(i):
            memo2 = int(i)


print(memo1*memo2)



Measured memory_bytes: 20876
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
char s[N];
int a[N];
void addedge(int u,int v){
	printf("%d %d\n",u,v);
}
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	for (int i=1;i<=n;i++)
	a[i]=s[i]-'0';
	if (a[1]==0||a[n]==1){printf("-1\n"); return 0;}
	for (int i=1;i<=n;i++)
	if ((a[i]^a[n-i])==1){printf("-1\n"); return 0;}
	int now=1;
	for (int i=2;i<=n;i++){
		addedge(now,i);
		if (a[i-1]==1) now=i;
	}
	return 0;
}

Measured memory_bytes: 1920
n, m, k = map(int, input().split())
a = list(map(int, ("0 " + input()).split()))
b = list(map(int, ("0 " + input()).split()))

time = 0
books = 0
a_index = 0
b_index = 0

for i in range(1, n + 1):
  if time + a[i] <= k:
    time += a[i]
    books += 1
    a_index = i
  else:
    break

for i in range(1, m + 1):
  if time + b[i] <= k:
    time += b[i]
    books += 1
    b_index = i
  else:
    break

max_books = books

for i in range(a_index, 0, -1):
  time -= a[i]
  books -= 1
  for j in range(b_index + 1, m + 1):
    if time + b[j] <= k:
      time += b[j]
      books += 1
      b_index = j
      max_books = max(max_books, books)
    else:
      break

print(max_books)

Measured memory_bytes: 42428
#include <bits/stdc++.h>
using namespace std;
bool kaibun(string x, int u, int v){
    bool r = true;
    for (int i = u; i < v + 1; i++)
    {
        if (x.at(i) != x.at(v - i)){
            r = false;
            break;
        }
    }
    return r;
}

int main(){
    string S;
    cin >> S;
    int N = S.size();
    int x = (N-1)/2,y = (N+3)/2;
    if (kaibun(S, 0,x-1) and kaibun(S,y-1,N-1) and kaibun(S,0,N-1)){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s_a, s_b, s_c; cin >> s_a >> s_b >> s_c;
    reverse(all(s_a)); reverse(all(s_b)); reverse(all(s_c));
    char step = 'a';
    while(true){
        if(step == 'a'){
            if(s_a.empty()){
                cout << 'A' << endl;
                return 0;
            }
            step = s_a[s_a.size()-1]; s_a.pop_back();
        }
        else if(step == 'b'){
            if(s_b.empty()){
                cout << 'B' << endl;
                return 0;
            }
            step = s_b[s_b.size()-1]; s_b.pop_back();
        }
        else{
            if(s_c.empty()){
                cout << 'C' << endl;
                return 0;
            }
            step = s_c[s_c.size()-1]; s_c.pop_back();
        }
    }
    return 0;
}



Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        int[] n = Read(2);
        int p=0;
        p+=n[0]>n[1]?n[0]--:n[1]--;
        p+=n[0]>n[1]?n[0]--:n[1]--;
        Write(p);
    }

    static void Write(string s) { Console.WriteLine(s); return; }
    static void Write(int n) { Console.WriteLine(n.ToString()); return; }
    static int Read() { return int.Parse(Console.ReadLine()); }
    static int[] Read(int n)
    {
        int[] p = new int[n];
        string[] t = Console.ReadLine().Split(' ');
        for(int i = 0; i < n; i++) { p[i] = int.Parse(t[i]); }
        return p;
    }
    static int abs(int n) { return (n > 0) ? n : -n; }
    static int gcd(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = gcd(p, n[i]); } return p; }
    static int gcd(int a, int b) { return (a==0)?b:gcd(b % a, a); }
    static int lcm(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = lcm(p, n[i]); } return p; }
    static int lcm(int a, int b) { return a * b / gcd(a, b); }
}


Measured memory_bytes: 11092
S = input()
T = input()
 
def match_num_character(x, y):
  count = 0
  for a, b in zip(x, y):
    if a == b:
      count += 1
      
  return count
 
length = len(T)
max_count = max([match_num_character(S[i:i+length], T) for i in range(1+len(S) - length)])
 
print(length - max_count)

Measured memory_bytes: 73092
#include<iostream>
#include<vector>
#include<algorithm>
using LL = long long;
using namespace std;

LL getmb(LL i) {
	LL t = i;
	LL n = 0;
	LL rtn = 0;
	while (t > 0) {
		if ((t & 1) == 1) {
			rtn = n;
		}
		t = t >> 1;
		n++;
	}
	return rtn;

}

LL powt(LL n) {
	LL res = 1;
	for (LL i = 0; i < n; i++) {
		res *= 2;
	}

	return res;
}

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

	LL ans = A[0];
	for (LL i = 2; i < N; i++) {
		LL left = getmb(i);
		LL diff = (i - powt(left)) / 2;
		LL k = powt(left - 1) + diff;
		ans += A[k];
	}



	cout << ans << endl;


	return 0;
}

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

int d[100], a[100], id[1000000], re[5040][7], dp[100][5040], v[7];
int h(int*v) {
	int p = 1, res = 0;
	rep(i, 7)res += v[i] * p, p *= 7;
	return res;
}
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &d[i]);
	rep(i, n)scanf("%d", &a[i]);
	iota(v, v + 7, 0);
	int p = 0;
	do {
		id[h(v)] = p; rep(i, 7)re[p][i] = v[i];
		int cnt = 0;
		bool t[7]{};
		for (int i : v) {
			rep(j, 7) {
				if (t[j] && abs(j - i) <= d[j])cnt += a[j];
			}
			t[i] = 1;
		}
		dp[0][p] = cnt;
		p++;
	} while (next_permutation(v, v + 7));
	int ans = 0;
	for (int i = 1; i + 6 < n; i++)rep(j, 5040)rep(k, 8) {
		int*t = re[j];
		int cnt = 0, o = 0;
		bool p[8]{};
		rep(l, 8) {
			if (k == l) {
				rep(y, 8) {
					if (p[y] && y + d[i - 1 + y] >= 7)
						cnt += a[i - 1 + y];
				}
				p[7] = 1; v[o++] = 6;
			}
			else {
				if (p[7] && 7 - d[i + 6] <= *t)cnt += a[i + 6];
				p[*t] = 1;
				if (*t)v[o++] = *t - 1;
				t++;
			}
		}
		int u = id[h(v)];
		dp[i][u] = max(dp[i][u], dp[i - 1][j] + cnt);
		ans = max(ans, dp[i][u]);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 7200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main(){
    int q;
    cin >> q;
    rep(i, q){
        string A, B;
        cin >> A >> B;
        int la = A.length(), lb = B.length();
        vector<vector<int> > dp(la+1, vector<int>(lb+1, 0));
        rep(i, la){
            rep(j , lb){
                if(A.at(i) == B.at(j)) {
                    dp[i+1][j+1] = dp[i][j] + 1;
                } else {
                    dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
                }
            }
        }
        cout << dp[la][lb] << endl;
    }
    
}


Measured memory_bytes: 6904
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] A = new int[N][];
        int[] bit = new int[N];
        for (int i = 0; i < A.length; i++) {
            int K = sc.nextInt();
            A[i] = new int[K];
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
                bit[i] |= (1 << (A[i][j] - 1));
            }
        }
        int res = bit[0];
        for (int i = 1; i < bit.length; i++) {
            res &= bit[i];
        }
        System.out.println(Integer.bitCount(res));
        sc.close();
    }
}

Measured memory_bytes: 21460
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define yes "Yes\n"
#define no "No\n"
//int m,n;
//int i,j,l;
//int a,b,c,d,e,f,g;
//int sum,total;
long long int a,b,k,i;
//float ;
//double ;
//char a[101],b[101],s[101],t[101],u[101];
int main(void){
    scanf("%lld %lld %lld",&a,&b,&k);
    if (k<=a)
    {
        printf("%lld %lld\n",a-k,b);
        return 0;
    }
    if (a+b<k)
    {
        printf("0 0\n");
        return 0;
    }
    printf("0 %lld\n",b-(k-a));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#include <cmath>
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
    int k, x;
    cin >> k >> x;
    int n = 1000000;
    int left, right;
    left = max(-n, x - k + 1);
    right = min(n, x + k - 1);
    for (int i=left;i<=right;i++){
        if (i != right) cout << i << " ";
        else cout << i << endl;
    }
}


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

int main() {
  rep(i,5) {
    int x;
    cin >> x;
    if (x == 0) cout << i + 1 << endl;
  }
}


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

using namespace std;

int main() {
	int n, m;
	std::cin >> n;
	vector<string> vstr_plus(n);
	for (int i = 0; i < n; ++i) {
		std::cin >> vstr_plus[i];
	}

	std::cin >> m;
	vector<string> vstr_minus(m);
	for (int i = 0; i < m; ++i) {
		std::cin >> vstr_minus[i];
	}

	int max_score = 0;

	for (string word : vstr_plus) {
		int score = 0;
		for (string plus : vstr_plus) {
			if (word == plus) {
				++score;
			}
		}
		for (string minus : vstr_minus) {
			if (word == minus) {
				--score;
			}
		}
		if (max_score < score) {
			max_score = score;
		}
	}

	std::cout << max_score << std::endl;

	return 0;
}


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

s=[0]*4
for i in range(n):
  tmp = (input())
  if tmp == 'AC':
    s[0] += 1
  elif tmp == 'WA':
    s[1] += 1
  elif tmp == 'TLE':
    s[2] += 1
  else:
    s[3] += 1
print('AC x ', s[0])
print('WA x ', s[1])
print('TLE x ', s[2])
print('RE x ', s[3])

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

bool IsPalindromic(int n){
    vi dec(0);
    while(n>0){
        dec.push_back(n%10);
        n/=10;
    }
    int leng = dec.size();
    bool flag = true;
    rep(0,i,leng/2){
        if(dec[i]!=dec[leng-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}

int main(){
    int a,b;
    cin>>a>>b;
    int res = 0;
    rep(a,i,b+1){
        bool pali = IsPalindromic(i);
        if(pali) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

count = 0
for i in range(a, b + 1):
    s = i // 10000
    t = (i % 10000) // 1000
    u = (i % 100) //  10
    v = i % 10
    if s == v and t == u:
        count += 1
print(count)


Measured memory_bytes: 3060
D=int(input())
C=list(map(int, input().split()))
S=[list(map(int,input().split())) for i in range(D)]

T=[]
for i in range(D):
  T.append(int(input()))

def dissat(day):
  dissat = 0
  for i in range(26):
    if T[day-1]-1 == i:
      continue
    dissat += C[i]*(day-lastdays[i])

  return dissat    
    
def last(day):
  lastdays[T[day-1]-1] = day

sat = 0
lastdays = [0]*26

# main
for i in range(D):
  # dayi
  last(i)
  sat += S[i][T[i]-1] - dissat(i+1)
  print(sat)


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

int N,t[100000];
int main(){
  cin>>N;
  for(int i=0;i<N;i++) cin>>t[i];
  sort(t,t+N);
  set<int> st;
  for(int i=1;i<=t[N-1];i++)if(t[N-1]%i==0)st.insert(i);
  int ans=0;
  for(int i=0;i<N;i++)ans+=*st.lower_bound(t[i])-t[i];
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

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



signed main(){
  double a,b,c;cin>>a>>b>>c;
  cout<<a*b/2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n;cin>>n;
    ll c;cin>>c;
    ll x[n+1],v[n+1];rep(i,1,n)cin>>x[i]>>v[i];
    ll maxi[2][n+1]; //jまで食べるときのmaxi
    maxi[0][0]=0;
    maxi[1][0]=0;
    ll sum=0;
    rep(i,1,n){
        ll posi=x[i];
        sum+=v[i];
        maxi[0][i]=max(maxi[0][i-1],sum-posi);
    }
    sum=0;
    for(ll i=n;i>=1;i--){
        ll posi=c-x[i];
        sum+=v[i];
        if(i==n){
            maxi[1][i]=max(maxi[1][0],sum-posi);
        }else{
            maxi[1][i]=max(maxi[1][i+1],sum-posi);
        }
    }
    ll ans=0;
    sum=0;
    rep(i,1,n){
        ll posi=x[i];
        sum+=v[i];
        ans=max(ans,sum-posi);
        if(i<n){
            ans=max(ans,sum-2*posi+maxi[1][i+1]);
        }
    }
    sum=0;
    for(ll i=n;i>=1;i--){
        ll posi=c-x[i];
        sum+=v[i];
        ans=max(ans,sum-posi);
        if(i>1){
            ans=max(ans,sum-2*posi+maxi[0][i-1]);
        }
    }
    cout<<ans<<endl;
    
        
    return 0;
}





Measured memory_bytes: 6744
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> v(n), dp(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	dp[n-2]=abs(v[n-2]-v[n-1]);
	for(int i=n-3;i>=0;i--)
		dp[i]=min(dp[i+1]+abs(v[i]-v[i+1]),dp[i+2]+abs(v[i]-v[i+2]));
	cout<<dp[0];
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <numeric>
#include <vector>

#define rep(i,a) repi(i,0,a)
#define repi(i,a,b) for(int i=(a);i<(b);i++)

using namespace std;

const int N = 128;

int n, m, s[N], t[N];

void input()
{
    rep(i, n) cin >> s[i];
    rep(j, m) cin >> t[j];
}

const int inf = 1000000;

void solve()
{
    const int S = accumulate(s, s + n, 0);
    const int T = accumulate(t, t + m, 0);

    int mn = inf, a = -1, b = -1;
    rep(i, n) rep(j, m) {
        if (S - s[i] + t[j] == T - t[j] + s[i] and mn > s[i] + t[j]) {
            mn = s[i] + t[j];
            a = s[i], b = t[j];
        }
    }
    if (mn == inf) {
        cout << -1 << endl;
    } else {
        cout << a << ' ' << b << endl;
    }
}

int main()
{
    while (cin >> n >> m and n) {
        input();
        solve();
    }

    return 0;
}

Measured memory_bytes: 1160
def f(n):
 if (m:=s.get(n,-1))<0:s[n]=m=min([d*n]+[abs(p*k-n)*d+c+f(k)for p,c in zip(a,b)for k in(n//p,0--n//p)])
 return m
exec("n,*b,d=map(int,input().split());a=2,3,5;s={0:0,1:d};print(f(n));"*int(input()))

Measured memory_bytes: 11220
#coding:utf-8
n = int(input())

if n==0:
    print ('0')
    exit()

i=0
s=''
while(n!=0):
    if n%(2**(i+1))!=0:
        s+='1'
        n-=(-2)**i
    else:
        s+='0'
    i+=1
print (s[::-1])


Measured memory_bytes: 3060
#codng utf-8
from collections import Counter
n=int(input())

#A = ["a","b","b","c"]
#B = ["b","b","c","d"]
#C = list((Counter(A) & Counter(B)).elements())
#print(C)
L=[i for i in input()]
for i in range(n-1):
    l=[i for i in input()]
    L=list((Counter(L) & Counter(l)).elements())

L.sort()
L=''.join(L)
print(L)

Measured memory_bytes: 3316
N = input()
x = [0]*N
y = [0]*N
h = [0]*N
for i in range(N):
  x[i], y[i], h[i] = map(int, raw_input().split())

for p in range(N):
  if h[p]>0:
    for Cy in range(101):
      for Cx in range(101):
        H = h[p] + abs(x[p]-Cx) + abs(y[p]-Cy)
        for i in range(N):
          if max(H-abs(x[i]-Cx)-abs(y[i]-Cy), 0) != h[i]:
            break
        else:
          print Cx, Cy, H
          exit(0)


Measured memory_bytes: 2692
#include<bits/stdc++.h>
#define int long long
using namespace std;
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; }

class ConvexFullTrick
{
 private:
    vector<pair<int,int>> lines;
 public:
    ConvexFullTrick(){}
    int f(int i,int x){
        return lines[i].first*x+lines[i].second;
    }
    bool check(int i,pair<int,int> nxt){
        // 新たに直線を追加するとき、line[i]が不要かどうか
        pair<int,int> cur=lines[i];
        pair<int,int> pre=lines[i-1];
        int x=(pre.first-cur.first)*(cur.second-nxt.second);
        int y=(cur.first-nxt.first)*(pre.second-cur.second);
        // cout<<i<<' '<<x<<' '<<y<<endl;
        return x>=y;
    }
    void add(int a,int b){
        // 傾きは単調減少
        pair<int,int> line(a,b);
        while(lines.size()>=2 and check(lines.size()-1,line)) lines.pop_back();
        lines.push_back(line);
        // cout<<a<<' '<<b<<endl;
        // for(auto p:lines) cout<<p.first<<','<<p.second<<' '; cout<<endl;
    }
    int get(int x){
        // 最小値を求める
        // for(int i=0;i<lines.size();i++) cout<<f(i,x)<<' '; cout<<endl;
        int ng=-1,ok=lines.size()-1;
        while(ok-ng>1){
            int mid=(ng+ok)/2;
            if(f(mid,x)<f(mid+1,x)) ok=mid;
            else ng=mid;
            // cout<<f(mid,x)<<' '<<f(mid,x+1)<<' '<<ng<<' '<<ok<<endl;
        }
        return f(ok,x);
    }
};

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

    int N,C; cin>>N>>C;
    vector<int> h(N);
    for(int i=0;i<N;i++) cin>>h[i];

    vector<int> dp(N);
    dp[0]=0;
    ConvexFullTrick cht;
    cht.add(-2*h[0],dp[0]+h[0]*h[0]);
    for(int i=1;i<N;i++){
        dp[i]=cht.get(h[i])+h[i]*h[i]+C;
        cht.add(-2*h[i],dp[i]+h[i]*h[i]);
    }
    cout<<dp[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 9328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    ll cnt = 0;
    for (int a = 1; a <= N; a++) {
        cnt += (N - 1) / a;
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void)
{
	int i,j,m,n,a[90],b=0,c=0;
	cin>>n;
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			a[b]=i*j;
			b++;
		}
	}
	for(m=0;m<90;m++){
		if(a[m]==n) c=1;
	}
	if(c==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int x;
    while (n--){
        cin >> x;
        if (x%2 == 0){
            if (x%3 && x%5){
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int h,w;
    while(1){
        cin>>h>>w;
        if(h==0&&w==0)    break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if((i+j)%2==0)  cout<<"#";
                else            cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
}

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

#define ll long long
#define pq priority_queue
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int H, W;
char b[30][30];
int ans;

void dfs(int y, int x) {
   ans++;
   b[y][x] = '*';   
   for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny>=0 && ny<H && nx>=0 && nx<W && b[ny][nx] == '.') {
         dfs(ny, nx);
      }
   }
}

int main() {
   while (cin >> W >> H, W) {
      for (int i = 0; i < H; i++) {
         cin >> b[i];
      }

      ans = 0;
      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            if (b[i][j] == '@') {
               dfs(i, j);
            }
         }
      }
      cout << ans << endl;
   }

   return 0;
}


Measured memory_bytes: 2988
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
template<typename _Ty> void print(vector<_Ty>& v, char delim = ' ') { cout << v[0]; for (uint i = 1; i < v.size(); i++) cout << delim << v[i]; cout << endl; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false


int main()
{
	//clock_t start, end;
	//start = clock();

	int N, A, B;

	cin >> N >> A >> B;

	while (true) {
		// turn A
		if (A + 2 <= B) A++;
		else if (2 <= A) A--;
		else {
			cout << "Borys" << endl;
			return 0;
		}

		// turn B
		if (A + 2 <= B) B--;
		else if (B <= N - 1) B++;
		else {
			cout << "Alice" << endl;
			return 0;
		}
	}

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
using namespace std;

vector <ll> g[100002];
vector <ll> dp;

ll solve(ll s)
{
    if(g[s].size()==0) return 0;
    if(dp[s]!=0) return dp[s];
    ll ma=0;
    for(ll x: g[s])
    {
        ma = max(ma,solve(x));
    }
    dp[s] = ma+1;
    return dp[s];
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,m;
    cin>>n>>m;
    while(m--)
    {
        ll x,y;
        cin>>x>>y;
        g[x].pb(y);
    }
    dp.resize(n+1,0);
    for(ll i=1;i<=n;i++)
    {
        if(dp[i]==0) solve(i);
    }
    cout<<*max_element(dp.begin(),dp.end())<<endl;
}


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

int date[2][2097152]={};

void update( int x ){

	if( date[1][x*2] >= date[1][x*2+1] ){
		date[0][x] = date[0][x*2] ;
		date[1][x] = date[1][x*2] ;
	}else{
		date[0][x] = date[0][x*2+1] ;
		date[1][x] = date[1][x*2+1] ;
	}

	if( x!=1 ) update( x/2 );
}

int main(){
	
	int n,m,z;
	int a,b;
	
	cin >> n >> m ;
	
	for( z=1 ; z<n ; z=z*2 ){}
	
	for( int i=0 ; i<m ; i++ ){
		cin >> a >> b ;
		date[0][z+a-1] = a ;
		date[1][z+a-1] += b ;
		
		update( (z+a-1)/2 );
		
		cout << date[0][1] << " " ;
		cout << date[1][1] << endl ;
	}
	
return 0;
}

Measured memory_bytes: 17464
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    string s;
    set<string> t;
    cin >> n;
    while (n--) cin >> s, t.insert(s);
    cout << t.size();
}


Measured memory_bytes: 19196
def resolve():
    X = int(input())

    ans = 0
    num_500 = X // 500
    X = X - num_500 * 500
    #num_100 = X // 100
    #X = X - num_100 * 100
    #num_50 = X // 50
    #X = X - num_50 * 50
    #num_10 = X // 10
    #X = X - num_10 * 10
    num_5 = X // 5
    X = X - num_5 * 5
    ans = int(ans + num_500 * 1000 + num_5 * 5)

    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <cstring>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

typedef long long ll;

using namespace std;

#define MAX_N 100
#define MAX_W 10000

int n, w;
vec<pair<int, int> > vw;
int dp[MAX_N + 1][MAX_W + 1];

int solve(int i, int j) {
  int res;
  if (dp[i][j] >= 0)
    return dp[i][j];

  if (i == n) {
    res = 0;
  } else if (j < vw[i].second) {
    res = solve(i + 1, j);
  } else {
    res = max(solve(i + 1, j), solve(i + 1, j - vw[i].second) + vw[i].first);
  }
  return dp[i][j] = res;
}

int main() {
  cin >> n >> w;
  rep(i, n) {
    int a, b; cin >> a >> b;
    vw.emplace_back(a, b);
  }
  memset(dp, -1, sizeof(dp));
  cout << solve(0, w) << endl;
  return 0;
}


Measured memory_bytes: 7048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int N = 20000 + 5;

int main()
{
	int h,n;
	cin >> h >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		int x;
		cin >> x;
		sum += x;
	}
	if(sum >= h)
		cout << "Yes" << endl;
	else
		cout << "No" << endl; 
    return 0;
}

Measured memory_bytes: 384
import sys
readline = sys.stdin.readline       
N = int(readline())

ans = 'Yes' if -N&N != N else 'No'
print(ans)
if ans == 'Yes':
    Edge = []
    
    for i in range(2, N-(N%2 == 0)+1):
        Edge.append((1, i))
        if not i&1:
            Edge.append((i, N+i+1))
            Edge.append((i+1, N+i))
    Edge.append((N+1, N+3))
    if not N&1:
        Edge.append(((-N&N)+1, N))
        Edge.append((N^(-N&N), N+N))
    print('\n'.join([' '.join(map(str, e)) for e in Edge]))


Measured memory_bytes: 88780
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N,H;cin >> N >> H;
    priority_queue<pll> pque;
    rep(i,N){
        LL a,b;
        cin >> a >> b;
        pque.push({a,0});
        pque.push({b,1});
    }
    LL HP = H;
    LL ct = 0;
    while(H > 0){
        pll tmp = pque.top();
        H -= tmp.F;
        ct++;
        if(tmp.S == 1)pque.pop();
        else{
            if(H > 0)ct += (H+tmp.F-1)/tmp.F;
            break;
        }
    }
    cout << ct << endl;
}


Measured memory_bytes: 6512
from collections import deque
query = int(input())
l = deque()
for _ in range(query):
    command = input().strip()
    if command == "deleteFirst":
        try:
            l.popleft()
        except:
            pass
    elif command == "deleteLast":
        try:
            l.pop()
        except:
            pass
    else:
        command, value = command.split(" ")
        if command == "insert":
            l.appendleft(int(value))
        elif command == "delete":
            try:
                l.remove(int(value))
            except:
                pass
print(*l)

Measured memory_bytes: 48116
from functools import reduce
N = int(input())
g = 10 ** 9 + 7

def add(a, b):
  return (a + b) % g
def mul(a, b):
  return (a * b) % g

def adda(a, p1, p2):
    for x in range(len(a)):
        a[x] = add(p1[x], p2[x])

d = []
DP = [[0 for _ in range(N+1)] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]
for i in range(2, N+1):
  for j in (x for x in d if x * x <= N):
    if i % j == 0:
      adda(DP[i], DP[j], DP[i//j])
      break
  else:
    d.append(i)
    DP[i][i] = 1
  adda(ans, ans, DP[i])

print(reduce(mul, [x + 1 for x in ans[1:N+1]]))


Measured memory_bytes: 12380
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int INTINF = 1 << 20;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int H, W;
    cin >> H >> W;
    string map[55];
    int saitan[55][55];
    int shiro = 0;
    rep(i, 0, H) {
        cin >> map[i];
        rep(j, 0, W) {
            saitan[i][j] = -1;
            if(map[i][j] == '.') {
                shiro++;
            }
        }
    }

    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    saitan[0][0] = 1;
    while(q.size() > 0) {
        int tx = q.front().first;
        int ty = q.front().second;
        q.pop();
        if(tx > 0 && map[tx - 1][ty] == '.' && saitan[tx - 1][ty] == -1) {
            saitan[tx - 1][ty] = saitan[tx][ty] + 1;
            q.push(make_pair(tx - 1, ty));
        }
        if(tx < H - 1 && map[tx + 1][ty] == '.' && saitan[tx + 1][ty] == -1) {
            saitan[tx + 1][ty] = saitan[tx][ty] + 1;
            q.push(make_pair(tx + 1, ty));
        }
        if(ty > 0 && map[tx][ty - 1] == '.' && saitan[tx][ty - 1] == -1) {
            saitan[tx][ty - 1] = saitan[tx][ty] + 1;
            q.push(make_pair(tx, ty - 1));
        }
        if(ty < W- 1 && map[tx][ty + 1] == '.' && saitan[tx][ty + 1] == -1) {
            saitan[tx][ty + 1] = saitan[tx][ty] + 1;
            q.push(make_pair(tx, ty + 1));
        }
    }
    // rep(i, 0, H) {
    //     rep(j, 0, W) { cout << saitan[i][j] << " "; }
    //     cout << endl;
    // }
    if(saitan[H - 1][W - 1] == -1) {
        cout << -1 << endl;
    } else {
        cout << shiro - saitan[H - 1][W - 1] << endl;
    }
}


Measured memory_bytes: 256
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N + 1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'AGCT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  sort(ALLR(a)); 
  int ans = 0;
  rep(i,n){
    if(i%2==0)ans+=a.at(i);
    if(i%2==1)ans-=a.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[1000001];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>f[i];
	}
	int ans=0,sum=1;
	for(int i=1;i<=n;i++)
	{
		if(f[i]==sum)
		{
			sum++;
			ans++;
		}
	}
	if(sum==1)
	{
		cout<<-1;
	}
	else
	cout<<n-ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);I++) cin >> x[i];

int main(){
  string a,b,c ;
  cin >> a >> b >> c;
  cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
//Prime Number
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	const int MAX = 1000000;
	bool isPrime[MAX];
	for(int i = 0; i < MAX; i++) {
		isPrime[i] = true;
	}
	
	for(int i = 2; i*i < MAX; i++) {
		if(isPrime[i]) {
			for(int j = i*i; j < MAX; j += i) {
				isPrime[j] = false;
			}
		}
	}
	
	int n;
	while(cin >> n) {
		int count = 0;
		for(int i = 2; i <= n; i++) {
			if(isPrime[i]) count++;
		}
		cout << count << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2132
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
#include<cmath>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin>>n;
    vector<int>v;
    while(n!=0){
        if(n%2!=0){
            n--;
            v.push_back(1);
        }
        else {
           v.push_back(0);
        }
        n/=(-2);
    
    }
    if(v.size()!=0){
   for(int i=v.size()-1;i>=0;i--){
       printf("%d",v[i]);
   }
   printf("\n");
}
else{
    cout<<0<<endl;
}

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

ull N, M;
string S, T;

ull gcd(ull m, ull n) {
  while (m != n) {
    if (m > n)
      m = m - n;
    else
      n = n - m;
  }
  return m;
}

ull lcm(ull m, ull n) {
  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
} // lcm

int main(int argc, char const *argv[]) {
  cin >> N >> M >> S >> T;
  ull l = lcm(N, M);

  ull n = l / N, m = l / M;

  for (int i = 0; i < N; ++i) {
    int j = i * n;
    if (j % m)
      continue;
    if (S[i] == T[j / m])
      continue;
    cout << -1 << endl;
    return 0;
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 512