akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main(){
	int a,b;
	int N,tp0,tp1;
	int ct;
	bool ans=false;
	vector<int> s;
	
	scanf("%d %d",&a,&b);
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d %d",&tp0,&tp1);
		s.push_back(tp0);
		s.push_back(tp1);
	}
	sort(s.begin(),s.end());
	if(N==1||N==0){
		if(b<=tp0||tp1<=a)
		printf("0\n");
		else
		printf("1\n");
	}
	else{
		ct=0;
		for(auto i=s.begin();i!=s.end();i++){
			if(*i<=a&&ct%2!=0){
				i++;
				if(b<=*i||i==s.end()){
					printf("0\n");
					ans=true;
				}
				if(ans==true)
				break;
				i--;
			}
			ct++;
		}
		if(ans==false)
		printf("1\n");
	}
}


Measured memory_bytes: 3212
from collections import deque
import sys
input = sys.stdin.readline
import bisect as bi
from operator import mul
from functools import reduce
from math import factorial

def main():
    n, m = map(int, input().split())
    if abs(n-m) > 1:
        print(0)
        return

    ns = factorial(n)
    ms = factorial(m)

    pattern = 2 if n == m else 1

    print((ns * ms * pattern) % (10**9 + 7))

main()


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

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)

int main(){
    int d,n;
    cin >> d >> n;

    if(n==100){
        if(d==0) cout << 101 << endl;
        else if(d==1) cout << 10100 << endl;
        else cout << 1010000 << endl;
    }else{
        cout << pow(100,d)*n << endl;
    }
}

Measured memory_bytes: 384
N = int(input())

T,A = 0,0

for i in range(N):
    F = 0
    Ti,Ai = map(int,input().split())
    if Ti<T or Ai<A: #両方大
        KT = T//Ti if T%Ti==0 else (T//Ti)+1
        KA = A//Ai if A%Ai==0 else (A//Ai)+1
        K = max([KT,KA])
        T = Ti*K
        A = Ai*K
    else: #両方小
        T = Ti
        A = Ai
        
print(T+A)

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

long long mat[207][207];
int ord[10];
long long ans = 1e16;
long long inf = 1e16;
int main(){
	int n,m,r;
	int a,b,c;
	
	cin >> n >> m >> r;
	
	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=n;j++){
			mat[i][j] = inf;
			mat[j][i] = inf;
		}
	}
	
	for(int i = 0;i < r;i++){
		cin >> ord[i];
	}
	
	while(m--){
		cin >> a >> b >> c;
		mat[a][b] = c;
		mat[b][a] = c;
	}
	
	for(int k = 1;k<=n;k++){
		for(int i = 1;i<=n;i++){
			for(int j = 1;j<=n;j++){
				if(mat[i][j]>mat[i][k]+mat[k][j]){
					mat[i][j] = mat[i][k]+mat[k][j];
				}
			}
		}
	}
	sort(ord,ord+r);
	while(next_permutation(ord,ord+r)){
		long long sum = 0;
		for(int i = 1;i < r;i++){
			sum+=mat[ord[i]][ord[i-1]];
		}
		ans = min(sum,ans);
	}
	cout << ans;
}

Measured memory_bytes: 512
S=list(input())

f=list()
f.append(1)

if S[0]==S[1]:
  f.append(1)
else:
  f.append(2)
  
if S[0] != S[1] and S[1] != S[2]:
  f.append(3)
else:
  f.append(2)

for i in range(3,len(S)): 
  if S[i] != S[i-1]:
    f.append(f[i-1]+1)
  else:
    f.append(f[i-3]+2)

print(f[len(S)-1])    

Measured memory_bytes: 12836
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;


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

int N, A; cin >> N >> A;
VI x(N); rep(i, 0, N) cin >> x[i];

int X = *max_element(ALL(x));
X = max(X, A);
// cnt[i][j][k] = x[i-1] までで j 枚選び，和を k にする選び方の数．
vector<VVI> cnt(N+1, VVI(N+1, VI(N * X + 1, 0)));
cnt[0][0][0] = 1;

rep(i, 1, N+1) rep(j, 0, N+1) rep(k, 0, N * X + 1){
    if (k < x[i-1]) cnt[i][j][k] = cnt[i - 1][j][k];
    else if (j > 0) 
        cnt[i][j][k] = cnt[i - 1][j][k] + cnt[i - 1][j - 1][k - x[i-1]];
}

i64 ans = 0;
rep(i, 1, N+1) ans += cnt[N][i][i * A];

cout <<  ans << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 52224
array = Array.new

while val = gets do
    array.push(val.chomp.split.map(&:to_i))
end

n,k = array[0]
h = array[1].sort.reverse
sum = 0

if k >= n
    puts(0)
    exit
elsif k > 0
    h.shift(k)
end

h.each do |i| 
    sum = sum + i 
end
puts(sum)

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	if (k & 1) cout << b - a << endl;
	else cout << a - b << endl;

	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);

	ll ans=0;
	if(n%2==0){
		int k=n/2;
		for(int i=k; i<n; i++) ans+=2*a[i];
		for(int i=0; i<k; i++) ans-=2*a[i];
		ans+=a[k-1]-a[k];
	}else{
		int k=(n-1)/2;
		ll t1=0, t2=0;

		for(int i=k+1; i<n; i++) t1+=2*a[i];
		for(int i=0; i<k+1; i++) t1-=2*a[i];
		t1+=a[k-1]+a[k];

		for(int i=k; i<n; i++) t2+=2*a[i];
		for(int i=0; i<k; i++) t2-=2*a[i];
		t2-=a[k]+=a[k+1];

		ans=max(t1, t2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int n, m, q, x, y, x1, y1, z, w;
	cin >> n >> m >> q;
	char c;
	int s[2010][2010], t[2010][2010], t1[2010][2010], u[2010][2010];
	rep(i, n) rep(j, m)
	{
		cin >> c;
		if(c=='1') s[i][j]=1;
		else s[i][j]=0;
	}
	u[0][0]=0;
	reps(j, m) u[0][j]=0;
	reps(i, n) u[i][0]=0;
	reps(i, n) reps(j, m)
	{
		u[i][j]=u[i-1][j]+u[i][j-1]-u[i-1][j-1]+s[i-1][j-1];
	}
	t[0][0]=0;
	reps(j, m) t[0][j]=0;
	reps(i, n) t[i][0]=0;
	reps(i, n) reps(j, m)
	{
		
		t[i][j]=t[i-1][j]+t[i][j-1]-t[i-1][j-1];
		if(s[i-1][j-1]==1)
		{
			if(i>1) if(s[i-2][j-1]==1) t[i][j]++;
		}
	}
	t1[0][0]=0;
	reps(j, m) t1[0][j]=0;
	reps(i, n) t1[i][0]=0;
	reps(i, n) reps(j, m)
	{
		
		t1[i][j]=t1[i-1][j]+t1[i][j-1]-t1[i-1][j-1];
		if(s[i-1][j-1]==1)
		{
			if(j>1) if(s[i-1][j-2]==1) t1[i][j]++;
		}
	}
	rep(k, q)
	{
		cin >> x >> y >> x1 >> y1;
		z=u[x1][y1]-u[x1][y-1]-u[x-1][y1]+u[x-1][y-1];
		w=t[x1][y1]-t[x1][y-1]-t[x][y1]+t[x][y-1];
		w+=t1[x1][y1]-t1[x1][y]-t1[x-1][y1]+t1[x-1][y];
		cout << (z-w) << endl;
	}
	return 0;
}

Measured memory_bytes: 64896
#include <cstdio>
#include <cstring>
const int MAXS = 2e5+5;
char S[MAXS];

int main() {
  scanf("%s", S);
  int N = strlen(S);
  int ret = 1;
  for (int i = 1; i < N; ++i) {
    // Single char
    if (S[i] != S[i-1]) {
      ++ret;
    } else {
      // Augment [1->2] [2->3]
      ++i;
      if (i < N) ++ret;
      // Single char
      ++i;
      if (i < N) ++ret;
    }
  }
  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
 
int main(void)
{
    // Your code here!
    int H,W,K;
    char map[6][7] = {};
    int ans = 0,i,Hb,Wb,j;
    
    scanf("%d%d%d",&H,&W,&K);
    
    for(i = 0; i < H; i++)
    {
        scanf("%6s",map[i]);
        //printf("%s\n",map[i]);
    }
    
    for(Hb = 0; Hb < (int)pow(2,H); Hb++ )
    {
        for( Wb = 0; Wb < (int)pow(2,W); Wb++)
        {
            int brack = 0;
            for( i = 0; i < H; i++)
            {
                for(j = 0; j < W; j++)
                {
                    if((Hb>>i & 1) == 0 && (Wb>>j & 1) == 0 && map[i][j] == '#')
                    {
                        brack++;
                    }
                }
            }
            if(brack == K)
            {
                ans++;
            }
        }
    }
    
    printf("%d\n",ans);
}

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

int main() {
    int n;
    cin >> n;
    cout << n/3 << endl;
}

Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
n = int(input())
h = int(input())
w = int(input())
print((n-h+1)*(n-w+1))


Measured memory_bytes: 5276
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    string a, b;
    cin >> n;
    cin >> a >> b;
    rep(i, n) {
        cout << a[i];
        cout << b[i];
    }
    
    


}


Measured memory_bytes: 3564
#include<stdio.h>
int main()
{
    int n,i,j,temp=0,ar[10];
    n=10;
    for(i=0; i<n; i++)
        scanf("%d",&ar[i]);
    for(i=0; i<n-1; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(ar[i]>ar[j])
            {
                temp=ar[i];
                ar[i]=ar[j];
                ar[j]=temp;
            }
        }
    }
    for(i=n-1; i>n-4; i--)
    {
        printf("%d\n",ar[i]);
    }

    return 0;

}



Measured memory_bytes: 2140
#include <iostream>

using namespace std;
#define MAX 2000000
#define INFINITY (1<<30)

int gHeap[MAX + 1],gSize;

void maxHeapify(int i){
    int left,right,largest;
    left = 2 * i;
    right = 2 * i + 1;
    
    // 左の子、自分、右の子で値が最大のノードを選択
    if(left <= gSize && gHeap[left] > gHeap[i]){
        largest = left;
    }
    else{
        largest = i;
    }
    // 右の子と比較
    if(right <= gSize && gHeap[right] > gHeap[largest]) largest = right;
    
    if(largest != i){
        swap(gHeap[i],gHeap[largest]);
        maxHeapify(largest);
    }
}

int extract(){
    int maxv;
    if(gSize < 1) return -INFINITY;
    maxv = gHeap[1];
    gHeap[1] = gHeap[gSize--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i ,int key){
    if(key < gHeap[i])return;
    gHeap[i] = key;
    while(i > 1 && gHeap[i / 2] < gHeap[i]){
        swap(gHeap[i],gHeap[i / 2]);
        i = i / 2;
    }
}

void insert(int key){
    gSize++;
    gHeap[gSize] = -INFINITY;
    increaseKey(gSize, key);
}

int main(){
    int key;
    char com[10];
    
    while(1){
        cin >> com;
        if(com[0] == 'e' && com[1] == 'n') break;
        if(com[0] == 'i'){
            cin >> key;
            insert(key);
        }else{
            cout << extract() << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 7004
n =int(input())
a=[int(x) for x in input().split()]
 
s=sum(a)
ans=0
diff=abs(s-a[0]*n)
for i in range(n):
  if diff>abs(s-a[i]*n): 
    diff= abs(s-a[i]*n)
    ans=i
print(ans)

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

int main()
{
	int n, hm = 0, m = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int h;
		cin >> h;

		if (hm <= h) {
			hm = h;
			m++;
		}
	}

	cout << m << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll ok[12345678], cost[12345678];
signed main() {
    ll n, m, l, r, d, z = 0, ans = 0;
	cin >> n >> m; map <ll, map<ll, ll>> ma;
	vector<vector<ll>> G(123456);
    queue<ll> que;
    if (m == 0) { cout << "Yes" << endl; return 0; }
    for (int h = 0; h <= n + 10; h++) { ok[h] = 1; }
	for (int h = 0; h < m; h++) {
		cin >> l >> r >> d; ma[l][r] = d;
        G[l].push_back(r); ok[r] = 0;
	}
    for (int i = 0; i <= n; i++) {
        if (ok[i] != 0) {
            if (!G[i].empty()) { cost[i] = 1; que.push(i); }
        }
    }
    if (que.empty()) { cout << "No" << endl; return 0; }
    while (que.size()) {
        for (int i = 0; i < G[que.front()].size(); i++) {
            if (cost[G[que.front()][i]] == 0) {
                que.push(G[que.front()][i]);
                cost[G[que.front()][i]] = cost[que.front()] + ma[que.front()][G[que.front()][i]];
            }
            else {
                if (cost[G[que.front()][i]] != cost[que.front()] + ma[que.front()][G[que.front()][i]]) {
                    cout << "No" << endl; return 0;
                }
            }
        }
        que.pop();
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 30820
import java.util.Scanner;

public class Main {
	
	public static void main(String... ac) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), k = sc.nextInt();
		
		int max = Math.max(a, Math.max(b, c));
		
		System.out.println(a + b + c + max * ((1 << k) - 1));
		
	}
	
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define llu ll unsigned
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define ft first
#define sd second
using namespace std;
const int MOD=(int)1e9+7;
// #pragma comment(linker, "/STACK:2000000")

string to_string(string s){return '"'+s+'"';}string to_string(const char* s){return to_string((string)s);}template <typename A, typename B>string to_string(pair<A, B> p){return "("+to_string(p.first)+", "+to_string(p.second)+")";}template<typename A>string to_string(A v){bool first=true;string res="{";for(const auto&x:v){if(!first){res+=", ";}first = false;res+=to_string(x);}res += "}";return res;}void debug_out(){cerr<<endl;}template<typename Head,typename... Tail>void debug_out(Head H,Tail... T){cerr<<" "<<to_string(H);debug_out(T...);}
#ifdef LOCAL
#define err(...)cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
#else
#define err(...) 42
#endif
#ifdef SUBLIME
#define IO freopen("in.txt","r",stdin)//;freopen("out1.txt","w",stdout)
#else
#define IO
#endif

const int N=1e3+9;
typedef long double ld;
const ll inf = 2e9+9;
const ld eps = 1e-11;


int a,b,c,d;

int main(){

    IO;  ios::sync_with_stdio(false);cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    for(int i=1;i<=n;i++){
        string num=to_string(i);
        int sum=0;
        for(int j=0;j<num.size();j++){
            sum+=(int)((char)num[j]-'0');
        }
        if(sum<=b && sum>=a){
            ans+=i;
            
        }
    }
    cout<<ans;
    return 0; 
} 




Measured memory_bytes: 256
n = int(input())
num = [ int(v) for v in input().split() ]
a, b, c = 0, 0, 0
for i in num:
	if i % 2 != 0:
		a += 1
	elif i % 4 != 0:
		b += 1
	else:
		c += 1
if b == 0:
	if c >= a - 1:
		print("Yes")
	else:
		print("No")
else:
	if c >= a:
		print("Yes")
	else:
		print("No")


Measured memory_bytes: 14252
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>

typedef long long LL;

const int MAXP = 3;
const int MAXM = 100000;
const int MAXN = 100000;
const int MOD = 1000000007;

const int Dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

inline int Add(int x, const int &y) {
	return (x += y) >= MOD ? x - MOD : x;
}

inline int Mul(const int &x, const int &y) {
	return (LL)x * y % MOD;
}

struct Matrix {
	int n, m;
	int Mat[MAXP][MAXP];

	Matrix(int _n = 0, int _m = 0) {
		n = _n, m = _m;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				Mat[i][j] = 0;
	}

	int* operator [] (const int &i) { return Mat[i]; }

	Matrix operator * (Matrix &other) const {
		Matrix ret(n, other.m);
		for (int i = 0; i < ret.n; i++)
			for (int j = 0; j < ret.m; j++)
				for (int k = 0; k < m; k++)
					ret[i][j] = Add(ret[i][j], Mul(Mat[i][k], other[k][j]));
		return ret;
	}

	Matrix operator ^ (int k) const {
		Matrix ret(n, m), tmp = *this;
		for (int i = 0; i < n; i++)
			ret[i][i] = 1;
		while (k) {
			if (k & 1)
				ret = ret * tmp;
			tmp = tmp * tmp;
			k >>= 1;
		}
		return ret;
	}
};

int N, M;
int Flag[MAXM + 5];

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= M; i++)
		scanf("%d", &Flag[i]);
	Matrix A(3, 3), B(3, 3), Dp(3, 1);
	A[0][0] = 1, A[0][1] = 0, A[0][2] = 0;
	A[1][0] = 2, A[1][1] = 1, A[1][2] = 0;
	A[2][0] = 1, A[2][1] = 1, A[2][2] = 1;
	B[0][0] = 1, B[0][1] = 0, B[0][2] = 1;
	B[1][0] = 2, B[1][1] = 1, B[1][2] = 2;
	B[2][0] = 1, B[2][1] = 1, B[2][2] = 2;
	Dp[0][0] = 1, Dp[1][0] = 2, Dp[2][0] = 1; // Dp[1]
	for (int i = 1; i <= M; i++) {
		int k = Flag[i] - Flag[i - 1] - 1;
		Dp = (B ^ k) * Dp, Dp = A * Dp;
	}
	Dp = (B ^ (N - Flag[M] - 1)) * Dp;
	printf("%d", Dp[2][0]);
	return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

using Int = long long;

Int left(const set<Int> &S, Int x) {
    auto it = S.lower_bound(x);
    if (it == S.begin()) {
        return -1e18;
    }
    it--;
    return *it;
}

Int right(const set<Int> &S, Int x) {
    auto it = S.lower_bound(x);
    if (it == S.end()) {
        return 1e18;
    }
    return *it;
}

Int update(Int ans, Int target) {
    // cout << "target: " << target << endl;
    return min(ans, target);
}

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    set<Int> S, T;
    rep(i, A) {
        Int s;
        cin >> s;
        S.insert(s);
    }
    rep(i, B) {
        Int t;
        cin >> t;
        T.insert(t);
    }

    rep(i, Q) {
        Int x;
        cin >> x;

        Int left_s = left(S, x);
        Int right_s = right(S, x);
        Int left_t = left(T, x);
        Int right_t = right(T, x);

        // cout << left_s << ", " << right_s << ": " << left_t << ", " << right_t << endl;

        // tera jin x
        Int ans = update(1e18, max(abs(left_s - x), abs(left_t - x)));

        // x tera jin
        ans = update(ans, max(abs(right_s - x), abs(right_t - x)));

        // s x t
        ans = update(ans, abs(left_s - x) + abs(right_t - left_s));
        ans = update(ans, abs(right_t - x) + abs(right_t - left_s));
        // t x s
        ans = update(ans, abs(right_s - x) + abs(left_t - right_s));
        ans = update(ans, abs(left_t - x) + abs(left_t - right_s));

        cout << ans << endl;
    }
}


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

int main() {
  
  int N;
  cin >> N;

  long long a,t;
  cin >> a >> t;
  long long A = a,T = t;
  for(int i = 1;i < N;i++) {
    long long numa,numt;
    cin >> a >> t;

    numa = (A - 1) / a + 1;
    numt = (T - 1) / t + 1;

    long long num = max(numa,numt);
    A = a * num;
    T = t * num;
  }

  cout << A + T << endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back





int main(){
    int n;
    cin >> n;
    int a[n];
    int ans=pow(3,n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    int kisuu_count=1;

    for(int i=0;i<n;i++){
        int kisuu=0;
        if(a[i]%2==0){
            kisuu=2;
        }else{
            kisuu=1;
        }
        kisuu_count=kisuu_count*kisuu;
    }
    cout << ans-kisuu_count << endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
INF=10**9+7
baisu= [[] for _ in [0]*(k+1)]
D=[0]*(k+1)
ans=0
for d in range(1,k+1):
    baisu[d]=[d*i for i in range(2,k//d+1)]
    D[d]=pow(k//d,n,INF)

for d in range(k,0,-1):
    for b in baisu[d]:
        D[d]-=D[b]
    D[d]%=INF
for i,x in enumerate(D):
    #ans+=(i*x)%INFだとだめだった  ansを%INF
    ans=(ans+i*x)%INF
    
#print(baisu)
#print(D)
print(ans)

Measured memory_bytes: 61644
package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)
	var ans []int32
	for _, c := range s {
		if c == '0' || c == '1' {
			ans = append(ans, c)
		} else {
			n := len(ans) - 1
			if n >= 0 {
				ans = ans[:n]
			}
		}
	}
	for _, c := range ans {
		fmt.Printf("%c", c)
	}
	fmt.Println("")
}


Measured memory_bytes: 512
#include<stdio.h>
   
int main(){
int i,j;
float x,l[10]={0},v1,v2,lsum,lsum2,sure;   
 
while(scanf("%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\n", &l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2)!=EOF){
   lsum=0;
   x=0;
   for(i = 0; i < 10; i++)lsum=lsum+l[i];

   x=lsum/(v1+v2);
   sure = v1*x;
   lsum2=0;
   for(i = 0; i < 10; i++){
     lsum2=lsum2+l[i];
     if(lsum2>=sure)
        {printf("%d\n", i+1);
        break;}
    }    
}
   
    return 0;
}

Measured memory_bytes: 624
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;

using int64 = long long;
using uint64 = unsigned long long;

#define repeat(i, x) for (int64 i = 0; (i) < (x); (i)++)
#define rev_repeat(i, x) for (int64 i = (x) - 1; (i) >= 0; (i)--)
#define countup(i, n) for (int64 i = 0; (i) <= (n); (i)++)
#define countdown(i, n) for (int64 i = (n); (i) >= 0; (i)--)
#define range(i, a, b) for (int64 i = (a); (i) < (b); (i)++)
#define traverse(it, ctn) for (auto it = begin(ctn); (it) != end(ctn); (it)++)
#define rev_traverse(it, ctn) for (auto it = rbegin(ctn); (it) != rend(ctn); (it)++)

template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec)
{
    os << "[";
    repeat (i, vec.size())
    {
        os << (i == 0 ? "" : ", ") << vec[i];
    }
    os << "]";
    return os;
}

template<typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T>& s)
{
    os << "{";
    traverse (it, s)
    {
        if (it != s.begin()) os << ", ";
        os << *it;
    }
    os << "}";
    return os;
}

template<typename K, typename V>
ostream& operator<<(ostream& os, map<K, V>& m) 
{
    os << "{";
    traverse (it, m)
    {
        if (it != m.begin()) os << ", ";
        os << it->first << ": " << it->second;
    }
    os << "}";
    return os;
}

//
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//

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

    int n;
    cin >> n;

    int sum = 0, maxP = 0;
    repeat (i, n)
    {
        int p;
        cin >> p;

        sum += p;
        maxP = max(maxP, p);
    }

    cout << sum - maxP / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int main(void){
    string A;
    vector<int> nc(26,0);
    cin>>A;
    REP(i,SZ(A))
        nc[A[i]-'a']++;
    LL ans=0;
    REP(i,SZ(A)){
        nc[A[i]-'a']--;
        REP(j,26)
            if(j!=A[i]-'a')
                ans+=nc[j];
    }
    cout<<ans+1<<endl;
     return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


int main(){
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);

    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];

    sort(all(A));
    sort(all(B));
    sort(all(C));
    reverse(all(A));
    reverse(all(B));
    reverse(all(C));

    vector<ll> s;
    rep(i, X)rep(j, Y)rep(k, Z) {
        if ((i + 1) * (j + 1) * (k + 1) <= K) s.push_back(A[i] + B[j] + C[k]);
        else break;
    }

    sort(all(s));
    reverse(all(s));
    rep(i, K) cout << s[i] << endl;
}

Measured memory_bytes: 1404
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, k;
    cin >> n >> k;
    cout << (n % k > 0);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

int main() {

    ll n, k;
    cin >> n >> k;

    if(k == 0){
        cout << n*n << endl;
        return 0;
    }
    ll ans = 0;
    for(ll i=k+1; i<=n; ++i){
        ans += (i-k) * (n/i);
        ll x = n % i;
        ans += max(0LL, x - k + 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 *      ABC 63 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-11 09:19:44
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int s[N] = {};
    for (int i = 0; i < N; ++i) {
        cin >> s[i];
    }

    int sum = 0;
    for (int i = 0; i < N; ++i) {
        sum += s[i];
    }
    if (sum % 10 != 0){
        cout << sum << endl;
        return 0;
    }
    sort(s, s + N);

    for (int i = 0; i < N; ++i) {
        if (s[i] % 10 != 0){
            cout << sum - s[i] << endl; return 0;
        }
    }
    cout << 0 << endl;

    return 0;

}

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

#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
    int N, M;
    cin >> N >> M;
    cout << (M*1900 + (N-M)*100) * (1 << M) << endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

int palin (int x)
{
    int r=0,k=x;
    while (k)
    {
        r=r*10+k%10;
        k/=10;
    }
    return (r==x);
}

main()
{
    fast;
    int a,b,i,ans=0;
    cin>>a>>b;
    for (i=a;i<=b;i++)
        ans+=palin(i);
    cout<<ans<<endl;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    for(i = 0;i <= n;++i){
        cin >> a.at(i);
    }
    vector<ll> limi2(n+1,1);
    for(i = 1;i <= n;++i){
        if(limi2.at(i-1) <= 1e18) limi2.at(i) = limi2.at(i-1)*2ll;
        else limi2.at(i) = limi2.at(i-1);
    }

    vector<ll> uekara(n+1);
    for(i = 0;i <= n;++i){
        if(i == 0){
            if(n == 0){
                if(a.at(i) <= 1) cout << 1 << endl;
                else cout << -1 << endl;
                return 0;
            }
            if(a.at(i) > 0){
                cout << -1 << endl;
                return 0;
            }
            uekara.at(i) = limi2.at(i) - a.at(i);
        }else{
            if(a.at(i) > 2*uekara.at(i-1)){
                cout << -1 << endl;
                return 0;
            }
            uekara.at(i) = min(limi2.at(i), 2*uekara.at(i-1) - a.at(i));
        }
    }

    ll ans = 0;
    ll tmp = 0;
    for(i = n;i >= 1;--i){
        ans += a.at(i);
        tmp += a.at(i);
        if(tmp > uekara.at(i-1)) tmp = uekara.at(i-1);
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  puts(A1 + A2 + A3 >= 22 ? "bust" : "win");
}

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

int main(){
    int A,B,C,X,i,j,k,ans=0;
    cin >> A >> B >> C >> X;
    for (i=0;i<A+1;i++){
        for(k=0;k<B+1;k++){
            for(j=0;j<C+1;j++){
                if(500*i+100*k+50*j == X){
                    ans++;

                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int d;
    while(cin >> d){
        int n = 600 / d;
        int sum = 0;
        rep(i, 0, n){
            sum += d * (i * d) * (i * d);
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 3000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c>21){
        cout << "bust";
    }else{
        cout << "win";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,m;
cin>>n>>m;
int ans=0;
if(n>1){
    ans+=(n*(n-1))/2;
}
if(m>1){
    ans+=(m*(m-1))/2;
}

cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	sl := make([]map[int]int, n)

	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		sl[i] = map[int]int{}
		for j := 0; j < a; j++ {
			var x, y int
			fmt.Scan(&x, &y)
			sl[i][x-1] = y
		}
	}

	var max int
	for bit := 0; bit < (1 << uint(n)); bit++ {
		ok := true
		for i := 0; i < n; i++ {
			if (bit>>uint(i))&1 == 1 {
				for k, v := range sl[i] {
					if v != ((bit >> uint(k)) & 1) {
						ok = false
						break
					}
				}
			}
		}
		if ok {
			cnt := onesCount(bit)
			if cnt > max {
				max = cnt
			}
		}
	}
	fmt.Println(max)
}

func onesCount(bit int) int {
	var num int
	for ; bit != 0; bit &= bit - 1 {
		num++
	}
	return num
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define yes "Yes\n"
#define no "No\n"
//int m,n;
int i,j,k,l;
//int a,b,c,d,e,f,g;
//int sum,total;
//long long int ;
//float ;
//double ;
//char a[101],b[101],s[101],t[101],u[101];
int h,n,a[100000],sum;
int main(void){
    scanf("%d %d",&h,&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    if (sum<h)
    {
        printf(no);
    } else
    {
        printf(yes);
    }
    return 0;
}

Measured memory_bytes: 512
a=[int(i) for i in input().split()]
b=[]
for i in range(a[2]):
  b.append([int(j) for j in input().split()])
import collections
import time
c=[]
d=[0 for i in range(10)]
for i in range(len(b)):
  for jj in [-2,-1,0]:
    for kk in [-2,-1,0]:
      if 0<b[i][0]+jj<a[0]-1 and 0<b[i][1]+kk<a[1]-1:
       c.append((b[i][0]+jj,b[i][1]+kk))
count_dict = collections.Counter(c)
n=count_dict.values()
for i in n:
  d[i]+=1
d[0]=(a[0]-2)*(a[1]-2)-len(n)
for j in range(10):
 print(d[j])


Measured memory_bytes: 216860
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
ll L[N], R[N], A[N], k;
ll Roundup(ll x, ll y){
	return (x / y + (x % y != 0));
}

int main(){
	IOS;
	cin >> k;
	for (int i = 1; i <= k; i++){
		cin >> A[i];
	}
	L[k] = 2;
	R[k] = 2;
	for (int i = k - 1; i >= 0; i--){
		L[i] = (Roundup(L[i + 1], A[i + 1])) * A[i + 1];
		R[i] = R[i + 1] / A[i + 1] * A[i + 1] + A[i + 1] - 1;
		if (L[i + 1] / A[i + 1] == R[i + 1] / A[i + 1] && (L[i + 1] % A[i + 1] != 0)) kill(-1);
	}
	cout << L[0] << ' ' << R[0];
	
	
	
	
	return 0;
}





/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  int MIN = 753;
  for(int i = 2;i<a.size();i++){
    int s = (int)a.at(i)-48 + ((int)a.at(i-1)-48)*10 + ((int)a.at(i-2)-48)*100;
    int t = abs(753-s);
    if(t<MIN)
      MIN = min(t,MIN);
  }
  cout << MIN << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  ll i,j,N,M,C,x,ans=0,res=0;
  cin>>N>>M>>C;
  vec b(M);
  rep(i,M){
    cin>>b[i];
  }
  while(N--){
    ans=C;
    rep(i,M){
      cin>>x;
      ans+=x*b[i];
    }
    if(ans>0){
      res++;
    }
  }
  cout<<res<<endl;
  return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

i64 po(i64 n){
    i64 ret = 1;
    rep(i, n) ret *= 10;
    return ret;
}

void solve(long long N, long long M, std::vector<long long> s, std::vector<long long> c){
    i64 b = po(N - 1);
    if(N == 1){
        bool flag = true;
        rep(j, M){
            if(c[j] != 0) flag = false;
        }
        if(flag){
            cout << 0 << endl;
            return;
        }
    }
    rep(i, b, b * 10){
        bool flag = true;
        rep(j, M){
            flag &= (i / po(N - s[j])) % 10 == c[j];
        }
        if(flag){
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    int ans = 1;

    rep(i,n){
        if((i+1)*(i+1) <= n) ans = (i+1)*(i+1);
        else break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define lli long long int
int main() {
    fast;
    lli sum=0;
        string s;
        cin>>s ;    
        for(lli i=0;i<s.size();i++){
            sum+=(s[i]-48);
        }
        if(sum%9==0)cout<<"Yes";
        else cout<<"No";   
}





Measured memory_bytes: 3756
private fun readIntArray(): List<Int> {
    return readLine()!!.split(" ").map{ it.toInt() }
}

private fun readInt(): Int {
    return readLine()!!.toInt()
}

private fun readTextArray(): List<String> {
    return readLine()!!.split(" ")
}

fun main(args: Array<String>) {
    var (A, B, C) = readIntArray().sorted()
    var count = 0

    while(B < C) {
        A += 1
        B += 1
        count += 1
    }
    while(A < B) {
        A += 2
        count += 1
    }
    if(A > B) {
        count += 1
    }

    print(count)
}

Measured memory_bytes: 36140
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll a;
    double b;
    cin >> a >> b;
    ll bl = b * 100ll + 0.001;
    cout << a * bl / 100ll << "\n";
    return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>

int main (int argc, char **argv)
{
  long long a = 0;
  long long b = 0;

  scanf("%lld %lld", &a, &b);

  
  if(((b * b) - (a * a)) % (2 * (b - a)))
  {
    printf("IMPOSSIBLE\n");
  }
  else
  {
    printf("%lld\n", ((b * b) - (a * a)) / (2 * (b - a)));
  }

  return 0;
}


Measured memory_bytes: 128