akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int calcPermutation(int x, int y)
{
    int ans = 1;
    for (int i = 0; i < y; i++)
    {
        ans *= (x - i);
    }
    return ans;
}

int calcCombination(int x, int y)
{
    if (x < y)
    {
        return 0;
    }
    if ((x - y) < y)
    {
        y = x - y;
    }
    int ans = calcPermutation(x, y);
    while (y > 0)
    {
        ans /= y;
        y--;
    }
    return ans;
}

int main()
{
    int N;
    cin >> N;
    int devs[100] = {};
    for (int i = 2; i <= N; i++)
    {
        int n = i;
        for (int j = 2; n > 1; j++)
        {
            while (n % j == 0)
            {
                devs[j]++;
                n /= j;
            }
        }
    }
    int over75 = 0;
    int over25 = 0;
    int over15 = 0;
    int over5 = 0;
    int over3 = 0;

    for (int i = 0; i < 100; i++)
    {
        if (devs[i] >= 74)
        {
            over75++;
        }
        else if (devs[i] >= 24)
        {
            over25++;
        }
        else if (devs[i] >= 14)
        {
            over15++;
        }
        else if (devs[i] >= 4)
        {
            over5++;
        }
        else if (devs[i] >= 2)
        {
            over3++;
        }
    }

    int ans = 0;
    // 3 x 5 x 5
    ans += calcCombination(over5 + over15 + over25 + over75, 3) * 3;
    ans += calcCombination(over5 + over15 + over25 + over75, 2) * over3;

    // 3 x 25
    ans += calcCombination(over25 + over75, 2) * 2;
    ans += (over25 + over75) * (over3 + over5 + over15);

    // 5 x 15
    ans += calcCombination(over15 + over25 + over75, 2) * 2;
    ans += (over15 + over25 + over75) * (over5);

    // 75
    ans += over75;
    cout << ans << endl;
}


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

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

    int a[] = {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};

    cout << a[k-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int DIRX[4] = {-1,0,1,0};
int DIRY[4] = {0,-1,0,1};

int main(){
	int h,w;
	char board[50][50];
	cin >> h >> w;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			cin >> board[j][i];
		}
	}

	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(board[j][i] != '#')continue;
			bool flag = 0;
			for(int k = 0;k < 4;k++){
				int nx = j + DIRX[k];
				int ny = i + DIRY[k];
				if(nx < 0 || ny < 0 || nx >= w || ny >= h)continue;
				if(board[nx][ny] == '#')flag = 1;
			}
			if(!flag){cout << "No" << endl;return 0;}
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    A1 = [int(i) for i in input().split()]
    A2 = [int(i) for i in input().split()]
    maxA = 0
    for i in range(N + 1):
        maxA = max(maxA, sum(A1[:i + 1]) + sum(A2[i:]))
    print(maxA)


resolve()


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

using namespace std;

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

  if(N == 3) {
    cout << 2 << " " << 5 << " " << 63 << endl;
    return (0);
  }

  random_device rd;
  mt19937 rnd(rd());
  vector< int > v;
  for(int i = 2; i <= 30000; i += 2) {
    v.emplace_back(i);
  }
  for(int i = 3; i <= 30000; i += 3) {
    if(i % 2 == 0) continue;
    v.emplace_back(i);
  }
  auto check = [&]() {
    int sum = 0, gcd = 0;
    for(int i = 0; i < N; i++) sum += v[i];
    for(int i = 0; i < N; i++) {
      if(__gcd(sum, v[i]) == 1) return false;
      gcd = __gcd(gcd, v[i]);
    }
    return gcd == 1;
  };
  while(!check()) {
    shuffle(begin(v), end(v), rnd);
  }
  for(int i = 0; i < N; i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

int main(){
    string s;
    cin >> s;
    int cnt=0;
    rep(i,s.size()) if(s[i]=='R') cnt++;
    if(cnt == 2){
        if(s[1]=='S')cnt=1;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3620
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

s = 0
digit = bytearray()
c = stdin.read(1)
while c:
    if c.isdigit():
        digit.append(c)
    elif digit:
        s += int(digit)
        digit = bytearray()
    c = stdin.read(1)

print(s)

Measured memory_bytes: 4244
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>

using namespace std;
int main(){

  string w,t;

  cin >> w;

  int sum;

  for(int i=0;i<w.size();i++){
    if(65 <= (int)w[i] && (int)w[i] <= 90){
      w[i] = (char)((int)w[i] + 32);
    }
  }

  while(true){
    cin >> t ;
    if(t.compare("END_OF_TEXT") == 0) break;
    for(int i=0;i<t.size();i++){
      if(65 <= (int)t[i] && (int)t[i] <= 90){
        t[i] = (char)((int)t[i] + 32);
      }
    }
    if(t.compare(w) == 0) {
      sum++;
    }
  }

  cout << sum <<endl;

}


Measured memory_bytes: 3192
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {


    public static void main(String[] args) {

        //System.out.println("aaaaaaaaa");

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] intArray = new int[N];
        for (int i = 0; i < N; i++) {
            intArray[i] = sc.nextInt(); // Integer
        }

        int res = IntStream.of(intArray).map(ele -> niDeWaru(ele)).sum();
        System.out.println(res);

    }

    private static int niDeWaru(int ele) {
        int result = 0;
        while (ele % 2 == 0) {
            ele = ele /2;
            result++;
        }
        return result;
    }
}


Measured memory_bytes: 38352
<?php
    list($W, $H, $x, $y, $r) = explode(" ",trim(fgets(STDIN)));
    
    $result = "Yes";

    if($x - $r < 0 || $x + $r > $W){
        $result = "No";
    }
    if($y - $r < 0 || $y + $r > $H){
        $result = "No";
    }
    
    echo $result."\n";
    

Measured memory_bytes: 15412
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {
    private static int count = 0;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int size = Integer.parseInt(scanner.next());
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = Integer.parseInt(scanner.next());
        }

        shellSort(array, size);
        System.out.println(count);
        for (int i : array) {
            System.out.println(i);
        }
    }

    private static void insertionSort(int[] array, int size, int gap) {
        for (int i = gap; i < size; i++) {
            int value = array[i];
            int j = i - gap;
            while (j >= 0 && array[j] > value) {
                array[j + gap] = array[j];
                j -= gap;
                count++;
            }
            array[j + gap] = value;
        }
    }

    private static void shellSort(int[] array, int size) {
        int m = 0;
        int[] gaps = new int[15];
        for (int i = 1; i <= size; i = i * 3 + 1) {
            gaps[m] = i;
            m++;
        }
        System.out.println(m);
        System.out.println(concat(gaps, m));
        for (int i = m - 1; i >= 0; i--) {
            insertionSort(array, size, gaps[i]);
        }
    }

    private static String concat(int[] array, int length) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i = length - 1; i >= 0; i--) {
            joiner.add(String.valueOf(array[i]));
        }
        return joiner.toString();
    }
}

Measured memory_bytes: 179296
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  string S; cin >> S;
  
  int count =0, maxR = 0;
  for (int i =0; i <3; i++) {
    if (S[i] == 'R') {
      count++; maxR = max(count,maxR);
    } else {
      count =0;
    }
  }
  cout << maxR << endl;
}

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

long long f[10000000];

long long fib(int n)
{
  if (n == 0 || n == 1) return (1);
  if (f[n] != 0)  return (f[n]);
  else {
    f[n] = fib(n - 1) + fib(n - 2);
  }
  return f[n];
}
int main()
{
  int n;
  cin >> n;
  cout << fib(n) << endl;
}

Measured memory_bytes: 1160
import java.util.Scanner;


public class Main {
    private static int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();

        long x = n / ( a + b );
        long y = n % ( a + b );

        if (a < y) {
            y = a;
        }

        System.out.println( (a * x) + y );

        if (!sc.hasNext()) {
            return;
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
using namespace std;
int main(){
int k,a,b;
bool ans = false;
cin >> k >> a >> b;
for(int i=a;i<=b;i++){
	if(i%k==0){
		ans = true;
		break;
	}
}	

if(ans){
	cout << "OK" << "\n";
}else{
	cout << "NG" << "\n";
}

return 0;






}


Measured memory_bytes: 3652
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

inline int waste(int a, int b, int m) { return (((a % m) + (b % m)) % m); }
inline int worse(int a, int b, int m) { return (((a % m) * (b % m)) % m); }
inline int worst(int a, int b, int m) { return (((a % m) - (b % m) + m) % m);}

using namespace std;

int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif
   int a;
   cin >> a;
   cout << a+(a*a)+(a*a*a);
   
}

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

using ll = long long;

using namespace std;

ll mod = 1000000007;

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

const int INF = 1001001001;


int main() {
	int n;
	cin >> n;
	vector<int>h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int>dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int jump = 1; jump <= 2; jump++) {
			if (i + jump >= n)continue;
			if (dp[i + jump] > dp[i] + abs(h[i] - h[i + jump])) {
				dp[i + jump] = dp[i] + abs(h[i] - h[i + jump]);
			}
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int lis(int n,vector<int>& A){
  vector<int> L(A.size()+1,0);
  L[0]=A[0];
  int length=1;
  for(int i=1;i<n;i++){
    if(L[length-1]<A[i]){
      L[length++]=A[i];
    }else{
      *lower_bound(L.begin(),L.begin()+length,A[i])=A[i];
    }
  }
  return length;
}
int main(){
  int n;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++) cin>>A[i];
  cout<<lis(n,A)<<endl;
  return 0;
}
/*
verified on 2017/06/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D&lang=jp
*/

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  long long ans = 3;
  if(a.at(0) != 0) ans = 0;
  
  vector<int> x(3, 0);
  x[0]++;
  int count, check;
  for(int i = 1; i < n; i++){
    count = 0, check = 0;
    if(x[0] == a.at(i)){
      count++;
      check++;
      x[0]++;
    }
    if(x[1] == a.at(i)){
      count++;
      check++;
      if(check == 1) x[1]++;
    }
    if(x[2] == a.at(i)){
      count++;
      check++;
      if(check == 1) x[2]++;
    }
    
    if(check == 0) ans = 0;
    ans *= count;
    ans %= 1000000007;
    
    sort(x.begin(), x.end());
  }
  
  cout << ans << "\n";
}

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

struct edge {
  int to; string s;
};
struct state{
  int id, len;
  string s;
  bool operator<(const state& st ) const{
    return s > st.s;
  }
};

vector<edge> G[55];
int N,M,S,T;
string H[55][500];
string dijk(){
  for(int i=0;i<N;i++)
    for(int j=0;j<500;j++)
      H[i][j] = "~";
  priority_queue<state> q;
  H[S][0] = "";
  q.push( (state){S,0,""} );
  while( !q.empty() ){
    state p = q.top(); q.pop();
    if( H[p.id][p.len] < p.s ) continue;
    for(int i=0;i<(int)G[p.id].size();i++){
      edge e = G[p.id][i];
      int nlen = p.len + e.s.size();
      if( nlen >= 500 ) continue;
      if( H[e.to][nlen] > p.s + e.s ){
        H[e.to][nlen] = p.s + e.s;
        q.push( (state){e.to,nlen,p.s+e.s} );
      }
    }
  }
  string res = "~";
  for(int i=0;i<500;i++){
    if( res > H[T][i] ){
      res = H[T][i];
      if( i > 300 ) return "NO";
    }    
  }
  if( res == "~" ) return "NO";
  return res;
}

int main(){
  while( cin >> N >> M >> S >> T && (N|M|S|T) ){
    for(int i=0;i<M;i++){
      int a,b; string s; cin >> a >> b >> s;
      G[a].push_back( (edge){b,s} );
    }
    cout << dijk() << endl;
    for(int i=0;i<N;i++) G[i].clear();
  }
}

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

long long gcd(long long x, long long y){
	if (y == 0)
		return x;
	return gcd(y, x % y);
}
int main(){
	int T;
	cin >> T;
	while (T --){
		long long a, b, c, d;
		cin >> a >> b >> c >> d;
		if (a < b)
			cout << "No" << endl;
		else if (b > d)
			cout << "No" << endl;
		else if (c >= b - 1)
			cout << "Yes" << endl;
		else{
		//	a %= b, c %= b, d %= b;
			long long g = gcd(d, b);
			if ((a - b) / g < (a - c - 1) / g)
				cout << "No" << endl;
			else
				cout << "Yes" << endl;
		}
	}
}


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

long gcd(long x, long y)
{
  return(y? gcd(y, x%y):x);
}

std::vector<std::pair<long, long>> 
pirme_factorize(long n)
{
  std::vector<std::pair<long, long>> res;
  for(long i = 2; i*i <= n; ++i)
  {
    if(n%i != 0) continue;
    int num = 0;
    while(n%i==0) num++, n /= i;
    res.push_back(std::make_pair(i, num));
  }
  if(n != 1) res.push_back(std::make_pair(n, 1));
  return res;
}

void solve(long A, long B) 
{
  long g = gcd(A,B);
  std::vector<std::pair<long,long>> pairs = 
    pirme_factorize(g);
  std::cout << pairs.size()+1 << std::endl;
}

int main(void) {
  long A;
  long B;
  std::cin >> A;
  std::cin >> B;
  solve(A,B);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define MAX  1e18
#define ss 1e15
#define pb push_back

bool comp(pair<pair<string,int>,int> p1, pair<pair<string,int>,int> p2){
    if(p1.first.first == p2.first.first){
        return p1.first.second > p2.first.second;
    }
    return p1.first.first < p2.first.first;
}

int main() {    
    int n;
    cin>>n;
    pair<pair<string,int>,int> arr[n];
    for(int i=0;i<n;i++){
        string str;
        int x;
        cin>>str>>x;
        arr[i] = make_pair(make_pair(str,x),i);
    }
    sort(arr,arr+n,comp);
    for(int i=0;i<n;i++){
        //cout<<arr[i].first.first<<" "<<arr[i].first.second<<" "<<arr[i].second<<"\n";
        cout<<arr[i].second + 1<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
S = input()
a = len(S)
mod = 0
ten = 1
L = [0]*2019 #余りの列
L[0] = 1
for i in range(a-1,-1,-1):
    mod = (int(S[i])*(ten)+mod) %2019
    L[mod] += 1
    ten = (ten*10)%2019
ans = 0
for i in L:
  ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 9280
S=input()
T=input()
ls = []
flg = False
for i in range(26):
    #print(S+chr(ord("a")+i))
    #print(type(T),type(S+chr(ord("a")+i)))
    if T == S+chr(ord("a")+i):
        flg = True
        #print("Yes")
        break
    else:
        continue
if flg == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 61788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    string s;
    cin >> s;
    int cou = 0;
    rep(i, 3) if(s[i] == 'o') cou++;
    cout << 700 + (100 * cou) << endl;

    return 0;
}

Measured memory_bytes: 3604
import math 
ip = [int(i) for i in input().split()]
a = ip[0]
b = ip[1]
h = ip[2]
m = ip[3]


lng =  30 * (h + m/60) 
sht = 6 * m

x = abs(lng - sht)
# print(x)
y = math.cos(math.radians(x))
# print(y)
shen = math.sqrt(a*a + b*b - 2*a*b*y)


print(shen)


Measured memory_bytes: 9512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextInt();
        int[][] allType = new int[n][n];
        long min = 0;
        for (int i = 0; i < n; i++) {
            allType[0][i] = sc.nextInt();
            min += allType[0][i];
        }
        for (int i = 1; i < n; i++) {
            long sum = 0;
            for (int j = 0; j < n; j++) {
                allType[i][j] = Math.min(allType[i - 1][j], allType[0][(j - i + n) % n]);
                sum += allType[i][j];
            }
            min = Math.min(min, sum + i * x);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 54484
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

ll ansCnt[(ll)1e6] = {};

int main() {
    
    ll n,k,q;
    cin >> n >> k >> q;
    for (ll i=0;i<q;i++){
        ll tmp;
        cin >> tmp;
        ansCnt[tmp]++;
    }
    for (ll i=1;i<=n;i++){
        if(k - (q - ansCnt[i]) > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

}

Measured memory_bytes: 1536
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
char s[12];
int main()
{
	scanf("%s", s);
	int n = strlen(s);
	if (n & 1)
		puts("No");
	else
	{
		for (int i = 0; i < n; i += 2)
			if (s[i] != 'h' || s[i + 1] != 'i')
			{
				puts("No");
				return 0;
			}
		puts("Yes");
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll = long long;

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

  for(ll h = 1; h <= 3500; h++){
    for(ll w = 1; w <= 3500; w++){
      ll num = N * h * w;
      ll den = 4 * h * w - N * w - N * h;
      if((den != 0) && (num % den == 0) && (num / den > 0)){
	cout << h << ' ' << (num / den) << ' ' << w << endl;
	return 0;
      }
    }
  }
}


Measured memory_bytes: 632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<cmath>
using namespace std;
const double Pi=acos(-1);
int main(){
	double r;
	cin>>r;
	cout<<setiosflags(ios::fixed)<<setprecision(6)<<Pi*r*r<<" "<<Pi*2*r<<endl;
	return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n;
cin >>n;
int k;
cin >>k;
int a[n][3][3];//n+1個の最後から2番目-1,1番目-1
int b[n];
int c;
c=0;
while(c<n){
b[c]=-1;
c=c+1;}
int d;
int e;
c=0;
while(c<k){
cin >>d;
cin >>e;
b[d-1]=e-1;
c=c+1;}
int f;
int h;
c=0;
while(c<3){
f=0;
while(f<3){
h=0;
if(b[0]!=c){if(b[0]!=-1){h=1;}}
if(b[1]!=f){if(b[1]!=-1){h=1;}}
if(h==1){a[1][c][f]=0;}
if(h==0){a[1][c][f]=1;}
f=f+1;}
c=c+1;}
int g;
c=2;
while(c<n){
f=0;
while(f<3){
g=0;
while(g<3){
a[c][f][g]=a[c-1][0][f]+a[c-1][1][f]+a[c-1][2][f];
if(f==g){a[c][f][g]=a[c][f][g]-a[c-1][f][f];}
if(b[c]!=g){if(b[c]!=-1){a[c][f][g]=0;}}
a[c][f][g]=a[c][f][g]%10000;
g=g+1;}
f=f+1;}
c=c+1;}
int i;
i=a[n-1][0][0]+a[n-1][0][1]+a[n-1][0][2]+a[n-1][1][0]+a[n-1][1][1]+a[n-1][1][2]+a[n-1][2][0]+a[n-1][2][1]+a[n-1][2][2];
cout << i%10000<<endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h> // Integer Product, by Errichto
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    map<pair<int,int>, int> cnt;
    for(int rep = 0; rep < n; ++rep) {
        double x;
        scanf("%lf", &x);
        long long i = llround(x * 1e9);
        int two = 0, five = 0;
        while(i % 2 == 0) {
            two++;
            i /= 2;
        }
        while(i % 5 == 0) {
            five++;
            i /= 5;
        }
        ++cnt[{two,five}];
    }
    long long answer = 0;
    for(auto p1 : cnt) {
        for(auto p2 : cnt) {
            if(p1.first.first+p2.first.first >= 18 && p1.first.second+p2.first.second >= 18) {
                if(p1 < p2) {
                    answer += (long long) p1.second * p2.second;
                }
                else if(p1 == p2) {
                    answer += (long long) p1.second * (p1.second - 1) / 2;
                }
            }
        }
    }
    printf("%lld\n", answer);
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

int mystoi(string s){
  int res = 0, t = 1;
  for(int i = (int)s.size()-1; i >= 0; i--){
    res += s[i] * t;
    t *= 10;
  }
  return res;
}

signed main(){

  int a, b; cin >> a >> b;

  for(int i = 0; i < max(a, b); i++){
    cout << min(a, b);
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=1e5+1e2;
int n,m;
int Ans;
int a[maxn],fa[maxn];

inline void file() {
	freopen("ARC097D.in","r",stdin);
	freopen("ARC097D.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

int find(int x) {
	if (x!=fa[x]) fa[x]=find(fa[x]);
	return fa[x];
}

int main() {
//	file();
	n=read(); m=read();
	For (i,1,n) a[i]=read();
	For (i,1,n) fa[i]=i;
	For (i,1,m) {
		int x=read(),y=read();
		x=find(x); y=find(y);
		if (x!=y) fa[x]=y;
	}
	For (i,1,n) if (find(i)==find(a[i])) ++Ans;
	printf("%d",Ans);
	return 0;
}

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

int main(void){
  char b;
  cin >> b;
  if(b=='A'){
    cout << 'T' << endl;
  }else if(b=='T'){
    cout << 'A' << endl;
  }else if(b=='G'){
    cout << 'C' << endl;
  }else{
    cout << 'G' << endl;
  }
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [h, a] <- getIntList
    print $ (h - 1) `div` a + 1

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

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  if(A==5 && B==5 && C==7)
  {cout<<"YES"<<endl;}
else if(A==7 && B==5 && C==5)
  {cout<<"YES"<<endl;}
  else if(A==5 && B==7 && C==5)
  {cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.array, std.algorithm;

void main()
{
  long a, b, c, x, y;
  readf("%d %d %d %d %d", &a, &b, &c, &x, &y);

  if (a + b < 2 * c) {
    writeln(a * x + b * y);
    return;
  }
  long n = min(x, y);
  long ans = n * 2 * c;
  x -= n; y -= n;
  ans += min(a * x + y * b, max(x, y) * 2 * c);

  writeln(ans);
}


Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)
b = nil
ans = 1
(1...N).each{ |i|
  c = A[i-1] <=> A[i]
 # p [i,b,c]
  next if c == 0
  next if b && b == c
  if !b
    b = c
  else
    ans += 1
    b = nil
  end    
}
p ans


Measured memory_bytes: 8452
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var list = new List<int>();
        for (int i = 0; i < inp[0]; i++) list.Add(inp[1] + i);
        var sum = list.Sum();
        list = list.Select(f => Math.Abs(f)).ToList();
        Console.WriteLine(sum < 0 ? sum + list.Min() : sum - list.Min());
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    if (a + b == 3)cout << 3 << endl;
    else if (a + b == 4)cout << 2 << endl;
    else if (a + b == 5)cout << 1 << endl;
}


Measured memory_bytes: 256
from collections import Counter
n=int(input())
v=list(input().split())
v1=Counter(v[0::2]).most_common()
v2=Counter(v[1::2]).most_common()
ans=0
if v1[0][0]!=v2[0][0]:
  ans=(len(v[0::2])-v1[0][1])+(len(v[1::2])-v2[0][1])
elif len(v1)==1 and len(v2)==1:
  ans=min(v1[0][1],v2[0][1])
elif len(v1)==1:
  ans=len(v[1::2])-v2[1][1]
elif len(v2)==1:
  ans=(len(v[0::2])-v1[1][1])
else:
  ans=min((len(v[0::2])-v1[1][1])+(len(v[1::2])-v2[0][1]),(len(v[0::2])-v1[0][1])+(len(v[1::2])-v2[1][1]))
print(ans)

Measured memory_bytes: 102380
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main() {
// your code goes here
double as[101],bs[101];
int n;
double d1=0,d2=0,d3=0,dm=0;
scanf("%d",&n);
for(int i=0;i<n;i++){
	scanf("%lf",&as[i]);
}
for(int i=0;i<n;i++){
	scanf("%lf",&bs[i]);
}
for(int i=0;i<n;i++){
	double d=fabs(as[i]-bs[i]);
	d1+=d;
	d2+=(d*d);
	d3+=(d*d*d);
	dm=std::max(d,dm);
}
printf("%lf\n%lf\n%lf\n%lf\n",d1,pow(d2,1/2.0),pow(d3,1/3.0),dm);
return 0;
}


Measured memory_bytes: 2876
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
void solve()
{
    char ch;
    cin>>ch;
    if(ch>='a'&&ch<='z')
    cout<<'a';
    else
    cout<<'A';
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3616
#include <string>
#include <cstdint>
#include <iostream>
#include <cmath>

using namespace std;


uint32_t mcxiToValue(const string& str)
{
    uint32_t dst = 0;
    int32_t v = -1;

    for(auto c : str){
        if('0' <= c && c <= '9'){
            v = c - '0';
        }else{
            if(v == -1)
                v = 1;

            switch(c){
              case 'm': dst += 1000 * v; break;
              case 'c': dst += 100 * v; break;
              case 'x': dst += 10 * v; break;
              case 'i': dst += v; break;
              // default: assert(0);
            }
            v = -1;
        }
    }

    return dst;
}


string toMCXI(uint32_t value)
{
    char cs[9], *bIter;
    bIter = cs;

    for(int32_t i = 3; i >= 0; --i){
        uint32_t m = value / pow(10, i);

        if(m == 0)
            continue;
        if(m != 1){
            *bIter = m + '0';
            ++bIter;
        }

        *bIter = (i == 3 ? 'm' :
                    (i == 2 ? 'c':
                        (i == 1 ? 'x' : 'i')));
        ++bIter;

        value -= m * pow(10, i);
    }

    return string(cs, bIter);
}


int main(void)
{
    const auto N = [](){ int a; cin >> a; return a; }();

    for(size_t i = 0; i < N; ++i){

        string str1, str2;
        cin >> str1 >> str2;
        const auto v = mcxiToValue(str1),
                   w = mcxiToValue(str2);

        cout << toMCXI(v + w) << endl;
    }

    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    cout<<((s[0]==s[1]||s[1]==s[2]||s[2]==s[3])?"Bad":"Good");
    return 0;
}



Measured memory_bytes: 3648
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d = scan.nextInt();
        
        if(a+b>c+d){
            System.out.println("Left");
        }
        else if(a+b==c+d)
        {
            System.out.println("Balanced");
        }
        else
        {
            System.out.println("Right");
        }
    }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<bool> rank(8, false);
    int pro = 0;
    REP(i, n){
        int a;
        cin >> a;
        if(a >= 3200){
            pro++;
        }else{
            rank[a/400] = true;
        }
    }
    int ans = 0;
    for(auto i : rank){
        if(i){
            ans++;
        }
    }
    cout << max(1, ans) << " " << ans + pro << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    N, M, Q = map(int, input().split())
    ABCD = [list(map(int, input().split())) for i in range(Q)]
    score = 0

    def dfs(l, N, M, ABCD):
        # 末端まで探索したか判定
        if judge_end(l, N):
            nonlocal score
            tmp_score = calc_score(ABCD, l)
            score = max(tmp_score, score)
            return
        else:
            # 現時点から選べる選択肢の列挙と探索
            nexts = listup_next(l[-1], M)
            for x in nexts:
                dfs(l+[x], N, M, ABCD)

    def judge_end(l, N):
        return len(l) == N

    def calc_score(ABCD, l):
        s = 0
        for a, b, c, d in ABCD:
            if l[b-1] - l[a-1] == c:
                s += d
        return s

    def listup_next(m, M):
        return range(m, M+1)

    for i in range(1, M+1):
        dfs([i], N, M, ABCD)
    print(score)


if __name__ == "__main__":
    main()


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

namespace B___Ordinary_Number
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var pi = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var cnt = 0;

            for (int i = 1; i < n - 1; i++)
            {
                if (pi[i - 1] == pi[i] || pi[i] == pi[i + 1]) continue;
                if (pi[i - 1].CompareTo(pi[i]) == pi[i].CompareTo(pi[i + 1])) cnt++;
            }

            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 62);
ll n,k, m, t,q,h1,h2,m1,m2; string s;
const ld PI = acos(-1);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main() {
    cin >> n; vector<ll> a(n + 1), b(n + 1);
    rep(i, n+1) cin >> a[i];
    if (n == 0 && a[0] != 1) {
        cout << -1 << endl;
        return 0;
    }if (n != 0 && a[0] != 0) {
        cout << -1 << endl;
        return 0;
    }b[0] = 1;
    req(i, n) {
        if ((b[i - 1] - a[i - 1]) * 2 < a[i]) {
            cout << -1 << endl;
            return 0;
        }
        b[i] = min((b[i - 1] - a[i - 1]) * 2,INF);
    }ll now = a[n], res = a[n];
    rrep(i, n) {
        now = min(now + a[i], b[i]);
        res += now;
    }cout << res << endl;
}

Measured memory_bytes: 4828
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    rep(i,N){
        if(a[i]%2!=0) continue;
        else{
            if(a[i]%3==0 || a[i]%5==0) continue;
            else{
                cout << "DENIED" << nn;
                return 0;
            }
        }
    }
    cout << "APPROVED" << nn;
    return 0;
}

Measured memory_bytes: 256
/*JOI 君はマルスタンプ，バツスタンプ，マルバツスタンプの3種類のスタンプをそれぞれ 0 個以上持っている．これらはマルやバツのマークを紙に印字することができるスタンプである．

   マルスタンプを使うとマルが 1 つ印字され，バツスタンプを使うとバツが 1 つ印字される．マルバツスタンプを使うとマルとバツが横一列に 1 つずつ印字され，スタンプの向きを変えることで，マルの右にバツが来るようにも，バツの右にマルが来るようにも印字できる．

   JOI 君は，持っているスタンプをそれぞれちょうど 1 回ずつ適当な順番で使い，紙に横一列にマルとバツを印字した．印字されたマルとバツの列は文字列 S で表される．S は O と X から構成された長さ N の文字列であり，Si= O ならば JOI 君が印字したマークのうち左から i 番目のものがマルであることを表し，Si= X ならばそれがバツであることを表す (1≦i≦N)．*/

#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
        int length, counter = 0;

        string ox;
        cin >> length >> ox;
        for(int i = 0; i < length; i++) {
                if(ox[i] == 'O' && ox[i+1] == 'X') {
                        counter++;
                        i++;
                }else if(ox[i] == 'X' && ox[i+1] == 'O') {
                        counter++;
                        i++;
                }
        }
        cout << counter << endl;
        return 0;
}



Measured memory_bytes: 3320
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <map>
#include <set>
using namespace std;
using ll = long long;

int main(void) {
	int N;
	string S;
	cin >> N >> S;
	map<char, int> X, Y;
	for (int i = 0; i < N; i++) {
		auto it = Y.find(S.at(i));
		if (it != Y.end()) {
			(it->second)++;
		} else {
			Y.emplace(S.at(i), 1);
		}
	}

	int max_intersection = 0;
	for (int i = 0; i < N - 1; i++) {
		// move cut position
		char c = S.at(i);
		if (--(Y.at(c)) == 0) {
			Y.erase(c);
		}
		auto it = X.find(c);
		if (it != X.end()) {
			(it->second)++;
		} else {
			X.emplace(c, 1);
		}
		// calculate intersection size
		int intersection_size = 0;
		for (auto x : X) {
			if (Y.find(x.first) != Y.end()) {
				intersection_size++;
			}
		}
		max_intersection = max(max_intersection, intersection_size);
	}

	cout << max_intersection << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
 
from collections import Counter
 
N = int(input())
 
A = list(map(int, input().split()))
 
c = Counter(A) #１、２などの数の書かれたボールが何個あるかについてのdict生成
 
s = 0
for key in c:
    s += c[key] * (c[key] - 1) // 2  #数列から何も除かなかった時の各ボールの選び方　の和
 
for num in A:
    print(s - c[num] * (c[num]-1) // 2 + (c[num]-1) * (c[num]-2) // 2)
    
#k番目のボールを除いたN-1個のボールから、k番目のボールと同じ整数が書かれたボールを選び出す方法の数
#をsから引くと各kに対する答えになる。

Measured memory_bytes: 82896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			String text = "NO";
			int mul = 0;
			int i = 0;
			for (i = 0; i < b; i++) {
				mul = mul + a;
				if (mul % b == c) {
					text = "YES";
					break;
				}
			}
			System.out.println(text);
		}
	}
}

Measured memory_bytes: 21844
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max() / 100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<Pll, LL>ma;
set<LL>st;
vector<LL>rest;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[310000], b[310000], sub[210000];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> n;
	t = n;
	while (t) {
		if (t == 1) {
			cout << "No" << endl;
			return 0;
		}
		if (t % 2 != 0)break;
		t /= 2;
	}
	cout << "Yes" << endl;
	m = n;
	n++;
	while (n > 1) {
		n /= 2;
		cnt++;
	}
	n = m;
	rep(i, (1LL << cnt) - 2) {
		cout << i + 1 << " " << i + 2 << endl;
	}
	cout << ((1LL << cnt) - 1) << " " << n + 1 << endl;
	rep(i, (1LL << cnt) - 2) {
		cout << n + i + 1 << " " << n + i + 2 << endl;
	}
	m = n - ((1LL << cnt) - 1);
	LL cur = (1LL << cnt) - 1;
	cur++;
	rep(i, m / 2) {
		cout << cur << " " << 1 << endl;
		cout << cur + 1 << " " << 1 << endl;
		cout << cur + 1 << " " << cur + n << endl;
		cout << cur << " " << cur + 1 + n << endl;
		cur+=2;
	}
	if (n % 2 == 0) {
		rep(i, n) {
			if ((1 << i)&n) {
				if (i == 1) {
					cout << n - 1 << " " << n << endl;
					cout << ((n - 2) ^ n) << " " << n * 2 << endl;
				}
				else {
					cout << (n ^ (1 << i)) << " " << n << endl;
					cout << (1 << i) << " " << n * 2 << endl;
				}
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2560
def readInts():
  return [int(i) for i in input().split()]

def readLine(n: int):
  return [input().split() for _ in range(n)]


n, q = readInts()
ps = readLine(n)

t = 0
while ps != []:
    p = ps.pop(0)
    pt = int(p[1])
    if pt <= q:
        t += pt
        print(p[0], t)
    else:
        t += q
        ps.append([p[0], pt - q])



Measured memory_bytes: 16852
import sys
readline = sys.stdin.readline

N,W = map(int,readline().split())

import numpy as np
dp = np.full(10 ** 5 + 1, W + 1, dtype = int)
dp[0] = 0

for i in range(N):
  w,v = map(int,readline().split())
  np.minimum(dp[:-v] + w, dp[v:], out = dp[v:])
  
for i in range(len(dp) - 1, -1, -1):
  if dp[i] <= W:
    print(i)
    break

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    string s;
    cin >> s;

    pl(s.substr(0,4)+" "+s.substr(4,8))

    return 0;
}

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

// queue の実装
int queue_data[N];
int head;
int tail;
int elements;

void init(void){
    head = 0;
    tail = 0;
    elements = 0;
}

bool enqueue(int val){
    if (elements>=N) return false;
    queue_data[tail] = val;
    tail = ++tail%N;
    elements++;
    return true;
}

int dequeue(void){
    if (head==tail) return -1;
    int ret = queue_data[head];
    head = ++head%N;
    elements--;
    return ret;
}

int rdm_access(int index){
    int effective_index = (head+index)%N;
    return queue_data[effective_index];
}

bool push_front(int val){
    if (elements>=N) return false;
    head = (head==0)?N-1:head-1;
    queue_data[head] = val;
    elements++;
    return true;
}

bool del_end(void){
    if (elements<=0) return false;
    tail = (tail==0)?N-1:tail-1;
    elements--;
    return false;
}

int main(){
    int n;
    init();
    cin >> n;
    for (int i=0;i<n;i++){
        int temp;
        cin >> temp;
        switch(temp){
            case 0:
                cin >> temp;
                if (temp==0){
                    cin >> temp;
                    push_front(temp);
                }else{
                    cin >> temp;
                    enqueue(temp);
                }
                break;
            case 1:
                cin >> temp;
                cout << rdm_access(temp) << endl;
                break;
            case 2:
                cin >> temp;
                if (temp==0)
                    dequeue();
                else
                    del_end();
        }

    }
    return 0;
}



Measured memory_bytes: 4564
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

h,w=mii()

if h==1 or w==1:
    print(1)
    exit()

if (h*w)%2==0:
    print(h*w//2)
else:
    print((h*w)//2 +1)







Measured memory_bytes: 65516
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
else:
    pro = 1;
    ok = True
    for el in A:
        pro *= el
        if(pro > 1e18):
            ok = False
            break

    if ok: print(pro)
    else: print(-1)


Measured memory_bytes: 87948