akhauriyash/Code-Regression huggingface dataset:
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n, L;
int a[N], Right[20][N], Left[20][N];
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	rep(i, 1, n) cin >> a[i];
	cin >> L;

	/// calculating Rights
	int ptr = n;
	per(i, n, 1) {
		while (a[ptr] - a[i] > L) ptr--;
		Right[0][i] = ptr;
	}
	/// Calculating Lefts
	ptr = 1;
	rep(i, 1, n) {
		while (a[i] - a[ptr] > L) ptr++;
		Left[0][i] = ptr;
	}
	rep(dg, 1, 19) {
		rep(i, 1, n) {
			Right[dg][i] = Right[dg - 1][Right[dg - 1][i]];
			Left[dg][i] = Left[dg - 1][Left[dg - 1][i]];
		}
	}

	int q;
	cin >> q;
	while (q--) {
		int l, r;
		cin >> l >> r;
		int ans = 0;
		if (l < r) {
			per(i, 19, 0) {
				if (Right[i][l] < r) {
					l = Right[i][l];
					ans += (1 << i);
				}
			}
			++ans;
		}
		else {
			per(i, 19, 0) {
				if (Left[i][l] > r) {
					l = Left[i][l];
					ans += (1 << i);
				}
			}
			++ans;
		}
		cout << ans << nl;


		/*
		if (l > r) swap(l, r);
		int ans = 0;
		per(i, 19, 0) {
			if (reight[i][l] <= r) {
				l = reight[i][l];
				ans += (1 << i);
			}
		}
		cout << ans << nl;*/
	}
	ioi
}


Measured memory_bytes: 16896
import java.util.*;

public class Main {
    long MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for(int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }
        Arrays.sort(d);
        int t1 = d[n / 2];
        int t2 = d[n / 2 - 1];
        int ans = t1 - t2;
        System.out.println(ans);

    }
}

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

const int MOD = 1e9 + 7;

int pow_mod(ll x, ll n, int M) {
    ll ans = 1;
    for (; n; n>>=1) {
        if (n & 1) ans = ans * x % M;
        x = x * x % M;
    }
    return ans;
}

int inv_mod(int x, int p) {
    return pow_mod(x, p - 2, p);
}

int main() {
    int N; cin >> N;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    vector<ll> a(N - 1);
    rep(i, N - 1) a[i] = x[i + 1] - x[i];
    N--;
    ll c = 0, ans = 0;
    rep(i, N) {
        c = (c + inv_mod(i + 1, MOD)) % MOD;
        ans = (ans + c * a[i]) % MOD;
    }
    for (int x = 1; x <= N; x++) ans = ans * x % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 1408
main = put =<< sol <$> get

get = fmap read . words <$> getLine

put = putStrLn . unwords . fmap show

sol [a,b,k] 
  | k==0      = [a,b]
  | a>0       = sol [a-c,b,k-c]
  | b>0       = sol [a,b-d,k-d]
  | otherwise = [a,b]
  where
  c = min a k
  d = min b k

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n,k;
  cin >> n >> k;
  int64_t a[n] = {};
  for(int64_t i=0;i<n;i++){
    cin >> a[i];
    a[i] -= 1;
  }

  int64_t visited[n] = {};
  int64_t current = 0;
  int64_t loopCount = 0;
  for(int64_t i=0;i<n;i++){
    visited[i] = -1;
  }
  for(int64_t i=0;i<n+1;i++){
    if(visited[current]!=-1){
      loopCount = i-visited[current];
      break;
    }
    visited[current] = i;
    current = a[current];
  }
  if(k<visited[current]){
    current = 0;
  	for(int64_t i=0;i<k;i++){
    	current = a[current];
  	}
    cout << current+1 << endl;
    return 0;
  }
  int64_t newK = (k-visited[current])%loopCount;
  for(int64_t i=0;i<newK;i++){
    current = a[current];
  }
  cout << current+1 << endl;
  return 0;
}

Measured memory_bytes: 6748
A,B,H,M = gets.split.map(&:to_i)

rh = 360.0 / 12 * H + 360.0 / (12*60) * M
rm = 360.0 / 60 * M
r = [rh,rm].sort.reverse.inject(:-)
p (A*A+B*B - (2*A*B*Math.cos(r / 180 * Math::PI))) ** 0.5

Measured memory_bytes: 14860
#include <stdio.h>

void shuffle(char *st)
{
	char ch;
	ch = *st;

	while (*(st + 1)) {
		*st = *(st + 1);
		st++;
	}

	*st = ch;
}

int main(void)
{
	char a[201];
	int h, i, m, j;

	while (1) {
		scanf("%s\n", a);
		if (a[0] == '-')	break;
		scanf("%d", &m);
		for (i = 0; i < m; i++) {
			scanf("%d", &h);
			for (j = 0; j < h; j++)
				shuffle(a);
		}
		printf("%s\n", a);
	}

	return 0;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=Pre[x];p;p=Next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=Next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (1000000007)
#define pb push_back
#define mp make_pair 
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %I64d\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
						For(j,m-1) cout<<a[i][j]<<' ';\
						cout<<a[i][m]<<endl; \
						} 
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int read()
{
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
	return x*f;
} 
int main()
{
//	freopen("A.in","r",stdin);
//	freopen(".out","w",stdout);
	char s[1000];
	cin>>s;
	int n=strlen(s);
	Rep(i,n) Fork(j,i+1,n-1) if (s[i]=='C'&&s[j]=='F') {
		puts("Yes");return 0;
	}
	puts("No");
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=0,l=0;
		int as=0,am=0; // テ・ツ、ツァテ」ツ?催」ツ??ヲツ閉ーテ」ツ?ィテ・ツーツ湘」ツ?陛」ツ??ヲツ閉ーテァツ板ィ

		while(sc.hasNext()){
			a = sc.nextInt();
			l = sc.nextInt();
			
			if(a == 0 && l == 0) break;
			
			int[] array = new int[l];

			// 20テ・ツ崢榲ァツケツーテ」ツつ甘ィツソツ氾」ツ?凖」ツ?づァツュツ氾」ツ?暗」ツ?古・ツ?コテ」ツ?淌」ツつ叡reak
			
			int[] result = new int[21];
			result[0] = a;
			for(int i = 1;i<result.length;i++){
				makeArray(array,a); // テ」ツ?禿」ツ?禿」ツ?ァテゥツ?催・ツ按療」ツつ津」ツ?、テ」ツ?湘」ツ?」テ」ツ?ヲ
				Arrays.sort(array); // テ」ツ?禿」ツ?禿」ツ?ァテ、ツクツヲテ」ツ?ウテヲツ崢ソテ」ツ?暗」ツ?ヲ
				am = makeAM(array); // テ・ツ、ツァテ」ツ?催」ツ??」ツ?ョテ」ツ?、テ」ツ?湘」ツ?」テ」ツ?ヲ
				as = makeAS(array); // テ・ツーツ湘」ツ?陛」ツ??」ツ?ョテ」ツつづ」ツ?、テ」ツ?湘」ツ?」テ」ツ?ヲ
				a = Math.abs(am - as);
				result[i] = a;
				if(isSolved(result,i)!=-1){
					System.out.print(isSolved(result,i) + " " + result[i] + " " + (i - isSolved(result,i)));
					break;
				}
			}
			
			System.out.println();
		}
		
	}
	
	// テ・ツ、ツァテ」ツ?催」ツ??ゥツ??
	static int makeAM(int[] array){
		int m = 1;
		int am = 0;
		for(int i = array.length-1;i>=0;i--){
			am += array[i]*m;
			m *= 10;
		}
		return am;
	}
	
	// テ・ツーツ湘」ツ?陛」ツ??ゥツ??
	static int makeAS(int[] array){
		int m = 1;
		int am = 0;
		for(int i = 0;i<array.length;i++){
			am += array[i]*m;
			m *= 10;
		}
		return am;
	}

	// テゥツ?催・ツ按療」ツ?ォテ」ツ?敕」ツつ古」ツ?榲」ツつ古・ツ?・テ」ツつ古」ツ?ヲテ」ツ??
	static void makeArray(int[] array,int a){
		for(int i = 0;i<array.length;i++){
			array[i] = a%10;
			a /= 10;
		}
	}
	
	// テ・ツ青古」ツ?佚ヲツ閉ーテ・ツュツ療」ツ?古」ツ?づ」ツつ凝」ツ?凝」ツ?ゥテ」ツ??」ツ?凝・ツ?ィテゥツδィテ」ツ?ソテ」ツ?ヲテ」ツ??
	static int isSolved(int[] result,int n){
		for(int i = 0;i<n;i++){
			if(i!=n && result[i]==result[n]) return i;
		}
		return -1;
	}
}

Measured memory_bytes: 20416
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	long ans = 1;
	
	scanf("%d", &n);
	
	for (i = n; i > 0; i--){
		ans = ans * i;
	}
	
	printf("%ld\n", ans);
	
	return (0);
}

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

using namespace std;

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

    string t = s.substr(0, n / 2);
    if (n % 2 == 0 and s == t + t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N; cin >> N;
vector<int64_t> A(N), absA(N); 
rep(i, 0, N) {
    cin >> A[i];
    absA[i] = abs(A[i]);
}
const int minApos = distance(absA.begin(), min_element(ALL(absA)));


rep(i, 0, minApos){
    if (A[i] < 0){
        A[i] *= -1;
        A[i+ 1] *= -1;
    }
}
Rrep(i, N - 1, minApos + 1){
    if (A[i] < 0){
        A[i] *= -1;
        A[i - 1] *= -1;
    }
}

cout << accumulate(ALL(A), 0LL) << "\n";


}

// 境界，出力文字列 チェック



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define st first
#define nd second
#define PQ priority_queue

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 3e5 + 10;
set<int> m_c;
int col[N];
vector<int> row[N];
int main(){
	int	n ,m, k, ma = 0;
	int x, y;
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 1; i <= k; i++){
		scanf("%d %d", &x, &y);
		row[x].push_back(y);
		col[y]++;
		if(col[y] >= ma) ma = col[y];
	}
	for(int i = 1; i <= m; i++){
		if(col[i] == ma) m_c.insert(i);
	}
	int ans = ma, val = ma;
	ma = 1;
	for(int i = 1; i <= n; i++){
		if((int)row[i].size() >= ma){
			ma = row[i].size();
			int cnt = 0;
			for(auto it: row[i]){
				if(m_c.count(it)) cnt++;
			}
			if(cnt < (int)m_c.size()) ans = ma + val;
			else ans = max(ans, ma + val - 1);
		}
	}
	printf("%d", ans);


}

Measured memory_bytes: 35332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e5+5;
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

int main()
{
	double f1,f2;

	cin>>f1>>f2;


	cout<<f1/f2<<endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
int w1,w2,c,count1,count2;

count1=0;
count2=0;

while(scanf("%d,%d,%d",&w1,&w2,&c)!=EOF){


if(w1==w2/*&&w1*w1+w2*w2!=c*c*/){
count2++;
}
if(w1*w1+w2*w2==c*c/*&&w1!=w2*/){
count1++;
}
}
printf("%d\n%d\n",count1,count2);
return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0;
  cin >> n;
  int a[n],b[n];
  for(int i=0;i<n;i++)a[i]=0;
  for(int i=0;i<n-1;i++)cin >> b[i];
  for(int i=0;i<n;i++){
    if(i==0)a[i]=b[i];
    else if(i==n-1)a[i]=b[i-1];
    else a[i]=min(b[i],b[i-1]);
  }
  sort(a,a+n);
  for(int i=0;i<n;i++)sum+=a[i];
  cout << sum << endl;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() {
  long long n, k;
  cin >> n >> k;
  
  int res = 1;
  long long tmp = k;
  while (tmp <= n) {
    tmp *= k;
    res++;
  }
  
  cout << res << endl;
  
  return 0;
}

    

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
int A, B, C, X, Y;
cin >> A >> B >> C >> X >> Y;

int min_p = min(X, Y);
int max_p = max(X, Y);
ll sum = 0;
if(C * 2 < A + B){
    sum += (C * 2) * min_p;
}else{
    sum += (A + B) * min_p;
}
// print(sum);

int rem = max_p - min_p;

if(X > Y && A <= (C * 2)) sum += A * rem;
else if(X < Y && B <= (C * 2)) sum += B * rem;
else sum += (C * 2) * rem;
 
print(sum);
}

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

constexpr int si = 1001 * 1234;
int n, k, ar[si], a2[si];
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   while (cin >> n)
   {
      for (int i = 1; i <= n; i++) cin >> ar[i];
      int j = 1;
      if (n&1) {//odd
         for (int i = n; 1 <= i; i -= 2) a2[j++] = ar[i];
         for (int i = 2; i <= n; i += 2) a2[j++] = ar[i];
      }else {
         for (int i = n; 1 <= i; i -= 2) a2[j++] = ar[i];
         for (int i = 1; i <= n; i += 2) a2[j++] = ar[i];
      }

      for (int i = 1; i <= n; i++) cout << a2[i] << ' ';
      cout << '\n';
      //auto ans = sol();
      //cout << ans << "\n";
      //break;
   }
   return 0;
}

Measured memory_bytes: 4992
import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
S = list(input())

# A < B < D, A < B < C
# A < D, B < C の間に # が2マス連続にあったらNo
# さらに D < C なら すぬけくんとふぬけくんが入れ替わる必要がある。
# すなわち3マス連続...が続いている必要がある(#が2マス連続ないことも注意)

left = A

if C < D:
    right = D
else:
    right = C
    idx = []
    for i in range(B - 2, D - 1):
        if S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.':
            idx.append(i)
    if not idx:
        print('No')
        exit()
    # print('idx', idx)
    # print('idx', S[idx[0]:idx[0] + 10])
# print('N, A, B, C, D', N, A, B, C, D)
T = S[left - 1:right + 1]
# print('T', T)
for i in range(len(T) - 1):
    if T[i] == '#' and T[i + 1] == '#':
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 6324
/*
Stay innocent, be naive. 
But still dream big. 
Dream big to the point that it is beyond your ability and endeavour to achieve it. 
So dream big and don�t lose your innocence.
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int D = Integer.parseInt(st.nextToken());
         int boof = 2*D+1;
         int res = N/boof;
         if(N%boof > 0)
            res++;
         System.out.println(res);
      }
      public static void sort(int[] arr)
      {
         //stable heap sort
         PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
         for(int a: arr)
            pq.add(a);
         for(int i=0; i < arr.length; i++)
            arr[i] = pq.poll();
      }
   }

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int N,A,B,goukei = 0;
    cin >> N >> A >> B;

    goukei = A * N;

    if(goukei <= B)
        cout << goukei << endl;
    else
    {
        cout << B << endl;
    }
    

    

    

}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <random>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>
#include <unordered_set>
#include <unordered_map>

#include <random>
#include <ctime>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const long double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll M = 1000000007;
const ll LLINF = 1000000000000000000;
const double EPS = 1e-8;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m, t1, t2;
    cin >> n >> m;
    vector<int> cnt(n, 1);
    vector<bool> res(n, false);
    res[0] = true;
    FOR(i, 0, m) {
        cin >> t1 >> t2;
        --t1; --t2;
        if (res[t1]) {
            if (cnt[t1] == 1)
                res[t1] = false;
            res[t2] = true;
        }
        --cnt[t1];
        ++cnt[t2];
    }
    int ans = 0;
    FOR(i, 0, n) {
        if (res[i])
            ++ans;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((int)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos(0))
#define linf (1ll << 60)

#define maxn 100005

ll n, a[maxn], f[maxn];
vector<int> V[maxn];
bool ok = true;
int deg[maxn];

void go(int par, int u){
	if(!ok) return;
	if(deg[u] == 1){
		f[u] = a[u];
		return;
	}

	ll sum = 0;
	Rep(i, sz(V[u])){
		int v = V[u][i];
		if(v == par) continue;
		go(u, v);
		sum += f[v];
		if(f[v] > a[u]){
			ok = false;
			return;
		}
	}
	if(a[u] > sum || a[u] + a[u] < sum){
		ok = false;
		return;
	}
	f[u] = a[u] + a[u] - sum;

}

int main(){

//	freopen("in.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    For(i, 1, n) cin >> a[i];
    Rep(run, n - 1){
    	int u, v;
    	cin >> u >> v;
    	deg[u]++;
    	deg[v]++;
    	V[u].pb(v);
    	V[v].pb(u);
    }

    if(n == 2){
    	if(a[1] == a[2]){
    		cout << "YES" << endl;
    	} else cout << "NO" << endl;
    	return 0;
    }

    int root = 0;
    For(i, 1, n) if(deg[i] != 1){
    	root = i;
    	break;
    }

    go(0, root);
    if(f[root] != 0 || !ok){
    	cout << "NO" << endl;
    } else cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 14336
A,V = [int(i) for i in input().split()]
B,W = [int(i) for i in input().split()]
T = int(input()) 

if V <= W:
    print("NO")
    exit()

L = abs(A-B)
N = V - W
if L <= T*N:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 61704
#include<iostream>
using namespace std;
int main () {
    int x,a,b;
    cin>>x>>a>>b;
    int xa=abs(x-a),xb=abs(x-b);
    if(xa<=xb){
        cout<<"A"<<endl;
    }else{
        cout<<"B"<<endl;
    }
    return 0;
}


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

int main() {
  int N, Y;
  cin >> N >> Y;
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N - i; ++j) {
      if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
        cout << i << ' ' << j << ' ' << N - i - j << '\n';
        return 0;
      }
    }
  }
  cout << "-1 -1 -1\n";
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    int N;cin>>N;
    vector<vector<pair<int,int>>> info(N);
    rep(i,N){
        int A;cin>>A;
        rep(j,A){
            int a,b;cin>>a>>b;
            info.at(i).push_back(make_pair(a-1,b));
        }
    }
    int ans=0;
    rep(bit,1<<N){
        int check[N],flag=0;
        rep(i,N){
            if(bit&(1<<i))check[i]=1;
            else check[i]=0;
        }
        rep(i,N){
            if(bit&(1<<i)){
                rep(j,info[i].size()){
                    if(check[info[i][j].first]==info[i][j].second)continue;
                    else{
                        flag=1;
                        i=N;
                        break;
                    }
                }
            }
        }
        if(flag==0){
            int count=0;
            rep(i,N)if(bit&(1<<i))count++;
            ans=max(ans,count);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
count = 0
a = [0]*(10**5)
for i in range(1, 100):
  for j in range(1, 100):
    for k in range(1, 100):
      a[(i+j+k)**2-(i*j+j*k+i*k)] += 1


for i in range(n):
  print(a[i+1])

Measured memory_bytes: 9876
-- ABC124 B problem
import Control.Monad
import Control.Applicative
import Data.List

-- conversion from String to Int
toInt :: String -> Int
toInt x = read x :: Int

-- obtain [Int] from I/O
getInts :: IO [Int]
getInts = do
  x <- getLine
  let y = (map $ toInt) $ words x
  return y

-- check from head to tail, m : maximum, n : count
check :: Int -> Int -> [Int] -> Int
check n m [] = n
check n m (x:xs) =
  if x >= m then check n x xs
  else check (n-1) m xs

-- main function
main :: IO ()
main = do
  rd <- getLine
  let n = read rd :: Int
  (h:hs) <- getInts
  print (check n h hs)

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
  	int a[n+1];
	int x=100000000;
  	for(int i=0; i<n; i++){
      cin>>a[i];
      int cnt=0;
     while(a[i]%2==0){
       a[i]/=2;
       cnt++;
     }
		x=min(cnt,x);
    }
  cout<<x<<endl;
}

Measured memory_bytes: 256
N, C = gets.split.map &:to_i
D = C.times.map{gets.split.map &:to_i}
c = N.times.map{gets.split.map{|i| i.to_i - 1}}

cost = Array.new(3){Array.new(C){0}}
N.times do |i|
  N.times do |j|
    r = (i+j).modulo(3)
    C.times do |k|
      cost[r][k] += D[c[i][j]][k]
    end
  end
end

ans = 10**9
(0...C).to_a.combination(3) do |comb|
  comb.permutation(3) do |(i, j, k)|
    ans = [ans, cost[0][i] + cost[1][j] + cost[2][k]].min
  end
end
p ans


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

int main() {
  int N; cin >> N;
  vector<int> d(N); for (int i = 0; i < N; i++) cin >> d[i];
  sort(d.begin(), d.end());
  int k = d[0], ans = 1;
  for (int i = 0; i < N; i++) {
    if (d[i] != k) {
      ans++;
      k = d[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;
ll gcd( ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll lcm( ll a, ll b ){
    return a * b / gcd(a,b);
}
ll lcm_n( vector<ll> numbers ) {
	ll l;
	l = numbers.at(0);
	for (ll i = 1; i < numbers.size(); i++) {
		l = lcm(l, numbers.at(i));
	}
	return l;
}
int main (void) {
    ll N, M, ans;
    scanf("%lld %lld", &N, &M);
    vector<ll> a(N),b(N);
    REP(ll,i,0,N){
        scanf("%lld", &a.at(i));
        b.at(i) = a.at(i) / 2;
    }
    ll lcm_b = lcm_n(b);
    REP(int,i,0,N){
      if ( lcm_b % a.at(i) == 0 ){
        printf("0\n");
        return 0;
      }
    }
    ans = ( M / lcm_b + 1 ) / 2;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")
        cout<<"Rainy"<<endl;
    else
        cout<<"Sunny"<<endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,m = LI()
        if n == 0 and m == 0:
            break

        r = I()
        a = [LI() for _ in range(r)]
        q = I()
        b = [LI() for _ in range(q)]
        for s,e,c in b:
            t = 0
            ins = -1
            inc = 0
            for tt,nn,mm,ss in a:
                if mm != c:
                    continue
                if ss == 1:
                    inc += 1
                    if ins < 0:
                        ins = max(tt,s)
                else:
                    inc -= 1
                    if inc == 0:
                        t += max(0, min(e,tt)-ins)
                        ins = -1

            rr.append(t)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9224
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int H, W; cin >> H >> W;
  vector<string> a(H);
  vvi dp(H, vi(W, 0));
  rep(i, H) {
    cin >> a[i];
  }

  dp[0][0] = 1;
  rep(y, H) {
    rep(x, W) {
      if (a[y][x] == '#') continue;
      if (y+1 < H && a[y+1][x] == '.') {
        dp[y+1][x] += dp[y][x];
        dp[y+1][x] %= MOD;
      }
      if (x+1 < W && a[y][x+1] == '.') {
        dp[y][x+1] += dp[y][x];
        dp[y][x+1] %= MOD;
      }
    }
  }
  cout << dp[H-1][W-1] << endl;
  return 0;
}


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

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

    int x = (int) ceil(n / 1.08);

    if (((int) (x * 1.08)) != n) {
        cout << ":(" << endl;
    } else {
        cout << x << endl;
    }
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for(int i = 0; r*i <= n; ++i){
        for(int j = 0; g*j <= n-r*i; ++j){
            if((n-r*i-g*j)%b == 0) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,M;
    cin>>N>>M;
    vector<tuple<int,int,int>> E(M);
    vector<vector<int>> G(N,vector<int>(N,inf));

    REP(i,N) G[i][i] = 0;
    REP(i,M) {
        int a,b,c;
        cin>>a>>b>>c;
        G[a-1][b-1] = min(G[a-1][b-1],c);
        G[b-1][a-1] = min(G[b-1][a-1],c);
        E[i] = make_tuple(a-1,b-1,c);
    }

    REP(k,N) {
        REP(i,N) {
            REP(j,N) {
                G[i][j] = min(G[i][j],G[i][k]+G[k][j]);

            }
        }
    }

    int ans = M;
    REP(i,M) {
        int a = get<0>(E[i]);
        int b = get<1>(E[i]);
        int c = get<2>(E[i]);
        bool used = false;
        REP(j,N) {
            if (G[j][b] == G[j][a] + c) used = true;
        }
        if (used) ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
typedef long long ll;
#include <cmath>

int main(int argc, char *argv[])
{
	string s;
	cin >>s;

	const int l=s.length();

	string ret="Yes";

	for (int i=0,j=l-1;i<j;i++,j--)
	{
		if (s[i]!=s[j]) ret="No";
	}

	for (int i=0,j=(l-3)/2;i<j;i++,j--)
	{
		if (s[i]!=s[j]) ret="No";
	}
	for (int i=(l+1)/2,j=l-1;i<j;i++,j--)
	{
		if (s[i]!=s[j]) ret="No";
	}

	cout<< ret<< endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF=100000000;
const int MOD=1000000007;

int main()
{
 ll n, m, ans=0;
 cin >> n >> m;
 priority_queue<int> q;
  
 for(int i=0;i<n;i++){
   int a;
   cin >> a;
   q.push(a);
 }
  
 for(int i=0;i<m;i++){
   int b, c;
   b=q.top();
   q.pop();
   c=b/2;
   q.push(c);
 }
  
 for(int i=0;i<n;i++) {
   ans+=q.top();
   q.pop();
 } 
  
 cout << ans;
 
 return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define pb push_back
#define eb emplace_back

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    vector<int> dp(n+1,0);
    dp[0] = 1;
    int j = 0;
    rep(i,n){
        if(j<m && i+1==a[j]){
            dp[i+1] = 0;
            j++;
        }
        else if(i==0){
            dp[i+1] = dp[i];
        }
        else{
            dp[i+1] = dp[i]+dp[i-1];
            dp[i+1] %=INF;
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;

struct R{
string y;
int C;
};

int main(){

int N,M;

while(1){

struct R n[101];
cin>>N;if(N==0)break;
cin>>M;
for(int i=0;i<N;i++){
	cin>>n[i].y;cin>>n[i].C;
}
string str;int s=0;
for(int iii=0;iii<M;iii++){
	cin>>str;
	for(int i=0;i<N;i++){bool f=true;
		for(int j=0;j<8;j++)
			if((n[i].y[j]!=str[j])&&n[i].y[j]!='*'){f=false;}//cout<<n[i].y[j]<<"#"<<str[j]<<endl;}
		if(f==true)s+=n[i].C;
	}

}

cout<<s<<endl;



}
return 0;
}

Measured memory_bytes: 1212
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

int main(void) {
    int num;
    cin >> num;
    vector<int> arr(num);
    cins(arr);
    int sum = 0;
    for(int i = 0; i < num; i++) {
        sum = sum ^ arr[i];
    }

    for(int i = 0; i < num; i++) {
        cout << (sum ^ arr[i]);
        cout << (i == num-1 ? '\n' : ' ');
    }
    return 0;
}

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

int main() {
	// your code goes here
	int a,b,i,ans=0;
	cin >> a >> b;
	if(b==1){
		cout << "0" << endl;
	} else {
		a=a-1;
		b=b-1;
		if(b%a==0) cout << b/a << endl;
		else cout << (b-b%a)/a+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
N,M=map(int,input().split())
p=10**9 +7
dog=math.factorial(N)
mon=math.factorial(M)

if N==M:
  ans = ((dog*mon)*2) % p
elif abs(N-M) == 1:
  ans = (dog*mon) % p
else:
  ans=0
print(ans)

Measured memory_bytes: 11080
var lines = [];

var readline = require('readline')
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});


rl.on('line', (x) => {
    lines.push(x)
});

rl.on('close', () => {
    var N = Number(lines[0].split(" ")[0])
    var M = Number(lines[0].split(" ")[1])
    lines.shift()

    var LR = lines.map(i => i.split(" ").map(i => Number(i)));
    var start = 1; var goal = Infinity;

    for (var i = 0; i < M; i++) {
        var l = LR[i][0]; var r = LR[i][1];

        if (goal < l || r < start) { console.log(0); return (0) }
        if (start < l) { start = l; }
        if (r < goal) { goal = r; continue; }

    }

    console.log(goal - start + 1)
});

Measured memory_bytes: 51716
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 1000005;
//
//

struct mi {
    ll v; explicit operator ll() const { return v; }
    mi() { v = 0; }
    mi(ll _v) { 
        v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
        if (v < 0) v += MOD;
    }
    friend bool operator==(const mi& a, const mi& b) { 
        return a.v == b.v; }
    friend bool operator!=(const mi& a, const mi& b) { 
        return !(a == b); }
    friend bool operator<(const mi& a, const mi& b) { 
        return a.v < b.v; }
   
    mi& operator+=(const mi& m) { 
        if ((v += m.v) >= MOD) v -= MOD; 
        return *this; }
    mi& operator-=(const mi& m) { 
        if ((v -= m.v) < 0) v += MOD; 
        return *this; }
    mi& operator*=(const mi& m) { 
        v = v*m.v%MOD; return *this; }
    mi& operator/=(const mi& m) { return (*this) *= inv(m); }
    friend mi pow(mi a, ll p) {
        mi ans = 1; assert(p >= 0);
        for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend mi inv(const mi& a) { assert(a.v != 0); 
        return pow(a,MOD-2); }
        
    mi operator-() const { return mi(-v); }
    mi& operator++() { return *this += 1; }
    mi& operator--() { return *this -= 1; }
    mi operator++(int) { mi temp; temp.v = v++; return temp; }
    mi operator--(int) { mi temp; temp.v = v--; return temp; }
    friend mi operator+(mi a, const mi& b) { return a += b; }
    friend mi operator-(mi a, const mi& b) { return a -= b; }
    friend mi operator*(mi a, const mi& b) { return a *= b; }
    friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};
typedef vector<mi> vmi;
typedef pair<mi,mi> pmi;
typedef vector<pmi> vpmi;
mi facs[MAX];
mi facInvs[MAX];
 
mi choose(mi _a, mi _b) {
    ll a = (ll) _a, b = (ll) _b;
    if (b > a) return 0;
    if (a < 0) return 0;
    if (b < 0) return 0;
    mi cur = facs[a];
    cur = cur * facInvs[b];
    cur = cur * facInvs[a-b];
    return cur;
}
 
void initFacs() {
    facs[0] = 1;
    facInvs[0] = 1;
    for(int i = 1; i < MAX; i++) {
        facs[i] = (facs[i-1] * i);
        facInvs[i] = inv(facs[i]);
    }
}


void solve(){
    int n;
    cin>>n;
    initFacs();
    mi ans = pow((mi)10, n);
    if(n < 2){
        cout<<"0";
        return ;
    }
    ans -= pow((mi)9, n);
    ans -= pow((mi)9, n);
    ans += pow((mi)8, n);
    // ans = choose(n, 2);
    // ans *= pow((mi)9, n-2);
    // ans *= 2;
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 19280
#include <stdio.h>

int main(void)
{
	int X;
	scanf("%d",&X);
	if(X%7==1)printf("fri\n");
	else if(X%7==2)printf("sat\n");
	else if(X%7==3)printf("sun\n");
	else if(X%7==4)printf("mon\n");
	else if(X%7==5)printf("tue\n");
	else if(X%7==6)printf("wed\n");
	else if(X%7==0)printf("thu\n");
	return 0;
}


Measured memory_bytes: 2120
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int n;
ll cost[250000];
int used[250000];

int dh[4] = {1,-1,0,0}, dw[4] = {0,0,1,-1};

void bfs(int src){
	deque<int> dq;
	dq.push_back(src);
	while(!dq.empty()){
		int cur = dq.front();
		int h = cur / n, w = cur % n;
		dq.pop_front();
		rep(i,4){
			int nh = h + dh[i];
			int nw = w + dw[i];
			if(nh < 0 || n <= nh) continue;
			if(nw < 0 || n <= nw) continue;
			int nex = nh * n + nw;
			int nex_cost = cost[cur] + used[cur];
			if(cost[nex] <= nex_cost) continue;
			cost[nex] = nex_cost;
			if(used[cur]) dq.push_back(nex);
			else dq.push_front(nex);
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	int m = n*n;
	rep(i,m){
		cost[i] = min({i/n, i%n, n-1-i/n, n-1-i%n});
		used[i] = 1;
	}
	ll ans = 0;
	rep(i,m){
		int p;
		cin >> p;
		--p;
		ans += cost[p];
		used[p] = 0;
		bfs(p);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6956
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <iomanip>
#include <queue>
#include <map>

int main()
{
	int N, D;
	std::cin >> N >> D;


	std::vector< std::vector<int> > x(N, std::vector<int>(D));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < D; ++j) {
			std::cin >> x[i][j];
		}
	}

	double distance;
	int count =0;
	double distance_in = 0;

	for (int i_a = 0; i_a < N; i_a++) {
		for (int i_b = 0; i_b < N; i_b++) {
			distance = 0;
			distance_in = 0;

			if (i_a == i_b) {

			}
			else {
				for (int j = 0; j < D; ++j) {
					distance_in += pow(x[i_a][j] - x[i_b][j], 2);
				}
			}
			distance = sqrt(distance_in);
//			std::cout << distance << std::endl;
			if (ceil(distance) != floor(distance)) {
				//整数でない
			}
			else if(distance!=0){
				count++;
			}
		}

	}


	
	std::cout << count/2;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    char[][] C;
    int[,] B;
    long ans = 1;
    void solve()
    {
        N = cin.nextint;

        C = new char[2][];
        for (int i = 0; i < 2; i++)
        {
            C[i] = cin.next.ToCharArray();
        }

        int mode = 0;
        for (int i = 0; i < N; i++)
        {
            if (i + 1 < N && C[0][i] == C[0][i + 1])
            {
                if (mode == 0)
                {
                    ans *= 6;
                }
                else if(mode == 1)
                {
                    ans *= 3;
                }
                else
                {
                    ans *= 2;
                }
                mode = 1;
                i++;
            }
            else
            {
                if (mode == 0)
                {
                    ans *= 3;
                }
                else if (mode == 1)
                {
                    ans *= 1;
                }
                else
                {
                    ans *= 2;
                }
                mode = 2;
            }
            ans %= mod;
        }


        WriteLine(ans);
    }

}
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

int main(void){
	int r,D,x2000;
	cin >> r >> D >>x2000;
	long long ans = 0;
	for(int i=0;i<10;i++){
		ans =  r*x2000 - D;
		x2000 = ans;
		cout << ans << endl;
	}
}

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

int main() {
    string s;
    std::cin >> s;
    ll x,y;
    std::cin >> x>>y;
    vector<vector<bool>> dx(8001,vector<bool>(16010,false));
    vector<vector<bool>> dy(8001,vector<bool>(16010,false));
    vector<ll> lx;
    vector<ll> ly;
    ll now = 0;
    bool xnow = true;
    bool first = true;
    for (int i = 0; i < s.size(); i++) {
        if(s[i]=='T'){
            // if(first){
            //     lx.push_back(0);
            //     first = false;
            // }
            
            if(now!=0){
                if(xnow){
                    lx.push_back(now);
                }else{
                    ly.push_back(now);
                }
                now = 0;
            }
            xnow = !xnow;
        }else{
            now++;
        }
    }
    if(now!=0){
        if(xnow){
            lx.push_back(now);
        }else{
            ly.push_back(now);
        }
        now = 0;
    }
    
    // for (auto e : lx) {
    //     std::cout << e << std::endl;
    // }
    
    dx[0][8001] = true;
    for (int i = 0; i < lx.size(); i++) {
        if(i==0 && s[0] == 'F'){
            dx[1][lx[i]+8001] = true;
            continue;
        }
        for (int j = 0; j <= 16001; j++) {
            if( j-lx[i]>=0 ){
                dx[i+1][j] = dx[i+1][j] || dx[i][j-lx[i]];
            }
            if( j+lx[i]<=16001){
                dx[i+1][j] = dx[i+1][j] || dx[i][j+lx[i]];   
            }
        }
    }
    dy[0][8001] = true;
    for (int i = 0; i < ly.size(); i++) {
        for (int j = 0; j <= 16001; j++) {
            if( j-ly[i]>=0 ){
                dy[i+1][j] = dy[i+1][j] || dy[i][j-ly[i]];
            }
            if( j+ly[i]<=16001){
                dy[i+1][j] = dy[i+1][j] || dy[i][j+ly[i]];
            }
        }
    }
    // std::cout << dx[lx.size()][x+8001] << std::endl;
    // std::cout << dy[ly.size()][y+8001] << std::endl;
    if(dx[lx.size()][x+8001] && dy[ly.size()][y+8001]){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 34432
n,x = map(int, input().split())
l = list(map(int, input().split()))
d = [0]*(n+1)
for i in range(1,n+1):
    d[i]=d[i-1]+l[i-1]

cnt = 0
for i in range(n+1):
    if d[i]<=x:
        cnt += 1
    else:
        break
print(cnt)


Measured memory_bytes: 3060
l=[]
for i in range(3):
  l.append(list(map(int,input().split())))
ch=[]
for i in l:
  ch.append([i[0]-i[1],i[1]-i[2]])
if ch[0]==ch[1] and ch[1]==ch[2]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 65988