akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	int n, h;
	cin >> n >> h;
	priority_queue<pair<int, bool>> p;
	FOR(i, 1, n) {
		int a, b;
		cin >> a >> b;
		p.push(MP(a, 1));
		p.push(MP(b, 0));
	}
	int cnt = 0;
	ll sum = 0;
	while (1) {
		if (p.top().second) {
			cnt += (h - sum + p.top().first - 1) / p.top().first;
			pv(cnt);
			return 0;
		}
		else {
			cnt++;
			sum += p.top().first;
			if (h <= sum) {
				pv(cnt);
				return 0;
			}
			p.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
int main() {
	int N;
	scanf("%d", &N);
	struct Material {
		int a, b;
	} mat[3];
	for (int i = 0; i < 3; ++i) scanf("%d", &mat[i].a);
	for (int i = 0; i < 3; ++i) scanf("%d", &mat[i].b);
	sort(mat, mat + 3, [](Material& x, Material& y) {
		return x.a - x.b < y.a - y.b;
	});
	if (mat[1].b < mat[1].a) {
		// (mat[1].a - mat[1].b) / mat[1].b
		if ((mat[1].a - mat[1].b) * mat[2].b > (mat[2].a - mat[2].b) * mat[1].b)
			swap(mat[1], mat[2]);
	}
	ll ans = 0;
	for (int i = 0; i <= 5000; ++i)
		for (int j = 0; j <= 5000; ++j) {
			ll n = N;
			if (mat[0].a <= mat[0].b) {
				if (mat[0].a * i > n) continue;
				n -= mat[0].a * i;
			}
			if (mat[1].a <= mat[1].b) {
				if (mat[1].a * j > n) continue;
				n -= mat[1].a * j;
			}
			if (mat[2].a <= mat[2].b) {
				n += (mat[2].b - mat[2].a) * (n / mat[2].a);
			}
			if (mat[0].a <= mat[0].b) {
				n += mat[0].b * i;
			} else {
				if (mat[0].b * i > n) continue;
				n -= mat[0].b * i;
			}
			if (mat[1].a <= mat[1].b) {
				n += mat[1].b * j;
			} else {
				if (mat[1].b * j > n) continue;
				n -= mat[1].b * j;
			}
			if (mat[2].a > mat[2].b) {
				n += (mat[2].a - mat[2].b) * (n / mat[2].b);
			}
			if (mat[0].a > mat[0].b) {
				n += mat[0].a * i;
			}
			if (mat[1].a > mat[1].b) {
				n += mat[1].a * j;
			}
			ans = max(ans, n);
		}
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
N = int(input())
G = [[0]*N for _ in range(N)]

for i in range(N):
    for j in range(N):
        if i!=j:
            G[i][j] = 1
            G[j][i] = 1

if N%2==0:
    for i in range(N):
        G[i][N-1-i] = 0
        
    print(N*(N-1)//2-N//2)
    
    for i in range(N):
        for j in range(i+1, N):
            if G[i][j]==1:
                print(i+1, j+1)
else:
    for i in range(N-1):
        G[i][N-2-i] = 0
        
    print(N*(N-1)//2-(N-1)//2)
    
    for i in range(N):
        for j in range(i+1, N):
            if G[i][j]==1:
                print(i+1, j+1)

Measured memory_bytes: 74320
n=int(input())
t=list(map(int,input().split()))
m=int(input())
ans=[]
for _ in range(m):
	p,x=map(int,input().split())
	tem=t[p-1]
	t[p-1]=x
	ans.append(sum(t))
	t[p-1]=tem

for i in ans:
	print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll x, a;
  cin >> x >> a;
  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

INF = float('inf')

N, M = map(int, input().split())
adjL = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    adjL[a].append(b)
    adjL[b].append(a)

# 単一始点最短経路を求める（Dijkstra法）
def Dijkstra(adjList, vSt):
    numV = len(adjList)
    numUsed = 0
    costs = [INF] * numV
    costs[vSt] = 0
    prevs = [None] * numV
    PQ = []
    heappush(PQ, (0, vSt))
    while PQ:
        cNow, vNow = heappop(PQ)
        if cNow > costs[vNow]: continue
        numUsed += 1
        if numUsed == numV: break
        for v2 in adjList[vNow]:
            c2 = cNow + 1
            if c2 < costs[v2]:
                costs[v2] = c2
                prevs[v2] = vNow
                heappush(PQ, (c2, v2))
    return (costs, prevs)

costs, prevs = Dijkstra(adjL, 0)

#print('costs:', costs)
#print('prevs:', prevs)

print('Yes')
print('\n'.join(map(lambda x: str(x+1), prevs[1:])))


Measured memory_bytes: 42188
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
	int x,y,z,n,i;
	scanf("%d%d%d",&x,&y,&z);
    	n=(x-z)/(y+z);
	printf("%d\n",n);
    
		return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<int>power(h + 2);
    power[0] = 1;
    for(int i = 1; i < h; i++){
        power[i] = power[i - 1] * 2;
    }
    char ch;
    int val[h + 2][w + 2];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> ch;
            val[i][j] = ch - '0';
        }
    }
    int ans = h * w;
    for(int x = 0; x < power[h - 1]; x++){
        int p = 1, cnt = 0;
        int dp[h + 2][w + 2];
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i == 0){
                    dp[i][j] = val[i][j];
                }
                else if(((1 << (i - 1)) & x) != 0){
                    dp[i][j] = val[i][j];
                }
                else{
                    dp[i][j] = dp[i - 1][j] + val[i][j];
                }
                if(dp[i][j] > k){
                    p = 0;
                }
            }
            if(i > 0 && (((1 << (i - 1)) & x) != 0)){
                cnt++;
            }
        }
        if(p == 0){
            continue;
        }
        int pref[h + 2][w + 2];
        for(int j = 0; j < w; j++){
            int p = 1;
            for(int i = 0; i < h; i++){
                if(j == 0){
                    pref[i][j] = dp[i][j];
                }
                else{
                    pref[i][j] = pref[i][j - 1] + dp[i][j];
                }
                if(pref[i][j] > k){
                    p = 0;
                }
            }
            if(p == 0){
                cnt++;
                for(int i = 0; i < h; i++){
                    pref[i][j] = dp[i][j];
                }
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;

const ll INF = 1e+3;
const int MAX_N = 100;
ll cost[MAX_N][MAX_N];
ll d[MAX_N];
bool used[MAX_N];
ll V;
vector<ll> H;

void dijkstra(ll s){
  fill(d, d+V, INF);
  fill(used, used+V, false);
  fill(cost[0], cost[MAX_N], INF);
  d[s] = 0;

  for (ll i = 0; i < V; i++)
  {
    cost[i][i+1] = abs(H[i] - H[i+1]);
    cost[i][i+2] = abs(H[i] - H[i+2]);
  }

  while (true)
  {
    int v = -1;
    for (int u = 0; u < V; u++)
    {
      if(!used[u] && (v == -1 || d[u] < d[v])) v=u;
    }
    if (v == -1) break;
    used[v] = true;

    for (int u = 0; u < V; u++)
    {
      d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }
}

void solve_dijkstra(long long N, std::vector<long long> h){
  V = N;
  H = h;
  dijkstra(0);
  cout << d[V-1] << endl;
}

ll dfs(ll i){
  if(dp[i] >= 0) return dp[i];
  ll d1, d2;
  d1 = abs(H[i] - H[i-1]);
  if (i == 1) return d1;
  d2 = abs(H[i] - H[i-2]);
  if (i == 2) return d2;
  dp[i] = min(dfs(i-1) + d1, dfs(i-2) + d2);
  return dp[i];
}

void solve(long long N, std::vector<long long> h){
  H = h;
  dp = vector<ll> (N+1, -1);
  cout << dfs(N-1) << endl;
}

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


Measured memory_bytes: 4992
#include <cstdio>
#include <vector>
using namespace std;
int n,m,x,ans=0x7fffffff;
int c[15],a[15][15];
int main(){
	scanf("%d%d%d",&n,&m,&x);
	for(int i=1;i<=n;++i){
		scanf("%d",c+i);
		for(int j=1;j<=m;++j){
			scanf("%d",a[i]+j);
		}
	}
	for(int i=0;i<(1<<n);++i){
		int t=i,sum=0;
		vector<int>v(m+1,0);
		for(int j=0;j<n;++j){
			if(t&1){
				for(int k=1;k<=m;++k){
					v[k]+=a[j+1][k];
				}
				sum+=c[j+1];
			}
			t>>=1;
		}
		int j;
		for(j=1;j<=m;++j){
			if(v[j]<x)break;
		}
		if(j>m){
			ans=(sum<ans?sum:ans);
		}
	}
	if(ans==0x7fffffff)printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3244
if __name__ == '__main__':


    while True:

        a,b = map(str,raw_input().split(' '))

        if a == '0' and b == '0':
            break

      #  print a,b

        a = list(a)
        b = list(b)
    #    print a


        br = 0
        hit = 0
        for i,data in enumerate(b):

            if data in a:
                if a[i] == data:
                    hit += 1

                else:
                    br += 1

        print hit,br

Measured memory_bytes: 4216
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    int ans = 0;
    int pre = 0;
    rep(i,n){
        int a;
        cin >> a;
        a += pre;
        ans += a/2;
        pre = a%2;
        if(a == 1) pre = 0;
    }
    cout << ans << endl;
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	char a;cin >> a;
	if(a=='A' || a=='T'){
		if(a=='T') cout << 'A' << endl;
		else cout << 'T' << endl;
	}
	else{
		if(a=='C') cout << 'G' << endl;
		else cout << 'C' << endl;
	}
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(S):
    if S != "".join(reversed(S)):
        return "No"
    s1 = S[0:(len(S)-1)//2]
    if s1 != "".join(reversed(s1)):
        return "No"
    s2 = S[(len(S)+1)//2:]
    if s2 != "".join(reversed(s2)):
        return "No"
    return "Yes"


if __name__ == "__main__":

    # S
    #
    S = input()
    ans = solv(S)

    print(ans)


Measured memory_bytes: 3060
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int, input().split())) for l in range(D)]
last = [0]*26

def score_down(d):
    ans = 0
    for i in range(26):
        ans += c[i]*(d - last[i])
    return ans

for d in range(D):
    score = [(s[d][i] - score_down(d+1)) for i in range(26)]
    t = score.index(max(score))
    print(t+1)
    last[t] = d+1

Measured memory_bytes: 9304
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

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

var (
	goods [3000][3000]int
)

func main() {
	defer flush()

	R := readInt()
	C := readInt()
	K := readInt()
	for i := 0; i < K; i++ {
		r := readInt() - 1
		c := readInt() - 1
		v := readInt()
		goods[r][c] = v
	}

	n := make([]int, C+1)
	c := make([]int, 4)
	for i := 0; i < R; i++ {
		for k := 0; k < 4; k++ {
			c[k] = 0
		}
		c[0] = n[0]
		for j := 0; j < C; j++ {
			for k := 2; k >= 0; k-- {
				c[k+1] = max(c[k+1], c[k]+goods[i][j])
			}
			for k := 0; k < 4; k++ {
				n[j] = max(n[j], c[k])
			}
			c[0] = max(c[0], n[j+1])
		}
	}

	result := -1
	for k := 0; k < 4; k++ {
		result = max(result, c[k])
	}

	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 76188
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int n,m,x,ans,y,h[100001];
bool v[100001];
int main(void)
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&h[i]);
    
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        if(h[x]>h[y]) v[y]=1;
        else if(h[x]<h[y]) v[x]=1;
        else v[x]=1,v[y]=1;
    }
    
    for(int i=1;i<=n;i++)
    {
        if(!v[i]) ans++;
    }
    printf("%d",ans);
    return 0;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 1000000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  if(N == 2){
    cout << 1 << endl;
    return 0;
  } 
  if(A > B){
    swap(A,B);
  }
  /*if(A == N / 2 && B == N / 2 + 1 && N % 2 == 0){
    cout << N / 2 << endl;
    return 0;
  }
  if(A == N / 2 + 1 && B == N / 2 + 2 && N % 2 == 1){
    cout << N / 2 << endl;
    return 0;
  }*/
  if((A - B) % 2 == 0){
    cout << abs(A-B) / 2 << endl;
    return 0;
  }else{
    ll ans = INF;
    ans = min(ans,A + abs((1-(B-A))/2));
    ans = min(ans,(N-B)+abs((A+(N-B) - N - 1)/2));
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    val cities = (0 until m).map { i ->
        val (p, y) = readLine()!!.split(' ').map { it.toInt() }
        Triple(i, p, y)
    }

    val prefectures = IntArray(n + 1) { 0 }
    val ids = Array(m) { "" }

    cities.sortedBy { it.third }.forEach {
        prefectures[it.second]++
        val id1 = it.second.toString().padStart(6, '0')
        val id2 = prefectures[it.second].toString().padStart(6, '0')
        ids[it.first] = id1 + id2
    }

    ids.forEach { println(it) }
}


Measured memory_bytes: 94044
#include <iostream>
#include <cstdio>
#include <algorithm>
#define LL long long

using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        LL a[100005];
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
        }
        sort(a,a+n);
        int flag=0;
        int j=0;
        LL ans=1;
        for(int i=n-1;i>=1;i--)
        {
            if(a[i]==a[i-1])
            {
                ans=ans*a[i];
                j++;
                i--;
                if(j>1)
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag)
        {
            printf("%lld\n",ans);
        }
        else
        {
            printf("0\n");
        }
    }
    return 0;
}


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

int main()
{

	int n, num;
	vector< long int > a;

	while( 1 ) {

		int Max = -1000001;

		cin >> n;
		if( n == 0 ) break;

		a.push_back( 0 );

		for( int i = 0; i < n; i++ ) {
		
			cin >> num;
			a.push_back( num );
			
		}

		//?????§???
		for( int i = 1; i <= n; i++ ) {
		
			a[i - 1] + a[i] > a[i] ? a[i] = a[i - 1] + a[i] : a[i] = a[i];

			if ( a[i] > Max ) {
				Max = a[i];
			}
		
		}

		cout << Max << endl;

		a.clear();
	
	}

	return 0;

}

Measured memory_bytes: 1268
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0;i<n;i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    int ans = Math.abs(a[0] - a[n-1]);
    System.out.println(ans);
  }
}


Measured memory_bytes: 36024
K = int(input())
A, B = map(int, input().split())

is_ok = False
# A以上B以下の要素xについて
for x in range(A, B + 1):
    # x が K の倍数であれば is_ok = True
    if x % K == 0:
        is_ok = True

print("OK" if is_ok else "NG")

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

int S[100000];

bool check(int left,int right,int t){
  if(left+1 == right) return 0;
  int mid = (left+right)/2;
  if(S[mid] == t || S[left] == t) return 1;
  if(S[mid] < t) check(mid,right,t);
  else check(left,mid,t);
}

signed main(){

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    cin >> S[i];
  }
  sort(S,S+n);
  int q; cin >> q;
  int ans = 0;
  for(int i = 0; i < q; i++){
    int t; cin >> t;
    ans += check(0,n,t);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3168
str = input().split()

a = int(str[0])
b = int(str[1])
c = int(str[2])

result1 = a+b
result2 = b+c
result3 = c+a

min = result1

if result2 <= min:
  min = result2
  
if result3 <= min:
  min = result3
  
print(min)

Measured memory_bytes: 3060
query=[int(x) for x in input().split()]
N = query[0]
K = query[1]
L = list()
L = [int(x) for x in input().split()]



def prob(x):
    out = 0.0

    out = (x+1)/2

    return out


# final = 0.0
# answer=list()
# for i in range(0, N):
#     final=0.0
#     for j in range(i, K+i):
#         if K+i<=N:
#             div = L[j]
#             final = final + prob(div)
#     answer.append(final)
#
# print("%14.12f"%max(answer))


res=0.0
tres=0.0
for i in range(0,K):
    tres+=prob(L[i])
    res=max(res,tres)
rindex=K
lindex=0
while rindex<N:
    tres=tres-prob(L[lindex])+prob(L[rindex])
    rindex+=1
    res=max(res,tres)
    lindex+=1
print("%14.12f"%res)

Measured memory_bytes: 24684
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int dp[200010];
vector<pair<int,int>> v;
int main(){
	cout.precision(30);
	int i,n,x1,x2,y1,y2,inf = 1000000000;
	cin >> x1 >> y1 >> x2 >> y2 >> n;
	if(x1>x2){
		swap(x1,x2); swap(y1,y2);
	}
	int ymx = max(y1,y2),ymn = min(y1,y2);
	for(i=0;i<n;i++){
		int a,b;
		cin >> a >> b;
		if(x1<= a && a<=x2 && ymn<=b && b<=ymx) v.push_back({a,b});
	}
	sort(v.begin(),v.end());
	for(i=0;i<=v.size();i++) dp[i] = inf;
	if(y2>=y1){
		for(i=0;i<v.size();i++){
			int l = -1,r = v.size() + 1;
			while(r - l>1){
				int mid = (l + r)/2;
				if(dp[mid]>v[i].second) r = mid;
				else l = mid;
			}
			dp[r] = v[i].second;
		}
	}else{
		for(i=(int)v.size() - 1;i>=0;i--){
			int l = -1,r = v.size() + 1;
			while(r - l>1){
				int mid = (l + r)/2;
				if(dp[mid]>v[i].second) r = mid;
				else l = mid;
			}
			dp[r] = v[i].second;
		}
	}
	int j = 0;
	for(i=0;i<=v.size();i++){
		if(dp[i]!=inf) j = i + 1;
	}
	long double ans = (ymx - ymn + x2 - x1)*100LL,pi = 3.1415926535;
	ans -= 5*j*(4 - pi);
	if(j==min(ymx - ymn,x2 - x1) + 1) ans += 5*pi;
	cout << ans << endl;
}

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


int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i*i <= n; i++){
        ans = max(ans, i*i);   

    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N, L = map(int, input().split())
ans = N * (L - 1) + N * (N + 1) // 2
if L * (L + N - 1) < 0:
    print(ans)
elif L < 0:
    ans -= (L + N - 1)
    print(ans)
else:
    ans -= L
    print(ans)


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

int main() {
  
  int A=0, B=0;
  
  cin >> A >> B;
  
  if(A==B) {
    
    cout << 2*A << endl;
    
  } else {
    
    int ans = 2*max(A, B)-1;
    
    cout << ans << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = int64_t;

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

void solve(){
    int n;
    cin >> n;
    ll a[n], b[n];
    rep(i, n){
        cin >> a[i];
        b[i] = a[i] - (i+1);
    }
    sort(b, b+n);

    ll x = b[n/2];
    ll res = 0;
    for(int i = 0; i < n; i++){
        res += abs(a[i] - x - (i+1));
    }
    cout << res << endl;
}

int main(){
    solve();
    return 0;
}

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

int w,h,n,m,i,x,y,z,xx,yy;
struct data{
    int x,y,z;
} a[200100];
int t[200100],p[200100],s[3][200100],ww[200100][3],num[3],res[300100];
char ch;
vector <int> v;

bool cmp(int u,int v) {
    return (a[u].x+a[u].y<a[v].x+a[v].y) || (a[u].x+a[u].y==a[v].x+a[v].y && a[u].y<a[v].y);
}

bool cmp1(int x,int y) {
    return (res[x]<res[y]) || (res[x]==res[y] && x<y);
}

void cal2() {
    //cout << "----- " << m << endl;
    num[0]=num[1]=0;
    for (int i=1;i<=m;++i) {
        s[a[p[i]].z][++num[a[p[i]].z]]=p[i];
        ww[i][0]=num[0]; ww[i][1]=num[1];
    }

    for (int i=1;i<=m;++i) {
        //cout << "** " << p[i] << endl;
        x=ww[i-1][1];
        y=num[0]-ww[i][0];
        z=a[p[i]].z;
        xx=yy=min(x,y);
        if (z==0 && x>xx) xx++;
        if (z==1 && y>yy) yy++;

        x=x-xx+1; y=ww[i][0]+yy;
        x=s[1][x]; y=s[0][y];
        if ((xx+yy)%2==1) z=1-z;
        //cout << x << " " << y << " " << z << endl;
        //cout << xx << " " << yy << endl;

        if (xx+yy>0) {
            res[p[i]]+=a[y].y-a[x].y;
            //cout << res[p[i]] << endl;
            if (z==0) res[p[i]]+=h+1-a[x].x;
                else res[p[i]]+=w+1-a[y].y;
            //cout << res[p[i]] << endl;
        }
        else {
            if (z==0) res[p[i]]+=h+1-a[p[i]].x;
                else res[p[i]]+=w+1-a[p[i]].y;
        }
    }
}

void cal() {
    if ((a[v[0]].x+a[v[0]].y)%2==1) {
        for (int i=0;i<v.size();++i) {
            if (a[v[i]].z==0) a[v[i]].x++;
                else a[v[i]].y++;
            res[v[i]]++;
            if (i>0 && a[v[i]].z==0 && a[v[i-1]].x==a[v[i]].x && a[v[i-1]].y==a[v[i]].y)
                swap(a[v[i]].z,a[v[i-1]].z);
        }
    }

    m=0;
    for (int i=0;i<v.size();++i)
        if (a[v[i]].x%2==0 && a[v[i]].x<=h && a[v[i]].y<=w) p[++m]=v[i];
    if (m>0) cal2();

    m=0;
    for (int i=0;i<v.size();++i)
        if (a[v[i]].x%2==1 && a[v[i]].x<=h && a[v[i]].y<=w) p[++m]=v[i];
    if (m>0) cal2();
}

int main() {
    /*freopen("ant.inp","r",stdin);
    freopen("ant.out","w",stdout);//*/

    scanf("%d %d %d",&w,&h,&n);
    for (i=1;i<=n;++i) {
        scanf("%d %d %c\n",&a[i].y,&a[i].x,&ch);
        if (ch=='E') a[i].z=1;
            else a[i].z=0;
        t[i]=i;
    }

    sort(t+1,t+1+n,cmp);

    for (i=1;i<=n;++i) {
        v.push_back(t[i]);
        if (i==n || a[t[i]].x+a[t[i]].y!=a[t[i+1]].x+a[t[i+1]].y) {
            cal();
            v.clear();
        }
    }
    for (i=1;i<=n;++i) t[i]=i;
    sort(t+1,t+1+n,cmp1);
    //for (i=1;i<=n;++i) printf("%d ",res[i]); cout << endl;
    for (i=1;i<=n;++i) printf("%d\n",t[i]);
}



Measured memory_bytes: 11512
use std::io;
use std::io::Read;

fn main() {
    let mut buffer = String::new();

    io::stdin().read_to_string(&mut buffer).unwrap();

    let mut lines = buffer.lines();

    let l1 = lines.next().unwrap();
    let l2 = lines.next().unwrap();

    let l1_vec = l1.split_whitespace().map(|s|s.parse::<i64>().unwrap()).collect::<Vec<i64>>();

    let n = l1_vec[0];
    let k = l1_vec[1];

    if k > n {
        println!("0");
        return
    }

    let mut l2_arr = l2.split_whitespace().map(|s|s.parse::<i64>().unwrap()).collect::<Vec<i64>>();

    if k > 0 {
//        l2_arr.sort_by(|a, b| b.cmp(a));
        l2_arr.sort();
        for _x in 0..k {
            l2_arr.pop();
//            l2_arr.remove(0);
        }
    }

    let mut sum = 0;

    for x in l2_arr {
        sum += x
    }

    println!("{}", sum);
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
double pi = 3.141592653589793238;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};


ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout<<setprecision(10);
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll ans = 0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        ans++;
    }
    cout<<ans;
    
    
} 

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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

const int N = 1e5 + 5;
const ll p = 1e9 + 7;

ll cnt[26] = {};

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	for (int i=1; i<=n; i++) {
		char cur;
		cin >> cur;
		cnt[cur - 'a']++;
	}
	ll ans = 1;
	for (int i=0; i<26; i++) {
		ans = (ans * (cnt[i] + 1)) % p;
	}
    ans--;
    if (ans < 0) ans += p;
	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import math


def main():
    n = int(input())
    mod = 1000000007
    zeroes = 0
    counter = defaultdict(lambda: defaultdict(int))
    for _ in range(n):
        x, y = [int(x) for x in input().split()]

        if x == y == 0:
            zeroes += 1
            continue

        denominator = math.gcd(x, y)
        x, y = x // denominator, y // denominator

        if y < 0:
            # quadrant III, IV -> I, II
            x, y = -x, -y

        if x <= 0:
            # round 90° from quadrant II to I
            x, y = y, -x
            counter[(x, y)][1] += 1
        else:
            counter[(x, y)][0] += 1

    ans = 1
    for v in counter.values():
        now = 1
        now += pow(2, v[0], mod) - 1
        now += pow(2, v[1], mod) - 1
        ans = ans * now % mod
    ans += zeroes
    ans -= 1  # choose no fish
    return ans % mod


if __name__ == '__main__':
    print(main())


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

int n,a[200010],c[200010];
long long ans,b;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		c[i]=a[i]-i;
	}
	sort(c+1,c+1+n);
	if(n%2)
	b=c[(n+1)/2];
	else
	b=c[n/2];
	for(int i=1;i<=n;++i)
	ans+=abs(a[i]-(b+i));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ll  unsigned long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	//#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	
	void solve()
	{
		ll k;
		cin>>k;
		set<ll> pq;
		ll er=7%k;
		ll i=1;
		while(er!=0)
		{
			 er=(10*er+7)%k;
				i++;
			// if(temp%k==1)
			// {
			// 	cout<<i<<endl;
			// 	return;
			// }
			if(pq.count(er))
			{
				cout<<"-1"<<endl;
				return;
			}	
			pq.insert(er);

		}
		cout<<i<<endl;
		//cout<<"-1"<<endl;

	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	


Measured memory_bytes: 50496
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    cout << "ABC";
    if (n < 10)
        cout << "00";
    else if (n < 100)
        cout << "0";
    cout << n << endl;
}


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

int main(){
  int N,K,S;
  cin >> N >> K >> S;
  for(int i=0;i<K;i++){
    cout << S ;
    if(i<N-1)
      cout << " ";
  }
  for(int i=K;i<N;i++){
    cout << (S==1000000000?1:S+1);
    if(i<N-1)
      cout << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  
  long long L[N];
  for(int i = 0; i < N; i++) scanf("%lld", L + i);
  
  int t = 0;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      for(int k = j + 1; k < N; k++){
        if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
        if(L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]){
          ++t;
        }
      }
    }
  }
  
  printf("%d\n", t);
  
  return 0;
}

Measured memory_bytes: 1732
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskDecayed solver = new TaskDecayed();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskDecayed {
        public static TaskDecayed.V[] vertices;
        public static TaskDecayed.E[] edges;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            vertices = new TaskDecayed.V[N];
            edges = new TaskDecayed.E[M];
            for (int i = 0; i < N; i++) {
                vertices[i] = new TaskDecayed.V(i + 1);
            }
            for (int i = 0; i < M; i++) {
                edges[i] = new TaskDecayed.E(in.nextInt(), in.nextInt(), i);
            }

            long res[] = new long[M + 1];
            long Nlong = N;
            res[M] = Nlong * (Nlong - 1) / 2l;
            for (int i = M - 1; i >= 0; i--) {
                res[i] = res[i + 1] - union(edges[i].v1, edges[i].v2);
            }
            if (res[0] != 0)
                throw new RuntimeException("Diff");
            for (int i = 1; i <= M; i++) {
                out.println(res[i]);
            }
        }

        private long union(TaskDecayed.V v1, TaskDecayed.V v2) {
            TaskDecayed.V rootV1 = findRoot(v1);
            TaskDecayed.V rootV2 = findRoot(v2);
            if (rootV1 == rootV2)
                return 0;
            if (rootV1.rank < rootV2.rank) {
                TaskDecayed.V tmp = rootV1;
                rootV1 = rootV2;
                rootV2 = tmp;
            }
            if (rootV1.rank == rootV2.rank)
                rootV2.rank++;
            long res = rootV1.nb * rootV2.nb;
            rootV1.parent = rootV2;
            rootV2.nb += rootV1.nb;
            return res;
        }

        private TaskDecayed.V findRoot(TaskDecayed.V v) {
            if (v.parent == null)
                return v;
            v.parent = findRoot(v.parent);
            return v.parent;
        }

        public static class V {
            int id;
            int rank;
            long nb;
            TaskDecayed.V parent;

            public V(int id) {
                this.id = id;
                this.rank = 1;
                this.nb = 1;
            }

        }

        public static class E {
            TaskDecayed.V v1;
            TaskDecayed.V v2;
            int id;

            public E(int id1, int id2, int id) {
                this.v1 = vertices[id1 - 1];
                this.v2 = vertices[id2 - 1];
                this.id = id;
            }

        }

    }
}



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

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

    vector<long long> A(n-1);
    vector<long long> B(n);
    for(int i=0; i<n-1; i++){
        cin >> A.at(i);
        B.at(A.at(i)-1)++;
    }

    for(int i=0; i<n; i++){
        cout << B.at(i) << endl;
    }
}


Measured memory_bytes: 6412
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
const int mxN = 2e5 + 7;
vector<int> adj[mxN];
bool visited[mxN];
int color[mxN];

void dfs(int n, int col){
    if(!visited[n]){
        visited[n] = 1;
        color[n] = col;
        for(auto neigh : adj[n]) dfs(neigh,col);
    }
}

void solve(){
    int n,m; cin >> n >> m;
    FOR(m){
        int a,b; cin >> a >> b;
        --a,--b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    FOR(n) dfs(i,i+1);
    unordered_map<int,int> mp;
    for(int x : color) ++mp[x];
    int maxx = 0;
    for(auto x : mp) if(x.first) maxx = max(maxx,x.second);
    cout << maxx;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 21816
program BegD
  implicit none
  integer(8) :: H, cnt
  integer(8) ::i                                                                              

  read(*,*) H
  i=0
  cnt=0
  if (H.eq.1) then
     print *, "1"
     stop
  endif
  do
     i=i+1
     H=H/2
     cnt=cnt+2**(i-1)
     if(H.eq.1) goto 500
  enddo
500 continue

  print*, cnt+2**i


end program BegD


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back
 
#define N 200010
#define MOD 1000000007


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int a, b;
	cin >> a >> b;
	a -= 1, b -= 1;
	if(b % a == 0)
		cout << b /a;
	else
		cout << b / a + 1;
 	return 0;
}

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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"NO\n"
#define CY cout<<"YES\n"

using namespace std;
using ll = long long;
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
// #define MAXN 1000001 
// ll sieve[MAXN]; 
// void makesieve()
// {
//     sieve[1] = 1; 
//     for (int i = 2; i < MAXN; i++) 
//         sieve[i] = i; 
//     for (int i = 4; i < MAXN; i += 2) 
//         sieve[i] = 2; 
//     for (int i = 3; i * i < MAXN; i++) { 
//         if (sieve[i] == i) { 
//             for (int j = i * i; j < MAXN; j += i) 
//                 if (sieve[j] == j) 
//                     sieve[j] = i; 
//         } 
//     } 
// }
ll powerflow(ll x, ll n)
{
    ll res;
    if (n == 0) {
        return 1;
    }
    res = powerflow(x, n-1);             // recurse
    if(INT_MAX / res < x) {          // check for overflow
        return -1; //LONG_MAX;
    }
    return x * res;
}
ll mod=1000000007;
ll power(ll a,ll b,ll m)
{
    ll res=1;
    while(b!=0)
    {
        if(b&1)
        res=(res%mod*a%mod)%mod;
        b=b/2;
        a=(a%mod*a%mod)%mod;
    }
    return res;
}
struct compare  
 {  
   bool operator()(const int& l, const int& r)  
   {  
       return l > r;  
   }  
 };
 ll recur(int n)
 {
    if(n==0) return 1;
    if(n<=2) return 0;
    ll ans=0;
    for(int i=3;i<=9;i++)
        ans+=recur(n-i);
    return ans;

 }
void solve()
{
    ll n; cin>>n;
    if(n==1) cout<<"0\n";
    else
    {
        ll k1=power(10,n,mod),k2=power(8,n,mod);
        ll k3=power(9,n,mod);
        k3=(k3*2+mod)%mod;
        ll ans=(k1-k3+mod)%mod;
        ans=(ans+k2+mod)%mod;
        cout<<ans;
    }
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
    //cin>>t;
    while(t--)
        {solve();}
    return 0;
}

Measured memory_bytes: 3604
<?php
list($n) = ints();
$a = ints();
$num = gcdAll($a);
$ans = 0;
while ($num % 2 === 0) {
    $ans++;
    $num /= 2;
}
echo $ans;

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}

// 最大公約数（2つ）
function gcd($m, $n)
{
    if (!$n) return $m;
    return gcd($n, $m % $n);
}

// 最大公約数（3つ以上）
function gcdAll($arr)
{
    $gcd = array_pop($arr);
    foreach ($arr as $a) {
        $gcd = gcd($gcd, $a);
    }
    return $gcd;
}

// 最小公倍数（2つ）
function lcm($m, $n)
{
    return $m * $n / gcd($m, $n);
}

// 最小公倍数（3つ以上）
function lcmAll($arr)
{
    $lcm = array_pop($arr);
    foreach ($arr as $a) {
        $lcm = lcm($lcm, $a);
    }
    return $lcm;
}


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

int n;
vector<int> t[100000];
bool u[100000];
int p[100000];
int d[100000];
int c[100000];

int dfs(int i, int cd){
    u[i] = true;
    d[i] = cd;
    c[i] = 1;
    for(int v: t[i]){
        if(!u[v]){
            p[v] = i;
            c[i] += dfs(v, cd + 1);
        }
    }
    return c[i];
}

int main(){
    cin >> n;
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        t[a - 1].push_back(b - 1);
        t[b - 1].push_back(a - 1);
    }

    p[0] = -1;
    dfs(0, 0);

    int k = (d[n - 1] - 1) / 2;
    int q = n - 1;
    rep(i, k){
        q = p[q];
    }

    int a = n - c[q];
    int b = c[q];
    if(a > b){
        cout << "Fennec" << endl;
    }
    else{
        cout << "Snuke" << endl;
    }
    return 0;
}

Measured memory_bytes: 11648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int N, A;
int x[111];
ll coudp[111][111][5555];

int main() 
{
	int N, K;
	cin >> N>> K;
	int ans = K;
	for (int i = 1; i < N; i++)
	{
		ans *= (K - 1);
	}
	cout << ans << endl;

	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;


int main(void){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long max_answer = b-a + 1;
    long long cd = c*d ;
    long long tmp, x, y;
    if(c > d){
        x=c;y=d;
    }else{
        x=d;y=c;
    }
    do{
        tmp = x % y;
        x=y;
        y = tmp;
        
    //    cout << tmp << " ";
    }while(tmp != 0);
    cd = c * d;
    if(x!=0)cd /= x;
    long long count = 0;
    count =  b/c + b/d - (a-1)/c - (a-1)/d - b/cd + (a-1)/cd;
    // cout << b <<  c <<d<<a-1 <<cd << endl;
    // cout << b/c <<" "<<b/d << " " <<(a-1)/c <<" "<<(a-1)/d <<" "<< b/cd <<" "<<(a-1)/cd<<endl;
    if(count > max_answer)count=max_answer;
  //  cout << max_answer << endl << count << endl;
    cout << max_answer - count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 
bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;
ll const inf = 1e5+1;

vector<ll> nodes[inf];
ll vis[inf];



void solve()
{   
    ll n,k; cin >> n ;

    ll a[n]; f(i,0,n) cin >> a[i];

    ll acc;
    ll mon=1000ll;
    f(i,0,n-1)
    {
        acc=0;
        if(a[i]<a[i+1])
        {
            acc = mon/a[i];
            
        }
        mon += (a[i+1]-a[i])*acc;


    }
    cout << mon << endl;
}
int main() {
Knucklehead 
/*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/


        
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        while(t-->0){
            solve();
 
        }
 
 
 
 
    return 0;
}

Measured memory_bytes: 5948
import sys
input = sys.stdin.readline
INF = float('inf')
def Bellmanford(n, edges, r):#r->start
    d = [INF] * n
    d[r] = 0
    for i in range(n):
        for (u, v, c) in edges:
            if d[u] != INF and d[u] + c < d[v]:
                d[v] = d[u] + c
                if i == n-1 and v == n-1:
                    return 'inf'
    return -d[n-1]


n, m = map(int, input().split())
edges = [None] * m
for i in range(m):
    ai, bi, ci = map(int, input().split())
    edges[i] = (ai-1, bi-1, -ci)
ans = Bellmanford(n, edges, 0)
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200
#define LN 63
#define ull unsigned long long
using namespace std;
int n,ans;ull a[N+5],v[LN+5];char op[N+5];
I void Clear() {ans=0;for(RI i=LN;~i;--i) v[i]=0;}
I void Ins(ull x)
{
	for(RI i=LN;~i;--i) if((x>>i)&1) {if(!v[i]) return (void)(v[i]=x);x^=v[i];}
}
I bool Q(ull x)
{
	for(RI i=LN;~i;--i) if((x>>i)&1) {if(!v[i]) return 0;x^=v[i];}return 1;
}
int main()
{
	RI Tt,i;scanf("%d",&Tt);W(Tt--)
	{
		for(Clear(),scanf("%d",&n),i=1;i<=n;++i) scanf("%llu",a+i);scanf("%s",op+1);
		for(ans=1,i=n;i;--i) if(a[i])
			{if(op[i]=='1'&&!Q(a[i])) {ans=0;break;}op[i]=='0'&&(Ins(a[i]),0);}
		putchar(49-ans),putchar('\n');
	}return 0;
}

Measured memory_bytes: 3692
n = int(input())
while n != 0:
	earnings = []
	for i in range(0,n):
		a = str.split(input(),' ')
		if i > 0 :
			for j in range(0,len(earnings)):
				if a[0] == earnings[j][0]:
					earnings[j][1] = str(int(earnings[j][1])+(int(a[1])*int(a[2])))
					break
				if j == len(earnings) - 1:earnings.append([a[0],str(int(a[1])*int(a[2]))])
		else:earnings.append([a[0],str(int(a[1])*int(a[2]))])
	milionear = []
	for i in range(0,len(earnings)):
		if int(earnings[i][1]) >= 1e6:
			milionear.append(earnings[i][0])
	if len(milionear) == 0 : print('NA')
	else:
		for i in range(0,len(milionear)):
			print(milionear[i])
	n = int(input())

Measured memory_bytes: 7924
#include<stdio.h>
short n, N, t, ans, i;
int a;
int main(){
  scanf("%hd%hd", &n, &t);
  N=n>>1;
  for(i=0; i<t; i++){
    scanf("%hd", &a);
    if(a>=N){ans=(a<<1)-n-1; break;}
  }
  printf("%d\n", ans>=0?ans:0);
}


Measured memory_bytes: 128