akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import bisect

def main():
    a, b = input().split()
    if a == 'H' and b == 'H':
        print('H')
    elif a == 'D' and b == 'D':
        print('H')
    else:
        print('D')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)

// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N;
	cin >> N;
 
	// 解法
	ll hit = 0;
	ll num_S = 0;
	ll n_i = 0;
	for (ll i = 2; i <= 100000; ++i){
		ll n_i = i*(i+1)/2;
		if (n_i==N){
			num_S = i + 1;
			// cout << "Yes" << endl;
			hit = 1;
			break;
		}
		else if (n_i > N){
			// cout << "No" << endl;
			break;
		}
	}
	if (N==1){
		cout << "Yes" << endl;
		printf("2\n");
		printf("1 1\n");
		printf("1 1\n");
	}
	else if (hit==0){
		cout << "No" << endl;
	}
	else if (hit==1){
		cout << "Yes" << endl;
		ll len_S = num_S - 1;
		// printf("len_S: %lld \n", len_S);
		ll map[num_S][len_S] = {0};
		for (ll i = 0; i < num_S; ++i){
			
			for (ll j = 0; j < len_S; ++j){
				if (i==0){
					map[i][j] = j+1;
					// printf("%lld ", map[i][j]);
				}
				else if (j>=i){
					map[i][j] = map[i-1][len_S-1] + j - i + 1;
				}
				else{
					map[i][j] = map[j][i-1];
				}
			}
		}
		
		// printf("len_S: %lld \n", len_S);
		
		printf("%lld\n", num_S);
		for (ll i = 0; i < num_S; ++i){
			printf("%lld ", len_S);
			
			for (ll j = 0; j < len_S; ++j){
				printf("%lld ", map[i][j]);
			}
			printf("\n");
		}
	}
	
	// if (hit){
	// 	cout << 4 << endl;
	// 	// printf("num_S: %lld \n", 4);
	// }
	
	
	
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    int a = n % 10;
    if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) cout << "hon" << endl;
    else if (a == 0 || a == 1 || a == 6 || a == 8) cout << "pon" << endl;
    else cout << "bon" << endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  int n, b;
  cin >> n;
  vector<int> a(100002);
  rep(i, 0, n) {
    cin >> b;
    ++a[b];
    ++a[-~b];
    ++a[-~-~b];
  }
  cout << *max_element(a.begin(), a.end());
  return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b);
#define chmin(a, b) (a)=min(a, b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  string s;
  cin >> s;
  ll N=s.size();
  ll dp[MAX*2][3]={};
  
  s="#"+s;
  dp[1][1]=1;
  dp[2][1]=(s[1]==s[2]) ? 0 : 2;
  dp[2][2]=1;
  for(i=1; i<=N; i++) {
    if(i>=2 && s.substr(i-1, 2)!=s.substr(i+1, 2))
      chmax(dp[i+2][2], dp[i][2]+1);
    if(s.substr(i, 1)!=s.substr(i+1, 1))
      chmax(dp[i+1][1], dp[i][1]+1);
    if(i>=2)
      chmax(dp[i+1][1], dp[i][2]+1);
    
    chmax(dp[i+2][2], dp[i][1]+1);
  }
  
  
  pt(max(dp[N][1], dp[N][2]));
  
}





Measured memory_bytes: 5508
#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++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> A(n, vector<ll>(m, 0));
    vector<ll> b(m, 0);
    for (auto &e : A)
    {
        for (ll &num : e)
        {
            ll tmp;
            cin >> tmp;
            num = tmp;
        }
    }
    for (ll &num : b)
    {
        ll tmp;
        cin >> tmp;
        num = tmp;
    }

    for (const auto &e : A)
    {
        ll c = 0;
        repi(i, m, 0)
        {
            c += e.at(i) * b.at(i);
        }
        cout << c << endl;
    }
    return 0;
}


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

int main() {
    string s;
    while(cin >> s) {
        int joi = 0, ioi = 0;
        rep (i, s.size() - 2) {
            if (s[i] == 'J') joi += (s[i + 1] == 'O' && s[i + 2] == 'I');
            if (s[i] == 'I') ioi += (s[i + 1] == 'O' && s[i + 2] == 'I');
        }
        cout << joi << endl << ioi << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
N = int(input())
A = list(map(int, input().split()))
for a in A:
    if a % 2 != 0:
        continue
    elif a % 3 == 0:
        continue
    elif a % 5 == 0:
        continue
    else:
        print("DENIED")
        exit()

print("APPROVED")

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

int main(){
    int a[4];
    
    for(int i=1;i<=3;i++)
      cin>>a[i];
      
    sort(a+1,a+4);
    
    if(a[1]==a[2] && a[2]!=a[3])
      cout<<"Yes";
    else if(a[2]==a[3] && a[1]!=a[2])
      cout<<"Yes";
    else
      cout<<"No";
      
    cout<<endl;
      
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAX=1<<18;
int n,dat[2*MAX-1],laz[2*MAX-1];
void init(int n_){
  n=1;
  while(n<n_) n*=2;
  for(int i=0;i<2*n-1;i++) dat[i]=laz[i]=0;
}
inline void eval(int len,int k){
  if(k*2+1<n*2-1){
    laz[k*2+1]+=laz[k];
    laz[k*2+2]+=laz[k];
  }
  dat[k]+=laz[k]*len;
  laz[k]=0;
}
int update(int a,int b,int x,int k=0,int l=0,int r=n){
  eval(r-l,k);
  if(r<=a||b<=l) return dat[k]+laz[k]*(r-l);
  if(a<=l&&r<=b) return dat[k]+(laz[k]+=x)*(r-l);
  eval(r-l,k);
  return dat[k]=update(a,b,x,k*2+1,l,(l+r)/2)+update(a,b,x,k*2+2,(l+r)/2,r);
}
int query(int a,int b,int k=0,int l=0,int r=n){
  eval(r-l,k);
  if(r<=a||b<=l) return 0;
  if(a<=l&&r<=b) return dat[k];
  int vl=query(a,b,k*2+1,l,(l+r)/2);
  int vr=query(a,b,k*2+2,(l+r)/2,r);
  return vl+vr;
}
signed main(){
  int N,q;
  cin>>N>>q;
  init(N);
  for(int i=0;i<q;i++){
    int f;
    cin>>f;
    if(f){
      int x;
      cin>>x;
      cout<<query(x-1,x)<<endl;
    }else{
      int s,t,x;
      cin>>s>>t>>x;
      update(s-1,t,x);
    }
  }
}

Measured memory_bytes: 7192
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
import java.util.Stack;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        String rand = sc.next();
        Stack<Integer> down = new Stack<>();
        Deque<Pool> s = new ArrayDeque<>();
        int sum = 0;
        for(int i = 0; i < rand.length(); i++) {
            char c = rand.charAt(i);
            switch(c) {
                case '\\':
                down.push(i);
                break;
                case '/':
                if(!down.isEmpty()){
                    int j = down.pop();
                    if(s.isEmpty()) {
                        s.addLast(new Pool(j, i - j));
                    }else {
                        int tmpS = i - j;
                        while(!s.isEmpty() && j < s.getLast().j) {
                            tmpS += s.removeLast().s;
                        }
                        s.addLast(new Pool(j, tmpS));
                    }
                    sum += i - j;
                }
            }
        }

        System.out.println(sum);

        StringBuilder sb = new StringBuilder();
        sb.append(s.size());
        while(!s.isEmpty()) {
           sb.append(" ").append(s.removeFirst().s);
        }
        System.out.println(sb);
        
        sc.close();
    }
}

class Pool {
    int j;
    int s;

    Pool(int j, int s) {
        this.j = j;
        this.s = s;
    }
}


Measured memory_bytes: 28356
N = int(input())
A = list(map(int, input().split()))

sorted_A = sorted(A, reverse=True)

Alice_sum = 0
Bob_sum = 0
for i in range(len(sorted_A)):
    if i % 2 == 0:
        Alice_sum = Alice_sum + sorted_A[i]
    else:
        Bob_sum = Bob_sum + sorted_A[i]

print(Alice_sum - Bob_sum)


Measured memory_bytes: 3060
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>

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

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    //与式＝A*(x%B)-(Ax%B)でAx%B=A(x%B)%B←modを利用
    ll x;
    if (n >= b - 1)x = b - 1;
    else x = n;
    ll ans = (a * x) / b - a * (x / b);
    cout << ans << endl;
  

    return 0;
}

Measured memory_bytes: 3168
import itertools
c=itertools.product([0,1], repeat=10)
n=int(input())
f=[list(map(int, input().split())) for i in range(n)]
p=[list(map(int, input().split())) for i in range(n)]
ans=-10**10
def C(ci):
    cnt=[0]*n
    for x in range(n):
        for y in range(10):
            if ci[y]==1 and f[x][y]==1:
                cnt[x]+=1
    res=0
    for z in range(n):
        res+=p[z][cnt[z]]
    return res
for ci in c:
    if all(i ==0 for i in ci):
        continue
    ans=max(ans, C(ci))
print(ans)    

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

int main() {
  int N, l, r, x, sum;
  x = 0;
  sum = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> l >> r;
    x = r - l + 1;
    sum += x;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
n, a, b, c = list(map(int, input().split(' ')))
ln = [None] * n
for i in range(n):
    ln[i] = (int(input()))


def dfs(i, ap, bp, cp):
    pattern = [ap, bp, cp]
    if i >= n and [] not in pattern:
        mp = 0
        for p in pattern:
            mp += max([0, len(p) - 1]) * 10
        mp += abs(a - sum(pattern[0]))
        mp += abs(b - sum(pattern[1]))
        mp += abs(c - sum(pattern[2]))
        return mp
    elif i >= n:
        return float('inf')
    else:
        return min([
            dfs(i + 1, ap + [ln[i]], bp, cp),
            dfs(i + 1, ap, bp + [ln[i]], cp),
            dfs(i + 1, ap, bp, cp + [ln[i]]),
            dfs(i + 1, ap, bp, cp)
        ])


result = dfs(0, [], [], [])
print(result)




Measured memory_bytes: 53212
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int v[200005];
int t[105];
int vv[205];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	m=0;
	for(i=0;i<n;i++){
		cin>>t[i];
		m+=t[i];
	}
	for(i=0;i<=m;i++){
		v[i]=min(i,m-i);
	}
	b=0;
	for(i=0;i<n;i++){
		cin>>a;
		for(j=0;j<=m;j++){
			if(j<b)c=a+b-j;
			else if(j<=b+t[i])c=a;
			else c=a+j-(b+t[i]);
			v[j]=min(v[j],c);
		}
		vv[i]=a;
		b+=t[i];
	}
	double s=0;
	b=0;
	//array_show(v,100);
	for(i=0;i<n;i++){
		for(j=b;j<b+t[i];j++){
			s+=(v[j]+v[j+1])/2.;
			if(v[j]==v[j+1] && v[j]!=vv[i])s+=1./4;
		}
		b+=t[i];
	}
	cout<<fixed<<setprecision(12)<<s<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	int A, B;
	cin >> A >> B;
	if (A + B >= 10)cout << "error";
	else cout << A + B;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    string s;
    cin >> s;
    LL rc = 0;
    LL gc = 0;
    LL bc = 0;
    for(int i = 0; i < N; ++i) {
        if(s[i] == 'R') ++rc;
        if(s[i] == 'G') ++gc;
        if(s[i] == 'B') ++bc;
    }

    LL res = rc * gc * bc;

    for(int i = 0; i < N; ++i) {
        for(int j = 1; i + j * 2 < N; ++j) {
            if(s[i] != s[i + j] && s[i + j] != s[i + j * 2] && s[i] != s[i + j * 2]) --res;
        }
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>

void sort(int *x,int kaisu){
	int i,j,tmp;
	
	for(i=0;i < kaisu-1;i++){
		for(j=i+1;j < kaisu;j++){
			if(x[i] < x[j]){
				tmp = x[i];
				x[i] = x[j];
				x[j] = tmp;
			}
		}
	}
}

int main(void){
	int x[10]={0};
	int kaisu=10,i;
	
	for(i=0;i < kaisu;i++){
		scanf(" %d",&x[i]);
	}
	
	sort(&x[0],kaisu);
	
	for(i=0;i < 3;i++){
		printf("%d\n",x[i]);
	}
	return 0;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l;
  load(l, n);

  sort(l);
  int sum = 0;
  for (int i = n - 1; i >= n - k; --i) {
    sum += l[i];
  }
  p(sum);
}

Measured memory_bytes: 256
MOD = 1000000007

h, w = map(int, raw_input().split())
grid = []
for _ in range(h):
    grid.append(raw_input())

dp = [[0] * w for _ in range(h)]
dp[h - 1][w - 1] = 1
for i in range(h - 2, -1, -1):
    if grid[i][w - 1] == '.':
        dp[i][w - 1] = dp[i + 1][w - 1]
for i in range(w - 2, -1, -1):
    if grid[h - 1][i] == '.':
        dp[h - 1][i] = dp[h - 1][i + 1]
for i in range(h - 2, -1, -1):
    for j in range(w - 2, -1, -1):
        if grid[i][j] == '.':
            dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % MOD
print(dp[0][0])


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

int main(){
 int h,w;
 cin>>h>>w;
  vector<string> g(h);
  for(string &s: g) cin>>s; 
  vector<int> dx={-1,0,0,1};
  vector<int> dy={0,1,-1,0};
  int ans=0;
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(g[i][j]=='#') continue;
      int cnt=0;
      vector<vector<int>> d(h,vector<int>(w,-1));
      queue<pair<int,int>> q;
      
      d[i][j]=0;
 	  pair<int,int> p(i,j);
      q.push(p);
      
      while(!q.empty()){
   	   pair<int,int> v=q.front();q.pop();
   	   int y=v.first,x=v.second;
    
       for(int k=0;k<4;k++){
        int Y=y+dy[k],X=x+dx[k];
      
        if(0<=Y&&Y<h&&0<=X&&X<w&&g[Y][X]=='.'){
          if(d[Y][X]!=-1) continue;
        
          d[Y][X]=d[y][x]+1;
          cnt=max(cnt,d[Y][X]);
          pair<int,int> V(Y,X);
          q.push(V);
        } 
	   }
      }
      ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
N = int(input())
C, S, F = [], [], []
for _ in range(N-1):
    c, s, f = tuple(map(int, input().split()))
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(N-1):
    total_time = 0
    for j, (c, s, f) in enumerate(zip(C[i:], S[i:], F[i:])):
        if j == 0:
            total_time += (c + s)
        else:
            if total_time < s:
                total_time = s
            if total_time % f != 0:
                total_time += f - total_time % f
            total_time += c
    print(total_time)
print(0)


Measured memory_bytes: 3188
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

template<class T = int>
struct CumulativeSum1D
{
	vector<T> data;
	CumulativeSum1D(int N) { data.resize(N + 1); }
	inline void add(int i, T x)
	{
		data[i] += x;
	}

	void build()
	{
		for (int i = 1; i < data.size(); i++) {
			data[i] += data[i - 1];
		}
	}

	inline T query(int i, int j) { return data[j] - data[i - 1]; }
};

int main(void) {
	int N;
	string S;
	cin >> N >> S;
	vec<int> W(N, 0);
	vec<int> E(N, 0);
	REP(i, N) {
		if (S[i] == 'W') {
			W[i] = 1;
		}
		else {
			E[i] = 1;
		}
	}

	CumulativeSum1D<int> csW(N + 1);
	CumulativeSum1D<int> csE(N + 1);
	REP(i, N) {
		csW.add(i + 1, W[i]);
		csE.add(i + 1, E[i]);
	}
	csW.build();
	csE.build();

	int ans = N;
	for (int i = 1; i < N; ++i) {
		int left = i == 1 ? 0 : csW.query(1, i - 1);
		int right = i == N - 1 ? 0 : csE.query(i + 1, N);
		int x = right + left;
		ans = min(ans, x);
	}
	OUT(ans);

	return 0;
}

Measured memory_bytes: 5396
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

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

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,k,s;
    cin>>n>>k>>s;
    if(s==1000000000){
        rep(i,k)cout<<s<<sp;
        rep(i,n-k)cout<<1<<sp;
        cout<<endl;
    }
    else{
        rep(i,k)cout<<s<<sp;
        rep(i,n-k)cout<<s+1<<sp;
        cout<<endl;
    }
}

Measured memory_bytes: 1280
n,q = map(int,input().split())
from collections import deque
s = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a = a-1
    b = b-1
    s[a].append(b)
    s[b].append(a)
count = [0 for i in range(n)]
for i in range(q):
    p,x = map(int,input().split())
    count[p-1] += x
ans = [-1 for i in range(n)]
ans[0] = count[0]
d = deque([(0,0)])
while d:
    u,v = d.pop()
    ans[u] = v + count[u]
    for b in s[u]:
        if ans[b] == -1:
            d.append((b,ans[u]))
        else:
            continue
for i in range(n):
    print(ans[i])

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

int main() {
    int x, y;
    cin >> x >> y;
    bool check = false;
    for (int i = 0; i <= x; i++){
        if(i * 2 + (x - i) * 4 == y){cout << "Yes" << endl; 
        check = true;
        break;
        }
    }
    
    if(!check) cout << "No" << endl;
    
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int numa, numb;
    cin >> numa >> numb;
    if(numa<numb){
        swap(numa,numb);
    }
    if((numa-numb)%2==0){
        cout << (numa-numb)/2+numb << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
int main(){
  int n,m,i,j,k,t,r,a,x[10200],y[10200];
  int X[]={ 0, 1, 0,-1};
  int Y[]={ 1, 0,-1, 0};
  while(scanf("%d %d",&n,&m),n||m){
    char c,d[102][102]={0};
    for(i=a=0;i<n;i++)scanf("%s",d[i+1]+1);
    for(i=1;i<=n;i++){
      for(j=1;j<=m;j++){
	if(!d[i][j])continue;
	x[t=0]=j;
	y[t]=i;
	a++;
	c=d[i][j];
	for(r=1;t-r;t++){
	  for(k=0;k<4;k++){
	    if(c==d[y[t]+Y[k]][x[t]+X[k]]){
	      x[r]=x[t]+X[k];
	      y[r]=y[t]+Y[k];
	      d[y[r]][x[r++]]=0;
	    }
	  }
	}
      }
    }
    printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 700
klist = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

print(klist[k-1])


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力1をnに入れる
		int n = sc.nextInt();

		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		// 累積GCDの左右
		int[] left = new int[n+1];
		int[] right = new int[n+1];
		int[] middle = new int[n];

	    for (int i = 0; i < n; ++i) left[i+1] = gcd(left[i], a[i]);
	    for (int i = n-1; i >= 0; --i) right[i] = gcd(right[i+1], a[i]);

	    // 集計
		int ans = 1;
	    for (int i=0;i<n;++i) {
	    	// 更新
	    	middle[i]  = gcd(left[i], right[i+1]);
	    	ans = Math.max(ans, middle[i]);
	    }

		System.out.println(ans);
	}


	public static int gcd(int a, int b) {
		return b != 0 ? gcd(b, a % b) : a;
	}
}

Measured memory_bytes: 52380
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Data.List

main :: IO ()
main = solve <$> f [] <*> g [] >>= putStrLn
  where
    f xs = do
      l <- getLine
      if l == "END_OF_TEXT"
        then return $ intercalate "\n" $ reverse xs
        else f (l:xs)
    g xs = do
      l <- getLine
      if l == "-"
        then return $ reverse xs
        else g (l:xs)
             
solve :: String -> [String] -> String
solve ts cs = evalState (f cs) ([], ts, [])
  where
    f :: [String] -> State (String, String, String) String
    f [] = do
      (as, bs, _) <- get
      return $ revAppend as bs
    f ("a":xs) = do
      (as, bs, cs) <- get
      let (a1s, a2s) = break (== '\n') as
      put (a2s, revAppend a1s bs, cs)
      f xs
    f ("e":xs) = do
      (as, bs, cs) <- get
      let (b1s, b2s) = break (== '\n') bs
      put (revAppend b1s as, b2s, cs)
      f xs
    f ("p":xs) = do
      (as, bs, cs) <- get
      let (a1s, a2s) = break (== '\n') as
      if null a2s
        then put ([], revAppend a1s bs, cs)
        else do
          let (a3s, a4s) = break (== '\n') (tail a2s)
          put (a4s, revAppend a3s ('\n' : (revAppend a1s bs)), cs)
      f xs
    f ("n":xs) = do
      (as, bs, cs) <- get
      let (b1s, b2s) = break (== '\n') bs
      if null b2s
        then do
          let (a1s, a2s) = break (== '\n') as
          put (a2s, revAppend a1s bs, cs)
        else put ('\n' : revAppend b1s as, tail b2s, cs)
      f xs
    f ("f":xs) = do
      (as, bs, cs) <- get
      if null bs
        then put (as, bs, cs)
        else put (head bs : as, tail bs, cs)
      f xs
    f ("b":xs) = do
      (as, bs, cs) <- get
      if null as
        then put (as, bs, cs)
        else put (tail as, head as : bs, cs)
      f xs
    f ("d":xs) = do
      (as, bs, cs) <- get
      if null bs
        then put (as, bs, cs)
        else put (as, tail bs, cs)
      f xs
    f ("k":xs) = do
      (as, bs, cs) <- get
      if null bs
        then put (as, bs, cs)
        else if head bs == '\n'
               then put (as, tail bs, "\n")
               else do
                 let (b1s, b2s) = break (== '\n') bs
                 put (as, b2s, b1s)
      f xs
    f ("y":xs) = do
      (as, bs, cs) <- get
      if null cs
        then put (as, bs, cs)
        else if cs == "\n"
               then put ('\n':as, bs, cs)
               else put (revAppend cs as, bs, cs)
      f xs

revAppend :: String -> String -> String
revAppend [] ys = ys
revAppend (x:xs) ys = revAppend xs (x:ys)



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	VI ck(n+10), dp(n+10);
	rep(i, m){
		int a; cin >>a; ck[a] = 1;
	}
	dp[0] =1;
	rep(i, n){
		if(ck[i+1]==0) (dp[i+1] += dp[i]) %=MD;
		if(ck[i+2]==0) (dp[i+2] += dp[i]) %=MD;
	}
	
	cout << dp[n] <<"\n";
	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	vi arr (N);

	F0R(i, N) cin >> arr[i];
	
	int gcd = arr[0];
	for (int x : arr) gcd = __gcd(x, gcd);

	sort(arr.begin(), arr.end());
	
	if ((K - arr[0]) % gcd == 0 && K <= arr[N-1]) {
		print("POSSIBLE");
	} else {
		print("IMPOSSIBLE");
	}
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner input1 = new Scanner(System.in);
		int largest = 0;
		int secondlargest = 0;
		int thirdlargest = 0;
		int largestindex = 0;
		int secondlargestindex = 0;
		int[] number = new int[10];
		for (int i = 0; i <= 9; i++) {
			number[i] = input1.nextInt();
		}
		for (int i = 0; i <= 9; i++) {
			if (number[i] > largest) {
				largest = number[i];
				largestindex = i;
			}
		}
		for (int i = 0; i <= 9; i++) {
			if (number[i] > secondlargest && i != largestindex) {
				secondlargest = number[i];
				secondlargestindex = i;
			}
		}
		for (int i = 0; i <= 9; i++) {
			if (number[i] > thirdlargest && i != largestindex && i != secondlargestindex) {
				thirdlargest = number[i];
			}
		}
		
		System.out.println(largest);
		System.out.println(secondlargest);
		System.out.println(thirdlargest);
	}

}

Measured memory_bytes: 17364
#include<stdio.h>
 
struct dice
{
    int n[6] ;
};
struct dice dice1 ;
 
 
int east()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[3] ;
    dice1.n[3] = dice1.n[5] ;
    dice1.n[5] = dice1.n[2] ;
    dice1.n[2] = mem ;
}
 
int west()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[2] ;
    dice1.n[2] = dice1.n[5] ;
    dice1.n[5] = dice1.n[3] ;
    dice1.n[3] = mem ;
}
 
int south()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[4] ;
    dice1.n[4] = dice1.n[5] ;
    dice1.n[5] = dice1.n[1] ;
    dice1.n[1] = mem ;
}
 
int north()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[1] ;
    dice1.n[1] = dice1.n[5] ;
    dice1.n[5] = dice1.n[4] ;
    dice1.n[4] = mem ;
}
 
int main()
{
    int i=0 ;
    int cmp=0 ;
 
    char a[101] = {0} ;
 
    for (i=0 ;i < 6 ;i++)
    {
        scanf("%d" ,&cmp) ;
 
        dice1.n[i] = cmp ;
 
    }
    scanf("%s" ,a) ;
 
    for (i=0 ;i < 101 ;i++)
    {
        if (a[i] == '\0') break ;
 
        if (a[i] == 'E') east() ;
        if (a[i] == 'W') west() ;
        if (a[i] == 'S') south() ;
        if (a[i] == 'N') north() ;
 
    }
 
    printf ("%d\n" ,dice1.n[0]) ;
    return 0 ;
}


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

int N,w,T[105][10005],W[105][2];

int main()
{
    memset(T,0,sizeof(T));
    memset(W,0,sizeof(W));
    cin>>N>>w;
    int i,j;
    for(i=1;i<=N;i++){
        int a,b;
        cin>>W[i][0]>>W[i][1];
    }
    for(i=1;i<=N;i++){
        for(j=1;j<=w;j++){
            if(W[i][1]<=j){
                if(W[i][0]+T[i-1][j-W[i][1]]>T[i-1][j]){
                    T[i][j]=W[i][0]+T[i-1][j-W[i][1]];
                }
                else T[i][j]=T[i-1][j];
            }else{
                T[i][j]=T[i-1][j];
            }
        }
    }
    cout<<T[N][w]<<endl;
    return 0;
}

Measured memory_bytes: 7200
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())


# bit全探索で愚直に
def solver1(n, p, A):
    ans = 0
    for i in range(2**n):
        x = 0
        for j in range(n):
            if (i>>j) & 1:
                x += A[j]
        if x % 2 == p:
            ans += 1
    return ans


def solver2(n, p, A):
    odd = 0
    even = 0
    for a in A:
        if a % 2 == 1:
            odd += 1
        else:
            even += 1
    if odd == 0:
        if p == 0:
            return 2 ** even
        else:
            return 0
    else:
        return 2 ** (n-1)


def main():
    n, p = inintm()
    A = inintl()
    # print(solver1(n, p, A))
    print(solver2(n, p, A))


main()


Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;
int MOD = 1e9+7;
int inf = 1e18;
const int N = 5e5+999;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
      int nn;
      cin>>nn;
      bool flag  = true;
      int n;
      while(nn--)
      {
          cin>>n;

          if(n%2==0)
          {
              if(n%3==0||n%5==0)
              {
                  continue;
              }
              else
              {
                  flag = false;
              }
          }
      }
      if(flag)
        cout<<"APPROVED"<<el;
      else
        cout<<"DENIED"<<el;
    }
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,j,k,m,n;
	cin>>n>>m;
	if((m-1)%(n-1)==0)cout<<(m-1)/(n-1)<<endl;
	else cout<<(m-1)/(n-1)+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string hoge;
	cin>>hoge;
	int n,s,w,e;
	n=s=w=e=0;
	rep(i,hoge.size()){
		if(hoge[i]=='N')n++;
		if(hoge[i]=='S')s++;
		if(hoge[i]=='W')w++;
		if(hoge[i]=='E')e++;
	}
	if(n>0)n=1;
	if(s>0)s=1;
	if(w>0)w=1;
	if(e>0)e=1;
	if(!(n xor s) && !(e xor w))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<memory.h>
#define mod 1000000007
int main()
{int n,sum=0,a;
int rec[100005];
scanf("%d",&n);
memset(rec,0,sizeof(rec));
for(int i=0;i<n;i++)
{scanf("%d",&a);
rec[a]++;}
if(n%2==0)
{for(int i=1;i<n;i+=2)
	if(rec[i]!=2)
	{printf("0");return 0;}}
	else
if(rec[0]!=1)
{printf("0");return 0;}
else
for(int i=2;i<n;i+=2)
	if(rec[i]!=2)
	{printf("0");return 0;}

long long int ans=1,base=2;
n/=2;
	while(n>0)
	{if(n&1)
ans=(ans*base)%mod;
	base=(base*base)%mod;
	n>>=1;}
	printf("%lld",ans);}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline


a, b, c= map(int, input().split())


#f_table = [a*t//b for t in range(b)]

if c >= b:
    print((a * (b-1)) // b)

else:
    x = c
    c_amari = c%b
    c_sho = c//b
    ans =(a * c_amari) //b
    print(ans)


Measured memory_bytes: 9168
#include <cstring>
#include <cstdio>
#include <iostream>
#include <set>
using namespace std;
int main() {
	int x, y, z; cin >> x >> y >> z;
	multiset<string> st;
	for (int i = 1;i <= x; i++) st.insert("a");
	for (int i = 1;i <= y; i++) st.insert("b");
	for (int i = 1;i <= z; i++) st.insert("c");
	while (st.size() != 1) {
		auto be = st.begin(), ed = st.end(); ed--;
		st.insert(*be + *ed);
		st.erase(be), st.erase(ed);
	}
	cout << *st.begin() << endl;
	return 0;
}

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

int main(){
	int a[101];
	int b[101];
	int n,m,p,x,res;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	cin >> m;
	for(int i = 0;i < m;i++){
		cin >> p >> x;
		res = 0;
		for(int i = 0;i < n;i++){
			if(i + 1 == p){
				res += x;
			}
			else res += a[i];
		}
		cout << res <<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,i,m=1;cin>>n;
	while(m*2<=n){m*=2;}
	if(m==n){cout<<"No"<<endl;return 0;}
	cout<<"Yes"<<endl;
	cout<<3+n<<" "<<1+n<<endl;
	for(i=2;i<n;i+=2){
		cout<<i<<" "<<i+1<<endl;
		cout<<i+1<<" "<<1<<endl;
		cout<<1<<" "<<i+n<<endl;
		cout<<i+n<<" "<<i+1+n<<endl;
	}
	if(n%2==0){
		cout<<n<<" "<<m+n<<endl;
		cout<<n-m+1<<" "<<n+n<<endl;
	}
	return 0;
}

Measured memory_bytes: 2304
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Collectors;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int n = sc.nextInt();
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				b[(n + i) / 2] = sc.nextInt();
			} else {
				b[(n - i - 1) / 2] = sc.nextInt();
			}
		}
		if (n % 2 == 0){
			System.out.println(Arrays.stream(b).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
		} else {
			StringJoiner joiner = new StringJoiner(" ");
			for (int i = b.length - 1; i >= 0; i--) {
				joiner.add(String.valueOf(b[i]));
			}
			System.out.println(joiner);
		}
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 87292
import sys
sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline()[:-1]


N, M = map(int, input().split())
from_1 = {}
to_n = {}
for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        from_1[b] = True
    elif b == N:
        to_n[a] = True

for key in to_n.keys():
    if key in from_1:
        print('POSSIBLE')
        exit(0)
print('IMPOSSIBLE')


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



using namespace std;



int main(){



	int n;

	cin >> n;



	int a[101];

	bool p[101];

	memset(p, true, sizeof(p));



	for(int i=2;i*i<=n;i++){

		if(p[i] == true){

			for(int j=i*i;j<=n;j+=i){

				p[j] = false;

			}

		}

	}

	

	int c2=0, c4=0, c14=0, c24=0, c74=0;

	for(int i=2;i<=n;i++){

		if(p[i]==true){

			//cout << "p: " << i << endl;

			int pw = 0;

			int p1 = i;

			while(p1<=n){

				pw = pw + (n/p1);

				p1 = p1 * i; 

			}

			//cout << "pw: " << i << " " << pw << endl; 

			if(pw >= 2) c2++;

			if(pw >= 4) c4++;

			if(pw >= 14) c14++;

			if(pw >= 24) c24++;

			if(pw >= 74) c74++;

		}

	}

	//cout << c2 << " " << c4 << " " << c14 << " " << c24 << " " << c74 << endl;



	int cvp = c74 + (c14 * (c4 - 1)) + (c24 * (c2 - 1)) + (((c4 * (c4 - 1))/2) * (c2 - 2));

	cout << cvp << endl;



	return 0;

}

Measured memory_bytes: 256
#include<cmath>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<cstdio>
#include<set>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define per(i,a,b) for(long long int i=a;i<=b;++i)
#define inf 0xf3f3f3f
#define ll long long 
using namespace std;
int main(){
	ll a,n,sum=0,b;
	cin>>a>>n;
	per(i,1,n) 
	{
		cin>>b;
		sum+=b;
	}
	if(sum>=a) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
m = 246912
p = [1] * m
p[0] = p[1] = 0
for i in range(2, int(m**0.5) + 1):
  if p[i]:
    for j in range(i*i, m, i):
      p[j] = 0
while True:
  n = int(input())
  if n == 0:
    break
  print(sum(p[n+1:2*n+1]))


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

p = list(map(int, input().split()))

ans = 0

for i in range(n - 2):
    if p[i] < p[i+1] and p[i+1] < p[i+2]:
        ans += 1
    elif p[i+2] < p[i+1] and p[i+1] < p[i]:
        ans += 1

print(ans)


Measured memory_bytes: 3060
n, k = map(int, input().split())

A = list(map(int, input().split()))
import fractions
def list_gcd(X):
    t = max(X)
    for i in X:
        t = fractions.gcd(t, i)
    return t

if k in A or (k % list_gcd(A) == 0 and max(A) >= k):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

using namespace std;

const long long mod = int(1e9) + 7;

long long fact[100000 + 2];

long long modExpo(long long x, long long n)
{

    long long result = 1;
    while (n > 0)
    {
        if (n % 2 == 1)
            result = (result * x) % mod;
        x = (x * x) % mod;
        n = (n >> 1);
    }
    return result;
}
long long modinv(long long n)
{
    return modExpo(n, mod - 2);
}
long long nCk(long long n, long long k)
{
    if (k > n)
        return 0;
    if (k == 0 || k == n)
        return 1;
    long long num = fact[n];
    long long den = (fact[k] * fact[n - k]) % mod;
    den = modinv(den);
    long long ans = (num * den) % mod;
    return ans;
}
int main()
{
    long long n, k;
    cin >> n >> k;
    long long arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);
    if (k == 1)
    {
        cout << 0 << "\n";
        return 0;
    }
    long long presum[n];
    presum[0] = arr[0];
    for (int i = 1; i < n; i++)
        presum[i] = (presum[i - 1] + arr[i]) % mod;
    fact[0] = 1;
    for (long long i = 1; i < 100000 + 2; i++)
        fact[i] = (fact[i - 1] * i) % mod;
    long long ans = 0;
    for (long long i = 0; i <= n - k; i++)
    {
        long long tmp = 0;
        long long left = (presum[n - 1] - presum[k - 2 + i]) % mod;
        long long right = presum[n - k - i] % mod;
        tmp = (left - right + mod * mod) % mod;
        tmp = (tmp * (nCk(k - 2 + i, k - 2))) % mod;
        ans = (ans + tmp) % mod;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define MN 5000
#define ll long long
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
ll f[MN+5],A,B;
int n;
int main()
{
    n=read();A=read();B=read();
    memset(f,63,sizeof(f));f[0]=0;
    for(int i=1;i<=n;++i)
    {
        int x=read();
        for(int j=0;j<x;++j)
        {
            f[x]=min(f[x],f[j]);
            f[j]+=A;
        }
        for(int j=x;++j<=n;) f[j]+=B;
    }
    ll ans=1e18;
    for(int i=0;i<=n;++i) ans=min(ans,f[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
//R<3S
#include <bits/stdc++.h>
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);}
#define inset(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);}
#define ll long long
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


using namespace std;

void solve()
  {

	int n,m,x,y;
	cin>>n>>m;
	int h[n];
	rep(i,n)cin>>h[i];
	vector<int>adj[n+1];
	rep(i,m)
	{
		cin>>x>>y;
		adj[x].pb(h[y-1]);
		adj[y].pb(h[x-1]);
		
	}
	int cnt=0;
	repA(i,1,n){sort(adj[i].begin(),adj[i].end(),greater<int>());}
	
	repA(i,1,n)
	{
		if(adj[i].empty()){cnt++;continue;}
		if(h[i-1]>adj[i][0])cnt++;
	}
	cout<<cnt;
	
	
	

  }



signed main()
{
   FAST
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


Measured memory_bytes: 10228
#include <iostream>

using namespace std;

int main() {

	string s;
	cin >> s;

	for(int i = 0 ; i < 4 ; i++) {
		cout << s[i];
	}
	cout << " ";
	for(int i = 4 ; i < 12 ; i++) {
		cout << s[i];
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256