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

const int MOD = 1e9 + 7;

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};


int n,a,b;
mint result;
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20);

    cin >> n >> a >> b;
    mint two = 2;
    result = two.pow(n) - 1;
    vector<mint> combinations(b + 1, n);
    
    for(int i = 2; i <= b; i++) {
        combinations[i] = combinations[i - 1];
        combinations[i] *= (n - i + 1);
        combinations[i] /= i;
    }
    result -= combinations[a];
    result -= combinations[b];
    cout << result;
}

Measured memory_bytes: 1792
#define DEBUG 0

/**
 * File    : D2.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-5-29 20:27:35
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

/*
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}

void No()
{
  cout << "No" << endl;
  exit(0);
}
*/

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

// const ll MOD = 1000000007;

int N, K;
vector<int> a, b, A, B, x, y, I;

vector<int> inv(vector<int> V)
{
  vector<int> W(N);
  for (auto i = 0; i < N; i++)
  {
    W[V[i]] = i;
  }
  return W;
}

vector<int> mult(vector<int> V, vector<int> W)
{
  vector<int> U(N);
  for (auto i = 0; i < N; i++)
  {
    U[i] = V[W[i]];
  }
  return U;
}

vector<int> power(vector<int> V, int n)
{
  if (n == 0)
  {
    return I;
  }
  else if (n % 2 == 0)
  {
    vector<int> W = power(V, n / 2);
    return mult(W, W);
  }
  else
  {
    return mult(V, power(V, n - 1));
  }
}

vector<int> f(vector<int> V, vector<int> W)
{
  return mult(W, inv(V));
}

void flush(vector<int> V)
{
  for (auto i = 0; i < N; i++)
  {
    cout << V[i] + 1;
    if (i < N - 1)
    {
      cout << " ";
    }
    else
    {
      cout << endl;
    }
  }
}

int main()
{
  cin >> N >> K;
  K--;
  a = vector<int>(N);
  b = vector<int>(N);
  I = vector<int>(N);
  for (auto i = 0; i < N; i++)
  {
    I[i] = i;
  }
  for (auto i = 0; i < N; i++)
  {
    cin >> a[i];
    a[i]--;
  }
  for (auto i = 0; i < N; i++)
  {
    cin >> b[i];
    b[i]--;
  }
  A = inv(a);
  B = inv(b);
  // $x = bABa$, $y = AbaB$
  x = mult(mult(b, A), mult(B, a));
  y = mult(mult(A, b), mult(a, B));
  if (K == 0)
  {
    flush(a);
    return 0;
  }
  int n = (K - 1) / 6;
  vector<int> p = mult(mult(power(x, n), b), power(y, n));
  vector<int> q = mult(mult(power(x, n), mult(b, A)), power(y, n));
  for (auto i = 6 * n + 1; i < K; i++)
  {
    vector<int> r = f(p, q);
    p = q;
    q = r;
  }
  flush(p);
}

Measured memory_bytes: 23584
#include <stdio.h>

int main(void){
  char str[20];
  int line[10];
  int i,j,p;
  while(scanf("%s",&*str)!=EOF){
    for(i=0;i<10;i++){
      line[i]=str[i]-48;
    }
    
    for(i=10;i>1;i--){
      for(j=0;j<i-1;j++){
	p=line[j]+line[j+1];
	if(p>9) line[j]=p%10;
	else    line[j]=p;
      }
    }
    printf("%d\n",line[0]);
  }
  return 0;
}

Measured memory_bytes: 540
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int M = 1 << sc.nextInt(), K = sc.nextInt();
		if (K < M && M != 2) {
			for (int i = 0;i < M;++ i) {
				if (i == K) continue;
				System.out.print(i + " ");
			}
			System.out.print(K + " ");
			for (int i = M - 1;i >= 0;-- i) {
				if (i == K) continue;
				System.out.print(i + " ");
			}
			System.out.println(K);
		} else if (M == 2 && K == 0) System.out.println("0 0 1 1"); 
		else System.out.println("-1");
	}
}

Measured memory_bytes: 47068
#include <bits/stdc++.h>
using namespace std;
#define ll                  long long
#define ld                  long double
#define pb                  push_back
#define mkp                 make_pair
#define f(i,l,h)            for(ll i=l;i<h;i++)
#define fr(i,h,l)           for(ll i=h;i>=l;i--)
#define mem(a,val)          memset(a,val,sizeof(a))
#define all(v)              (v).begin(),(v).end()
#define ff                  first
#define ss                  second
#define spc(x)              cout<<fixed<<setprecision((x));
#define deb(x)              cout<<#x<<" "<<x<<endl;
#define deba(x)             cout<<#x<<": "; for(auto u:x) cout<<u<<" ";  cout<<endl;
#define check               cout<<"hello"<<endl;
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
const ld pi=3.141592653589793;
const ll mod=998244353;
const ll INF=(ll)(1e9+7);
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

ll power(ll a,ll b){
    ll res=1;
	while(b){
	    if(b&1) res=(res*a);
	    a=(a*a);
	    b>>=1;
	}
	return res;
}

int main()
{
    //cout << "Hello world!" << endl;
    ll n;
    cin>>n;
    ll h[n+1];
    f(i,1,n+1) cin>>h[i];
    ll dp[n+1];
    dp[0]=0;
    dp[1]=0;
    dp[2]=llabs(h[2]-h[1]);
    f(i,3,n+1){
        dp[i]=min(dp[i-1]+llabs(h[i]-h[i-1]),dp[i-2]+ llabs(h[i]-h[i-2]));
    }
    cout<<dp[n]<<endl;

    return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
	x = n/m
	m+x = n
}*/

signed main()
{
	int n;
	cin >> n;

	int ans = 0;
	rep(i, 1, n/i+1){
		if((n-i)%i == 0){
			int t = (n-i)/i;
			if(t == 0) continue;
			if(n/t == n%t) ans += (n-i)/i;
		}
	}

	cout << ans << endl;

	return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int a,b,c; cin >> a >> b >> c;
    int K; cin >> K;
    int cnt=0;
    while(a>=b){
        b*=2;
        cnt++;
    }
    while(b>=c){
        c*=2;
        cnt++;
    }
    if(cnt<=K){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    vector<int>kai {0,1,2,6,24,120,720,5040,40320};
    int n,ansa = 0,ansb = 0;
    cin >> n;
    vector<int>va(n); vector<int>vb(n);
    for (int i = 0; i < n; i++) cin >> va.at(i);
    for (int i = 0; i < n; i++) cin >> vb.at(i);
    for (int i = 0; i < n-1; i++){
        int x = kai.at(n-1-i);
        ansa += x * (va.at(i)-1);
        ansb += x * (vb.at(i)-1);
        for (int j = 0; j < n; j++){
            if (va.at(i) < va.at(j)) va.at(j)--;
            if (vb.at(i) < vb.at(j)) vb.at(j)--;
        }
    }
    cout << abs(ansa - ansb) << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,vector<ll> > P;
typedef pair<P,ll>Q;

int s[102]; 
bool flag[200010];

int main(void){
    int n,m;
    cin>>n>>m;
    vector<ll>h(n);
    for(int i=0;i<n;i++)cin>>h[i];
    vector<int>a(m),b(m);
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        if(h[a[i]]>h[b[i]])flag[b[i]]=true;
        else{
            if(h[a[i]]<h[b[i]])flag[a[i]]=true;
            else{
                flag[a[i]]=true;
                flag[b[i]]=true;
            }
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++)if(!flag[i])ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4844
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
p = list(map(int,read().split()))
q = [0] * n
for i,p_i in enumerate(p):
    q[p_i-1] = i

longest = 1
now = 1
for i in range(1,n):
    if(q[i] > q[i-1]):
        now += 1
    else:
        now = 1
    longest = max(longest,now)

print(n-longest)

Measured memory_bytes: 100016
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=200005,INF=0X3F3F3F3F,P=1e9+7;
int n,m,f[N];
char s[N];
void sol1(){
	f[1]=1;
	rep(i,2,n+1)f[i]=(f[i-1]+f[i-2])%P;
	printf("%d\n",(f[n-1]+f[n+1])%P);
}
void sol2(int n,int lim){
	D("n=%d lim=%d\n",n,lim);
	int cur=0;
	for(int i=1;i<=n;++i){
		if(i>lim+1)cur=(cur-f[i-lim-1]+P)%P;
		f[i]=(cur+(i<=lim?i:0))%P;
		cur=(cur+f[i])%P;
	}
	printf("%lld\n",2LL*f[n]%P);
}
int main(){
	scanf("%d%d%s",&n,&m,s);
	if(s[0]=='B'){
		rep(i,0,m-1)s[i]=(s[i]=='R'?'B':'R');
	}
	if(count(s,s+m,s[0])==m){
		sol1();
		return 0;
	}
	if(n&1)puts("0"),exit(0);
	bool fir=1;
	int mn=INF;
	for(int i=0,j;i<m;i=j){
		j=i+1;
		while(j<m&&s[j]==s[i])++j;
		if(j>=m)break;
		if(s[i]=='R'&&(fir||(j-i)%2))mn=min(mn,j-i),fir=0;
	}
	sol2(n/2,mn/2+1);
	return 0;
}

Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(x) cerr<<#x": "<<(x)<<endl
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second

template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	int h, w, a, b;

	cin >> h >> w >> a >> b;
	for(int i = 1; i <= h; ++i, cout << '\n')
		for(int j = 1; j <= w; ++j)
			cout << ((i <= b && j <= a) || (i > b && j > a) ? '0' : '1');

	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll i,j,k,m,n,t;
	ll a,b,c,d;
	cin>>n;
	string s;
	map<string,ll> mp;
	for(i=0;i<n;i++)
	{
		cin>>s;
		mp[s]++;
	}
	cout<<mp.size();
}

Measured memory_bytes: 19100
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);

ll Pow(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n&1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

ll x[200010] = {}, y[200010] = {};

int main() {
    ll n,k;
    cin >> n >> k;

    y[n] = n;
    for(int i = 1; i <= n; i++){
        x[i] = x[i-1]+i;
        y[n-i] = y[n-i+1]+n-i;
    }
    ll sum = 1;
    for(ll i = k; i < n+1; i++){
        ll mi = x[i-1],ma = y[n+1-i];
        (sum += ma-mi+1) %= MOD;
        //cout << ma-mi+1 << endl;
    }
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 6708
#include<stdio.h>

#define DATA 100000000
#define max 100

void SSSP(int,int);

int num;
int size[max];
int change[max][max];
int cost[max][max];
int dist[max];

int main(){
  int i,j,u;
  scanf("%d",&num);

  for(i = 0;i < num;i++){
    scanf("%d",&u);
    scanf("%d",&size[u]);

    for(j = 0;j < size[u];j++){
      scanf("%d",&change[u][j]);
      scanf("%d",&cost[u][j]);
    }
  }

  for(i = 0;i < num;i++){
    dist[i] = DATA;
  }
    SSSP(0,0);
    for(i = 0;i < num;i++){
      printf("%d %d\n",i,dist[i]);
    }
  return 0;
}

void SSSP(int a,int b){
  int i;
  dist[a] = b;

  for(i = 0;i < size[a];i++){
    if(dist[change[a][i]] > b + cost[a][i]){
      SSSP(change[a][i],b + cost[a][i]);
    }
  }
}



Measured memory_bytes: 2112
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)*}
    };
}

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)*}
    };
}

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")
    };
}

fn main() {
    input! {
        h: usize,
        w: usize,
        s: [String; h],
    }
    let chars = s.join("").chars().collect::<Vec<_>>();

    let mut vertical = Vec::new();
    vertical.resize(h * w, 0);
    let mut horizontal = Vec::new();
    horizontal.resize(h * w, 0);

    for i in 0..h {
        let mut start = -1i64;
        for j in 0..w {
            if chars[i * w + j] == '#' {
                for k in (start + 1) as usize .. j {
                    horizontal[i * w + k] = (j as i64 - start - 1) as usize;
                }
                start = j as i64;
            }
        }
        for k in (start + 1) as usize .. w {
            horizontal[i * w + k] = (w as i64 - start - 1) as usize;
        }
    }

    for j in 0..w {
        let mut start = -1i64;
        for i in 0..h {
            if chars[i * w + j] == '#' {
                for k in (start + 1) as usize .. i {
                    vertical[k * w + j] = (i as i64 - start - 1) as usize;
                }
                start = i as i64;
            }
        }
        for k in (start + 1) as usize .. h {
            vertical[k * w + j] = (h as i64 - start - 1) as usize;
        }
    }

    let mut max = 0;
    for i in 0..h {
        for j in 0..w {
            if chars[i * w + j] == '.' {
                max = std::cmp::max(max, horizontal[i * w + j] + vertical[i * w + j] - 1);
            }
        }
    }
    println!("{:?}", max);
}


Measured memory_bytes: 90364
from collections import defaultdict
from heapq import heappop, heappush
n,m = map(int, input().split())
a = list(map(int, input().split()))

uf = [-1]*n
def root(x):
    if uf[x] < 0:
        return x
    uf[x] = root(uf[x])
    return uf[x]
def unite(x,y):
    rx, ry = root(x), root(y)
    if rx == ry:
        return False
    if uf[rx] > uf[ry]:
        rx, ry = ry, rx
    uf[rx] += uf[ry]
    uf[ry] = rx
    return True

for i in range(m):
    x,y = map(int, input().split())
    unite(x,y)
if m == n-1:
    print(0)
elif (n-m-1)*2 > n:
    print("Impossible")
else:
    d = defaultdict(list)
    for i in range(n):
        heappush(d[root(i)], a[i])
    cnt = (n-m-1)*2
    ans = 0
    heap = []
    for value in d.values():
        ans += heappop(value)
        cnt -= 1
        while value:
            heappush(heap, heappop(value))
    for _ in range(cnt):
        ans += heappop(heap)
    print(ans)

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

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

    int n;
    cin >> n;

    ll march[5] = {0};
    rep(i, n){
        string name;
        cin >> name;

        if(name[0]=='M') ++march[0];
        if(name[0]=='A') ++march[1];
        if(name[0]=='R') ++march[2];
        if(name[0]=='C') ++march[3];
        if(name[0]=='H') ++march[4];
        
    }

    ll res = 0;
    for(int i = 0; i < 3; ++i){
        for(int j = i+1; j < 4; ++j){
            for(int k = j+1; k < 5; ++k){
                res += march[i] * march[j] * march[k];
            }
        }
    }

    cout << res << endl;
}

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

int main()
{
	int n = 0, x = 0;

	cin >> n >> x;

	while ((n != 0) | (x != 0)) {
		int t = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++)
					if ((i + j + k) == x)
						t++;
			}
		}
		cout << t << endl;

		cin >> n >> x;
	}
	
    return 0;
}

Measured memory_bytes: 3080
import java.util.*

fun main(args : Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val p = mutableListOf<Pair<Int, Int>>()
    (0 until N).forEach {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        p.add(Pair(a, b))
    }
    p.sortBy {
        it.first
    }

    var anser = 0L
    val queue = PriorityQueue<Int>()
    var pointer = 0
    (M -1 downTo  0).forEach {
       val a = M - it
       while (pointer < N && p[pointer].first <= a) {
           queue.offer(-1 * p[pointer].second)
           pointer++
       }
        if (!queue.isEmpty()) {
            val value = queue.poll()
            anser += -1 * value
        }
    }
    println(anser)
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m,r;
int p[12];
int g[252][252];

int main(){
  cin>>n>>m>>r;
  REP(i,r)cin>>p[i],p[i]--;
  REP(i,n)REP(j,n)g[i][j] = 1e9;
  REP(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    --a;--b;
    g[a][b] = g[b][a] = c;
  }
  REP(k,n)REP(i,n)REP(j,n)CHMIN(g[i][j],g[i][k]+g[k][j]);
  sort(p,p+r);
  ll ans = 1e18;
  do{
    ll tmp = 0;
    REP(i,r-1){
      tmp += g[p[i]][p[i+1]];
    }
    CHMIN(ans,tmp);
  }while(next_permutation(p,p+r));
  cout<<ans<<endl;
  return 0;
}


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

int SumOfDigits(int a)
{
  int sum = 0;
  while (a > 0)
  {
    sum += a % 10;
    a /= 10;
  }
  return sum;
}

int main()
{
  int N;
  cin >> N;
  int ans = 900;

  for (int i = 1; i < N; i++)
  {
    int a = SumOfDigits(i) + SumOfDigits(N - i);
    if(ans > a){
      ans = a;
    }

  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){
	int A, B, angle=90;
	double x=0, y=0;

	const double PI = 3.14159265358979;
	for(;;){
		scanf("%d,%d", &A, &B);
		if(A==0 && B==0) break;
		x+=cos(angle*PI/180)*A;
		y+=sin(angle*PI/180)*A;
		angle -= B;
	}
	printf("%d\n%d\n", (int)x, (int)y);
}

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

typedef long long ll;

const int N = 2e5 + 5, M = 1e6 + 5;

int n, ans, cnt[26], son[M][26], ToT = 1;
bool is[M];
std::string s[N];

int main()
{
	std::cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int u = 1;
		std::cin >> s[i];
		for (int j = s[i].length() - 1; j >= 0; j--)
		{
			int c = s[i][j] - 'a';
			if (!son[u][c]) son[u][c] = ++ToT;
			u = son[u][c];
		}
		is[u] = 1;
	}
	for (int i = 1; i <= n; i++)
	{
		int u = 1, l = s[i].length(); memset(cnt, 0, sizeof(cnt));
		for (int j = 0; j < l; j++) cnt[s[i][j] - 'a']++;
		for (int c = 0; c < 26; c++)
			if (s[i][l - 1] != c + 'a' && cnt[c] && is[son[1][c]])
				ans++;
		for (int j = l - 1; j >= 1; j--)
		{
			if (u = son[u][s[i][j] - 'a'], is[u]) ans++; cnt[s[i][j] - 'a']--;
			for (int c = 0; c < 26; c++)
				if (s[i][j - 1] != c + 'a' && cnt[c] && is[son[u][c]])
					ans++;
		}
	}
	return std::cout << ans << std::endl, 0;
}

Measured memory_bytes: 113608
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
using board3D = vector< vector< vector<int> > >;
using board2D = vector< vector<int> >;

int H, W, R, C;
vector< vector< vector<int> > > orig, modi;
int memo[510][510][2], visited[510][510];

// up, left, down, right
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

void construct(const board2D& UD, const board2D& LR, board3D& board) {
  // printf("construct\n");
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      board[i][j][0] ^= UD[i][j];
      board[i][j][1] ^= LR[i][j];
      board[i][j][2] ^= UD[i+1][j];
      board[i][j][3] ^= LR[i][j+1];

      // printf("coor = %d, %d: %d %d %d %d\n", i+1, j+1, board[i][j][0], board[i][j][1], board[i][j][2], board[i][j][3]);
    }
  }
}

int solve(int x, int y, int f) {
  int &val = memo[x][y][f];
  board3D& board = (f == 0 ? orig : modi);
  if(val != -1) return val;

  for(int k=0; k<4; k++) {
    // wall
    if(board[x][y][k]) continue;
    int nx = x + dx[k], ny = y + dy[k];
    if(nx < 0 || nx >= H || ny < 0 || ny >= W) {
      // out
      return val = true;
    }

    if(visited[nx][ny]) continue;
    visited[nx][ny] = true;
    int v1 = solve(nx, ny, 0);
    int v2 = solve(nx, ny, 1);
    visited[nx][ny] = false;
    if(v1 == 1 && v2 == 1) return val = 1;
  }

  return val = 0;
}

int main() {
  while(1) {
    cin >> H >> W >> R >> C;
    R--; C--;
    if(!H) break;

    vector< vector<int> > UD(H+1, vector<int>(W+1));
    vector< vector<int> > LR(H+1, vector<int>(W+1));
    orig.clear();
    modi.clear();
    orig.resize(H, vector< vector<int> >(W, vector<int>(4, 0)));
    modi.resize(H, vector< vector<int> >(W, vector<int>(4, 1)));

    for(int i=0; i<2*H+1; i++) {
      int lim = (i % 2 == 0 ? W : W + 1);
      for(int j=0; j<lim; j++) {
        cin >> (i % 2 == 0 ? UD : LR)[i/2][j];
      }
    }

    construct(UD, LR, orig);
    construct(UD, LR, modi);

    memset(memo, -1, sizeof(memo));
    memset(visited, false, sizeof(visited));
    visited[R][C] = true;
    int ans = solve(R, C, 0);
    cout << (ans ? "Yes" : "No") << endl;
  }
}



Measured memory_bytes: 62700
n,m = map(int,input().split())
h = list(map(int,input().split()))
tem = [[] for i in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    tem[a-1].append(b-1)
    tem[b-1].append(a-1)
    
ans = 0
for i in range(n):
    if tem[i] == []:
        ans += 1
    else:
        tt = set(tem[i])
        fl = 1
        for j in tt:
            if h[i] <= h[j]:
                fl = 0
                
        ans += fl
        
print(ans)

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

using namespace std;

const int maxn = 100179;
int p[maxn];
vector<int> graph[maxn];

bool used[maxn];
set<int> indices;
set<int> values;

void dfs(int v) {
    indices.insert(v);
    values.insert(p[v]);
    used[v] = true;
    for (int u : graph[v]) {
        if (!used[u]) {
            dfs(u);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            indices.clear();
            values.clear();
            dfs(i);
            vector<int> numbers;
            set_intersection(indices.begin(), indices.end(), values.begin(), values.end(), back_inserter(numbers));
            ans += numbers.size();
        }
    }

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


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

int main(){

  int n;

  while(cin >> n, n){
    int a[100],m = 32,j = 0,k = 0;

    for(int i=0;i<n;i++) cin >> a[i];

    while(1){
      if(j == n) j = 0;

      if(k == 0){
	m -= ((m-1)%5);
	k = 1;
      }

      else if(k == 1){
	m -= a[j];
	k = 0;
	j++;
      }
      if(m <= 0) break;
      cout << m << endl;
    }
    cout << "0" << endl;
  }
}

Measured memory_bytes: 1160
// includes, macros {{{
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <climits>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

#define rep(i, s, e)    for (int i = (s); i < (int)(e); i++)
//#define PB(e) push_back(e)
//#define MP(a, b) make_pair(a, b)

// for debug
#define kita            cout << "kita\n"
#define print2(i, n)    cout << (i) << ": " << (n) << endl
#define print3(i, j, n)     cout << "(" << (i) << ", " << (j) << ") : " << (n) << endl
#define print4(i, j, n, m)  cout << "(" << (i) << ", " << (j) << ") : " << (n) << ", " << (m) << endl
#define print_mat(mat, h, w) for(int i=0;i<(h);i++){for(int j=0;j<(w);j++){cout << mat[i][j] << " ";}cout << endl;}
 
typedef long long ll;
typedef unsigned long long ull; // }}}

ll N;

int main(){
    cin >> N;
    ll p[30000];
    ll ans[30000];
    for(ll i=0;i<N;i++){
        ans[i] = (N-i)*30000;
    }

    for(ll i=0;i<N;i++){
        cin >> p[i];
        cout << (i+1)*30000;
        ans[p[i]-1] += i+1;
        if(i==N-1){
            cout << endl;
        }else{
            cout << ' ';
        }
    }
    for(ll i=0;i<N;i++){
        cout << ans[i];
        if(i==N-1){
            cout << endl;
        }else{
            cout << ' ';
        }
    }
    return 0;
}


Measured memory_bytes: 896
n,k = map(int ,input().split())
h = sorted([int(input()) for i in range(n)])

ans = float('INF')
for i in range(n-k+1):
    # print(h[i+k-1], i+k-1)
    if h[i+k-1] - h[i] < ans:
        ans = h[i+k-1] - h[i]
print(ans)


Measured memory_bytes: 8280
def check(i, j, w, h, s):
  if(i + 1 < h and s[i+1][j] == "#"):
    return True
  if(i - 1 >= 0 and s[i-1][j] == "#"):
    return True
  if(j - 1 >= 0 and s[i][j-1] == "#"):
    return True
  if(j + 1 < w and s[i][j+1] == "#"):
    return True
  return False

h,w = list(map(int, input().split()))
s = [list(input()) for _ in range(h)]
for i in range(h):
  for j in range(w):
    if(s[i][j] == "#"):
      if(check(i, j, w, h, s)):
        True
      else:
        print("No")
        exit()
print("Yes")


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

int main(){
  int N;
  cin >>N;
  if(N%10 == 3)cout<<"bon";
  else if(N%10==0||N%10==1||N%10==6||N%10==8)cout<<"pon";
  else cout <<"hon";

return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    ll ans = 0;
    REP(i,N) {
        int a,b;
        cin>>a>>b;
        ans += b-a+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
if (b<=c)|(d<=a):
    print(0)
elif a<=c<=b<=d:
    print(b-c)
elif c<=a<=d<=b:
    print(d-a)
elif a<=c<=d<=b:
    print(d-c)
else:
    print(b-a)

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

using namespace std;

int main()
{
    map<long long int, long long int> mp;
    int n;
    long long int a[100010];
    int ans = 0;

    cin >> n;

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

    for (auto x: mp) {
        if (x.second%2) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 7296
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
// #define mp make_pair
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int
map<pair<int,int>,int> mp;
string n;

int32_t main(){
    IOS;
    int n;
    cin>>n;
    map<pair<int,int>,int> mp;
    for(int i=1;i<=n;i++){
    	int fist = i%10;
    	int lst = i;
    	while(lst>=10)
    		lst/=10;
    	mp[{fist,lst}]++;
    }
    int ans = 0;
    for(auto it:mp){
    	int x = it.ff.ff;
    	int y = it.ff.ss;
    	int v = it.ss;
    	ans = ans + v*mp[{y,x}];
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}
double logfact(int n){
    long long dp[n+1];
    dp[0]=1;
    //dp[1]=1;
    double sum=0;
    for(int i=1;i<=n;i++){
        sum+=log(i);
    }
    return sum;
}
int main(){
    int D;
    cin >>D;
    
    cout <<"Christmas";
    while(25-D>0){
        cout<<" Eve";
        D++;
    }

    cout<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
//typedef __int128_t Int;
#define DBG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define loop(n) rep(loop,(0),(n))
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> class DisjointSet {
public:
  vector<T> rank, p;
  DisjointSet() {}
  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    rep(i, 0, size) makeSet(i);
  }
  void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }
  bool same(int x, int y) { return findSet(x) == findSet(y); }
  bool unite(int x, int y) {
    if (same(x, y))
      return false;
    link(findSet(x), findSet(y));
    return true;
  }
  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) {
        rank[y]++;
      }
    }
  }
  int findSet(int x) {
    if (x != p[x]) {
      p[x] = findSet(p[x]); // path compression
    }
    return p[x];
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);

  int N, M; cin >> N >> M;
  vector<int> p(N); rep(i, 0, N){ cin >> p[i];p[i]--; }
  vector<int> x(M), y(M); rep(i, 0, M){ cin >> x[i] >> y[i];x[i]--,y[i]--; }
  DisjointSet<int>uf(N);
  rep(i,0,M){
    uf.unite(p[x[i]],p[y[i]]);
  }
  int ans=0;
  rep(i,0,N){
    ans+=uf.same(i,p[i]);
  }
  cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 2176
#3:03
import sys
import math

sys.setrecursionlimit(10000000)



def count_prime(N):
    N = N*2
    max = int(math.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


while True:
    target = int(input())
    if target == 0 :
        break

    prime_list = count_prime(target)

    print(sum(2*target>=x for x in prime_list) - sum(target>=x for x in prime_list))
    



Measured memory_bytes: 17728
#include<stdio.h>
int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int distance_1 = b - a;
    int distance_2 = c - a;
    if(distance_1 < 0){
        distance_1 = distance_1 * -1;
    }
    if(distance_2 < 0){
        distance_2 = distance_2 * -1;
    }
    if(distance_2 < distance_1){
        printf("B\n");
    }
    else{
        printf("A\n");
    }
    return 0;
}

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

int h,w,k;
int ans=0;
char a[6][6];
void dfs(int s,int r){
	s=~s;
	r=~r;
	int res=0;
	for(int x=0;x<h;x++){
		for(int y=0;y<w;y++){
			if((s>>x&1==1)&&(r>>y&1==1)){
				if(a[x][y]=='#') res++;
			}
		}
	}
	if(res==k) ans++;
}

int main(){
	cin>>h>>w>>k;
	for(int p=0;p<h;p++){
		getchar();
		for(int q=0;q<w;q++){
			a[p][q]=getchar();
		}
	} 
	for(int m=0;m<1<<h;m++)
	    for(int n=0;n<1<<w;n++){
	    	dfs(m,n);
		}
    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 3608
#include<stdio.h>

int main(void)
{
	long long int num;
	scanf("%lld", &num); //整数の入力
	int i = 0;
	int j, k;
	int str[100];
	long long int check;
	check = num;

	while (check)			 //桁数チェック　i=桁数
	{
		check = check / 10;
		i++;
	}						

							
	for (j = 0; j < i; j++)  //配列に入れる
	{
		check = num;
		if (j == 0)
		{
			str[j] = check % 10;
		}
		else if (j != 0)
		{
			for (k = 0; k < j; k++)
			{
				check = check / 10;
			}
			str[j] = check % 10;

		}
	}


	for (j = 0; j < i-1; j++)  //出力
	{
		if (str[j] != 9)
		{
			str[j] = 9;
			if (str[j + 1] == 0)
			{
				str[j + 1] = 9;
				str[j + 2] = str[j + 2] - 1;
			}
			else str[j + 1] = str[j + 1] - 1;
		}
	}
	int sum=0;
	for (j = 0; j < i; j++)
	{
		sum= sum + str[j];
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <complex>
using namespace std;
typedef complex<double> P;
const double EPS=1e-11;
int main(){
    int n;
    double x1,y1,x2,y2,x3,y3,x4,y4;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if(abs((conj(P(x2-x1,y2-y1))*P(x4-x3,y4-y3)).imag()) < EPS) printf("YES\n");
        else printf("NO\n");
    }
}

Measured memory_bytes: 1044
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll a, b;

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

  if(a <= 0 && b >= 0) {
    cout << "Zero" << endl;
  } else if(b < 0) {
    if((b - a) % 2 == 0) {
      cout << "Negative" << endl;
    } else {
      cout << "Positive" << endl;
    }
  } else {
    cout << "Positive" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, x;
    cin >> a >> b >> x;
    ll cnt = 0;
    a -= 1;
    if (a < 0)
    {
        a = 0;
        cnt++;
    }
    cnt += b / x - a / x;
    cout << cnt << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
#include <limits>
using namespace std;
int gcd(int a, int b)//最大公約数
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
vector<int> v;
class Calc
{
    // 宣言
    long long a;

    public:
        // 素因数分解
        void decompositPrime(long long a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(long long n)
{
    // 割る数の初期値
    a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            //printf("%d * ", a);
             v.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v.push_back(n);
    //printf("%d\n", n);
}
vector<int> divisor(int n) {//約数発見
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    std::sort(ret.begin(), ret.end());
    return ret;
}
long nc2(long n){
    return n*(n-1)/2;
}
template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
	static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string ret;
	static numeric_limits<TypeInt> t;
	TypeInt n = v;
	if (t.is_signed) {
		if (v < 0) n *= -1;
	}

	while (n >= base) {
		ret += table[n%base];
		n /= base;
	}
	ret += table[n];
	if (t.is_signed) {
		if (v < 0 && base == 10) ret += '-';
	}
	// 文字列の順番を逆にする
	std::reverse(ret.begin(), ret.end());

	return ret;
}

int main(){
    //std::stack<int> stack;
    int n,q;
    cin >> n;
    vector<int> a(n);
    vector<int> cnt(100001,0);
    long ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cnt[a[i]] ++;
        ans += a[i];
    }
    cin >> q;
    vector<int> b(q);
    vector<int> c(q);
    for(int i = 0; i < q; i++){
        cin >> b[i] >> c[i];
    }
    for(int i = 0; i < q; i++){
        ans += c[i]*cnt[b[i]] - b[i]*cnt[b[i]];
        cnt[c[i]] += cnt[b[i]];
        cnt[b[i]] = 0;
        cout << ans << endl;
    }
    
    return 0;
}






Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;

signed main()
{
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    std::ios::sync_with_stdio(false);
    int t = 1;
    cin >> t;
    unordered_map<string, int> m;
    while (t--) {
        string s;
        cin >> s; m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int n, m, k, ans;
pair<int, int>a[100005];
int main () {
  scanf("%d%d", &n, &m);
  for (int i=0; i<n; i++)
    scanf("%d%d", &a[i].first, &a[i].second);
  sort(a, a+n);
  priority_queue<int>pq;
  for (int i=1; i<=m; i++) {
    while (k<n && a[k].first <= i) {
      pq.push(a[k].second);
      k++;
    }
    if (!pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1660
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

int n;
string s, t;

void solve() {
    int idx_t = 0;
    rep(i, n) {
        while (i < n && idx_t < n && s[i] == t[idx_t]) {
            i++, idx_t++;
        }
    }
    cout << n + n - idx_t;
}

int main() {
    cin >> n >> s >> t;
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.TreeMap;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readCard(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		M = Integer.parseInt(strArr[1]);
	}

	int M;

	public void readCard(String str) {
		Card = new TreeMap<Integer, Integer>();
		String[] strArr = str.split(" ");
		for (int i = 0; i < N; i++) {
			int card = Integer.parseInt(strArr[i]);
			addCard(card, 1);
		}
	}

	TreeMap<Integer, Integer> Card;

	private void addCard(int card, int num) {
		if (Card.containsKey(card))
			Card.put(card, Card.get(card) + num);
		else
			Card.put(card, num);
	}

	public boolean hasNext() {
		// return cnt < N;
		return cnt < M;
	}

	public void readBody(String str) {
		// System.out.println(str);
		String[] strArr = str.split(" ");
		int b = Integer.parseInt(strArr[0]);
		int c = Integer.parseInt(strArr[1]);
		ArrayList<Integer> zero = new ArrayList<Integer>();
		for (int last = b; last > 0;) {
			int chg = 0;
			int chgCard = 0;
			zero.clear();
			for (int card : Card.keySet()) {
				if (card >= c)
					last = 0;
				if (last <= 0)
					break;
				chg = Integer.min(last, Card.get(card));
				if (chg > 0) {
					chgCard = card;
					break;
				} else {
					zero.add(card);
				}
			}
			if (chg > 0) {
				addCard(chgCard, -1 * chg);
				addCard(c, chg);
				last -= chg;
			}
			for (int card : zero) {
				Card.remove(card);
			}
		}

		cnt++;
	}

	public void solve() {
		long ans = 0;
		for (int card : Card.keySet()) {
			// System.out.println(card + " " + Card.get(card));
			ans += ((long) card * (long) Card.get(card));
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 78368
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll l,r,d;
    cin >> l >> r >> d;
    ll res = 0;
    for(ll i=l; i<=r; i++){
        if(i%d==0) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3632