akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<deque>
using namespace std;
long long n,m,i,j,a[100005],mx=60,mi=70,cnt;
vector<pair<int,int> > ans;
bool check()
{
	int i;
	for (i=1;i<n;i++) if (a[i]>a[i+1]) return 0;
	return 1;
}
bool check2()
{
	int i;
	for (i=1;i<n;i++) if (a[i]<a[i+1]) return 0;
	return 1;
}
int main()
{
	cin>>n;
	a[mx]=-1e9;
	a[mi]=1e9;
	for (i=1;i<=n;i++)
	{
		cin>>a[i];
		if (a[i]>a[mx]) mx=i;
		if (a[i]<a[mi]) mi=i;
	}
	if (check())
	{
		cout<<0;
		return 0;
	}
/*	if (check2())
	{
		cout<<n*2<<endl;
		if (abs(a[mx])>abs(a[mi]))
		{
			cout<<mx<<' '<<n<<endl;
			cout<<mx<<' '<<n<<endl;
			cout<<n<<' '<<n<<endl;
			cnt=3;
			for (i=1;i<n;i++)
			{
				cout<<n<<' '<<i<<endl;cnt++;
				if (a[i]>a[i+1]) {cout<<n<<' '<<n<<endl;cnt++;}
			}
			while (cnt++<n)
			{
				cout<<n<<' '<<n<<endl;
			}
		}
		else
		{
			cout<<mi<<' '<<1<<endl;
			cout<<mi<<' '<<1<<endl;
			cout<<1<<' '<<1<<endl;
			cnt=3;
			for (i=n;i>1;i--)
			{
				cout<<1<<' '<<i<<endl;cnt++;
				if (a[i]<a[i-1]) {cout<<1<<' '<<1<<endl;cnt++;}
			}
			while (cnt++<n)
			{
				cout<<1<<' '<<1<<endl;
			}
		}
		return 0;
	}*/
	cout<<2*n<<endl;
	if (abs(a[mx])>abs(a[mi]))
	{
		cout<<mx<<' '<<n<<endl;
		cout<<mx<<' '<<n<<endl;
		cout<<n<<' '<<n<<endl;
		cnt=3;
		for (i=2;i<n;i++)
		{
			cout<<n<<' '<<i<<endl;cnt++;
			if (a[i]>a[i+1]) {cout<<n<<' '<<n<<endl;cnt++;}
		}
		while (cnt++<2*n)
		{
			cout<<n<<' '<<n<<endl;
		}
	}
	else
	{
		cout<<mi<<' '<<1<<endl;
		cout<<mi<<' '<<1<<endl;
		cout<<1<<' '<<1<<endl;
		cnt=3;
		for (i=n-1;i>1;i--)
		{
			cout<<1<<' '<<i<<endl;cnt++;
			if (a[i]<a[i-1]) {cout<<1<<' '<<1<<endl;cnt++;}
		}
		while (cnt++<2*n)
		{
			cout<<1<<' '<<1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int w, a, b; cin >> w >> a >> b;
    int ans = 0;
    if(a+w < b) ans = b - a - w;
    else if(b+w < a) ans = a - b - w;
    cout << ans;
}


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

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++){
        	a[i] = sc.nextInt();
        }
        int x = 0;
        if((n-k)%(k-1)==0){
        	x = (n-k)/(k-1);
        }
        else{
        	x = (n-k)/(k-1) + 1;	
        }
        System.out.println(x+1);
    }
}

Measured memory_bytes: 50108
s = list(input())
add = 0
ans = [0 for i in range(len(s))]

for i in range(len(s)):
    if s[i] == "R":
        add += 1
    else:
        ans[i] += add // 2
        ans[i - 1] += (add + 1) // 2
        add = 0

s.reverse()
ans.reverse()

for i in range(len(s)):
    if s[i] == "L":
        add += 1
    else:
        ans[i] += add // 2
        ans[i - 1] += (add + 1) // 2
        add = 0
        
ans.reverse()
print(*ans)

Measured memory_bytes: 7096
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll 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 fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll n;cin>>n;
		map<std::string ,ll> pq;
		forn(i,n)
		{
			string x;
			cin>>x;
			pq[x]++;
		}	
		
			
			cout<<"AC x "<<pq["AC"]<<endl;
			cout<<"WA x "<<pq["WA"]<<endl;
			cout<<"TLE x "<<pq["TLE"]<<endl;
			cout<<"RE x "<<pq["RE"]<<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: 3664
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);
        ATheNumberOfEvenPairs solver = new ATheNumberOfEvenPairs();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATheNumberOfEvenPairs {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            out.println((int) (Math.pow(n, 2) - n + Math.pow(m, 2) - m) / 2);
        }

    }
}



Measured memory_bytes: 21972
import fractions
N = int(input())
T = list(map(int, input().split()))
ans = T[0]
for i in range(1, N):
    ans = ans * T[i] // fractions.gcd(ans, T[i])
#print(ans)

sum = 0
for i in range(0,N):
    sum += ans / T[i]

print(ans / sum)

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

double getProbability (const vector <double> &p) {
    int n = p.size();
    vector <double> dp(n + 1);
    dp[0] = 1;
    /* dp[i] - probability of having i heads */
    for (int i = 1; i <= n; ++i) {
        vector <double> curr(n + 1);
        for (int j = 0; j <= i; ++j) {
            /* There can be 0 <= j <= i heads */
            if (j > 0) {
                curr[j] += dp[j - 1] * p[i - 1];
            }
            curr[j] += dp[j] * (1 - p[i - 1]);
        }
        dp = curr;
    }
    double result = 0;
    for (int heads = 0; heads <= n; ++heads) {
        int tails = n - heads;
        if (heads > tails) {
            result += dp[heads];
        }
    }
    return result;
}

int main() {
    int n;
    cin >> n;
    vector <double> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    double result = getProbability(p);
    printf("%.10f\n", result);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

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

    if (n-a-b < -1 || n > a*b){
        printf("-1\n");
        return 0;
    }
/*    if (a==1) {
        REP(i,n){
            printf("%d ",n-i);
        }
        printf("\n");
    } else if (b==1){
        REP(i,n){
            printf("%d ",i+1);
        }
        printf("\n");
    } else if (n-a-b == -1){
    int up = 0;
    int down = 0;
        REP(i,a-1){
            printf("%d ",up+1);
            up++;
        }
        REP(i,b-1){
            printf("%d ",n-down);
            down++;
        }
        printf("\n");
    } else {*/
        int cnt = 0;
        while(cnt+(n-cnt+b-1)/b < a){
            printf("%d ", cnt+1);
            cnt++;
        }
        int offset = cnt;
        cerr << " " << cnt << " " << endl;
        REP(i,a){
            int start = min(n,(i*(int)b)+(int)b + offset);
            REP(i,b){
                printf("%d ", start-i);
                cnt++;
                if(cnt == n) goto HOGE;
            }
        }
        HOGE:
        printf("\n");
    //}
}


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

int n, a[200200], b[200200], cnt[200200], cnt2[200200], chk[200200], cnt3[200200];
priority_queue<pair<int, int>> A, B;
queue<int> q[200200];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for(int i=1;i<=n;i++) cin >> a[i];
	for(int i=1;i<=n;i++) cin >> b[i];

	for(int i=1;i<=n;i++) cnt[a[i]]++, cnt[b[i]]++;

	for(int i=1;i<=n;i++) if(cnt[i] > n){
		cout << "No";
		return 0;
	}

	for(int i=1;i<=n;i++) chk[a[i]] = 1;
	for(int i=1;i<=n;i++) if(chk[i]) A.push({cnt[i], i});

	for(int i=1;i<=n;i++) cnt2[b[i]]++;
	for(int i=1;i<=n;i++) if(cnt2[i]) B.push({cnt[i], i});

	for(int i=1;i<=n;i++) cnt3[a[i]]++;

	auto u = A.top().second; A.pop();
	int mx = 0;

	for(int i=1;i<=n;i++){
		if(cnt2[mx]) B.push({cnt[mx], mx});
		mx = B.top().second, B.pop();

		if(B.empty() || mx != u){
			// cout << 1 << " " << u.second << " " << mx.second << "\n";
			q[u].push(mx);
			--cnt2[mx];
			--cnt[mx];
		}else{
			auto k = B.top().second; B.pop();
			// cout << 2 << " " << u.second << " " << k.second << "\n";
			q[u].push(k);
			--cnt2[k];
			--cnt[k];
			if(cnt2[k]) B.push({cnt[k], k});
		}

		--cnt3[u];
		--cnt[u];
		if(cnt3[u]) A.push({cnt[u], u});
		u = A.top().second, A.pop();
	}

	cout << "Yes\n";
	for(int i=1;i<=n;i++){
		cout << q[a[i]].front() << " ";
		q[a[i]].pop();
	}
}

Measured memory_bytes: 146332
S = input()

a = S[0]+S[1]
b = S[2]+S[3]

month = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']

if a in month and b in month:
    ans = 'AMBIGUOUS'
elif a in month:
    ans = 'MMYY'
elif b in month:
    ans = 'YYMM'
else:
    ans = 'NA'

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector> 

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int x = a + b;
	if (a % 3 == 0 || b % 3 == 0 || x % 3 == 0)cout << "Possible" << endl;
	else { cout << "Impossible" << endl; }
	return 0;
}

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

using namespace std;
using uint = unsigned int;
using int64 = long long;
using i64 = int64;
using uint64 = unsigned long long;
using vint = vector<int>;
using vint64 = vector<int64>;
template<typename T>
using p_que = priority_queue<T>;
#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rep1(i,N) for(int i=1;i<=(int)(N);++i)
#define fs first
#define sc second
#define eb emplace_back
#define all(x) x.begin(),x.end()

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (auto& e : v) os << e << ", ";
	return os << "]";
}

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

template<class T, class U> ostream& operator<<(ostream& os, const map<T, U>& mp) {
	os << "{";
	for (auto& e : mp) os << e << " ";
	return os << "}";
}

void Main();
signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
}

/* Cut from here! */

template <uint mod> struct ModInt {
	uint x;
	ModInt(int64_t y = 0) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
	ModInt& operator+=(const ModInt& p) {
		if ((x += p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt& operator-=(const ModInt& p) {
		x = (int)(1ll * x * p.x % mod);
		return *this;
	}
	ModInt& operator/=(const ModInt& p) {
		*this *= p.inverse();
		return *this;
	}
	ModInt operator-() const {
		return ModInt(-x);
	}
	ModInt operator+(const ModInt& p) const {
		return ModInt(*this) += p;
	}
	ModInt operator-(const ModInt& p) const {
		return ModInt(*this) -= p;
	}
	ModInt operator*(const ModInt& p) const {
		return ModInt(*this) *= p;
	}
	ModInt operator/(const ModInt& p) const {
		return ModInt(*this) /= p;
	}
	bool operator==(const ModInt& p) const {
		return x == p.x;
	}
	bool operator!=(const ModInt& p) const {
		return x != p.x;
	}
	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while (b > 0) {
			t = a / b;
			swap(a -= t * b, b);
			swap(u -= t * v, v);
		}
		return ModInt(u);
	}
	ModInt pow(int64_t n) const {
		ModInt ret(1), mul(x);
		while (n > 0) {
			if (n & 1) ret *= mul;
			mul *= mul;
			n >>= 1;
		}return ret;
	}
	friend ostream& operator<<(ostream& os, const ModInt& p) {
		return os << p.x;
	}
};


//#define int long long
const uint MOD = 1e9 + 7;

template<typename T>
T gcd(T x, T y) {
	if (x == 0 || y == 0) return 1;
	T r;
	while ((r = y % x) != 0) {
		y = x;
		x = r;
	}
	return x;
}

template<typename T>
void swaper(T& a, T& b) {
	a = a ^ b;
	b = a ^ b;
	a = a ^ b;
}

void print(const multiset<int>& s) {
	for (auto& e : s) cout << e << endl;
}

using pi=pair<int, int>;

void Main() {
	i64 A, B, X; cin >> A >> B >> X;

	i64 ans = X / 1000 * min(A, B * 2);
	X %= 1000;
	if (X > 500) ans += min(A, 2 * B);
	else if (X != 0) ans += min(A, B);

	cout << ans << endl;
}


Measured memory_bytes: 3168
N, M = map(int, input().split())
card = [0]*(N+1)

for i in range(M):
    l, r = map(int, input().split())
    card[l-1] += 1
    card[r] -= 1

res = 0
gate = 0
for i in range(N):
    gate += card[i]
    if gate == M:
        res += 1

print(res)

Measured memory_bytes: 73492
<?php
$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($N,$M,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$c = array_map('intval',explode(" ",trim(fgets(STDIN))));

$res['AC']=0;
$res['WA']=0;
$res['TLE']=0;
$res['RE']=0;
for($i=0;$i<$N;$i++) {
  $S = trim(fgets(STDIN));
  $res[$S]++;
}
foreach($res as $k=>$v) {
  printf("%s x %d\n",$k,$v);
}


Measured memory_bytes: 16212
import scala.io.Source.stdin

object Main extends App {
  stdin.getLines.filter(_!="").map(_.toDouble).foreach { x =>
    println {
      x match  {
        case i if i <= 48D => "light fly"
        case i if i <= 51D => "fly"
        case i if i <= 54D => "bantam"
        case i if i <= 57D => "feather"
        case i if i <= 60D => "light"
        case i if i <= 64D => "light welter"
        case i if i <= 69D => "welter"
        case i if i <= 75D => "light middle"
        case i if i <= 81D => "middle"
        case i if i <= 91D => "light heavy"
        case _ => "heavy"
      }
    }
  }
}

Measured memory_bytes: 44044
n = list(map(int, input().split()))
while n[0]>0 and n[2]>0:
    n[2] = n[2] - n[1]
    if n[2] <= 0:
        break
    n[0] = n[0] - n[3]

if n[0]>n[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
def main():
    N = int( input())
    t = 26
    ANS = []
    a = ord("a")
    # if N == 1:
    #     print("a")
    #     return
    # N -= 1
    while True:
        # if N%t == 0:
        #     ANS.append("z")
        # else:
        ANS.append( chr((N-1)%t+a))
        N = (N-1)//t
        if N == 0:
            break
    print("".join( ANS[::-1]))
if __name__ == '__main__':
    main()


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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}

/*
 * f(U) = \sum_{U\in T}(-1)^(|T\U|)f(T)
 * for f(U) = \sum_{U\in T}f(T), use f[j | i] -= f[j];
 */
template <typename T>
void fast_moebius(vector<T> &f){
  int n = f.size();
  for(int i = 1; i < n; i<<=1){
    for(int j = 0; j < n; j++){
      if((j & i) == 0){
        f[j | i] -= f[j];
      }
    }
  }
}

ostream& operator<<(ostream& dest, __int128_t value) {
  ostream::sentry s(dest);
  if(s){
    __uint128_t tmp = value < 0 ? - value: value;
    char buf[128];
    char *d = end(buf);
    do{
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    }while(tmp != 0);
    if(value < 0)--d, *d='-';
    int len = end(buf) - d;
    if(dest.rdbuf()->sputn(d, len) != len){
      dest.setstate(ios_base::badbit);
    }
  }
  return dest;
}

__int128_t to_int128(string s){
  __int128_t res = 0;
  for(int i = 0; i < s.size(); i++){
    res = res * 10 + (s[i] - '0');
  }
  return res;
}

using uint128 = __int128_t;

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

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  ll m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<int> p(n);
  cin >> a >> p;
  double res = 0.;
  vector<ll> f((1 << n), 0);
  vector<double> pr((1 << n), 0.);
  for(int i = 0; i < (1 << n); i++){
    uint128 tmp = 1;
    double ptmp = 1.;
    bool ng = false;
    if(tmp > m){
      ng = true;
      tmp = m + 1;
    }
    for(int j = 0; j < n; j++){
      if((i >> j) % 2 == 1){
        if(!ng)tmp = tmp * (a[j] / gcd(tmp, uint128(a[j])));
        if(tmp > m){
          ng = true;
          tmp = m + 1;
        }
        ptmp *= (double)p[j] / 100.;
      }else ptmp *= (1. - (double)p[j] / 100.);
    }
    if(i == 0)tmp = m + 1;
    if(ng)tmp = m + 1;
    f[i] = (tmp > 0 ? m / tmp: 0);
    pr[i] = ptmp;
  }
  fast_moebius(f);
  //for(int i = 0; i < (1 << n); i++)cout << i << " " << f[i] << endl;
  for(int i = 0; i < (1 << n); i++)res += pr[i] * (double)(abs(f[i]));
  cout << setprecision(20);
  cout << res << endl;
	return 0;
}



Measured memory_bytes: 19200
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
ll mypow(ll a, ll n) {
	if (n == 0)return 1;
	ll d = mypow(a, n / 2);
	if (n & 1)return d * d%MOD*a%MOD;
	return d * d%MOD;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	vvl dp(n + 1, vl(n+1,0));
	vl fact(n + 1), rfact(n + 1);
	fact[0] = 1;
	REP(i, n) {
		fact[i + 1] = (fact[i] * (i + 1)) % MOD;
	}
	REP(i, n + 1) {
		rfact[i] = mypow(fact[i], MOD - 2);
	}
	dp[0][0] = 1;
	REP(i, n) {
		REP(j, n+1) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j] %= MOD;
			if (i+1 >= a && i+1 <= b) {
				FOR(k, c, d + 1) {
					if (j + (i+1) * k > n)break;
					dp[i + 1][j + (i+1) * k] += dp[i][j] * mypow(rfact[i + 1], k) % MOD*fact[n - j] % MOD*rfact[n - j - (i+1) * k] % MOD*rfact[k] % MOD;
					dp[i + 1][j + (i+1) * k] %= MOD;
				}
			}

		}
	}
	cout << dp[n][n] << endl;
}


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

int main()
{
	int n, x;
	cin>>n;
	
	for(float i=n; i<=n+0.99; i+=0.01){
		x=int(i/1.08);
		if(n==int(x*1.08)){
			cout<<x<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
	return 0;
} 

Measured memory_bytes: 256
// #C
// atcoder Mujin Programming Challenge 2017 main.go
//Thanks to user:n      http://mujin-pc-2017.contest.atcoder.jp/submissions/1132503
// and https://atcoder.jp/img/mujin-pc-2017/editorial.pdf

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

const MAX = 500015
const Erase = 26

var N, Q int
var pos [MAX][27]int
var cut [21][MAX]int

func solve(in io.Reader, out, err io.Writer) {
	S := []byte{}
	fmt.Fscan(in, &S, &Q)
	N = len(S)
	S = append(S, []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}...)
	for i := range pos {
		for jj := range pos[i] {
			pos[i][jj] = -1
		}
	}

	//line,34-
	for i := N - 1; i >= 0; i-- {
		char := S[i] - 'a'
		pos[i][char] = i + 1

		for k := char; k < 26; k++ {
			if pos[i][k] == -1 {
				break
			}
			pos[i][k+1] = pos[pos[i][k]][k]
		}

		if pos[i][Erase] != -1 {
			for k := 0; k < int(char); k++ {
				pos[i][k] = pos[pos[i][Erase]][k]
			}
		}
	}
	//line, 45

	//line. 47
	for i := 0; i < N+10; i++ {
		if pos[i][Erase] == -1 {
			cut[0][i] = N + 1
		} else {
			cut[0][i] = pos[i][Erase]
		}
	}

	//51 nuketeiru
	for t := 0; t < 20; t++ {
		for i := 0; i < N+10; i++ {
			cut[t+1][i] = cut[t][cut[t][i]]
		}
	}

	//line, 53
	for i := 0; i < Q; i++ {
		L, R := 0, 0
		fmt.Fscan(in, &L, &R)
		L--

		for t := 20; t >= 0; t-- {
			if cut[t][L] <= R {
				L = cut[t][L]
			}
		}

		//line, 61
		ans := "No"
		if L == R {
			ans = "Yes"
		}
		fmt.Fprintln(out, ans)
	}

}

func main() {
	br := bufio.NewReaderSize(os.Stdin, int(1e7))
	solve(br, os.Stdout, os.Stderr)
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> L(m);
	vector<int> R(m);
	rep(i,m) cin >> L[i] >> R[i];
	sort(R.begin(), R.end());
	sort(L.begin(), L.end(),greater<int>());
	int sms = R[0];
	int ler = L[0];
//	cout << sms << endl;
//	cout << ler << endl;
	int ans = 0;
	for (int i = 1; i < n + 1; i++) {
		if(i <= sms && i >= ler) {
			ans++;
		}
	}

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



Measured memory_bytes: 4060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    cout<<fixed<<setprecision(15);
    ll n,m,d; cin>>n>>m>>d;
    ld ans=(ld)(n-d)*(m-1)/(n*n);
    if(d>0) ans*=2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N,K,ans=0;
  cin >> N >> K;
  vector <int> H(N);
  for(int i=0; i<N; i++){
    cin >> H.at(i);
  }
  sort(H.begin(),H.end());
  for(int i=0; i<N-K; i++){
    ans+=H.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import fractions
# input process
inputData = input().split()
A = int(inputData[0])
B = int(inputData[1])
C = int(inputData[2])
D = int(inputData[3])

C_q_num = (B // C) - (A // C)
if (A % C) == 0:
    C_q_num += 1
D_q_num = (B // D) - (A // D)
if (A % D) == 0:
    D_q_num += 1
CD_lcm = (C * D) // fractions.gcd(C, D)
CD_q_num = (B // CD_lcm) - (A // CD_lcm)
if (A % CD_lcm) == 0:
    CD_q_num += 1
print((B - A + 1) - C_q_num - D_q_num + CD_q_num)


Measured memory_bytes: 5052
#B問題
c=[]
t=[]
N,T= map(int, input().split())

for i in range (0,N):
    c_,t_= map(int, input().split())
    if(t_<=T):#コストが高いものを除外
        c.append(c_)
        t.append(t_)

if( len(t)==0 ):#一つも低コストがない
    print("TLE")
else:
    print(min(c))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int d,n;
  cin >>d>>n;
  if(n==100){
    if(d==0){
      cout<<101<<endl;
    }else if(d==1){
      cout<<10100<<endl;
    }else{
      cout<<1010000<<endl;
    }
  }else{
    if(d==0){
      cout<<n<<endl;
    }else if(d==1){
      cout<<n*100<<endl;
    }else{
      cout<<n*10000<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int max_num = max(A,max(B,C));
  cout << A + B + C - max_num << endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13) cout<<b<<endl;
    else if(a>=6) cout<<b/2<<endl;
    else cout<<0<<endl;

    return 0;
}

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

pf = R[1] - R[0] #利益の初期値代入
minv = min(R[0],R[1]) #最小値の初期値
maxv = R[1]

for i in range(2,N):
    newv = R[i]
    if (newv - minv) > pf:
        maxv = newv
        pf = newv - minv
    if newv < minv:
        minv = newv

print(pf)




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

#define ll long long int
#define vl vector<ll>
#define vvl vector<vl>

int main() {

    ll N;
    cin >> N;

    // vl A;
    vl B(200010, 0);
    vl C(200010, 0);

    ll a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        // A.push_back(a);
        if(i+a < 200005) {
            B[i+a]++;
        }
        if(i-a >= 0) {
            C[i-a]++;
        }
    }

    ll ans = 0;
    for (int i = 0; i < 200010; ++i) {
        ans += (B[i]*C[i]);
    }


    cout << ans << endl;

    return 0;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    ll a,b,c,k; cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += min(k,a);
    k -= min(k,a);
    k -= min(k,b);
    ans -= min(k,c);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
        ll h,w,n,i,j;
        cin>>h>>w>>n;
        vector<ll> r(h+5,0);
        vector<ll> c(w+5,0);
        vector<pair<ll,ll> > v;
        map<pair<ll,ll> ,ll> mp;
        ll ans=0;
        ll rr=0,cc=0;
        ll x,y;
        for(i=0;i<n;i++)
        {
            cin>>x>>y;
            r[x]++;
            c[y]++;
            if(r[rr]<r[x])
                rr=x;
            if(c[cc]<c[y])
                cc=y;
            mp[{x,y}]=1;
            v.push_back({x,y});
        }
        ll temp=0;
        for(auto i:v)
        {
            temp=0;
            temp+=r[i.first];
            temp+=c[cc];
            if(mp.find({i.first,cc})!=mp.end())
                temp--;
            ans=max(ans,temp);
            temp=0;
            temp+=r[rr];
            temp+=c[i.second];
            if(mp.find({rr,i.second})!=mp.end())
                temp--;
            ans=max(ans,temp);
        }
        cout<<ans<<"\n";
    
}

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);

    int n;
    long long sum = 0;
    cin >> n;
    for(int i = 1; i <= n; i ++){
        if(i % 3 == 0 || i % 5 == 0){
            continue;
        }
        sum += i;
    }
    cout << sum << "\n";
}



Measured memory_bytes: 3652
//Link : https://atcoder.jp/contests/agc034/tasks/agc034_c

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

int b[N],l[N],r[N];
pair<ll,int> in[N];
int ind[N];
ll preSum[N];

ll getValue(int id,int x) {
  if(b[id]<=x) {
    return (ll)b[id]*l[id] + (ll)(x-b[id])*r[id];
  } else {
    return (ll)x*l[id];
  }
}

bool canDoit(ll D,ll m,int x,int n) {
  if(m%x==0) {
    if(D + preSum[m/x]>=0) {
      return true;
    } else {
      return false;
    }
  } else {
    int g = m/x;
    ll sum = preSum[g];
    int rem = m%x;
    for(int i=1;i<=n;++i) {
      ll tmp;
      int id = in[i].second;
      if(i<=g) {
        tmp = sum - in[i].first;
        tmp += getValue(id,rem);
        tmp += in[g+1].first;
      } else {
        tmp = sum + getValue(id,rem);
      }
      if(tmp+D>=0) {
        return true;
      }
    }
    return false;
  }
}

void solve() {
  int n,x;scanf("%d %d ", &n,&x);
  ll D = 0;
  for(int i=1;i<=n;++i) {
    scanf("%d %d %d ", &b[i],&l[i],&r[i]);
    long long ret = (ll)b[i]*l[i] + (ll)(x-b[i])*r[i];
    in[i] = make_pair(ret,i);
    D += -(ll)b[i]*l[i];
  }
  sort(in+1,in+n+1,greater<pair<ll,int> >());
  for(int i=1;i<=n;++i) {
    preSum[i] = preSum[i-1] + in[i].first;
    ind[in[i].second] = i;
  }
  ll l = 0,r = (ll)n*x,mid;
  while(l<r) {
    mid = (l+r)/2;
    if(canDoit(D,mid,x,n)) {
      r = mid;
    } else {
      l = mid+1;
    }
  }
  printf("%lld\n", l);
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000007;

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

	int sum = 0, ave = 0, ave2 = 0;
	for(int i=0;i<n;i++) sum += a[i];
	ave = sum / n; ave2 = (sum / n) + 1;
	int cost = 0, cost2 = 0;
	for(int i=0;i<n;i++) {
		cost += (a[i] - ave) * (a[i] - ave);
		cost2 += (a[i] - ave2) * (a[i] - ave2);
	}

	cout<< min(cost, cost2) <<endl;

	return 0;
}

Measured memory_bytes: 256
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

if __name__ == '__main__':
    n = int(input())
    print(num2alpha(n).lower())


Measured memory_bytes: 61700
#include <cstdio>
int main(){
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	int start = a>c ? a : c;
	int end = b<d ? b : d;
	printf("%d\n", end > start ? end - start : 0);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;

int N, K, R, S, P;

int getScore(char c) {
    if (c == 'r') return P;
    if (c == 's') return R;
    return S;
}

int main()
{
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    vector<bool> check(N);

    int ans = 0;
    rep(i, N) {
        if (i >= K) {
            if (T[i] == T[i - K] && check[i - K]) continue;
            ans += getScore(T[i]);
            check[i] = true;
        }
        else if (i < K) {
            ans += getScore(T[i]);
            check[i] = true;
        }
        // cout << ans << endl;
    }

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

Measured memory_bytes: 3768
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
const ll INF=1e16;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N, M, R;
vector<int> order;
vector<vector<P>> root(201);  //pair<辺の距離, 行先の頂点>
vector<vector<ll>> dist(8, vector<ll>(201, LLONG_MAX)); //distance[i]は始点(start)から頂点iへの最短距離が入る
bitset<201> used;

void Dijkstra(int r, int start){ //start = 始点
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(make_pair(0, start));
    used.reset();
    while(!que.empty()){
        ll d, t; //d:startからの距離, t:行先
        tie(d, t) = que.top(); que.pop();
        if(used[t]) continue;   //探索済み
        used[t] = true, dist[r][t] = d;
        for(auto e : root[t]){
            if(dist[r][e.second] <= d + e.first) continue;
            que.push(make_pair(d + e.first, e.second));
        }
    }
}

ll ans = LLONG_MAX;
bitset<8> bit;
void rec(int corrent, int count, ll sum){
    if(count == R){
        ans = min(ans, sum);
        return;
    }
    if(sum >= ans) return;
    for(int i = 0; i < R; ++i){
        int a = corrent, b = order[i];
        if(!bit[i] && dist[a][b] != LLONG_MAX){
            bit[i] = true;
            rec(i, count + 1, sum + dist[a][b]);
            bit[i] = false;
        }
    }
    return;   
}

int main(void){
    
    scanf("%d %d %d", &N, &M, &R);
    for(int i = 0; i < R; ++i){
        int a; scanf("%d", &a);
        order.push_back(a);
    }
    
    for(int i = 0; i < M; ++i){
        ll a, b, c; scanf("%lld %lld %lld", &a, &b, &c);
        root[a].push_back(make_pair(c, b)), root[b].push_back(make_pair(c, a));
    }
    
    for(int i = 0; i < R; ++i) Dijkstra(i, order[i]);
    
    for(int i = 0; i < R; ++i){
        bit.reset();
        bit[i] = true;
        rec(i, 1, 0);
        bit[i] = false;
    }
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 2004
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n, k; cin >> n >> k;

	vector<LL> x(n);
	vector<LL> y(n);

	vector<LL> xb(n);
	vector<LL> yb(n);


	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];

		xb[i] = x[i];
		yb[i] = y[i];
	}

	sort(xb.begin(), xb.end());
	sort(yb.begin(), yb.end());

	LL ans = LLONG_MAX;

	//xの左端の番号を決める
	for (int x1 = 0; x1 < n; x1++) {

		//xの右端の番号を決める
		for (int x2 = x1+1; x2 < n; x2++) {

			//yの左端の番号を決める
			for (int y1 = 0; y1 < n; y1++) {
				//yの右端の番号を決める
				for (int y2 = y1+1; y2 < n; y2++) {

					//番号に対応した、4つの座標を格納する
					LL xl = xb[x1];
					LL xr = xb[x2];

					LL ys = yb[y1];
					LL yu = yb[y2];

					LL cnt = 0;

					//決めた領域に対して、すべての点をひとつひとつ
					//入ってるかチェックする
					for (int i = 0; i < n; i++) {
						if (xl <= x[i] && x[i] <= xr) {
							if (yu >= y[i] && y[i] >= ys) {
								cnt++;
							}
						}
					}

					//領域内の個数がk以上なら面積を更新
					if (cnt >= k) {
						LL area = (LL)(xr - xl)*(LL)(yu - ys);

						ans = min(ans, area);
					}
				}

			}
		}
	}

	cout << ans << endl;



	return 0;
}

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

using namespace std;

const int P = 1000000000 + 7;

long long qpow(long long a, long long k) {
    long long res = 1;
    while (k) {
        if (k & 1)  res = res * a % P;
        a = a * a % P;
        k >>= 1;
    }
    return res;
}

int main() {
    int n;  cin >> n;
    if (n < 2)  cout << 0 << '\n';
    else {
        long long ans = qpow(10, n) - qpow(9, n) * 2 + qpow(8, n);
        ans = (ans % P + P) % P;
        cout << ans << '\n';
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 3696
H, W = map(int,input().split())
A = [list(input()) for i in range(H)]

#from queue import Queue #キューを使ったら1ケースだけTLEになった。
from collections import deque

dj = [1, 0, -1, 0]
di = [0, 1, 0, -1]

sum_sharp = sum([A[i].count('#') for i in range(H)])

fin_d_max = 1

for s_i in range(H):
    for s_j in range(W):
        d_max = 0
        #q_i = Queue()
        q_i = deque()
        #q_j = Queue()
        q_j = deque()
        D = [[-1]*W for i in range(H)]
        flag = 1

        if A[s_i][s_j] == '.':
            D[s_i][s_j] = 0
            #q_i.put(s_i)
            q_i.append(s_i)
            #q_j.put(s_j)
            q_j.append(s_j)
            #while q_i.empty() == False:
            while len(q_i)!=0:
                #i = q_i.get()
                i = q_i.popleft()
                #j = q_j.get()
                j = q_j.popleft()
                for x in range(4):
                    ni = i+di[x]
                    nj = j+dj[x]
                    if ni<0 or ni>=H or nj<0 or nj>=W or A[ni][nj]== '#' or D[ni][nj]!=-1:
                        continue
                    else:
                        flag += 1
                        D[ni][nj] = D[i][j]+1
                        d_max = max(d_max, D[ni][nj])
                        #q_i.put(ni)
                        q_i.append(ni)
                        #q_j.put(nj)
                        q_j.append(nj)
        fin_d_max = max(fin_d_max, d_max)
                
print(fin_d_max)

Measured memory_bytes: 3316
/*
 * Author : Sadi
 * Tue 14/07/2020
 * 14:03:50.98
 */
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int a, b;
    cin >> a >> b;
    if(a - (b << 1) > 0) {
        cout << a - (b << 1) << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
import numpy as np
a = [int(i) for i in input().split()] 
K = a[0]
X = a[1]

min_ = np.max([X - K + 1, -10000])
max_ = np.min([X + K - 1, 10000])
print(*[x for x in range(min_,max_+1)])


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

int main(){
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    sort(a.begin(),a.end());
    int M = a[2];
    int sum = a[0] + a[1] + a[2];
    int ans = 0;
    if((3*M % 2) == (sum%2)){
        ans = (3 * M - sum ) / 2;
    }else{
        ans = (3 * (M + 1) - sum) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W = 1;
  
  while( W > 0){
    cin >> H >> W;
    if(H == 0 && W == 0){
      break;
    }
    else{
      for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(i == 0 || i == H - 1 || j == 0 || j == W -1){
          cout << "#";
        }
        else{
        cout << ".";
      }
      }
      cout << endl;
      }
      cout << endl;
    }    
    
  }
  
}


Measured memory_bytes: 3028
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int fibs[1010]={};
int fib(int n){
	if(fibs[n]!=-1){
		return fibs[n];
	}
	return fibs[n]=(fib(n-2)+fib(n-1))%1001;
}

int main(){
	int v,d;
	while(cin>>v>>d,cin){
		REP(i,1010){
			fibs[i]=-1;
		}
		fibs[0]=1;
		fibs[1]=2;
		FOR(i,1,v+1){
			fib(i);
		}

		sort(fibs+1,fibs+v+1);
		int ans=v;
		FOR(i,2,v+1){
			if(abs(fibs[i]-fibs[i-1])<d){
				ans--;
			}
		}
		cout<<ans<<endl;
	}
}

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

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    c*=2;
    if(x<y)
        swap(x,y),swap(a,b);
    cout<<min(a+b,c)*y+min(a,c)*(x-y);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

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

	vector<int> v(n);
	rep(i, n) cin >> v[i];

	sort(v.begin(), v.end());

	int a = INF, b = INF, c = INF, x;
	rep(i, n) {
		rep(j, n) {
			if(i == j) continue;

			int x = v[i];
			for(int k = v[j]; k > 0; k /= 10) {
				x *= 10;
			}

			x += v[j];

			if(x <= a) {
				c = b;
				b = a;
				a = x;
			} else if(x <= b) {
				c = b;
				b = x;
			} else if(x <= c) {
				c = x;
			}
		}
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>

int main(){

  int x,y,tmp,r;

  scanf("%d%d",&x,&y);

  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }

  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }

  printf("%d\n",y);

  return 0;
}


Measured memory_bytes: 2084
n, a ,b = map(int, input().split())
v = list(map(int, input().split()))
d = {}
for i in range(n):
  d.setdefault(v[i], 0)
  d[v[i]] += 1
c = sorted(list(set(v)), reverse=True)
c.append(0)
d[0] = 0
fact = [1 for _ in range(n+1)]
for i in range(n):
  fact[i+1] = fact[i] * (i+1)
ave = 0
cnt = 0
for i in range(a, b+1):
  t = i; cur = 0; sum=0
  while(cur<len(c)-1 and d[c[cur]]<=t):
    sum += c[cur] * d[c[cur]]
    t -= d[c[cur]]
    cur += 1
  sum += c[cur] * t
  if ave < (sum / i):
    ave = sum / i
    cnt = fact[d[c[cur]]] // fact[t] // fact[d[c[cur]]-t]
  elif ave == (sum / i):
    cnt += fact[d[c[cur]]] // fact[t] // fact[d[c[cur]]-t]
print(ave)
print(cnt)

Measured memory_bytes: 3064