akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int freq1[100001], freq2[100001];
inline int max (int a, int b) {return a > b ? a : b;}
int main () {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n,maxfreq1=0, maxfreq12= 0, maxfreq2=0, maxfreq22=0,a, what1, what2;
  cin >> n;
  for (int x = 0; x < n; x++) {
    cin >> a;
    if (x&1) {
      if (++freq1[a] > maxfreq1) {
        if (what1 != a) maxfreq12 = maxfreq1;
        maxfreq1 = freq1[a];
        what1 = a;
      }
      else maxfreq12 = max(maxfreq12,freq1[a]);
    }
    else {
      if (++freq2[a] >= maxfreq2) {
        if (what2 != a) maxfreq22 = maxfreq2;
        maxfreq2 = freq2[a];
        what2 = a;
      }
      else maxfreq22 = max(maxfreq22,freq2[a]);
    }
  }
  n>>=1;
  cout << (what1 == what2 ? min((n-maxfreq1) + (n-maxfreq22),(n-maxfreq12) + (n-maxfreq2)) : ((n-maxfreq1) + (n-maxfreq2))) << '\n';
  return 0;
}


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

vector<pair<long long,long long>> pf(long long N){ //素因数分解
    vector<pair<long long,long long>> v;
    for(long long i = 2; i*i <= N; i++){
        if(N%i != 0) continue;
        long long counter = 0;
        while(N%i == 0){
            counter ++;
            N /= i;
        }
        v.push_back(make_pair(i,counter));
    }
    if(N!= 1) v.push_back(make_pair(N,1));
    return v;
}

int main(){
    long long N, M;
    cin >> N >> M;
    long long g = __gcd(N,M);
    vector<pair<long long,long long>> v = pf(g);
    cout << v.size() + 1 << endl;
}

Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>
// ↓これいる？
#include <boost/graph/strong_components.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;

using ll = long long;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto&& i : v) cin >> i; }

//#include "atcoder.hpp"

int main() {
    int N;
    
    cin >> N;
  vector<vector<int>> ya(N, vector<int>(N, -1));
  
    REP(i,N) {
      int A;
      
      cin>>A;
      
      REP(j, A) {
        int x, y;
        
        cin >> x >> y;
        
        ya[i][x-1] = y;
      }
    }
  
    int r = 0;
    REP(i, 1 << N) {
      int num = 0;
      REP(j, N) {
        int use = (i >> j) & 1;
        
        if (use) {
          num++;
          REP(k, N) {
        int use = (i >> k) & 1;

            if ( (ya[j][k] == 1 && !use) || (ya[j][k] == 0 && use)) {
              goto DOUBT;
            }


          }
        }
      }
        r = max(r, num);
      DOUBT: (void)0;
      
    }
    
    cout << r << endl;
    
    return 0;
}







Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=b && b<=c){
  printf("%d %d %d\n",a,b,c);
	}else if(a<=c && c<~b){
  printf("%d %d %d\n",a,c,b);
	}else if(b<=a && a<=c){
  printf("%d %d %d\n",b,a,c);
	}else if(b<=c && c<=a){
  printf("%d %d %d\n",b,c,a);
	}else if(c<=a && a<=b){
  printf("%d %d %d\n",c,a,b);
        }else if(c<=b && b<=a){
  printf("%d %d %d\n",c,b,a);
	}

	return 0;
}


Measured memory_bytes: 2108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            List<int> items = new List<int>();
            for (int i = 0 ; i < n ; i++)
            {
                items.Add(ReadInt());
            }

            int sum = items.OrderByDescending(x => x).Skip(1).Take(items.Count -1).Sum();
            sum += items.Max() / 2;

            Console.WriteLine(sum.ToString());
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}


Measured memory_bytes: 13396
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);
		        double cm = sc.nextDouble();

		        double a =0;
		        double b = 0;
		        double c =0;
		        double Volume  = 0;
		        a = cm/3;
		        b = cm/3;
		        c = cm/3;
		        /*while(a != b && b != c && c != (cm/3)) {

		        }*/
		        if(a ==b &&  b == c) {
		        	Volume = a*b*c;
		        }
		        BigDecimal volume = new BigDecimal(String.valueOf(Volume));
		        BigDecimal anser = volume.setScale(12, RoundingMode.DOWN);
		        System.out.println(anser);		        }

	}




Measured memory_bytes: 22868
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    if(a==b){
        if(a!=c){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
      if(a==c or b==c){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;
 
void solve()
  {
   int n,m;
   cin>>n>>m;
   int sum = 0;
   loop(i,0,m)
    {
      int x;
      cin>>x;
      sum += x;
    } 
   if(sum>n)
     cout<<-1;
   else
     cout<<n-sum;
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

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

int main()
{
	int n;
	while(cin >> n, n)
	{
		int pm,pe,pj;
		while(n--)
		{
			cin >> pm >> pe >> pj;
			
			if(pm==100 || pe==100 || pj==100)
			{
				cout << 'A' << endl; continue;
			}

			if((pm+pe)/2 >= 90)
			{
				cout << 'A' << endl; continue;
			}

			if((pm+pe+pj)/3 >= 80)
			{
				cout << 'A' << endl; continue;
			}

			if((pm+pe+pj)/3 >= 70)
			{
				cout << 'B' << endl; continue;
			}

			if((pm+pe+pj)/3 >= 50 && (pm>=80 || pe>=80))
			{
				cout << 'B' << endl; continue;
			}

			cout << 'C' << endl;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <functional>
#include <cmath>
#include <numeric>

using namespace std;

struct mo {
    int n, q, width;
    vector<int> ql, qr, qi;
    int ptr = 0, nl = 0, nr = 0;

    mo(int n, int q) : n(n), q(q), width(n / sqrt(q)), ql(q), qr(q), qi(q) {}

    // [l, r)
    inline void insert(int l, int r) { ql[ptr] = l; qr[ptr] = r; ptr++; }

    void build() {
        ptr = 0;
        iota(qi.begin(), qi.end(), 0);
        sort(qi.begin(), qi.end(), [&](int i, int j) {
            if (ql[i] / width != ql[j] / width) return ql[i] < ql[j];
            else {
                if ((ql[i] / width) % 2 == 0) return qr[i] < qr[j];
                else return qr[i] > qr[j];
            }
        });
    }

    inline int process() {
        int i = qi[ptr++];
        while (ql[i] < nl) add(--nl);
        while (nr < qr[i]) add(nr++);
        while (nl < ql[i]) del(nl++);
        while (qr[i] < nr) del(--nr);
        return i;
    }

    inline void add(int i);
    inline void del(int i);
};

vector<int> a, cnt;
int sum = 0;

inline void mo::add(int i) { if (cnt[a[i]]++ == 0) sum++; }
inline void mo::del(int i) { if (--cnt[a[i]] == 0) --sum; }

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

    int n, q;
    cin >> n >> q;
    a.resize(n);
    for (int i = 0; i < n; ++i) cin >> a[i], a[i]--;

    mo query(n, q);

    for (int i = 0; i < q; ++i) {
        int ql, qr;
        cin >> ql >> qr;
        ql--;
        query.insert(ql, qr);
    }
    query.build();

    cnt.resize(n);
    vector<int> ans(q);
    for (int i = 0; i < q; ++i) {
        int idx = query.process();
        ans[idx] = sum;
    }

    for (int i = 0; i < q; ++i) cout << ans[i] << '\n';
}


Measured memory_bytes: 15476
n,m = map(int,input().split())
wa = [0 for _ in range(n)]
ac = [0 for _ in range(n)]
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        ac[p-1] = 1
    else:
        if ac[p-1]==1:continue
        wa[p-1] += 1

ans1 = sum(ac)
ans2 = 0
for i in range(n):
    if ac[i] == 1:
        ans2 += wa[i]

print(ans1,ans2)

Measured memory_bytes: 47280
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int N;
	scanf("%d", &N);
	int *A = (int*)(malloc(sizeof(int)*N));
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	qsort(A, N,sizeof(int) ,cmp);
	int ans;
	ans = A[N - 1] - A[0];
	printf("%d\n", ans);



#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
vll dp;
vector<vll> S;
lli dfs(lli index){
	if(dp[index] != 0)
		return dp[index];
	lli ans = 0;
	loop(i, 0, S[index].size()){
		ans = max(ans, dfs(S[index][i])+1);
	}
	dp[index] = ans;
	return ans;
}
lli solve(){
	lli n, m;
	cin>>n>>m;
	dp.clear();
	dp.resize(n+1, 0);
	S.clear();
	S.resize(n+1);
	loop(i, 0, m){
		lli t1, t2;
		cin>>t1>>t2;
		S[t1].pb(t2);
	}
	loop(i, 1, n+1){
		if(dp[i] == 0)
			dfs(i);
	}
	cout<<*max_element(dp.begin(), dp.end())<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int *x, *idx;
  int pc = 0;
  int nc = 0;
  int ans = 0;

  cin >> N;
  x = new int[N];
  idx = new int[N];
  
  for(int i=0; i<N; i++) {
    cin >> x[i];
    idx[i] = i;
    if (x[i] > 0) {
      pc++;
    } else {
      nc++;
    }
  }
  if (pc == 0) { 
    pc++; nc--;
  } else if (nc == 0) {
    nc++; pc--;
  }
  
  sort(idx, idx+N, [&x](int i1, int i2) {
        return x[i1] < x[i2];
    });
 
  for(int i=0; i < nc; i++) {
    ans -= x[idx[i]];
  }
  for(int i = nc; i<N; i++) {
    ans += x[idx[i]];
  }
  cout << ans << endl;
  
  int l = 0;
  int m = N-1;
  int tmp_psub = x[idx[l]]; l++;
  for (int i=0; i<pc-1; i++) {
    cout << tmp_psub << " " << x[idx[m]] << endl;
    tmp_psub -= x[idx[m]];
    m--;
  }
  int tmp_nsub = x[idx[m]]; m--;
  for (int i=0; i<nc-1; i++) {
    cout << tmp_nsub << " " << x[idx[l]] << endl;
    tmp_nsub -= x[idx[l]];
    l++;
  }
  cout << tmp_nsub << " " << tmp_psub << endl;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int seki(int a){

    int ans = 0;
    ans = a% 10;
    a/=10;
    ans *= a%10;


    return ans;

}

int main(void){

    int M,D; cin>>M>>D;
    int cnt=0;

    for (int month = 1; month <= M; ++month) {
        for (int day = 1; day <= D; ++day) {
            if(day % 10 < 2 || day%100<20) continue;
            if(month == seki(day)) {
                cnt++;
            }
        }
    }

    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    string a;
    cin >> a;
    if (a[0] == '9' || a[1] == '9') {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

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

    sort(a.begin(),a.end(),greater<ll>());

    ll A=0,B=0;
    for(ll i=0;i<N;i++){
        if(i%2 == 0){
            A += a[i];
        }else{
            B += a[i];
        }
    }
    ll result = A-B;
    cout << result << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
  
int main(void){
   int a,b,c,i;
   scanf("%d%d%d",&a,&b,&c);
     if(a>b){
       i=a; a=b; b=i;
     }
     if(b>c){
       i=b; b=c; c=i;
     }
     if(a>b){
       i=a; a=b; b=i;
     }
  printf("%d %d %d\n",a,b,c);
  return 0;
}


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

int main () {
  string a, b, ans;
  cin >> a >> b;
  
  if (a.size() > b.size()) {
    ans = "GREATER";
  }
  else if (a.size() < b.size()) {
    ans = "LESS";
  }
  else {
    ans = "EQUAL";
    for (int i = 0; i < a.size(); i++) {
      if (a[i] > b[i]) {
        ans = "GREATER";
        break;
      }
      if (a[i] < b[i]) {
        ans = "LESS";
        break;
      }
    }
  }
  cout << ans << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,a[100000],memo[3],ans=1;

signed main() {
    rep(i,3) memo[i] = -1;
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n) {
        int cnt=0;
        rep(j,3) if (memo[j]+1 == a[i]) cnt++;
        ans = (ans*cnt)%MOD;
        rep(j,3) if (memo[j]+1 == a[i]) {
            memo[j]++;
            break;
        }
    }
    cout << ans << endl;
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int k, m1, m2, h1, h2;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int diff = h2-h1, mins = m2-m1;
    if (diff < 0) diff += 24;
    if (m2 < m1) mins += 60, diff--;
    cout << (diff*60+mins) - k;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    
    return 0;
}

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

int main()
{
	vector<char> str;
	char c;
	
	while(cin >> c)
	{
		str.push_back(c);
	}

	for(size_t i=0; i<str.size(); ++i)
	{
		cout << str[str.size()-i-1];
	}
	cout << '\n';
}

Measured memory_bytes: 0
program main
	integer N, counter, i, j
	integer(8), allocatable :: a(:)
	read(*, *) N
	allocate(a(1: N))
	read(*, *) a(1: N)
	counter = 0
	do i = 1, N
		do
			if(mod(a(i), 2) == 0) then
				counter = counter + 1
				a(i) = a(i) / 2
			else
				exit
			end if
		end do
	end do
	write(*, *) counter
end program main

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include<iomanip>
#include<limits>
#include <utility>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e18
 
int main()
{
	

	int A,P;
	cin>>A>>P;

	P += A*3;

	cout << P/2 << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, M = map(int, input().split())
s = set()
for n in range(N):
    items = list(map(int, input().split()))
    K = items[0]
    As = items[1:]
    if n == 0:
        s = set(As)
    else:
        s &= set(As)
print(len(s))


Measured memory_bytes: 5716
#include <iostream>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
const int maxn=1e5+10;
int h[maxn],vis[maxn];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    For(i,1,n)cin>>h[i];
    int ans=n;
    For(i,1,m)
    {
        int a,b;
        cin>>a>>b;
        if(h[a]==h[b])
        {
            if(!vis[a])ans--,vis[a]=1;
            if(!vis[b])ans--,vis[b]=1;
            continue;
        }
        if(h[a]>h[b])a=b;
        if(!vis[a])
        {
            vis[a]=1;
            ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

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

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll A,B,C,D;
    cin>>D>>C>>B>>A;
    ll n;
    cin>>n;
    n *= 4;
    ll a = n/8;
    ll b = n%8>=4;
    ll c = (n%8-b*4)>=2;
    ll d = (n%8-b*4-c*2);

    chmin(C,2*D);
    chmin(B,2*C);
    chmin(A,2*B);

    ll ans=a*A+b*B+c*C+d*D;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
//テスト
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;


int main(){
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(d,vector<int>(26));
    rep(i,d){
        rep(j,26){
            cin >> s[i][j];
        }
    }
    ll sum=0;
    vector<int> last(26);
    //答え入れる配列
    vector<int> ans(d);
    int tm = 1+rand()%26;
    sum = s[0][tm-1];
    ans[0] = tm;
    last[tm]=1;
    //減少

    for(int i=1;i<d;i++){
        ll nax=-INF;
        ll nax_i;
        rep(j,26){
            ll now_sum=0;
            now_sum+=s[i][j];
            ll minus=0;
            rep(k,26){
                if(k!=j)
                    minus+=c[k]*(i+1-last[k]);
            }
            now_sum-=minus;
            if(nax<now_sum){
                nax_i = j;
                nax = now_sum;
            }
        }
        ans[i] = nax_i+1;
        last[nax_i] = i+1;
    }  
    rep(i,d){
        cout << ans[i] << endl;
    }
	return 0;   
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if(0 <= x-r && 0 <= y-r && w >= x+r && h >= y+r){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    
}


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

int main() {
  int N;
  cin >> N;
  N %= 10;
  if (N == 3) cout << "bon" << endl;
  else if (N == 0 || N == 1 || N == 6 || N == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3636
import numpy as np
N, K = map(int, input().split())
H=np.array(list(map(int, input().split())) + [0] * K, dtype=np.int64)

dp=np.full(N+K, 1e+14, dtype=np.int64)
dp[0]=0
for i in range(1, N):
  dp[i:i + K]=np.minimum(dp[i:i + K], np.abs(H[i:i + K]-H[i-1])+dp[i-1])

print(dp[N - 1]) 

Measured memory_bytes: 38712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

template <class T> struct Dinic{
    const T inf;
    struct edge{
        int cd;
        T c;
        size_t rv;
        bool f;
    };
    vector<vector<edge>> v;
    vector<int> m,it;
    Dinic(int n):inf(numeric_limits<T>::max()),v(n){}
    void ad(int dm,int cd,T c){
        v[dm].emplace_back((edge){cd,c,v[cd].size(),0});
        v[cd].emplace_back((edge){dm,0,v[dm].size()-1,1});
    }
    bool bfs(int s,int t){
        m.assign(v.size(),-1);
        queue<int> q;
        m[s]=0;
        q.push(s);
        while(!q.empty()&&m[t]==-1){
            int p=q.front();q.pop();
            for(auto &e:v[p]){
                if(e.c>0&&m[e.cd]==-1){
                    m[e.cd]=m[p]+1;
                    q.push(e.cd);
                }
            }
        }
        return m[t]!=-1;
    }
    T dfs(int i,int t,T f){
        if(i==t) return f;
        for(int j=it[i];j<v[i].size();++j){
            edge &e=v[i][j];
            if(e.c>0&&m[i]<m[e.cd]){
                T d=dfs(e.cd,t,min(f,e.c));
                if(d){
                    e.c-=d;
                    v[e.cd][e.rv].c+=d;
                    return d;
                }
            }
        }
        return 0;
    }
    T mf(int s,int t){
        T fl=0;
        while(bfs(s,t)){
            it.assign(v.size(),0);
            T f=0;
            while((f=dfs(s,t,inf))>0) fl+=f;
        }
        return fl;
    }
};

template <class T> struct BM{
    int n,m;
    Dinic<T> d;
    BM(int n_,int m_):n(n_),m(m_),d(n_+m_+2){
        fr(i,n) d.ad(n+m,i,1);
        fr(i,m) d.ad(n+i,n+m+1,1);
    }
    void ad(int dm,int cd){d.ad(dm,cd+n,1);}
    T mm(){return d.mf(n+m,n+m+1);}
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x,y,e,a,b;
    cin>>x>>y>>e;
    BM<int> bm(x,y);
    fr(i,e){
        cin>>a>>b;
        bm.ad(a,b);
    }
    cout<<bm.mm()<<endl;
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var h, n int
	fmt.Fscan(r, &h)
	fmt.Fscan(r, &n)

	as := make([]int, n)
	bs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &as[i])
		fmt.Fscan(r, &bs[i])
	}

	// モンスターの体力iを減らすための最小の体力値
	dp := make([]int, h+1)
	for i := 0; i < h+1; i++ {
		dp[i] = math.MaxInt64
	}
	// 0減らすためには体力の消耗は不要
	dp[0] = 0

	// すべての技を確認
	for i := 0; i < n; i++ {
		//
		for j := 0; j <= h; j++ {
			if dp[j] != math.MaxInt64 {
				// 現在減らした体力 + 技で減らせる体力（モンスターの体力以下の範囲）
				nj := min(j+as[i], h)
				// 消耗する体力を考慮しても最小の体力であれば更新
				dp[nj] = min(dp[nj], dp[j]+bs[i])
			}
		}
	}

	fmt.Println(dp[h])

}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 768
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-09-23 05:35:55
*/

#include <iostream>
#include <vector>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

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

    int zero = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 0) zero++;
    }

    if (zero > 0) {
        cout << 0 << endl;
        return 0;
    }

    long ans = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] <= 1000000000000000000/ans) {
            ans *= a[i];
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll ans = 0;
    if (a >= k) {
        ans = k;
    } else if (b >= k - a) {
        ans = a;
    } else {
        ans = a - (k - a - b);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <deque>

using namespace std;

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<string> field(n);
  for (int i = 0; i < n; ++i) {
    cin >> field[i];
  }

  const int inf = 1000 * 1000 * 1000;

  vector<vector<int>> ans(n, vector<int>(m, inf));
  deque<pair<int, int>> d;

  ans[0][0] = (field[0][0] == '#');
  d.push_back({0, 0});

  while (!d.empty()) {
    assert(!d.empty());
    pair<int, int> cur = d.front();
    d.pop_front();

    int r = cur.first;
    int c = cur.second;

    //cerr << "r, c = " << r << " " << c << endl;

    for (int t = 0; t < 2; ++t) {
      int rr = r + dx[t];
      int cc = c + dy[t];
      if (rr >= n || cc >= m) {
        continue;
      }

      int weight = 0;
      if (field[r][c] == '.' && field[rr][cc] == '#') {
        weight = 1;
      }

      if (ans[rr][cc] > ans[r][c] + weight) {
        ans[rr][cc] = ans[r][c] + weight;
        //printf("  Adding %d, %d to %d, %d, weight %d.\n", r, c, rr, cc, weight);
        if (weight == 0) {
          d.push_front({rr, cc});
        } else {
          d.push_back({rr, cc});
        }
      }
    }
  }

  cout << ans[n - 1][m - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
N,M,Q = map(int,input().split())
ABCD = [tuple(map(int,input().split())) for i in range(Q)]
import itertools
ans = 0
for ptn in itertools.combinations_with_replacement(range(1,M+1), N):
    tmp = 0
    for a,b,c,d in ABCD:
        if ptn[b-1] - ptn[a-1] == c:
            tmp += d
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sum=0; cin>>n;
  int ar[n];
	for(int i=0;i<n;i++){
      cin>>ar[i];
      sum+=ar[i];
  }
  int res=0,res2=0;

 	int  avg=ceil((sum*1.0)/n);
   int avg2=floor((sum*1.0)/n);

  // cout<<sum<<endl<<avg<<endl<<avg2;
  for(int i=0;i<n;i++){
    res+=((avg-ar[i])*(avg-ar[i]));
    res2+=((avg2-ar[i])*(avg2-ar[i]));
  }
    cout<<min(res,res2);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c;
    int s=0;
  	int i=0;
    scanf("%d%d%d",&a,&b,&c);
    /*for(;++i<=b;){
        a*i%b-c||s++;
        //printf("%d ",i);
    }*/
  	for(i=b;i;){
        a*i--%b-c||s++;
        //printf("%d ",i);
    }
    printf(s?"YES":"NO");
}

Measured memory_bytes: 1736
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;

int main() {
	int N;
	cin >> N;
	vector<int> d;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		d.push_back(x);
	}
	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());
	cout << d.size() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>

using namespace std;

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

	map<string, int> cnt;

	int N;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;

		cnt[s]++;
	}

	int M;
	cin >> M;

	for (int i = 0; i < M; i++)
	{
		string t;
		cin >> t;

		cnt[t]--;
	}

	int max_value = 0;
	for (auto e : cnt)
	{
		max_value = max(max_value, e.second);
	}

	cout << max_value;

	return 0;
}


Measured memory_bytes: 256
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll x,y;cin>>x>>y;
    ll num=y-2*x;
    if(num<0 or num%2!=0)
    {
        cout<<"No\n";
        return;
    }
    ll c=x-num/2;
    if(c<0)
    {
        cout<<"No\n";
        return;
    }
    cout<<"Yes\n";
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

//    cin.tie(NULL);cout.tie(NULL);
//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  bool flag = false;
  for(int i=0; i<3; i++){
    if(S.at(i) == '7'){
      flag = true;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll K, N;
    cin >> K >> N;
    vector<ll> A(N), diff(N);
    ll sum = 0;
    ll ans = K;
    rep(0, i, N)
    {
        cin >> A.at(i);
        if (i != 0)
        {
            diff.at(i) = A.at(i) - A.at(i - 1);
            sum += diff.at(i);
        }
    }
    diff.at(0) = K - A.at(N - 1) + A.at(0);
    sum += diff.at(0);
    rep(0, i, N)
    {
        ans = min(ans, (sum - diff.at(i)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<cmath>
#include<set>
#include<cstdlib>
#include<functional>
#include<climits>
#include<cctype>
#include<iomanip>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
const int mod = 1e9+7 ;
#define clr(a,x) memset(a,x,sizeof(a))
#define cle(a,n) for(int i=1;i<=n;i++) a.clear();
const double eps = 1e-6;
int main()
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
   ll dp[100005];
   dp[1] = 1;
   for(int i = 2;i<=100000;i++)
   {
     dp[i] = i*dp[i-1]%mod;
   }
   int a;
   while(cin>>a)
   cout<<dp[a]<<endl;
  return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long 
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi <vector<vector<vector<int>>> 
#define vc vector<char> 
#define vvc vector<vector<char>>
#define vvvc vector<vector<vector<char>>> 

using namespace std;

int main() {
	int r,g;
	cin >> r >> g;
	cout << g * 2 - r << endl;

	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  AOJ1167
//
//  Created by aki33524 on 2014/07/09.
//  Copyright (c) 2014年 aki33524. All rights reserved.
//

#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

const int MAX_N = 1000000;
const int MAX_T = 200;

vector<int> tetras;
vector<int> oddtetras;
int dp1[2][MAX_N];
int dp2[2][MAX_N];

void init(){
    memset(dp1, 0x3f, sizeof(dp1));
    memset(dp2, 0x3f, sizeof(dp2));
    
    for(int i=0; i<MAX_T; i++){
        int t = i*(i+1)*(i+2)/6;
        tetras.push_back(t);
        if(t%2)
            oddtetras.push_back(t);
    }
    
    for(int i=0; i<tetras.size(); i++)
        dp1[0][tetras[i]] = 1;
    for(int i=0; i<tetras.size(); i++){
        int t = tetras[i];
        for(int j=0; j<MAX_N; j++){
            if(j < t){
                dp1[(i+1)&1][j] = dp1[i&1][j];
            }else{
                dp1[(i+1)&1][j] = min(dp1[i&1][j], dp1[(i+1)&1][j-t]+1);
            }
        }
    }
    
    for(int i=0; i<oddtetras.size(); i++)
        dp2[0][oddtetras[i]] = 1;
    for(int i=0; i<oddtetras.size(); i++){
        int t = oddtetras[i];
        for(int j=0; j<MAX_N; j++){
            if(j < t){
                dp2[(i+1)&1][j] = dp2[i&1][j];
            }else{
                dp2[(i+1)&1][j] = min(dp2[i&1][j], dp2[(i+1)&1][j-t]+1);
            }
        }
    }
}

int main(int argc, const char * argv[])
{
    init();
    
    int N;
    while(cin>>N, N){
        cout << dp1[tetras.size()&1][N] << " " << dp2[oddtetras.size()&1][N] << endl;;
    }
    
    return 0;
}

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

using namespace std;

int const MAX=1299709;
int prime[MAX+1]={0};//0::prime 1::NOTprime;

void hurui(){
  prime[1]=1;
  for(int i=1;i*i<=MAX;i++){
    for(int j=2;j<=MAX/i;j++){
      if(prime[i]==0)prime[i*j]=1;
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
    
  hurui();
  int n;
  //for(int i=1;i<=30;i++) cout << prime[i] << endl;
  while(cin >> n,n){
    int res=0;
    if(prime[n]==0){
      cout << res << endl;
    }
    else{
      int mae=n,ato=n+1;
      while(prime[mae]==1){
        res++;
        mae--;
      }
      while(prime[ato]==1){
        res++;
        ato++;
      }
      cout << res+1 << endl;
    }
  }
}

Measured memory_bytes: 8112
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"
#define PI 3.141592653589793

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


void print_array(int a[], int N){
    REP(i,N-1){
        printf("%d ",a[i]);
    }
    printf("%d\n",a[N-1]);
}

void insertion_sort(int a[], int N){
    REP(i,N){
        int v = a[i];
        int j = i-1;
        while( j>=0 && a[j] > v){
            a[j+1] = a[j];
            --j;
        }
        a[j+1] = v;
        print_array(a,N);
    }
}

int main(){
    int N; cin>>N;
    int a[N]; CINA(a,N);
    insertion_sort(a,N);
}


Measured memory_bytes: 3212
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;
int main()
{
	int n;
	string s;
	cin >> n >> s;
	int cnt = 1;
	rep(i, n-1){
		if (s[i] != s[i +1]) {
			cnt++;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int main()
{
	scanf("%d",&n);
	vector<int> a(n),b(n),c(n),d(n);
	for(int &x:a)scanf("%d",&x);
	for(int &x:b)scanf("%d",&x);
	if(n&1)
	{
		for(int &x:a)ans^=x;
		for(int &x:b)ans^=x;
	}
	for(int &x:a)x=~x;
	for(int i=0;i<28;i++)
	{
		int p=n,q=n,s=0,t=0,mask=(2<<i)-1;
		for(int x:a)p-=(x>>i)&1;
		for(int x:b)q-=(x>>i)&1;
		for(int x:a)c[(x>>i)&1?p++:s++]=x;
		for(int x:b)d[(x>>i)&1?q++:t++]=x;
		swap(a,c);swap(b,d);
		for(s=t=0;s<n;s++)
		{
			while(t<n&&(a[s]&mask)>=(b[t]&mask))t++;
			if((n-t)&1)ans^=2<<i;
		}
	}
	printf("%d\n",ans);
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end() 

using namespace std;
using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} C(100010);

void solve()
{
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }
  sort(ALL(a));

  mint max_sum = 0;
  mint min_sum = 0;

  // 最大値がa[n - i]になる組み合わせ
  // 最小値がa[i]になる組み合わせ
  
  for(int i = k; i <= n; ++i)
  {
    mint ma = a[i - 1];
    max_sum += ma * C(i - 1, k - 1);
  }
  for(int i = k; i <= n; ++i)
  {
    mint ma = a[n - i];
    min_sum += ma * C(i - 1, k - 1);
  }
  cout << max_sum - min_sum;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}

int main(){
    char str[10];
    scanf("%s",str+1);
    for(int i=1;i<4;i++)
        if(str[i]==str[i+1]){
            puts("Bad");
            return 0;
        }
    puts("Good");
}


Measured memory_bytes: 128
const main = (lines: string) => {
  const data = lines.split("\n");
  const N = parseInt(data[0], 10);
  const p = data[1].split(" ").map(str => parseInt(str, 10));
  let result = 0;

  for (let i = 1; i < N - 1; i++) {
    if (
      (p[i - 1] < p[i] && p[i] < p[i + 1]) ||
      (p[i - 1] > p[i] && p[i] > p[i + 1])
    ) {
      result += 1;
    }
  }

  console.log(result);
};

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


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    bitset<10001> tensuu(1);
    ll N;
    cin >> N;
    for (auto &&i: irange(0LL, N)){
        ll a;
        cin >> a;
        tensuu |= tensuu << a;
    }
    for (auto &&i: irange(0LL, 10001LL) | reversed){
        if (i % 10 != 0 && tensuu[i]){
            cout << i << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 3005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll dp[maxn][maxn][4],a[maxn][maxn],n,m,k,ans;

int main()
{
	n=read(); m=read(); k=read();
	rep(i,1,k)
	{
		ll x=read(),y=read(),z=read();
		a[x][y]=z;
	}
	rep(i,1,n) rep(j,1,m)
	{
		dp[i][j][0]=max(dp[i-1][j][0],max(dp[i-1][j][1],max(dp[i-1][j][3],dp[i-1][j][2])));
		dp[i][j][0]=max(dp[i][j][0],dp[i][j-1][0]);
		per(k,3,1)
		{
			dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+a[i][j]);
			dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
			dp[i][j][k]=max(dp[i][j][k],dp[i][j][k-1]+a[i][j]);
		}
	}
	ans=max(dp[n][m][0],max(dp[n][m][1],max(dp[n][m][3],dp[n][m][2])));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 355356
from collections import deque


def dfs(maze, start):
    move = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    q = deque([(0, start)])
    dist = [[-1] * w for _ in range(h)]

    depth, i, j = -1, -1, -1

    while q:
        depth, (i, j) = q.popleft()
        if dist[i][j] != -1:
            continue
        dist[i][j] = depth
        for di, dj in move:
            ni, nj = i + di, j + dj

            if (not 0 <= ni < h) or (not 0 <= nj < w):
                continue

            if maze[ni][nj] == "#" or dist[ni][nj] != -1:
                continue

            q.append((depth + 1, (ni, nj)))

    return depth, i, j


h, w = list(map(int, input().split()))

maze = []

for _ in range(h):
    maze.append(input())

answer = 0

for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            depth, i, j = dfs(maze, (i, j))
            answer = max(answer, depth)

print(answer)

Measured memory_bytes: 3316