akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};
int main(){
	int n,m;
	cin>>n>>m;
	vs in(n);
	rep(i,n)cin>>in[i];
	rep(i,n)rep(j,m)if(in[i][j]=='.'){
		int co=0;
		rep(k,8){
			int x=i+dx[k];
			int y=j+dy[k];
			if(x<0||y<0||x>=n||y>=m)continue;
			if(in[x][y]=='#')co++;
		}
		in[i][j]=co+'0';
	}
	rep(i,n)cout<<in[i]<<endl;
}









Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(ll N, std::vector<ll> A) {
  map<ll, ll> c;
  ll m1 = 0, m2 = 0;

  rep(i, N) {
    ll v = A.at(i);
    if (c.count(v)) {
      c.at(v)++;
      if (c.at(v) == 2 || c.at(v) == 4) {
        if (v > m1) {
          m2 = m1;
          m1 = v;
        } else if (v > m2) {
          m2 = v;
        }
      }
    } else {
      c[v] = 1;
    }
  }

  cout << m1 * m2 << endl;
}

int main() {
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 7296
#include<iostream>
using namespace std;
int main()
{
      int n,m;

      cin>>n>>m;

      int a[m],sum=0;

      for(int i=0;i<m;i++)
      {

          cin>>a[i];
          sum=sum+a[i];
      }

      if(sum>n)
      {
          cout<<-1;
      }
      else{
        cout<<n-sum;
      }
}


Measured memory_bytes: 3200
from bisect import bisect
from heapq import heappush, heappop
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    cA = ord('A')
    ds = "LURD"
    hi, hm = map(int, readline().split())
    if hi == hm == 0:
        return False
    R, C = map(int, readline().split())
    A = [list(map(lambda x: (ord(x) - cA), readline().strip())) for i in range(R)]
    T = int(readline())
    D = [0]*26
    for i in range(T):
        c, d = readline().split()
        D[ord(c) - cA] = int(d)
    RS = [D[A[0][0]]]
    dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
    x = 0; y = 0
    S = int(readline())
    for i in range(S):
        c, n = readline().split()
        dx, dy = dd[ds.index(c)]
        for j in range(int(n)):
            x += dx; y += dy
            v = D[A[y][x]]
            if v:
                RS.append(v)
    L = len(RS)
    SS = [0]*(L+1)
    for i in range(L):
        SS[i+1] = SS[i] + RS[i]
    def check(h, i):
        idx = bisect(SS, SS[i] + h - 1)
        return h - (SS[idx-1] - SS[i]), idx-1

    P = int(readline())
    PS = [int(readline()) for i in range(P)]

    INF = 10**18
    D = [INF]*(1 << P)
    D[0] = 0
    C = [0]*(L+1)
    U = [0]*(1 << P)

    hi, k = check(hi, 0)
    que = [(0, 0, k, hi)]
    while que:
        df, state, k, h0 = heappop(que)
        if D[state] < df or U[state]:
            continue
        C[k] += 1
        U[state] = 1
        for i in range(P):
            n_state = state | (1 << i)
            if state == n_state:
                continue
            h, k0 = check(min(h0 + PS[i], hm), k)
            n_df = df + max(h0 + PS[i] - hm, 0)
            if n_df < D[n_state]:
                heappush(que, (n_df, n_state, k0, h))
    if C[L]:
        write("YES\n")
    else:
        write("NO\n")
    return True
while solve():
    ...


Measured memory_bytes: 6692
import numpy as np

N, T = (int(i) for i in input().split())

selected_c = []
for i in range(N):
    c, t = (int(i) for i in input().split())
    if(t<=T):
        selected_c.append(c)

selected_c = np.array(selected_c)
if(len(selected_c)==0):
    print("TLE")
else:
    print(np.min(selected_c))

Measured memory_bytes: 12436
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
int mod = 1000000007;

int main()
{
    IOS
    int t = 1;
    //cin >> t;
    while (t--)
    {
        ll N, D;
        cin >> N >> D;
        int res = 0;
        for (int i = 0; i < N; i++)
        {
            ll a, b;
            cin >> a >> b;
            if (a * a + b * b <= D * D)
                res++;
        }
        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 3652
using System;
using static System.Console;

namespace abc178
{
    class Program
    {
        static int keyNum = (int)1e9 + 7;
        static void Main()
        {
            var s = int.Parse(ReadLine());
            WriteLine(Redistribution(s));
        }
        static int Redistribution(int s)
        {
            int[] facts = null;
            int[] revFacts = null;

            var total = 0L;
            for (var len = 1; len * 3 <= s; ++len)
            {
                var rest = s - len * 3;
                GetFactorialsDiv(len + rest - 1, keyNum, out facts, out revFacts);
                total += NCRDiv(len + rest - 1, len - 1, facts, revFacts, keyNum);
            }
            return (int)(total % keyNum);
        }
        // nCr の計算に必要な階乗リストを求める
        static void GetFactorialsDiv(int n, int keyNum, out int[] facts, out int[] revFacts)
        {
            facts = new int[n + 1];
            revFacts = new int[n + 1];

            facts[0] = 1;
            var tmp = 1L;
            for (var i = 1; i <= n; ++i)
            {
                tmp = (tmp * i) % keyNum;
                facts[i] = (int)tmp;
            }
            // n!^-1 = n!^(m-2) (mod m)
            tmp = Exp(facts[n], keyNum - 2, keyNum);
            revFacts[n] = (int)tmp;
            for (var i = n; i > 1; --i)
            {
                tmp = (tmp * i) % keyNum;
                revFacts[i - 1] = (int)tmp;
            }
        }
        // 累乗 mod keyNum
        static long Exp(int n, int k, int keyNum)
        {
            if (k == 0)
            {
                return 1;
            }
            if (k == 1)
            {
                return n;
            }
            var half = Exp(n, k / 2, keyNum);
            var result = (half * half) % keyNum;
            return ((k % 2) == 0) ? result : ((result * n) % keyNum);
        }
        // nCr mod keyNum
        static int NCRDiv(int n, int r, int[] facts, int[] revFacts, int keyNum)
        {
            if (r == 0 || r == n)
            {
                return 1;
            }
            if (r == 1)
            {
                return n;
            }
            var result = 1L;
            result = (result * facts[n]) % keyNum;
            result = (result * revFacts[r]) % keyNum;
            result = (result * revFacts[n - r]) % keyNum;
            return (int)result;
        }
    }
}


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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> vote(N);
	for (int t = 0; t < M; t++) {
		int B;
		cin >> B;
		for (int i = 0; i < N; i++) {
			if (A[i] <= B) {
				vote[i]++;
				break;
			}
		}
	}
	int res = 0, tmp = 0;
	for (int i = 0; i < N; i++) {
		if (vote[i] > tmp) {
			tmp = vote[i];
			res = i + 1;
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;

int main() {
	string S;
	cin >> S;
	vector<string> Sk;

	rep(i, S.size()) {
		string next = S.substr(i, 1);
		ll k = Sk.size();

		if(k==0) {
			Sk.push_back(next);
			continue;
		} else if(k==1) {
			if(Sk[k-1]==next) {
				Sk[k-1] = Sk[k-1] + next;
			} else {
				if(Sk[k-1].size()==1) {
					Sk.push_back(next);
				} else {
					Sk.push_back(Sk[k-1].substr(1,1)+next);
					Sk[k-1] = Sk[k-1].substr(0,1);
				}
			}
			continue;
		}

		if(Sk[k-1].size()>1) {
			if(Sk[k-2]==Sk[k-1].substr(0,1)) {
				Sk.push_back(next);
			} else {
				Sk.push_back(Sk[k-1].substr(1,1) + next);
				Sk[k-1] = Sk[k-1].substr(0,1);	
			}
		} else {
			if(Sk[k-1]==next) {
				Sk[k-1] = Sk[k-1]+next;
			} else {
				Sk.push_back(next);
			}
		}
		
		// rep(x, Sk.size()) {
		// 	cout << Sk[x] << endl;
		// }
		// cout << endl;
	 }

	cout << Sk.size() << endl;

	// rep(i, Sk.size()) {
	// 	cout << Sk[i] << endl;
	// }

	return 0;
}

Measured memory_bytes: 10996
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
ll INF = 1e10;

int main()
{
	int a,b;
	cin >> a >> b;
        cout<<a*b<<" "<<2*(a+b)<<endl;
	return 0;
}



Measured memory_bytes: 3116
#include<stdio.h>
int main()
{
	long long int N,K,count=0,a;
	scanf("%lld %lld",&N,&K);
	if(N==0){
		printf("1");
		return 0;
	}
	else{
	while(1){
			a=N/K;
			N=a;
			count++;
			if(N==0) break;
	}
	}
	printf("%lld",count);
	return 0;
		
}

Measured memory_bytes: 760
using System;
using System.Linq;

namespace C___GeT_AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var Read = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int N = Read[0];
            int Q = Read[1];

            string S = Console.ReadLine();

            //1文字めからi文字めまでの"AC"の登場回数の累積
            int[] Accumulation = new int[N+1];

            Accumulation[1] = 0;

            for(int i = 2 ; i <= N ; i++)
            {
                Accumulation[i] = Accumulation[i-1];
                if(S[i-1]== 'C')
                {
                    if(S[i-2] == 'A')
                    {
                        Accumulation[i] = Accumulation[i-1]+1;
                    }
                }
            }

            for(int i = 0 ; i < Q ; i++)
            {
                Read = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                int L = Read[0];
                int R = Read[1];
                Console.WriteLine(Accumulation[R]-Accumulation[L]);
            }
 
        }
    }
}


Measured memory_bytes: 18492
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

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

    int i = 0;
    int counter = 0;
    while (i < 3) {
        if (s[i] == 'R')
            counter++;
        i++;
    }
    if (counter > 0) {
        if (counter == 3)
            cout << 3;
        else if (counter == 2 && s[1] == 'R')
            cout << 2;
        else
            cout << 1;
    }else
        cout << 0;
    
    return 0;
}

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

 int n;
 int dp[100005];

int solve(int a[])
{
	dp[0] = 0;
  	dp[1] = dp[0]+abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    dp[i] = min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
  } 
  return dp[n-1];
}
  

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

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;


int MOD=1000000007;
int main(void){
	int N,Q,l,r;
	cin >> N >> Q;
	string S;
	cin >> S;
	int cou[S.size()+10]={};
	for(int i=1; i<S.size(); i++){
		cou[i]=cou[i-1];
		if(S[i-1]=='A' && S[i]=='C')
		cou[i]+=1;
	}
	for(int i=0; i<Q; i++){
		int l,r;
	cin >> l >> r;
	if(l == 1)cout << cou[r-1] << endl;
	else cout << cou[r-1]-cou[l-1] << endl;
    }
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>
 
using namespace std;
 
#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair
 
typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;
 
const int N = 2002;
 
int A[N];
 
void check(vi &v, vi &v1, int k) {
  if(v.size() >= k) {
    sort(all(v));
    reverse(all(v));
    while(v.size() >= k) {
      v1.pb(v.back());
      v.pop_back();
    }
  }
  v.clear();
}
 
int main() {
  int n,k,q;
  scanf("%d%d%d",&n,&k,&q);
  rep(i,1,n+1) {
    S(A[i]);
  }
 
  int ans = 1000000009;
  rep(i,1,n+1) {
    vi v, v1;
    rep(j,1,n+1) {
      if(A[j] < A[i]) {
        check(v, v1, k);
      } else {
        v.pb(A[j]);
      }
    }
    check(v, v1, k);
    sort(all(v1));
    if(v1.size() >= q) {
      ans = min(ans, v1[q - 1] - v1[0]);
    }
  }
  P(ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int n,m,s,i;
int taro[1000];
int hana[1000];
int T,H,X;
int anst,ansh;
 
int main(){
  while(1){
    scanf("%d %d",&n,&m);
    if(n==0&&m==0){
      break;
    }
 
    T=0;
    H=0;
    for(i=0;i<1000;i++){
      taro[i]=0;
      hana[i]=0;
    }
    for(i=0;i<n;i++){
      scanf("%d",&s);
      taro[s]=1;
      T+=s;
    }
    for(i=0;i<m;i++){
      scanf("%d",&s);
      hana[s]=1;
      H+=s;
    }
 
    X=(H-T)/2;
    anst=-1;
    ansh=-1;
 
    for(i=0;i<=100;i++){
      if(0<=i+X&&taro[i]==1&&hana[i+X]==1){
        anst=i;
        ansh=i+X;
        break;
      }
    }
     
    if( (H-T)%2!=0 || anst==-1 ){
      printf("-1\n");
    }else{
      printf("%d %d\n",anst,ansh);
    }
 
  }
  return 0;
}

Measured memory_bytes: 616
#include<stdio.h>
int main(void) {

	int i = 0;
	int c_0 = 0;
	int c_1 = 0;
	char s[200000];

	scanf("%s", s);

	while (s[i]) {
		if (s[i] == '0')c_0++;
		if (s[i] == '1')c_1++;
		i++;
	}

	if (c_0 > c_1)printf("%d\n", c_1 * 2);
	else printf("%d\n", c_0 * 2);

	return 0;
}

Measured memory_bytes: 256
s = input()
count1 = 0
count2 = 0
count3 = 0
count4 = 0
if s[0] == 'A'and s[1].islower() == True and s[len(s)-1].islower() == True:
    count1 += 1
for i in range(2, len(s) - 1):
    if (s[i] == 'C'):
        count2 += 1
if count1 != 1 or count2 != 1:
    print('WA')
else:
    print('AC')



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n; cin >> n;
    vector<ll> a(n, 0); // a[i] := A_j = i となる j の数
    rep(i, n) {
        int x; cin >> x;
        a[x-1]++;
    }
    sort(a.begin(), a.end());
    vector<ll> sum(n+1, 0);
    sum[0] = a[0];
    repr(i, 1, n) sum[i] = sum[i-1] + a[i];

    auto check = [&](ll t, auto k) {
        auto i = upper_bound(a.begin(), a.end(), t) - a.begin();
        ll val = sum[i-1] + t*(n-i);
        return val>=k*t;
    };

    repr(k, 1, n+1) {
        ll ok = 0; ll ng = n/k+1;
        while(ng-ok > 1) {
            ll mid = (ok+ng) / 2;
            (check(mid, k)? ok:ng) = mid;
        }
        cout << ok << endl;
    }
    
    return 0;
}




Measured memory_bytes: 5632
// g++ -std=c++11 test.cpp && ./a.out
// g++ -std=c++11 bfs.cpp && cat bfs.txt | ./a.ou

#include <algorithm>
#include <iostream>
#include <queue>
#include <functional>
#include <numeric>

using namespace std;

#define PRINT(A) {for (int i = 0; i < A.size(); i++) { cout << A[i] << " ";} cout << endl;}
#define SUM(A) accumulate(A.begin(), A.end(), 0)
#define MAX(A) *max_element(A.begin(), A.end())
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int main() {
    int X;
    cin >> X;
    if (X >= 30) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  string s;
  cin>>s;
  string S=s.substr(0,3);
  cout<<S;
}


Measured memory_bytes: 3592
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int k = stdIn.nextInt();
		
		int[] a = new int[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		
		System.out.println((n-2)/(k-1)+1);
		
	}

}


Measured memory_bytes: 50616
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int count=0;


void select_sort(int *A,int n,int g){
  int i,j;
  int key;
  for(i=g;i<n;i++){
    j=i;
    key=A[i];
    while(0 <= j-g){
      if(A[j-g] <= key) break;
      A[j]=A[j-g];
      j-=g;
      count+=1;
    }
   A[j]=key;
 }
}
  

int main(){
  int n;
  int i,j;
  int *A;
  int G[20];

  scanf("%d",&n);
  A=malloc(n*sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&A[i]);
 
  int m=0;
  G[0]=0;
  while(1){
    if(n < 3*G[m]+1) break;
    G[m+1]=3*G[m]+1;
    m+=1;
 }
 
 for(i=m;i>0;i--) select_sort(A,n,G[i]);
 
  printf("%d\n",m);
  for(i=m;i>=1;i--) printf("%d ",G[i]);
  printf("\n");
  printf("%d\n",count);

 
  for(i=0;i<n;i++) printf("%d\n",A[i]);
  return 0;
}
 


Measured memory_bytes: 5652
from collections import Counter

nn = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

# 逆元を利用してcomb(nCk)をO(1)計算
# https://qiita.com/ophhdn/items/5622ac22cce8fc9432bf
n = nn + 3
fac = [1] * (n + 1) 
inv = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = (fac[j - 1] * j) % MOD

inv[n] = pow(fac[n], MOD-2, MOD)
for j in range(n - 1, -1, -1):
    inv[j] = (inv[j + 1] * (j + 1)) % MOD

def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return (fac[n] * inv[n - r] * inv[r]) % MOD

duple = Counter(A).most_common()[0][0]

l = A.index(duple)
r = A.index(duple, l+1)

outer = nn - (r - l)

for i in range(1, nn + 2):
  print((comb(nn + 1, i) - comb(outer, i - 1)) % MOD)

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


int n;
std::pair<int, int> a[105], b[105];
bool used[105];
int main()
{
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i].second >> a[i].first;
	for (int i = 0; i < n; ++i)
		std::cin >> b[i].first >> b[i].second;

	std::sort(a, a + n, std::greater<std::pair<int, int>>());
	std::sort(b, b + n);

	for (int pos = 0; pos < n; ++pos)
		for (int i = 0; i < n; ++i)
			if (!used[i] && a[pos].second < b[i].first && a[pos].first < b[i].second) {
				used[i] = true;
				break;
			}

	int ans = 0;
	for (int i = 0; i < n; ++i)
		if (used[i])
			++ans;

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


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <climits>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  vector<int> vec(5, 0);
  int min = 10, minindex = -1;
  for (int i = 0; i < 5; i++  ) {
    cin >> vec[i];
    if (vec[i] % 10 < min && vec[i] % 10 != 0) {
      minindex = i;
      min = vec[i] % 10;
    }
    // cout << min << " " << minindex << " " << (vec[i] % 10) << endl;
  }
  int sum = vec[minindex];
  for (int i = 0; i < 5; i++) {
    if (i == minindex) continue;
    if (vec[i] % 10 == 0) { sum += vec[i]; }
    else {
      sum += ((vec[i] / 10 + 1) * 10);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i, j, H, W;

  while (1) {
    scanf("%d %d", &H, &W);
    if (H == 0 && W == 0)
      break;
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++)
        putchar('#');
      putchar('\n');
    }
    putchar('\n');
  }

  return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  vector<ll> e(n,0);
  vector<ll> w(n,0);
  ll west=0,east=0;
  for(ll i=0;i<n;i++){
    w[i] = west;
    if(s[i] == 'W'){
      west++;
    }
  }
  
  for(ll i=n-1;i>=0;i--){
    e[i] = east;
    if(s[i] == 'E'){
      east++;
    }
  }
  
  ll ans=1e9;
  for(ll i=0;i<n;i++){
    ans = min(ans,w[i]+e[i]);
  }
  
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 8240
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));

  $n = strlen($s);
  $maru = 0;
  for($i=0; $i<$n; $i++){
    if($s[$i] == 0){
      $maru++;
    }
  }

  if($maru > $n / 2){
    echo ($n-$maru)*2;
  }else{
    echo $maru*2;
  }


Measured memory_bytes: 16056
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const x = BigInt(input[0]);

let current = 100n;
let result = 0;
while(current<x){
	current *= 101n;
	current /= 100n;
	result++;
}

console.log(result);


Measured memory_bytes: 29840
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 2500;
const int K = 19;
int n, q;
int mod = 998244353;
int a[N][N], f[N], invf[N], used[N];
vector < pair < int, int > > v;
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int c(int n, int k){
    if (k < 0) return 0;
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    string s1, s2, s3;
    cin >> s1;
    cin >> s2;
    cin >> s3;
    int ans = 0;
    for (int i = 0; i < n; i++){
        set < int > t;
        t.insert(s1[i]);
        t.insert(s2[i]);
        t.insert(s3[i]);
        ans = ans + (int)t.size() - 1;
    }
    cout << ans;
}


Measured memory_bytes: 256
from collections import Counter

N,M = map(int, input().split() )
A   = list(map(int, input().split() ))
B   = [0]*M
C   = [0]*M
Cou = Counter(A)

for i in range(M):
  B[i],C[i]  = map(int, input().split() )
  Cou[C[i]] += B[i]
  
#print(Cou)  
ans=0
cnt=0
S=sorted(Cou,reverse=True)
#print(S)
for num in S:
  kosuu = min(Cou[num],N-cnt)
  cnt += kosuu
  ans += num*kosuu
  
print(ans)

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

int main(){
    int n, m, temp, ans; cin >> n >> m; ans = 0;
    rep(i, m){
        cin >> temp;
        ans += temp;
    }
    if(ans <= n) cout << n - ans <<endl;
    else cout << "-1" << endl;
    return 0;
}

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

int main() {
    int M,D;
    cin >> M >>D;
    int ans=0;
    int m=0;
    int d_1,d_10;
    for(int i=22; i<D+1;i++){
        d_10 = i/10;
        d_1 = i%10;
        if(d_10 > 1 && d_1 > 1){
            m = d_10 * d_1;
            if(m < (M+1) && 1 <= m){
                ans += 1;    
            }
        }
    }
    cout << ans << endl;
}



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

namespace ITP1_11_A
{
    class Dice
    {


        public Dice()
        {
            Top = 0;
            Front = 1;
            Right = 2;
        }

        public void RotateNorth()
        {
            var temp = Top;
            Top = Front;
            Front = Inverse(temp);
        }


        public void RotateSouth()
        {
            var temp = Top;
            Top = Inverse(Front);
            Front = temp;
        }


        public void RotateEast()
        {
            var temp = Top;
            Top = Inverse(Right);
            Right = temp;
        }


        public void RotateWest()
        {
            var temp = Top;
            Top = Right;
            Right = Inverse(temp);
        }


        public bool RotateTo(int top, int front)
        {

            return false;
        }


        public int Top { get; private set; }


        public int Front { get; private set; }


        public int Right { get; private set; }


        public int Inverse(int surface)
        {
            return 5 - surface;
        }
    }


    class Program
    {
        static void Main(string[] args)
        {
            var aliasOfSurface = Console.ReadLine().Split(' ');
            var dice = new Dice();

            foreach (var n in Console.ReadLine())
            {
                switch (n)
                {
                    case 'N': dice.RotateNorth(); break;
                    case 'S': dice.RotateSouth(); break;
                    case 'E': dice.RotateEast(); break;
                    case 'W': dice.RotateWest(); break;
                }
            }

            Console.WriteLine(aliasOfSurface[dice.Top]);
        }
    }
}

Measured memory_bytes: 5276
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN = 200005;

int a[MAXN];

long long res = 0;

int n, m;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		a[i] -= i;
	sort(a + 1, a + n + 1);
	m = (n + 1) >> 1;
	for (int i = 1; i <= n; i++)
		res += abs(a[i] - a[m]);
	cout << res << endl;
	return 0;	
}


Measured memory_bytes: 1024
N,K = map(int,input().split())
#ans[i]=上からi個の和-下からiこの和+1 i個選んだ和の種類
ans = 0
mod = 10**9+7
for i in range(K,N+2):
    if i*2 > N+1:
      #print(i,(N+1-i)*N+1 % mod)
      ans += (N+1-i)*i+1 % mod
    else:
      #print(i,(N-i+1)*i+1 % mod)
      ans += (N-i+1)*i+1 % mod
print(ans%mod)


Measured memory_bytes: 64272
"use strict"

function main(input) {
  input = input.split(/\n/)
  let S = input[0].split("")
  const T = input[1].split("")
  const us = "UNRESTORABLE"
  // if (S.length < T.length) {
  //   console.log(us)
  //   return
  // } else {
  for (let i = S.length - T.length; i >= 0; i--) {
    //
    let x = 0
    for (let j = 0; j < T.length; j++) {
      //Tの区間の中で合致するかどうか
      if (S[i + j] == T[j] || S[i + j] == "?") {
        //この文字は合致、または?だからパス
      } else {
        //合致しない＞この区間は合致しない
        x++
        continue
      }
      //
    }
    //合致しなかったら次のforへ、合致したら次のステップへ
    if (x > 0) continue

    //Tで埋める
    for (let k = 0; k < T.length; k++) {
      S[i + k] = T[k]
    }
    //残りの?をaに変換 <todo> : 正規表現などで
    // S = S.replace(/(.+)/, "a")
    for (let i = 0; i < S.length; i++) {
      S[i] = S[i] == "?" ? "a" : S[i]
    }
    console.log((S = S.join("")))
    return
  }
  // }
  //
  console.log(us)
  //
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> fill(10000+1);


    for(int i = 0; i <= 10000; i++){
        fill[i] = 0;
    }
    for(int i = 0; i < n; i++){
        cin >> v[i];
        fill[v[i]] = 1;
    }

    int count = 0;
    for(int i = 1; i < n; i++){
        if(v[i] == v[i-1]){
            for(int j = 1; j < fill.size(); j++){
                if(fill[j] == 0){
                    v[i] = fill[j];
                    fill[j] = 1;
                    count++;
                    break;
                }
            }
        }
    }
    cout << count << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < 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 k, x;
    cin >> k >> x;
    for (int i = max(-1000000, x - (k - 1)); i <= min(1000000, x + (k - 1)); i++) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <queue>
#include <unordered_map>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>

using namespace std;

bool isSubsequence(string s, string t);

int main() {

    int n = 0;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    int count = 0;
    for (int i = 1; i < n - 1; i++) {
        if ((arr[i] < arr[i - 1] && arr[i] > arr[i + 1]) || (arr[i] < arr[i + 1] && arr[i] > arr[i - 1])) {
            count++;
        }
    }
    cout << count;
    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 mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int a,b;cin>>a>>b;
    for(int i = 1;i < 2000;i++){
        int aa = i*0.08;
        int bb = i*0.10;
        if(aa==a&&bb==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

/**
 * @author Tran Anh Tai
 * @template for CP codes
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        public void solve(InputReader in, PrintWriter out) {
            int x = in.nextInt();
            int lcm = (x * 360) / gcd(x, 360);
            out.println(lcm / x);
        }
        int gcd(int a, int b){
            if (a == 0){
                return b;
            }
            else{
                return gcd(b % a, a);
            }
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}

Measured memory_bytes: 32856
while True:
  n = int(input())
  if n == 0:
    break
  lst = list(map(int, input().split()))
  for i in range(n + 1):
    sample = lst[:i] + lst[i + 1:]
    correct = [sample[0] + (sample[1] - sample[0]) * j for j in range(n)]
    if sample == correct:
      print(lst[i])
      break


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

int main() {
	int n;
	scanf("%d", &n);
	int house[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &house[i]);
	}
	printf("%d", *std::max_element(house, house + n) - *std::min_element(house, house + n));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string str;
    cin >> str;
    long long n;
    n = str.size();
    long long cnt=0;
    long long bcnt=0;
    for(long long i=0; i<n; i++){
        if(str[i]=='W'){
            cnt = cnt + bcnt;
        }else{
            bcnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3740
n = input()
a = [int(i) for i in input().split()]

cnt_0 = 0
cnt_2 = 0
cnt_4 = 0
for i in a:
  if i % 4 == 0:
    cnt_4 += 1
  elif i % 2 == 0:
  	cnt_2 += 1
  else:
  	cnt_0 += 1

if cnt_2 == 0:
  if cnt_4 >= cnt_0-1:
    print('Yes')
  else:
    print('No')
else:
  if cnt_4 >= cnt_0:
    print('Yes')
  else:
    print('No')
    

Measured memory_bytes: 14252
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
signed main(){
    int a,b;
    cin >> a >> b;
    if(b%a==0){
        cout << a + b << endl;
    }else{
        cout << b - a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
int main (){
	char input[101],temp;
	scanf ("%s",input);
	
	for (int i=0; i < strlen(input);i++){
		if (input[i]== ','){
			printf(" ");
		}
		else {
			printf("%c",input[i]);
		}
	}
	

	return 0;
}

Measured memory_bytes: 1644
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
int main() {
    string n;
    cin >> n;
    if (n[n.length()-1] == '2' ||
        n[n.length()-1] == '4' ||
        n[n.length()-1] == '5' ||
        n[n.length()-1] == '7' ||
        n[n.length()-1] == '9') {
        cout << "hon" << endl;
    }
    else if (n[n.length()-1] == '3') {
        cout << "bon" << endl;
    }
    else cout << "pon" << endl;
    return 0;
}

Measured memory_bytes: 3056
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(a, b, c) = sc.nextLine.split(" ").map(_.toInt).sorted
    if (a + b == c) println("Yes")
    else println("No")
  }
}


Measured memory_bytes: 25528
n,m=map(int,input().split())
h=[0]+list(map(int, input().split()))
roads=[[] for _ in range(n+1)]
cnt=0
for i in range(m):
    a,b=map(int,input().split())
    roads[a].append(b)
    roads[b].append(a)

for i in range(1,n+1):
    for j in roads[i]:
        if h[i]<=h[j]:
            break
    else:
         cnt+=1
    
print(cnt)

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

typedef long long ll;

ll n, a, b, c, d;

int main()
{
	cin >> n >> a >> b >> c >> d;
	for (int i = 0;i < n;i++)
	{
		ll lo = a, hi = a;
		lo += c*i; hi += d*i;
		lo -= d*(n-i-1); hi -= c*(n-i-1);
		if (lo <= b && b <= hi)
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;


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



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);

    int N;
    cin >> N;

    vi A(N);
    rep(i, N)cin >> A[i];
    int ans = gcd(A[0], A[1]);

    for(int i = 3; i< N; i++){
        
        ans = gcd(A[i], ans);
        
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
	int main()
	{
	int n,m;
	cin >> n >> m;
	int k[10];
	int s[10][10];
	int p[10];
	for (int i = 0; i < m ;i++)
	{
		cin >> k[i];
		for (int j = 0; j < k[i]; j++)
		{
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	for (int i = 0; i < m; i++)
	{
		cin >> p[i];
	}

	int count = 0;
	for (int bit = 0; bit < (1 << n); bit++)
	{
		bool judge = true;
		for (int i = 0; i < m; i++)
		{
			int c = 0; //つながっていて、onになっているスイッチの個数
			for (int j = 0; j < k[i]; j++) //onになっているスイッチのチェック。
			{
				int check = s[i][j];
				if(bit &(1 << check)) c++;
			}
			if ((c % 2) != p[i]) judge = false;
		}
		if (judge) count++;
	}
	cout << count << endl;
	}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, m;
	cin >> n >> m;

	if (n == 1) {
		if (m == 1) cout << 1 << endl;
		else if (m >= 2) cout << m - 2 << endl;
	} else if (m == 1) {
		cout << n - 2 << endl;
	} else {
		cout << 1LL * (n - 2) * (m - 2) << endl;

	}
}

Measured memory_bytes: 256
MOD = 10**9 + 7
n = int(input())

# -- 包除原理というらしい。勉強になった。 --
# 0も9も存在する
# 全体　- 0または9が存在しない
# 全体 - (0が存在しない + 9が存在しない　- 0,9どちらも存在しない)
# 10^n - (9^n + 9^n + 8^n)
print((pow(10,n,MOD) - 2 * pow(9,n,MOD) + pow(8,n,MOD)) % MOD)

Measured memory_bytes: 9128
#include<iostream>

using namespace std;

int main()
{
    int a[9];
    int n;
    bool c[9];
    for (int i = 0; i < 9; i++) {
        cin >> a[i];
        c[i] = false;
    }
    cin >> n;
    int *b = new int[n];
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 9; j++) {
            if (b[i] == a[j]) {
                c[j] = true;
            }
        }
    }

    if ((c[0] && c[1] && c[2]) || (c[3] && c[4] && c[5]) || (c[6] && c[7] && c[8]) || 
     (c[0] && c[3] && c[6]) || (c[1] && c[4] && c[7]) || (c[2] && c[5] && c[8]) || 
     (c[0] && c[4] && c[8]) || (c[2] && c[4] && c[6])) {
         cout << "Yes" << endl;
     } else {
         cout << "No" << endl;
     }


    return 0;
}


Measured memory_bytes: 256
//2018-1-1 ~ 2018-a-b

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<=b)
		printf("%d",a);
	else
		printf("%d",a-1);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//this code is written by Itst
using namespace std;

const int _ = 2e5 + 3 , MOD = 1e9 + 7;
struct peo{
	int x , v , l , r;
}now[_];
bool cmp1(peo a , peo b){return a.x < b.x;}
bool cmp2(peo a , peo b){return a.v < b.v;}
int mn[_] , mx[_] , N;
#define PII pair < int , int >

namespace segTree{
	int sum[_ << 2];

#define mid ((l + r) >> 1)
#define lch (x << 1)
#define rch (x << 1 | 1)
	void up(int x){sum[x] = (sum[lch] + sum[rch]) % MOD;}
	
	void modify(int x , int l , int r , int tar , int val){
		if(l == r){sum[x] = (sum[x] + val) % MOD; return;}
		mid >= tar ? modify(lch , l , mid , tar , val) : modify(rch , mid + 1 , r , tar , val);
		up(x);
	}
	
	int qry(int x , int l , int r , int L , int R){
		if(l >= L && r <= R) return sum[x];
		int sum = 0;
		if(mid >= L) sum = qry(lch , l , mid , L , R);
		if(mid < R) sum = (sum + qry(rch , mid + 1 , r , L , R)) % MOD;
		return sum;
	}
}
using segTree::modify; using segTree::qry;

int main(){
	ios::sync_with_stdio(0);
	cin >> N;
	for(int i = 1 ; i <= N ; ++i) cin >> now[i].x >> now[i].v;
	sort(now + 1 , now + N + 1 , cmp1);
	mn[N + 1] = 2e9;
	for(int i = 1 ; i <= N ; ++i) mx[i] = max(mx[i - 1] , now[i].v);
	for(int i = N ; i ; --i) mn[i] = min(mn[i + 1] , now[i].v);
	for(int i = 1 ; i <= N ; ++i){
		now[i].l = mn[i]; now[i].r = mx[i];
	}
	sort(now + 1 , now + N + 1 , cmp2);
	vector < PII > line;
	for(int i = 1 ; i <= N ; ++i){
		int L = lower_bound(now + 1 , now + N + 1 , (peo){0 , now[i].l , 0 , 0} , cmp2) - now;
		int R = lower_bound(now + 1 , now + N + 1 , (peo){0 , now[i].r + 1 , 0 , 0} , cmp2) - now - 1;
		line.push_back(PII(L , R));
	}
	sort(line.begin() , line.end()); modify(1 , 0 , N , 0 , 1);
	for(int i = 0 ; i < (int)line.size() ; ++i)
		modify(1 , 0 , N , line[i].second , qry(1 , 0 , N , line[i].first - 1 , N));
	printf("%d\n" , qry(1 , 0 , N , N , N));
	return 0;
}


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

void chmax(int& a, int b) {
  if (a < b) a = b;
}


int main() {
  int N;
  cin >> N;
  int Shop[N+1][11];
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= 10; j++) {
      cin >> Shop[i][j];
    }
  }
  
  int P[N+1][11];
  
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> P[i][j];
    }
  } 
  
  int ans = -1000000000;
  
  
  for (int i = 1; i < 1024; i++) {
    int benefit = 0;
    // 店jとの利益
    for (int j = 1; j <= N; j++) {
      int count = 0;
      for (int k = 0; k < 10; k++) {
        if ((i & (1 << k)) && Shop[j][k+1]) count++;
      }
      benefit += P[j][count];
    }
    chmax(ans, benefit);
  }
  
  cout << ans << endl;
  
}

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

void main() {
    const N = readln.chomp.to!long;
    const xs = 5.iota.map!(_ => readln.chomp.to!long).array;
    writeln(4 + cast(long)ceil(cast(double)N / xs.reduce!min));
}



Measured memory_bytes: 256
A, B, C = map(int, input().split())

li = [A, B, C]

def is_odd(x):
  return True if x % 2 == 1 else False

def has_odd(l):
  for x in l:
    if is_odd(x):
      return True
  return False

ans = 0

continue_loop = True

while continue_loop:
  if has_odd(li):
    break
  if li[0] == li[1] or li[1] == li[2] or li[2] == li[0]:
    ans = -1
    break
  a, b, c = (li[0], li[1], li[2])
  li[0] = (a + b) // 2
  li[1] = (a + c) // 2
  li[2] = (b + c) // 2
  ans += 1

print(ans)


Measured memory_bytes: 3064
import numpy as np
L=list(map(int,input().split()))
N=L[0]
D=L[1]
count=0
M = [list(map(int, input().split(" "))) for j in range(N)]

for j in range(N):
    r=np.sqrt((M[j][0])**2+(M[j][1])**2)
    if r<=D:
        count += 1

print(count)

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

//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("Ofast")

#define F first
#define S second
#define MT make_tuple
#define SZ(a) ((int)(a).size())
#define PB push_back
#define LBS 20
#define MOD ((long long)1e9+7) //1e9+9
#define LEFT(i) (2*(i))
#define RIGHT(i) (2*(i)+1)
#define PAR(i) ((i)/2)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

typedef long long ll;
typedef double rat;
typedef long long bi;
typedef pair<int, int> ii;
typedef std::vector<ii> vii;
typedef std::map<int, int> mii;
typedef bitset<LBS> bis;
typedef std::vector<bis> vbs;

template<class T>
void in(T &a){
  for(auto &x: a)
    cin >> x;
}

template<class T>
void out(T &a, string sep=" "){
  for(auto x: a)
    cout << x<<sep;
  cout << '\n';
}

template<class T>
void err(T &a, string sep=" "){
  for(auto x: a)
    cerr << x <<sep;
  cerr << '\n';
}


int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n; cin >> n;
  std::vector<int> d(n); in(d);
  ll s=0;
  for(int i=0; i<n; i++)
    for(int j=i+1; j<n; j++)
      s+=d[i]*d[j];
  cout << s<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  bool y = false;
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    if (s == "Y"){
      y = true;
    }
  }
  if (y){
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256