akhauriyash/Code-Regression huggingface dataset:
macro_rules! check {
    ($b:expr) => {
        if !$b {
            println!("-1");
            return;
        }
    };
}

const ALL1: u64 = u64::max_value();

fn main() {
    proconio::input! {
        n: usize,
        s: [u8; n],
        t: [u8; n],
        u: [u64; n],
        v: [u64; n],
    }
    let s: Vec<_> = s.iter().map(|&i| i == 1).collect();
    let t: Vec<_> = t.iter().map(|&i| i == 1).collect();
    let mut mat = vec![vec![0; n]; n];
    for i in 0..n {
        for j in 0..n {
            mat[i][j] = u[i] & v[j];
            if !s[i] {
                mat[i][j] |= u[i];
            }
            if !t[j] {
                mat[i][j] |= v[j];
            }
            check!(!s[i] || mat[i][j] & !u[i] == 0);
            check!(!t[j] || mat[i][j] & !v[j] == 0);
        }
    }
    for i in 0..n {
        let and = (0..n).map(|j| mat[i][j]).fold(ALL1, |a, b| a & b);
        check!(s[i] || and & !u[i] == 0);
    }
    for j in 0..n {
        let and = (0..n).map(|i| mat[i][j]).fold(ALL1, |a, b| a & b);
        check!(t[j] || and & !v[j] == 0)
    }
    for i in 0..n {
        if !s[i] {
            continue;
        }
        let mut ok = !u[i] | (0..n).map(|j| mat[i][j]).fold(0, |a, b| a | b);
        for j in 0..n {
            if t[j] {
                continue;
            }
            let set = !v[j] & !ok;
            mat[i][j] |= set;
            let ng = !v[j] & (0..n).map(|i| mat[i][j]).fold(ALL1, |a, b| a & b);
            mat[i][j] &= !ng;
            ok |= mat[i][j];
        }
        check!(ok == ALL1)
    }
    for j in 0..n {
        if !t[j] {
            continue;
        }
        let mut ok = !v[j] | (0..n).map(|i| mat[i][j]).fold(0, |a, b| a | b);
        for i in 0..n {
            if s[i] {
                continue;
            }
            let set = !u[i] & !ok;
            mat[i][j] |= set;
            let ng = !u[i] & (0..n).map(|j| mat[i][j]).fold(ALL1, |a, b| a & b);
            mat[i][j] &= !ng;
            ok |= mat[i][j];
        }
        check!(ok == ALL1)
    }
    for i in 0..n {
        println!(
            "{}",
            mat[i]
                .iter()
                .map(|&x| x.to_string())
                .collect::<Vec<_>>()
                .join(" ")
        );
    }
}


Measured memory_bytes: 7568
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>
 
const int64_t cc = pow( 10, 9 ) + 7;
 
bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.first < another.first;
}

int64_t check( int64_t num )
{
    if( num == 1 )
    {
        return 1;
    }
    else
    {
        return 2 * check( num / 2 ) + 1;
    }
}

int main()
{
    int64_t a,b,c,d,e;
    std::cin>> a;
    
    c = check( a );
    std::cout<< c <<"\n";
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==25)
	cout<<"Christmas"<<endl;
	if(n==24)
	cout<<"Christmas Eve"<<endl;
	if(n==23)
	cout<<"Christmas Eve Eve"<<endl;
	if(n==22)
	cout<<"Christmas Eve Eve Eve"<<endl;
	
	
	
	return 0;
} 

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


def solve(K: int, X: int):
    left = max(-1000000, X-K)
    right = min(1000000, X+K)
    ans = [str(i) for i in range(left+1, right)]
    print(' '.join(ans))
    return


# Generated by 1.1.4 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():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <stack>

using namespace std;

typedef long long ll;
#define mem(a) (memset(a,0,sizeof(a)))
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define MAX(a, b) ((a)>(b)?(a):(b))
#define MIN(a, b) ((a)<(b)?(a):(b))

const int maxn = static_cast<const int>(1e5 + 5);
const int mod = static_cast<const int>(1e9);

int a[maxn];

int main() {
    int n, x;
    ll sum = 0;
    scanf("%d%d", &n, &x);
    rep(i, n)scanf("%d", &a[i]);
    for (int i = 1; i < n; i++) {
        int cha = a[i] + a[i - 1] - x;
        if (cha > 0) {
            if (a[i] > cha) {
                a[i]-=cha;
                sum+=cha;
            } else {
                a[i]=0;
                cha-=a[i];
                a[i-1]-=cha;
                sum+=cha;
            }
        }
    }
    printf("%lld\n",sum);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <utility>
#include <stack>
#include <queue>
#include <ctype.h>
#include <iomanip>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    vector<int> B(N);
    B = A;
    sort(B.begin(),B.end(),greater<int>());
    for (int i=0;i<N;i++){
        if (A[i] == B[0]) cout << B[1] << endl;
        else cout << B[0] << endl;
    }


    return 0;
}

Measured memory_bytes: 3200
from collections import deque
inf=100000000000000000000
N = input()
N = int(N)
path=[[] for i in range(N)]
for fuga in range(N-1):
    a,b,c=map(int, input().split())
    path[a-1].append([b-1,c])
    path[b-1].append([a-1,c])
Q,K=map(int, input().split())
stack=deque()
stack.append(K-1)
Kcost=[0]*N#あとあと初期化
went=[False]*N
went[K-1]=True
while stack:
    cur=stack.pop()
    curcost=Kcost[cur]
    for next,c in path[cur]:
        if c and not went[next]:
            went[next]=True
            Kcost[next]=curcost+c
            stack.append(next)
for q in range(Q):
    x,y=map(int, input().split())
    print(Kcost[x-1]+Kcost[y-1])
    


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

counter = 0
for i in range(N-1):
    min_index = i
    for j in range(i,N):
        v = A[j]
        min = A[min_index]
        if A[j] < A[min_index]:
            min_index = j
    if min_index != i:
        temp = A[min_index]
        A[min_index] = A[i]
        A[i] = temp
        counter = counter + 1

print(' '.join([str(a) for a in A]))
print(counter)




Measured memory_bytes: 5608
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[m];
        int[][] s = new int[m][];
        for (int i = 0; i < m; i++) {
            k[i] = sc.nextInt();
            s[i] = new int[k[i]];
            for (int j = 0; j < k[i]; j++) {
                s[i][j] = sc.nextInt();
            }
        }
        int[] p = new int[m];
        for (int i = 0; i < m; i++) {
            p[i] = sc.nextInt();
        }
        sc.close();

//        n = 10;
//        System.out.println(pow(2, n));
//        System.out.println(toBinaryString(3));
        int ans = 0;
        for (int i = 0; i < pow(2, n); i++) {
            String target = toBinaryString(i).substring(19); // 10桁のbinary文字列
//            System.out.println(target);
            boolean isOk = true;
            for (int j = 0; j < m; j++) {
                int count = 0;
                for (int a = 0; a < k[j]; a++) {
//                    System.out.println("target.length(): " + target.length());
//                    System.out.println("s[j][a]: " + s[j][a]);
                    if (target.charAt((target.length() - 1) - (s[j][a] - 1)) == '1') {
                        count++;
                    }
                }
                if (count % 2 != p[j]) {
                    isOk = false;
                    break;
                }
            }
            if (isOk) {
                ans++;
            }
        }
        System.out.println(ans);
    }

    // intを29桁のbit文字列に変換
    static String toBinaryString(int input) {
        String ret = "";
        int max = 0x10000000;
        for (int i = 0; i < 29; i++) {
            int tmp = input / max;
            ret += tmp;
            input %= max;
            max /= 2;
        }
        return ret;
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

}


Measured memory_bytes: 29908
#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define lli long long int
#define f(i,a,b) for (lli i = a; i <= b; i++)
#define fr(i,a,b) for (lli i = a; i >= b; i--)
#define sl(x)	scanf("%lld",&x)
#define pl(x)	printf("%lld",x)
#define ss(s)	scanf("%s",s)
#define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

vector<lli> dp(100005, -1);
vector<lli> a(100005, 0);
lli n, k;
lli fun(lli idx)
{
	if (idx == n - 1)
		return 0;
	
	if (dp[idx] != -1)
		return dp[idx];
	
	lli val = INT_MAX;
	f(i, idx + 1, min(n, idx + k))
	val = min(val, abs(a[i] - a[idx]) + fun(i));
	
	return dp[idx] = val;
}
void solve()
{
	cin >> n >> k;
	f(i, 0, n - 1)
	cin >> a[i];
	cout << fun(0);
}
int main()
{
	IOS;
	solve();
	return 0;
}

Measured memory_bytes: 11116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define plint pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n;
    string s;
    cin >> n >> s;
    ll a=0,b=0,c=0;

    FOR(i,0,n){
        if(s[i]=='R'){
            a++;
        }else if(s[i]=='G'){
            b++;
        }else{
            c++;
        }
    }
    // ひとつめの条件をみたす
    ll res = a*b*c;

    // ひとつめ満たすけど、ふたつめの条件をみたさないものは引く
    FOR(i,0,n){
        FOR(j,i+1,n){
            int k=j+j-i;
            if(k>=n) continue;
            if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i]){
                res--;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;


long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

int main(){
    ll n,m;cin>>n>>m;
    ll res = 0;
    if(n>1)res += combi(n,2);
    if(m>1)res += combi(m,2);
    cout<<res;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  cin>>n;
  i=1;
  while(i*i<=n)i++;
  cout<<(i-1)*(i-1)<<endl;



}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	string s, t;
	cin >> s >> t;
	int sum = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s.at(i) != t.at(i))
			sum++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3896
function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const b = parseInt(input.split(" ")[1], 10);
  const c = parseInt(input.split(" ")[2], 10);
  if(a+b==c||a+c==b||a==b+c){
    console.log("Yes");
  }else{
    console.log("No");
  }


}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  for(int i = 0; i < s.size() - 1; i ++){
    if(s.at(i) == s.at(i+1)){
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    int sum=0;
    map<int,int> cnt;
    cnt[sum]++;
    REP(i,N){
        sum+=a[i];
        cnt[sum]++;
    }
    
    int ans=0;
    for(pint p:cnt){
        ans+=p.second*(p.second-1)/2;
    }
    cout<<ans<<endl;
}


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

int N, M; pair<int, int> T[100100];

int main()
{
	scanf ("%d %d", &N, &M);
	for (int i = 0; i < N; i++) scanf ("%d %d", &T[i].first, &T[i].second);
	sort(T, T + N);
	priority_queue<int> Q;
	long long ans = 0;
	for (int i = 1, j = 0; i <= M; i++){
		while (j < N && T[j].first <= i){
			Q.push(T[j].second);
			j++;
		}
		if (!Q.empty()){
			ans += Q.top();
			Q.pop();
		}
	}
	printf ("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1660
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return;
}

int main()
{
	ll X = 0, i = 0, j = 0;
	scanf("%lld", &X);

	for (i = 100; i < X; ) {
		i = i + (i/100);
		j++;
	}
	printf("%I64d\n", j);
	return 0;
}


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

int main(){
    ll n,i;
    bool judge = true;
    string s;
    cin >> n;
    cin >> s;
    if(n % 2 == 1 ) judge = false;
    else{
        i = 0;
        while(judge && i < n/2){
            if(s[i] != s[i+n/2]){
                judge = false;
            }
            i++;
        }
    }
    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

int dfs(string &S, string &s_pre, string &s_post, int i) {
    if (i == S.size()) {
        return 0;
    }
    else {
        s_post.push_back(S[i]);
        if (s_pre==s_post) {
            return dfs(S, s_pre, s_post, i+1);
        }
        else {
            s_pre = s_post;
            s_post = {};
            return dfs(S,s_pre,s_post,i+1)+1;
        }
    }
}

int main() {
    string S;
    cin >> S;
    string s_pre,s_post;
    int ans = dfs(S,s_pre, s_post, 0);
    cout << ans << endl;

 }



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;

typedef long long ll;

const int N = 19;
const int MAXN = (1<<N);
const int MAXVAL = 1e9;

int dp[N + 1][MAXN];

int A[N + 5], B[N + 5];
int n;

int solve(int pre, int bmask) {
	if(bmask == 0) return 0;
	int &res = dp[pre][bmask];
	if(res != -1) return res;
	res = MAXVAL;
	int getID = n + 1 - __builtin_popcount(bmask);
	int pval = A[pre];
	if((getID + pre + 1) % 2) pval = B[pre];
	int pass = getID - 1;
	for(int i = 1;i <= n;i++) {
		if(bmask & (1<<i)) {
			int curval = A[i];
			if((getID + i) % 2) curval = B[i];
			if(pval > curval) continue;
			res = min(res, solve(i, bmask ^ (1<<i)) + (i + pass - getID));
		} else pass--;
	}
	return res;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>n;
	memset(dp, -1, sizeof dp);
	for(int i = 1;i <= n;i++) cin>>A[i];
	for(int i = 1;i <= n;i++) cin>>B[i];
	int result = solve(0, (1<<(n + 1)) - 2);
	if(result >= MAXVAL) result = -1;
	cout<<result<<endl;
}

Measured memory_bytes: 41216
import sys
n = int(input())

strs = input().split()
sum = 1
out_range = False
for i in range(n):
  v = int(strs[i])
  if(not out_range):
    sum *= v
    if(sum > 1000000000000000000):
      out_range = True

  if(v == 0):
    print(0)
    sys.exit()
    
if(not out_range):
  print(sum)
else:
  print(-1)

Measured memory_bytes: 19284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

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

    int h, w, n;
    cin >> h >> w >> n;
    int x = max(h, w);
    cout << (n + x - 1) / x << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    if(a>=499) {
        cout << "Yes" << endl;
        return 0;
    }
    if(n%500<=a) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
      ll n,k,c=0;
      cin>>n>>k;
       while(n>0){
           c++;
           n=n/k;
      }    
    cout<<c<<endl;
    }



Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if((x-r)>=0&&W>=(x+r)&&(y-r)>=0&&H>=(y+r)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1812
#include<bits/stdc++.h>
using namespace std;
int n;
int d[15];
int main(void)
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>d[i];
	
	int mx =0,s=0;
	for(int i=0;i<n;i++) mx=max(mx,d[i]),s+=d[i];
	cout<<s-mx/2<<endl;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int>(3));
    for (int i = 0; i < n; ++i) {
        cin>>a[i][0];
        cin>>a[i][1];
        cin>>a[i][2];
    }
    vector<int> s(n,0);
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < n; ++j) {
            bool p=true;
            for (int k = 0; k < n; ++k) {
                if(j!=k&&a[j][i]==a[k][i])p=false;
            }
            if(p)s[j]+=a[j][i];
        }
    }
    for (int i = 0; i < n; ++i) {
        cout<<s[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include<iostream>
void merge(long long n[], long long left, long long mid, long long right)
{
    long long num = right - left;
    long long *tmp = new long long[num];

    long long iw = 0;
    long long il = left;
    long long ir = mid;

    while (il < mid && ir < right)
    {
        if (n[il] <= n[ir])
        {
            tmp[iw++] = n[il++];
        } else {
            tmp[iw++] = n[ir++];
        }
    }

    while (il < mid) tmp[iw++] = n[il++];
    while (ir < right) tmp[iw++] = n[ir++];

    for (int i=0; i<num; i++) n[left + i] = tmp[i];

    delete[] tmp;
}


void merge_sort_sub(long long n[], long long left, long long right)
{
    if (right - left <= 1) return;

    long long mid = left + (right - left) / 2;
    merge_sort_sub(n, left, mid);
    merge_sort_sub(n, mid, right);

    merge(n, left, mid, right);
}


void merge_sort(long long n[], long long len)
{
    merge_sort_sub(n, 0, len);
}
using namespace std;
int main(){
int n;
cin >>n;
long long a[n];
long long max1=0;
for(int i=0;i<n;i++){
cin >> a[i];
if(max1<a[i]){
max1=a[i];
}
}
 merge_sort(a,n);
long long x=0;
long long y=0;
long long count1=0;
for(int i=n-1;i>=0;i--){
if(x!=0&&y!=0){
break;}
if(max1==a[i]){
count1++;}
else{
max1=a[i];
count1=1;
}
if(count1==2){
if(x==0){
x=max1;
}
else if(y==0){
y=max1;
}
}
if(count1==4){
if(y==0){
y=max1;
}
}
}
unsigned long long ans=x*y;
cout <<ans<<endl;
return 0;}

Measured memory_bytes: 2228
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

ll h,w;
char a[101][101];
bool search(ll x,ll y){
    ll flag=0;
    for(ll i=0;i<w;++i){
        if(a[x][i]=='#'){
            flag++;
        }
    }
    if(flag==0){
        return false;
    }
    flag=0;
    for(ll i=0;i<h;++i){
        if(a[i][y]=='#'){
            flag++;
        }
    }
    if(flag==0){
        return false;
    }
    return true;
}
int main(){
    cin>>h>>w;
    bool bol=false;
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            cin>>a[i][j];
        }
    }
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            if(a[i][j]=='#'){
                cout<<'#';
                bol = true;
            }else{
                if(search(i,j)){
                    cout<<'.';
                    bol = true;
                }
            }
        }
        if(bol){
            cout<<endl;
        }
        bol = false;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY (1<<30)
int main(){
    int n;
    cin >> n;
    int A[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> A[i];
    }
    int ans = 0, a = INFTY;
    for(int i = 1; i <= n; i++){
        a = min(a, A[i]);
        if(A[i] == a){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    string S,T;
    cin >> S >> T;
    int A,B;
    cin >> A >> B;
    string U;
    cin >> U;

    if( S == U ) cout << A-1 << " " << B << endl;
    else if( U == T ) cout << A << " " << B-1 << endl;
    else cout << A << " " << B << endl;
}


Measured memory_bytes: 256
a,b,c,d,e,f = map(int,input().split())
maxden = 0
amax = f //(a*100)
water=a*100
sugar=0
for i in range(amax+1):
  waterA = i*100*a
  res = f-waterA
  bmax = res // (b*100)
  for j in range(bmax+1):
    waterB = j*100*b
    waterS =waterA+waterB
    res = f-waterS
    cmax = res // c
    for k in range(cmax+1):
      sugarC = k*c
      res = f-waterS-sugarC
      dmax = res // d
      for l in range(dmax+1):
        sugarD = l*d
        sugarS = sugarC+sugarD
        if(sugarS+waterS==0):break
        den = (sugarS)*100/(sugarS+waterS)
        #if(den>49 and den<50.1):print(res-sugarD,waterA,waterB,sugarC,sugarD,den)
        #if(sugarS==146 and waterS==200):print(waterS,sugarS,den,(den*(100+e))/100,e)
        #if(sugarS==582 and waterS==800):print(waterS,sugarS,den,(den*(100+e))/100,e)
        if(den>maxden and (den*(100+e)/100)-e<=10**-5):
          maxden = den
          sugar = sugarS
          water = waterS

print(str(water+sugar)+" "+str(sugar))
#print(maxden)

Measured memory_bytes: 3064
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long ll;

int main(void) {
    ll n;
    cin >> n;

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

    ll all = 0;
    for (ll i = 0; i < n; i++) {
        all += a[i];
    }

    ll sum = a[0];
    ll ans = abs(sum - (all - sum));
    for (ll i = 1; i < n - 1; i++) {
        sum += a[i];
        ans = min(ans, abs(sum - (all - sum)));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
typedef long long ll;
int main() {
	ll n, m, ans;
	scanf("%lld%lld", &n, &m);
	// S*1andc*2, c*4 => Scc
	ll left = m - (n * 2);
	if (left >= 0) {
		ans = n;
		ans += left / 4;
	} else {
		ans = m / 2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>
#include <complex>
#include <bitset>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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

class UnionFind {
public:
    int n;
    vector<int> parent;
    vector<int> rank;
    UnionFind(int m) {
        n = m;
        parent.resize(n);
        rank.resize(n, 0);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
        }
    }

    int find(int node) {
        if (parent[node] == node) {
            return node;
        } else {
            parent[node] = find(parent[node]);
            return parent[node];
        }
    }

    void unite(int node1, int node2) {
        node1 = find(node1);
        node2 = find(node2);
        if (node1 == node2) {
            return;
        } else {
            if (rank[node1] < rank[node2]) {
                parent[node1] = node2;
            } else if (rank[node1] > rank[node2]) {
                parent[node2] = node1;
            } else {
                parent[node1] = node2;
                rank[node1] += 1;
            }
        }
    }

    bool same(int node1, int node2) {
        node1 = find(node1);
        node2 = find(node2);
        if (node1 == node2) {
            return true;
        } else {
            return false;
        }
    }
};

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n); rep(i, n) cin >> a[i];
    UnionFind uf(n);
    rep(i, m) {
        int x, y; cin >> x >> y;
        uf.unite(x, y);
    }

    ll ans = 0;
    int group = 0;
    vector<vector<int>> box(n);
    rep(i, n) {
        if (uf.find(i) == i) group++;
        int p = uf.find(i);
        box[p].push_back(a[i]);
    }
    if ((group-1)*2 > n) {
        cout << "Impossible" << endl;
        return 0;
    }
    if (group == 1) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> box2;
    rep(i, n) {
        if (uf.find(i) == i) {
            sort(box[i].begin(), box[i].end());
            ans += box[i][0];
            for (int j = 1; j < box[i].size(); j++) {
                box2.push_back(box[i][j]);
            }
        }
    }

    sort(box2.begin(), box2.end());
    rep(i, group-2) ans += box2[i];
    cout << ans << endl;
    

    return 0;
}


    


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n;
  
  ll a[n];
  vector<ll> cnt(n+10);
  for (ll i = 0; i < n; ++i)
  {
  cin>>a[i];
  cnt[a[i]]++;
  }
  for (int i = 0; i <= n; ++i)
  {
  	x = cnt[i];
    ans +=  x * (x - 1) /2;
  }
  for (int i = 0; i < n; ++i)
  {
  	x = cnt[a[i]];
  	cout<< ans - x * (x - 1) / 2 + (x -1 ) * ( x - 2) / 2<<"\n";
  }

}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


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

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans=5000*1e5+5000*1e5+1;
  
  int n=max(x, y)*2;
  int ai, bi, ci;
  rep(i, n+1){
    ai = bi = ci = 0;
    
    ci = i;
    (x-ci/2)>0 ? ai=x-ci/2 : ai=0;
    (y-ci/2)>0 ? bi=y-ci/2 : bi=0;
    ans = min(ans, a*ai+b*bi+c*ci);
  }
  cout << ans << endl;  
  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
	int n,a=0,w=0,t=0,r=0;
	scanf("%d",&n);
	char c;
	for(int i=0;i<n;i++){
		do{
			scanf("%c",&c);
		}while(c!='\n');
		
		scanf("%c",&c);
		if(c=='A'){
			a++;
		}else if(c=='W'){
			w++;
		}else if(c=='T'){
			t++;
		}else{
			r++;
		}
	}
	
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,w,t,r);
}

Measured memory_bytes: 1724
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define PI 3.14159265358979
#define MOD 1000000007

using namespace std;

int main(void) {
	long long int a, b, l, m, n;
	int x[200000];
	int i, j, k;
	bool flag = true;
	cin >> n;
	for (i = 0; i < n; i++) {
		x[i] = 0;
	}
	for (i = 0; i < n - 1; i++) {
		cin >> m;
		x[m - 1]++;
	}
	for (i = 0; i < n; i++) {
		cout << x[i] << endl;
	}
	

	return 0;
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,a,n) for(ll i=a;i<n;i++)
#define ford(i,a,n) for(ll i=n-1;i>=a;i--)
#define testc  ll ts;\
               cin>>ts;\
               while(ts--)
#define arn ll n;\
            cin>>n;\
            ll a[n];\
            forr(i,0,n)cin>>a[i];\
               
#define arr(a,n) ll a[n];\
                 forr(i,0,n)cin>>a[i];\
 
#define sss <<" "<<
#define nnn <<"\n"
#define nl cout<<"\n";
using namespace std;
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,d,ctr=0;
    cin>>n>>d;
    forr(i,0,n){
        ll a,b;
        cin>>a>>b;
        if(a*a+b*b<=d*d)ctr++;
    }
    cout<<ctr;
    return 0;
}

Measured memory_bytes: 3692
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    b, c = map(int, input().split())
    B += [b]
    C += [c]
s = set()
d = {}
for i in range(N):
    if A[i] not in d:
        d[A[i]] = 1
        s.add(A[i])
    else:
        d[A[i]] += 1

result = sum(A)
for i in range(len(B)):
    if B[i] in s:
        result -= B[i]*d[B[i]]
        result += C[i]*d[B[i]]
        if C[i] not in d:
            d[C[i]] = d[B[i]]
        else:
            d[C[i]] += d[B[i]]
        s.add(C[i])
        s.remove(B[i])
        del d[B[i]]
    print(result)

Measured memory_bytes: 30136
// Problem : C - Step
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	cio;
	lli n,i,ans=0;
	cin>>n;
	lli a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=1;i<n;i++){
		if(a[i]<a[i-1]){
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 5168
#include <iostream>

using namespace std;

int a[200005];

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	int xor_sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		xor_sum ^= a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cout << (xor_sum ^ a[i]);
		if (i < n - 1)
		{
			cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n;
    cin >> n;
    int P[n];
    REP(i,n) cin >> P[i];

    int A[n] = {},B[n] = {};

    REP(i,n){
        A[i] = n * i + 1;
        B[n-1-i] = n * i + 1;
    }

    REP(i,n){
        A[P[i]-1] += i;
    }

    REP(i,n) cout << A[i] << " ";
    cout << endl;
    REP(i,n) cout << B[i] << " ";
    cout << endl;

}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstdlib>

using namespace std;

long long MOD = 1000000000 + 7;

long long kaijo(long long s) {
  if ( s== 0 ) {
    return 1;
  } else {
    return (kaijo(s-1) * s) % MOD;
  }
}

int main() {
  long long N,M;
  scanf("%lld%lld", &N, &M);

  if (abs(N-M) >= 2) {
    printf("0");
    return 0;
  }


  if (N==M){
    printf("%lld", ((kaijo(N)%MOD) * (kaijo(M)%MOD) * 2) % MOD);
  } else {
    printf("%lld", ((kaijo(N)%MOD) * (kaijo(M)%MOD)) % MOD);
  }

  return 0;
}

Measured memory_bytes: 1664
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    # N = int(input())
    N,M = map(int, input().split())
    MOD = 1000000007
    AS = [int(input()) for _ in range(M)]
    AS = set(AS)
    dp = [0]*(N+1)
    dp[0] = 1
    dp[1] = 1 if 1 not in AS else 0
    for n in range(2,N+1):
        if n in AS: continue
        if n-1 not in AS:
            dp[n] += dp[n-1]
            dp[n] %= MOD
        if n-2 not in AS:
            dp[n] += dp[n-2]
            dp[n] %= MOD
    print(dp[N])

if __name__ == '__main__':
    main()

Measured memory_bytes: 13936
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;//d, v
const int max_n = 5000+10;
const int INF = 1e6;
struct edge{
  int from,to,cost;
};
bool comp(const edge& e1, const edge& e2){
  return e1.cost < e2.cost;
}
ll a,b,c,x,y;
vector<edge> G[max_n];
int dist[max_n];
int dist2[max_n];
edge es[max_n];
ll dp[max_n][max_n];
int main(){
  cin >> a>>b>>c>>x>>y;
  ll atob = a + b;
  ll ans = 0;
  ll mi = min(x,y);
  if(atob < 2*c){
      ans += a*x + b*y;
  }else{
    ans += mi*2*c;
    x -= mi;  y -= mi;
    ans += min(x*a+y*b, 2*c*max(x,y));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
fun main(){
  val x : Int = readInt()

  println(x * 3.141592 * 2)

}


fun readLn() = readLine()!! // string line
fun readInt() = readLn().toInt() // single int
fun readStrings() = readLn().split(" ") // list of strings
fun readInts() = readStrings().map { it.toInt() } // list of ints

Measured memory_bytes: 34660
def judge_yymm(aa,bb):
	if 0<bb<13:
		return True
	return False
	
def judge_mmyy(aa,bb):
	if 0<aa<13:
		return True
	return False

s=input()
num=int(s)
#aabb
aa,bb=num//100,num%100
#YYMM, MMYY, AMBIGUOUS, NA 
if judge_mmyy(aa,bb):
	if judge_yymm(aa,bb):
		print('AMBIGUOUS')
	else:
		print('MMYY')
else:
	if judge_yymm(aa,bb):
		print('YYMM')
	else:
		print('NA')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	vector<int> A(N), B(M);
	long long sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	for (int i = 0; i < M; i++) cin >> B[i];
	int MAX = 0, ai = N - 1, now = N;
	if (sum <= K) MAX = now;
	for (int i = 0; i < M; i++) {
		sum += B[i];
		now++;
		while (sum > K && ai >= 0) {
			sum -= A[ai];
			ai--;
			now--;
		}
		if (sum > K) break;
		MAX = max(MAX, now);
	}
	cout << MAX << endl;
}


Measured memory_bytes: 4824
#include<stdio.h>
int main(void){
  int n,n1,n2,n3;
  scanf("%d",&n);
  n1=n%10;
  n2=(n/10)%10;
  n3=n/100;
  if(n1==7 || n2==7 || n3==7){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>v(n);
  for(int i = 0;i < n;i++){
    cin >> v.at(i);
  }
  int q;
  cin >> q;
  vector<int>e(q);
  for(int i = 0;i < q;i++){
    cin >> e.at(i);
  }
  int counter = 0;
  for(int i = 0;i < q;i++){
  if(binary_search(v.begin(),v.end(),e.at(i)) == true){
    counter++;
  }
}
cout << counter << endl;
}


Measured memory_bytes: 3356
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll X, Y;
  cin >> X >> Y;

  cout << X + Y / 2 << "\n";
  
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define get(a,t) get<a>(t)
#define EPS 0.000000001 //1e-9
using pii=pair<int,int>;
const int INF=1e18;

void dprint(string s) { cout << endl;}
void dprint() { cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w=s.find(','); cout <<"["<< s.substr(0,w) << ": " << t << "] " ; dprint(s.substr(w+1, sz(s)-w), u...);} 


#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...); 
#endif
const int N=100005;

int32_t main()
{
	IOS;
	int n,m; cin>>n>>m;
	int h[n];
	for(int &x:h)
		cin>>x;
	vector<int> adj[n+1];
	for(int i=0;i<m;i++)
	{
		int a,b; cin>>a>>b;
		a--,b--;
		adj[a].pb(b); adj[b].pb(a);
	}
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		int flg=true;
		int val=h[i];
		for(int x:adj[i])
			if(h[x]>=val)
				flg=false;
		if(flg)
			cnt++;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 10272
from collections import deque

H, W = map(int, input().split())
# 周りを#dで囲う
ss = ['#' + input() + '#' for i in range(H)]
ss = ['#' * (W + 2)] + ss + ['#' * (W + 2)]

# 初期の白の数を数える
numWhite = sum(map(lambda s: s.count('.'), ss))

# 上下左右
dij = [(0, -1), (0, 1), (-1, 0), (1, 0)]

# 各点への距離の初期値をINFに設定
dist = [[float('inf')] * (W + 2) for i in range(H + 2)]
# スタート地点の距離は1
dist[1][1] = 1

# O(1)で配列操作をする為にdequeを採用
# 操作未完了リストをqueueに追加していく
#  (x,y)で記入
Q = deque()
# start地点を追加
Q.append((1, 1))

# 操作未完了リストが空になるまで行う
while Q:
  # Qの左から取り出し
  i, j = Q.popleft()
  # 上下左右で同じ操作を行う
  for di, dj in dij:
    # 白でまだ距離が確定していなかったら操作を行う
    if (ss[i + di][j + dj] == '.') & (dist[i + di][j + dj] == float('inf')):
      # 距離を移動元から一つ増やす
      dist[i + di][j + dj] = dist[i][j] + 1
      # 操作未完了リストに追加
      Q.append((i + di, j + dj))

#　ゴールがINFなら到着できなかったので、-1を返す
if dist[H][W] == float('inf'):
    print(-1)
# ゴールできた場合、最初の白の数から最短距離を引く
else:
    print(numWhite - dist[H][W])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef bool bolean;

#define ll long long

const int V = 1e9;

ll S;

int main() {
	scanf("%lld", &S);
	if (S == 1000000000000000000ll) {
		printf("%d 0 0 0 0 %d\n", V, V);
		return 0;
	}
	int z = S / V;
	int y = V;
	int x = 1;
	int h = S % V;
	printf("0 %d %d 0 %d %d\n", y, x, x + z, h);
	return 0;
}


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

sc = 0
wmin = int(1e10)

for a in A:
  if a < 0:
    sc += 1
  wmin = min(wmin, abs(a))
  
ans = sum(B) if sc%2 == 0 else sum(B) - 2*wmin
print(ans)

Measured memory_bytes: 14284
n, m = list(map(int, input().split()))
ac = [0] * n
wa = [0] * n
numac = 0
numwa = 0
p = 0
for i in range(m):
    _a, _s = list(input().split())
    _a = int(_a)
    if _s == "AC":
        if ac[_a - 1] == 0:
            numac += 1
            ac[_a - 1] = 1
            numwa += wa[_a - 1]
    elif _s == "WA":
        if ac[_a - 1] == 0:
            wa[_a - 1] += 1
print("{} {}".format(numac, numwa))


Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
const int m=1e9+7;
int dp[100][100005];
int arr[100];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(int i=0;i<=arr[0];i++)
    {
        dp[0][i]=1;
    }
    for(int i=1;i<n;i++)
    {
        //dp[i]
        vector<int>prefix(k+1);
        prefix[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            prefix[j]=(prefix[j-1]+dp[i-1][j])%m;
        }
        for(int j=0;j<=k;j++)
        {
            if(j>arr[i])
            dp[i][j]=(prefix[j]+m-prefix[j-arr[i]-1])%m;
            else
            dp[i][j]=prefix[j];
        }
    }
    cout<<dp[n-1][k];
    return 0;
}


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

int main() {
  int N, M;
  int A, B;
  cin >> N >> M;

  vector<int> goodpnt(N, 1);
  vector<unsigned int> height(N);
  for (int i = 0; i < N; i++) {
    cin >> height.at(i);
  }

  for (int i = 0; i < M; i++) {
    cin >> A >> B;
    if (height.at(A-1) > height.at(B-1)) {
      goodpnt.at(B-1) = 0;
    } else if (height.at(A-1) < height.at(B-1)) {
      goodpnt.at(A-1) = 0;
    } else {
      goodpnt.at(A-1) = 0;
      goodpnt.at(B-1) = 0;
    }
  }
  int sum = 0;
  for(int i = 0; i < N; i++) {
    sum += goodpnt.at(i);
  }
  cout << sum << endl;
}


Measured memory_bytes: 4048
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 1000000
#define LL long long
using namespace std;

const LL mod=1e9+7;
int k;
LL fac[N*2+5],facinv[N*2+5];
char s[N+5];
LL ksm(LL x,LL y)
{
	LL res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res;
}
LL C(int x,int y)
{
	return fac[x]*facinv[y]%mod*facinv[x-y]%mod;
}
int main()
{
	int i,j;
	scanf("%d",&k);
	scanf("%s",s+1);
	fac[0]=1;
	for(i=1;i<=(N<<1);i++)
		fac[i]=fac[i-1]*i%mod;
	facinv[N<<1]=ksm(fac[N<<1],mod-2);
	for(i=N*2-1;i>=0;i--)
		facinv[i]=facinv[i+1]*(i+1)%mod;
	int n=strlen(s+1);
	LL ans=0;
	for(i=0;i<=k;i++)
		ans+=ksm(25,i)*ksm(26,k-i)%mod*C(n+i-1,n-1)%mod;
	printf("%lld\n",ans%mod);
	return 0;
}

Measured memory_bytes: 35860
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
int n;
std::vector<int> d;
int main(){
	std::cin >> n;
	for(int i = 0; i < n; i++){
		int tmp;
		std::cin >> tmp;
		d.push_back(tmp/ 10);
	}
	bool flag = true;
	int st = 0;
	for(int i = 0; i < n - 1; i++){
		st = std::max(st, d[i]);
		if(st <= 0)flag = false;
		st--;
	}
	if(st < 0)flag = false;	
	st = 0;
	std::reverse(d.begin(), d.end());
	for(int i = 0; i < n - 1; i++){
		st = std::max(st, d[i]);
		if(st <= 0)flag = false;
		st--;
	}
	if(st < 0)flag = false;
	std::cout << (flag ? "yes" : "no") << std::endl;
	return 0;
}


Measured memory_bytes: 4968
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int n,k;
double f(int x){
	int tmp=0;
	while(x<k)
		x*=2,tmp++;	
	return 1.0/(1<<tmp);		
}
int main(){
    scanf("%d%d",&n,&k);
    long double ans=0;
    for(int i=1;i<=n;i++)
    	ans+=f(i);
    ans/=n;	
    cout<<setprecision(13)<<ans<<endl;	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int L;
	int R;
	int d;
	scanf("%d %d %d",&L,&R,&d);
	int c=0;
	for (int i=L;i<=R;i++){
		if(i%d == 0){
			c++;
		}else{
			continue;
		}
	}
	printf("%d",c);
return 0;
}

Measured memory_bytes: 1716