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

using namespace std;
using ll = long long;


int main()
{
    ll N,K;cin >> N >> K;
    vector<ll> A,F;
    for(int i = 0;i < N;i++){
        ll c;cin >> c;
        A.push_back(c);
    }
    for(int i = 0;i < N;i++){
        ll c;cin >> c;
        F.push_back(c);
    }
    sort(A.begin(), A.end());
    sort(F.begin(), F.end());
    reverse(F.begin(), F.end());
    ll ok = 1e18;
    ll ng = -1;
    auto check = [&](ll a){
        ll _K = K;
        for(int i = 0;i < N;i++){
            ll usi = a / F.at(i);
            if(usi < A.at(i)){
                _K -= A.at(i) - usi;
            }
        }
        return _K >= 0;
    };
    while(ok - ng > 1){
        ll mid = (ok + ng)/2;
        //cout<<mid<<endl;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout<<ok<<endl;
}


Measured memory_bytes: 5488
#include <iostream>

using namespace std;
int dp[2005] = {0,0,0,1,1};
int main()
{
    int s;
    cin>>s;
    if(s>4)
    {
        for(int i = 5;i<=s;i++)
        {
            dp[i] = (dp[i-3]+dp[i-1])%1000000007;
        }
    }
    cout<<dp[s]<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	clock_t begin = clock();
	int n, k, r, s, p;
	cin >> n >> k;
	cin >> r >> s >> p;
	string str;
	cin >> str;
	int ans = 0;
	string used = "";
	for (int i = 0; i < int(str.size()); i++) {
		if (i < k) {
			if (str[i] == 'r')
				ans += p;
			if (str[i] == 'p')
				ans += s;
			if (str[i] == 's')
				ans += r;
		}
		else {
			if (str[i] == str[i - k])
				str[i] = '$';
			else {
				if (str[i] == 'r')
					ans += p;
				if (str[i] == 'p')
					ans += s;
				if (str[i] == 's')
					ans += r;
			}
		}
	}
	cout << ans << endl;
	clock_t end = clock();
	cerr << "Time run: " << (float)(end - begin) / CLOCKS_PER_SEC << " s" << endl;
}

Measured memory_bytes: 3928
function Main(input) {
	input = input.split(" ");
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	var c = a*b;

	if (c%2 === 0) {
		console.log('Even');
	} else {
		console.log('Odd');
	}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b) if a * b else 0


def solve(string):
    n, m, *a = map(int, string.split())
    c = 2**len(bin(a[0]).split("1")[-1])
    l = reduce(lcm, (0 if _a % c or not _a // c % 2 else _a for _a in a))
    return str((m - l // 2) // l + 1) if l else "0"


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 17172
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scn = new Scanner(System.in);
        int N = scn.nextInt();
        int K = scn.nextInt();
        
        int ans = 1;
        while(true){
            if(Math.pow(K,ans) > N) break;
            ans++;
        }
        System.out.println(ans);
    }
}


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

int main()
{
    int N, val = 0, ans = 0;
    cin >> N;

    int d[N];

    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }

    for (int i = 0; i < N - 1; i++)
    {
        val += d[i];
        ans += val * d[i + 1];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    string a,b,c;
    cin>>a>>b;
    c=b+a;
    cout<<c;
    

    return 0;
}


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

int main()
{
  vector<int> v(3, 0);

  cin >> v[0] >> v[1] >> v[2];

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

  if (v[0] + v[1] == v[2])
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}


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

int main() {

 int a[3][3];

  int n;
  int b[n];
for(int j=0;j<3;j++){
  for(int i=0; i<3;i++){
      cin >> a[j][i];
  }
}

cin >> n;

int c[9] ;
rep(i,9) c[i] =0;


rep(i,n) {
    cin >> b[i];
    for(int j=0;j<3;j++){
        for(int k=0;k<3;k++){
            if(b[i] == a[j][k]){
               c[3*j + k] = 1;
            }
        }
    }
}

if((c[0]==1 && c[1]==1 && c[2]==1) ||
(c[3]==1 && c[4]==1 && c[5]==1) ||
(c[6]==1 && c[7]==1 && c[8]==1) ||
(c[0]==1 && c[3]==1 && c[6]==1) ||
(c[1]==1 && c[4]==1 && c[7]==1) ||
(c[2]==1 && c[5]==1 && c[8]==1) ||
(c[0]==1 && c[4]==1 && c[8]==1) ||
(c[2]==1 && c[4]==1 && c[6]==1) ){
    puts("Yes");
}

else{
    puts("No");
}

}

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

import numpy as np 
#first_plus
count = 0
summention =0
plus_minus = 1

for i in range (0,n):
    summention_temp = a[i] + summention
    if np.sign(summention_temp)!=plus_minus:
        
        summention = plus_minus
        count += abs(summention-summention_temp)
    else:
        summention = summention_temp
    plus_minus = plus_minus*(-1)

count_plus = count

#first_minus
count = 0
summention =0
plus_minus = -1

for i in range (0,n):
    summention_temp = a[i] + summention
    if np.sign(summention_temp)!=plus_minus:
        
        summention = plus_minus
        count += abs(summention-summention_temp)
    else:
        summention = summention_temp
    plus_minus = plus_minus*(-1)

count_minus = count
print(min(count_plus,count_minus))

Measured memory_bytes: 18376
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;

main(){
    int n=in(),k=in();
    vector<double> v;
    double now=1.0;
    v.pb(now);
    rep(i,200000){
        now/=2.0;
        v.pb(now);
    }
    double ans=0;
    rep2(i,1,n){
        int count=0,temp=i;
        while(temp<k){
            count++;
            temp*=2;
        }
        //cout<<count<<" "<<(v[count]/(double)n)<<endl;
        ans+=(v[count]/(double)n);
    }
    printf("%.10f",ans);
}



Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i, x, y) for (long long i = x; i <= y; i++)
using namespace std;

const int N = 1e6, mod = 998244353, M = 2e5 + 10;
typedef long long ll;
ll n, a[M], inv[N + 5], bin[N + 5], ans, f[N + 5];
int mu[N + 5], prime[N + 5], tot, mark[N + 5];

void prework() {
    mu[1] = 1;
    rep(i, 2, N) {
        if (!mark[i]) prime[++tot] = i, mu[i] = -1;
        for (int j = 1; j <= tot && i * prime[j] <= N; j++) {
            mark[i * prime[j]] = 1;
            if (i % prime[j] == 0) {
                mu[i * prime[j]] = 0; break;
            }
            mu[i * prime[j]] = -mu[i];
        }
    }
}

int main() {
    prework();

    cin >> n;
    
    inv[1] = 1;
    rep(i, 2, N) inv[i] = inv[mod % i] * (mod - mod / i) % mod;

    rep(i, 1, n) cin >> a[i], bin[a[i]]++;

    rep(i, 1, N) {
        ll sum = 0;
        for (ll j = i; j <= N; j += i) {
            sum = (sum + bin[j] * j % mod) % mod;
            f[i] = (f[i] + j * j * bin[j] % mod) % mod;
        }
        f[i] = (sum * sum % mod - f[i] + mod) * inv[2] % mod;
    }
    rep(k, 1, N) {
        for (int i = k; i <= N; i += k) {
            ans = (ans + inv[k] * mu[i / k] % mod * f[i] % mod) % mod;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x;
    cin >> x;
    if(x==0){
        cout << 1 << "\n";
    }else{
        cout << 0 << "\n";
    }
    return 0;
    
}   

Measured memory_bytes: 3644
n = int(input())
t,a = map(int,input().split())
h_lst = list(map(int,input().split()))

ans = 0
ondosa = float("inf")
for i in range(n):
    if abs(a - (t - 0.006*h_lst[i])) < ondosa:
        ondosa = abs(a - (t - 0.006*h_lst[i]))
        ans = i

print(ans + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, K;

bool good(const vector<ll>& v, ll m) {
    ll cnt = 0;
    for (ll n : v) {
        cnt += (n - 1) / m;
    }
    return cnt <= K;
}

void solve() {
    cin >> N >> K;
    vector<ll> v(N);
    for (ll& n : v) cin >> n;
    ll a = 1, b = *max_element(v.begin(), v.end());
    while (a < b) {
        ll m = a + (b - a) / 2;
        if (good(v, m))
        {
            b = m;
        }
        else
        {
            a = m + 1;
        }
    }
    cout << a << "\n";
}

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

    int t = 1;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 4752
#include<iostream>
#include<cstdio>

#define fo(i,a,b) for (register int i = a;i <= b;i ++)
#define fd(i,a,b) for (register int i = a;i >= b;i --)
#define wr(a,b) printf("%s = %d\n",a,b)
#define mem(a,b) memset(a,(b),sizeof(a))

using namespace std;

int a, b, c;
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
    //freopen("in.txt","r",stdin);
    cin >> a >> b >> c;
    cout << max(0,c - (a - b)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define loop for(int i=0;i<n;i++)
#define pb push_back
 

int32_t main()
{
	 int n;
	 cin>>n;
	 string s;
	 cin>>s;
	 if(s.size()<=n)
	 cout<<s<<endl;
	 else
	 cout<<s.substr(0,n)<<"...";
 }



Measured memory_bytes: 3628
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	long long n, x, i, ans = 0, a[10000000];
	cin >> n >> x;
	a[1] = x; a[2] = n - x;
	
	if (a[1] < a[2]) {
	    a[3] = x;
	    ans += (a[1] + a[2]);
	    i = 3;
	    while (a[i - 1] % a[i] != 0) {
	        a[i + 1] = a[i - 1] % a[i];
	        ans += ((a[i - 1] / a[i]) * a[i] * 2);
          	i++;
	    }
	    ans += (((a[i - 1] / a[i]) * 2 - 1) * a[i]);
	}
	
	else if (a[1] > a[2]) {
	    ans += a[1];
	    i = 2;
	    while (a[i - 1] % a[i] != 0) {
	        a[i + 1] = a[i - 1] % a[i];
	        if (i != 2) ans += ((a[i - 1] / a[i]) * a[i] * 2);
          	else ans += (((a[i - 1] / a[i]) * 2 + 1) * a[i]);
          	i++;
	    }
	    if (i != 2) ans += (((a[i - 1] / a[i]) * 2 - 1) * a[i]);
      	else ans += (((a[i - 1] / a[i]) * 2) * a[i]);
	}
	else { // equal 
	    ans = x * 3;
	}
	cout << ans;
	return 0;
}


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

int main() {
  int A, B, ans;
  cin >> A >> B;
  ans = 0;
    
  for (int i = A; i <= B; i++) {
    int i1, i2, i3, i4, i5;
    i5 = i - (i/10) *10;
    i4 = (i - (i/100)*100 - i5)/10;
    i1 = i/10000;
    i2 = i/1000 -i1*10;
    if (i1==i5 && i2==i4) ans++;
  }

  cout << ans << endl;
}

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

int main(){
	int i=0;
	int N;
	cin >> N;
	int A[N];
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	int count=0;
	for(int i=0;i<N;i++){
		int minj=i;
		for(int j=i;j<N;j++){
			if(A[minj] > A[j]){
				minj=j;
			}
		}
		if(i!=minj){
			int temp = A[i];
			A[i] = A[minj];
			A[minj]=temp;
			count++;
		}
	}
	for(int i=0;i<N;i++){
		cout << A[i];
		if(i != N-1)
			cout << " ";

	}
	cout << endl << count << endl;

	return 0;
}

Measured memory_bytes: 1160
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
// it is a knapsack dummy
int knp(int wei[],int val[],int n,int mxl){
	int dp[n+1][mxl+1]; // consider items for all possible weight
	//for(int i=0;i<n;++i) cout<<wei[i]<<" "<<val[i]<<"\n";
	for(int i=0;i<=n;++i) for(int j=0;j<=mxl;++j){
		if(i==0 || j==0) dp[i][j]=0;
		else if(wei[i-1]<=j) {
			// consider the weight
			dp[i][j] = max(val[i-1]+dp[i-1][j-wei[i-1]],dp[i-1][j]);
			// either include or not
		}
		else {
			// now i cannot include it 
			dp[i][j]=dp[i-1][j];
		}
	}
	//for(int i=0;i<=n;++i){
	//	for(int j=0;j<=mxl;++j) cout<<dp[i][j]<<" ";
	//	cout<<"\n";
	//}
	return dp[n][mxl]; // all items considered
}
int knp2(int wei[],int val[],int n,int mxl,bool inc[]){
	int dp[n+1][mxl+1]; 
	for(int i=0;i<=n;++i) for(int j=0;j<=mxl;++j){
		if(i==0 || j==0) dp[i][j]=0;
		else if(wei[i-1]<=j) {
			dp[i][j] = max(val[i-1]+dp[i-1][j-wei[i-1]],dp[i-1][j]);
		}
		else {
			dp[i][j]=dp[i-1][j];
		}
	}
	// if it comes form top -> not include else include
	// for minimum we if include == not include then not include;
	int ans=dp[n][mxl];
	int curr_w=mxl;
	for(int i=n;i>0;--i){
		if(ans<=0) break; // no solution
		if(ans==dp[i-1][curr_w]) continue; // not include
		else{
			// include
			inc[i-1]=1;
			ans-=val[i-1]; curr_w-=wei[i-1];
		}
	}
	return dp[n][mxl]; 
}
vector<int> prime;
void seive(){
	int arr[200005]={0};
	for(int i=2;i<200005;++i){
		if(arr[i]==0){
			prime.push_back(i);
			for(int j=2*i;j<200005;j+=i)
				arr[j]=1;
		}
	}
}
int fx(int n){
	for(auto it : prime){
		if(n%it==0) return it;
	}
	return n;
}
int lcm(int a,int b){
	a/=__gcd(a,b);
	return a*b;
}
void solve(){
	int n,k; cin>>n>>k;
	int a[n],b[n];
	for(int i=0;i<n;++i) cin>>a[i];
	for(int i=0;i<n;++i) cin>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	int i=0,j=n-1;
	while(i<n && a[i]<b[j]){
		a[i]=b[j];
		++i; --j;
	}
	int s=0;
	for(int i=0;i<n;++i) s+=a[i];
	cout<<s<<"\n";
}
vector<int> adj[100005];
bool vis[100005];
int par[100005];
void bfs(){
	vis[0]=1;
	queue<int> q; q.push(0);
	while(!q.empty()){
		int p=q.front();
		q.pop();
		for(auto it : adj[p]){
			if(!vis[it]){
				vis[it]=1;
				par[it]=p;
				q.push(it);
			}
		}
	}
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,q; cin>>n>>q;
	while(q--){
		int a,b; cin>>a>>b; --a; --b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i=0;i<n;++i) par[i]=-1;
	vis[0]=1;
	bfs();
	bool ans=1;
	for(int i=1;i<n;++i) if(par[i]==-1) {ans=0;break;}
	if(ans){
		cout<<"Yes\n";
		for(int i=1;i<n;++i) cout<<par[i]+1<<"\n";
	}else cout<<"No\n";
	return 0;
}



Measured memory_bytes: 13164
#include <bits/stdc++.h>
//#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

vector<char> p;
char dfs(char cur, int cnt){
    if(cnt >= p.size()) return cur;

    if(cur == 'T' && p[cnt] == 'T') {
        //cout << 'T' << endl;
        return dfs('T', cnt+1);
    }
    else if(cur == 'T' && p[cnt] == 'F') {
        //cout << 'F' << endl;
        return dfs('F', cnt+1);
    }
    else if(cur == 'F' && p[cnt] == 'T') {
        //cout << 'T' << endl;
        return dfs('T', cnt+1);
    }
    else {
        //cout << 'T' << endl;
        return dfs('T', cnt+1);
    }
}

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

    int n;
    cin >> n;
    p.resize(n);
    REP(i, n) cin >> p[i];

    cout << dfs(p[0], 1) << endl;

}


Measured memory_bytes: 3196
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<int,lint> pl;
typedef pair<lint,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
struct unionf{
	vector <int> data;
	unionf(int size):data(size,-1){}
	bool unions(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x]){int d=x;x=y;y=d;}
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool finds(int x,int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int find(int x){
		return -data[x];
	}
};
lint d[400100];int from[400100];
vector<pl> gr[400100];
priority_queue<tint> q;
vector<tint> ed;
int main()
{
	int n,a;lint D;cin>>n>>D;
	rep(i,n){
		cin>>a;gr[i].pb(mp(i+n,a));gr[i+n].pb(mp(i,a));
	}
	rep(i,n-1){
		gr[i].pb(mp(i+1,D));gr[i+1].pb(mp(i,D));
	}
	memset(from,-1,sizeof(from));
	rep(i,n) q.push(mp(0,mp(i+n,i+n)));
	while(!q.empty()){
		tint p=q.top();q.pop();
		lint di=-p.fi;int x=p.se.fi,y=p.se.se;
		//cout<<di<<' '<<x<<' '<<y<<endl;
		if(from[x]>=0){
			if(y!=from[x]) ed.pb(mp(d[x]+di,mp(y-n,from[x]-n)));
		}
		else{
			from[x]=y;d[x]=di;
			rep(i,gr[x].size()){
				q.push(mp(-di-gr[x][i].se,mp(gr[x][i].fi,y)));
			}
		}
	}
	unionf uni(n+10);
	lint out=0;
	rep(i,ed.size()){
		lint c=ed[i].fi;int x=ed[i].se.fi,y=ed[i].se.se;
		//cout<<c<<' '<<x<<' '<<y<<endl;
		if(uni.finds(x,y)) continue;
		out+=c;uni.unions(x,y);
	}
	cout<<out<<endl;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




PQ<int>pq;
V<int>day[100002];

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,j,m,n,x,y;
    cin >> n >> m;
    for(i=0; i<n; i++)
    {
        cin >> x >> y;
        day[x].PSB(y);
    }
    int ans=0;
    for(i=1; i<=m; i++)
    {
        for(j=0; j<day[i].SZ; j++)
        {
            pq.PS(day[i][j]);
        }
        if(!pq.EM)
        {
            ans+=pq.T;
            pq.PP;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5632
import java.util.*;
public class Main{

	public static void main(String[]agrs){
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i = 1; i < n; i++) {
				int tmp = (i*i) % n;
				if(list.contains(tmp)) continue;
				list.add(tmp);
			}
			
			int[] a = new int[(n-1)/2+1];
			for(int i = 0; i < list.size(); i++) {
				for(int j = 0; j < list.size(); j++) {
					if(i == j) continue;
					int b = list.get(i) - list.get(j);
					if(b < 0) b += n;
					if(b > (n-1)/2) b = n - b;
					a[b]++;
				}
			}
			for(int i = 1; i < a.length; i++) {
				System.out.println(a[i]);
			}
		}
	}
}

Measured memory_bytes: 28688
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int a = (int)scan.next().charAt(0);
        int b = (int)scan.next().charAt(0);
        if(a < b) System.out.println("<");
        else if(a == b) System.out.println("=");
        else System.out.println(">");
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


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

int main(){
  string S;
  cin >> S;
  int N=S.size();
  int c = 0;
  for(int i=0;i<N;i++){
    if(S[i]=='x'){
      c ++;
    }
  }
  if(c>=8){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
lst = list(map(int, input().split()))

def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

lst2 = quick_sort(lst)
print(lst2[n//2]-lst2[n//2-1])


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

int main() {
  int N;
  cin >>N;
  int H[N];
  for(int i=0;i<N;i++){
    cin >>H[i];
  }
  int max=0;
  int ans=0;
  for(int i=0;i<N;i++){
    if(H[i]>=max){
      ans++;
      max=H[i];
    }
  }
  cout <<ans<<endl;
}

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

int main(){
    int n;
    int a,b;
    int i,j;
    char t;
char t1[1510];
char t2[1510];
char t3[1510];
    scanf("%s",&t1);
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",&t3);
        if(strcmp(t3,"replace")==0){
            scanf("%d %d %s",&a,&b,&t2);
            for(j=0;j<b-a+1;j++){
                t1[a+j]=t2[j];
            }
        }
        else if(strcmp(t3,"reverse")==0){
            scanf("%d %d",&a,&b);
            for(;a<b;){
                t=t1[a];
                t1[a]=t1[b];
                t1[b]=t;
                a++;
                b--;
            }
        }
        else if(strcmp(t3,"print")==0){
            scanf("%d %d",&a,&b);
            for(j=a;j<b+1;j++){
                printf("%c",t1[j]);
            }
             printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// ::iterator it;
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (int i=be;i<=en;i++)
#define per(i,be,en) for (int i=en;i>=be;i--)
//ll ksm(ll a,ll b,ll c){ll ans=1;a=a%c;while(b>0){if(b%2) ans=(ans*a)%c;b=b/2;a=(a*a)%c;}return ans;}
using namespace std;

const int N=5e5+7;
int t,n,m,k,fl=0;
string s;
int main(){
    cin>>s;
    rep(i,0,s.size()-1){
        if(s[i]=='7') fl=1;
    }
    if(fl) puts("Yes");
    else puts("No");

}

Measured memory_bytes: 3036
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int H, W;
        public char[,] M;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                H = line[0];
                W = line[1];
            }
            M = new char[H, W];
            for (int y = 0; y < H; y++)
            {
                var line = Console.ReadLine();
                for (int x = 0; x < W; x++)
                    M[y, x] = line[x];
            }

            bool flag = true;
            for (int y = 0; y < H; y++)
            for (int x = 0; x < W; x++)
            {
                if (M[y, x] == '#')
                {
                    if ((y == 0 && x == 0) || (y == H - 1 && x == W - 1))
                    {
                        if (AdjCount(y, x) != 1) flag = false;
                    }
                    else
                    {
                        if (AdjCount(y, x) != 2) flag = false;
                    }
                }
            }

            int count = 0;
            for (int y = 0; y < H; y++)
            for (int x = 0; x < W; x++)
            {
                if (M[y, x] == '#') count++;
            }
            if (count != H + W - 1) flag = false;

            Console.WriteLine(flag ? "Possible" : "Impossible");
        }

        public int AdjCount(int y, int x)
        {
            int ret = 0;
            if (IsPainted(y - 1, x)) ret++;
            if (IsPainted(y + 1, x)) ret++;
            if (IsPainted(y, x + 1)) ret++;
            if (IsPainted(y, x - 1)) ret++;
            return ret;
        }

        public bool IsPainted(int y, int x)
        {
            if (y < 0 || y >= H || x < 0 || x >= W) return false;
            return M[y, x] == '#';
        }
    }


    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
	fastio
	int n;
	cin >> n;
	int a[n],b[n],c[n];
	for(int i = 0;i < n;i++) cin >> a[i] >> b[i] >> c[i];
	int dp[n][3];
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	for(int i = 1;i < n;i++){
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + c[i];
	}
	cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << "\n";
}

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

int main() {
	int n,m,x;
	cin>>n>>m>>x;
	int sum;
	sum=0;
	for(int i=0;i<m;i++){
		int a;
		cin>>a;
		if(a>x){
			sum++;
		}
		
	}
	if(2*sum<m){
		cout<<sum<<endl;
	}
	else{
		cout<<m-sum<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b,c,d,e;//アンテナA~Eの座標
    int k;//2つのアンテナ間の距離がk以下なら直接通信可能
    
    //標準入力から与えられるデータの読み込み
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);
    scanf("%d", &k);
    
    //アンテナA,Eの距離はe-a　これがkを超える場合はアウト
    if(e-a > k){
        //直接通信は不可能
        puts(":(");
    }else{
        //直接通信可能
        puts("Yay!");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<atcoder/all>
#define int long long
int m,N,A,i=1;
void a(int x,int y){
  if(std::gcd(x,y)==1)
    A=atcoder::inv_mod(x,y)*x,m=std::min(m,(A>1?A:A+x*y)-1);
}
signed main(){
  std::cin>>N;N*=2;m=N*9;
  for(;i*i<=N;i++)
    if(N%i==0)a(i,N/i),a(N/i,i);
  printf("%lld\n",m);
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=2e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int a[N];
ll pref[N];
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  for(int i=1;i<=n;i++)
  {
    pref[i]=pref[i-1]+a[i];
  }
  ll ans=0;
  for(int i=1;i<=n;i++)
  {
    ll temp=(1ll*a[i]*((pref[n]-pref[i])%Mod))%Mod;
    ans=(ans+temp)%Mod;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6000
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
using namespace std;
string sl = "CODEFESTIVAL2016";
string str;
int ans;
int main()
{
	cin >> str;
	int l = str.length();
	for (int i = 0;i < l;i++)
	{
		if (str[i] != sl[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;

int main()
{
	bool n=0,w=0,s=0,e=0;
    char c;
    while(cin>>c) {
        if(c=='N') n=1;
        if(c=='W') w=1;
        if(c=='S') s=1;
        if(c=='E') e=1;
    }
    if(n!=s || w!=e) cout<<"No\n";
    else cout<<"Yes\n";
	
    return 0;
}


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

void go(std::vector< std::vector<int> > &g, int n, int m)
{
	bool visited[100010] = { 0 };
	int color[100010] = { 0 }, count[4] = { 0 };
	
	std::queue<int> q;
	q.push(0);
	bool flag = false;
	count[1] = 1;
	color[0] = 1;
	
	while (q.empty() == false)
	{
		int top = q.front();
		q.pop();
		
		if (visited[top])
			continue;
		else
			visited[top] = true;
		
		for (int i = 0; i < g[top].size(); ++i)
		{
			int next = g[top][i];
			if (visited[next])
			{
				if (color[next] == color[top])
				{
					flag = true;
					break;
				}
			}
			else
			{
				if (color[next] != 0 && color[next] == color[top])
				{
					flag = true;
					break;
				}
				
				if (color[top] == 1 && color[next] == 0)
				{
					color[next] = 2;
					++count[2];
				}
				else if (color[next] == 0)
				{
					color[next] = 1;
					++count[1];
				}
				q.push(next);
			}
		}
	}
	
	if (flag)
	{
		std::cout << n * 1ll * (n - 1) / 2 - m;
	}
	else
	{
//		std::cout << count[1] << " " << count[2];
		std::cout << count[1] * 1ll * count[2] - m;
	}
}

int main()
{
	int n, m;
	std::cin >> n >> m;
	int k = m;
	std::vector< std::vector<int> > g(n);
	
	while (k--)
	{
		int a, b;
		std::cin >> a >> b;
		--a;
		--b;
		
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	go(g, n, m);
}

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

int main(void){
    unsigned long long x;
    cin >> x;
    if (x % 11 == 0) {
        cout << (x / 11) * 2;
    } else if(x % 11 > 6) {
        cout << (x / 11) * 2 + 2;
    } else {
        cout << (x / 11) * 2 + 1;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
// Function to return the count of valid pairs 
int countPairs(int a[], int n) 
{ 
    // Storing occurrences of each element 
    unordered_map<int, int> mp; 
    for (int i = 0; i < n; i++) 
        mp[a[i]]++; 
  
    // Sort the array in deceasing order 
    sort(a, a + n, greater<int>()); 
  
    // Start taking largest element each time 
    int count = 0; 
    for (int i = 0; i < n; i++) { 
  
        // If element has already been paired 
        if (mp[a[i]] < 1) 
            continue; 
  
        // Find the number which is greater than 
        // a[i] and power of two 
        int cur = 1; 
        while (cur <= a[i]) 
            cur <<= 1; 
  
        // If there is a number which adds up with a[i] 
        // to form a power of two 
        if (mp[cur - a[i]]) { 
  
            // Edge case when a[i] and crr - a[i] is same 
            // and we have only one occurrence of a[i] then 
            // it cannot be paired 
            if (cur - a[i] == a[i] and mp[a[i]] == 1) 
                continue; 
  
            count++; 
  
            // Remove already paired elements 
            mp[cur - a[i]]--; 
            mp[a[i]]--; 
        } 
    } 
  
    // Return the count 
    return count; 
} 
int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i) {
		cin>>a[i];
	}
	cout<<countPairs(a,n);
	return 0;
}

Measured memory_bytes: 17524
import java.io.*;
import java.util.*;

public class Main {

	public static void solver() {
	
		int a = cin.nextInt();
		int b = cin.nextInt();
		int c = cin.nextInt();
		int cnt = 0;
		
		for (int i=a; i<=b; i++) {
			
			if (c%i==0) cnt++;
			
		}
		
		cout.println(cnt);
		
	}
	
	public static void main(String[] args) throws IOException {

		cin = new Scanner(System.in);
		Main.solver();
	}

	static Scanner     cin;
	static PrintStream cout = System.out;//標準出力
}

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

using namespace std;

long long n,x,y,i,j;
long long a[1000];

int main() {
	scanf("%lld",&n);
	printf("50\n");
	for (i=0 ; i<50 ; i++) a[i] = 49;
	
	x = n / 50;
	y = n % 50;
	
	for (i=0 ; i<50 ; i++) a[i] += x;
	for (i=0 ; i<y ; i++) {
		a[i] += 49;
		for (j=0 ; j<50 ; j++) if (j != i) a[j] -= 1;
	}
	
	for (i=0 ; i<50 ; i++) {
		printf("%lld\n",a[i]);
		if (i == 49) printf("\n"); else printf(" ");
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
typedef long double ld;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265
const int MOD=1e9+7;
 
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

const int N=3005;
double dp[N][N];
double p[N];
int n;
double go(int pos,int head)
{
    if(pos==n+1)
    {
        return head>n/2;
    }
    double &ans=dp[pos][head];
    if(ans!=-1)
        return ans;
    ans=0;
    ans+=(p[pos]*go(pos+1,head+1))+((1-p[pos])*go(pos+1,head));
    return ans;


}

int32_t main()
{
    IOS;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=-1.0;
        }
    }
    cout<<fixed<<setprecision(12)<<go(1,0)<<endl;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,end) for(ll i = 0; i < end ; i++ )
typedef long long ll;
typedef vector<ll> vi;

int main() {
  int N;
  bool flag = true;
  cin >> N;
  string S;
  cin >> S;
  if (N%2 == 1){
    cout << "No" << endl;
  }
  else{
    rep(i, N/2){
      if (S[i] != S[i+N/2]){
        cout << "No" << endl;
        flag = false;
        break;
      }
    }
    if (flag){
      cout << "Yes" << endl;
    }

  }
}

Measured memory_bytes: 3632
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn lower_bound(v: Vec<i32>, search_num: i32) -> usize {

    0
}

fn main() {
    input!{
        n: usize,
        l: [i32; n],
    }

    println!("{}", syakutori_method(n, l));
    // println!("{}", use_rs_binaly_search(n, l));
}

#[allow(dead_code)]
fn syakutori_method(n: usize, l: Vec<i32>) -> i32 {
    let mut l = l;
    l.sort();
    let l = l;
    let mut answer = 0;

    for fst_i in 0..n {
        let mut lim = fst_i;
        for snd_i in fst_i+1..n {
            while lim < n && l[lim] < l[fst_i] + l[snd_i] { lim+=1; }
            answer += lim - (snd_i + 1);
        }
    }
    answer as i32
}

#[allow(dead_code)]
fn mine_binaly_search(n: usize, l: Vec<i32>) -> i32 {
    let mut l = l;
    l.sort();
    let l = l;
    let mut answer: i32 = 0;
    for i in 0..n {
        for u in i+1..n {
            let k = lower_bound(l.to_vec(), l[i] + l[u]);
            answer += std::cmp::max(0, k - u) as i32;
        }
    }
    answer
}

#[allow(dead_code)]
fn use_rs_binaly_search(n: usize, l: Vec<i32>) -> i32 {
    let mut l = l;
    l.sort();
    let l = l;
    let mut answer: i32 = 0;
    for i in 0..n {
        for u in i+1..n {
            let up_lim = l[i] + l[u];
            let point = match l.binary_search(&(up_lim - 1)) {
                Ok(x) => x,
                Err(y) => y - 1
            };
            answer += std::cmp::max(0, point - u) as i32;
        }
    }
    answer
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {
    int n, i, a;
    scanf("%d", &n);
    int order[n];

    for (i = 0; i < n; i++) {
        scanf("%d", &a);
        order[a - 1] = i + 1;
    }

    for (i = 0; i < n; i++) {
        printf("%d", order[i]);
        if (i < n - 1) printf(" ");
        else printf("\n");
    }

    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
using namespace std;
#define INFTY 1<<21
#define DIV 1000000007



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

Measured memory_bytes: 256
islands = []
bridges = []

N, M = map(int, input().split())

for i in range(M):
    a, b = map(int, input().split())
    islands.append({'a': a, 'b': b})

islands.sort(key=lambda x: x['b'])
# print(islands)

for i in islands:
    b = [j for j in bridges if j >= i['a']]
    if len(b) == 0:
        bridges.append(i['b'] - 1)

# print(bridges)
print(len(bridges))


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


int main(){
  int A,B;
  cin >> A >> B;
  int i,sum;
  i = A;
  int s[4];
  while(i<=B){
    if(i / 10000 == i % 10 && (i / 10) % 10 == (i / 1000) % 10) sum += 1;
    i++;
  }
  cout << sum << endl;
}
    

Measured memory_bytes: 256
#!/usr/bin/env python3

def oneBit(bitarr,k):
    return (bitarr & 1 << k) > 0

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    H,W,K = map(int,input().split())
    C = [list(input())for i in range(H)]
    hMax = 2**H
    wMax = 2**W
    c=0
    for h in range(hMax):
        for w in range(wMax):
            bc = 0
            for y in range(H):
                for x in range(W):
                    if C[y][x] == "#" and (not oneBit(h,y) and not oneBit(w,x)):
                        bc +=1
            if bc == K:
                c += 1
    print(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68252
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include<iomanip>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll mx,sum,mn=1e8,cnt;
double ans;
int main(){
	ll n;
	cin>>n;
	ll a[n],b[n];
	for(int i=0; i<n; i++){
		cin>>a[i]>>b[i];
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(i!=j){
				double x=(a[i]-a[j])*(a[i]-a[j]);
				double y=(b[i]-b[j])*(b[i]-b[j]);
				double res=sqrt(x+y);
				ans+=res;
				
			}
		}
	}
	cout<<fixed<<setprecision(10)<<ans/n;
	
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 998244353
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}
ll mul(ll x, ll y) {ll res=x*y; return(res>=MOD?res%MOD:res);}
ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}
ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}
ll power(ll x, ll y) {ll res=1; x%=MOD; while(y){if(y&1)res=mul(res,x); y>>=1; x=mul(x,x);} return res;}

const int MAX = 3e3 + 5;
ll dp[MAX][MAX];
int main()
{
	boost;
	int n, s, i, j;
	cin >> n >> s;
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	ll inv = power(2, MOD - 2);
	dp[0][0] = power(2, n);
	fo(i, 0, n) {
		foe(j, 0, s) {
			if(arr[i] > j) dp[i + 1][j] = dp[i][j];
			else dp[i + 1][j] = add(dp[i][j], mul(dp[i][j - arr[i]], inv));
		}
	}
	cout << dp[n][s];
}


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

int main(){
    int n; cin >> n;
    string S; cin >> S;
    vector <int> seen_cnt_from_l(n, 0);
    vector <int> seen_cnt_from_r(n, 0);
    vector <int> seen_cnt(n, 0);

    for (int i = 1; i < n; i ++){
        seen_cnt_from_l[i] = seen_cnt_from_l[i - 1];
        if (S[i - 1] == 'E'){
            seen_cnt_from_l[i] += 1;
        }
    }
    for (int i = n - 2; i >= 0; i --){
        seen_cnt_from_r[i] = seen_cnt_from_r[i + 1];
        if (S[i + 1] == 'W'){
            seen_cnt_from_r[i] += 1;
        }
    }

    for (int i = 0; i < n; i ++){
        seen_cnt.at(i) = seen_cnt_from_r.at(i) + seen_cnt_from_l.at(i);
    }

    // for (auto cnt : seen_cnt) cout << cnt << " ";

    int seen_max = *max_element(seen_cnt.begin(), seen_cnt.end());
    cout << (n - 1) - seen_max << endl;
}

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

int main() {
    int n; cin >> n;
    vector<int> p(n), q(n), perm(n);
    rep(i,n) cin >> p[i];
    rep(i,n) {
        cin >> q[i]; 
        perm[i] = i+1;
    }

    map<vector<int>, int> mp;
    do {
        mp[perm] = mp.size();
    }    while (next_permutation(perm.begin(), perm.end()));

    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5248