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

public class Main{
	private static final Scanner scan = new Scanner(System.in)
												.useDelimiter("[,\\s+]");

	public static void main(String[] args){

			int[][] p = new int[10][10];
			for(int i = 0; i < 10; i++){
				for(int j = 0; j < 10; j++){
					p[i][j] = 0;
				}
			}
			while(scan.hasNext()){
				int x = scan.nextInt();
				int y = scan.nextInt();
				int size = scan.nextInt();
				switch(size){
					case 3 :
						if(x-2 >= 0)p[x-2][y]++;
						if(y-2 >= 0)p[x][y-2]++;
						if(x+2 <= 9)p[x+2][y]++;
						if(y+2 <= 9)p[x][y+2]++;
					case 2 :
						if(x-1 >= 0 && y-1 >= 0)p[x-1][y-1]++;
						if(x-1 >= 0 && y+1 <= 9)p[x-1][y+1]++;
						if(x+1 <= 9 && y-1 >= 0)p[x+1][y-1]++;
						if(x+1 <= 9 && y+1 <= 9)p[x+1][y+1]++;
					case 1 :
						if(x-1 >= 0)p[x-1][y]++;
						if(y-1 >= 0)p[x][y-1]++;
						if(x+1 <= 9)p[x+1][y]++;
						if(y+1 <= 9)p[x][y+1]++;
						p[x][y]++;
						break;
				}
			}

			int count = 0, max = 0;
			for(int i = 0; i < 10; i++){
				for(int j = 0; j < 10; j++){
					if(p[i][j] == 0)count++;
					max = Math.max(max, p[i][j]);
				}
			}
			System.out.printf("%d\n", count);
			System.out.printf("%d\n", max);
	}
}

Measured memory_bytes: 26228
W, H, N = map(int, input().split())
b = [0, 0, W, 0, H]
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        b[a] = max(b[a], x)
    elif a == 2:
        b[a] = min(b[a], x)
    elif a == 3:
        b[a] = max(b[a], y)
    else:
        b[a] = min(b[a], y)
# print('b', b)
_W = b[2] - b[1]
_H = b[4] - b[3]
# print('_W, _H', _W, _H)
if _W < 0 or _H < 0:
    print(0)
else:
    print(_W * _H)


Measured memory_bytes: 3064
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <algorithm>

using namespace std;

int n;
int a[100];
long long s;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort (a+1, a+n+1);
    a[n]/=2;
    for (int i = 1; i <= n; i++) s+=a[i];
    cout << s;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using vs = vector<string>;
const int MOD = 1000000007;

int main(){
    string s;
    cin>>s;
    int n = s.size();
    string t="keyence";
    for(int i=0; i<=n; i++){
        for(int j=i; j<=n; j++){
            string a = s.substr(0,i);
            if(j<n){
                string b = s.substr(j,n-j);
                a = a+b;
            }
            if(a==t){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    
    cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(void)
{
   int n, x=0, i=10;

   scanf("%d",&n);

   while(i<n){
      x+=9*i/10;
      i=i*100;
   }

   if((n>=i/10)&&(n!=i))
      x+=n-(i/10)+1;
   else if(n>=i/10)
      x+=n-(i/10);
   printf("%d\n",x);
   return 0;
}

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

const int N = 3005;

char s[N], t[N];
string subseq;

int dp[N][N];

void trace(int i, int j) {
  if (i == 0 || j == 0)
    return;
  if (s[i] == t[j]) {
    subseq.push_back(s[i]);
    trace(i-1, j-1);
  } else if (dp[i][j-1] > dp[i-1][j]) {
    trace(i, j-1);
  } else {
    trace(i-1, j);
  }
}

int main () {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  scanf("%s", s + 1);
  int szs = strlen(s + 1);
  scanf("%s", t + 1);
  int szt = strlen(t + 1);
  for (int i = 1; i <= szs; i++) {
    for (int j = 1; j <= szt; j++) {
      if (s[i] == t[j]) {
      	dp[i][j] = 1 + dp[i-1][j-1];
    	} else {
    	  dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    	}
    }
  }
  trace(szs, szt);
  reverse(subseq.begin(), subseq.end());
  cout << subseq << '\n';
  return 0;
}

Measured memory_bytes: 35456
import sys
from itertools import combinations, permutations

def solve():
    input = sys.stdin.readline
    T1, T2 = map(int, input().split())
    A1, A2 = map(int, input().split())
    B1, B2 = map(int, input().split())
    Atotal = A1 * T1 + A2 * T2
    Btotal = B1 * T1 + B2 * T2

    if Atotal == Btotal: print("infinity")
    else:
        if A1 >= B1 and A2 >= B2: print(0)
        elif A1 <= B1 and A2 <= B2: print(0)
        else:
            if Atotal > Btotal:
                if A1 > B1: print(0) #Aが先行逃げ切りでBは追い付けない
                else: #Bが先行するがAが抜き返す
                    max_roop = (B1 - A1) * T1 // (Atotal - Btotal) 
                    cross = (1 if (B1 - A1) * T1 % (Atotal - Btotal) == 0 else 2)
                    count = 1
                    if max_roop > 0: 
                        count += 2 * (max_roop - 1) + cross
                    print(count)
            else:
                if B1 > A1: print(0) #Bの先行逃げ切りでAは追い付けない
                else: #Aが先行するがBが抜き返す
                    max_roop = (A1 - B1) * T1 // (Btotal - Atotal)
                    cross = (1 if (A1 - B1) * T1 % (Btotal - Atotal) == 0 else 2)
                    count = 1
                    if max_roop > 0:
                        count += 2 * (max_roop - 1) + cross
                    print(count)

    return 0

if __name__ == "__main__":
    solve()

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

int main(void){
    int i, j;
    char s[201];

    scanf("%s", s);
    i = strlen(s) - 1;
    while(1){
        if(i % 2 == 0){
            j = i / 2;
            for(int k = 0; k < j; k++){
                if(s[k] != s[k + j]) break;
                if(k == j - 1){
                    printf("%d", i);
                    return 0;
                }
            }
        }
        i--;
    }

    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    string s;
    cin >> s;
    ll num[3] = {};

    for(ll i=0;i<s.length();i++){
        num[s[i] - 'a']++;
    }
    ll maxv = max(num[0], max(num[1], num[2]));
    ll minv = min(num[0], min(num[1], num[2]));
    if(maxv - minv <= 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  rep(i, N) cin >> H[i];
  int ans = 0;
  rep(i, N) {
    if (H[i] >= K) ans++;
  }
  cout << ans << '\n';  
  
  return 0;
}

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

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] Cookie = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine($"{Cookie[1] + Math.Min(Cookie[0]+Cookie[1]+1,Cookie[2])}");
        }

    }
}

Measured memory_bytes: 13396
#include <iostream>

using namespace std;

#define MAX_N 100000

// 入力
int N;
int A[MAX_N + 1];

int cnt[MAX_N];
long long kind = 1;

int main(void) {
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }

    for (int i = 1; i <= N; ++i) {
        cnt[A[i]]++;
    }

    bool exist = true;
    if (N % 2 == 0) {
        for (int j = 1; j < N; ++j) {
            if (j % 2 == 1) {
                kind = kind * 2 % 1000000007;
                if (cnt[j] != 2) {
                    exist = false;
                }
            }
        }
    } else {
        if (cnt[0] != 1) exist = false;
        for (int j = 2; j < N; ++j) {
            if (j % 2 == 0) {
                kind = kind * 2 % 1000000007;
                if (cnt[j] != 2) {
                    exist = false;
                }
            }
        }
    }

    if (exist) {
        cout << kind << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

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

vector<int>E[1010];
int n, m, b[200020][2];
bool vis[1010], f[200020][2];
int q[1010], h, t, l[1010], r[1010];
int st[1010], tp;

void dfs1(int v, int a[], int w)
{
	vis[v] = 1, a[v] = w;
	for (auto u : E[v])if (!vis[u])dfs1(u, a, w);
}
void work(int v)
{
	tp = 0;
	for (auto u : E[v])st[++tp] = u;
	memset(vis + 1, 0, n); vis[v] = 1;
	for (int i = 1; i <= tp; ++i)if (!vis[st[i]])dfs1(st[i], l, i);
	memset(vis + 1, 0, n); vis[v] = 1;
	for (int i = tp; i; --i)if (!vis[st[i]])dfs1(st[i], r, i);
	for (int i = 1; i <= m; ++i)if (b[i][0] == v)f[i][0] = l[b[i][1]] != r[b[i][1]];
}
void dfs(int v)
{
	vis[v] = 1;
	for (auto u : E[v])if (!vis[u])dfs(u);
}

int main()
{
	scanf("%d %d", &n, &m);
	int x, y;
	for (int i = 1; i <= m; ++i)scanf("%d %d", &x, &y), E[x].emplace_back(y), b[i][0] = x, b[i][1] = y;
	for (int i = 1; i <= n; ++i)
	{
		memset(vis + 1, 0, n);
		dfs(i);
		for (int j = 1; j <= m; ++j)if (b[j][1] == i)f[j][1] = vis[b[j][0]];
	}
	for (int i = 1; i <= n; ++i)work(i);
	for (int i = 1; i <= m; ++i)
		if (f[i][0] != f[i][1])printf("diff\n");
		else printf("same\n");
	return 0;
}

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


void solve(long long N, long long D, std::vector<long long> X, std::vector<long long> Y){
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (X[i] * X[i] + Y[i] * Y[i] <= D * D) {
            ans++;
        }
    }
    cout << ans << endl;
}

// 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(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
    }
    solve(N, D, std::move(X), std::move(Y));
    return 0;
}


Measured memory_bytes: 6444
Group = [None] * 100001
Edge  = [None] * 100001

def DFS(item, group):
    S = []
    S.append(item)
    Group[item] = group
    while (len(S) != 0):
        S_top = S.pop()
        for link in Edge[S_top]:
            if Group[link] == 0:
                Group[link] = group
                S.append(link)

n, m = map(int, raw_input().split())
for i in xrange(n):
    Edge[i] = []
    Group[i] = 0

for i in xrange(m):
    s, t = map(int, raw_input().split())
    Edge[s].append(t)
    Edge[t].append(s)

group = 1
for i in xrange(n):
    if Group[i] == 0:
        DFS(i, group)
        group = group + 1

q = input()
for _ in xrange(q):
    s, t = map(int, raw_input().split())
    if Group[s] == Group[t]:
        print 'yes'
    else:
        print 'no'
 

Measured memory_bytes: 24496
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
const int INF = 1000000009;

int n;

int main(){
	scanf("%d", &n);
	int f = 0;
	int m = n;
	while(m){
		f += m % 10;
		m /= 10;
	}
	if(n % f == 0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

object Main extends App {

  val sc = new Scanner(System.in);

  val n = sc.nextInt();

  val answer = (1 to n).foldLeft(0L) { (sum, k) =>
    val m = n / k;
    sum + m.toLong * (m + 1) / 2 * k;
  }

  println(answer);
}

Measured memory_bytes: 57248
$<.gets.to_i.times do
  bases = [0, 0, 0]
  out_count = 0
  points = 0
  while out_count < 3
    case $<.gets.chomp
    when "OUT"
      out_count += 1
      puts points if out_count >= 3
    when "HIT"
      bases << 1
      points += bases.shift
    when "HOMERUN"
      points += bases.sum + 1
      bases = [0, 0, 0]
    else
      raise "error"
    end
  end
end


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

int main(void) {
    long n;
    cin >> n;
    bool f = false;
    for(long i=0; i<n; i++) {
        long x;
        cin >> x;
        f |= x&1;
    }
    cout << (f ? "first" : "second") << endl;
}


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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << ':' << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) <<  ':'  << arg1 << '|' ;
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
int main(){
  ll a, b, c; cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, k, a[200005], f[200005], ans, lo, hi, mid;
bool check(long long kl){
	long long sum=0;
	for (int i=0;i<n;i++) sum += max(0LL, a[i]-kl/f[i]); 
	return sum<=k;
}
bool msfa (long long a, long long b){return a<b;}
bool msff (long long a, long long b){return a>b;}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i=0; i<n; i++) cin >> a[i];
	for (int i=0; i<n; i++) cin >> f[i];
	sort (a, a+n, msfa); sort(f, f+n, msff);
	lo=0; hi=1000000000000LL;
	while (lo<hi){
		mid=(lo+hi)>>1;
		if (check(mid)) hi=mid;
		else lo=mid+1;
	}
	cout << hi;
return 0;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			 int d = sc.nextInt();
			 if(d == 0) break;
			 int n = sc.nextInt()-1;
			 int m = sc.nextInt();
			 int[] dd = new int[n];
			 int[] kk = new int[m];
			 int[] kpx = new int[m];
			 for(int i = 0; i < n; i++) {
				 dd[i] = sc.nextInt();
			 }
			 for(int i = 0; i < m; i++) {
				 kk[i] = sc.nextInt();
			 }
			 Arrays.sort(dd);
			 Arrays.sort(kk);
			 Data[] list = new Data[n + m + 1];
			 int dp = 0;
			 int kp = 0;
			 int p =  0;
			 list[p++] = new Data(0,true);
			 while(dp != n || kp != m) {
				 if(dp != n && kp != m) {
					 if(dd[dp] < kk[kp]) {
						 list[p++] = new Data(dd[dp++],true);
					 }
					 else {
						 kpx[kp] = p;
						 list[p++] = new Data(kk[kp++],false);
					 }
				 }
				 else if(kp != m) {
					 kpx[kp] = p;
					 list[p++] = new Data(kk[kp++],false);
				 }
				 else {
					 list[p++] = new Data(dd[dp++],true);
				 }
			 }
			 int sum = 0;
			 for(int i = 0; i < m; i++) {
				 int l = -1;
				 int r = -1;
				 for(int j = kpx[i]-1; j >= 0; j--) {
					if(list[j].isS) {
						l = list[j].p;
						break;
					}
				 }
				 if(l == -1) {
					 l = dd[n-1];
				 }
				 for(int j = kpx[i]+1; j < n + m + 1; j++) {
					 if(list[j].isS) {
						 r = list[j].p;
						 break;
					 }
				 }
				 if(r == -1) {
					 r = d;
				 }
				 int s = list[kpx[i]].p;
				 
				 int min = Math.min(Math.min(Math.abs(s - l), Math.abs(s - l - d)), Math.min(Math.abs(s - r), Math.abs(s - r)));
				 sum += min;
			 }
			 System.out.println(sum);
		}
		
	}
	static class Data {
		int p;
		boolean isS;
		Data(int a, boolean b) {
			p = a;
			isS = b;
		}
	}
	
	
	
}

Measured memory_bytes: 64284
n, m = map(int, input().split())
a = set(map(int, input().split()))
b = set(map(int, input().split()))

a_and_b = list(a & b)
a_or_b = list(a | b)

a_and_b.sort()
a_or_b.sort()

print(len(a_and_b), len(a_or_b))

for p in a_and_b:
    print(p)

for q in a_or_b:
    print(q)



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

int a[100000];

int main()
{
	int N,S,W,Q;
	while(cin >> N >> S >> W >> Q, N||S||W||Q)
	{		
		map<int,int> r;
		int ans,val,base,g=S;

		ans=0; val=0;
		for(int i=0; i<N; i++)
		{
			a[i] = (g/7) % 10;
			if( g%2 == 0 ) { g = (g/2); }
			else           { g = (g/2) ^ W; }

			if(10%Q==0)
			{
				if(a[i])      val++;
				if(a[i]%Q==0) ans+=val;
			}
		}

		if(10%Q==0)
		{
			cout << ans << endl;
			continue;
		}

		val=0; base=1; r[0]=1;
		for(int i=N-1; i>=0; i--)
		{
			val=(a[i]*base+val)%Q;
			base=(base*10)%Q;

			if(a[i])
			{
				ans+=r[val];
			}
			r[val]++;
		}

		cout << ans << endl;	
	}
}

Measured memory_bytes: 4116
#include<stdio.h>
int main(void)
{
	int a,b,box,i,j,cnt,c[5];
	cnt=0;
	scanf("%d %d",&a,&b);
	for(i=a;i<=b;i++){
		box=i;
		j=0;
		while(box>0){
			c[j]=box%10;
			box=box/10;
			j++;
		}
		if(c[0]==c[4] && c[1]==c[3]){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
    ll K, N = 50, a[50];
    cin >> K;
    REP(i, N) a[i] = N - 1 + K / N;
    ll d = K % N;
    REP(i, N) a[i] -= d;
    REP(i, d) a[i] += N + 1;
    PRINT(N);
    REP(i, N) cout << a[i] << " ";
    cout << endl;
    return 0;
}



Measured memory_bytes: 3632
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MOD = 1e9 + 7;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

map<int, int> factor(int x){
    map<int, int> ret;
    int fx = x;
    for(int i=2;i*i<=fx;i++){
        while(x % i == 0){
            x /= i;
            ret[i]++;
        }
    }
    if(x > 1)
        ret[x]++;
    return ret;
}

int power(int n, int p)
{
    if (p == 0)
        return 1;
    long long res = 1;
    long long add = n;
    while (p > 0)
    {
        if (p & 1)
            res = (res * add) % MOD;
        p >>= 1;
        add = add*add%MOD;
    }
    return res;
}

      
int getinv(int n) {
    static int invtable[3000];
    if (invtable[n])
        return invtable[n];
    return invtable[n] = power(n, MOD - 2);
}

ll comb(int n, int r) {
    long long res = 1;
    for (int i = n - r + 1; i <= n; i++)
        res = (res * i) % MOD;
    for (int i = 1; i <= r; i++)
        res = (res * getinv(i)) % MOD;

    return res;
}
      


int main() {
    int n, m;
    cin >> n >> m;
    auto fac = factor(m);

    ll ans = 1;
    for(auto p: fac){
        int jou = p.second;
        ll tomul = comb(n+jou-1, jou);
        ans = (ans * tomul) % MOD;
    }

    cout << ans << endl;;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = {int(input()) for _ in range(m)}

mod = 10**9+7
dp = [0]*(n+1)
dp[0]=1

if not 1 in a:
  dp[1]=1

for i in range(2, n+1):
  if i in a:
    continue
  else:
    dp[i] = dp[i-1]+dp[i-2]

print(dp[n]%mod)


Measured memory_bytes: 470264
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#define ll long long
#define INF 0x3f3f3f3f
#define SIS std::ios::sync_with_stdio(false)
using namespace std;
ll fast_pow(ll a,ll b,ll mod)
{
    ll c=1;
    while(b>=2)
    {
        if(b%2==0)
            a*=a,b/=2;
        else
            c*=a,a*=a,b--,b/=2;
        a%=mod,c%=mod;
    }
    return (a*c)%mod;
}

int main()
{
    ll x;
    while(cin>>x)
    {
        ll a=x/500,ans=a*1000;
        x%=500;
        ans+=(x/5)*5;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# ABC 118, B - food loved by everyone
from collections import Counter

n, m = map(int, input().split(' '))

C_total = Counter()
for i in range(n):
    A = input().split(' ')
    del A[0]
    C = Counter(A)
    C_total += C

count = 0
for val in C_total.values():
    if val == n:
        count += 1
print(count)


Measured memory_bytes: 3316
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll RepeatSquaring(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2);
        return t*t;
    }
    return N * RepeatSquaring(N, P-1);
}

int main() {
    ll N, K;
    cin >> N >> K;
    printf("%lld\n", K  * RepeatSquaring(K-1,N-1));

}

Measured memory_bytes: 256
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const s = tmp.shift();

    const l = s.length % 2 === 0 ? s.length / 2 : (s.length - 1) / 2;
    
    let hugs = 0;
    for (let i = 0; i < l; i++) {
      if(s[i] !== s[s.length - 1 - i]) {
        hugs += 1;
      } 
    }

    return `${hugs}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    ll a[26];
    for (int i = 0; i < 26;i++)
        a[i] = 0;
        for (int i = 0; i < n; i++)
        {
            ll tmp = s[i] - 'a';
            a[tmp]++;
        }
    ll ans = 1;
    for (int i = 0; i < 26;i++){
        ans *= (a[i] + 1);
        ans %= mod;
    }
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=5e3+5;
const ll inf=1e15;

int n,a,b,p[N];
ll f[N][N];

int main() {
	scanf("%d%d%d",&n,&a,&b);
	fo(i,1,n) scanf("%d",&p[i]);
	fo(i,0,n) fo(j,0,n) f[i][j]=inf;f[0][0]=0;
	fo(i,1,n)
		fo(j,0,n)
			if (f[i-1][j]!=inf) 
				if (p[i]>j) {
					f[i][j]=min(f[i][j],f[i-1][j]+a);
					f[i][p[i]]=min(f[i][p[i]],f[i-1][j]);
				} else f[i][j]=min(f[i][j],f[i-1][j]+b);
	ll ans=inf;
	fo(i,0,n) ans=min(ans,f[n][i]);
	printf("%lld\n",ans);
	return 0;
}

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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

template<class T>
struct UnionFind {
    vector<T> par,rank,large;

    void init(T N){
        rank.assign(N,0);
        large.assign(N,1);
        par.resize(N);
        for(T i= 0; i < N; i++){
            par[i]=i;
        }
    }

    T root(T x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(T x, T y) {
        T rx = root(x);
        T ry = root(y);
        if (rx == ry) return;
        if(rank[rx]<rank[ry]) {
            par[rx]=ry;
            large[ry]+=large[rx];
            large[rx]=0;
        }
        else {
            par[ry]=rx;
            large[rx]+=large[ry];
            large[ry]=0;
            if(rank[rx]==rank[ry])rank[x]++;
        }
    }

    bool same(T x, T y) {
        T rx = root(x);
        T ry = root(y);
        return rx == ry;
    }

    T size(int x) {
        return large[root(x)];
    }
};

int main() {
  ll N;
  cin>>N;
  vector<vector<ll>> x(100005),y(100005);
  rep(i,N){
    ll X,Y;
    cin>>X>>Y;
    X--;
    Y--;
    x[X].push_back(Y);
    y[Y].push_back(X);
  }
  UnionFind<ll> tree;
  tree.init(100005);
  rep(i,100005){
    for(auto t:y[i]){
      tree.unite(y[i][0],t);
    }
  }
  map<ll,set<ll>> m;
  rep(i,100005){
    for(auto t:x[i]){
      m[tree.root(i)].insert(t);
    }
  }
  ll ans = 0;
  for(auto t:m){
    ans += tree.size(t.first)*(ll)t.second.size();
  }
  cout<<ans-N<<endl;
}

Measured memory_bytes: 18444
program main
 implicit none
 character*4 s
 read(*,*) s
 if(s(1:1)==s(2:2) .and. s(3:3)==s(4:4) .and. s(2:2)/=s(3:3))then
  write(*,*) 'Yes'
 else if(s(1:1)==s(3:3) .and. s(2:2)==s(4:4) .and. s(2:2)/=s(3:3))then
  write(*,*) 'Yes'
 else if(s(1:1)==s(4:4) .and. s(2:2)==s(3:3) .and. s(2:2)/=s(4:4))then
  write(*,*) 'Yes'
 else
  write(*,*) 'No'
 end if
end program main

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  //ll a;cin>>a;
  //ll a,b;cin>>a>>b;
  ll a,b,c;cin>>a>>b>>c;
  //ll a,b,c,d;cin>>a>>b>>c>>d;
  //string s;cin>>s;
  //cout<<<<endl;
  ans1(c>=a&&c<=b);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int d;
	
	while (scanf("%d %d", &a, &b) != EOF){
		c = a + b;
		d = 1;
		while (c / 10 != 0){
			c /= 10;
			d++;
		}
		printf("%d\n", d);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string T;
    cin >> T;
    int t[n];
    rep(i, 0, n) {
        if (T[i] == 'r') t[i] = 2;
        if (T[i] == 's') t[i] = 0;
        if (T[i] == 'p') t[i] = 1;
    }
    int score[3] = {r, s, p};
    int hand[n] = {};
    int ans = 0;
    rep(i, 0, n) {
        if (i - k >= 0) {
            if (hand[i - k] == t[i]) {
                hand[i] = 3;
            } else {
                hand[i] = t[i];
                ans += score[t[i]];
            }
        } else {
            hand[i] = t[i];
            ans += score[t[i]];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
n = int(input())
a_l = list(map(int,input().split()))

a_l.sort(reverse=True)
ans_n = a_l[0]
a_l2 = []
for i, val in enumerate(a_l):
    a_l2.append((abs(val-float(ans_n)/2),i))
a_l2.sort()

if a_l2[0][1] == 0:
    ans_r_index = a_l2[1][1]
else:
    ans_r_index = a_l2[0][1]
ans_r = a_l[ans_r_index]
print(ans_n, ans_r)

Measured memory_bytes: 20064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>

using namespace std;

int main()
{
	char buf[2000];
	int a,b,c;

	while(scanf("%d%d",&a,&b)!=EOF){
		c=1;
		a+=b; while(a/=10) c++;

		cout<<c<<endl;

	}

}

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

double toRadian(int degree)
{
    return (degree / (180 / M_PI));
}

int main()
{
    int a, b, C;
    scanf("%d%d%d", &a, &b, &C);

    double S, L, h;
    S = (double)(a * b * sin(toRadian(C)) / 2);
    double c = sqrt(pow(a, 2) - 2*a*b*cos(toRadian(C)) + pow(b, 2));
    L = (double)(a + b + c);
    h = (double)(2 * S / a);
    printf("%lf\n%lf\n%lf\n", S, L, h);

    return 0;
}

Measured memory_bytes: 684
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int x,y,z,a,t;
  while(cin>>z&&z){
    a=t=pow(z,3);
    for(x=1;x<z;x++){
      for(y=x;y<z;y++){
	int u;
	u=a-x*x*x-y*y*y;
	if(u>0&&t>u)
	  t=u;
	if(u<=0)
	  break;
      }
    }
    cout<<t<<endl;
  }
  return 0;
}

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

int main() {

    int A, B, K;
    cin >> A >>  B >> K;

    int s_i;
    if (A < B) {
        s_i = A;
    } else {
        s_i = B;
    }


    int count = 0;
    for (int i=s_i; i>0; i--) {
        if (A%i == 0 && B%i == 0) {
            count++;
        }
        if (count == K) {
            cout << i  << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        if(a>=k)
            ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3604
n,m = map(int,input().split())
s = [[] for _ in range(m)]
for i in range(m):
    s[i] = list(map(int,input().split()))
p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    ls = [0] * n
    
    for j in range(n):
        if (i >> j) & 1:
            ls[j] = 1
            
    am = [0] * m      
    
    for j in range(m):
        for k in s[j][1:]:
            if ls[k-1] == 1:
                am[j] += 1
    
    t = 0
    for j in range(m):
        if am[j] % 2 == p[j]:
            t += 1
        
    if t == m:
        ans += 1
        
print(ans)

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

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

void main() {
    auto nq = readints;
    int n = nq[0], q = nq[1];

    auto xxs = new int[][](n);
    for (int i = 0; i < q; i++) {
        auto query = readints;
        switch (query[0]) {
        case 0:
            xxs[query[1]] ~= query[2];
            break;
        case 1:
            writeln(xxs[query[1]].map!(to!string).join(" "));
            break;
        case 2:
            xxs[query[1]] = [];
            break;
        default:
            break;
        }
    }
}



Measured memory_bytes: 17376
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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

const int INF = 1e9;
const ll LINF = 1e18;
const ll NMAX = 1e2;
ll fac[NMAX + 1], inv[NMAX + 1], finv[NMAX + 1];

ll mod_pow(ll base, ll index, ll mod) {
    if(index == 0) return 1LL;
    ll res = mod_pow((base * base) % mod, index / 2, mod);
    if(index & 1) (res *= base) %= mod;
    return res;
}

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2;i<NMAX + 1;i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
ll comb(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,p;
    cin>>N>>p;
    vector<ll> A(N);
    cominit();
    int odd=0,even=0;
    REP(i,N){
        cin>>A[i];
        if(A[i]%2) odd++;
        else even++;
    }
    ll ans=0;
    if(p){
        for(int i=0;2*i+1<=odd;i++) ans+=comb(odd,2*i+1);
        ans*=mod_pow(2LL,even,LINF);
    }
    else{
        for(int i=0;2*i<=odd;i++) ans+=comb(odd,2*i);
        ans*=mod_pow(2LL,even,LINF);
    }
    cout<<ans<<endl;
}

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

int main() {
	string s, t;
	cin >> s >> t;
	for (int i = s.size() - t.size(); i >= 0; i--) {
		bool match = true;
		for (int j = 0; j < t.size(); j++) {
			if (s[i + j] != '?' && s[i + j] != t[j]) {
				match = false;
				break;
			}
		}
		if (!match) continue;
		for (int j = 0; j < t.size(); j++) {
			s[i + j] = t[j];
		}
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == '?') s[i] = 'a';
		}
		cout << s << endl;
		return 0;
	}
	cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<vector<int>,int> P;

int n, d, idx;

ll Vtoll(vector<int> V){
  
  ll res=0;
  
  for(int i=0;i<V.size();i++) res=res*10+V[i];
  
  return res;
  
}

map<ll,int> memo[2];

queue<P> q;

void bfs(vector<int> s){
  
  q.push(P(s,0));

  memo[idx][Vtoll(s)]=0;
  
  while(!q.empty()){

    P t=q.front(); q.pop();

    int cost=t.second;
    vector<int> S=t.first;
    
    if(cost==d) continue;
    
    for(int i=0;i<n-1;i++)
      for(int j=i+2;j<=n;j++){
	
	vector<int> nS=S;
	reverse(nS.begin()+i,nS.begin()+j);
	
	if(memo[idx].count(Vtoll(nS))) continue;
	memo[idx][Vtoll(nS)]=cost+1;
	
	q.push(P(nS,cost+1));
      }
    
  }
  
}

int main(){
  
  cin>>n;
  
  vector<int> A;
  
  A.resize(n);
  
  for(int i=0;i<n;i++) cin>>A[i],A[i]--;
  
  d=(n-1)/2;
  
  idx=0;
  
  bfs(A);
  
  d=(n-1)/2;
    
  idx=1;
  
  for(int i=0;i<n;i++) A[i]=i;
  
  bfs(A);

  int ans=n-1;
  
  map<ll,int>::iterator ite=memo[0].begin();

  while(ite!=memo[0].end()){
    
    if(memo[1].count((*ite).first))
      ans=min(ans,(*ite).second+memo[1][(*ite).first]);
    
    ite++;
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}

/*

SAK

*/

Measured memory_bytes: 53292
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
    int i, j, k, l, count;
    int M, N;
    char a, b;
    string tmp_str, ans;
    vector<string> A, B;
    // get input ----------------------
    cin >> N >> M;
    for(i = 0; i < N; i++) {
        cin >> tmp_str;
        A.push_back(tmp_str);
    }
    for(i = 0; i < M; i++) {
        cin >> tmp_str;
        B.push_back(tmp_str);
    }
    // search -------------------------
    ans = "No";
    for(i = 0; i < N; i++) {
        for(j = 0; j < N; j++) {
            a = A[i][j];
            b = B[0][0];

            if(a == b) {
                count = 0;
                for(k = 0; k < M; k++) {
                    for(l = 0; l < M; l++) {
                        if(i+k >= N || j+l >= N) {
                            continue;
                        }

                        a = A[i+k][j+l];
                        b = B[k][l];

                        if(a == b) {
                            count++;
                        }
                    }
                }
                if(count == M*M) {
                    ans = "Yes";
                    break;
                }
            }
        }
    }
    // disp answer --------------------
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 256
s=list(input())
t=list(input())
flag=0
if s==t:
    flag=1
for i in range(len(s)):
    s.insert(0,s[-1])
    s.pop(-1)
    if s==t:
        flag=1
if flag==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll N;
        in >> N;
        vll a(N);
        vll cnt(N);
        int cnt2[3] = {};
        rep(i, N) {
            in >> a[i];
            if (a[i] % 4 == 0) {
                cnt[i] = 2;
                cnt2[2]++;
            }
            else if (a[i] % 2 == 0) {
                cnt[i] = 1;
                cnt2[1]++;
            }
            else {
                cnt[i] = 0;
                cnt2[0]++;
            }
        }
        bool ans = false;
        if (!cnt2[1]) {
            ans = cnt2[2] - cnt2[0] + 1 >= 0;
        }
        else if (cnt2[2] >= cnt2[0]) {
            ans = true;
        }
        else {
            ans = false;
        }
        out << (ans ? "Yes" : "No") << endl;
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


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

#define mod 1000000007
#define maxn 200005

typedef pair<ll, ll> P;

int n;
ll k;
ll a[maxn], sum[maxn];
map<ll, vector<int>> mp;

int main()
{
    //freopen("monotonic.in", "r", stdin);
    //freopen("monotonic.out", "w", stdout);
    cin >> n >> k;
    mp[0].push_back(0);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        a[i] %= k;
        sum[i] = sum[i - 1] + a[i];
        ll now = (sum[i] - i + k * n) % k;
        mp[now].push_back(i);
    }
    ll ans = 0;
    for (auto iter = mp.begin(); iter != mp.end(); iter++)
    {
        vector<int> &v = iter->second;
        for (int j = 0; j < v.size(); j++)
        {
            //printf("%d ", v[j]);
            int kk = lower_bound(v.begin(), v.end(), v[j] + k) - v.begin();
            ans += kk - j - 1;
        }
        //printf("\n");
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  long long x, k, d;
  cin >> x >> k >> d;
  
  x = abs(x);
  if(x / d >= k){
    cout << x - k*d << endl;
    return 0;
  }
  long long ans = x % d;
  k -= x / d;
  k %= 2;
  ans = abs(ans - d * k);
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int n,x,mitad,mcd;
	cin >> n >> x;
	mitad = n/2;
	mcd = __gcd(n, x);
	if (n%2 == 0){
		if (x != mitad){
			cout << 3*(n-mcd)<< endl;
		}
		else{
			cout << 3*x << endl;			
		}
	}
	else{
		cout << 3*(n-mcd) << endl;		
	}	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  long long int ans=0;
  int a;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a;
    a--;
    ans+=a;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
// =====================================================
//   File    :   main.cpp
//   Author  :   eezyl
//   Synopsis:   codeforces/atcoder template
//   Address :
//   Date    :   2020/08/15
// =====================================================

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < int(b); ++i)
typedef long long LL;

const int INF = (1<<31)-1;
const LL LL_INF = (1ll << 63)-1;
const int MOD = 1e9+7;

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

void solve() {
    LL X, K, D;
    cin >> X >> K >> D;
    LL Y = abs(X);
    if (Y / D > K) {
        cout << Y-D*K << endl;
    } else {
        if (Y/D %2 == K%2) {
            cout << Y%D << endl;
        } else {
            cout << abs(Y%D-D) << endl;
        }
    }
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
//#define LOCAL
#ifdef LOCAL
freopen("data.in", "r", stdin);
while (!feof(stdin)) {
#endif // LOCAL

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

#ifdef LOCAL
}
printf("Time used = %.2lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 3616
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;


int main(void){
    int n;
    cin >> n;

    long long T[n], A[n];

    for(int i=0;i<n;i++){
        cin >> T[i] >> A[i];
    }
    long long a=1LL, b = 1LL;
    
    for(int i=0;i<n;i++){
        long long k;
        k = max((a -1)/ T[i] + 1, (b-1)/A[i]+1);
        a = T[i] *k;
        b = A[i] * k;
    }
    cout << a+b << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
    
        
        long long int n,m,o=0,l,d=1,i,j,p=0,k,f;
       double pie=3.141592653589793238;
    long long int MOD=1000000007;
    string s,s1;
    cin>>n>>s;
    s1=s1+s[0];
  for(i=1;i<s.length();i++)
  {
      if(s[i]!=s[i-1])
      s1=s1+s[i];
  }
  cout<<s1.length();
 return 0;
}

Measured memory_bytes: 696
import math
a = list(map(int, input().split(" ")))


min_ = 99999999999999999

for i in range(3):
    for j in range(3):
        sum_ = None
        for k in range(3):
            if i != j != k and i != k:
                sum_ = abs(a[i]-a[j]) + abs(a[j]-a[k])

        if sum_ is not None:
	        min_ = min(min_, sum_)

print(min_)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<time.h> 
#define loop(i,c,n) for(long long i=c;i<n;i++) 
#define iter(v) for(auto x : v)  // to iterate over entire vector/sets/map
using namespace std; 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii; 
typedef set<int> si; 
int max(int a,int b){if(a>b)return a;
return b;} 
//optimised school method
bool isPrime(ll a){ 
if(a<=1)return false ;
if(a<=3)return true ;
if(a%2==0 || a%3==0)return false;
for(ll i=5;i*i<=a;i=i+6){//Instead of checking till n, we can check till √n because a larger factor of n 
//must be a multiple of smaller factor that has been already checked.
if(a%i==0 || a%(i+2)==0)return false;}return true;}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);  
	cout.tie(0);
	//  to read input from local files  
	 #ifndef ONLINE_JUDGE 
	clock_t clocktime; 
	clocktime= clock(); 
	 freopen("input.txt", "r",stdin);
	 freopen("output.txt", "w",stdout);
	#endif
	// to read entire line with spaces 
	// string s;
	// getline(cin,s);
	
	// when amount of data is unknown
	// while(cin>>x){}    
	
 
char c ;
cin>>c ; 
if((c>='A')&&(c<= 'Z'))cout<<'A'; 
else if((c>= 'a')&& (c<='z'))cout<<'a';
	
	#ifndef ONLINE_JUDGE
	clocktime = clock()-clocktime; 
	double runtime  = (((double)clocktime)/CLOCKS_PER_SEC); 
	cout<<"\n--------\nTimeUsed -- "<<runtime<<"s"; 
	#endif
	return 0;
}

Measured memory_bytes: 3648