akhauriyash/Code-Regression huggingface dataset:
#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 rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int a,b,c;
void input(){
    cin>>a>>b>>c;
    return;
}

void solve(){
    int ans=max(0,c-(a-b));
    cout<<ans<<endl;
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;


public class Main {


//	final int MOD = 1000000007;

//	public static int max = 0;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();
		int k = sc.nextInt();
//		String string = sc.next();

//		int[] ans = new int[n];
		int[][] a = new int[k][n];
		int[] d = new int[k];

		for(int i = 0; i < k; i++) {
			d[i] = sc.nextInt();
			for(int j = 0; j < d[i]; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();

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

		for(int i = 0; i < k; i++) {
			for(int j = 0; j < d[i]; j++) {
				map.put(a[i][j], 1);
			}
		}

		ans = n - map.size();
		//-------------------------------------------------------------------------------------

//		for(int i = 0; i < n; i++) {
//			System.out.println(ans[i]);
//		}

//		if(f) {
//			System.out.println("ABC");
//		} else {
//			System.out.println("ARC");
//		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 46200
local n, k = io.read("*n", "*n")
local c = 0
for i = 1, n do
  local a = io.read("*n")
  if a == 1 then
    c = i
  end
end
local r = math.ceil((c - 1) / (k - 1))
c = 1 + r * (k - 1)
if c < n then
  r = r + math.ceil((n - c) / (k - 1))
end
print(r)


Measured memory_bytes: 2708
# abc143_d.py
def can_make(i, j, k):
    if L[i] < L[j] + L[k] and L[j] < L[k] + L[i] and L[k] < L[j] + L[i]:
        return True
    return False


def find(i, j, L):
    left = j
    right = N
    mid = (right + left)//2
    flg = False
    while right - left > 1:
        mid = (right + left)//2
        # print("left,mid,right", left, mid, right)
        if can_make(i, j, mid):
            # print("can make")
            left = mid
            flg = True
        else:
            right = mid
    # print("j,mid", j, mid)
    # print(flg)
    if flg:
        return left-j
    else:
        return 0


N = int(input())
L = list(map(int, input().split()))
cnt = 0
L = sorted(L, reverse=True)
for i in range(N):
    for j in range(i+1, N):
        # print(L)
        # print("i,j", i, j, L[i], L[j])
        cnt += find(i, j, L)
print(cnt)


Measured memory_bytes: 46428
#include<cstdio>
#include <cstring>
#include<iostream>
#include<algorithm>

using namespace std;

bool ice[100][100];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
int n,m;

int bre(int x,int y,int c){
  int ret = c;
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(ice[nx][ny]){
      ice[nx][ny] = false;
      ret = max(ret,bre(nx,ny,c+1));
      ice[nx][ny] = true;
    }
  }
  return ret;
}

int main(void){
  int i,j;
  while(1){
    scanf("%d %d",&m,&n);
    if(!m && !n) break;
    memset(ice,false,sizeof(ice));
    for(i=1;i<=n;i++){
      for(j=1;j<=m;j++){
	int a;
	scanf("%d", &a);
	if(a) ice[i][j] = true;
      }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= m; j++){
	if(ice[i][j]){
	  ice[i][j] = false;
	  ans = max(ans,bre(i,j,1));
	  ice[i][j] = true;
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1224
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;

int main(){
  int n,d,x; cin>>n>>d>>x;
  int a[n];
  int res=0;
 
  REP(i,n)cin>>a[i];
  REP(i,n){
      int hi=1;
      while(hi<=d){
         res++;
         hi+=a[i];
      }
  }
  
 res+=x;
 cout<<res<<endl;
}

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

const int MAX_SIZE = 100;

double calc(int n, int w, int v[]) {
  int mv = 0, mr = 0, r[MAX_SIZE] = {};
  double a = 0.0;
  for (int i = 0; i < n; ++i) {
    r[v[i] / w]++;
    if (v[i] > mv) mv = v[i];
  }
  for (int i = 0; i < mv / w + 1; ++i) {
    if (r[i] > mr) mr = r[i];
  }
  for (int i = 0; i < mv / w; ++i) {
    a += 1.0 * r[i] / mr * (mv / w - i) / (mv / w);
  }

  return a + 0.01;
}

int main() {
  int n, w, v[MAX_SIZE];
  while (true) {
    cin >> n >> w;
    if (!n) break;
    for (int i = 0; i < n; ++i) {
      cin >> v[i];
    }
    cout << calc(n, w, v) << endl;
  }
}

Measured memory_bytes: 1232
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  string S;
  cin >> N >> S;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (!(i + 1 < N && S[i] == S[i + 1])) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3736
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	x := nextInt()
	if x == 0 {
		fmt.Fprintln(out, "1")
	} else {
		fmt.Fprintln(out, "0")
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func quickSort(val []int) []int {
	if len(val) < 2 {
		return val
	}

	pivot := val[0]

	left := []int{}
	right := []int{}

	for _, v := range val[1:] {
		if pivot > v {
			left = append(left, v)
		} else {
			right = append(right, v)
		}
	}

	left = quickSort(left)
	right = quickSort(right)

	ret := append(left, pivot)
	ret = append(ret, right...)

	return ret
}


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


int main(){


    long long n, i, t;

    long long k = 0;

    vector<long long> a;

    vector<long long> b;


    cin >> n;


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

         cin >> t;

         a.push_back(t);

         }

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

         cin >> t;

         b.push_back(t);

         }


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

         if( a.at(i) <= b.at(i) ){

             b.at(i) -= a.at(i);

             k += a.at(i);

             if( a.at(i + 1) >= b.at(i) ){

                 a.at(i + 1) -= b.at(i);

                 k += b.at(i);

                 }

             else{

                   k += a.at(i + 1);

                   a.at(i + 1) = 0;

                   }

             }

         else k += b.at(i);

         }


    cout << k << endl;

    
    return 0;


    }

Measured memory_bytes: 2548
class RangeMinimumQuery:
    def __init__(self, N, INF=float('inf')):
        self.N = 1
        while self.N < N:
            self.N <<= 1
        self.INF = INF
        self.segtree = [self.INF] * (self.N * 2 - 1)

    def update(self, i, val):
        i += self.N - 1
        self.segtree[i] = val
        while i > 0:
            i = (i - 1) // 2
            self.segtree[i] = min(self.segtree[2*i+1], self.segtree[2*i+2])

    def query(self, low, high, k=0, left=0, right=-1):
        if right == -1: right = self.N
        if right <= low or high <= left: return self.INF

        if low <= left and right <= high:
            return self.segtree[k]
        else:
            mid = (left + right) // 2
            return min(self.query(low, high, 2*k+1, left, mid), 
                       self.query(low, high, 2*k+2, mid, right))

N, Q = map(int, input().split())
rmq = RangeMinimumQuery(N, INF=(1<<31)-1)
for _ in range(Q):
    com, x, y = map(int, input().split())
    if com == 0:
        rmq.update(x, y)
    elif com == 1:
        print(rmq.query(x, y+1))
#    print(rmq.segtree[:rmq.N*2-1])

Measured memory_bytes: 9912
import java.util.Scanner;

class Main {
	int n;
	int m;
	int[] a;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}

	Main(Scanner sc) {
		n = sc.nextInt();
		m = sc.nextInt();
		a = new int[m];
		for(int i=0;i<m;i++){
			a[i] = sc.nextInt();
		}
	}

	void solve() {
		for(int i:a){
			n-=i;
		}
		System.out.println(n>=0?n:-1);
	}
}

Measured memory_bytes: 46104
#include <stdio.h>
#include <stdlib.h>

int morikubosyoutarou(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

#define INF 1010101010

int N;
int A[114514];

int main(void) {
	int i;
	int suzukitatuhisa = 0;
	int aoisyouta = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	qsort(A, N, sizeof(*A), morikubosyoutarou);
	for (i = 0; i < N; i++) {
		suzukitatuhisa += A[i];
		if (suzukitatuhisa > INF) suzukitatuhisa = INF;
		if (!(i + 1 < N) || suzukitatuhisa * 2 >= A[i + 1]) aoisyouta++; else aoisyouta = 0;
	}
	printf("%d\n", aoisyouta);
	return 0;
}


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

#define ll long long
#define ar array

const int MOD=1e9+7, mxN=500005;
ll n, m, f[mxN], iF[mxN];

ll binP(ll b, ll p) {
	ll res=1;
	while(p>0) {
		if (p&1)
			res=res*b%MOD;
		b=b*b%MOD;
		p>>=1;
	}
	return res;
}

ll getC(int a, int b) {
	return f[a]*iF[b]%MOD*iF[a-b]%MOD;
}

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

	cin >> n >> m;
	f[0]=iF[0]=1;
	for (int i=1; i<mxN; ++i) {
		f[i]=f[i-1]*i%MOD;
		iF[i]=binP(f[i], MOD-2);
	}
	ll ans=0;
	const int MULT=f[m]*iF[m-n]%MOD*iF[m-n]%MOD;
	for (int i=0; i<=n; ++i) {
		int s=i%2==0?1:-1;
		ll x=getC(n, i);
		x=x*MULT%MOD*f[m-i]%MOD;
		ans+=x*s;
	}
	ans+=999999ll*MOD;
	ans%=MOD;
	cout << ans;
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 11424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int k;
ll cnt;
void print(int n) {
	if (!n) return;
	print(n / k);
	cnt++;
}

int main()
{
	int n; cin >> n>>k;
	print(n);
	cout<<cnt;
	return 0;
}

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


int main(){
    int N, M;
    cin >> N >> M;
    pair<int, int> pairs[100000];

    for(int n = 0; n < M; n++){
        cin >> pairs[n].second >> pairs[n].first;
    }
    sort(pairs, pairs+M);
    int broken = pairs[0].first - 1;
    int ans = 1;
    for(int n = 1; n < M; n++){
        if(pairs[n].second <= broken){
            continue;
        }else{
            ans++;
            broken = pairs[n].first - 1;
        }
    }
    cout << ans << endl;
}

    

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<set>
#include<map>
#include<queue>
#include<math.h>
using namespace std ;
using ll = long long ;
using vi = vector<int> ;
using vii = vector<vi> ;
using pii = pair<ll,ll> ;

int main(){
	ll n,k ; cin >> n >> k ;
	if(n>=10) cout << k << endl ;
	else{
		cout << k+100*(10-n) << endl ;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int vs[100000+10];

int main(void) {
  int N, M;
  scanf("%d%d", &N, &M);
  REP(i, N) {
    scanf("%d", &vs[i]);
  }
  priority_queue<int> q;
  REP(i, N) {
    q.push(vs[i]);
  }
  ll res = 0;
  while(!q.empty()) {
    int cur = q.top(); q.pop();
    if(M > 0) {
      cur /= 2;
      --M;
      q.push(cur);
    } else {
      res += cur;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1276
#include <stdio.h>
#include <math.h>

#define N 10000
#define True 1
#define False 0

int isPrime(int);

int main()
{
  int i,j,m,g=0,n[N];

  scanf("%d",&i);

  for(j=0;j<i;j++){
    scanf("%d",&n[j]);

  m = isPrime(n[j]);
  g = g + m;
  }

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

  return 0;
}

int isPrime(int x)
{
  int i;

  if(x == 2)
    return True;

  else if(x < 2 || (x%2 == 0))
    return False;

  i = 3;
  while(i <= sqrt(x)){
    if(x%i == 0)
      return False;

    i = i + 2;
  }

  return True;
}

  

  



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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    vector<i32> a(3);
    cin >> a;

    whole(sort, a);
    cout << a[0] * a[1] / 2 << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}

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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
void solve() {
    int n;
    cin>>n;
    if(n>=30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    c_p_c();
    solve();

    return 0;
}

Measured memory_bytes: 3648
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll N;

int main(){

    cin >> N;

    if(N % 2 ==0){
        cout << N/2 << endl;
    }else{
        cout << N/2+1 << endl;
    }



}

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

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

int main(){
  int n;
  cin>>n;
  set<int>st;
  vector<int>array(n);
  rep(i,n)cin>>array[i];
  bool ok=true;
  rep(i,n){
    if(st.count(array[i]))ok=false;
    st.insert(array[i]);
  }
  if(ok)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
  
  

Measured memory_bytes: 10368
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
int prime[3005];
int isPrime[3005];
 
int sieve(int n){
  int p = 0;
  for(int i = 0; i <= n; i++){
    isPrime[i] = 1;
  }
  isPrime[0] = 0;
  isPrime[1] = 0;
  for(int i = 2; i <= n; i++){
    if(isPrime[i] == 1){
      prime[p] = i;
      p++;
      for(int j = 2 * i; j <= n; j += i){
        isPrime[j] = 0;
      }
    }
  }
  return p;
}
 
int main() {
  sieve(3004);
  vector<ll> p;
  rep(i,2,3003){
    if(isPrime[i]==1){
      p.pb(i);
    }
  }
  ll n;
  cin>>n;
  ll c1 = 0;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    rep(j,0,p.sz){
      ll b = p[j]*p[j]*p[j];
      while(a%b==0){
        a/=b;
      }
    }
    if(a==1)c1++;
    else v.pb(a);
  }
  sort(all(v));
  vector<ll> v1;
  rep(i,0,v.sz){
    ll a = v[i];
    ll b = 1;
    rep(j,0,p.sz){
      ll c = 0;
      if(a%p[j]==0){
        c++;
        a/=p[j];
      }
      if(a%p[j]==0){
        c++;
        a/=p[j];
      }
      if(c==1){
        b*=p[j]*p[j];
      }
      if(c==2){
        b*=p[j];
      }
    }
    ll d = pow(a,0.5);
    if(d*d==a){
      b*=d;
    }
    else{
      b*=a*a;
    }
    if(b==1)continue;
    v1.pb(b);
  }
  map<ll,ll> ma1;
  map<ll,ll> ma2;
  rep(i,0,v.sz){
    ma1[v[i]]++;
    ma2[v[i]]=v1[i];
  }
  set<ll> se;
  rep(i,0,v.sz){
    se.insert(v[i]);
  }
  vector<ll> vs(all(se));
  reverse(all(vs));
  ll ans = 0;
  if(c1>0)ans++;
  map<ll,ll> ma3;
  rep(i,0,vs.sz){
    if(ma3[vs[i]]==1)continue;
    ans += max(ma1[vs[i]],ma1[ma2[vs[i]]]);
    ma3[ma2[vs[i]]]=1;
    ma3[vs[i]]=1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 38528
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    ll a[n];
    ll ans = 0;
    rep(i,n) cin >> a[i];
    rep(i,n)
    {
        for(int j=i+1; j<n; j++)
        {
            ans = max(ans, abs(a[i]-a[j]));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
url = "https://atcoder.jp//contests/abc094/tasks/abc094_b"

def main():
    N, M, X = list(map(int, input().split()))
    Ms = list(map(int, input().split()))
    count = 0
    for i in range(0, X + 1):
        if i in Ms:
            count += 1
    ans = count
    count = 0
    for i in range(X, N):
        if i in Ms:
            count += 1
    ans = count if ans > count else ans
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint p=1e9+7;
int l[1000002];
lint pow3[1000002];
lint calc(int d){
  if(d<0)return 1;
    // cerr<<l[d]<<endl;
  if(l[d]==0)return calc(d-1);
  else return ((lint)2*calc(d-1)%p+pow3[d])%p;
}

int main(){
  string L;
  cin>>L;
  int N=0;
  for(int i=L.size()-1;i>=0;i--){
    if(L[i]=='0')l[N]=0;
    else l[N]=1;
    N++;
  }
  pow3[0]=1;
  FOR(i,1,1000002)pow3[i]=((lint)3*pow3[i-1])%p;
  cout<<calc(N-1)<<endl;
  return 0;
}


Measured memory_bytes: 12288
import java.util.Scanner;
import java.util.Arrays;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
    boolean judge=false;
    String str = Integer.toString(N);
      String []resultArray = str.split("");
      for(int i = 0; i < resultArray.length; i++){
        if(resultArray[i].equals("7")){
      judge=true;
        }
      }


      if (judge) {
        System.out.println("Yes");
      }else{
       System.out.println("No");
      }
        }
      }


Measured memory_bytes: 35832
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  Int n;
  cin >> n;
  Int ans = n-1;
  for(Int i=1;i*i<=n;i++){
    if(n%i==0){
      ans = min(ans,i+n/i-2);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n ;
	cin>> n ;
	ll ans=0;
	for(ll i=1;i<=n ;i++){
		for(ll j=1;j<=n ;j++){
			for(ll k=1;k<=n ;k++){
				ans += __gcd(i,__gcd(j,k));
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}


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

bool f(int x){
    string s;
    while(x > 0){
        s += char(x % 10 - '0');
        x /= 10;
    }

    for(int i = 0; i < s.size()/2; ++i){
        if(s[i] != s[s.size() - 1 - i]) return false;
    }
    return true;

}

int main(){
    int a,b;
    cin >> a >> b;
    int c = 0;
    for(int i = a; i <= b; ++i){
        if(f(i)) c++;
    }

    cout << c << endl;
}

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

int main(){
  char C[100][100];
  int H,W;
  cin>>H>>W;

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

  for(int i=0;i<2*H;i++){
    for(int j=0;j<W;j++) cout<<C[i/2][j];
    cout<<endl;
  }
  
  return 0;
}


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

int main() {
  int N, min=1000000000, max=0;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
    cin >> A.at(i);
    if(A.at(i)<min) min=A.at(i);
    if(A.at(i)>max) max=A.at(i);
  }
  cout << max-min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int w,h,n;cin>>w>>h>>n;
  vpii p(n);
  vi a(n);
  rep(i,n){
    int x,y;cin>>x>>y;
    p[i]=mp(x,y);
    cin>>a[i];
  }
  
  int l=0;
  int r=w;
  int b=0;
  int t=h;
  
  rep(i,n){
    int e=a[i];
    int px=p[i].first;
    int py=p[i].second;
    if(e==1&&l<px)l=px;
    if(e==2&&r>px)r=px;
    if(e==3&&b<py)b=py;
    if(e==4&&t>py)t=py;
  }
  int ans=(r-l)*(t-b);
  if((r-l)<0||(t-b)<0)ans=0;
  cout(ans);
  
  return 0;
}

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

using namespace std;
typedef pair<int, int> P;
int n;

int ans = 0;
vector< vector<P> > info;

void dfs(int cur, vector<bool> chosen) {
  if (cur >= n) {
    for (int i = 0; i < n; ++i) {
      if (chosen[i]) {
	bool is_valid = true;
	for (int j = 0; j < info[i].size(); ++j) {
	  P now = info[i][j];
	  if ((now.second == 0 && chosen[now.first] == 1) || (now.second == 1 && chosen[now.first] == 0)) is_valid = false;
	}
	if (!is_valid) return;
      }
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) if (chosen[i]) cnt++;
    ans = max(ans, cnt);
    return;
  }

  dfs(cur + 1, chosen);
  chosen[cur] = true;
  dfs(cur + 1, chosen);
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    vector<P> tmp;
    int a;
    cin >> a;
    for (int j = 0; j < a; ++j) {
      int x, y;
      cin >> x >> y;
      x--;
      tmp.push_back(P(x, y));
    }
    info.push_back(tmp);
  }
  vector<bool> c(n, false);
  dfs(0, c);
  cout << ans << endl;
  return 0;
}



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

int LCS(char *c1, char *c2){

  int i,j;
  int x = strlen(c1),y = strlen(c2);
  int A[x+1][y+1];

  for(i=1;i<=x;i++)
    A[i][0] = 0;
  for(j=0;j<=y;j++)
    A[0][j] = 0;
  
  for(i=1;i<=x;i++){
    for(j=1;j<=y;j++){
      if(c1[i-1] == c2[j-1])
	A[i][j] = A[i-1][j-1] + 1;
      else if(A[i-1][j] >= A[i][j-1]) 
	A[i][j] = A[i-1][j];
      else 
	A[i][j] = A[i][j-1];
    }
  }
  return A[x][y];
}


int main(void){

  int i,j,n,x;
  char c1[N],c2[N];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %s",c1,c2);
    x = LCS(c1,c2);
    //printf("n = %d\n",n);
    //printf("i = %d x = %d\n",i,x);
    printf("%d\n",x);
  }
  return 0;
}

Measured memory_bytes: 4520
#include <bits/stdc++.h>
using namespace std;
using Cache = pair<long long, pair<long long, long long>>;

const bool DEBUG = false;

Cache cache = make_pair(-1, make_pair(-1, 1));

tuple<long long, long long, long long, long long> get_anchors(
    long long i, const vector<long long>& P) {
  long long outer_left_anchor, inner_left_anchor, inner_right_anchor,
      outer_right_anchor;
  long long anchor;

  anchor = (P[i] > cache.first) ? min(cache.second.first, i - 1) : i - 1;
  while ((anchor >= 0) && P[anchor] < P[i]) anchor--;
  inner_left_anchor = anchor;
  if (anchor == -1) {
    outer_left_anchor = -1;
  } else {
    anchor--;
    while ((anchor >= 0) && P[anchor] < P[i]) anchor--;
    outer_left_anchor = anchor;
  }

  anchor = (P[i] > cache.first) ? max(cache.second.second, i + 1) : i + 1;
  while ((anchor < P.size()) && P[anchor] < P[i]) anchor++;
  inner_right_anchor = anchor;
  if (anchor == P.size()) {
    outer_right_anchor = P.size();
  } else {
    anchor++;
    while ((anchor < P.size()) && P[anchor] < P[i]) anchor++;
    outer_right_anchor = anchor;
  }

  if (P[i] > cache.first) {
    if (DEBUG)
      cout << "cache hit at: (" << inner_left_anchor << ", " << i << ", "
           << inner_right_anchor << ")" << endl;
    cache.first = P[i];
    cache.second.first = inner_left_anchor;
    cache.second.second = inner_right_anchor;
  }

  return forward_as_tuple(outer_left_anchor, inner_left_anchor,
                          inner_right_anchor, outer_right_anchor);
}

int main(int argc, char const* argv[]) {
  long long N;
  cin >> N;
  vector<long long> P(N);
  for (size_t i = 0; i < N; i++) cin >> P[i];

  size_t max_index = distance(P.begin(), max_element(P.begin(), P.end()));
  if (max_index <= P.size() / 2) reverse(P.begin(), P.end());

  long long total = 0;
  long long outer_left_anchor, inner_left_anchor, inner_right_anchor,
      outer_right_anchor;
  for (size_t i = 0; i < N; i++) {
    tie(outer_left_anchor, inner_left_anchor, inner_right_anchor,
        outer_right_anchor) = get_anchors(i, P);

    total +=
        P[i] *
        (((i - inner_left_anchor) * (outer_right_anchor - inner_right_anchor)) +
         ((inner_left_anchor - outer_left_anchor) * (inner_right_anchor - i)));

    if (DEBUG)
      cout << outer_left_anchor << ", " << inner_left_anchor << ", " << i
           << ", " << inner_right_anchor << ", " << outer_right_anchor << endl;
  }

  cout << total << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int D[7],i,j,n,t,f,T,F;
	for(i=1;i<=6;i++){scanf("%d",&D[i]);}
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&T,&F);
		for(j=1;j<=6;j++){if(T==D[j])t=j;}
		for(j=1;j<=6;j++){if(F==D[j])f=j;}
		switch(t){
			case 1:switch(f){
				case 2:printf("%d\n",D[3]);break;
				case 3:printf("%d\n",D[5]);break;
				case 4:printf("%d\n",D[2]);break;
				case 5:printf("%d\n",D[4]);break;
			}break;
			case 2:switch(f){
				case 1:printf("%d\n",D[4]);break;
				case 3:printf("%d\n",D[1]);break;
				case 4:printf("%d\n",D[6]);break;
				case 6:printf("%d\n",D[3]);break;
			}break;
			case 3:switch(f){
				case 1:printf("%d\n",D[2]);break;
				case 2:printf("%d\n",D[6]);break;
				case 5:printf("%d\n",D[1]);break;
				case 6:printf("%d\n",D[5]);break;
			}break;
			case 4:switch(f){
				case 1:printf("%d\n",D[5]);break;
				case 2:printf("%d\n",D[1]);break;
				case 5:printf("%d\n",D[6]);break;
				case 6:printf("%d\n",D[2]);break;
			}break;
			case 5:switch(f){
				case 1:printf("%d\n",D[3]);break;
				case 3:printf("%d\n",D[6]);break;
				case 4:printf("%d\n",D[1]);break;
				case 6:printf("%d\n",D[4]);break;
			}break;
			case 6:switch(f){
				case 2:printf("%d\n",D[4]);break;
				case 3:printf("%d\n",D[2]);break;
				case 4:printf("%d\n",D[5]);break;
				case 5:printf("%d\n",D[3]);break;
			}break;
		}
	}
	return 0;
}

Measured memory_bytes: 596
S = input()

cand = set()
def make(F, B):
    if len(B) == 0:
        cand.add(F)
        return
    if B[0] == "A":
        make(F, B[1:])
    make(F + B[0], B[1:])

make("", "AKIHABARA")

if S in cand:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <string> 
using namespace std;
int main(){
    int n,q,count=0; cin>>n;
    long long S[10001],T[501];
    for(int i=0;i<n;i++) cin>>S[i];
    cin>>q; bool x =false;
    for(int j=0;j<q;j++) cin>>T[j];
    for(int j=0;j<q;j++){
        x=false;
        for(int i=0;i<n;i++){
            if(S[i]==T[j]&&x==false){
                count++; x=true;
            }
            
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define pb(x) push_back(x)
using namespace std;
using ll = long long;
using pl = pair<ll,ll>;
using ppl = pair<pl,ll>;
ll n,m,k,a[1010],ans;
set<pl> s;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            for(int k=j+1; k<=n; k++){
                if(a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) continue;
                ll l = max({a[i],a[j],a[k]}), r = a[i] + a[j] + a[k]-max({a[i],a[j],a[k]});
                if(l < r) ans++;
            }
        }
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

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

    int n, k;
    cin >> n >> k;
    vector<int> x(n, 0);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            --a;
            x[a]++;
        }
    }

    int sum = 0;
    rep(i, n) {
        if(x[i] == 0) sum++;
    }

    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 3660
table = [0] * 26
string = []
while True:
  try:
    string += list(input())
  except EOFError:
    break

for s in string:
  n = ord(s.lower()) - 97
  if n >= 0 and n <= 25:
    table[n] += 1

for idx, s in enumerate(table):
  print(chr(idx + 97) + " : " + str(s))


Measured memory_bytes: 5584
console.log((args=>{
  const [n,...s] = args.trim().split`\n`;
  const N = n|0;
  const m = new Map();
  for ( let i = 0; i < N; i++ ) {
    const e = Array(26).fill(0);
    for ( let j = 0; j < 10; j++ ) e[s[i].charCodeAt(j)-97]++;
    let p = e.map(c=>c.toString(11)).join``;
    m.set( p, (m.get(p)|0) + 1 );
  }
  let a = 0;
  for ( const [,v] of m ) a += v*(v-1)/2;
  return `${a}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 71568
#include<iostream>
#include<vector>

using namespace std;

int main(){

int N;
vector<int>W;
int tmp;

cin>>N;
for(int i=0;i<N;i++){
    cin>>tmp;
    W.push_back(tmp);
}

int S0=0;
int S1=0;
int min=100000;

for(int T=0;T<N;T++){
    S0=0;
    S1=0;
    for(int i=0;i<N;i++){
        if(i<=T){
            S0+=W[i];
            }
        else{   
            S1+=W[i];
            }
    }
    if(min>abs(S0-S1)){
        min=abs(S0-S1);
    }
}
cout<<min<<endl;

return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int[] x = new int[5];
		int[] y = new int[5];
		x[1] = sc.nextInt();
		y[1] = sc.nextInt();
		x[2] = sc.nextInt();
		y[2] = sc.nextInt();
		int xd = x[2] - x[1];
		int yd = y[2] - y[1];
		x[3] = x[2] - yd;
		y[3] = y[2] + xd;
		x[4] = x[1] - yd;
		y[4] = y[1] + xd;
		System.out.println(x[3] + " " + y[3] + " " + x[4] + " " +  y[4]);
	}
}

class FastScanner {
    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() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        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 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();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

struct op{
    int b;
    int c;

    bool operator<(const op &OP){
        return c < OP.c;
    }
};

void solve(){
    int x;
    cin >> x;
    cout << abs(1-x) << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    vector<int>x,y,z;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a%4==0)
            x.push_back(a);
        else if(a%2==0)
            y.push_back(a);
        else
            z.push_back(a);
    }
    if(x.size()>=z.size())
        cout<<"Yes"<<endl;
    else if(z.size()-x.size()==1 && y.size()==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    int N, M;
    cin >> N >> M;
    vector<i_i> ans;
    //奇数は単純
    if(N&1){
        for(int l = 1, r = N;l < r;l++,r--){
            ans.emplace_back(l, r);
        }
    }
    //偶数は途中で変えないといけない
    else{
        bool f = false;
        map<i_i, int> map;
        for(int l = 1,r = N; l < r; l++, r--){
            int a = r - l;
            int b = N - a;
            if(a > b)swap(a,b);
            if(!f&&(map[{a,b}]>0||a==b)){
                f = true;
                r--;
            }
            a = r-l;
            b = N-a;
            if(a > b)swap(a,b);
            ans.emplace_back(l, r);
            map[{a,b}]++;
        }
        print(map);
    }
    rep(i,M){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}

Measured memory_bytes: 8132
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_ruiseki = [0]
for i in range(n):
    if A_ruiseki[-1]+A[i] <= k :
        A_ruiseki.append(A_ruiseki[-1]+A[i])
    else:
        break

B_ruiseki = [0]
for i in range(m):
    if B_ruiseki[-1]+B[i] <= k :
        B_ruiseki.append(B_ruiseki[-1]+B[i])
    else:
        break

ans = len(A_ruiseki)-1

for i in range(len(A_ruiseki)):
    time = A_ruiseki[i]
    expected = max(ans-i, 0)

    if len(B_ruiseki) <= expected:
        continue

    if time + B_ruiseki[expected] > k:
        continue

    time += B_ruiseki[expected]

    for j in range(expected, len(B)):
        if time + B[j] > k:
            break

        time += B[j]
        ans =i+j+1

print(ans)

Measured memory_bytes: 123048
#include <iostream>
#include <string>
#include <queue>
using namespace std;

int main(){
    string com;
    priority_queue<int> PQ;

    while(1){
        cin >> com;
        if(com == "insert"){
            int key; cin >> key;
            PQ.push(key);
        }else if (com == "extract"){
            cout <<  PQ.top() << endl;
            PQ.pop();
        }else if (com == "end"){
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 5976
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>

using namespace std;



int main() {
	int n,a,b;
	cin >> n >> a;
	a = a * 2 + 1;
	if (n % a == 0) {
		cout << n / a << endl;
	}
	else {
		cout << n / a + 1 << endl;
	}
	

}

Measured memory_bytes: 256
function Main (input) {
  var N, X;
  var ans1 = [];
  input = input.split("\n");
  N = parseInt(input[0], 10);
  X = input[1].split(" ").map(inp => parseInt(inp, 10));
  for (var i = Math.min(...X); i <= Math.max(...X); i++) {
    var ret = 0;
    for (var j of X) {
      ret += Math.pow(i - j, 2);
    }
    ans1.push(ret);
  }
  console.log(Math.min(...ans1));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9376
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
int fact [N];

int mult (int a, int b) {
  a %= MOD;
  b %= MOD;
  return (1LL * a * b) % MOD;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); 
  fact[0] = fact[1] = 1;
  FOR (i, 2, N) {
    fact[i] = mult (fact[i - 1], i);
  }
  int n, m;
  cin >> n >> m;
  if (abs(n - m) >= 2) {
    cout << 0 << '\n';
    return 0;
  }
  int res = mult (fact[n], fact[m]);
  if (n == m) res = mult (res, 2);
  cout << res << '\n';
  return 0; 
}


Measured memory_bytes: 640
def fi(i, x):
    a, b = lines[i]
    return a*x+b

def find(x):
    def f(i):
        return fi(i+1,x) > fi(i,x)
    mn, mx = -1, len(lines)-1
    idx = (mn+mx)//2
    while mx-mn>1:
        if f(idx):
            mx, idx = idx, (mn + idx)//2
            continue
        mn, idx = idx, (mx + idx)//2
    return fi(idx+1, x)

def insert(a, b):
    (e, f) = lines[-1]
    while len(lines)-1:
        (c, d), (e, f) = (e, f), lines[-2]
        if (c-e)*(b-d) < (d-f)*(a-c):
            break
        lines.pop()
    lines.append((a, b))

N, C = map(int, input().split())
hs = list(map(int, input().split()))
lines = [(-2*hs[0], hs[0]**2)]
for h in hs[1:]:
    r = find(h) + h**2+C
    insert(-2*h, r+h**2)
print(r)


Measured memory_bytes: 94540