akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

string S;

int main() {
	cin >> S; long long ans = 0, cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'W') {
			ans += (i - cnt); cnt++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <queue>

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

int main()
{
	int n,a,b;
	scanf("%d %d %d",&n,&a,&b);
	ll mx=(ll) a+(ll) b*(ll) (n-1);
	ll mn=(ll) b+(ll) a*(ll) (n-1);
	ll ret=max(0LL,mx-mn+1);
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <stdio.h>
using namespace std;
int main(void){
    string s;
    int num=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        num+=s[i]-'0';
    }
    if(stoi(s)%num==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main () {
    int n, card;
    char type;
    int trump[4][14];
    int given_type;
    scanf("%d", &n);
    for (int i = 0; i < 4; i++) {
        for (int j = 1; j < 14; j++) {
            trump[i][j-1] = j;
        }
    }
    for (int i=0; i < n; i++) {
        scanf(" %c %d", &type, &card);
        if ( type == 'S') {
            given_type = 0;
        } else if ( type == 'H' ) {
            given_type = 1;
        } else if ( type == 'C' ) {
            given_type = 2;
        } else if ( type == 'D' ) {
            given_type = 3;
        }
        trump[given_type][card - 1] = 0;
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 1; j < 14; j++) {
            int check = trump[i][j-1];
            if (0 < check) {
                if ( i == 0) {
                    printf("%c %d\n", 'S', check);
                } else if ( i == 1 ) {
                    printf("%c %d\n", 'H', check);
                } else if ( i == 2 ) {
                    printf("%c %d\n", 'C', check);
                } else if ( i == 3 ) {
                    printf("%c %d\n", 'D', check);
                }
            }
        }
    }
    return 0;
}

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

public class Main {

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

		Scanner scan = new Scanner(System.in);

		int T_studyTime, X_Baisu;
		T_studyTime = scan.nextInt();
		X_Baisu = scan.nextInt();

		System.out.println((double) T_studyTime / X_Baisu);
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 21844
/**
 * auther: moririn_cocoa
 */

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second


int main(void) {

double R;

cin >> R;

cout << R * 2 * 3.141592653589793238 << endl;

    return 0;
}




Measured memory_bytes: 3764
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  // cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  string s, t;
  cin >> s >> t;
  REP(i, s.size()) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, L, R, H, W;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	int num[200000] = {};
	for (int i = 0; i < N; i++) {
		cin >> M;
		num[M]++;
		num[M + 1]++;
		num[M + 2]++;
	}
	int box = 0;
	for (int i = 0; i < 200000; i++) {
		if (num[box] < num[i]) {
			box = i;
		}
	}
	cout << num[box] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int m,p[n][n],shitteru;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				p[i][j]=0;
			}
		}
		for(int i=0;i<n;i++){
			cin>>m;
			for(int j=0;j<m;j++){
				cin>>shitteru;
				p[i][shitteru-1]=1;
			}
		}
		int k;
		cin>>k;
		int l[k];
		for(int i=0;i<k;i++){
			cin>>l[i];
		}
		int hannin=-1;
		for(int i=0;i<n;i++){
			int flg=1;
			for(int j=0;j<k;j++){
				if(p[i][l[j]-1]==0){
					flg=0;
					break;
				}
			}
			if(flg==1&&hannin==-1){
				hannin=i+1;
			}
			else if(flg==1&&hannin>-1){
				hannin=-1;
				break;
			}
		}
		cout<<hannin<<endl;
	}
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long a, long long b, long long x){
	static const double pi = 3.141592653589793;
	double res = 0.0;
	if (x*2 <= a*a*b) res = atan2(b, x*2.0/a/b)*180.0 / pi; else res = atan2(b-(x*2.0/a/a-b), a)*180.0 / pi;
	printf("%.16f\n", res);
}

int main(){	
	long long x;
	long long b;
	long long a;
	scanf("%lld",&a);
	scanf("%lld",&b);
	scanf("%lld",&x);
	solve(a, b, x);
	return 0;
}



Measured memory_bytes: 384
#include<cstdio>
/*int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int ans = a>2*b ? a-2*b : 0;
    printf("%d\n",ans);
    return 0;
}
*/
int d[55];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i ++)
    {
        scanf("%d",&d[i]);
    }
    int ans = 0;
    for(int i = 1;i <= n;i ++)
    {
        for(int j = i+1;j <= n;j ++)
        {
            ans += d[i]*d[j];
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  std::unordered_map<i64, i64> B, C;
  for (i64 i = 0; i < N; ++i) {
    ++B[i + A[i]];
    ++C[i - A[i]];
  }

  i64 answer = 0;
  for (const std::pair<i64, i64>& pair : B) {
    answer += pair.second * C[pair.first];
  }

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

Measured memory_bytes: 27904
_, m = gets.split.map(&:to_i)

solved = {}
wa = {}
was = 0
m.times do
  p, s = gets.split
  p = p.to_i
  next if solved[p]
  case s
  when 'AC'
    solved[p] = true
    was += wa[p]||0
  when 'WA'
    wa[p] = (wa[p]||0)+1
  end
end

puts [(solved.select{|_,v|v}.size), was]*' '



Measured memory_bytes: 14716
#include<stdio.h>
int cmb(int b, int n, int s)
{
	int c, i;
	if (n == 0)
		return s == 0;
	c = 0;
	for (i = b; i <= 9 && i <= s; i ++)
		c += cmb(i+1, n-1, s-i);
	return c;
}
int main()
{
	int n, s;
	while (scanf("%d%d", &n, &s)>0, n||s) {
		printf ("%d\n", cmb(0, n, s));
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>

int main()
{
  int c1x, c1y, c1r;
  int c2x, c2y, c2r;

  std::cin >> c1x >> c1y >> c1r;
  std::cin >> c2x >> c2y >> c2r;

  double d;

  d = sqrt( (c1x-c2x) * (c1x-c2x) + (c1y-c2y) * (c1y-c2y) );

  if( d > (c1r+c2r) )
    std::cout << "4" << std::endl;
  
  /*
  if( fabs(c1r+c2r-d) <= 0.000000001 )
  std::cout << "3" << std::endl;
  */

  if( d == (c1r+c2r) )
    std::cout << "3" << std::endl;
  
  if( fabs(c1r-c2r) < d && d < (c1r+c2r) )
    std::cout << "2" << std::endl;
  
  /*
  if( fabs( d - fabs(c1r-c2r) ) <= 0.000000001 )
  std::cout << "1" << std::endl;
  */

  if( d == fabs(c1r-c2r) )
    std::cout << "1" << std::endl;
  
  if( d < fabs(c1r-c2r) )
    std::cout << "0" << std::endl;

  return 0;
}


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

int main(){
  int a,i,j,b;
  string s;
  cin>>a>>b>>s;
  for(i=0;i<a;i++){
    if(s.at(i)>='0'&&s.at(i)<='9'){
      continue;
    }else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  if(s.at(a)!='-'){
    cout<<"No"<<endl;
    return 0;
  }
  for(i=a+1;i<=a+b;i++){
    if(s.at(i)>='0'&&s.at(i)<='9'){
      continue;
    }else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

class combination
{
public:
  vector<int> fac, finv, inv;

  combination(int M)
  {
    fac = vector<int>(M, 1);
    finv = vector<int>(M, 1);
    inv = vector<int>(M, 1);

    for (int i = 2; i < M; i++)
    {
      fac.at(i) = fac.at(i - 1) * i % MOD;
      inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
      finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
  }

  int COM(int N, int K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * (finv.at(K) * finv.at(N - K) % MOD) % MOD;
  }
};

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

  combination C(111111);

  for (int i = 0; i < K; i++)
  {
    int ans = C.COM(K - 1, i) * C.COM(N - K + 1, N - K - i) % MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e18
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int i = 0;
  while (1) {
    i++;
    int a;
    cin >> a;
    if (a == 0)
      return 0;
    printf("Case %d: %d\n", i, a);
  }

  return 0;
}



Measured memory_bytes: 3212
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

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

	int ops = 0;
	for (int i = 0; i < n; ++i) {
		while (a[i] % 2 == 0) {
			++ops;
			a[i] >>= 1;
		}
	}

	cout << ops << "\n";

	return 0;

}

Measured memory_bytes: 256
#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;
    int a, b, c;
    a = A+B;
    b = A-B;
    c = A*B;
    int res = a;
    if(a>=b) {
        if(a>=c) res = a;
    } 
    if(b>=a) {
        if(b>=c) res = b;
    } 
    if(c>a) {
        if(c>=b) res = c;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
int d[105];
int dis[105];
int ct[105][105];
int n,k;
int dijkstra(int a,int b){
  for(int i=0;i<105;i++){
      d[i]=INF;
      dis[i]=1;
  }
  d[a]=0;
  //cout<<a<<" "<<d[a]<<endl;
  
  int ne=-1;
  for(int j=0;j<n;j++){
    int co=INF;
    for(int i=1;i<=n;i++){
      
      if(dis[i]==1 && d[i]!=INF){
	//cout<<i<<" "<<d[i]<<endl;
	if(co>d[i]){
	  ne = i;
	  co = d[i];
	}
      }
    }
    if(ne==-1) break;
    dis[ne]=0;
    //cout<<"ne"<<ne<<endl;
    /*
    for(int i=1;i<=n;i++){
      cout<<d[i]<<endl;
    }
    */
    //cout<<"//"<<endl;
    for(int i=1;i<=n;i++){
      if(i==ne || dis[i]==0) continue;
      d[i]=min(d[i],d[ne]+ct[ne][i]);
    }
  }
  if(d[b]==INF) return -1;
  else return d[b];
}
int main(){
  while(1){
    cin>>n>>k;
    if(n==0 && k==0) break;
    
    for(int i=0;i<105;i++){
      for(int j=0;j<105;j++){
	ct[i][j]=INF;
      }
    }
    for(int i=0;i<k;i++){
      int f;
      cin>>f;
      if(f==0){
	int a,b;
	cin>>a>>b;
	cout<<dijkstra(a,b)<<endl;
      }
      else if(f==1){
	int c,d,e;
	cin>>c>>d>>e;
	ct[c][d]=min(ct[c][d],e);
	ct[d][c]=min(ct[d][c],e);
      }
    }
  }
  return 0;
}



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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

long long llabs(  
  long long n   
);  

int main(){
  unsigned LL a,b,c;

  scanf("%llu %llu %llu",&a,&b,&c);
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) printf("0\n");
  else if (b <= a && c <= a) printf("%llu\n",b * c);
  else if (a <= b && c <= b) printf("%llu\n",a * c);
  else if (a <= c && b <= c) printf("%llu\n",a * b);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int N,A[100],i,x=0,y=0,flag=1;

  scanf("%d",&N);
  if(N>=1 && N<=100){
    for(i=0;i<N;i++){
      scanf("%d",&A[i]);
    }
  }
  while(flag){
    flag=0;
  for(i=N-1;i>=1;i--)
    {
      if(A[i] < A[i-1]){
	x=A[i];
      A[i]=A[i-1];
      A[i-1]=x;
      y++;
      flag=1;
      }
    }
  }

  for(i=0;i<N;i++)
{
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
    printf("\n%d\n",y);

    return 0;
  }

Measured memory_bytes: 604
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a;
	while (true) {
		int sum = 0;
		cin >> n;
		if (n == 0) {
			cin >> n; return 0;
		}
		for (int h = 0; h < 9; h++) {
			cin >> a;
			sum += a;
		}
		cout << n - sum << endl;
	}
	cin >> n;
}


Measured memory_bytes: 3084
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        x: usize,
        y: usize,
    }

    let y = y - 2 * x;
    if y < 0 {
        echo!("No");
        return;
    }

    if y % 2 != 0 {
        echo!("No");
        return;
    }

    if y > 2 * x {
        echo!("No");
        return;
    }

    echo!("Yes");
}


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] a = cin.arrayInt();

        int[] b = new int[N];

        for (int i = N; i >= 1; i--)
        {
            int tmp = i * 2;
            int sum = 0;
            while (tmp <= N)
            {
                sum += b[tmp - 1];
                tmp += i;
            }
            b[i - 1] = (sum + a[i - 1]) % 2;
        }

        int ret = 0;
        for (int i = 0; i < N; i++)
        {
            ret += b[i];
        }

        Console.WriteLine(ret);
        if (ret == 0)
        {
            return;
        }

        for (int i = 0; i < N; i++)
        {
            if (b[i] == 1)
            {
                Console.Write("{0} ", i + 1);
            }
        }
        Console.Write("\n");
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	vi a(3);
	rep(i,3) cin >> a[i];
	sort(all(a));
	reverse(all(a));
	int ans = a[0]*10 + a[1] + a[2];
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

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

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

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
    }

    vector<ll> B(N + 1, 0);
    for (int i = 0; i < N; i++) {
        B[i + 1] = B[i] + A[i];
    }
    for (int i = 0; i <= N; i++) {
        B[i] = B[i] % K;
    }

    ll answer = 0;
    map<int, ll> m;
    for (int i = 0; i <= N; i++) {
        answer += m[B[i]];
        // cout << answer << endl;
        m[B[i]]++;
        if (i + 1 >= K) {
            m[B[i + 1 - K]]--;
        }
    }

    cout << answer << endl;
    
    return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

struct Segment {
    int l, r;
    Segment(int l = 0, int r = 0) : l(l), r(r) {}
} a[MAXN];

bool operator< (Segment a, Segment b) {
    if (a.l == b.l) return a.r > b.r;
    return a.l < b.l;
}

int n, m;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> m >> n;
    FOR(i,1,n) cin >> a[i].l >> a[i].r;
    sort(a+1, a+n+1);
    int l = 1, r = m;
    int res = 1;
    FOR(i,1,n) {
        int L = max(l, a[i].l);
        int R = min(r, a[i].r);
        if (L >= R) {
            L = a[i].l;
            R = a[i].r;
            res++;
        }
        l = L; r = R;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 1024
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  auto hw = readln.chomp.split.map!(to!int);
  int h = hw.front;
  int w = hw.back;
  int n = readln.chomp.to!int;
  alias Node = Tuple!(int, "num", int, "color");
  int[] a = readln.chomp.split.map!(to!int).array;
  Node[] b = new Node[](n);
  foreach (i, v; a)
  {
    b[i] = Node(v, cast(int) i + 1);
  }
  auto queue = redBlackTree!"a > b"(b);
  // queue.writeln;
  Node prev = Node(0, 0);
  foreach (i; 0 .. h)
  {
    int[] line;
    int cnt = 0;
    while (cnt < w)
    {
      Node node;
      if (prev.num)
      {
        node = prev;
      }
      else
      {
        node = queue.front;
        queue.removeFront;
      }
      int del = min(node.num, w - cnt);
      line ~= node.color.repeat.take(del).array;
      node.num -= del;
      prev = node;
      cnt += del;
    }
    if (i % 2)
    {
      // rev
      line = line.retro.array;
    }
    foreach (j, v; line)
    {
      if (j)
        write = " ";
      write = v;
    }
    writeln;
  }
}


Measured memory_bytes: 1532
//============================================================================
// Name        : h
// Date        : Wed Feb 20 14:23:41 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define pvi(x, v) if(v) pvar(x); fora(a, x) cout << a << " "; cout << "\n"
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"

#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int mod = (int) 1e9 + 7;
void add(int& a, int b) {
    a = a + b;
    if (a >= mod) {
        a -= mod;
    }
}

void solve() {
    int n, m; cin >> n >> m;
    vs gg(n);
    fori (i, 0, n) {
        cin >> gg[i];
    }

    vvi dp(n, vi(m, 0));
    dp[0][0] = 1;
    fori (i, 0, n) {
        fori (j, 0, m) {
            if (j - 1 >= 0 && gg[i][j] != '#' && gg[i][j-1] != '#') {
                add(dp[i][j], dp[i][j-1]);
            }
            if (i - 1 >= 0 && gg[i][j] != '#' && gg[i-1][j] != '#') {
                add(dp[i][j], dp[i-1][j]);
            }
        }
    }
    // trace(dp);
    output(dp[n-1][m-1]);
}

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



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

#define SIZE 100000

int array[SIZE];

int binary_search(int b,int from,int to){
	int now=(from+to)/2;
	int a=array[now];
	if(from>to){return 0;}
	
	if(a==b){
		return 1;
	}
	else if(a>b){
		return binary_search(b,from,now-1);
	}
	else if(a<b){
		return binary_search(b,now+1,to);
	}else{
		printf("error\n");
		exit(1);
	}
}

int main(void){
    int num,count=0;
    int b;
	
    scanf("%d",&num);
	
    for(int i=0;i<num;i++){
        scanf("%d",&array[i]);
    }
    
	int tmp;
    scanf("%d",&tmp);
    
    for(int i=0;;i++){
    	if(scanf("%d",&b)==EOF)break;
    	if(binary_search(b,0,num-1))count++;
    }
    
    printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 2128
#include <stdio.h>

int main(void){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b)printf("%d",c);
	else if(b==c)printf("%d",a);
	else if(c==a)printf("%d",b);
	return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  ll A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;

  if (V - W <= 0){
    NO(); return 0;
  }

  ll N = abs(A - B) / (V - W);
  if ((A - B) % (V - W) != 0) N++;

  if (N <= T) YES();
  else NO();

  return 0;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

const char newl = '\n';

int main() {
    int n;cin >> n;
    ll x[15],y[15],p[15];
    for (int i = 0;i < n;++i) cin >> x[i] >> y[i] >> p[i];
    vector<vector<ll>> mnx(1<<n,vector<ll>(n)),mny(1<<n,vector<ll>(n));
    for (int s = 0;s < (1<<n);++s) {
        for (int i = 0;i < n;++i) {
            mnx[s][i] = abs(x[i]);
            for (int j = 0;j < n;++j) if ((s>>j)&1) mnx[s][i] = min(mnx[s][i],abs(x[i]-x[j]));
            mnx[s][i] *= p[i];
        }
    }
    for (int s = 0;s < (1<<n);++s) {
        for (int i = 0;i < n;++i) {
            mny[s][i] = abs(y[i]);
            for (int j = 0;j < n;++j) if ((s>>j)&1) mny[s][i] = min(mny[s][i],abs(y[i]-y[j]));
            mny[s][i] *= p[i];
        }
    }
    vector<ll> ans(n+1,1e18);
    int t = 1;
    for (int i = 0;i < n;++i) t *= 3;
    for (int s = 0;s < t;++s) {
        int ss = s,bitx = 0,bity = 0,cnt = 0;
        for (int i = 0;i < n;++i) {
            if (ss%3 == 1) bitx += (1<<i),cnt++;
            else if (ss%3 == 2) bity += (1<<i),cnt++;
            ss /= 3;
        }
        ll sum = 0;
        for (int i = 0;i < n;++i) sum += min(mnx[bitx][i],mny[bity][i]);
        ans[cnt] = min(ans[cnt],sum);
    }
    for (int i = 0;i < n+1;++i) cout << ans[i] << newl;
}

Measured memory_bytes: 12996
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;

    vector<vector<size_t>> g(N);
    for (size_t i = 0; i < N; ++i) {
        size_t u, k; cin >> u >> k;
        u--;
        for (size_t j = 0; j < k; ++j) {
            size_t v; cin >> v;
            v--;
            g[u].emplace_back(v);
        }
    }

    vector<int> dist(N, INF);
    dist[0] = 0;

    queue<size_t> que;
    que.emplace(0);

    while (!que.empty()) {
        size_t now_node = que.front();
        que.pop();
        for (auto &next_node: g[now_node]) {
            if (chmin(dist[next_node], dist[now_node] + 1)) {
                que.emplace(next_node);
            }
        }
    }

    for (size_t idx = 0; idx < N; ++idx) {
        cout << idx + 1 << " " << (dist[idx] == INF ? -1 : dist[idx]) << "\n";
    }

    return 0;
}



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

int main(){
  long long int n, a[100010], ans=0, x=1000000010;
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n-1;i++){
    if(a[i]<0){
      a[i]*=-1;
      a[i+1]*=-1;
    }
    ans+=a[i];
  }
  if(a[n-1]<0){
    ans+=abs(a[n-1]);
    for(int i=0;i<n;i++)x=min(x,abs(a[i]));
    ans-=2*x;
  }
  else ans+=a[n-1];
  cout << ans << endl;

  return 0;
}


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

int main(){
  int m,f,r;
  while(1){
  cin >> m >> f >> r;
  if(m ==-1 && f==-1 && r==-1)
    break;
  if(m == -1 || f== -1)
    cout <<"F";
  else if(m+f >= 80)
    cout << "A";
  else if(m+f  >=65 && m+f <80)
    cout <<"B";
  else if(m+f >=50 && m+f <65)
    cout <<"C";
  else if(m+f >=30 && m+f <50)
    if(r>49)
      cout <<"C";
    else
      cout <<"D";
  else if(m+f<30)
    cout <<"F";
  cout <<endl;
}
}

Measured memory_bytes: 1156
let rec gcd n m =
  if m = 0 then n
  else gcd m (n mod m)

let lcm n m = n / gcd n m * m

(*
X / (0.5 * a_k) = (2 * p + 1)
*)

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a / 2 in
  Printf.printf "%d\n" @@
  try
    let lcm = Array.fold_left (fun ans a ->
      (if m < ans then raise Not_found);
      lcm ans a) 1 as_ in
    if
      Array.fold_left ( || ) false @@
      Array.init n @@ fun i -> lcm / as_.(i) mod 2 = 0
    then 0
    else (m / lcm + 1) / 2
  with Not_found -> 0



Measured memory_bytes: 6272
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=set(a);B=set(b)
if len(A)!=len(a) or len(B)!=len(b):
  print(0)
else:
  L=[]
  l=[0 for j in range(m)]
  for i in range(n):
    L.append(l)
  ct=1;ctn=0;ctm=0
  for k in range(m*n,0,-1):
    if k in A and k in B:
      L[n-ctn-1][m-ctm-1]=k
      ctn+=1;ctm+=1
    elif k in A:
      ct*=ctm;ctn+=1
    elif k in B:
      ct*=ctn;ctm+=1
    else:
      ct*=(ctm*ctn-m*n+k)
    if ct==0:
      break
    ct=ct%(10**9+7)
  print(ct)

Measured memory_bytes: 3188
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

bool arr[101];

uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }

int main(void){
	uint32_t n=nextpint();
	uint32_t k=nextpint();
	for(uint32_t i=k; i>0; i--){
		uint32_t d=nextpint();;
		for(uint32_t j=d; j>0; j--){
			uint32_t a=nextpint();
			arr[a]=true;
		}
	}
	uint32_t ans=0;
	for(uint32_t i=n; i>0; i--){
		if(!arr[i]) ans++;
	}
	printf("%"PRIu32"\n", ans);
}


Measured memory_bytes: 1580
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if(N%1000 == 0){
	cout << (N/1000)*1000-N << endl;
  }
  else{
	cout << (N/1000+1)*1000-N << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

int N, K;

int f(int a, int b){
    int ret = (a==b ? 1 : 0);
    
    ret += max(.0,(pow(10,K-2)-1)/9);
    
    int minimum = pow(10,K-1)*a + b;
    int maximum = min(N, ((int)pow(10,K-2)*(a+1)-1)*10 + b);
    
    for(int i = minimum; i <= maximum; i += 10){
        ret++;
    }
    
    return ret;
}

int solve(){
    if(N < 10) return N;
    
    int ans = 0;
    reps(a,1,8)reps(b,a+1,9){
        ans += f(a,b) * f(b,a) * 2;
    }
    reps(i,1,9){
        ans += f(i,i) * f(i,i);
    }
    
    return ans;
}

signed main(){
    cin >> N;
    K = (int)to_string(N).length();
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int S[1000] = { 0 };


int main() {
	ll N,Q;
	cin >>N>>Q;
	priority_queue<ll>Y[N];
	rep(i, Q) {
		int a;
		cin >> a;
		if (a == 0) {
			int b,c;
			cin >> b>>c;
			Y[b].push(c);
		}
		else if (a == 1) {
			int b;
			cin >> b;
			if (0 < Y[b].size()) cout << Y[b].top() << endl;
		}
		else {
			int b;
			cin >> b;
			if (0 < Y[b].size()) Y[b].pop();
		}
	}
	return 0;
}





Measured memory_bytes: 5164
#include<stdio.h>

int main(void)
{
  int a,b,many=0;
  scanf("%d %d",&a,&b);
  if(a<=0 && b>=0)
    {
      printf("Zero\n");
      return 0;
    }
  else if(a>0 && b>0)
    {
      printf("Positive\n");
      return 0;
    }
  else
    {
      many = b-a+1;
      if(many%2 == 0)
	{
	  printf("Positive\n");
	  return 0;
	}
      else
	{
	  printf("Negative\n");
	  return 0;
	}
    }
}

Measured memory_bytes: 128
import bisect
while True:
    n = int(input())
    if n == 0:
        break
    tc = sorted([int(input()) for _ in range(n)])
    hc = sorted([v for v in range(1, 2*n+1) if v not in tc])
    ba = []
    flag = True
    while tc and hc:
        if len(ba) == 0:
            try:
                if flag:
                    tmp = tc.pop(0)
                    flag = False
                else:
                    tmp = hc.pop(0)
                    flag = True
            except IndexError:
                pass
            ba = [tmp]
            continue

        last_card = ba[-1]
        if flag:
            x = bisect.bisect_left(tc, last_card)
            flag = False
            try:
                tmp = tc.pop(x)
            except IndexError:
                ba = []
                continue
        else:
            x = bisect.bisect_left(hc, last_card)
            flag = True
            try:
                tmp = hc.pop(x)
            except IndexError:
                ba = []
                continue
        ba.append(tmp)
    print(len(hc))
    print(len(tc))

Measured memory_bytes: 7656
import sys

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()

N, M = map(int, input().split())
A = list(map(int, input().split()))
print('Yes' if sum(1 for a in A if a * 4 * M >= sum(A)) >= M else 'No')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    ll num[3];
    num[0]=num[1]=num[2]=0;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	if(a[i]%4==0){
    		num[2]++;
    	}else if(a[i]%2==0){
    		num[1]++;
    	}else num[0]++;
    }
    if(num[1]>0){
    	if(num[2]>=num[0]){
    		cout << "Yes"<<endl;
    	}else{
    		cout <<"No" <<endl;
    	}
    }else{
    	if(num[2]+1>=num[0]){
    		cout <<  "Yes"<<endl;
    	}else{
    		cout << "No" <<endl;
    	}
    }
    return 0;
}


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

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    rep(i,n){
        if(i < k) cout << s;
        else if(s < 10000) cout << s+1;
        else cout << s-1;
        if(i != n-1) cout << " ";
    }
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int k, x;
  cin >> k >> x;
  cout << (k * 500 >= x ? "Yes": "No") << endl;
  return 0;
}


Measured memory_bytes: 888
import sys
sys.setrecursionlimit(100000)

S=int(input())
def saiki(T,c):
    T=str(T)
    if len(T) == 0:
        return 0
    for i in range(len(T)):
        c += int(T[:i+1])*2**(len(T[i+1:])-1 if len(T[i+1:]) != 0 else 0) + saiki(T[i+1:],0)
    return c
print(saiki(S,0))


Measured memory_bytes: 38256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val sList = (1..n).map { readLine()!! }.sorted()
    val map = mutableMapOf<String, Int>()
    sList.forEach { map[it] = map.getOrDefault(it, 0) + 1 }
    println(map.size)
}

Measured memory_bytes: 75684
// #define ll long long
// #define mod 1000000007
// #define maxn 200005
// #define vi vector<int>
// #define vl vector<ll>
// #define mii map<int,int>
// #define mli map<ll,int>
// #define forit(it,v) for(auto it=v.begin();it!=v.end();++it)
// #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// vector<vector<pair<int,int>>> vt(1000001);
// void sieve()
// {
//     for (int i = 2; i <= 1000000; ++i)
//     {
//         if (vt[i].size()>0)
//         {
//             continue;
//         }
//         for (int j = i; j <= 1000000; j+=i)
//         {
//             vt[j].push_back({i,0});
//         }
//     }
//     for (int i = 2; i < 1000001; ++i)
//     {
//         for (int j=0;j<vt[i].size();j++)
//         {
//             int x=i,c=0;
//             while(x%(vt[i][j].first)==0){
//                 c++;
//                 x=x/(vt[i][j].first);
//             }
//             vt[i][j].second=c;
//         }
//     }
// }
#include <string>
#include <iostream>
void solve()
{
    string x,y,z;
    cin>>x>>y;
    z=y.substr(0,y.length()-1);
    if (z==x)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    // fastIO;
    // sieve();
    int t=1;
    // int t;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3056
/* ex 7_1
   seira3 */

#include <stdio.h>

typedef struct point{ //頂点を表す構造体
    int x_elem; //x成分
    int y_elem; //y成分
}point;

point shift_point(point top, int x, int y){ //top.x_elemにxを,top.y_elemにyを足す関数
    top.x_elem += x; //top.x_elemにxを足す
    top.y_elem += y; //top.y_elemにyを足す
    return top;
}

int main(void){
    point top1, top2, top3, top4; //各頂点のpoint型の変数を宣言
    int diff_x, diff_y; //分かっている頂点の各成分の差のint型の変数を宣言
    scanf("%d %d",&top1.x_elem,&top1.y_elem); //top1に代入
    scanf("%d %d",&top2.x_elem,&top2.y_elem); //top2に代入
    diff_x = top2.x_elem - top1.x_elem; //2頂点のx成分の差
    diff_y = top2.y_elem - top1.y_elem; //2頂点のy成分の差
    top3 = shift_point(top2,-diff_y,diff_x); //(diff_x,diff_y)を90度回転させれば(-diff_y,diff_x),あとは足せば良い
    top4 = shift_point(top1,-diff_y,diff_x); //上と同様
    printf("%d %d %d %d\n", top3.x_elem, top3.y_elem, top4.x_elem, top4.y_elem); //答えを出力
    return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	//ifstream in("input.txt");
	//cin.rdbuf(in.rdbuf());
	ll N,A;
	cin >> N >> A;
	vector<ll> x(N);
	FOR(i,0,N)cin>>x[i];
	ll dp[51][50*50+1]={};
	dp[0][0] = 1;
	for(auto xx:x){
		FORR(i,0,N){
			FORR(j,0,50*50+1){
				if(dp[i][j]>0){
					dp[i+1][j+xx] += dp[i][j];
				}
			}
		}
	}
	ll ans = 0;
	FOR(i,1,N+1){
		FOR(j,0,50*50+1){
			if(j==A*i)ans += dp[i][j];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1280
# include <bits/stdc++.h>
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
using namespace std;
using lint = long long;

int main()
{
    lint X[4], Y[4];
    X[1] = Y[1] = 0;

    lint S;
    cin >> S;

    lint sqrtS = sqrt(S);

    if (sqrtS * sqrtS == S)
    {
        X[2] = Y[3] = sqrtS;
        X[3] = Y[2] = 0;
    }
    else
    {
        X[2] = sqrtS + 1;
        Y[3] = sqrtS + 1;
        X[3] = X[2] * Y[3] - S;
        Y[2] = 1;
    }

    reps (i, 3)
    {
        cout << X[i] << " " << Y[i] << ((i!=3)?" ":"\n");
    }

    return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
string s;
int cnt[3];
int p[3];
int num[3];

int main() {
	cin >> s;
	N = s.size();

	rep(i, N) {
		++cnt[s[i]-'a'];
	}

	rep(i, 3) p[i] = i;
	num[0] = N / 3;
	num[1] = (N%3>=1?N/3+1:N/3);
	num[2] = N-num[0]-num[1];

	bool ok = 0;
	do {
		bool f = 1;
		rep(i, 3) if (cnt[p[i]]!=num[i]) {
			f = 0;
		}
		if (f) ok = 1;
	} while (next_permutation(p, p+3));
	puts(ok?"YES":"NO");

	return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()





int main(){
  int A, B;
  cin >> A >> B;

  rep(i, 1, 20000){
    if(floor(i*0.08) == A && floor(i*0.1) == B){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256