akhauriyash/Code-Regression huggingface dataset:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def bfs():
    dist = [-1]*n
    que = deque([i])
    dist[i] = 0
    ans[0] += 1
    while que:
        v = que.popleft()
        d = dist[v]
        for w in g[v]:
            if dist[w] > -1:
                continue
            dist[w] = d + 1
            ans[d+1] += 1
            que.append(w)

n, x, y = MAP()
x -= 1
y -= 1
g = [[] for i in range(n)]
for i in range(n-1):
    g[i].append(i+1)
    g[i+1].append(i)
g[x].append(y)
g[y].append(x)

ans = [0]*(n+1)
for i in range(n):
    bfs()
for i in range(1,n):
    print(ans[i]//2)

Measured memory_bytes: 10568
n, m = map(int, input().split())
a = [int(c) // 2 for c in input().split()]

def f(x):
    res = 0
    while x % 2 == 0:
        res += 1
        x //= 2
    return res

t = f(a[0])
for ai in a:
    if f(ai) != t:
        print(0)
        exit()

m //= 2 ** t
a = [ai // 2 ** t for ai in a]

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

lcm = 1
for ai in a:
    d = gcd(lcm, ai)
    lcm = lcm * ai // d
    if lcm > m:
        print(0)
        exit()

print((m // lcm + 1) // 2)

Measured memory_bytes: 14244
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string

module IntMap = Map.Make(struct type t = int let compare = compare end)

let map = List.fold_left (fun map i ->
  let cnt = try IntMap.find i map with Not_found -> 0 in
  IntMap.add i (cnt + 1) map
) IntMap.empty a

let () = Printf.printf "%d\n" @@ 
  IntMap.fold (fun i cnt sum -> sum + if i <= cnt then cnt - i else cnt) map 0

Measured memory_bytes: 21252
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;
using vi = vector<int>;

#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int N;
double dp[301][301][301];
double dfs(int i, int j, int k) {
  if (dp[i][j][k] != -1)
    return dp[i][j][k];
  if (i == 0 && j == 0 && k == 0)
    return 0;
  double ans = N;
  if (i > 0) ans += i * dfs(i-1, j, k);
  if (j > 0) ans += j * dfs(i+1, j-1, k);
  if (k > 0) ans += k * dfs(i, j+1, k-1);
  ans /= (i+j+k);
  return dp[i][j][k] = ans;
}
int main() {
  cin >> N;

  rep(i, 301) rep(j, 301) rep(k, 301) dp[i][j][k] = -1;
  vi v(4, 0);
  rep(i, N) {
    int in(a);
    ++v[a];
  }

  cout << fixed << setprecision(15) << dfs(v[1], v[2], v[3]) << endl;


  return 0;
}


Measured memory_bytes: 213376
#include <bits/stdc++.h>
#define mp make_pair
#define ll long long
#define pii pair<int,int>
using namespace std;

bool cmp(pii p1,pii p2) {
    return p1.first<p2.first;
}
int main() {
 ll n,k;
 cin>>n>>k;
 ll r=(n*(n-1))/2-(n-1);
 if(k>r) {
     cout<<-1;
     return 0;
 }
 vector<pii>v;
 for(int i=1;i<=n-1;i++) {
     v.push_back({i,n});
 }
 for(int i=1;i<=n-2;i++) {
     for(int j=i+1;j<=n-1;j++) {
         if(r==k) {
             break;
         }
         v.push_back({i,j});
         r--;
         if(r==k) {
             break;
         }
     }
     if(r==k) {
         break;
     }
 }
cout<<v.size()<<endl;
for(int i=0;i<v.size();i++) {
    cout<<v[i].first<<" "<<v[i].second<<endl;
}
}

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

struct card {
  char suit;
  int number;
};

struct card a[37];
struct card b[37];

void swap(struct card *deck1, struct card *deck2) {
  struct card temp;
  int i;
  temp = *deck1;
  *deck1 = *deck2;
  *deck2 = temp;
}


void bubble(int n, struct card deck[]) {
  int i, j;
  int temp;

  for (i = 0; i < n; i++) {
    for (j = n - 1; j > i; j--) {
      if (deck[j].number < deck[j - 1].number) {
        swap(&deck[j], &deck[j - 1]);
      }
    }
  }
}


void selection(int n, struct card deck[]) {
  int i, j;
  int min;

  for (i = 0; i < n; i++) {
    min = i;
    for (j = i; j < n; j++) {
      if (deck[min].number > deck[j].number)
        min = j;
    }
    swap(&deck[min], &deck[i]);
  }
}


void print(int n, struct card deck[]) {
  int i;
  for (i = 0; i < n; i++) {
    if (i != n - 1) {
      printf("%c%d ", deck[i].suit, deck[i].number);
    } else {
      printf("%c%d\n", deck[i].suit, deck[i].number);
    }
  }
}


int check(int n, struct card deck1[], struct card deck2[]) {
  int i;
  for (i = 0; i < n; i++) {
    if (deck1[i].suit != deck2[i].suit)
      return -1;
  }
  return 1;
}


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

  for (i = 0; i < num; i++) {
    scanf(" %c%d", &a[i].suit, &a[i].number);
    b[i].suit = a[i].suit;
    b[i].number = a[i].number;
  }

  bubble(num, a);
  print(num, a);
  printf("Stable\n");

  selection(num, b);
  print(num, b);
  result = check(num, a, b);
  if (result == -1) {
    printf("Not stable\n");
  } else {
    printf("Stable\n");
  }

  return 0;
}



Measured memory_bytes: 2140
#!/usr/bin/env ruby

n = gets.chomp.to_i

taro = 0
hanako = 0
n.times do
  a, b = gets.chomp.split

  if a > b
    taro += 3
  elsif a == b
    taro += 1
    hanako += 1
  else
    hanako += 3
  end
end

puts "#{taro} #{hanako}"

Measured memory_bytes: 6868
n,m = map(int,input().split())
aa = list(map(int,input().split()))
 
bb = [abs(a-m) for a in aa]

def gcd(a,b):
    while b:
        a, b = b, a % b
    return a
    
if len(aa) == 1:
    print(abs(aa[0]-m))
else:
    while len(bb) > 1:
        a, b = bb.pop(), bb.pop()
        bb.append(gcd(a,b))
    print(bb[0])

Measured memory_bytes: 14252
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
       
		String s=sc.next();
        String t=sc.next();
		int a=sc.nextInt();
        int b=sc.nextInt();
		String u=sc.next();
  		
    
 	if(u.equals(s)){
    		a--;
    	}else{
     		b--;
   	 }

    	System.out.println(a);
  		System.out.println(b);
    }
}

Measured memory_bytes: 22228
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		if (N.equals("Sunny")) {
			System.out.println("Cloudy");
		}else if (N.equals("Cloudy")) {
			System.out.println("Rainy");
		}else if (N.equals("Rainy")) {
			System.out.println("Sunny");
		}
		sc.close();
	}
}

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

int main(){
    int h,a,b;
    int n=0;
    cin>>h>>a>>b;

    for(int i=a;i<=b;i++){
        if(h%i==0)n++;
    }

    cout<<n<<endl;
    return 0;
}



Measured memory_bytes: 3112
import sys
from heapq import heapify, heappop, heappush
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

r = I()
print(r**2)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

int main(){
    int n; cin >> n;
    vector<ll> a(n*3);
    for(auto& v:a){
        cin >> v;
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    ll ans = 0;
    for(int i=0; i<n; i++){
        ans += a[i*2+1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#pragma warning(disable:4996)

int main() {

	int n = 0, a = 0;
	scanf("%d", &n);
	for (int i = 1; i <= 9; i++) {
		
			if (n / i <= 9 && n / i >= 1) {
				if (n%i == 0) {
					a = 1;
					
				}
			}
	}
	if (a == 1) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	


	return 0;
}

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

int  main()
{
	string  s;
	int  a,b,i;
	
	cin>>a>>b;
	
	cin>>s;
	
	if(s.size()!=a+b+1)
	{
		cout<<"No"<<endl;
		return 0;
	}
	
	for(i=0; i<s.size(); i++)
	{
		if(i!=a)
		{
		    if(!isdigit(s[i]))
		    {
		        cout<<"No"<<endl;
		        return 0;
		    }
	    }
		else
	    {
		    if(s[i]!='-')
		    {
		   	    cout<<"No"<<endl;
		   	    return 0;
		    }
	    }
	}
	
	cout<<"Yes"<<endl;
	
	return 0;
}

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

using namespace std;

int main(void) {
	vector<int> p(3);
	for (int i = 0; i < 3; ++i) {
		cin >> p[i];
	}
	sort(p.begin(),p.end());
	cout << p[0]+p[1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int K, S;
  int count = 0;
  int Z;

  scanf("%d %d", &K, &S);

  for(int X = 0; X <= K; X++){
    for(int Y = 0; Y <= K; Y++){

      Z = S - (X + Y);
      if(Z >= 0 && Z <= K){
        count++;
      }

    }
  }

  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long inf = 1LL<<60;

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

    long long ans;
    ans = k*pow(k-1,n-1);
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
ll a[1000000+9];
using namespace std;
int main()
{
    ll n,i;
    cin>>n;

    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll x=n-1;
    if(n==1)
    {
        cout<<a[0]<<endl;
    }
    else if(n%2==0)
    {
        for(i=1; i<=n/2; i++)
        {
            cout<<a[x]<<" ";
            x=x-2;
        }
        x=0;
        for(i=1; i<=n/2; i++)
        {
            if(x<n-2)
                cout<<a[x]<<" ";
            else if(x==n-2)
                cout<<a[x]<<endl;
            x=x+2;
        }
    }
    else if(n%2==1)
    {
        for(i=1; i<=(n+1)/2; i++)
        {
            cout<<a[x]<<" ";
            x=x-2;
        }
        x=1;
        for(i=1; i<=n/2; i++)
        {
            if(x<n-2)
                cout<<a[x]<<" ";
            else if(x==n-2)
                cout<<a[x]<<endl;
            x=x+2;
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int N;
	
	while(cin >> N, N) {
		vvi field(21, vi(21, 0));
		
		REP(i, N) {
			int x, y;
			cin >> x >> y;
			field[x][y] = 1;
		}

		int M;
		cin >> M;

		int pos_x = 10, pos_y = 10;

		REP(i, M) {
			char d;
			int l;
			cin >> d >> l;

			switch(d) {
			case 'N':
				REP(j, l) {
					++pos_y;
					field[pos_x][pos_y] = 0;
				}
				break;
			case 'E':
				REP(j, l) {
					++pos_x;
					field[pos_x][pos_y] = 0;
				}
				break;
			case 'W':
				REP(j, l) {
					--pos_x;
					field[pos_x][pos_y] = 0;
				}
				break;
			case 'S':
				REP(j, l) {
					--pos_y;
					field[pos_x][pos_y] = 0;
				}
				break;
			}
		}

		bool suc = true;

		REP(i, 21) {
			REP(j, 21) {
				if(field[i][j]) {
					suc = false;
				}
			}
		}

		if(suc) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
ll sizes[100001];
ll arr[100001];
ll root(ll i){
    while(i!=arr[i]) i=arr[i];
    return(i);
}
void Union(ll i,ll j){
    ll root_i=root(i),root_j=root(j);
    if(root_i==root_j) return;
    if(sizes[root_i]>sizes[root_j]) swap(root_i,root_j);
    sizes[root_j]+=sizes[root_i];
    arr[root_i]=arr[root_j];
    return;
}
bool prime[10000];
void era(){
    memset(prime,true,sizeof prime);
    for(ll p=2;p*p<=10000;p++){
        if(prime[p]){
            for(ll q=p*p;q<=10000;q+=p){
                prime[q]=false;
            }
        }
    }

    return;
}
ll fac[200001],finv[200001];
ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=(ans*a)%MAX;
        b/=2;
        a=(a*a)%MAX;
    }
    return(ans%MAX);
}
ll inverse(ll a){
    return((power(a,MAX-2))%MAX);
}
ll ncr(ll n, ll r){
    ll p1=finv[n-r];
    ll p2=finv[r];

    return((((fac[n]*p1)%MAX)*p2)%MAX);


}
int main(){
    IO

    ll H,W,A,B;
    cin>>H>>W>>A>>B;
    fac[0]=1;finv[0]=1;
    for(ll i=1;i<=H+W;i++){
        fac[i]=(i*fac[i-1])%MAX;
        finv[i]=power(fac[i],MAX-2);
    }
    ll ans=ncr(H+W-2,H-1);
    for(int i=H-A+1;i<=H;i++){
        ans-=ncr(i+B-2,B-1)*ncr(H - i + 1 + W - B - 2, W - B - 1) % MAX;
        ans=(ans+MAX)%MAX;
    }
    cout<<ans;
    return(0);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int cnt = 0;
  if( a != b) ++cnt;
  if( b != c) ++cnt;
  if( c != a) ++cnt;
  if(a == b && b == c) cnt = 1;

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3596
use std::io::stdin;

fn main() {
    let mut s = String::new();

    stdin().read_line(&mut s).ok();
    let N: i32 = s.trim().parse().unwrap();
    s.clear(); // $B$3$l$,Bg;v!*!*(B

    stdin().read_line(&mut s).ok();
    let nums: Vec<i32> = s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect();

    let mut register: i32 = 0;
    // 2^0 $B$N0L$,A4$F(B 0 $B$G$"$l$PNI$$(B
    for (i, num) in nums.into_iter().enumerate() {
        // 0 $B$,$"$l$P=*N;(B
        if num == 0 {
            println!("{}", 0);
            return
        }

        // or $B$G(B 0 $B$K$J$k0L$OA4$F(B 2 $B$NG\?t(B
        if i == 0 {
            register = num;
        } else {
            register |= num;
        }
    }

    let mut even_digit_cnt: i32 = 0;
    loop {
        if register & 1 == 1 {
            break;
        } else {
            even_digit_cnt += 1;
            register = register >> 1;
        }
    }

    println!("{}", even_digit_cnt);
}


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

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

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

int main(){
    int x; cin>>x;
    if(x<30) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


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

int x;

void f(int64_t d,int64_t val,vector<int64_t>&a){
  a.push_back(val);
  if(d==11)return;
  for(int64_t i=-1;i<=1;i++){
    int64_t tmp=val%10+i;
    if(tmp>=0&&tmp<=9)f(d+1,val*10+tmp,a);
  }
}

int main(){
  cin >>x;
  vector<int64_t>a;
  for(int v=1;v<=9;v++){
    f(1,v,a);
  }
  sort(a.begin(),a.end());
  cout <<a.at(x-1)<<endl;
}

Measured memory_bytes: 11664
N = int(input())
a_list = list(map(int, input().split()))

tmp = set()
for a in a_list:
    tmp.add(a)

if a_list.count(0) == N:
    print("Yes")
else:
    if len(tmp) == 2 and a_list.count(0) == N // 3:
        print("Yes")
    elif len(tmp) == 3 and a_list.count(0) == 0:
        b = list(tmp)
        if b[0] ^ b[1] == b[2] and a_list.count(b[0]) == N // 3 \
                and a_list.count(b[1]) == N // 3 and a_list.count(b[2]) == N // 3:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 14212
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main(void) {
	string s; cin >> s;
	int n = s.size();
	vector<int> arr(n + 1, 0);
	for (int i = 0; i < n; ++i) {
		if (s[i] == '<')
			arr[i + 1] = max(arr[i + 1], arr[i] + 1);
	}
	for (int i = n - 1; i >= 0; --i) {
		if (s[i] == '>')
			arr[i] = max(arr[i], arr[i + 1] + 1);
	}
	long long ans = accumulate(arr.begin(), arr.end(), 0LL);
	cout << ans << endl;
	return 0;
}


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

long funcABS( long x )
{
	return ( x > 0 ? x : -x );
}

long calc_sad( const std::vector<long> &v, long b )
{
	long total = 0;
	for ( int i = 0; i < v.size(); i++ )
	{
		total += funcABS( v[i] - ( b + ( i + 1 ) ) );
	}

	return ( total );
}

int main()
{
	unsigned int N;
	std::vector<long> v;

	std::cin >> N;

	for ( int i = 0; i < N; i++ )
	{
		long tmp;
		std::cin >> tmp;
		v.emplace_back( tmp );
	}

	// 式を変形すると、、、
	// abs( A_i - i - b )

	// A_i - i を先に計算する
	std::vector<long> vA;
	for ( int i = 0; i < N; i++ )
	{
		vA.emplace_back( v[i] - ( i + 1 ) );
	}

	// vAをソートする
	std::sort( vA.begin(), vA.end(), []( long a, long b ) {
			return ( a < b );
		} );

	// 中央値を取る
	// 中央値は、Nが偶数の場合は2通り計算しておく
	long b = vA[N / 2];

	// 計算する
	long sad_value = 0;
	sad_value = calc_sad( v, b );

	if ( ( N & 1 ) == 0 )	//	偶数の場合はこっちも計算する
	{
		long sad_value2 = 0;
		long b_even = vA[N / 2 - 1];
		sad_value2 = calc_sad( v, b_even );

		if ( sad_value > sad_value2 )
		{
			std::cout << sad_value2 << std::endl;
		}
		else
		{
			std::cout << sad_value << std::endl;
		}
	}
	else
	{
		std::cout << sad_value << std::endl;
	}

	return ( 0 );
}


Measured memory_bytes: 4848
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    vector<int> a(3);
    REP(i, 3) cin >> a[i];
    sort(all(a));

    if(a[2] == a[0]+a[1]) yOUT;
    else nOUT;
}


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

int main(void) {
  int n, k;
  scanf("%d %d", &n, &k);

  int flag[n];
  for (int i = 0; i < n; i++) flag[i] = 0;

  for (int i = 0; i < k; i++) {
    int d;
    scanf(" %d", &d);
    for (int j = 0; j < d; j++) {
      int tmp_a;
      scanf(" %d", &tmp_a);
      flag[tmp_a - 1]++;
    }
  }

  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (!flag[i]) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


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

int a[105],n,ans,sum;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%d",a+i);
		sum+=a[i];
	}
	for(int i=1;i<=n;++i) {
		ans+=(sum-a[i])*a[i];
	}
	printf("%d",ans/2);
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
	public static void main(String[] args) {
		FS r = new FS();
		String str = r.next();
		Deque<Integer> stack = new ArrayDeque<Integer>();
		int tmpsum = 0;
		int sum = 0;
		Deque<int[]> pond = new ArrayDeque<int[]>();
		for(int i=0; i<str.length(); i++) {
			switch(str.charAt(i)) {
				case '\\':
					stack.addLast(i);
					break;
				case '/':
					if(!stack.isEmpty()) {
						int t = stack.pollLast();
						sum += i-t;
						if(pond.isEmpty()) {
							int[] data = {i, t, i-t};
							pond.addLast(data);
						} else {
							int tmppond = i-t;
							while(!pond.isEmpty()) {
								int[] tmp = pond.peekLast();
								if(tmp[0] < t) break;
								tmppond += tmp[2];
								pond.removeLast();
							}
							int[] data = {i, t, tmppond};
							pond.addLast(data);
						}
					}
					break;
				default:
					break;
			}
		}
		System.out.println(sum);
		if(pond.size() == 0) {
			System.out.println(0);
		} else {
			int size = pond.size();
			System.out.print(size + " ");
			for(int i=0; i<size; i++) {
				if(i == size-1) System.out.print(pond.pollFirst()[2]);
				else System.out.print(pond.pollFirst()[2] + " ");
			}
			System.out.println();
		}
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


void func(long long N, long long M){

}

int main(){
    int n, m;
    cin >> n >> m;
    int ans = 0;
    ans += n * (n - 1) / 2;
    ans += m * (m - 1) / 2;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = pow(3, n)
if n == 1:
    if a[0] % 2 == 0:
        print(1)
    else:
        print(2)
else:
    num = 1
    for i in range(n):
        if a[i] % 2 == 0:
            num *= 2
        else:
            num *= 1
    print(ans - num)

Measured memory_bytes: 61652
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    F0R(i, n) cin >> v[i];
    ll res = 0;
    FOR(i, 1, k + 1)
    {
        if(i > n) break;
        F0R(j, i + 1)
        {
            vector<ll> taken;
            F0R(a, j) taken.pb(v[a]);
            F0R(x, i - j) taken.pb(v[v.sz() - 1 - x]);
            sort(taken.begin(), taken.end());
            ll rem = k - i;
            ll cmax = 0;
            F0R(j, taken.sz())
            {
                if(taken[j] < 0 && rem > 0)
                {
                    rem--;
                }
                else
                {
                    cmax += taken[j];
                }
            }
            res = max(res, cmax);
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n;
    scan(n);

    int ca, cb, cab;
    int ans;

    foreach (i ; 0 .. n) {
        auto s = readln.chomp;
        foreach (j ; 0 .. s.length.to!int - 1) {
            if (s[j .. j + 2] == "AB") ans++;
            debug { writeln(s[j .. j + 2]); }
        }
        if (s.front == 'B') cb++;
        if (s.back == 'A') ca++;
        if (s.front == 'B' && s.back == 'A') cab++;
    }

    ans += min(ca, cb);

    if (ca > 0 && ca == cb && cb == cab) {
        ans--;
    }

    writeln(ans);
}























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main() {
int K, A, B;cin >> K >> A >> B;
int i = A;
while(i <= B){
if(i%K == 0){cout << "OK";break;}
else if(i == B){cout << "NG";break;}
i++;
}
}

Measured memory_bytes: 3636
#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 n;
  cin >> n;
  for (int i=1; i<=n; ++i) {
    int x=i;
    if (x%3 == 0) {
      cout << " " << i;
      continue;
    }
    while (x) {
      if (x%10 == 3) {
        cout << " " << i;
        break;
      }
      x /= 10;
    }
  }
  cout << endl;
  return 0;
}



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

using namespace std;
using ll = long long ;

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

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

    vector<bool> a(N);

   REP(i,K) {
       ll d;
       cin >> d;
       REP(j , d){
           ll x;
           cin >> x;
           a[--x] = true;
       }
   }

    ll ans = 0;
    REP(i, N){
        if(!a[i]) ans++;
    }

    cout << ans << endl;

}


Measured memory_bytes: 3560
#import heapq
import itertools
import math
#import numpy as np
#import sys

N = int(input())
#S = list(input())
#A = list(map(int, input().split()))
#S = [input() for _ in range(H)]
T = [list(map(int,input().split())) for _ in range(N)]
#sys.exit()
#print(T)

K = 0
C = list(itertools.combinations(list(range(N)),2))
for c in C :
    #print(c)
    k = (T[c[0]][0] - T[c[1]][0]) * (T[c[0]][0] - T[c[1]][0]) + (T[c[0]][1] - T[c[1]][1]) * (T[c[0]][1] - T[c[1]][1])
    k = math.sqrt(k)
    K += k
#print(K)
kaisu = (N - 1) * math.factorial(N) / len(C)
#print(kaisu)
print(K * kaisu  / math.factorial(N))

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

int main() {
  int N;
  cin >> N;
  for (int i{9}; i >= 1; --i) {
    if (N % i == 0 && N / i <= i) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>

int main()
{
	int a, b;
	std::cin >> a;
	std::cin >> b;
	std::string relation;
	if (a < b)
		relation = "<";
	else if (a > b)
		relation = ">";
	else if (a == b)
		relation = "==";
	std::cout << "a " << relation << " b\n";
    return 0;
}




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

#define llint long long int

using namespace std;

int main(){
    int A, B;

    cin >> A >> B;

    int max = A + B;

    if(A - B > max){
        max = A - B;
    }
    if(A * B > max){
        max = A * B;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int[] ten = new int[5];
		int sum = 0;
		for(int i= 0; i < 5; i++) {
			ten[i] = sc.nextInt();
			if(ten[i] < 40) {
				ten[i] = 40;
			}
			sum = sum + ten[i];
		}
		int avg = 0;
		avg = sum / 5;
		System.out.println(avg);
	}

}

Measured memory_bytes: 26056
#include <iostream>

using namespace std;

int main(void){
  int a,b;
  
  cin >> a >> b;
  
  if(a == b) cout << "Draw" << endl;
  else if(a == 1) cout << "Alice" << endl;
  else if(b == 1 || a < b) cout << "Bob" << endl;
  else cout << "Alice" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long N, long long M, std::vector<long long> A){
  ll ans = 0;
  for (int i = 0; i < M; i++) {
    ans += A[i];
  }
  cout << (N-ans >= 0? N-ans : -1) << endl;
}

int main(){
    long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	std::vector<long long> A(M);
	for(int i = 0 ; i < M ; i++){
		scanf("%lld",&A[i]);
	}
    solve(N, M, std::move(A));
}


Measured memory_bytes: 3784
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M=list(map(int,input().split()))
tree=UnionFind(N+1)

for _ in range(M):
    X,Y,Z=list(map(int,input().split()))

    tree.union(X,Y)

print(tree.group_count()-1)


Measured memory_bytes: 69208
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#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 endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES


    int k;
    cin >> k;
    string s;
    cin >> s;
    for(int i = 0;i < min(k, (int)s.size());i++)
    {
        cout << s[i];
    }
    if (s.size() > k)
    {
        cout << "...";
    }
    

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
int ans = 0;
int f (int pw) {
    int lol = 0, ans = 0;
    for (int i = 1; lol + i <= pw; i++) {
        lol += i, ++ans;
    }
    return ans;
}
void solve() {  
    int n;
    cin >> n;
    int nn = n;
    for (int i = 2; i * i <= nn; ++i) {
        if (n % i == 0) {
            int pw = 0;
            while (n % i == 0) 
                n /= i, ++pw;
            ans += f(pw);
        }
    }
    if (n > 1)
        ans += 1;
    cout << ans;
}       
    

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

using ll = long long;

int main(){
    int n; cin >> n;    
    ll ls[87];
    ls[0] = 2;
    ls[1] = 1;

    for(int i = 2; i <= n; ++i){
        ls[i] = ls[i-1] + ls[i-2];
    }

    cout << ls[n] << endl;

    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		bool answer = false;
		string s = Console.ReadLine();
		int n = s.Length;
		string answerMemo = "";
		string checkMemo = "keyence";

		for(int i = 0; i < n-6; i++)
		{
			answerMemo = "";
			answerMemo += s[i];
			answerMemo += s[i+1];
			answerMemo += s[i+2];
			answerMemo += s[i+3];
			answerMemo += s[i+4];
			answerMemo += s[i+5];
			answerMemo += s[i+6];
			if(answerMemo == checkMemo) answer = true;
		}

		for(int i = 0; i < 6; i++)
		{
			bool answera = true;
			
			if(s[0] != 'k') answera = false;
			if(i > 0 && s[1] != 'e') answera = false;
			if(i > 1 && s[2] != 'y') answera = false;
			if(i > 2 && s[3] != 'e') answera = false;
			if(i > 3 && s[4] != 'n') answera = false;
			if(i > 4 && s[5] != 'c') answera = false;

			if(s[n-1] != 'e') answera = false;
			if(i < 5 && s[n-2] != 'c') answera = false;
			if(i < 4 && s[n-3] != 'n') answera = false;
			if(i < 3 && s[n-4] != 'e') answera = false;
			if(i < 2 && s[n-5] != 'y') answera = false;
			if(i < 1 && s[n-6] != 'e') answera = false;

			if(answera) answer = true;
		}

		Console.WriteLine((answer) ? "YES" : "NO");
		
	}

}

Measured memory_bytes: 11092
import java.util.*;
import java.util.Map.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();

		HashMap<Integer,Integer> o=new HashMap<>(),e=new HashMap<>();
		o.put(0,0);
		e.put(0,0);

		for(int i=0;i<n;++i)
			(i%2==0?e:o).merge(s.nextInt(),1,Integer::sum);

		Comparator<Entry<Integer,Integer>> c=Entry.comparingByValue();
		Entry<Integer,Integer> O=o.entrySet().stream().max(c).get(),E=e.entrySet().stream().max(c).get();
		o.remove(O.getKey());
		e.remove(E.getKey());
		Entry<Integer,Integer> O2=o.entrySet().stream().max(c).get(),E2=e.entrySet().stream().max(c).get();

		int r=O.getValue()+E.getValue();
		if(O.getKey().equals(E.getKey())){
			r=Math.max(O.getValue()+E2.getValue(),
						E.getValue()+O2.getValue());
		}
		System.out.println(n-r);
	}
}


Measured memory_bytes: 64536
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  ll n;
  string ans="No";
  cin >>n;
  ll a[n],res2=0,res4=0;
  rep(i,n){
    cin >> a[i];
    if(a[i]%2==0){
      if(a[i]%4==0){
        res4++;
      }else res2++;
    }
  }
  ll res0=n-res2-res4;
  if(res0<=res4+1)if(res2==0)ans="Yes";
  if(res0<=res4)ans="Yes";


  cout << ans << endl;
}


Measured memory_bytes: 1024
from heapq import heapify,heappop,heappush
n,m = map(int,input().split())
P = list(map(int,input().split()))
P.sort()
heapify(P)
Q = []
for i in range(m):
    Q.append([int(i) for i in input().split()])
Q.sort(key = lambda x:x[1],reverse=1)
for b,c in Q:
    for i in range(b):
        tmp = heappop(P)
        if c > tmp:
            heappush(P,c)
        else:
            heappush(P,tmp)
            print(sum(P))
            exit()
print(sum(P))


Measured memory_bytes: 27088
open Batteries
open Printf
let () =
  let s = Scanf.scanf "%s " (fun a -> a) in
  let c_l = String.to_list s in

  let pl = 
    List.filter (fun x -> x = '+') c_l |>
    List.length
  in
  let mi = 4 - pl in

  Printf.printf "%d\n" @@
  (pl*1) - (mi*1)


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
const int MAX_N=8;
int N,M;
vector<int>G[MAX_N];
bool visited[MAX_N];

int dfs(int o,int k,bool visited[MAX_N]){
    bool fin=true;
    REP(i,N)if(!visited[i])fin=false;
    if(fin)return 1;
  	int ret=0;
    for(auto v:G[k]){
        if(!visited[v]&&o!=v){
            visited[v]=true;
            ret+=dfs(k,v,visited);
            visited[v]=false;
        }
    }
    return ret;
}

signed main(){
    cin>>N>>M;
    REP(i,M){
        int a,b;cin>>a>>b;a--;b--;
        G[a].eb(b);
        G[b].eb(a);
    }
    bool visited[N];
    REP(i,N)visited[i]=false;
  	visited[0]=true;
    cout<<dfs(-1,0,visited)<<endl;
}

Measured memory_bytes: 256
/**
*    created: 09.07.2020 01:11:05
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> p;
    vector<pair<int,int>> c;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        p.push_back(make_pair(a,b));
    }
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        c.push_back(make_pair(a,b));
    }
    rep(i,n) {
        int x = p[i].first;
        int y = p[i].second;
        int ret;
        int d = INF;
        rep(j,m) {
            int a = c[j].first;
            int b = c[j].second;
            if (abs(x-a) + abs(y-b) < d) {
                ret = j+1;
                d = abs(x-a) + abs(y-b);
            }
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>

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

using namespace std;



int main() {
    int X;
    cin>>X;
    int cnt=0;
    int d=0;
    do{
        d += X;
        cnt++;
    }while(d%360);
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int swap(int a,int b){
    int temp=a;
    a=b;
    b=temp;
}
int main(void){
    int a,b,c;
    int i;
    scanf("%d %d %d\n",&a,&b,&c);
    for(i = 0;i < 3;i++){
    if(a > b){
         int temp=a;
         a=b;
         b=temp;
    }
        if(b > c){
             int temp=b;
                b=c;
                c=temp;
            }
        }
    printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2704
#include "bits/stdc++.h"
using namespace std;

bool t(char x) {
	return (x >= 'a' && x <= 'z');
}

int main() {
	
	string s;
	cin >> s;
	
	if (s[0] == 'A') {
		int occ = 0;
		bool can = t(s[1]) && t(s[s.size()-1]);
		for (int i=2; i<s.size()-1; i++) {
			if (s[i] == 'C') occ++;
			else {
				can = can && t(s[i]);
			}
		}
		if (occ == 1 && can) {
			cout << "AC" << endl;
			exit(0);
		}
	}
	cout << "WA" << endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int N=3005;
int n;
ll dp[N][N];
int a,b,c,d;
int main(){
	ios::sync_with_stdio(false);
	cin >> a >> b >> c >> d;
	for(int i=a; i<=c ;i++){
		for(int j=b; j<=d ;j++){
			if(i==a && j==b){
				dp[i][j]=1;
				continue;
			}
			dp[i][j]=dp[i-1][j]*j+dp[i][j-1]*i-dp[i-1][j-1]*((i-1)*(j-1));
			dp[i][j]=(dp[i][j]%mod+mod)%mod;
		}
	}
	cout << dp[c][d] << '\n';
}

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

int main() {
    int R;
    cin >> R;
    string ans = "";
    if (R < 1200) {
        ans = "ABC";
    } else if (R >= 1200 && R < 2800) {
        ans = "ARC";
    } else {
        ans = "AGC";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  int N;
  std::cin >> N;
  std::vector<long long> A(N);
  for (auto &i : A) { std::cin >> i; }
  std::sort(A.begin(), A.end());
  long long prev = A[N - 1];
  bool reset = true;
  std::vector<long long> hoge;
  for (int i = N; i > 0; --i) {
    if (!reset && prev == A[i - 1]) {
      reset = true;
      hoge.push_back(A[i - 1]);
      if (hoge.size() >= 2) { break; }
    } else {
      reset = false;
    }
    prev = A[i - 1];
  }
  if (hoge.size() >= 2) { std::cout << hoge[0] * hoge[1] << std::endl; }
  else { std::cout << 0 << std::endl; }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n),y(n);

  rep(i,n)
  cin >> x[i] >> y[i];

  vector<int> v(n);
  rep(i,n)
  v[i]=i;
  double dist=0;
  do {
     rep(i,n-1){
        double dx=x[v[i]]-x[v[i+1]];
        double dy=y[v[i]]-y[v[i+1]];
        dist+=sqrt(dx*dx+dy*dy);
     }
  } while(next_permutation(all(v)));

  rep(i,n)
  dist/=(i+1);
  printf("%.10f\n",dist);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  cout << 3 * n * n << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>D(N);
	for (int n = 0;n<N;++n) {
		cin >> D[n];
	}
	sort(D.begin(),D.end());
	cout << D[N/2] -D[N/2-1] << endl;
	return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  char s;
  cin>>s;
  if(s>='a' && s <='z'){
    cout << 'a' << endl;
  }else{
    cout << 'A' << endl;
  }
  return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+20;

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

int n,a[N],b[N],ans;

int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=b[i]=read();
	std::sort(b+1,b+n+1);
	for(int i=1;i<=n;i++) a[i]=lower_bound(b+1,b+n+1,a[i])-b;
	for(int i=1;i<=n;i++)
	if((a[i]&1)&&!(i&1) || !(a[i]&1)&&(i&1)) ans++;
	printf("%d\n",ans/2);
}

Measured memory_bytes: 1024