akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

	
	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		PrintWriter out=new PrintWriter(System.out);
	//	int t=in.nextInt();
	//	while(t-->0)
		solve(in,out);
		out.close();
	}

    static void solve(FastScanner in,PrintWriter out){
      long d=in.nextLong(), t=in.nextLong(), s=in.nextLong();
      if(t*s>=d) out.println("Yes"); else out.println("No");
      
    }    
	


	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


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

// #include<cstdio>

int main(){
  int n, x, count=0;
  while(1){
    cin >> n >> x;
    if (n*n+x*x==0) break;
    for (int i=1; i<=n-2; i++){
      for (int j=i+1; j<=n-1; j++){
	for (int k=j+1; k<=n; k++){
	  if (i+j+k==x) count++;
	}
      }
    }
    cout << count << "\n";
    count = 0;
  }

  return 0;
}

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

int main(){
  int a[10],b[10];
  for(int i=0;i<10;i++){
    cin>>a[i];
  }
  for(int i=0;i<10;i++){
    cin>>b[i];
  }
  sort(a,a+10);
  sort(b,b+10);
  cout << a[8]+a[9]+a[7] << " ";
  cout << b[8]+b[9]+b[7] << endl;
  return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int yama,before = 0,count = 0;
    for (int i=0;i<n;i++){
        cin >> yama;
        if (before <= yama){count++; before = yama;}
    }

    cout << count << endl;
}


Measured memory_bytes: 256
S = input()
T = input()
Flg = False

ans1 = "z"*len(S)
pos = ""
num = 0
for i in range(len(S)-len(T)+1):
    sl = ""
    sl = S[i:(i+len(T))]
    for j in range(len(T)):
        pos = ""
        if(sl[j] != "?" and sl[j] != T[j]):
            break
    else:
        pos += S[:i]+T+S[(i+len(T)):]
        if(ans1 > pos):
            ans1 = pos
            Flg = True
                
if(Flg == True):
    ans1 = ans1.replace("?", "a") 
    print(ans1)
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] num = new int[n];
			int ans = Integer.MAX_VALUE;
			for (int i = 0; i < n; i++)
				num[i] = scanner.nextInt();
			for (int i = 0; i < 1 << (n - 1); i++) {
				int sum1 = 0;
				int sum2 = 0;
				for (int j = 0; j < n; j++) {
					if (((i >> j) & 1) == 1)
						sum1 += num[j];
					else
						sum2 += num[j];
				}
				ans = Math.min(ans, Math.abs(sum1 - sum2));
			}
			System.out.println(ans);
		}

	}
}

Measured memory_bytes: 20780
#include<bits/stdc++.h>
using namespace std;
 
 
int main()
{
    long long n,m,k;
    cin>>n>>m>>k;
    vector<long long>a(n),b(m);
    
    for(int i=0;i<n;i++)
      cin>>a[i];
      
    for(int j=0;j<m;j++)
      cin>>b[j];
   vector<long long>prefix_a(n+1),prefix_b(m+1);
   prefix_a[1]=a[0];
   prefix_b[1]=b[0];
   for(int i=1;i<n;i++)
     prefix_a[i+1]=prefix_a[i]+a[i];
     
  for(int i=1;i<m;i++)
    prefix_b[i+1]=prefix_b[i]+b[i];
    
  int ans=0;
  prefix_a[0]=0;
  for(int i=0,j=m;i<=n;i++)
  {
      if(prefix_a[i]>k)
        break;
      while(prefix_a[i]+prefix_b[j]>k)
        j--;
     ans=max(i+j,ans);    
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9596
# coding: utf-8


II = lambda: int(input())
MI = lambda: map(int, input().split())


def gen_primes(N):
    primes = [True] * (N + 1)
    primes[0] = primes[1] = False
    for i in range(N + 1):
        if not primes[i]: continue
        for j in range(2, N):
            if i * j > N: break
            primes[i * j] = False
    return [i for i in range(N + 1) if primes[i]]


def main():
    N = II()
    ans = [p for p in gen_primes(55555) if p % 5 == 1]
    print(" ".join(map(str, ans[:N])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3700
#二部グラフで連結判定
N,M = map(int,input().split())
KL = [list(map(int,input().split())) for _ in [0]*N]

E = [[] for _ in [0]*(N+M)] #E[0] - E[N-1]:人, E[N] - E[N+M-1]:言語
for i,kl in enumerate(KL):
    for l in kl[1:]:
        E[i].append(N+l-1)
        E[N+l-1].append(i)

def connect_bfs(N,E,start):
    connect = {start}
    q = [start]
    while q:
        i = q.pop()
        for j in E[i]:
            if j in connect:continue
            connect.add(j)
            q.append(j)
    return connect

c = connect_bfs(N+M,E,0)
ans = len(c & set(range(N)))==N
print("YES" if ans else "NO")

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll N;
    string S;
    cin >> N >> S;
    rep(i, S.size()) {
        S[i] = 'A' + (S[i] - 'A' + N) % 26;
    }
    print(S);
    return 0;
}

Measured memory_bytes: 256
main = input => {
  input = input.split('\n').map(x => x.split(' ')).map(x => x.map(parseFloat));
  var N = input[0];
  var B = input[1];
  
  B = [B[0]].concat(B).concat(B.slice(-1));
  
  var A = 0;
  
  B.reduce((N,nextToN) => {
    A += Math.min(N,nextToN);
    return nextToN;
  });
  process.stdout.write(A);
}

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

Measured memory_bytes: 7244
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);


        int a;
        int b;
        int c;

        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();

        if (a==b && a!=c || a==c && a!=b || b==c && b!=a ) {
            System.out.println("Yes");
        }
        else if ((a+b+c / 3 == a)) {
            System.out.println("No");
        }
        else if (a != b && a != c) {
            System.out.println("No");
        }
        else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,w;
  cin>>n>>w;
  long long int dp[n+1][w+1];
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=w;j++)
    {
     
       dp[i][j]=0;
    }
  }
  
  for(int i=1;i<=n;i++)
  {
      int w1;
      long long int c;
      cin>>w1>>c;
      
    for(int j=1;j<=w;j++)
    {
     
      if(w1<=j)
      {
        dp[i][j]=max(c+dp[i-1][j-w1],dp[i-1][j]);
      }
      else
        dp[i][j]=dp[i-1][j];
    }
  }
  cout<<dp[n][w];
  return 0;
  
}

Measured memory_bytes: 82276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
//#define s second
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
   
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll f=0;
    while(a>0 && c>0)
    {
        if(f==0)
        {
            c=c-b;
            f=1-f;
        }
        else
        {
            a=a-d;
            f=1-f;
        }
        
    }
    if(c<=0)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    
    

    return 0;
}



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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<pair<ll,ll>> tmp;
    for(i = 0;i < n;++i){
        if(s.at(i) == 'o') tmp.emplace_back(i, i + c);
    }
    ll last = -1;
    set<pair<ll,ll>> mae;
    for(i = 0;i < tmp.size();++i){
        if(tmp.at(i).first <= last) continue;
        last = tmp.at(i).second;
        mae.insert(tmp.at(i));
    }
    if(mae.size() != k){
        return 0;
    }
    set<pair<ll,ll>> usiro;
    ll hazi = 1e9+7;
    for(i = tmp.size()-1;i >= 0;--i){
        if(hazi <= tmp.at(i).second) continue;
        hazi = tmp.at(i).first;
        usiro.insert(tmp.at(i));
    }
    if(usiro.size() != k){
        return 0;
    }
    vector<pair<ll,ll>> ans;
    set_intersection(all(mae), all(usiro), inserter(ans, ans.end()));
    for(auto x:ans){
        cout << x.first + 1 << endl;
    }

    return 0;
}

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

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    if(((r*100)+(g*10)+b) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int[] sieve(int n) {
    assert(n > 1);
    auto t = new bool[n + 1];
    int[] primes = [2];
    for (int i = 3; i < t.length; i += 2) {
        if (!t[i]) {
            primes ~= i;
            for (int j = i + i; j < t.length; j += i)
                t[j] = true;
        }
    }
    return primes;
}

void main() {
    int n = readint;

    auto primes = sieve(cast(int)sqrt(n * 1.0));
    int[] facs;
    int x = n;
    foreach (prime; primes) {
        if (prime * prime > x) break;
        while (x % prime == 0) {
            facs ~= prime;
            x /= prime;
        }
    }

    if (x > 1) facs ~= x;
    writefln("%d: %s", n, facs.map!(to!string).join(" "));
}


Measured memory_bytes: 2544
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
typedef long long ll;
#define mod 1000000007
using namespace std;

const int N = 13;
ll dp[100010][13];

int main(){
    string s;
    cin >> s;
    dp[0][0] = 1;
    for(int i=0;i<s.size();i++){
        char c = s[i];
        if (c == '?'){
            for (int j=0;j<10;j++){
                for (int k=0;k<13;k++){
                    dp[i+1][(k*10+j) % N] += dp[i][k];
                    dp[i+1][(k*10+j) % N] %= mod;
                }
            }
        }
        else{
            int t = c - '0';
            for (int k=0;k<13;k++){
                dp[i+1][(k*10+t) % N] += dp[i][k];
                dp[i+1][(k*10+t) % N] %= mod;
            }
        }
    }
    cout << dp[s.size()][5] <<  endl;
    return 0;
}


Measured memory_bytes: 10624
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int K = scan.nextInt();
    int N = scan.nextInt();
    int[] ie = new int[N];
    for(int i = 0;i < N;i++){
      ie[i] = scan.nextInt();
    }
   int x,y,z,sa;
    z = 0;
    for(int i = 0;i < N - 1;i++){
       x = ie[i];
       y = ie[i+1];
       sa = y - x;
       if(sa > z){
         z = sa;
       }
    }
    x = ie[N-1];
    y = ie[0];
    sa = K - x + y;
    if(sa > z){
      z = sa;
    }
    System.out.println(K-z);
  }
}


Measured memory_bytes: 85360
#include <iostream>
#include <cmath>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;  cin >> n;
    vector<vector<int> >a(n, vector<int>(3));
    rep(i, n)   rep(j, 3)   cin >> a[i][j];
    vector<vector<int> >dp(n, vector<int>(3));
    rep(i, n)   rep(j, 3){
        if(i == 0){
            dp[i][j] += a[i][j];
        }else{
            rep(k, 3){
                if(j==k)    continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k]);
            }
            dp[i][j] += a[i][j];
        }
    }
    int ans = 0;
    rep(j, 3){
        ans = max(ans, dp[n-1][j]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
# coding: utf-8
# Your code here!
import sys
from collections import Counter

N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

mod = 10**9+7


cnt_A = [False]*(N*M+1)

for a in A:
    cnt_A[a] = True
    
cnt_B = [False]*(N*M+1)
for b in B:
    cnt_B[b] = True


ans = 1
N_ume = 0
M_ume = 0
for i in reversed(range(1,N*M+1)):
    if cnt_A[i] and cnt_B[i]:
        N_ume += 1
        M_ume += 1
    elif cnt_A[i]:
        ans *= M_ume
        N_ume += 1
    elif cnt_B[i]:
        ans *= N_ume
        M_ume += 1
    else:
        ans *= N_ume*M_ume - (N*M - i)
    ans %= mod
    # print(ans)

print(ans)

Measured memory_bytes: 19052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC171_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = char.Parse(Console.ReadLine());
            if (char.IsUpper(input))
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine("a");
            }
        }
    }
}


Measured memory_bytes: 17296
#include<bits/stdc++.h>
using namespace std;
int bns (int a[], int l, int r, int key) {
    int mid, pos = l - 1;
    while(l<=r) {
        mid=(l+r) / 2;
        if(a[mid]<key) {
            l = mid + 1;
            pos = mid;
        } else
            r = mid - 1;
    }
    return pos;
}
int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    int cnt=0;
    for(int i=0; i<n-2; i++) {
        for(int j=i+1; j<n-1; j++) {
            cnt += bns(a,j+1,n-1,a[i] + a[j]) - j;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
const int maxn = 1e5 + 10;
using namespace std;
pair<int, int> num[maxn];
int N;
int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> num[i].first;
		num[i].second = i + 1;
	}
	sort(num, num + N);
	cout << num[0].second;
	for (int i = 1; i < N; i++)
		cout << " " << num[i].second;
	return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
  z->parent = y;

  if(y==NIL)root=z;
  else if(z->key < y->key) y->left =z;
  else y->right = z;
  
}

void inorder(Node u){
  if(u->left!=NIL)inorder(u->left);
  printf(" %d",u->key);
  if(u->right!=NIL)inorder(u->right);
			
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL)preorder(u->left);
  if(u->right!=NIL)preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 24040
from collections import deque

n, p = map(int, input().split())
que = deque([])

gTime = 0

for i in range(n):
    name, time = input().split()
    time = int(time)
    que.append([name, time])

t = 0

while len(que) > 0:
    top = que.popleft()
    x = min(top[1], p)
    top[1] -= x
    t += x

    if top[1] == 0:
        print(top[0], t)
    else:
        que.append(top)



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

int main() {
	// init
	int a = 0;
	int b = 0;
	int c = 0;
	int x = 0;
    int counter = 0;

    // input
    cin >> a >> b >> c >> x;

    // check
    for (int i = 0; i < a+1; ++i){
		for (int j = 0; j < b+1; ++j){
    	    for (int k = 0; k < c+1; ++k){
    			if (500*i + 100*j + 50*k == x) ++counter;
    		}
    	}
    }

    // output
    cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back 
#define mp make_pair
#define f first
#define s second
#define sz(x) ((int)x.size())
const ll maxint=2e18;
const ll minint =-2e18;
/*******\
(͡ ° ͜ʖ ͡ °) : Hello there, relax.
\*     */
const int mod = 998244353;
int n;
const int M = 2e5+5;
vector<pair<int,int>> edges;
int main(){
    int k;
    scanf("%d%d",&n,&k);
    edges.assign(k,pair<int,int>());
    for(int i=0;i<k;i++){
        scanf("%d%d",&edges[i].f,&edges[i].s);
    }
    sort(edges.begin(),edges.end());
    vector<ll> dp(n+1,0),sum(n+1,0);
    dp[1] = 1;
    sum[1]=1;
    for(int i=2;i<=n;i++){
        for(auto e:edges){
            dp[i] += ((sum[max(0,i-e.f)]%mod)-(sum[max(0,i-e.s-1)]%mod)+mod)%mod;
            dp[i]%=mod;
        }
        sum[i]=(sum[i-1]%mod+dp[i]%mod)%mod;
        sum[i]%=mod;
    }

    cout<<dp[n]%mod<<'\n';
    return 0;
}

Measured memory_bytes: 6404
<?php
fscanf(STDIN,"%d",$n);
$arr=explode(' ',trim(fgets(STDIN)));
sort($arr);

$atai=0;
//print_r($arr);
$atai=$arr[0];
for($i=1;$i<$n;$i++){
	$atai=($atai+$arr[$i])/2;
}
echo $atai;
?>

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans = a - b;
	if(abs(ans) >= 1e18){
		cout << "Unfair" << endl;
		return 0;
	}
	if(k%2 == 0){
		cout << ans << endl;
	} else {
		cout << -ans << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007



signed main(){

	int N, H;
	cin >> N >> H;
	P a[200000];
	for (int i = 0; i < N; i++){
		cin >> a[i * 2].first;		a[i * 2].second = -1;	// 無限
		cin >> a[i * 2 + 1].first;	a[i * 2 + 1].second = 1;// 1回
	}

	sort(a, a + 2 * N, [](P s, P t){ return s.first > t.first; });

	int ans = 0;
	for (int i = 0; i < 2 * N; i++){
		if (a[i].second == 1){
			H -= a[i].first;
			ans++;
			if (H <= 0) break;
		}else{
			ans += ((H-1) / a[i].first)+1;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
import sys
#input = sys.stdin.readline
from itertools import chain

H, W = map(int, input().split())
grid = [input() for _ in range(H)]
initial = sum(row.count("#") for row in grid)
dire = [(1,0),(0,1),(-1,0),(0,-1)]

def out(y, x):
    return y < 0 or y >= H or x < 0 or x >= W

def wall(y, x):
    return grid[y][x] == "#"

def can_go(y, x, explored):
    return not (out(y, x) or wall(y, x) or (y, x) in explored)

def succs(explored):
    def succs_(point):
        y = point[0]
        x = point[1]
        return [(y+h, x+w) for h, w in dire if can_go(y+h, x+w, explored)]
    return succs_

def bfs(frontier, explored, count):
    if not frontier:
        return -1
    elif any(map(lambda point: point == (H-1, W-1), frontier)):
        return count
    else:
        frontier_ = set(chain(*map(succs(explored), frontier)))
        return bfs(frontier_, explored | frontier_, count+1)
    
def main():
    path_count = bfs([(0, 0)], set([(0, 0)]), 1)
    if path_count == -1:
        print(-1)
    else:
        print(H*W - path_count - initial)

main()

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


void DFS(){
    
}

int main(void){
    int n;
    cin>>n;
    vector<int> p(n);
    vector<int> q(n);
    rep(i, n) cin>>p[i];
    rep(i, n) cin>>q[i];

    vector<int> a(n);
    rep(i, n) a[i]=i+1;
    map<vector<int>, int> mp;
    do{
        mp[a]=mp.size();
    }while(next_permutation(a.begin(), a.end()));

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


}

Measured memory_bytes: 5248
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            var s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            if ((a + b) % 2 == 1)
            {
                Console.WriteLine("IMPOSSIBLE");
            }
            else
            {
                Console.WriteLine((a + b) / 2);
            }


#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <algorithm>  
#include <bitset>
#include <cassert>
#include <ctime>  
#include <cmath>  
#include <cstdlib>  
#include <cstring>  
#include <functional>  
#include <iostream>  
#include <deque>  
#include <stack>
#include <queue>  
#include <vector>  
#include <map>  
#include <set>  
#include <string>  
#include <unordered_map>  
#include <unordered_set>  
#pragma warning(disable:4996)

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const int INF = 1e9;
const int MAXN = 2e5 + 5;

ll N, A[MAXN], cnt[MAXN];

ll nc2(ll n) { return n * (n-1) / 2; }

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for(int i=1; i<=N; i++) {
		cin >> A[i];
		cnt[A[i]]++;
	}
	ll sum = 0;
	for(int i=1; i<=N; i++) sum += nc2(cnt[i]);
	for(int i=1; i<=N; i++) {
		cout << sum - nc2(cnt[A[i]]) + nc2(cnt[A[i]]-1) << endl;
	}
}

Measured memory_bytes: 4736
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++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 all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,L;
  cin>>N>>L;
  ll sum=(1+N)*N/2-(1-L)*N;

  ll ans;
  ll min=INF;
  for(int i=1;i<N+1;i++){
    if(min>abs(L+i-1)){
      min=abs(L+i-1);
      ans=sum-(L+i-1);
    }
  }
  cout<<ans<<endl;
    

}








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

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> arr;
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        arr.emplace_back(temp, i);
    }
    sort(arr.begin(), arr.end());
    int ans[arr.size()];
    for(int i = 0; i < n; i++){
        if(i < n / 2){
            ans[arr[i].second] = arr[n / 2].first;
        } else {
            ans[arr[i].second] = arr[n / 2 - 1].first;
        }
    }
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5464
#include <bits/stdc++.h>
using namespace std;
int A[100];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int tmp;
		cin>>tmp;
		tmp+=100;
		A[i]=tmp;
	}
	int mini=1000000;
	for(int i=0;i<=200;i++){
		int tmp=0;
		for(int j=0;j<n;j++){
			tmp+=(A[j]-i)*(A[j]-i);
		}
		mini=min(mini,tmp);
	}
	cout<<mini<<endl;
}

Measured memory_bytes: 256
<?php

list($h, $w) = explode(' ', trim(fgets(STDIN)));

$s = [];
for ($i = 0; $i < $h; ++$i) {
    $s[] = str_split(trim(fgets(STDIN)));
}

$maze_master = new MazeMaster($h, $w, $s);
echo $maze_master->getLongestDistnace();

class MazeMaster
{
    private $height;
    private $width;
    private $maze;
    private $longest_distance = 0;

    public function __construct($height, $width, $maze)
    {
        $this->height = $height;
        $this->width = $width;

        for ($i = 0; $i < $this->height; ++$i) {
            for ($j = 0; $j < $this->width; ++$j) {
                $this->maze[$this->convertXY2Index($j, $i)] = $maze[$i][$j];
            }
        }
    }

    /**
     * 各点に対して最も遠い点までの距離をBFS（幅優先探索）で求める
     *
     * @return void
     */
    public function getLongestDistnace()
    {
        foreach ($this->maze as $index => $road_or_stop) {
            if ($road_or_stop === '#') {
                continue;
            }
            $distance = $this->getLongestDistnaceWithStartPoint($index);
            if ($distance > $this->longest_distance) {
                $this->longest_distance = $distance;
            }
        }

        return $this->longest_distance;
    }

    /**
     * 各点に対して最も遠い点までの距離をBFS（幅優先探索）で求める
     *
     * @return void
     */
    protected function getLongestDistnaceWithStartPoint($start_point_index)
    {
        $que = [$start_point_index];
        $distance = [$start_point_index => 0];
        $passed = [];

        while (($current_point = array_shift($que)) !== null) {
            $passed[$current_point] = $distance[$current_point];
            foreach ($this->getNextPoints($current_point) as $next_point) {
                if ($this->maze[$next_point] === '#') {
                    continue;
                }
                if (array_key_exists($next_point, $passed)) {
                    continue;
                }
                if (in_array($next_point, $que)) {
                    continue;
                }

                $que[] = $next_point;
                $distance[$next_point] = $distance[$current_point] + 1;
            }
        }

        return max($distance);
    }

    protected function getNextPoints($current_point)
    {
        $x = $current_point % $this->width;
        $y = ($current_point - $x) / $this->width;

        $next_points = [];
        if ($y > 0) {
            $next_points[] = $this->convertXY2Index($x, $y - 1);
        }
        if ($y < $this->height - 1) {
            $next_points[] = $this->convertXY2Index($x, $y + 1);
        }
        if ($x > 0) {
            $next_points[] = $this->convertXY2Index($x - 1, $y);
        }
        if ($x < $this->width - 1) {
            $next_points[] = $this->convertXY2Index($x + 1, $y);
        }

        return $next_points;
    }

    protected function convertXY2Index($x, $y)
    {
        return $this->width * $y + $x;
    }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

struct Dinic {
  struct edge { int v; long long c; };
  vector<edge> es;
  vector<vector<int>> g;
  vector<int> dist;
  vector<int> index;
 
  Dinic(int n) : g(n), dist(n), index(n) {}
 
  void add(int u, int v, long long c) {
    g[u].push_back(es.size());
    g[v].push_back(es.size() + 1);
    es.push_back(edge{v, c});
    es.push_back(edge{u, 0});
  }
 
  long long calc(int s, int t) {
    long long ans = 0;
    while (bfs(s, t)) {
      for (;;) {
        long long d = dfs(s, t, 1e18);
        if (d == 0) break;
        ans += d;
      }
    }
    return ans;
  }
 
  bool bfs(int s, int t) {
    fill(dist.begin(), dist.end(), -1);
    fill(index.begin(), index.end(), 0);
    queue<int> q;
    q.push(t);
    dist[t] = 0;
    while (!q.empty()) {
      int u = q.front(); q.pop();
      for (int i : g[u]) {
        int v = es[i].v;
        if (es[i ^ 1].c > 0 && dist[v] == -1) {
          dist[v] = dist[u] + 1;
          q.push(v);
        }
      }
    }
    return dist[s] != -1;
  }
 
  long long dfs(int u, int t, long long f) {
    if (u == t) return f;
    for (int &it = index[u]; it < g[u].size(); it++) {
      int i = g[u][it];
      int v = es[i].v;
      if (es[i].c > 0 && dist[v] < dist[u]) {
        long long d = dfs(v, t, min(f, es[i].c));
        if (d > 0) {
          es[i ^ 0].c -= d;
          es[i ^ 1].c += d;
          return d;
        }
      }
    }
    return 0;
  }
};

struct unionfind {
  vector<int> dat;

  unionfind(int n) : dat(n, -1) {}

  int find(int x) {
    if (dat[x] < 0) return x;
    return dat[x] = find(dat[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (dat[x] > dat[y]) swap(x, y);
    dat[x] += dat[y];
    dat[y] = x;
  }

  int size(int x) {
    return -dat[find(x)];
  }
};


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> P(N), Q(N);
  rep(i, N) cin >> P[i];
  rep(i, N) cin >> Q[i];
  unionfind up(N), uq(N);
  rep(i, N) up.unite(i, P[i]);
  rep(i, N) uq.unite(i, Q[i]);
  Dinic mf(2 + 2 * N);
  int s = 2 * N;
  int t = s + 1;
  int same = 0;
  rep(i, N) {
    int x = up.find(i);
    int y = uq.find(i) + N;
    if (i == P[i] && i == Q[i]) {
      same++;
    } else if (i == P[i]) {
      mf.add(s, y, 1);
    } else if (i == Q[i]) {
      mf.add(x, t, 1);
    } else if (P[i] != Q[i]) {
      mf.add(x, y, 1);
    } else {
      mf.add(x, y, 1);
      mf.add(y, x, 1);
    }
  }
  cout << N - mf.calc(s, t) - same << endl;
}


Measured memory_bytes: 19820
I0 = lambda :map(int,input().split())
I1 = lambda :int(input())
I2 = lambda :list(map(int,input().split()))
#####################################################


from sys import stdin,setrecursionlimit
#from copy import deepcopy
 
setrecursionlimit(10**6)
input=stdin.readline

def dfs(p,father=-1):
    for i in tree[p]:
        if i == father:
            continue
        counter[i]+=counter[p]
        dfs(i,p)

n ,q = I0()
counter = [0]*n
tree = [[] for i in range(n)]
for i in range(n-1):
    a,b=I0()
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for i in range(q):
    p,x = I0()
    counter[p-1]+=x
    

dfs(0)

print(*counter)

'''stack = [1]
while stack:
    yy = stack.pop()
    for i in tree[yy]:
        counter[i-1]+=counter[yy-1]
        stack.append(i)'''

Measured memory_bytes: 268456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
 
int shiftonly(int a) {
  int ans = 0;
  while (a % 2 == 0) {
    a = a / 2;         
    ans++;
  }
  return ans;
}
 
int main() {
  int N;
  cin >> N;
  int ans = 10000;
  rep(i, N) {
    int a;
    cin >> a;
    ans = min(ans, shiftonly(a));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll d = c-a-b;
    if(d<0){
        cout<<"No"<<endl;
    }else{
        if(4*a*b<d*d){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

//BIT
int bit[SIZE],n;
int sum(int i){
  int s=0;
  while(i>0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
}
void add(int i,int x){
  while(i<=n){
    bit[i] += x;
    i += i & -i;
  }
}

string s;
map<char,vector<int>> m; //記号と場所
map<char,queue<int>> q;
int p[SIZE];
int w[SIZE];

int main(){
  cin >> s;
  rep(i,0,s.size()){
    m[s[i]].push_back(i);
  }
  bool t = true;
  int u=0; //oddの数
  //int k=0; //odd中心
  for(auto v : m){
    int l = v.second.size();
    rep(i,l/2,l){
      p[v.second[i]] = 1;
    }
    if(l%2 == 1){
      u++;
      //k = abs((int)v.second[l/2] - (int)s.size()/2);
      p[v.second[l/2]] = 2;
      if(u>1){
        t = false;
        break;
      }
    }
  }

  ll ans = 0;

  if(t){
    int l=0;
    rep(i,0,s.size()){
      if(p[i] == 0)ans += l;
      else l++;
    }
    if(u==1){
      rep(i,0,s.size()){
        if(p[i]==1)ans++;
        if(p[i]==2)break;
      }
    }
    string a,b;
    rep(i,0,s.size()){
      if(p[i]==0)a.push_back(s[i]);
      if(p[i]==1)b.push_back(s[i]);
    }
    reverse(b.begin(),b.end());
    //aとbの距離をansに足す
    rep(i,0,a.size()) q[a[i]].push(i+1);
    rep(i,0,b.size()){
      w[i] = q[b[i]].front();q[b[i]].pop();
    }
    //wの転倒数
    n = a.size()+1;
    rep(i,0,a.size()){
      ans += i - sum(w[i]);
      add(w[i],1);
    }
  }else ans = -1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<ll> VL;

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

    ll N, Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    pair<ll, ll> lr[Q];
    for (ll i = 0; i < Q; ++i){
        ll l, r;
        cin >> l >> r;
        lr[i] = make_pair(l - 1, r - 1);
    }

    ll ruiseki[N] = {0};
    for (ll i = 1; i < N; ++i) {
        if (S[i - 1] == 'A' && S[i] == 'C') {
            ruiseki[i] = ruiseki[i - 1] + 1;
        } else {
            ruiseki[i] = ruiseki[i - 1];
        }
    }

    // for (ll i = 0; i < N; ++i) {
    //     cout << ruiseki[i] << endl;
    // }

    for (ll i = 0; i < Q; ++i) {
        ll ans = ruiseki[lr[i].second] - ruiseki[lr[i].first];
        cout << ans << endl;
    }
}

Measured memory_bytes: 3408
#include <bits/stdc++.h>
using namespace std;
 
#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)
 
#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif
 
using i64 = long long;
using iip = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;
 
template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }
 
template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }
 
template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
 
// template<typename ...T>
// istream& read(T&... args) { return (cin >> ... >> args); }
 
static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 
  int a, b;
  cin >> a >> b;
  set<int> as = {1, 2, 3};
  as.erase(a);
  as.erase(b);
  cout << *as.begin() << endl;
}

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

#define F first
#define S second
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),a.end()
#define pw(x) (1LL<<(x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl

using namespace std;

typedef long long ll;
typedef double dbl;
const int INF = 1.01e9;



int main() {
#define TASK "A"
#ifdef HOME
    assert(freopen(TASK".in", "r", stdin));
#endif
    int n;
    cin >> n;
    //int a[2][n] =
    vector<vector<int>> a(2, vector<int>(n));
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    //int dp[2][n] = {};
    vector<vector<int>> dp(2, vector<int>(n));
    dp[0][0] = a[0][0];
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            if (i + 1 < 2) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i + 1][j]);
            }
            if (j + 1 < n) {
                dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + a[i][j + 1]);
            }
        }
    }
    cout << dp[1][n - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
gets
input = gets.chomp.split(" ").map(&:to_i)
line = []
input.each_with_index do |x, i|
    line.push(x-i)
end
line.sort!
b = line.length % 2 == 0 ? line[(line.length / 2) - 1] : line[line.length / 2]
puts line.inject(0){|acc, cur| acc+(cur-b).abs}

Measured memory_bytes: 21816
K,N= map(int,input().split())
a_list = list(map(int,input().split()))
diff = []
for i in range(N-1):
    diff.append(a_list[i+1] - a_list[i])
diff.append(a_list[0] + (K-a_list[N-1]))
# print(max(diff))
print(K-max(diff))

Measured memory_bytes: 26444
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,temp,b1,b2,b4;
inline void read(int &x)
{
	int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<3)+(data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
int main()
{
	read(n);
	for(register int i=1;i<=n;++i)
	{
		read(temp);
		if(temp&1)b1++;
		else if(temp%4==0)b4++;
		else b2++;
	}
	if(!b2)
		if(b1<=b4+1)printf("Yes\n");
		else printf("No\n");
	else
		if(b1<=b4)printf("Yes\n");
		else printf("No\n");
	return 0;
}

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

int N, D;
vector<int> C;
vector<vector<int>> S;

void Read() {
  N = 26;
  cin >> D;
  C.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }
  S.resize(D);
  for (int i = 0; i < D; i++) {
    S[i].resize(N);
    for (int j = 0; j < N; j++) {
      cin >> S[i][j];
    }
  }
}

int ans_score = 0;
vector<int> ans;

void Write() {
  for (auto i : ans) {
    cout << i + 1 << "\n";
  }
  exit(0);
}

int Evaluate(vector<int> a) {
  vector<int> last(N, -1);
  int score = 0;
  for (int i = 0; i < D; i++) {
    score += S[i][a[i]];
    last[a[i]] = i;
    for (int j = 0; j < 26; j++) {
      score -= C[j] * (i - last[j]);
    }
    cout << score << "\n";
  }
  return score;
}

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

  Read();
  vector<int> a(D);
  for (int i = 0; i < D; i++) {
    cin >> a[i];
    a[i]--;
  }
  Evaluate(a);
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

// int prime[1000001];
// vector<ll> primes;

// void soe() {
//     int i,j;
//     for(i=2;i<1000001;i++) prime[i] = 1;
//     for(i=2;i<=sqrt(1000001);i++) {
//         if(prime[i] == 1) {
//             for(j=i*i;j<1000001;j+=i) {
//                 prime[j] = 0;
//             }
//         }
//     }
//     for(i=2;i<1000001;i++) {
//         if(prime[i]) primes.pb(i);
//     }
// }

int d[10];

bool valid(int n) {
    while(n) {
        if(d[n%10]) return false;
        n/=10;
    }
    return true;
}

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

    string s;
    int i=1,flag = 0, l, r;
    cin >> s;
    if(s.length() == 2) {
        if(s[0] == s[1]) {
            flag = 1;
            l = 0; r = 1;
        }
    } else {
        while(s[i]) {
            if(s[i+1]) {
                if((s[i] == s[i-1]) || (s[i] == s[i+1]) || (s[i-1] == s[i+1])) {
                    l = i-1 ; r = i+1;
                    flag = 1;
                    break;
                }
            }
            i++;
        }
    }
    if(flag) {
        cout << l+1 << ' ' << r+1;
    } else cout << -1 << ' ' << -1;
    cout << "\n";
    return 0;
}




Measured memory_bytes: 512
N = int(input())
AB = list()
for _ in range(N):
    ab = list(map(int, input().split()))
    ab.reverse()
    AB.append(ab)
AB.sort()
#print(AB)

at = 0
flag = False

for i in range(N):
    bt = AB[i][0]
    at += AB[i][1]
    #print(at, bt)
    if at > bt:
        flag = True
        break

if flag:
    print("No")
else:
    print("Yes")


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

pair<bool, string> f(string s, char first, char second)
{
    int n = s.size();
    string ret(n, '0');
    ret[0] = first;
    ret[1] = second;
    for (int i = 1; i <= n; i++)
    {
        int current = i % n;
        int prev = (n + i - 1) % n;
        int next = (n + i + 1) % n;
        if ((ret[current] == 'S' && s[current] == 'o') || (ret[current] == 'W' && s[current] == 'x'))
        {
            if (ret[next] == '0')
            {
                ret[next] = ret[prev];
            }
            else
            {
                if (ret[next] != ret[prev])
                {
                    return make_pair(false, ret);
                }
            }
        }
        else
        {
            if (ret[next] == '0')
            {
                if (ret[prev] == 'S')
                {
                    ret[next] = 'W';
                }
                if (ret[prev] == 'W')
                {
                    ret[next] = 'S';
                }
            }
            else
            {
                if (ret[next] == ret[prev])
                {
                    return make_pair(false, ret);
                }
            }
        }
    }
    return make_pair(true, ret);
}

int main()
{
    int N;
    string s;
    cin >> N >> s;

    pair<bool, string> ret;
    ret = f(s, 'S', 'S');
    if (ret.first)
    {
        cout << ret.second << endl;
        return 0;
    }

    ret = f(s, 'S', 'W');
    if (ret.first)
    {
        cout << ret.second << endl;
        return 0;
    }

    ret = f(s, 'W', 'S');
    if (ret.first)
    {
        cout << ret.second << endl;
        return 0;
    }

    ret = f(s, 'W', 'W');
    if (ret.first)
    {
        cout << ret.second << endl;
        return 0;
    }

    cout << -1 << endl;
}


Measured memory_bytes: 896
// ACチェックのため、提出
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n, m;
    cin >> n >> m;
    VL a(n);
    REP(i,n){
        a[i] = in();
    }
    sort(ALL(a));
    reverse(ALL(a));
    ll ok = 0, ng = 1e6;
    while (ng - ok > 1){
        ll x = (ok + ng) / 2;
        ll s = 0;
        int j = n - 1;
        REP(i,n){
            while (j >= 0 && a[i] + a[j] < x) j--;
            s += j + 1;
        }
        if (s >= m) ok = x;
        else ng = x;
    }
    VL s(n + 1);
    REP(i,n) s[i + 1] = s[i] + a[i];
    ll c = 0, ans = 0;
    int j = n - 1;
    REP(i,n){
        while (j >= 0 && a[i] + a[j] < ok) j--;
        ans += (j + 1) * a[i] + s[j + 1];
        c += j + 1;
    }
    ans -= (c - m) * ok;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792