akhauriyash/Code-Regression huggingface dataset:
while True:
    h,w = map(int,input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i % 2 == 0:
            if w % 2 == 0:
                print("#." * (w // 2))
            else:
                print("#" + ".#" * (w // 2))
        else:
            if w % 2 == 0:
                print(".#" * (w // 2))
            else:
                print("." + "#." * (w // 2))
    print("")


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

int main() {
    int N;
    cin >> N;
    int num_negative = 0, mini = 1000000000;
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a < 0) {
            num_negative++;
            a = -a;
        }
        sum += a;
        mini = min(mini, a);
    }

    if (num_negative % 2 == 0)
        cout << sum << endl;
    else
        cout << sum - 2 * mini << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int arrayA[][] = new int[n][m];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                arrayA[i][j] = sc.nextInt();
            }
        }
        int arrayB[] = new int[m];
        for(int i = 0; i < m; i++){
            arrayB[i] = sc.nextInt();
        }
       
        for(int i = 0; i < n; i++){
            int sum = 0;
            for(int j = 0; j < m; j++){
                sum += arrayA[i][j] * arrayB[j];
            }
            System.out.println(sum);
        }
        
    }
}


Measured memory_bytes: 40920
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	public static void main(String args[]) {
		MyInput in = new MyInput();

    int N = in.nextInt();
    int a,b;
    int all = 0;

    for(int i = 0; i < N; i++) {
        a = in.nextInt();
        b = in.nextInt();
        all += b - a + 1;
    }
    System.out.println(all);

	}
}

class MyInput {
	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;
	}

	public int readByte() { 
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}

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

	private void skipUnprintable() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if(!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public 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: 23124
#include<bits/stdc++.h>
#define MOD 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

main()
{
	IO;
	int n,w;
	cin>>n>>w;
	
	vector<pair<long long,long long>> v(n);
	
	for(int i=0;i<n;i++)
	{
		cin>>v[i].first>>v[i].second;
	}
	
	long long dp[1000*n+1];
	
	for(int i=0;i<1000*n+1;i++)
	{
		dp[i]=1e11;
	}
	
	//dp[v[0].first]=v[0].second;
	//cout<<dp[5];
	dp[0]=0;
	
	for(int i=0;i<n;i++)
	{
		/*for(int j=1000*n;j>=v[i].second+1;j--)
		{
			if(dp[j-v[i].second]!=1e11)
			{
				dp[j]=min(dp[j],dp[j-v[i].second]+v[i].first);
			}
		}
		
		dp[v[i].second]=min(dp[v[i].second],v[i].first);*/
		
		for(int j=1000*n;j>=v[i].second;j--)
		{
			dp[j]=min(dp[j],dp[j-v[i].second]+v[i].first);
		}
	}
	
	int i;
	//cout<<dp[90];
	
	for(i=1000*n;;i--)
	{
		if(dp[i]<=w)
		break;
	}
	
	cout<<i;
}

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

int main() {
        int n;
        cin >> n;
        vector<ll> l(n);
        rep(i,n)cin >> l[i];
        int ans = 0;
        if(n<3){
                cout << ans << endl;
                return 0;
        }
        for(int i=0;i<(n-2);i++){
                for(int j=i;j<(n-1);j++){
                        if(l[i]==l[j])continue;
                        for(int k=j;k<n;k++){
                                int a = l[i];
                                int b = l[j];
                                int c = l[k];
                                if(a==c || b==c)continue;
                                if((abs(b-c)<a&&a<b+c)||(abs(c-a)<b&&b<c+a)||(abs(a-b)<c&&c<a+b))ans++;
                        }
                }
        }

        cout << ans << endl;

}

Measured memory_bytes: 3632
import java.util.*;
 
import java.io.*;
 
public class Main{

    public static long Combination(long n, long r){
        long A = 1;
        long B = 1;
        for(long i = 0; i < r; i++){
            A = A*(n-i);
            B = B*(r-i);
        }
        if(A == 0) return 0;
        return A/B;
    }

    public static long solve(int i, int j, boolean check, int N, String S){
        if(i == N){
            if(j == 0){
                return 1;
            }else{
                return 0;
            }
        }

        if(j == 0) return 1;

        if(check){
            return Combination(N-i, j)*(long)Math.pow(9, j);
        }else{
            if(S.charAt(i) == '0') return solve(i+1, j, false, N, S);
            long Z = solve(i+1, j, true, N, S);
            long A = solve(i+1, j-1, true, N, S)*(S.charAt(i)-'1');
            long P = solve(i+1, j-1, false, N, S);
            return Z+A+P;
        }


    }
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        String N = s.next();
        int K = s.nextInt();
        System.out.println(solve(0, K, false, N.length(), N));
        
	}
} 

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

/*
int main(){
  int a, b;
  cin>>a>>b;
  //string のコンストラクタは第一引数で文字列の長さ、第二引数で埋める文字を示すので
  string s(b,'0'+a);
  string t(a, '0'+b);
  cout<<min(s,t)<<endl;

}
*/
int main(){
  int a,b;
  cin >>a>>b;
  int ans = min(a,b);
  char cans = '0'+ans;
  string sans ;
  rep(i,max(a,b))sans+=cans;
  cout <<sans<<endl;


}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())

D = [[0 for j in range(N)] for i in range(N)]

for _ in range(M):
    l, r = map(int, input().split())
    D[l - 1][r - 1] += 1

for i in range(N):
    for j in range(1, N):
        D[i][j] += D[i][j - 1]

for j in range(N):
    for i in range(N - 1)[::-1]:
        D[i][j] += D[i + 1][j]

for _ in range(Q):
    p, q = map(int, input().split())
    print(D[p - 1][q - 1])

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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

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

void solve_A(){
    int n, m;
    cin >> n >> m;
    int a[m];
    int sum = 0;
    REP(i,m){
        cin >> a[i];
        sum += a[i];
    }

    if(n - sum >= 0) cout << n - sum << endl;
    else cout << "-1" << endl;


}

int main(void){
    solve_A();
    
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    String a,b;
    int c;
    boolean d = false;
    Scanner scan = new Scanner(System.in);
    a = scan.next();
    b = scan.next();
    c = Integer.parseInt(a + b);
    for(int i = 0; i <= c; i++){
      if(c == i*i){
        d = true;
        break;
      }
    }
      
    if(d){       
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23892
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int h, m, s, n;
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        h = n / 3600;
        m = n % 3600 / 60;
        s = n % 60;
        System.out.printf("%d:%d:%d\n", h, m, s);
    }
}


Measured memory_bytes: 26360
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T
{
    std::io::Read::bytes(std::io::stdin())
                    .map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>()
                    .parse().ok().unwrap()
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    let x: i32 = read();
    let y: i32 = read();

    let price;

    if a + b < c * 2 {
        price = a * x + b * y;
    } else {
        if x > y {
            if a > c * 2 {
                price = c * 2 * x;
            } else {
                price = c * 2 * y + a * (x - y);
            }
        } else {
            if b > c * 2 {
                price = c * 2 * y;
            } else {
                price = c * 2 * x + b * (y - x);
            }
        }
    }

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


Measured memory_bytes: 4352
n, m= map(int, input().split())
List = [int(i) for i in input().split()]
num = 0
i = 0
L_sum = sum(List)
while i < len(List):
    if List[i] >= (1/(4*m))*L_sum:
        num += 1
    i += 1
if num >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import math

n=int(input())
a=list(map(int,input().split()))
def lcm(a,b):
    return a*b/math.gcd(a,b)
ans=int(lcm(a[0],a[1]))
for i in range(2,len(a)):
    ans=int(lcm(ans,a[i]))
print(int(ans))


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

int ans(int n,int *h,int *dp)
{    
     if(dp[n]!=-1)
	return dp[n];
	else if(n==1)
	return dp[1]==0;
	else if(n==2)
	return dp[2]=abs(h[2]-h[1]);
	else 
	return dp[n]=min(ans(n-1,h,dp)+abs(h[n]-h[n-1]),ans(n-2,h,dp)+abs(h[n]-h[n-2]));
}
int main()
{
	int n,i;
	cin>>n;
	int h[n+1];
	for(i=1;i<=n;i++)
	cin>>h[i];
	int dp[n+1];
	memset(dp,-1,sizeof(dp));
	cout<<ans(n,h,dp);
}


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

int main(){
  ll N,X;
  cin >> N >> X;
  vector<ll> A(N,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  ll count = 0;
  for(int i=0;i<N-1;i++){
    if(A[i]+A[i+1]<=X){
    }else if(A[i]<=X){
      count += (A[i]+A[i+1]-X);
      A[i+1] = X-A[i];
    }else{
      count += (A[i]+A[i+1]-X);
      A[i+1]=0;
      A[i]=X;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int ma = max(A, max(B, C));
    int d = ma * 3 - (A + B + C);
    cout << (d % 2 ? (d + 3) / 2 : d / 2) << endl;
    return 0;
}


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

int main() {
  int A, B;
  string S;
  cin >> A >> B >> S;
  for (int i = 0; i < A; i++) {
    if (!('0' <= S[i] && S[i] <= '9')) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (S[A] != '-') {
    cout << "No" << endl;
    return 0;
  }
  for (int i = A + 1; i < A + B + 1; i++) {
    if (!('0' <= S[i] && S[i] <= '9')) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 998244353;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

template<typename T>
vector<vector<T>> MakeVector2D(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

  int n, s;
  cin >> n >> s;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  FiniteField base = 1;
  for (int i = 0; i < n; i++) {
    base *= 2;
  }

  auto dp = MakeVector2D(n + 1, s + 1, FiniteField(0));
  dp[0][0] = base;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= s; j++) {
      dp[i + 1][j] += dp[i][j];
      if (j + xs[i] <= s) {
        dp[i + 1][j + xs[i]] += dp[i][j] / 2;
      }
    }
  }
  cout << dp[n][s] << endl;
}


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

using namespace std;

int main(int argc, char* argv[])
{
    int N, L; cin >> N >> L;

    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(S.begin(), S.end());

    for (int i = 0; i < N; i++) {
        cout << S[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i+1, N):
        if L[i] == L[j]:
            continue
        for k in range(j+1, N):
            if L[k] >= L[i] + L[j]:
                break
            if L[j] == L[k]:
                continue
            ans += 1
print(ans)


Measured memory_bytes: 9036
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);(i)++)
typedef long long ll;

int main(){
    string hantei[4] = {"dream","dreamer","erase","eraser"};
    string S;
    bool can = true;
    cin >> S;
    reverse(S.begin(),S.end());
    rep(i,4) reverse(hantei[i].begin(),hantei[i].end());
    for(int i=0;i<S.size();){
        bool can2 = false;
        rep(j,4){
            if (S.substr(i,hantei[j].size()) == hantei[j]){
                can2 = true;
                i += hantei[j].size();
                break;
            }
        }
        if (!can2){
            can = false;
            break;
        }
    }
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxn=3005;
const int mod=998244353;
typedef long long LL;
LL dp[maxn]; int a[maxn];
int main(void)
{
	int n,s; scanf("%d%d",&n,&s);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	LL res=0;
	for(int i=1;i<=n;i++)
	{
		dp[0]++; // 增加一次计数，表示从i 到 i 的容量为0时方案加一，这里相当于插入一个L, 
		for(int j=s;j>=a[i];j--) dp[j]=(dp[j]+dp[j-a[i]])%mod;
		res=(res+dp[s])%mod; // 计数答案每次增加量，当R等于i时 L=1 到 i 时的方案数 
	}
	printf("%lld\n",res);
	return 0;
}

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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

int main()
{
    string s;

    cin>>s;

    FOR(i,0,s.length())
    {
        cout<<'x';
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  int level[N][N];
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) {
      for (int b = 0; b < 10; b++)
        if (((i >> b) & 1) != ((j >> b) & 1)) {
          level[i][j] = b + 1;
          break;
        }
    }
  for (int i = 0; i < N; i++)
    for (int j = i + 1; j < N; j++)
      cout << level[i][j] << (j == N - 1 ? '\n' : ' ');
  return 0;
}


Measured memory_bytes: 4508
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#define LL long long
#define PP std::pair<LL,int>
int N;
std::map<LL,int> M;
std::vector<LL> B;
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		LL tmp;
		std::cin >> tmp;
		auto it = M.find(tmp);
		if (it == M.end()) {
			M.insert(PP{ tmp,1 });
		}
		else {
			it->second++;
		}
	}
	for (auto u : M) {
		if (u.second >= 2) {
			B.emplace_back(u.first);
		}
		if (u.second >= 4) {
			B.emplace_back(u.first);
		}
	}
	std::sort(B.rbegin(), B.rend());
	if (B.size() < 2)std::cout << 0 << std::endl;
	else std::cout << B[0] * B[1] << std::endl;
	return 0;
}

Measured memory_bytes: 6528
#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;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll n,m,x;
	cin>>n>>m>>x;
	ll** arr = new ll*[n];
	REP(i,0,n){
		arr[i] = new ll[m+1];
	}

	ll a[m+1] = {0};
	REP(i,0,n){
		REP(j,0,m+1){
			cin>>arr[i][j];
			a[j] += arr[i][j];
		}
	}
	REP(i,1,m+1){
		if(a[i] < x){
			cout<<-1<<endl;
			return 0;
		}
	}

	ll mini = 1e9;

	REP(i,0,(1 << n)){
		vector<ll> subset;
		REP(j,0,60){
			if((i >> j) & 1){
				subset.push_back(j);
			}
		}
		ll cost[m+1] = {0};
		REP(j,0,subset.size()){
			bool f = 0;
			REP(k,0,m+1){
				cost[k] += arr[subset[j]][k];
			}
			REP(k,1,m+1){
				if(cost[k] < x){
					f = 1;
					break;
				}
			}
			if(f == 0){
				mini = min(mini,cost[0]);
				break;
			}
		}
	}
	cout<<mini<<endl;
	
	return 0;
}  


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

#define p pair<int,int>
#define f first
#define s second
#define ll long long
#define db double

const int maxn=1e6+10;
const int inf=1e9;
ll a[maxn];
int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    ll n,ans1=0,ans2=0,ans3=0;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)
    {
        if(a[i]%4==0)ans1++;
        else if(a[i]%2==0)ans2++;
        else ans3++;
    }
    if(ans1>=ans3||ans2==n)cout<<"Yes";
    else if(ans1==ans3-1&&ans1+ans3==n)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

#define rp(i,t) for(int i=0;i<(t);i++)
#define rep(i,s,t) for(int i=(s);i<=(t);i++)
#define rsp(i,s,t) for(int i=(s);i<(t);i++)
#define rrp(i,t,s) for(int i=(t);i>=(s);i--)
#define rcp(i,s,b,d) for(int i=(s);b;d)
#define mst(a,x) memset(a,x,sizeof(a))
#define INF 1E18
#define N2 200002

#define Dp puts("")
#define Dw printf
#define Ds printf("#")

typedef long long ll;
char ch;
ll n,m,a[N2],b[N2],c[N2],sum,ans=INF;

inline void read(ll &x){x=0;do{ch=getchar();}while(ch<'0'||'9'<ch);do{x=x*10+ch-'0';ch=getchar();}while('0'<=ch&&ch<='9');}

int main(void)
{
	read(n),read(m);
	rep(i,1,n)read(a[i]);
	rep(i,2,n)
	{
		ll &l=a[i-1],&r=a[i];
		if(l<r)b[l+1]++,b[r+1]--,c[r+1]-=r-l;
		else b[l+1]++,b[r+m+1]--,c[r+m+1]-=r+m-l;
	}
	rep(i,1,m<<1)b[i]+=b[i-1];
	rep(i,1,m<<1)c[i]+=c[i-1]+b[i];
	rep(i,1,m)b[i]+=b[i+m],c[i]+=c[i+m],sum+=b[i];
	rep(i,1,m)ans=min(ans,sum-c[i]+b[i]);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 4352
N = int(input())
li = list(map(int,input().split()))
li.sort()
a = 0
b = 0
while len(li) >= 2:
  if li[-1] == li[-2] and a == 0:
    a = li[-1]
    del li[-1]
    del li[-1]
  elif li[-1] != li[-2]:
    del li[-1]
  elif li[-1] == li[-2] and a != 0:
    b = li[-1]
    break
print(a * b)

Measured memory_bytes: 14224
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  int N,H,W;
  in(N,H,W);
  int cnt=0;
  int A,B;
  rep(i,N){
    in(A,B);
    cnt+=H<=A&&W<=B;
  }
  out(cnt);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

void solve () {

}

int main () {
	//int var;
	int vector[5];
	for(int i = 0; i < 5; i++) {
		cin >> vector[i];
		if (vector[i] == 0) {
			cout << i+1;
			break;
		}
	}
	
	/*
	for (int i = 0; i < 5; i++) {
		if (vector[i] == 0) {
			cout << i+1;
			break;
		}
	}
	*/
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main()
{
    int x;
    int cnt = 0;
    while(1)
    {
        cin >> x;
        if(x == 0) break;
        else cout << "Case " <<  cnt+1 << ": " << x <<"\n";
        cnt++;

    }
    return 0;
}



Measured memory_bytes: 3044
import sys
import numpy as np

N, X  = list(map(int, input().split()))

L = np.array(list(map(int, input().split())))

x = np.zeros(N+1)

for n in range(1,N+1):
    x[n] = x[n-1] + L[n-1]
    if x[n] > X:
        print(n)
        sys.exit()

print(N+1)



Measured memory_bytes: 12396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<cstdio>
#include <iomanip>


using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int  INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int SIZE = 100;

int p[100050] = {};

int main() {
	int n;
	int ans = 0;
	bool count = false;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> p[i];
	}
	
	for (int i = 1; i <= n; i++)
	{
		if (i == p[i]) {
			if (!count) {
				ans++;
				count = true;
			}
			else {
				count = false;
			}
		}
		else {
			count = false;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

std::vector<int> sieve(int n) {
	std::vector<int> res(n);
	std::iota(res.begin(), res.end(), 0);
	for (int i = 2; i*i < n; ++i) {
		if (res[i] < i) continue;
		for (int j = i * i; j < n; j += i)
			if (res[j] == j) res[j] = i;
	}
	return res;
}

int CNT[1000010];

void factor(int n, const std::vector<int>& min_factor) {
	// min_factor は sieve() で得られたものとする
	int pre = -1;
	while (n > 1) {
		if (pre != min_factor[n])CNT[min_factor[n]]++;
		pre = min_factor[n];
		n /= min_factor[n];
		// 割った後の値についても素因数を知っているので順次求まる
	}
}

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

	int N;
	cin >> N;

	auto pv = sieve(1000010);

	int A;
	rep(i, 0, N)
	{
		cin >> A;
		factor(A, pv);
	}

	int ma = 1;
	rep(i, 0, 1000010)
	{
		chmax(ma, CNT[i]);
	}

	if (ma == N)
	{
		cout << "not coprime" << endl;
	}
	else if (ma == 1)
	{
		cout << "pairwise coprime" << endl;
	}
	else
	{
		cout << "setwise coprime" << endl;
	}

	return 0;
}


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

#define M 1e9+7
#define ll long long int
#define vii vector<int>
#define pii pair<int,int>

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

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

    int dp[n]={0};


    for(int i=1;i<n;i++){
        dp[i]=INT_MAX;
        for(int j=i-1;j>=0 and i-j<=k;j--){
            dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
        }
    }

    cout<<dp[n-1]<<endl;



    return 0;
}

Measured memory_bytes: 1024
/*input
5
1
2
1
2
2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int a[maxn];

map<int,ll> mp;

ll dp[maxn];

int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];

	dp[0]=1;
	for(int i=1;i<=n;i++){
		if(i>1&&a[i-1]==a[i-2]){
			dp[i]=mp[a[i-1]];
		}
		else{
			dp[i]=mp[a[i-1]]+dp[i-1];
			if(dp[i]>=MOD) dp[i]-=MOD;
			mp[a[i-1]]+=dp[i-1];
			if(mp[a[i-1]]>=MOD) mp[a[i-1]]-=MOD;
		}
		// cout<<i<<' '<<dp[i]<<'\n';
	}
	cout<<dp[n]<<'\n';
	return 0;
}


Measured memory_bytes: 15104
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int i, j, n, p;
  int x[100], y[100];
  double sum, d;
  
  cin >> n;

  for( i = 0; i < n; i++ ) cin >> x[i];
  for( i = 0; i < n; i++ ) cin >> y[i];

  // when 1 <= p <= 3
  for( p = 1; p <= 3; p++ ){
    sum = 0;
    for( i = 0; i < n; i++ ){
      sum += pow( fabs( x[i] - y[i] ), p );
    }
    printf("%lf\n", pow( sum, 1.0/p ) );
  }

  // when p is unlimited
  for( i = 0; i < n; i++ )
    d = d < fabs( x[i] - y[i] ) ? fabs( x[i] - y[i] ) : d;  
  printf("%lf\n", d);
  
  return 0;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int N, M;
vector<int> R;
vector<int> A;

void init()
{
	cin >> N;
	R.resize(N);
	rep(i, N) cin >> R[i];
	cin >> M;
	A.resize(M);
	rep(i, M) cin >> A[i];
}

void solve()
{
	sort(all(R));
	sort(all(A));
	int pos = 0;
	rep(i, N) {
		if (pos == M) break;
		if (R[i] == A[pos]) pos++;
	}
	PRINT(pos == M);
}



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

int main() {
    long long A;
    std::string B;
    std::cin >> A >> B;

    long long ans = 0;
    ans += A * 100 * (B[0] - '0');
    ans += A * 10 * (B[2] - '0');
    ans += A * (B[3] - '0');
    ans /= 100;

    std::cout << ans << "\n";
}

Measured memory_bytes: 3616
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = Enumerable.Repeat(0, nm[0]).Select(_ => Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray()).ToArray();
        canUse = new bool[nm[1]];
        count = new int[nm[1]];
        var possible = nm[0];
        var impossible = 0;
        while (possible - impossible > 1)
        {
            var mid = (possible + impossible) / 2;
            if (Judge(a, mid)) possible = mid;
            else impossible = mid;
        }
        Console.WriteLine(possible);
    }

    static bool[] canUse;
    static int[] count;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static bool Judge(int[][] a, int target)
    {
        int canUseCount = canUse.Length;
        int[] indexer = new int[a.Length];
        for (int i = 0; i < count.Length; i++)
            count[i] = 0;
        for (int i = 0; i < a.Length; i++)
            count[a[i][0]]++;
        for (int i = 0; i < canUse.Length; i++)
            canUse[i] = true;
        while (canUseCount > 0)
        {
            bool isValid = true;
            for (int i = 0; i < a.Length; i++)
            {
                if (canUse[a[i][indexer[i]]]) continue;
                while (!canUse[a[i][indexer[i]]])
                    indexer[i]++;
                count[a[i][indexer[i]]]++;
            }
            for (int i = 0; i < canUse.Length; i++)
            {
                if (!canUse[i])
                    continue;
                if (count[i] <= target)
                    continue;
                canUse[i] = false;
                isValid = false;    
                canUseCount--;
            }
            if (isValid) return true;
        }
        return false;
    }
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int pos = 0;
  
  for (int i = 1; i < N; i++) {
    string x = S.substr(0,i);
    string y = S.substr(i);
    set<char> s;
    int kind = 0;
    for (int j = 0; j < x.size(); j++) {
      s.insert(x[j]);
    }
    for (int j = 0; j < y.size(); j++) {
      if (s.count(y[j])) {
        kind += 1;
        s.erase(y[j]);
      }
    }
    pos = max(kind,pos);
  }
  
  cout << pos << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	while(1){
		int n,field[402][402]={},x,y,ue,sita,migi,hidari;
		field[200][200]=1;
		cin >> n;
		if(!n)	break;
		for(int f=1;f<n;f++){
			cin >> x >> y;
			for(int i=0;i<=400;i++){
				for(int j=0;j<=400;j++){
					if(field[i][j]==(x+1)){
						if(y==0)	field[i][j-1]=f+1;
						else if(y==1)	field[i-1][j]=f+1;
						else if(y==2)	field[i][j+1]=f+1;
						else	field[i+1][j]=f+1;
					}
				}
			}
		}
		for(int i=0;i<=400;i++){
			for(int j=0;j<=400;j++){
				if(field[i][j]){
						ue=i;
						break;
				}
			}
		}
		for(int i=0;i<=400;i++){
			for(int j=0;j<=400;j++){
				if(field[j][i]){
						hidari=i;
						break;
				}
			}
		}
		for(int i=400;i>=0;i--){
			for(int j=400;j>=0;j--){
				if(field[j][i]){
						migi=i;
						break;
				}
			}
		}
		for(int i=400;i>=0;i--){
			for(int j=400;j>=0;j--){
				if(field[i][j]){
						sita=i;
						break;
				}
			}
		}
		cout << abs(migi-hidari)+1 << ' ' << abs(ue-sita)+1 << endl;
	}
}


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

int main() {
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  
  if(e-a>f){
    cout<<":("<<endl;
  }
  else{
    cout<<"Yay!"<<endl;
  }
  
}

Measured memory_bytes: 256
H, W, K = gets.split.map(&:to_i)
CIJS = H.times.map { gets.chomp }

count = 0

(2 ** H - 1).times.each do |h|
  hs = sprintf("%0#{H}b", h)
  (2 ** W - 1).times.each do |w|
    ws = sprintf("%0#{W}b", w)
    k = 0
    CIJS.each.with_index do |line, i|
      next if hs[i] == "1"
      line.length.times.each do |j|
        next if ws[j] == "1"
        k += 1 if line[j] == "#"
      end
    end
    if k == K
      count += 1
    end
  end
end

puts count


Measured memory_bytes: 14216
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        r: usize,
        d: usize,
        x0: usize,
    }
    let mut x = x0;
    for i in 0..10 {
        x = r * x - d;
        println!("{}", x);
    }
}


Measured memory_bytes: 4352
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
s = ns()

change = 0
for i in range(1, n):
    if s[i] == 'E':
        change += 1

ans = [change]
for i in range(1, n):
    if s[i-1] == 'W':
        change += 1
    if s[i] == 'E':
        change -= 1
    ans.append(change)

print(min(ans))


Measured memory_bytes: 16128
from itertools import combinations_with_replacement
while True:
    price = int(input())
    if price == 0: break
    candidates = []
    for i in range(1, 25):
        tmp = list(combinations_with_replacement([200, 300, 500], i))
        for t in tmp:
            if sum(t) == price:
                candidates.append(t)
    ans = []
    for candidate in candidates:
        i=j=k=0
        for c in candidate:
            if c == 200:
                i += 1
            elif c == 300:
                j += 1
            else:
                k += 1
        m200, m300, m500 = divmod(i, 5)[1], divmod(j, 4)[1], divmod(k, 3)[1]
        ans.append(380*(i-m200)*0.8+380*m200 + 550*(j-m300)*0.85+550*m300 + 850*(k-m500)*0.88+850*m500)
    print(int(min(ans)))

Measured memory_bytes: 7992
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int L,A,B,C,D; cin >> L >> A >> B >> C >> D;
  cout << L - max((A+C-1)/C,(B+D-1)/D) << endl;
  return 0;
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 1000000007LL
ll pre[100002][2];
ll fact[1000002];
ll inv(ll a,ll b){
   ll res=1;
   while(b){
    if(b%2) res=(res*a)%mod;
    a=(a*a)%mod;
    b/=2;
   }
   return res;
}
ll ncr(ll n,ll r){
  if(r<0 or r>n) return 0;
  return (((fact[n]*inv(fact[r],mod-2))%mod)*inv(fact[n-r],mod-2))%mod;
}
int main() {
       ios::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);
       ll a,b;
       cin>>a>>b;
       if((a-b)%2){
        cout<<"IMPOSSIBLE";
       }
       else{
        cout<<(a+b)/2;
       }
}

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

int main() {
	int n;
	cin>>n;
	vector<int> arr (n);
	for(int i=0;i<n;i++)
	{
	    cin>>arr[i];
	}
	int count=0;
	for(int i=0;i<n;i+=2)
	{
	    if(arr[i]%2!=0)
	        count++;
	}
    cout<<count<<endl;
	return 0;
}


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

using namespace std;

#define DIM 200009
#define MODULO 1000000007
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double

long long i,j,k,l,n,m;

long long dp[DIM],a[DIM];

int main()
{
    cin>>n>>k;
    for(i=1;i<=n;i++)cin>>a[i];

    dp[0]=0;
    for(i=1;i<=k;i++){
        dp[i]=0;
        for(j=1;j<=n;j++){
            if(i>=a[j] && dp[i-a[j]]==0)dp[i]=1;
        }
    }

    if(dp[k]==1)cout<<"First"<<endl;
    else cout<<"Second"<<endl;

    return 0;
}


Measured memory_bytes: 1024
import sys
from functools import lru_cache

sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

mod = 10**9 + 7

i = 0
b = []
for ai in a:
    b.append(ai - i)
    i = ai + 1
b.append(N + 1 - i)


@lru_cache(maxsize=None)
def f(n):
    if n < 2:
        return n
    else:
        return f(n - 2) + f(n - 1)


ans = 1
for bi in b:
    ans *= f(bi) % mod
print(ans % mod)


Measured memory_bytes: 556248
n, m = list(map(int, input().split()))
s1 = {}
sn = []

for i in range(m):
    a, b = list(map(int, input().split()))
    if a == 1:
        s1[b] = 1
    elif b == n:
        sn.append(a)

res = False
for s in sn:
    if s in s1:
        res = True
        break

print("POSSIBLE" if res else "IMPOSSIBLE")

Measured memory_bytes: 22636
#include <iostream>


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#include <stdio.h>
#include <vector> 
#include <map> 
#include <algorithm>
#include <functional>


#include<iostream>
using namespace std;
int main()
{
	int a, c;
	std::string s;
	cin >> a >> s;

	if (a >= 3200) {
		printf("%s\n", s.c_str());
	} else {
		printf("red\n");
	}


	return 0;
}



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


int main(){
int A,B;
cin >> A >> B;
if(A<10&&B<10)cout << A*B <<endl;
else cout << -1 <<endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=1e5+50;
int n,a[N],b[N],c[N],c2[N],m,ans;bool vis[N];
vector<int>v[N];
void dfs(int x){
	vis[x]=1;
	for(int i=0,y;i<v[x].size();i++)
		if(!vis[y=v[x][i]])dfs(y);
}
int main(){
	scanf("%d",&n);n++;
	for(int i=1;i<n;i++)scanf("%d",&a[i]),a[n]^=a[i];
	for(int i=1;i<n;i++)scanf("%d",&b[i]),b[n]^=b[i];
	for(int i=1;i<=n;i++)c[i]=a[i],c2[i]=b[i];
	sort(c+1,c+n+1);sort(c2+1,c2+n+1);
	for(int i=1;i<=n;i++)if(c[i]!=c2[i])puts("-1"),exit(0);
	m=unique(c+1,c+n+1)-c-1;
	for(int i=1;i<=n;i++)a[i]=lower_bound(c+1,c+m+1,a[i])-c,b[i]=lower_bound(c+1,c+m+1,b[i])-c;
	for(int i=1;i<=n;i++)if(a[i]!=b[i])v[a[i]].pb(b[i]),ans++;
	for(int i=1;i<=m;i++)if(!vis[i]&&v[i].size())dfs(i),ans++;ans-=2;
	if(a[n]==b[n]){
		if(!v[a[n]].size())ans+=2;
		else ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int count = 0;
    if(N%2 == 1){
        cout << "No";
    } else {
        for(int i = 0; i < N/2; i++){
            if(S[i] != S[N/2+i]){
                count += 1;
            }
        }
        
        if(count == 0){
            cout << "Yes";
        } else {
            cout << "No";
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
int A,B,C,X;
//=============================
void input()
{
    cin>>A;
    cin>>B;
    cin>>C;
    cin>>X;
}
//=============================
void func(){}
//=============================
void solve()
{
    int ans = 0;
    rep(i,0,A){
        rep(j,0,B){
            rep(k,0,C){
                if (500*i + 100*j + 50*k == X)ans++;
            }
        }
    }
    cout<<ans<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256