akhauriyash/Code-Regression huggingface dataset:
N, C, K = map(int, input().split())
Ts = []
for n in range(N):
	Ts.append(int(input()))
Ts.sort()

bus = 0
bus_t = None
bus_on_board = 0

for t in Ts:
	if bus_t is not None and t <= bus_t and bus_on_board < C:
		bus_on_board += 1
	else:
		bus += 1
		bus_t = t + K
		bus_on_board = 1
print(bus)


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


int main() {
	
	int n;
	cin >>n;
	int64_t cnt=0;
	map<string, int64_t> b;
	set<string> a;
	for(int i=0; i<n; i++){
		string s;
		cin >> s;
		vector<char> t(10);

		for(int j=0; j<10; j++) t.at(j) = s.at(j);
		sort(t.begin(),t.end());
		string r;
		for(int j=0; j<10; j++) r+= t.at(j);
		if(!a.insert(r).second) b[r]++;
	}
	
	for(auto itr=b.begin(); itr!=b.end(); itr++) {
		cnt += itr->second*(itr->second+1)/2;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using intl = long long;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define debug(x) cout << #x << ":" << x << endl
const intl INF = 1e9;
const intl MOD = 1e9+7;
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl h;
    cin >> h;
    intl w;
    cin >> w;
    if((w == 1)||(h == 1)){
        cout << 1 << endl;
        return 0;
    }
    intl a = 0;
    a = (h + 1) / 2;
    a *= (w + 1) / 2;
    intl b = 0;
    b = h / 2;
    b *= w / 2;
    cout << a + b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <queue>
#include<algorithm>
#include <cstdlib>
#include <numeric>


#define rep(i,n) for(int i=0; i<(n);i++)
using namespace std;


typedef long long ll;
const int INF = 1001001001;



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

	cout << ans << endl;

	return 0;
}

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

void swap(int &a, int &b);
void swap(int &a, int &b)
{
    if (a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
}
int main() {
    int a, b, c;
    cin >> a >> b >> c;

    swap(a, b);
    swap(b, c);
    swap(a, b);
    cout << a <<" "<< b <<" "<< c<<endl;
    return 0;
}

Measured memory_bytes: 1168
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    T = LIST()
    M = INT()
    L = [LIST() for i in range(M)]
    ans = []
    for i in range(M):
        T_copy = deepcopy(T)
        p = L[i][0]
        x = L[i][1]
        T_copy[p-1] = x
        print(sum(T_copy))






if __name__ == "__main__":
    main()




Measured memory_bytes: 5196
H, W = map(int,input().split())
A = [input() for _ in range(H)]
mod = 10**9+7

dp = [[0 for j in range(W+1)] for i in range(H+1)]
dp[0][1] = 1

for i in range(H):
    for j in range(W):
        if A[i][j] == '.':
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % mod

print(dp[-1][-1])

Measured memory_bytes: 44628
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N;
unordered_set<string> dic;

int main() {
    cin >> N;
    rep(i, N) {
        string q, word;
        cin >> q >> word;
        if (q == "insert") {
            dic.insert(word);
        } else {
            if (dic.find(word) != dic.end()) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }
}



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

using namespace std;

int main(){
    long long int N,ans=0;
    cin >> N;
    vector<long long int> A(N),dp(N,-1e9);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    dp[0] = A[0];

    for(int i=1;i<N;i++){
        int lb = -1, ub = N+1;
        while(1<ub-lb){
            int mid = (ub+lb)/2;
            if(A[i]<=dp[mid]){
                lb = mid;
            }else{
                ub = mid;
            }
        }

        dp[ub] = A[i];
    }

    for(int i=0;i<N;i++){
        if(dp[i] == -1e9){
            cout << i << endl;
            return 0;
        }
    }

    cout << N << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    string s;
    cin >> s;
    if(s.size() & 1){
        cout << "No";
        return;
    }
    sort(all(s));
    for(int i = 1; i < s.size(); i += 2){
        if(s[i] != s[i - 1]){
            cout << "No";
            return;
        }
    }
    cout << "Yes";
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
struct man{
  string name;
  int buy,sell;
  man(string name):name(name){buy=sell=0;}
  bool operator<(const man &m) const{
    return name.compare(m.name)<0;
  } 
};
vector<string> vs;
struct item{
  string name;
  int mi,ma,su,n;
  set<P> ss,sb;
  item(string name):name(name){n=su=0;}
  bool operator<(const item &i) const{
    return name.compare(i.name)<0;
  } 
  P finds(int x,int i){
    P p=P(-1,-1);
    for(set<P>::iterator it=ss.begin();it!=ss.end();++it){
      if(vs[i]==vs[it->second]) continue;
      if(~p.first){
	if(it->first<p.first) p=*it;
	if(it->first==p.first&&it->second<p.second) p=*it;
      }else p=*it;
    }
    if(p.first>x) p=P(-1,-1);
    if(~p.first) ss.erase(p);
    return p;
  }
  P findb(int x,int i){
    P p=P(-1,-1);
    for(set<P>::iterator it=sb.begin();it!=sb.end();++it){
      if(vs[i]==vs[it->second]) continue;
      if(~p.first){
	if(it->first>p.first) p=*it;
	if(it->first==p.first&&it->second<p.second) p=*it;
      }else p=*it;
    }
    if(p.first<x) p=P(-1,-1);
    if(~p.first) sb.erase(p);
    return p;
  }
};
int main(){
  int n;
  while(cin>>n,n){
    int i,j,k;
    map<string,int> mm,mi;
    string name,order,com;
    vector<man> vm;
    vector<item> vi;
    vs.resize(n);
    for(i=0;i<n;i++){
      cin>>name>>order>>com>>k;
      vs[i]=name;
      if(mm.find(name)==mm.end()){
	mm[name]=vm.size();
	vm.push_back(man(name));
      }
      if(mi.find(com)==mi.end()){
	mi[com]=vi.size();
	vi.push_back(item(com));
      }
      if(order=="BUY"){
	P p=vi[mi[com]].finds(k,i);
	if(p.first==-1){
	  vi[mi[com]].sb.insert(P(k,i));
	  continue;
	}
	j=(k+p.first)/2;
	if(vi[mi[com]].n){
	  vi[mi[com]].mi=min(vi[mi[com]].mi,j);
	  vi[mi[com]].ma=max(vi[mi[com]].ma,j);
	}else{
	  vi[mi[com]].mi=vi[mi[com]].ma=j;
	}
	vm[mm[vs[p.second]]].sell+=j;
	vm[mm[name]].buy+=j;
	vi[mi[com]].su+=j;
	vi[mi[com]].n++;
      }else{
	P p=vi[mi[com]].findb(k,i);
	if(p.first==-1){
	  vi[mi[com]].ss.insert(P(k,i));
	  continue;
	}
	j=(k+p.first)/2;
	if(vi[mi[com]].n){
	  vi[mi[com]].mi=min(vi[mi[com]].mi,j);
	  vi[mi[com]].ma=max(vi[mi[com]].ma,j);
	}else{
	  vi[mi[com]].mi=vi[mi[com]].ma=j;
	}
	vm[mm[vs[p.second]]].buy+=j;
	vm[mm[name]].sell+=j;
	vi[mi[com]].su+=j;
	vi[mi[com]].n++;
      }
    }
    sort(vm.begin(),vm.end());
    sort(vi.begin(),vi.end());
    for(i=0;i<(int)vi.size();i++){
      if(!vi[i].n) continue;
      cout << vi[i].name << " " << vi[i].mi << " " << (vi[i].su/vi[i].n) << " " << vi[i].ma << endl;
    }
    puts("--");
    for(i=0;i<(int)vm.size();i++){
      cout << vm[i].name << " " << vm[i].buy << " " << vm[i].sell << endl; 
    }
    puts("----------");
  }
  return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> v(m);
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		v[i] = { a,b };
	}
	sort(ALL(v));
	int a = v[0].first, b = v[0].second;
	int res = 1;
	int i = 1;
	while (i < m) {
		if (v[i].first < b) {
			b = min(b, v[i].second);
			i++;
		}
		else {
			a = v[i].first;
			b = v[i].second;
			res++;
			i++;
		}
	}
	cout << res << endl;
	return 0;

}

Measured memory_bytes: 1024
#include <stdio.h>

void sort(int[],int,int);

int main()
{
    int n,d[100000];

    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&d[i]);
    }
    
    sort(d,0,n - 1);
    
    printf("%d",d[n / 2] - d[n / 2 -1]);
}

void sort(int number[],int first,int last){
   int i, j, pivot, temp;

   if(first<last){
      pivot=first;
      i=first;
      j=last;

      while(i<j){
         while(number[i]<=number[pivot]&&i<last)
            i++;
         while(number[j]>number[pivot])
            j--;
         if(i<j){
            temp=number[i];
            number[i]=number[j];
            number[j]=temp;
         }
      }

      temp=number[pivot];
      number[pivot]=number[j];
      number[j]=temp;
      sort(number,first,j-1);
      sort(number,j+1,last);

   }
}

Measured memory_bytes: 2048
#include <iostream>
#include <cmath>

int main() {
    int D, N;

    std::cin >> D >> N;

    if ( N != 100 ) std::cout << std::pow(100, D) * N << std::endl;
    else std::cout << (int)std::pow(100, D) * (N+1) << std::endl;
    
    return 0;
}

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

int main()
{
	long long r,d,x;
	cin>>r>>d>>x;
	
	long long k = x;
	for(int i = 1;i<=10;++i){
		x = r*k-d;
		cout<<x<<endl;
		k = x;
	}
    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n,m,b,maxnum;
	scanf("%d%d",&n,&m);
	int a[n+1];
	int B[n+1];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		B[i]=0;
	}
	for(int i=0;i<m;i++){
		scanf("%d",&b);
		for(int j=0;j<n;j++){
			if(a[j]<=b){
			B[j]+=1;
			break;
			}
		}
	}
	int max=B[0];
	for(int i=1;i<n;i++){
		if(max<B[i]){
			max=B[i];
			maxnum=i;
		}
	}
	printf("%d\n",maxnum+1);
	return 0;
}

Measured memory_bytes: 1032
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}

signed main() {
	int n, k, s;
	cin >> n >> k >> s;
	rep(i, k) {
		cout << s << ' ';
	}
	rep(i, n - k) {
		if (s == 1e9) {
			cout << s - 1 << ' ';
		}
		else {
			cout << s + 1 << ' ';
		}
	}
	cout << endl;
}


Measured memory_bytes: 1280
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Char
import Data.List


-- space delimited integers
getVals::IO [Int]
getVals = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

-- space delimited strings
getStrings::IO [String]
getStrings = (map BS.unpack . BS.words) <$> BS.getLine


solver:: Int -> Int -> Int -> Int
solver n x t = (t * (div n x)) +  (if (mod n x) /= 0 then t else 0)

main::IO()
main = do
    n:x:t:_<- getVals
    print $ solver n x t

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,r = 0,ans = 0;
	string s;
	cin >> n >> s;
	for(int i = 0;i < n;i++){
		if(s[i] == 'R') r++;
	}
	for(int i = r;i < n;i++){
		if(s[i] == 'R') ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3760
#include <stdio.h>

int main(void) {

  long n,k;
  scanf("%ld %ld", &n, &k);
  long a[n+1];
  for (long i = 1; i <= n; i++) {
    scanf("%ld", &a[i]);
  }
  long start = 1;
  for (long i = k+1; i <= n; i++) {
    if (a[start] < a[i]) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
    start++;
  }

  return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

vector<pair<string,pair<ll,pair<ll,ll>>>> Ans;

void add(ll i,ll j,ll k){
    Ans.push_back({"+",{i,{j,k}}});
}

void leq(ll i,ll j,ll k){
    Ans.push_back({"<",{i,{j,k}}});
}

void output(void){
    cout << Ans.size() << endl;
    REP(i,Ans.size()){
        cout << Ans[i].first << " " << Ans[i].second.first << " ";
        cout << Ans[i].second.second.first << " " ;
        cout << Ans[i].second.second.second << endl;
    }
}

int main(void){
    
    add(0,1,3);
    leq(2,3,4);
    
    add(4,5,6);
    REP(i,60-1){
        add(6+i,6+i,7+i);
    }
    
    add(0,4,66);
    add(1,4,67);
    
    for(ll i=29;i>=0;i--){
        add(68,6+i,69);
        leq(69,66,71+i);
        add(5,71+i,70);
        REP(j,i){add(70,70,70);}
        add(68,70,68);
    }
    
    add(5,5,68);
    
    for(ll i=29;i>=0;i--){
        add(68,6+i,69);
        leq(69,67,101+i);
        add(5,101+i,70);
        REP(j,i){add(70,70,70);}
        add(68,70,68);
    }
    
    REP(i,30){
        REP(j,30){
            add(71+i,101+j,151+i*30+j);
            leq(4,151+i*30+j,151+i*30+j);
            REP(k,i+j){
                add(151+i*30+j,151+i*30+j,151+i*30+j);
            }
            add(151+i*30+j,2,2);
        }
    }
    
    
    output();
    return 0;
}



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

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

    ll N;
    cin >> N;

    cout << N * (N - 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
N, X, Y = map(int,input().split())
k_list = [0]*N

for p in range(1, N):
    for q in range(p, N+1):
        p2X = abs(p - X)
        p2Y = abs(p - Y)
        q2X = abs(q - X)
        q2Y = abs(q - Y)

        distance = min(q-p, p2X+1+q2Y, p2Y+1+q2X)
        k_list[distance] += 1
        
for k in range(1, N):
    print(k_list[k])

Measured memory_bytes: 3444
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        lld n;
        cin>>n;
        if(n==1)
            cout<<0<<endl;
        else
            cout<<add(add(binpow(10,n),-mul(2,binpow(9,n))),binpow(8,n));
    }
}





Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = max(a, c);
    int y = min(b, d);
    if((y - x) < 0){
        cout << 0 << endl;
        return 0;
    }
    cout << y - x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
#include <utility>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, h, w, ans = 0, d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
  scanf("%lld%lld", &h, &w);
  char s[h][w + 10];
  for(i = 0; i < h; ++i) scanf("%s", s[i]);
  bool flg[h][w];
  queue< pair< pair<ll, ll>, ll> > q;
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) {
    if(s[i][j] == '#') q.push({{i, j}, 0}), flg[i][j] = false;
    else flg[i][j] = true;
  }
  while(q.size()) {
    pair<ll, ll> p = q.front().first;
    ll tmp = q.front().second;
    q.pop();
    for(i = 0; i < 4; ++i) if(d[i][0] + p.first >= 0 && d[i][0] + p.first < h && d[i][1] + p.second >= 0 && d[i][1] + p.second < w && flg[d[i][0] + p.first][d[i][1] + p.second]) {
      flg[d[i][0] + p.first][d[i][1] + p.second] = false;
      if(tmp + 1 > ans) ans = tmp + 1;
      q.push({{d[i][0] + p.first, d[i][1] + p.second}, tmp + 1});
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 26420
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

ll kaijo(ll n){
  ll ret = 1;
  for (int i = 2; i <= n; ++i)
  {
    ret = ret * i % MOD;
  }
  return ret;
}

void solve(){
  // main algorithm
  if (abs(N - M) > 1)
  {
    ans = 0;
  }else if(N != M){
    ans = (kaijo(N) * kaijo(M)) % MOD;
  }else{
    ans = (kaijo(N) * kaijo(M)) % MOD * 2 % MOD;
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  Fill(dp, -1);
  cin >> N >> M;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second
#define ff fflush(stdout)

using namespace std;

const int N = 6e6 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main ()
{
	int n;
	cin >> n;
	int x = n % 10;
	if (x == 3)
	{
		cout << "bon";
	}
	else if (x == 0 || x == 1 || x == 6 || x == 8)
	{
		cout << "pon";
	}
	else {
		cout << "hon";
	}
}



Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  int a,b,c,x,y;
  scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
  printf("%d",a+b<c*2?a*x+b*y:x<y?b<c*2?x*c*2+b*(y-x):c*y*2:a<c*2?y*c*2+a*(x-y):c*x*2);
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
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; }


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

    ll n; cin>>n;
    ll a[5]={};
    for(int i=0; i<5; i++){
        cin>>a[i];
    }
    sort(a,a+5);
    ll mi=a[0];
    ll cnt = n/mi+4;
    if(n%mi!=0) cnt++;
   cout<<cnt<<endl;
}

Measured memory_bytes: 3656
N, M = gets.split(' ').map(&:to_i)
A = gets.split(' ').map(&:to_i)
usable = [] # usable[i]: 数字iを使えるかどうか
A.each { |a| usable[a] = true }
nums = [1, 7, 4, 5, 3, 2, 9, 6, 8] # マッチの本数順にソートされた数字
mnums = [nil, 2, 5, 5, 4, 5, 6, 3, 7, 6] # mnums[i]: 数字iのマッチの本数
dp = Array.new(N + 1, -999) # dp[i]: i本のマッチをちょうど使ってできる最大桁数

dp[0] = 0
1.upto(N) do |i|
  nums.each do |num|
    next if !usable[num] || i < mnums[num]
    dp[i] = [dp[i], dp[i - mnums[num]] + 1].max
  end
end

n = N
dp.last.times do
  9.downto(1).each do |num|
    if usable[num] && n >= mnums[num] && dp[n - mnums[num]] == dp[n] - 1
      n -= mnums[num]
      print num
      break
    end
  end
end

puts

Measured memory_bytes: 1916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private int[][] c;
        private void Scan()
        {
            var sc = new Scanner();
            c = new int[3][];
            for (int i = 0; i < 3; i++)
            {
                c[i] = sc.IntArray();
            }
        }

        private bool C(int a1)
        {
            int[] a = new int[3];
            int[] b = new int[3];
            a[0] = a1;

            b[0] = c[0][0] - a[0];
            b[1] = c[0][1] - a[0];
            b[2] = c[0][2] - a[0];
            a[1] = c[1][0] - b[0];
            a[2] = c[2][0] - b[0];
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if(c[i][j]!=a[i]+b[j])
                    {
                        return false;
                    }
                }
            }
            return true;
        }

        public void Solve()
        {
            Scan();
            for(int i=-1000000;i<=1000000;i++)
            {
                if(C(i))
                {
                    Console.WriteLine("Yes");
                    return;
                }

            }
            Console.WriteLine("No");
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 17568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt(),m = sc.nextInt();
		int[] a = new int[m], b = new int[m];
		int[] ca = new int[h+1], cb = new int[w+1];
		for(int i = 0; i < m; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			a[i] = x;
			b[i] = y;
			ca[x]++;
			cb[y]++;
		}
		int ma = 0, mb = 0;
		for(int i = 0; i <= h; i++) {
			if(ca[i] > ma) {
				ma = ca[i];
			}
		}
		for(int i = 0; i <= w; i++) {
			if(cb[i] > mb) {
				mb = cb[i];
			}
		}
		int mpa = 0, mpb = 0;
		for(int i = 0; i <= h; i++) {
			if(ca[i] == ma) {
				mpa++;
			}
		}
		for(int i = 0; i <= w; i++) {
			if(cb[i] == mb) {
				mpb++;
			}
		}
		long mc = mpa*mpb;
		for(int i = 0; i < m; i++) {
			if(ca[a[i]] == ma && cb[b[i]] == mb) {
				mc--;
			}
		}
		if(mc != 0) {
			System.out.println(ma + mb);
		}else {
			System.out.println(ma + mb - 1);
		}
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 62176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();

            if(a[0] >= 'a' && a[0] <= 'z')
            {
                Console.WriteLine("a");
            }
            else
            {
                Console.WriteLine("A");
            }
        }
    }
}

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

using namespace std;


int main(){
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   int k;
   cin>>k;
   cout<<a[k-1];
   return 0;
}

Measured memory_bytes: 256
#
# abc055 b
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10"""
        output = """3628800"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """100000"""
        output = """457992974"""
        self.assertIO(input, output)


def resolve():
    N = int(input())

    ans = 1
    for i in range(1, N+1):
        ans *= i
        ans %= (10**9+7)

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16160
import Control.Monad
import qualified Data.IntMap as IM

solve :: [(Int, Int)] -> [Int] -> [Int]
solve [] _ = []
solve (px:pxs) ts = sum (solve' px ts 1) : solve pxs ts

solve' :: (Int, Int) -> [Int] -> Int -> [Int]
solve' _ [] _ = []
solve' px@(p, x) (t:ts) count = current : solve' px ts (count + 1)
  where current = if p == count
                  then x
                  else t

main :: IO ()
main = do
  getLine
  ts <- map read . words <$> getLine
  let tis = IM.fromList $ zip [1..] ts
  m <- readLn
  let toTuple [x, y] = (x, y)
  pxs <- replicateM m $ toTuple . map read . words <$> getLine :: IO [(Int, Int)]
  mapM_ print $ solve pxs ts

Measured memory_bytes: 1020
#include<stdio.h>

int main(){
  int n,i;
  char s[101],t[101];
  scanf("%d",&n);
  scanf("%s%s",s,t);
  for(i=0;i<n;i++){
    printf("%c",s[i]);
    printf("%c",t[i]);
  }
  return 0;
}

Measured memory_bytes: 128
(defmacro defsolver (name vars &body body)
  `(defun ,name ()
     (let (,@(mapcar #'list
            vars
            (mapcar (constantly '(read))
                vars)))
       ,@body)))

(defsolver solution-a (a b)
  (format t "~a~%"
	  (cond ((<= a 5) 0)
		((>= a 13) b)
		(t (/ b 2)))))

(solution-a)

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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	get(a);
	get(b);
	if(b%a == 0)
	cout << b + a << endl;
	else
	cout << b -a << endl;	

	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
int main() {
cout << fixed << setprecision(30);
  string s;
  cin>>s;
  if(s=="SUN")putout(7);
  if(s=="MON")putout(6);
  if(s=="TUE")putout(5);
  if(s=="WED")putout(4);
  if(s=="THU")putout(3);
  if(s=="FRI")putout(2);
  if(s=="SAT")putout(1);
}


Measured memory_bytes: 256
import heapq

s=input()
k=int(input())
n=len(s)
ans=set()

for i in range(n+1):
    j=1
    while j<=k and i+j<=n:
        ans.add(s[i:i+j])
        j+=1


ansh=[]
for ss in ans:
    heapq.heappush(ansh,ss)
for _ in range(k-1):
    heapq.heappop(ansh)
print(ansh[0])



Measured memory_bytes: 4584
#include <iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size()/2;++i){
    if(s[i]!=s[s.size()-i-1]){
      ans+=1;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] ans = new String[] {"Christmas Eve Eve Eve","Christmas Eve Eve","Christmas Eve","Christmas"};
        System.out.println(ans[N-22]);
        sc.close();
    }
}


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

#define int long long

signed main(){
    int m, d;
    cin >> m >> d;

    int ans = 0;
    for(int i = 2;i < 10;i++){
        for(int j = 2;j < 10;j++){
            int tmp = i * j;
            if(i*10 + j <= d && 1 <= tmp && tmp <= m){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		String N = scan.next();

		String ans = "s";

		if (N.substring(N.length() - 1).equals("s")) {
			ans = "es";
		}

		//結果出力
		System.out.println(N + ans);
	}
}

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

using namespace std;
long long n,i,j,sol,previ=0, mod=1000000007,poz,hor,ver;
char s1[54], s2[54];

int main()
{
    cin>>n;
    cin>>s1>>s2;
    poz=0; previ=-1; sol=3;
    while(poz<n)
    {
        ver=0; hor=0;
        if(poz<n-1 && s1[poz]==s1[poz+1]) hor=1, ver=0, poz+=2;
        else ver=1, hor=0, poz++;
        if(hor)
        {
            if(previ==-1) sol*=2;
            else if(previ==0) sol=(3*sol)%mod;
            else sol=(2*sol)%mod;
            previ=0;
        }
        if(ver)
        {
            if(previ==-1) sol*=1;
            else if(previ==0) sol=(1*sol)%mod;
            else sol=(2*sol)%mod;
            previ=1;
        }
    }
    cout<<sol<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
}

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

LL MOD = 998244353;
void solve(long long N, std::vector<PII> data)
{
  sort(data.begin(), data.end());
  LL ans = 1;
  stack<PII> sta;
  for (auto xd : data)
  {
    LL x = xd.first;
    LL d = xd.second;

    while (!sta.empty())
    {
      auto val = sta.top();
      if (x >= val.first)
      {
        ans += val.second;
        ans %= MOD;
        sta.pop();
      }
      else
        break;
    }
    sta.push(PII(x + d, ans));
  }
  while (!sta.empty())
  {
    ans += sta.top().second;
    ans %= MOD;
    sta.pop();
  }
  cout << ans << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  std::vector<PII> XD(N);
  for (int i = 0; i < N; i++)
  {
    LL a, b;
    scanf("%lld", &a);
    scanf("%lld", &b);
    XD[i] = PII(a, b);
  }
  solve(N, std::move(XD));
  return 0;
}


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

int main() {
	int a, b, c, d, e;

	cin >> a >> b >> c >> d >> e;

	if (a == 0)
		cout << 1 << endl;
	if (b == 0)
		cout << 2 << endl;
	if (c == 0)
		cout << 3 << endl;
	if (d == 0)
		cout << 4 << endl;
	if (e == 0)
		cout << 5 << endl;
}

Measured memory_bytes: 3136
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
vector<ll> v;

struct C
{
    ll x, y, h;
};
int cnt = 0;
int N;

int h[110];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> h[i];
    }
    int ans = 0;
    while (1)
    {
        if (*max_element(h, h + N) == 0)
            break;

        for (int i = 0; i < N; ++i)
        {
            if (h[i] == 0)
                continue;
            for (int j = i; j < N; ++j)
            {
                if (h[j] == 0)
                    break;
                h[j]--;
            }
            break;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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


int32_t main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<n;++i){
            ans+= ((n+i-1)/i)-1;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3520
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int w, h, x, y, r;

	cin >> w >> h >> x >> y >> r;

	w -= r;
	h -= r;
	if(0 <= x && x <= w) {
		if(0 <= y && y <= h) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int n,t,r=0,d=-1;
  cin>>n>>t;
  vector<int> a;
  for(int i=0,j=-1,c;i<n;++i){
    cin>>c;
    if(i<2||(a[j-1]<a[j]&&a[j]>c)||(a[j-1]>a[j]&&a[j]<c))j++,a.push_back(c);
    else if((a[j-1]<a[j]&&a[j]<c)||(a[j-1]>a[j]&&a[j]>c))a[j]=c;
  }
  n=a.size();
  for(int i=1,m=a[0];i<n;++i){
    if(a[i]-m==d)r++;
    if(a[i]-m>d)r=1;
    d=max(d,a[i]-m);
    m=min(m,a[i]);
  }
  cout<<r;
}

Measured memory_bytes: 1400
import math
n = input()
A = 0

def is_prime(m):
	for i in range(2, int(math.sqrt(m)) + 1):
		if (m % i == 0):
			return False
	return True

for i in range(n):
	k = input()
	if is_prime(k):
		A += 1

print A

Measured memory_bytes: 6988
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 2e5+10;
int d[20][SIZE];
int N,a[SIZE];
int main(){
    R(N);
    FOR(i,1,N){
        R(a[i]);
    }
    REP(j,20)d[j][N+2]=d[j][N+1]=N+1;
    for(int i=N;i>0;i--){
        REP(j,20)d[j][i]=d[j][i+1];
        REP(j,20){
            if((a[i]>>j)&1)d[j][i]=i;
        }
    }
    LL an=0;
    FOR(i,1,N){
        int mi=N;
        REP(j,20){
            mi=min(mi,d[j][d[j][i]+1]-1);
        }
        an+=mi-i+1;
    }
    W(an);
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  bool flag=false;
  for (int i=0; i<=N/7; i++){
    if ((N-7*i)%4==0){
      flag=true;
    }
  }
  if (flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3632
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	string ans = "Yes";
	rep(i, a) {
		if (s[i] == '-') {
			ans = "No";
		}
	}
		if (s[a] != '-') {
			ans = "No";
		}
	rep(i, b) {
		if (s[a + i + 1] == '-') {
			ans = "No";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
S = list(input())
T = list(input())
s = []
t = []
s_num = []
t_num = []
for Si, Ti in zip(S, T):
    if not Si in s:
        s.append(Si)
    if not Ti in t:
        t.append(Ti)
for Si, Ti in zip(S, T):
    s_num.append(str(s.index(Si)))
    t_num.append(str(t.index(Ti)))
# print(S, T, s, t)
# print(s_num)
# print(t_num)
# print(''.join(s_num))
# print(''.join(t_num))

if ''.join(s_num) == ''.join(t_num):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 32304