akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;


//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> sa(n+1);
    ll sum = 0;
    vector<ll> sumb(n);
    rep(i, n){
        cin >> a[i];
    }
    sa[0] = a[0];
    sa[n] = 0 - a[n-1];
    rep2(i, 1, n){
        sa[i] = a[i] - a[i-1];
    }

    rep(i, n+1){
        sum += abs(sa[i]);
    }

    rep(i, n){
        sumb[i] = sum - abs(sa[i]) - abs(sa[i+1]);
    }

    rep(i, n){
        cout << sumb[i] + abs(sa[i] + sa[i+1]) << "\n";
    }

    
    
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
long long int dp[100001];
int h[100001];

int solve(int n){
      for(int i=2; i<=n; i++)
      dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
      return dp[n];
}

int main(){
      int n;
      cin>>n;
      for(int i=0; i<n; i++){
            cin>>h[i];
            dp[i]=-1;
      }
      dp[0]=0;
      dp[1]=abs(h[1]-h[0]);
      cout<<solve(n-1);
}

Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool ok[10][10];
int  N, M;
int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        ok[a][b] = true;
        ok[b][a] = true;
    }
    vector<int> sq;
    for(int i = 1; i <= N; i++){
        sq.push_back(i);
    }
    int ans = 0;
    do{
        bool flag = true;
        for(int i = 1; i < N; i++){
            if(!ok[sq[i - 1]][sq[i]]) flag = false;
        }
        if(flag) ans++;
    }while(next_permutation(sq.begin() + 1, sq.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], q, x, d;


int32_t main(){
INIT
cin>>x>>k>>d;
x=abs(x);
int f=((x-x%d)/d);
if(f>k){
    cout<<(x-d*k); return 0;
}
int sc=k-f;
if(sc%2==0){
    cout<<x%d;
}
else{
    cout<<(d-x%d);
}


return 0;
}





Measured memory_bytes: 3688
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int botton = sc.nextInt();
        int botton2 = sc.nextInt();
        int sum = 0;
        for (int i = 0; i <= 1; i++) {
            if (botton > botton2) {
                sum += botton;
                botton--;
            } else {
                sum += botton2;
                botton2--;
            }
        }
        System.out.println(sum);
    }

}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(void){
  int n,i,j,value;
  char symbol;
  int s[13],h[13],c[13],d[13];
  for(i=0;i<13;i++){
    s[i]=0;
    h[i]=0;
    c[i]=0;
    d[i]=0;
  }
  cin>>n;
  for(i=0;i<n;i++){
    cin>>symbol>>value;
    if(symbol=='S'){
      s[value-1]++;
    }else if(symbol=='H'){
      h[value-1]++;
    }else if(symbol=='C'){
      c[value-1]++;
    }else{
      d[value-1]++;
    }
  }
  for(i=0;i<13;i++){
    if(s[i]==0){
      cout<<"S "<<i+1<<endl;
    }
  }
  for(i=0;i<13;i++){
    if(h[i]==0){
      cout<<"H "<<i+1<<endl;
    }
  }
  for(i=0;i<13;i++){
    if(c[i]==0){
      cout<<"C "<<i+1<<endl;
    }
  }
  for(i=0;i<13;i++){
    if(d[i]==0){
      cout<<"D "<<i+1<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int grid[1000][1000] = {};
int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	if (H % h != 0) {
		cout << "Yes" << endl;
		for (int i = 0;i < H;++i) {
			for (int q = 0;q < W;++q) {
				if (i % h == h - 1) {
					grid[i][q] = -10000 * (h - 1) - 1;
				}
				else {
					grid[i][q] = 10000;
				}
			}
		}
	}
	else if (W % w != 0) {
		cout << "Yes" << endl;
		for (int i = 0;i < H;++i) {
			for (int q = 0;q < W;++q) {
				if (q % w == w - 1) {
					grid[i][q] = -10000 * (w - 1) - 1;
				}
				else {
					grid[i][q] = 10000;
				}
			}
		}
	}
	else {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0;i < H;++i) {
		for (int q = 0;q < W;++q) {
			cout << grid[i][q] << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    string s;
    int count = 0;
    
    cin >> s;
    for(int i = 0; i < 3; i++)
        if(s[i] == 'o')
            count++;
            
    cout << 700 + count * 100 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  if (str[0] == '7' | str[1] == '7' | str [2] == '7') {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int b[n];
    for (int i = 0; i < n; i++) cin >> b[i];
    bool x[30] = {0};
    for (int i = 29; i >= 0; i--) {
        if (n % 2) {
            for (int j = 0; j < n; j++) {
                x[i] ^= (a[j] >> i) % 2;
                x[i] ^= (b[j] >> i) % 2;
            }
        }
        for (int j = 0; j < n; j++) {
            a[j] %= 1 << i;
            b[j] %= 1 << i;
        }
        sort(b, b + n);
        for (int j = 0; j < n; j++) {
            x[i] ^= (b + n - lower_bound(b, b + n, (1 << i) - a[j])) % 2;
        }
    }
    int res = 0;
    for (int i = 0; i < 30; i++) {
        res += x[i] << i;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 1792
X,N=map(int,input().split())
if N==0:
    print(X)
    exit()
else:
    p=list(map(int,input().split()))

p.sort()

if X in p:
    ind=p.index(X)
    i=1
    while True:
        if (X-i) in p and (X+i) in p :
            i+=1
        elif (X-i) not in p:
            print(X-i)
            break
        else:
            print(X+i)
            break
else:
    print(X)

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

int main(){
  int N;
  cin >> N;
  
  vector<int> C(N),V(N);
  for(int i=0;i<N;i++){
    cin >> C.at(i);
  }
  for(int j=0;j<N;j++){
    cin >> V.at(j);
  }
  
  vector<int> Z;
  for(int k=0;k<N;k++){
    Z.push_back(C.at(k)-V.at(k));
  }

  int ans=0;
  for(int l=0;l<N;l++){
    if(Z.at(l)>0){
      ans +=Z.at(l);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from fractions import gcd
# https://img.atcoder.jp/agc028/editorial.pdf
N, M = map(int,input().split())
S = input()
T = input()

L = int((N*M)/gcd(N, M))

gcded = gcd(N,M)
n = N//gcded
m = M//gcded
for i in range(gcded):
  if S[i*n] != T[i*m]:
    print(-1)
    exit()

print(L)


Measured memory_bytes: 5432
/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  static long G(long x){
    long n = x/4;
    long ret = 0;
    for(long k = 4*n; k<=x; k++){
      ret ^= k; 
    }
    return ret;
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong(), B = sc.nextLong();
    System.out.println(G(B) ^ G(A-1));
  }
}


Measured memory_bytes: 35740
cards = [ raw_input() for _ in xrange(3) ]
indexes = [ 0 for _ in xrange(3) ]
player2num = { "a" : 0, "b" : 1, "c" : 2} 
num2winner = { 0 : "A", 1 : "B", 2 : "C"}

turn_player = 0
while True:
    if indexes[turn_player] == len(cards[turn_player]):
        print num2winner[turn_player]
        break
    next_turn_player = cards[turn_player][indexes[turn_player]]
    indexes[turn_player] += 1
    turn_player = player2num[next_turn_player]

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;


int main(){
    ll h,a; cin>>h>>a;
    if(h%a ==0)cout<<h/a<<endl;
    else cout<<h/a+1<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;

int main() {
	string A,B,C;
	cin>>A>>B>>C;
	cout<<char(A[0]-'a'+'A')<<char(B[0]-'a'+'A')<<char(C[0]-'a'+'A');
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

	int k, t;
	cin >> k >> t;

	vector<int> a(t);

	rep(i, t) {
		cin >> a[i];
	}

	sort(a.begin(), a.end(), greater<>());

	ll ans;
	ans = max(a[0] - 1 - (k - a[0]), 0);

	cout << ans;

	return 0;
}


ll gcd(ll a, ll b) {
	if (a % b == 0)return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i =0; i < n ;i++)
using namespace std;
int D[32][32];
int co[32][3];

int main(){
    int N, C, c;
    int ans = 1<<30;
    cin >> N >> C;

    for(int i =0; i < C; i++){
        for(int j =0; j < C; j++){
            cin >> D[i][j];
        }
    }

    for(int i =0; i < N; i++){
        for(int j =0; j < N; j++){
            cin >> c;
            co[c-1][(i+j)%3]++;
        }
    }

   
    rep(i, C)rep(j, C)rep(k, C){
        if (!(i==j || i==k || k==j)){
            long long a =0;
            rep(m, C) a+=co[m][0] * D[m][i];
            rep(m, C) a+=co[m][1] * D[m][j];
            rep(m, C) a+=co[m][2] * D[m][k];
            if(ans > a) ans =a;

        }
    }
    
        

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

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(M)]
G = [0, N]
def overlap(a, b):
    if max(a[0], b[0]) > min(a[1], b[1]):
        return [0, 0]
    return [max(a[0], b[0]), min(a[1], b[1])]
for m in range(M):
    G = overlap(G, A[m])
if G == [0, 0]:
    print(0)
else:
    print(G[1] - G[0] + 1)

Measured memory_bytes: 27332
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        String s = sc.next();
        sc.close();

        // 主処理
        String[] arr = new String[n];
        int countA = 0;
        int countB = 0;
        for (int i = 0; i < n; i++) {
            int count = countA + countB;
            if (s.charAt(i) == 'a') {
                if (count < a + b) {
                    arr[i] = "Yes";
                    countA++;
                } else {
                    arr[i] = "No";
                }
            } else if (s.charAt(i) == 'b') {
                if (count < a + b && countB < b) {
                    arr[i] = "Yes";
                    countB++;
                } else {
                    arr[i] = "No";
                }
            } else {
                arr[i] = "No";
            }
        }

        String result = String.join("\n", arr);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 28488
#include <stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define BLACK 2
#define GRAY 1
int n;
int a[MAX][MAX];

int omomi(void);

int main(){
int i,j,e;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&e);
			if(e == -1)a[i][j] = INFTY;
			else a[i][j] = e;
		}
	}

	printf("%d\n",omomi());
	return 0;
}

int omomi(){
	int u,minv,i,sum=0,v;
	int d[MAX],p[MAX],color[MAX];

	for(i=0;i<n;i++){
		d[i] = INFTY;
		p[i] = -1;
		color[i] = 0;
	}

	d[0] = 0;

	while(1){
		minv = INFTY;
		u = -1;
		for(i = 0;i<n;i++){
			if(minv > d[i] && color[i] != BLACK){
				u = i;
				minv = d[i];
			}
		}
		if(u == -1)break;
		color[u] = BLACK;
		for(v = 0;v<n;v++){
			if(color[v] != BLACK && a[u][v] != INFTY){
				if(d[v] > a[u][v]){
					d[v] = a[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
		for(i = 0;i<n;i++){
			if(p[i] != -1)sum += a[i][p[i]];
		}
	
	return sum;
}

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

int main(void)
{
    string odd, even;
    int i;
    cin >> odd;
    cin >> even;
    if (odd.size() == even.size())
    {
        for (i = 0; i < odd.size(); i++)
        {
            cout << odd[i];
            cout << even[i];
        }
        cout << endl;
    }
    else if (odd.size() > even.size())
    {
        for (i = 0; i < even.size(); i++)
        {
            cout << odd[i];
            cout << even[i];
        }
        cout << odd[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int v[1001],w[1001],dp[10001][10001];
int N,W;


int main(){
    scanf("%d%d",&N,&W);
    for(int i = 0;i <N;i++)
        scanf("%d%d",&v[i],&w[i]);
    for(int i = 1;i <= N;i++)
        for(int j = 0;j <= W;j++){
            if(j - w[i-1] < 0)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]] + v[i-1]);
        }
    printf("%d\n",dp[N][W]);

    return 0;
}


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

int main()
{
  int n, cmp;
  char s1[101], s2[101];
  int p1 = 0, p2 = 0;

  scanf("%d", &n);
  while (n--) {
    scanf("%s %s", s1, s2);
    cmp = strcmp(s1, s2);
    if (cmp > 0) {
      p1 += 3;
    } else if (cmp < 0) {
      p2 += 3;
    } else {
      p1++;
      p2++;
    }
  }
  printf("%d %d\n", p1, p2);
}



Measured memory_bytes: 2148
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var m = mutableListOf<Pair<String, Int>>()
    for (i in 0 until n) {
        val (a, b) = readLine()!!.split(" ")
        m.add(a to b.toInt())
    }
    val sorted = m.sortedWith(kotlin.comparisons.compareBy({ it.first }, { it.second * -1 }))
    sorted.map { println(m.indexOf(it) + 1) }
}


Measured memory_bytes: 36516
fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val ansSet = Array(11) { mutableSetOf<String>() }
    (1..9).forEach { ansSet[1].add(it.toString()) }

    for (i in 2..10) {
        for (v in ansSet[i - 1]) {
//            left
            val lv = v.first().toString().toInt()
            if (lv != 1) ansSet[i].add((lv - 1).toString() + v)
            ansSet[i].add(lv.toString() + v)
            if (lv != 9) ansSet[i].add((lv + 1).toString() + v)

//            right
            val rv = v.last().toString().toInt()
            if (rv != 0) ansSet[i].add(v + (rv - 1).toString())
            ansSet[i].add(v + rv.toString())
            if (rv != 9) ansSet[i].add(v + (rv + 1).toString())
        }
    }
    val ansList = (1..10).flatMap {x->
        ansSet[x].map { it.toLong() }
    }
    println(ansList.sorted()[k - 1])
}


Measured memory_bytes: 108528
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	double n,m,d,ans=0;;
	cin>>n>>m>>d;
	double type=(n-d)/pow(n,2);
	if(d==0)ans=(m-1)*type;
	else ans=2*(m-1)*type;
	print(setprecision(20)<<ans);
}

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

m = A[N-1] - A[0]

for i in range(N - 1):
    n = (K - A[i+1]) + A[i]
    # print("i:{}, n:{}".format(i, n))

    if n < m:
        m = n

print(m)


Measured memory_bytes: 25836
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>a(3);
  for (int i=0;i<a.size();i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  cout<<a.at(2)*10+a.at(1)+a.at(0)<<endl;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:100000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
#define debug puts
#define setp cout << fixed << setprecision(15)
#define fst ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
const int N=3e5+5;
const int MOD=998244353;
char s[N];
int a[N];
int pre[N];
int n;

int cul(int x){
    int ans=0;
        ans+= pre[n]-pre[x];
        ans+=x-1-(pre[x-1]);
    return ans;
}
int main(void){
    fst;
    cin >>n >> s+1;
    for(int i=1;i<=n;i++){
        if(s[i]=='W')   a[i]=-1;
        else    a[i]=1;
    }
    for(int i=1;i<=n;i++){
        pre[i]=pre[i-1];
        if(a[i]==1) pre[i]++;
    }
    int mn=1e9;
    for(int i=1;i<=n;i++){
        mn=min(mn,cul(i));
    }
    cout << mn << endl;
    return 0;
}
void bef0re_submit(){
    debug("Make sure the algorithm is right!");
    debug("LONG LONG!!!");
    debug("n==0?1?2?3?");
    debug("Make sure output format is right/// Yes??YES  (%.20LF)???");
    debug("if all meet,run with special situation!!!");
    debug("I confirm that I have done all above");

    debug("If u know brute,consider fast,binary(log) or tree?");
}


/*********

*********/


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

int main() {
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    int res = 1;
    int d;
    if(a[0] > a[1]) d = 1;
    else if(a[0] < a[1]) d = -1;
    else d = 0;
    for (int i = 1; i < n; i++)
    {
        if(d == 0) {
            if(a[i-1] > a[i]) d = 1;
            else if(a[i-1] < a[i]) d = -1;
            else d = 0;
        }
        else {
            if(d < 0 && a[i-1] > a[i]) {
                res++;
                i++;
                if(a[i-1] > a[i]) d = 1;
                else if(a[i-1] < a[i]) d = -1;
                else d = 0;
            }
            else if(d > 0 && a[i-1] < a[i]) {
                res++;
                i++;
                if(a[i-1] > a[i]) d = 1;
                else if(a[i-1] < a[i]) d = -1;
                else d = 0;
            }
        }
    }

    cout << res << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  if (H % h == 0 && W % w == 0) {
    no();
  }
  int x = (1000000000 - 1) / (h * w - 1);
  vector<vi32> ans(H, vi32(W, x));
  for (int i = h - 1; i < H; i += h) {
    for (int j = w - 1; j < W; j += w) {
      ans[i][j] = -(h * w * x - x + 1);
    }
  }
  cout << "Yes" << '\n';
  rep(i, H) cout << ans[i] << '\n';
}


Measured memory_bytes: 4264
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = Integer.parseInt(scan.nextLine());
		String[] value = scan.nextLine().split(" ");
		String[] cost = scan.nextLine().split(" ");

		int ans = 0;


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

			int temp = Integer.parseInt(value[i]) - Integer.parseInt(cost[i]);

			ans = temp > 0 ? ans + temp : ans;
		}


		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		Long sum = 0L;
		for(int i = 1; i <= n; i++) {
			String s = String.valueOf(i);
			Long ssum = 0L;
			for(char c : s.toCharArray()) {
				ssum += Integer.valueOf(String.valueOf(c));
			}
			if(a <= ssum && b >= ssum) {
				sum += i;
			}
		}
		System.out.println(sum);
	}
}

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

long long mod = 1000000007;

class UnionFind
{
public:
   vector<int> parent;
   UnionFind(int N)
   {
      for (int i = 0; i < N; i++)
      {
         parent.push_back(-1);
      }
   }
   int root(int A)
   {
      if (parent[A] < 0)
         return A;
      return parent[A] = root(parent[A]);
   }
   int size(int A)
   {
      return -parent[root(A)];
   }

   bool unite(int A, int B)
   {
      A = root(A);
      B = root(B);
      if (A == B)
         return false;
      if (size(A) < size(B))
         swap(A, B);
      parent[A] += parent[B];
      parent[B] = A;
      return true;
   }
};

int main(void)
{
   int N;
   cin >> N;
   vector<vector<int>> D(N, vector<int>(2));
   for (int i = 0; i < N; i++)
   {
      for (int j = 0; j < 2; j++)
      {
         cin >> D[i][j];
      }
   }
   bool flag = false;
   for (int i = 0; i < N - 2; i++)
   {
      if (D[i][0] == D[i][1] && D[i + 1][0] == D[i + 1][1] && D[i + 2][0] == D[i + 2][1])
      {
         flag = true;
         break;
      }
   }
   if (flag)
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 3556
#幸福度の最小値で二分探索

##右手左手による重複の処理
##同一の値や和がたまたま一致する重複の処理
import bisect
n,m = map(int, input().split())
a = list(map(int, input().split( )))
a.sort()
a2 = [a[i]*2 for i in range(n)]

mn = -1
mx = (a[-1]+1)*2
md = (mx+mn)//2
while mx-mn>1:
    md = (mx+mn)//2
    cnt = 0
    for i in range(n):
        tmp = md-a[i]
        idx = bisect.bisect_left(a, tmp)
        cnt += n-idx

    if cnt >= m:
        mn = md
    else:
        mx = md
ans = 0

acc = []
sm = 0
for i in range(n):
    sm += a[i]
    acc.append(sm)
acc.append(0)##一つも足さない場合
#iは右手とする
for i in range(n-1,-1,-1):
    idx = bisect.bisect_left(a,mx-a[i])
    tmp2 = n-idx
    if m>=tmp2:
        ans += a[i] * tmp2
        ans += (acc[n-1] - acc[idx-1])
        m-=tmp2
    else:
        ans += a[i]*m
        ans += acc[n-1]-acc[n-1-m]
        break
if m:
    ans += mn*m

print(ans)
    

    


Measured memory_bytes: 61504
import collections
from math import ceil
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(input())
x = []
for i in range(n):
	s = list(input())
	s.sort()
	z = (' '.join(map(str, s)))
	x.append(z)
c = collections.Counter(x)

ans = 0
for y in c.values():
	if y > 1:
		ans += combinations_count(y,2)
print(ans)

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

int n, x1=0, x2, y1=0, y2, t1=0, t2;

int main(void){
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> t2 >> x2 >> y2;
		int dx = abs(x2-x1), dy = abs(y2-y1), dt = t2-t1;
		if(dx+dy>dt || dt%2!=(dx+dy)%2){
			cout << "No" << endl;
			return 0;
		}
		x1=x2;
		y1=y2;
		t1=t2;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

X = input_int()

for a in range(2000):
    A = a - 1000

    for b in range(2000):
        B = b - 1000
        if A ** 5 - B ** 5 == X:
            print("{} {}".format(A, B))
            exit()

Measured memory_bytes: 9112
#include <iostream>
     
    using namespace std;
     
    int main( ){
    int n;
    int sum = 0;
cin >> n;
    for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum = (sum + a) & 1;
    }
    if (sum & 1) cout << "NO\n";
    else cout << "YES\n";
    return 0;
    }

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  if (max(a, b) - min(a, b) > w) {
    cout << max(a, b) - min(a, b) - w << endl;
  } else if (max(a, b) - min(a, b) <= w) {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   string s;
   cin>>s;
   
   if(s[s.length()-1]=='s')
   {
     s.push_back('e');
     s.push_back('s');
   }
   else
   {
     s.push_back('s');
   }
   
   cout<<s<<"\n";
   return 0;
 }

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

void c()
{
   int n, k;
    cin >> n >> k;
    map<int, int> a;
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        if(!a.count(temp))
        {
            a[temp] = 1;
        } else{
            a[temp]++;
        }
    }
    if(a.size() <= k)
    {
        cout << 0 << endl;
    }else{
        vector<int> result;
        for(auto e : a)
        {
            result.push_back(e.second);
        }
        sort(result.begin(), result.end());
        int count = 0;
        for(int i = 0; i < a.size() - k; i++)
        {
            count += result[i];
        }
        cout << count << endl;
    }
}

void d()
{
    int n;
    cin >> n;
    vector<pair<long long int, int>> a;
    vector<long long int> a2(n);
    for (int i = 0; i < n; ++i) {
        long long int temp;
        cin >> temp;
        a2[i] = temp;
        a.push_back({temp, i});
    }
    sort(a.begin(), a.end());
    vector<pair<int, int>> result;
    if(abs(a[0].first) < abs(a.back().first))
    {
        for(int i = 0; i < n; i++)
        {
            if(a2[i] != a.back().first)
            {
                a2[i] += a.back().first;
                result.push_back({a.back().second, i});
            }
        }
        for(int i = 0; i < n - 1; i++)
        {
            if(a2[i] > a2[i + 1])
            {
                a2[i + 1] += a2[i];
                result.push_back({i, i + 1});
            }
        }
    }else{
        for(int i = 0; i < n; i++)
        {
            if(a2[i] != a.front().first)
            {
                a2[i] += a.front().first;
                result.push_back({a.front().second, i});
            }
        }
        for(int i = n - 1; i >= 1; i--)
        {
            if(a2[i] < a2[i - 1])
            {
                a2[i - 1] += a2[i];
                result.push_back({i, i - 1});
            }
        }
    }
    cout << result.size() << endl;
    for(auto e : result)
    {
        cout << e.first + 1 << " " << e.second + 1<< endl;
    }
}

int main() {
    d();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;} 
int main(void)
{
    char s[3];
  	scanf("%s",&s);
    if(s[1]=='R')
      printf("ABC");
  else
    printf("ARC");
}

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

int gcd3(int a, int b, int c){
    int pick=min(a,min(b,c));
    int ans;
    for(int i=1; i<pick+1; i++){
        if(a%i==0 && b%i==0 && c%i==0){
            ans=i;
        }
    }
    return ans;
}

int main() {
    int K; cin >>K;
    int sum=0;
    for(int i=1; i<K+1; i++){
        for(int j=1; j<K+1; j++){
            for(int k=1; k<K+1; k++){
                sum=sum+gcd3(i,j,k);
            }
        }
    }
    cout << sum << endl;
}


    

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    vector<string> ss(3);
    cin>>ss[0]>>ss[1]>>ss[2];
    queue<char> A,B,C;
    vector<queue<char>> card(3);
    for(int i=0;i<3;i++){
        for(int j=0;j<ss[i].size();j++){
            card[i].push(ss[i][j]);
        }
    }
    char turn=0;
    while(!card[turn].empty()){
        char newturn=card[turn].front()-'a';
        card[turn].pop();
        turn=newturn;
    }
    turn+='A';
    cout<<turn<<endl;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ld x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
ll fact_[5000000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 5000000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[300000];
signed main() {
	cin >> n;
	int ans = Inf, sum = 0, res = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	ans = min(ans, sum);
	for (int i = 0; i < n; i++) {
		sum -= a[i];
		res += a[i];
		ans = min(ans, abs(sum - res));
	}
	cout << ans << endl;
}

Measured memory_bytes: 3840
# https://atcoder.jp/contests/abc138/tasks/abc138_c


n = int(input())
gu = sorted(list(map(float, input().split())))
count = 0

while True:
    if len(gu) > 2:
        d = (gu.pop(0) + gu.pop(0)) / 2
        gu.insert(0, d)
    if len(gu) == 2:
        count = (gu.pop() + gu.pop()) / 2
        break

print(count)


Measured memory_bytes: 2940
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

struct integ {
	ll num; ll val;
};
ll const MAX = 100005;
integ a[MAX];

bool order(integ x, integ y) {
	return x.num < y.num;
}

ll m_ = 0;

int main() {
	ll n;
	ll m;
	cin >> n >> m;
	REP(i, 1, n) {
		ll x, y;
		cin >> x >> y;
		a[i] = { x,y };
	}
	SORT_O(a, n, order);
	ll ans = 0;
	while (m >= (1 << m_)) {
		m_++;
	}
	while (m_ >= 0) {
		ll t = (1 << m_);
		ll cnt = 0;
		if ((t & m) != 0) {
			REP(i, 1, n) {
				if (a[i].num < t) {
					cnt += a[i].val;
				}
				if(a[i].num>=t) {
					a[i].num -= t;
				}
			}
			//cout << cnt << endl;
			ans = max(ans, cnt);
			/*
			REP(i, 1, n) {
				cout << a[i].num << " " << a[i].val << endl;
			}
			*/
		}
		m_--;
	}
	ll cnt = 0;

	REP(i, 1, n) {
			if (a[i].num == 0) cnt += a[i].val;
		}
	ans = max(cnt, ans);

	cout << ans << endl;
}

Measured memory_bytes: 1792
H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(H)]
Q=int(input())
X=[[[0,0] for _ in range((H*W)//D+1)] for _ in range(D)]
for i in range(H):
    for j in range(W):
        X[A[i][j]%D][A[i][j]//D][0]=i
        X[A[i][j]%D][A[i][j]//D][1]=j
M=[[0] for _ in range(D)]
for d in range(D):
    for k in range((H*W)//D):
        M[d].append(abs(X[d][k+1][0]-X[d][k][0])+abs(X[d][k+1][1]-X[d][k][1])+M[d][k])

for i in range(Q):
    L,R=map(int,input().split())
    print(M[L%D][R//D]-M[L%D][L//D])

Measured memory_bytes: 90716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const ll MOD=1e9+7;

ll factorial[200010];
ll inverse_factorial[200010];

ll add(ll x, ll y){return (x+y)%MOD;}
ll mlt(ll x, ll y){return (x*y)%MOD;}
ll sbt(ll x, ll y){return (MOD+(x-y)%MOD)%MOD;}

ll power(int x, int n){
  ll v=1;
  while(n>0){
    if(n%2!=0)v=mlt(v, x);
    x=mlt(x,x);
    n/=2;
  }
  return v;
} 

ll inv(ll x){return power(x, MOD-2);}

void fct(){
  factorial[0]=1;
  for (int i=0;i<200009;++i){factorial[i+1]=mlt(factorial[i], i+1);}
}

void ifct(){
  inverse_factorial[200009]=inv(factorial[200009]);
  for (int i=200009;i>=1;--i){
    inverse_factorial[i-1]=mlt(inverse_factorial[i],i);
  }
}

ll comb(int n, int k){
  if (n<0|| k<0|| k>n)return 0;
  return mlt(factorial[n], mlt(inverse_factorial[n-k], inverse_factorial[k]));
}

int main(){
  fct();ifct();
  int n;cin>>n;
  vi a;map<int, vi> table;
  int cnt=0;
  for (int i=0;i<n+1;++i){
    int a_;cin>>a_;a.push_back(a_);
    table[a_].push_back(i);
    int m=table[a_].size();
    if(m==2) break;
    cnt++;
  }

  int p=table[a[cnt]][0], q=table[a[cnt]][1];
  int l=n-q+p, m=q-p-1;
  for (int k=1;k<=n+1;++k){
    ll ans=comb(n-1, k);
    ans=add(ans, comb(l, k-1));
    ans=add(ans, 2*(sbt(comb(n-1, k-1),comb(l, k-1))));
    ans=add(ans, comb(n-1, k-2));
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 15608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String l = sc.nextLine();
		String[] arr1 = l.split(" ");
		l = sc.nextLine();
		String[] arr2 = l.split(" ");

		Integer dSum = 0;
		for(String s : arr2) {
			dSum += Integer.valueOf(s);

		}
		Integer res = Integer.valueOf(arr1[0]) - dSum;
		System.out.println(res >= 0 ? res : -1);
		sc.close();
	}
}


Measured memory_bytes: 31004
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}



int main(){
	ll a, b;
	cin>>a>>b;
	if(a>0) cout<<"Positive"<<endl;
	else if(a<=0&&0<=b) cout<<"Zero"<<endl;
	else {
		b = min(-1LL, b);
		cout<<((a-b)%2?"Positive":"Negative")<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
list = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    list[b-1][f-1][r-1] += v

for k in range(4):
    for j in range(3):
        for i in range(10):
            print ("", end=" ")
            print (list[k][j][i], end = "")
        print("")
    if k != 3:
        print("####################")


Measured memory_bytes: 5636
#include<stdio.h>

main(){
	
	int r, c, i, j, a[101][101]={0};
	
	
	scanf("%d%d",&r,&c);
	
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(i=0;i<r+1;i++){
		for(j=0;j<c;j++){
			a[i][c]+=a[i][j];
		}
	}
	for(i=0;i<r;i++){
		for(j=0;j<c+1;j++){
			a[r][j]+=a[i][j];
		}
	}
	
	for(i=0;i<r+1;i++){
		for(j=0;j<c;j++){
			printf("%d ",a[i][j]);
		}
		printf("%d\n",a[i][c]);
	}
	
	return 0;
}

Measured memory_bytes: 648
import heapq
from collections import deque, Counter
N, K = map(int, input().split())
P = list(map(int, input().split()))
#ans = []
q = deque()
q_idx = []
L = []
for i, p in enumerate(P):
    while q and p <= q[-1][1]:
        idx, _ = q.pop()
        heapq.heappush(q_idx, idx)
    q.append((i, p))
    #print(q, q_idx)
    L.append(q_idx[0] if q_idx else -1)
    #ans.append(q[0][1])
    if q and q[0][0] <= i+1-K:
        idx, _ = q.popleft()
    if q_idx and q_idx[0] <= i+1-K:
        heapq.heappop(q_idx)
L = L[K-1:]

P = [-p for p in P]
P.reverse()
q = deque()
q_idx = []
R = []
for i, p in enumerate(P):
    while q and p <= q[-1][1]:
        idx, _ = q.pop()
        heapq.heappush(q_idx, idx)
    q.append((i, p))
    #print(q, q_idx)
    R.append(N - 1 - q_idx[0] if q_idx else -1)
    #ans.append(q[0][1])
    if q and q[0][0] <= i+1-K:
        idx, _ = q.popleft()
    if q_idx and q_idx[0] <= i+1-K:
        heapq.heappop(q_idx)
R = R[K-1:]
R.reverse()

#for l, r in zip(L, R):
print(len(Counter(zip(L, R))))


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

def f(n):
    if n%2==0:
        return int(n/2)
    else:
        return 3*n+1
    
s = int(input())
a = []

for i in range(1000000):
    a.append(s)
    s = f(s)
    if len(a)!=len(set(a)):
        print(i+1)
        break

Measured memory_bytes: 3316
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,m = readInts()

ans = (1900*m+(n-m)*100)*2**m

print(ans)

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

int main() {

    long long n, a, cont = 0;
    vector<long long> nums;

    cin >> n;

    while(n--) {
        cin >> a;
        if(a%2 == 0) nums.push_back(a);
    }

    for(long long i = 0; i < nums.size(); i++) {
        while(nums[i]%2 == 0) {
            cont++;
            nums[i] = nums[i]/2;
        }
    }

    cout << cont << endl;

    return 0;
}

Measured memory_bytes: 512
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = [[] for i in range(n)]
    for i in range(60):
        c = 0
        for x in a:
            if (x >> i) & 1:
                c ^= 1
        for j in range(n):
            x = (a[j] >> i) & 1
            b[j].append(x ^ c)

    for x in b:
        print(int("".join(str(i) for i in x[::-1]), 2))
main()


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

template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

using ll=long long;
const long long LINF=1e18;
ll n,a,b,c,d;
map<ll,ll> m;
ll f(ll x){
  if(!x)return LINF;
  if(x==1)return d;
  if(m[x])return m[x];
  ll res=LINF;
  if(res/d>x-100)chmin(res,x*d);
  chmin(res,f((x+1)/2)+a+(2-x%2)*d);
  chmin(res,f((x+2)/3)+b+(3-x%3)*d);
  chmin(res,f((x+4)/5)+c+(5-x%5)*d);
  chmin(res,f(x/2)+a+(x%2)*d);
  chmin(res,f(x/3)+b+(x%3)*d);
  chmin(res,f(x/5)+c+(x%5)*d);
  return m[x]=res;
}

int main(){
  int t;cin>>t;
  while(t--){
    cin>>n>>a>>b>>c>>d;
    m.clear();
    cout<<f(n)<<endl;
  }
}


Measured memory_bytes: 4428
class UnionFind:
  par = None
  
  def __init__(self, n):
    self.par = [0] * n
    
  def root(self, x):
    if(self.par[x] == 0):
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.root(self.par[x])
  
  def unite(self, x, y):
    if(self.root(x) != self.root(y)):
      self.par[self.root(x)] = self.root(y)
      
  def same(self, x, y):
    return self.root(x) == self.root(y)
  
N, M = list(map(int, input().split()))
UF = UnionFind(N)
for i in range(M):
  A, B = list(map(int, input().split()))
  UF.unite(A - 1, B - 1) 
ans = 0
for i in range(N):
  if(UF.par[i] == 0):
    ans += 1
print(ans - 1)  


Measured memory_bytes: 80252
dissembly = {}
def factoring(N):
	from math import sqrt
	global dissembly
	search_maxval = sqrt(N) + 1
	i = 2
	while True:
		if N == 1 or i == search_maxval:
			break

		if N % i == 0:
			if i in dissembly:
				dissembly[i] += 1
			else:
				dissembly[i] = 1

			N /= i

		else:
			i += 1


n = int(input())
ans = 1
for i in range(2,n+1):
	factoring(i)


for val in dissembly.values():
	ans *= (val+1)
	ans %= ((10 ** 9) + 7)

print(ans)


Measured memory_bytes: 3064
import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((), cache=True)
def compute_small_f():
    popcount = np.empty(1 << 18, np.int64)
    popcount[0] = 0
    for n in range(18):
        popcount[1 << n:1 << n + 1] = popcount[:1 << n] + 1
    f = np.empty(1 << 18, np.int64)
    f[0] = 0
    for n in range(1, 1 << 18):
        f[n] = 1 + f[n % popcount[n]]
    return f

@njit((i8[:], i8[:]), cache=True)
def main(X, f):
    N = len(X)
    popX = X.sum()
    MOD1 = popX + 1
    MOD2 = popX - 1
    if popX == 1:
        MOD2 = 1
    pow1 = np.ones_like(X)
    pow2 = np.ones_like(X)
    for n in range(1, N):
        pow1[n] = 2 * pow1[n - 1] % MOD1
        pow2[n] = 2 * pow2[n - 1] % MOD2

    X1, X2 = 0, 0
    for x in X:
        X1 = (2 * X1 + x) % MOD1
        X2 = (2 * X2 + x) % MOD2

    ans = np.empty(N, np.int64)
    for i in range(N):
        x = X[N - 1 - i]
        if x == 0:
            nxt = (X1 + pow1[i]) % (popX + 1)
            ans[i] = 1 + f[nxt]
        elif x == 1:
            if popX == 1:
                ans[i] = 0
            else:
                nxt = (X2 - pow2[i]) % (popX - 1)
                ans[i] = 1 + f[nxt]
    return ans[::-1]

N = int(readline())
X = np.array(list(read().rstrip()), np.int64) - ord('0')
ans = main(X, compute_small_f())
print('\n'.join(map(str, ans.tolist())))

Measured memory_bytes: 128052