akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<string> v(H);
  for (int i = 0; i < H; i++) {
    cin >> v.at(i);
  }

  // ビット全探索
  // 入力例1の場合は、2^2 * 2^3 = 32パターンの全探索となる
  // (H, W) = (00, 000) ~ (11, 111)
  int ans = 0;
  for (int h = 0; h < (1 << H); h++) {
    for (int w = 0; w < (1 << W); w++) {

      // 各パターンについて '#' 記号の数を数える
      int count = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          // 1の場合、# が塗り替えられているとする
          if (((h >> i) & 1) == 0 &&
              ((w >> j) & 1) == 0 &&
              v.at(i).at(j) == '#') {
            count++;
          }
        }
      }

      if (count == K) { ans++; }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<map>
using lint=int64_t;
using namespace std;

const lint mod=1e9+7;

int main()
{
	int N;
	lint C[200010]={};

	cin >> N;
	for(int i=1;i<=N;i++)
		cin >> C[i];
	
	lint dp[200010]={};
	dp[0]=1;
	map<int,int> m;
	for(int i=1;i<=N;i++)
	{
		if(m[C[i]]==0)
		{
			m[C[i]]=i;
			dp[i]=dp[i-1];
		}
		else
		{
			if(i-m[C[i]]>1)
			{
				dp[i]=dp[i-1]+dp[m[C[i]]];
				m[C[i]]=i;
			}
			else
			{
				m[C[i]]=i;
				dp[i]=dp[i-1];
			}
		}
		dp[i]%=mod;
	}

	cout << dp[N] << endl;
	return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

char winhand(char enemy)
{
  if(enemy=='r') return 'p';
  else if(enemy=='s') return 'r';
  else return 's';
}

int main()
{
  int n,k,r,s,p;
  string t;
  cin>>n>>k>>r>>s>>p>>t;
  string myhand(n,' ');
  ll ans=0;
  for (int i = 0; i < k; ++i)
  {
    if(t[i]=='r') 
    {
      myhand[i]='p';
      ans+=p;
    }
    else if(t[i]=='s') 
    {
      myhand[i]='r';
      ans+=r;
    }
    else 
    {
      myhand[i]='s';
      ans+=s;
    }
  }

  for (int i = k; i < n; ++i)
  {
    char limit=myhand[i-k];
    if(limit==winhand(t[i])) 
    {
      set<char> st={'r','s','p'};
      st.erase(limit);
      st.erase(winhand(t[i+k]));
      myhand[i]=*(st.begin());
      continue;
    }
    if(t[i]=='r') 
    {
      myhand[i]='p';
      ans+=p;
    }
    else if(t[i]=='s') 
    {
      myhand[i]='r';
      ans+=r;
    }
    else 
    {
      myhand[i]='s';
      ans+=s;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b < c){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

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

  ll X; cin >> X;
  for (ll i = 0; i < 10000; i++) {
    double B5;
    ll B, A;

    A = i;
    B5 = pow(A, 5) - X;
    B = pow(abs(B5), 1.0 / 5.0);
    if (B5 < 0) B = -B;
    if (abs(pow(A, 5) - pow(B, 5) - X) < 1) {
      cout << A << ' ' << B;
      break;
    }

    A = -i;
    B5 = pow(A, 5) - X;
    B = pow(abs(B5), 1.0 / 5.0);
    if (B5 < 0) B = -B;
    if (abs(pow(A, 5) - pow(B, 5) - X) < 1) {
      cout << A << ' ' << B;
      break;
    }
  }
 return 0;
}

Measured memory_bytes: 4116
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> L(N+2),R(N+2),V(N+2);
    int T = 0;
    //l(s) - r(s)
    for(int i = 1;i <= N;i++){
        int t;
        cin >> t;
        t*=2;//
        L[i] = R[i-1];       
        R[i] = L[i] + t;
        T += t;
    }
    for(int i = 1;i <= N;i++)cin >> V[i],V[i]*=2;
    L[N+1] = R[N+1] = T;    
    vector<double> vel;
    for(int i = 0;i <= T;i++){
        double v = INF;
        int t = i;
        for(int j = 0;j < N+2;j++){
            if      (t <= L[j])   v = min(v, 1.*V[j] + L[j] - t);
            else if (t >= R[j])   v = min(v, 1.*V[j] + t - R[j]);
            else                  v = min(v, 1.*V[j]);
        }
        vel.push_back(v);
    }
    double sum = 0;
    for(int i = 0;i < T;i++){sum += 0.25*(vel[i] + vel[i+1]);}
    printf("%.9lf\n",sum/2);
}

Measured memory_bytes: 896
import math
from functools import reduce
n= int(input())
a= list(map(int,input().split()))

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
if n==1:
    print(a[0])
else:
    element = gcd(a[0], a[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,a[i])
        print(element)

Measured memory_bytes: 14760
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;


int main(void) {
    Int a[5];
    for (Int i = 0; i < 5; ++i) {
        cin >> a[i];
    }
    for (Int i = 0; i < 5; ++i) {
        if (a[i] == 0) {
            cout << i + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
	int a, b, c,E, F;
	int K;
	cin >> a >> b >> c;
	cin >> K;
	if (a == b && b == c) {
		for (int i = 0; i < K; i++) {
			a *= 2;
		}	
		cout << a + b + c<< endl;	
	} else {
		int ans = max({a, b, c});
		if (ans == a) {
			E = b;
			F = c;
		} else if (ans == b) {
			E = a;
			F = c;
		} else if (ans == c) {
			E = a;
			F = b;
		}
		for (int j = 0; j < K; j++) {
			ans = ans * 2;
		}
		cout << ans + E + F << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			long two_count = 0;
			for(int i = 0; i < N; i++) {
				for(long x = sc.nextLong(); x % 2 == 0; x /= 2) { two_count++; }
			}
			
			System.out.println(two_count);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 25300
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string N;
    cin >> N;
    int sum = 0;
    for (int i = 0; i < N.size(); i++)
    {
        sum += stoi(N.substr(i,1));
    }
    cout << ((sum%9==0) ? "Yes" : "No");
    
    return 0;
}

Measured memory_bytes: 3756
# -*- coding: utf-8 -*-


def main():
    n, k = map(int, input().split())
    ans = 0

    if k == 0:
        print(n ** 2)
        exit()

    for i in range(k + 1, n + 1):
        p, q = divmod(n, i)
        ans += p * (i - k)
        ans += max(q - k + 1, 0)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll hoge=0;
  ll num=n;
  while(n>0){
    hoge+=n%10;
    n/=10;
  }
  if(num%hoge ==0 )cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

// const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }

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

int main(){
  int k;
  cin >> k;
    int now = 7;
    now %= k;
    int ret = 1;
    while (ret<=k+1) {
      if (now == 0) break;
      ret++;
      now *= 10;
      now %= k;
      now += 7;
      now %= k;
    }
  if(now==0)cout << ret << endl;
  else
    cout << -1 << endl;
}


Measured memory_bytes: 3568
// AOJ 1218: Push!!
// 2018.1.23 bal4u@uu

#include <stdio.h>
#include <string.h>

#define QMAX 5000
#define BASE 1000
typedef struct { char pr, pc, cr, cc; int k; } Q;
Q q[QMAX+2]; int top, end;

char map[8][8];
char mk[8][8][8][8];
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
 
int in()
{
	int n;
	int c = getchar();
	n = c & 0xf, getchar();
	return n;
}

int main()
{
	int w, h, i, r, c, d, cr, cc, gr, gc, ans;
	Q t;

	while (w = in()) {
		h = in();
		
		memset(mk, 0, sizeof(mk));
		top = BASE, end = top+1;
		for (r = 0; r < h; r++) for (c = 0; c < w; c++) {
			d = in();
			if      (d == 2) q[top].cr = r, q[top].cc = c;
			else if (d == 3) gr = r, gc = c;
			else if (d == 4) q[top].pr = r, q[top].pc = c;
			if (d != 1) d = 0;
			map[r][c] = d;
		}

		q[top].k = 0;
		ans = -1;
		while (top != end) {
			t = q[top++];

			if (t.cr == gr && t.cc == gc) { ans = t.k; break; }

			if (mk[t.pr][t.pc][t.cr][t.cc]) continue;
			mk[t.pr][t.pc][t.cr][t.cc] = 1;

			for (i = 0; i < 4; i++) {
				r = t.pr + mv[i][0], c = t.pc + mv[i][1];
				if (r == t.cr && c == t.cc) continue;
				if (r < 0 || r >= h || c < 0 || c >= w || map[r][c]) continue;
				q[--top] = t, q[top].pr = r, q[top].pc = c;
			}

		    for (i = 0 ; i < 4; i++) {
				r  = t.pr + mv[i][0];
				c  = t.pc + mv[i][1];
				cr = t.cr + mv[i][0];
				cc = t.cc + mv[i][1];
				if ((r == t.cr && c == t.cc) && (r >= 0 && r < h && c >= 0 && c < w && !map[r][c]) &&
					(cr >= 0 && cr < h && cc >= 0 && cc < w && !map[cr][cc])) {
					q[end].pr = r, q[end].pc = c, q[end].cr = cr, q[end].cc = cc, q[end++].k = t.k+1;
				}
			}
        }
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1996
def main():
	N, A, B = [int(n) for n in input().split(" ")]
	X = [int(x) for x in input().split(" ")]
	D = []
	for i in range(1, len(X)):
		D.append(X[i] - X[i - 1])
	print(sum([min(A * d, B) for d in D]))

main()

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

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

using namespace std;

int main() {
  string a, b;
  std::cin >> a >> b;
  bool ok = false;
  rep(i, 10000 / 2) {
    if (to_string(i * i) == a + b) {
      std::cout << "Yes" << std::endl;
      ok = true;
      break;
    }
  }
  if (!ok) {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i = 0;i<N;i++){
    cin>>a[i];
  }
  int temp;
  int ans = 100000007;
  for(int i = 0;i<=100;i++){
    temp = 0;
    for(int k = 0;k<N;k++){
      temp += abs(i-a[k])*abs(i-a[k]);
    }
    ans = min(ans,temp);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int i,len,j;
  char str[20];
  scanf("%s",str);
  len = strlen(str);
  char str2[len],rts[len];
  for(j=0;j<=len;j++){
    str2[j] = str[j];
  }
  for(i=len;i>=0;i--){
  rts[i] = str2[len-i-1];
  }
  printf("%s\n",rts);
  
  return 0;
}

Measured memory_bytes: 524
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

#define Pig (OO)

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int n,m;
vector<int> v[100010];
int dp[100010];
bool vis[100010];

const int INF=117901063;

int DFS(int x)
{
	if(vis[x])return dp[x];
	
	vis[x]=1;
	
	int ans=0;
	
	for(int i=0;i<v[x].size();i++)ans=max(ans,DFS(v[x][i])+1);
	
	return dp[x]=ans;
}

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		
		v[x].pb(y);
	}
	
	int ans=0;
	
	for(int i=1;i<=n;i++)ans=max(ans,DFS(i));
	
	cout<<ans;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

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

    ll A, B, N;
    cin >> A >> B >> N;

    ll b = std::min(N, B - 1);
    cout << (A * b) / B - A * (b / B) << endl;
    return 0;
}

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

int main(){
  int n;
  while(cin>>n,n){
    for(int i=0;i<n;i++){
      int num[8];
      for(int j=0;j<8;j++) cin>>num[j];
      cout<<num[0]*num[4]-
	(num[1]*num[5]+
	 num[2]*num[6]+
	 num[3]*num[7])<<" "<<
	num[0]*num[5]+
	num[1]*num[4]+
	num[2]*num[7]-
	num[3]*num[6]<<" "<<
	num[0]*num[6]-
	num[1]*num[7]+
	num[2]*num[4]+
	num[3]*num[5]<<" "<<
	num[0]*num[7]+
	num[1]*num[6]-
	num[2]*num[5]+
	num[3]*num[4]<<endl;
    }
  }
  return 0;
}

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

int main()
{
    string str;
    
	int count[26] = {0};
	while(cin >> str)
		for(auto c : str)
			if(isalpha(c)) ++count[tolower(c) - 'a'];
    
	for(int i=0; i<26; ++i)
		cout << (char)('a'+i) << " : " << count[i] << '\n';

	return 0;
}



Measured memory_bytes: 3208
def main():

    N = int(input())
    S1 = input()
    S2 = input()

    mod = pow(10, 9) + 7
    i = 0
    count = 1
    isSame = True
    while i < N:
        if S1[i] == S2[i]:
            if isSame:
                if i == 0:
                    count *= 3
                else:
                    count *= 2
            isSame = True
            i += 1
        else:
            if isSame:
                if i == 0:
                    count *= 6
                else:
                    count *= 2
            else:
                count *= 3
            isSame = False
            i += 2
        count %= mod
    return count

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define dl double long
const int INF=0x3fffffff;
const ll MOD=1000000007;
const ll MODD=998244353;
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

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

  REP(i, K, N+2){
    ll f = i*(i-1)/2;
    ll l = i*(2*N-i+1)/2;
    ans += (l-f+1)%MOD;
  }
  cout << ans%MOD << "\n";
}


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

int main(void) {
  int h, w;
  cin >> h >> w;
  vector<string> vs(h);
  for (int i = 0; i < h; i++) {
    cin >> vs[i];
  }

  int dx[] = {0, 1, 0, -1};
  int dy[] = {1, 0, -1, 0};
  bool ret = true;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (vs[i][j] != '#') continue;
      bool ok = false;
      for (int k = 0; k < 4; k++) {
        int ni = i + dy[k], nj = j + dx[k];
        if (ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
        if (vs[ni][nj] == '#') ok = true;
      }
      if (!ok) ret = false;
    }
  }
  cout << (ret ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N;
  sc.scan(N);

  int[] d = new int[N];

  foreach (i; 0 .. N)
    sc.scan(d[i]);

  sort(d);

  int res = N;

  foreach (i; 0 .. N - 1) {
    if (d[i] == d[i + 1])
      res--;
  }

  writeln(res);
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || 
			(a == 7 && b == 5 && c == 5))
		std::cout << "YES" << std::endl;
	else
		std::cout << "NO" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int s[100000],n;
int search(int);
int main(){
  int i,key,q,cnt=0;

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

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&key);
    if(search(key)) cnt++;
  }

  printf("%d\n",cnt);
  return 0;
}

int search(int key){
  int left=0,right=n,mid;

  while(left<right){
    mid=(left+right)/2;

    if(s[mid]==key) return 1;
    else if(s[mid]>key) right=mid;
    else left=mid+1;
  }
  return 0;
}

Measured memory_bytes: 988
#include <iostream>
#include<limits.h>
using namespace std;

int main() {
	int n, k;
	cin>>n>>k;
	int a[n];
	for(int i = 0;i < n; i++){
		cin>>a[i];
	}
	int dp[n];
	if(k>=n){
		cout<<abs(a[0]-a[n-1])<<endl;
		return 0;
	}
	for(int i = 0; i < k; i++){
		dp[n-i-1] = abs(a[n-i-1] - a[n-1]);
	}
	for(int i = n-k-1; i>=0; i--){
		long long int min = INT_MAX;
		for(int j = 1; j <= k; j++){
			if(min > (abs(a[i] - a[i+j]) + dp[i+j])){
				min = abs(a[i] - a[i+j]) + dp[i+j];
			}
		}
		dp[i] = min;
	}
	cout<<dp[0]<<endl;

}


Measured memory_bytes: 1024
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 5e5 + 6, M = 1e9 + 7;
ll r[N], c[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll h, w, m, mr = 0, mc = 0;
    cin >> h >> w >> m;
    vector<pair<ll, ll>> v(m);
    vector<ll> vr, vc;
    map<pair<ll, ll>, ll> f;
    for (auto &[x, y] : v)
        cin >> x >> y, r[x]++, c[y]++, f[{x, y}] = 1;
    for (ll i = 1; i <= h; i++)
        mr = max(mr, r[i]);
    for (ll i = 1; i <= w; i++)
        mc = max(mc, c[i]);
    for (ll i = 1; i <= h; i++)
        if (mr == r[i])
            vr.push_back(i);
    for (ll i = 1; i <= w; i++)
        if (mc == c[i])
            vc.push_back(i);
    if (vr.size() * vc.size() > N)
        cout << mr + mc;
    else
    {
        for (ll i : vr)
            for (ll j : vc)
                if (!f[{i, j}])
                    return cout << mr + mc, 0;
        cout << mr + mc - 1;
    }
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    int cnt = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1]))
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	var a [3][2]int
	fmt.Scanf("%d %d", &a[0][0], &a[0][1])
	fmt.Scanf("%d %d", &a[1][0], &a[1][1])
	fmt.Scanf("%d %d", &a[2][0], &a[2][1])

	var flag [5]int
	for i := 0; i < 3; i++ {
		for j := 0; j < 2; j++ {
			flag[a[i][j]] += 1
		}
	}

	for i := 1; i < 5; i++ {
		if flag[i] > 2 {
			fmt.Println("NO")
			os.Exit(0)
		}
	}

	fmt.Println("YES")
}

Measured memory_bytes: 512
#include<iostream>
#include<map>
using namespace std;
map<long,int>M;
long ans;
int n,a[2<<17];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	long s=0;M[0]=1;
	for(int i=0;i<n;i++)
	{
		ans+=M[s+=a[i]]++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 13568
#include <stdio.h> 

int main(void)
{	
	int n, min, max, i, a[10000];
	long long int sum;
	
	min = 1000000;
	max = -1000000;
	sum = 0;

	scanf("%d",&n);

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

		if(a[i] < min)
		{
			min = a[i];
		}
		if(a[i] > max)
		{
			max = a[i];
		}
	
		sum = sum + a[i];
	 }
	 
	printf("%d %d %lld\n", min, max, sum);

	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

  int n;
  cin >> n;
  int k = -1;
  for (int i = 0; i < 1010; i++)
  {
    if (i * (i - 1) / 2 == n)
    {
      k = i;
      break;
    }
  }
  if (k == -1)
  {
    Yes(false);
    return 0;
  }
  int num = 1;
  vector<int> v[10010];
  rep(i, k) REP(j, i + 1, k)
  {
    v[i].push_back(num);
    v[j].push_back(num);
    num++;
  }
  Yes(true);
  cout << k << "\n";
  rep(i, k)
  {
    cout << v[i].size() << " ";
    rep(j, v[i].size()) cout << v[i][j] << (j == v[i].size() - 1 ? "\n" : " ");
  }
  return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int memo[10101];
bool done[10101];
int h,n,a[1010],b[1010];

int solve(int x){
	int i;
	if(done[x]){
		return memo[x];
	}
	done[x] = true;
	if(!x){
		return memo[x] = 0ll;
	}
	memo[x] = INF;
	for(i=0; i<n; ++i){
		memo[x] = min(memo[x],solve(max(x-a[i],0))+b[i]);
	}
	return memo[x];
}

int main(void){
	int i,h;
	cin >> h >> n;
	for(i=0; i<n; ++i){
		cin >> a[i] >> b[i];
	}
	cout << solve(h) << endl;
	return 0;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
            var k = array.First();
            var x = array.Last();

            var start = x - k + 1;
            var end = x + k - 1;

            Console.WriteLine(string.Join(" ", Enumerable.Range(start, end - start + 1).Select(_ => _.ToString())));
        }
    }
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  char c = s[s.size()-1];
  if (c == '3') {
    cout << "bon" << endl;
  } else if (c == '0' || c == '1' || c == '6' || c == '8') {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }

  return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main{
	public static void main(String[] args){
	int x =0;
	Scanner scan = new Scanner(System.in);
	ArrayList<Integer> list = new ArrayList<Integer>();
	int ii = 0;
		while(scan.hasNextLine()){
			x = scan.nextInt();			
			if(x == 0){
				break;
			}
			else{
				list.add(x);
			}
		}
		for(int i=0;i<list.size();i++){
			System.out.println("Case "+(i+1)+": "+list.get(i));
		}
	}
}

Measured memory_bytes: 66888
#include<stdio.h>

int linearSearch(int A[], int n, int key){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( A[i] == key ) return 1;
  }
  return 0;
}

int main(){
  int i, n, A[10000], q, key, sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
  scanf("%d", &q);
  for (i = 0; i < q; i++){
    scanf("%d", &key);
    if (linearSearch(A, n, key)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
int main(void)
{
	int a,b,c,x,cnt,i,j,k;
	scanf("%d %d %d %d",&a,&b,&c,&x);
	cnt=0;
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			for(k=0;k<=c;k++){
				if(i*500+j*100+k*50==x){
					cnt++;
				}
			}
		}
	}	
	printf("%d\n",cnt);
	return 0;
}	

Measured memory_bytes: 128
n=int(input())
task=[]
for i in range(n):
    a,b=map(int,input().split())
    task.append([b,a])
task.sort()
t=0
ans="Yes"
for i in range(n):
    t+=task[i][1]
    if t>task[i][0]:
        ans="No"
        break
print(ans)

Measured memory_bytes: 36284
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

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




// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> x(5);
    for(int i = 0 ; i < 5 ; i++){
        scanf("%lld",&x[i]);
    }
    int ans=-1;
    rep(i,5)if(x[i]==0)ans=i+1;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

int num2(int n)
{
	int cnt = 0;

	while ( true )
	{
		if ( n < 2 ) break;

		if ( n % 2 == 0 )
		{
			n /= 2;
			cnt++;
		}
		else
		{
			break;
		}
	}

	return cnt;
}

int main()
{
	int n;
	int sum = 0;
	cin >> n;
	rep (i, n)
	{
		int an;
		cin >> an;
		sum += num2(an);
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

int main(){
	int w,h,n,ans=0;
	int sx,sy,gx,gy;
	std::cin>>w>>h>>n>>sx>>sy;
	
	for(int i=1;i<n;i++){
	
		std::cin>>gx>>gy;
		int dist_x=sx-gx,dist_y=sy-gy;

		if((dist_x<=0&&dist_y<=0)||(dist_x>=0&&dist_y>=0)){
			dist_x=std::abs(dist_x);dist_y=std::abs(dist_y);
			ans+=std::max(dist_x,dist_y);
		}else if((dist_x>=0&&dist_y<=0)||(dist_x<=0&&dist_y>=0)){
			dist_x=std::abs(dist_x);dist_y=std::abs(dist_y);
			ans+=dist_x+dist_y;
		}

		sx=gx,sy=gy;

	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <math.h>
#include <string.h>
#define rep(i,a,n) for(int i=a;i<n;i++)

int main(){
	double a,b,C,S,L,h,PI=acos(-1.0);
	scanf("%lf %lf %lf",&a,&b,&C);
	S=0.5*a*b*sin(C*PI/180.0);
	L=a+b+sqrt(a*a+b*b-2*a*b*cos(C*PI/180.0));
	h=b*sin(C*PI/180.0);
	printf("%.10lf\n%.10lf\n%.10lf\n",S,L,h);
	return 0;
}

Measured memory_bytes: 1104
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

ll power(ll x, ll y) { ll temp; if( y == 0) return 1; temp = power(x, y/2); if (y%2 == 0) return temp*temp; else return x*temp*temp; } 

int main()
{
    fast;
	int k;cin>>k;
	int a,b;cin>>a>>b;
	int y1,y2;
	if(a%k==0)
	{
		y1=a/k -1;
	} 
	else
		y1=a/k;

	if(b%k==0)
	{
		y2=b/k;
	}
	else
		y2=b/k;

	if(y2>y1)
		cout<<"OK"<<"\n";
	else
		cout<<"NG"<<"\n";

}






Measured memory_bytes: 3584
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back

void solve(int n,int m,bool *isok){
  vector<int> a;
  rep(i,n){
    a.pb(i);
  }
  
  int p=0;
  for(int i=1;i<m+1 && a.size() != 1;i++){
    if (isok[i]){
      p=(p+1)%a.size();
      continue;
    }
    if (!isok[i]){
      a.erase(a.begin()+p);
      if (a.size() == 0)break;
      p%=a.size();
    }
  }

  rep(i,a.size()){
    if (i)cout <<' ';
    cout <<a[i]+1;
  }
  cout << endl;
}


main(){
  int n,m;
  bool isok[10011];
  while(cin>>n>>m && n){
    rep(i,m+1)isok[i]=true;
    REP(i,1,m+1){
      string in;
      cin>>in;
      if (i%3 == 0 && i% 5 == 0){
	if (in != "FizzBuzz")isok[i]=false;
      }else if (i%3==0){
	if (in != "Fizz")isok[i]=false;
      }else if (i%5==0){
	if (in !="Buzz")isok[i]=false;
      }else {
	stringstream sin(in);
	rep(j,in.size()){
	  if (!isdigit(in[j])){
	    isok[i]=false;
	    continue;
	  }
	}
	int tmp;
	sin>>tmp;
	if (tmp != i){
	  isok[i]=false;
	}
      }
    }
    solve(n,m,isok);
  }
}

Measured memory_bytes: 952
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#pragma GCC optimize ("O3")
using namespace std;
int main () {
    ios::sync_with_stdio(false);
    cin.tie (0);    
      ll n; cin>>n;
  vector <ll> a (n);
  for (auto &i : a) cin>>i;
  ll dp[n]; dp[0]=0; dp[1]=abs(a[1]-a[0]);
  for (ll i=2;i<n;++i) {
    dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1])); 
  }
  cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	string S;
	cin >> S;
	int K;
	cin >> K;

	for (int i = 0; i < K && i< S.size(); i++) {
		if (S[i] != '1') {
			cout << S[i] << endl;
			return 0;
		}
	}

	cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main(){
	long long int N, A, B, C, D, E; 
	cin >> N >> A >> B >> C >> D >> E;
	long long int a = (N+A-1)/A; //全員2に到着
	long long int b = max(a + 1, 1 + (B+N-1)/B); 
	long long int c = max(b + 1, 2 + (C+N-1)/C); 
	long long int d = max(c + 1, 3 + (D+N-1)/D); 
	long long int e = max(d + 1, 4 + (E+N-1)/E); 
	cout << e << endl; 
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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)*}
    };
}

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input!{
        w: usize,
        a: usize,
        b: usize,
    }
    println!(
        "{}",
        if min(a, b) + w > max(a, b) {
            0
        } else {
            max(a, b) - (min(a, b) + w)
        }
    );
}


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

int N,h[100000],K;
int a[100000];


int cost(int n)
{
  int k,temp;
  
  if(a[n]>=0)
  {
    temp=a[n];
  }
  else if(n==N-1)
  {
    temp=0;    
  }
  else if(n==N-2)
  {
    temp=cost(n+1)+abs(h[n]-h[n+1]);
  }
  else
  {
    temp=cost(n+1)+abs(h[n+1]-h[n]);
    for(k=1;k<K && k+n<N-1;k++)
    {
      temp=fmin(temp,cost(n+k+1)+abs(h[n+k+1]-h[n]));
    }
  }
  a[n]=temp;
  return a[n];
}

int main()
{

  int j;
  scanf("%d %d",&N,&K);
  for(j=0;j<N;j++)
  {
    scanf("%d",&h[j]);
    a[j]=-1;
  }
  
  j=cost(0);
  
  printf("%d",j);
  
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a;
    vector<pair<int,int>> pv(n);
    for(int i=0;i<n;i++){
        cin>> a;
        pv[i].second = i+1;
        pv[i].first = a;
    }
    sort(pv.begin(),pv.end());
    for(int i=0;i<n;i++){
        cout << pv[i].second;
        if(i==n-1){
            cout << endl;
        }else{
            cout << ' ';
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  int one = 0;
  int two = 0;
  int four = 0;
  for (int i = 0; i < N; i++) {
    if (a.at(i) % 4 == 0) four++;
    else if (a.at(i) % 2 == 0) two++;
    else one++;
  }
  if ((two == 0 && four >= one - 1) || (two != 0 && four >= one)) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};

template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}

extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


int main()
{
    int n;
    cin>>n;
    vector<int> c(n+1);
    REP(i,n)
        cin>>c[i+1];
    vector<int> fil(n+1);
    int q;
    cin>>q;
    int ans=0;
    REP(i,q)
    {
        int t,x,d;
        cin>>t>>x>>d;
        if(t==1)
        {
            if(fil[x]+d>c[x])
            {
                //print(i,t,x,d);
                if(ans==0)
                    ans=x;
            }
            fil[x]+=d;
        }
        else
        {
            if(fil[x]-d<0)
            {
                //print(i,t,x,d);
                if(ans==0)
                    ans=x;
            }
            fil[x]-=d;
        }
    }
    print(ans);
}



Measured memory_bytes: 3112
//
// Created on 2020/08/05.
//

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



int main() {
    string s;
    cin>>s;
    int black = 0;
    int white = 0;
    for (int i = 0; i < s.size(); ++i) {
        if(i % 2 == 0){
            if(s[i] != '0')black++;
            if(s[i] != '1')white++;
        }else{
            if(s[i] != '1')black++;
            if(s[i] != '0')white++;
        }
    }
    cout<<min(black,white)<<endl;
    return 0;
}



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

#define int long long

signed main(){
    int amt = 100;
    int x;
    cin>>x;
    for(int i=1;;i++){
        amt = (amt*1.01);
        // cout<<amt<<endl;
        if(amt>=x){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3172
from collections import defaultdict
d = defaultdict(int)
n = int(input())
for i in range(n):
    a = int(input())
    if d[a] > 0:
        d[a] -= 1
    else:
        d[a] += 1

ans = 0
for v in d.values():
    if v > 0:
        ans += 1
print(ans)


Measured memory_bytes: 19380
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int H, W;
	cin >> H >> W;

	vector<vector<char>> a(H, vector<char>(W));
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			cin >> a[i][j];
		}
	}

	vector<vector<mint>> dp(H, vector<mint>(W));
	dp[0][0] = 1;
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			if (a[i][j]=='#') {
				continue;
			}

			if (i+1<H) {
				if (a[i+1][j]=='.') {
					dp[i + 1][j] += dp[i][j];
				}
			}

			if (j+1<W) {
				if (a[i][j+1]=='.') {
					dp[i][j + 1] += dp[i][j];
				}
			}
		}
	}

	cout << dp[H-1][W-1] << "\n";
}


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

int main() {
  string s; cin >> s;
  rep(i, s.length()) {
    cout << 'x';
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;
const int maxn = 100;
int n;
int a[maxn+1];

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	cin >> n;
	int dem=0,res=0;
	for (int i=1; i<=n; i++)
	{
		cin >> a[i];
		if (a[i]!=a[i-1])
		{
			res+=(dem/2);
			dem=1;
		}
		else
			dem++;
	}
	res+=(dem/2);
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int k,x;
    cin >> k >> x;
    if(k*500 >=x){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b, c, d; cin >> a >> b >> c >> d;
  cout << max(a * b, c * d) << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,t,h,l,m10=0,m100=0,z=0;
	cin>>n>>m10>>m100>>l;
	int a[n][2];
	for(int i=0;i<n;i++)
		cin>>a[i][0]>>a[i][1];
	long long c=0;
	while(1){
		if(a[c%n][0]){
			if(m10+1>l)goto L;
			a[c%n][0]--;
			z++;
			m10++;
		}
		else if(a[c%n][1]){
			a[c%n][1]--;
			z+=10;
			m100++;
		}
		else goto L;
		if(z>=9){
			if(m10<z-9)goto L;
			a[c%n][0]+=z-9;
			m10-=z-9;
			z=0;
		}
		c++;
	}
	L:;cout<<(c)%n+1<<endl;
}

Measured memory_bytes: 3116