akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define mem(a,b) memset(a,b,sizeof(a))
#define endl "\n"
#define mod 1000000007
#define PI 3.1415926535897932384626
#define pq priority_queue
#define pb push_back
#define mp make_pair
using namespace std;
/*
int gcd(int x,int y)
{
    if(x%y==0)
    return y;
    return gcd(y,x%y);
}

int no1(int x)
{
    int count=0;
    while(x)
    {
        if(x%2)
        count++;
        x=x>>1;
    }
    return count;
}
ll power(int  b,int p)
{
    if(p==0)
    return 1;
    ll temp=power(b,p/2);
    temp=temp*temp;
    if(p%2==1)

    temp=temp*b;
    return temp;
}
bool cmp(const pair<int, pair<int,int> > & p1,const pair<int, pair<int,int> > & p2)
{
    if(p1.first>p2.first)
        return true;
    if(p1.first==p2.first&&p1.second.first<p2.second.first)
        return true;
    return false;
}
*/
int jump(int i,int h[],int dp[],int n,int k)
{
    if(i==n-1)
        return 0;

    if(dp[i]!=-1)
        return dp[i];
    dp[i]=INT_MAX;
    for(int j=1;j<=k&&i+j<n;j++)
        dp[i]=min(dp[i],abs(h[i+j]-h[i])+jump(i+j,h,dp,n,k));
    return dp[i];
}
int main()
{
    int n;
    int h[100005];
    cin>>n;
    int k;
    cin>>k;

    for(int i=0;i<n;i++)
        cin>>h[i];
    int dp[100005];
    for(int i=0;i<100005;i++)
        dp[i]=-1;
    cout<<jump(0,h,dp,n,k);
    return 0;

}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define ll  int
using namespace std;
int main() {
    ll n,d;
    cin>>n>>d;
    ll a[n][d];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<d;j++)cin>>a[i][j];
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ll r=0;
            for(ll k=0;k<d;k++){
                r+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
            long double r1=sqrt(r);
            
            if(r1-floor(sqrt(r))==0)ans++;
        }
    }
    cout<<ans<<"\n";
    
}



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

int main() {
  const ll MOD = 1000000007;
  ll N,K; cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  
  ll count  = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      if (A[j] < A[i]) count++;
    }
  }
  
  ll countK = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A[j] < A[i]) countK++;
    }
  }
  
  ll p = K * count % MOD;
  ll q = K * (K-1) / 2 % MOD;
  q = countK * q % MOD;
  ll pq = (p + q) % MOD;
  
  cout << pq << endl;  
}

Measured memory_bytes: 256
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [a, b, n] = input[0].split(" ").map((x: string): number => +x);

const x = n < b ? n : b - 1;
console.log(Math.floor((x * a) / b));

Measured memory_bytes: 29588
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	ll n; cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 15 != 0) {
			if (i % 5 != 0 && i % 3 != 0) {
				sum += i;
			}
		}
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int r;
    cin >> r;
    string ans;
    if(r < 1200)
        ans = "ABC";
    else if(r < 2800)
        ans = "ARC";
    else
        ans = "AGC";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int d = N % 10;
	N /= 10;
	int c = N % 10;
	N /= 10;
	int b = N % 10;
	N /= 10;
	int a = N % 10;
	
	if (a + b + c + d == 7) {
		cout << a << "+" << b << "+" << c << "+" << d << "=" << 7 << endl;
	}
	else if (a - b + c + d == 7) {
		cout << a << "-" << b << "+" << c << "+" << d << "=" << 7 << endl;
	}
	else if (a + b - c + d == 7) {
		cout << a << "+" << b << "-" << c << "+" << d << "=" << 7 << endl;
	}
	else if (a + b + c - d == 7) {
		cout << a << "+" << b << "+" << c << "-" << d << "=" << 7 << endl;
	}
	else if (a + b - c - d == 7) {
		cout << a << "+" << b << "-" << c << "-" << d << "=" << 7 << endl;
	}
	else if (a - b + c - d == 7) {
		cout << a << "-" << b << "+" << c << "-" << d << "=" << 7 << endl;
	}
	else if (a - b - c + d == 7) {
		cout << a << "-" << b << "-" << c << "+" << d << "=" << 7 << endl;
	}
	else if (a - b - c - d == 7) {
		cout << a << "-" << b << "-" << c << "-" << d << "=" << 7 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
int n,a[100010],mo=1e9+7,b,f[100010],jie[100010],inv[100010],ans;
template<class T>
inline void read(T&a){
	char c=getchar();
	for(a=0;c<'0'||c>'9';c=getchar());
	for(;c>='0'&&c<='9';c=getchar())a=a*10+c-'0';
}
inline int ksm(int x,int y){
	int ans=1;
	for(;y;y>>=1){
		if(y&1)ans=(long long)ans*x%mo;
		x=(long long)x*x%mo;
	}
	return ans;
}
int main(){
	read(n);n++;jie[0]=1;
	for(int i=1;i<=n;i++)read(a[i]),f[a[i]]?b=i:f[a[i]]=i,jie[i]=(long long)jie[i-1]*i%mo;
	inv[n]=ksm(jie[n],mo-2);inv[0]=1;
	for(int i=n-1;i;i--)inv[i]=(long long)inv[i+1]*(i+1)%mo;
	printf("%d\n",n-1);
	for(int i=2;i<n;i++){
		ans=(long long)jie[n]*inv[n-i]%mo*inv[i]%mo;
		if(i<=f[a[b]]+n-b)ans-=(long long)jie[f[a[b]]+n-b-1]*inv[i-1]%mo*inv[f[a[b]]+n-b-i]%mo;
		printf("%d\n",(ans+mo)%mo);
	}
	puts("1");
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define inv(x) qpow(x,mod-2)
const int mod = 998244353;
const int N = 1e6+1;
using namespace std;
typedef long long ll;

ll fac[N],rev[N],n,m;

ll qpow(ll a,int b)
{
	ll ret=1;
	while(b)
	{
		if(b&1)ret=(ret*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return ret;
}
 
ll C(ll n,ll m){return n<m?0:fac[n]*rev[m]%mod*rev[n-m]%mod;}

int main()
{
	fac[0]=1;
	for(ll i=1;i<N;++i)fac[i]=(fac[i-1]*i)%mod;
	rev[N-1]=inv(fac[N-1]);
	for(int i=N-2;i>=0;--i)rev[i]=(rev[i+1]*(i+1))%mod;
	cin>>n>>m;
	if(n<m)swap(n,m);
	ll sum=0;
	for(ll i=2;i<=n+m;i+=2)
	{
		ll k=i/2;
		if(m<k)continue;
		ll ret=1;
		(ret*=C(2*k,k))%=mod;
		(ret*=C(m+n-2*k,m-k))%=mod;
		(sum+=ret)%=mod;
	}
	sum=(sum*rev[2])%mod;sum=(sum*rev[m+n])%mod;
	sum=(sum*fac[m])%mod;sum=(sum*fac[n])%mod;
	(n+=sum)%=mod;
	while(n<0)n+=mod;
	cout<<n;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m;
string s;

int main(){
	cin >> n >> m >> s;
	int flag=0;
	for(int i=0;i<s.size();i++){
		if(i!=n&&(s[i]<'0'||s[i]>'9')){
			flag=1;
		}else if(i==n&&s[i]!='-'){
			flag=1;
		}
	}
	if(flag){
		cout << "No" << endl;	
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;

int main() {
	speed;
	int n;
	cin >> n;
	vector<ll>a(n + 1);
	vector<ll>b(n);
	rep(i, n + 1) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	ll delta = min(a[0], b[0]);
	ll sum = delta;
	ll d;
	rep(i,n) {
		if (i > 0) {
			delta = min(a[i] - d, b[i]);
			sum += delta;
		}
		d = min(a[i + 1], b[i] - delta);
		sum += d;
	}

	c(sum);
	ed;
	return 0; 
}



Measured memory_bytes: 1792
import Data.Array
import Data.Array.ST
import Data.Array.MArray
import Control.Monad
import Control.Monad.ST

solve n goods w = runST $ do
  dp <- newArray ((0,0), (n,w)) (-1)
  f dp 0 w where
    gary = listArray (0, n-1) goods
    f :: STUArray s (Int,Int) Int -> Int -> Int -> ST s Int
    f dp i j = do
      mem <- readArray dp (i, j)
      if mem /= -1 then
        return mem
      else do
        res <- res
        writeArray dp (i, j) res
        return res
      where
        (wi, vi) = gary ! i
        res
          | i == n = return 0
          | j < wi = nxt
          | otherwise = liftM2 max nxt nx'
          where
            nxt = f dp (i+1) j
            nx' = (+vi) <$> f dp (i+1) (j-wi)

main = do
  [n,w] <- map read.words <$> getLine
  goods <- replicateM n $ (\[a,b]->(a,b)).map read.words <$> getLine
  print $ solve n goods w

Measured memory_bytes: 79996
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

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

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

struct less_key {
    bool operator() (const pair<i64, i64>& p1, const pair<i64, i64>& p2)  const {
        return p1.first < p2.first;
    }
};

const i64 MAXN = 300005;

i64 n;
pair<i64, i64> a[MAXN];
bool e[MAXN];
bool z[MAXN];

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;

    map < i64, vector<pair<bool, i64>>> q;

    for (i64 i = 0; i < n; i++) {
        i64 x, l;
        cin >> x >> l;
        a[i].first = x - l;
        a[i].second = x + l;
    }

    for (i64 i = 0; i < n; i++) {
        q[a[i].first].push_back({ false, i });
        q[a[i].second].push_back({ true, i });
    }

    map<i64, set<i64>> s2i;

    for (auto& p : q) {
        for (auto v : p.second) {
            i64 i = v.second;
            if (!v.first) {
                s2i[a[i].first].insert(i);
            }
            else {
                s2i[a[i].first].erase(i);
                if (s2i[a[i].first].empty()) {
                    s2i.erase(a[i].first);
                }
                auto it = s2i.begin();
                while (it != s2i.end()) {
                    if (it->first > a[i].first) {
                        break;
                    }
                    for (auto t : it->second) {
                        e[t] = 1;
                    }
                    s2i.erase(it++);
                }
            }
        }
    }

    vector<pair<i64, i64>> u;
    for (i64 i = 0; i < n; i++) {
        if (!e[i]) {
            u.push_back(a[i]);
        }
    }
    sort(u.begin(), u.end(), less_key());

    i64 R = 0;
    i64 r = u[0].first;
    for (i64 i = 0; i < u.size(); i++) {
        if (u[i].first >= r) {
            r = u[i].second;
            R++;
        }
    }
    cout << R << endl;

    return 0;
}

Measured memory_bytes: 32896
#include <stdio.h>

int main(void){
    int N, M, P;
    int X[100];
    int i,j;
    int gold;
    while(1){
        gold=0;
        fscanf(stdin,"%d",&N);
        fscanf(stdin,"%d",&M);
        fscanf(stdin,"%d",&P);
        if(N==0 && M==0 && P==0){
            break;
        }
        for(i=0;i<N;i++){
            fscanf(stdin,"%d",&X[i]);
        }
        if(X[M-1] == 0){
            printf("0\n");
        }else{
            for(j=0;j<N;j++){
                gold = gold + X[j]*100;
            }
            gold = gold*(100-P)/100.0;
            printf("%d\n",gold/X[M-1]);
        }
    }
    return 0;
}

Measured memory_bytes: 616
#include<stdio.h>

#define INF 1000000000
#define MAX 500000

typedef struct{
  int next;
  int back;
  int cost;
} Edge;

int main(){
  int i,j,n,k,u,v,c,count=0,flag=1;
  Edge E[MAX];
  int w[10000];

  scanf("%d",&n);

for(i=0;i<n;i++){
  scanf("%d %d",&u,&k);
  for(j=0;j<k;j++){
    E[count].back=u;
    scanf("%d %d",&v,&c);
    E[count].next=v;
    E[count].cost=c;
    count++;
    }
  }

for(i=0;i<n;i++){
  w[i]=INF;
}

w[0]=0;

while(flag!=0){
  flag=0;
  for(i=0;i<count;i++){
    if((E[i].cost+w[E[i].back])<w[E[i].next]){
      flag=1;
      w[E[i].next]=E[i].cost+w[E[i].back];
    }
  }
}


for(i=0;i<n;i++){
  printf("%d %d\n",i,w[i]);
}

return 0;
}



Measured memory_bytes: 7564
#include <iostream>
#include<string>
#include<vector>
#include <climits>
using namespace std;

int main() {
	string longW,shortW;
	int a, b, c,ans=INT_MAX;
	cin >> longW >> shortW;
	a = longW.size();
	b = shortW.size();
	c = a - b;
	for (int i=0;i<=c;i++) {
		int d = 0;
		for (int j=0;j<shortW.size();j++) {
			d+=(longW.at(i+j)!=shortW.at(j));
		}
		ans = min(ans, d);

	}
	cout << ans << endl;
	
}


Measured memory_bytes: 3612
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

n,x = readInts()
a = readInts()
a.sort()
ans = []

if a[0]>x:
	print(0)
	exit()
elif sum(a)<x:
	print(len(a)-1)
	exit()

for i in range(1,len(a)+1):
	if sum(a[:i])<=x:
		ans = a[:i]
	else:
		break


print(len(ans))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N;
  vector<string> blue(N);
  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }
  cin >> M;
  vector<string> red(M);
  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }
  int ans = 0;
  int nb, nr;
  string b;
  bool is_first;
  for (int i = 0; i < N; i++) {
    b = blue.at(i);
    nb = 0;
    nr = 0;
    is_first = true;
    for (int j = 0; j < N; j++) {
      if (b == blue.at(j)) {
        if (j < i) {
          is_first = false;
          break;
        }
        nb++;
      }
    }
    if (!is_first) {
      continue;
    }
    for (int j = 0; j < M; j++) {
      if (b == red.at(j)) {
        nr ++;
      }
    }
    ans = max({ans, nb-nr});
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
// #include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
// using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

typedef vector<int> vec;
typedef vector<vec> mat;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

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

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

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N, V, P;
    Int M;
    cin >> N >> M >> V >> P;
    vector<Int> A(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    vector<Int> cumsum(N+1);
    
    for (int i = 1; i <= N; i++) {
        cumsum[i] = A[i] + cumsum[i-1];
    }

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        // cout << "Checking : A" << i << " = " << A[i] << endl; 
        Int voted_Ai = A[i] + M;
        int greater_idx = (int)(lower_bound(A.begin(), A.end(), voted_Ai + 1) - A.begin());
        int less_or_equal_idx = (int)(lower_bound(A.begin(), A.end(), A[i] + 1) - A.begin()) - 1;
        int remain_V = V - (N - greater_idx + 1) - less_or_equal_idx;
        if (N - greater_idx + 1 > P - 1) continue;
        int already_voted = 0;
        if (P - (N - greater_idx + 2) >= 0) {
            remain_V -= P - (N - greater_idx + 2);
            already_voted = P - (N - greater_idx + 2);
        }
        if (remain_V <= 0) {
            ans++;
        } else {
            Int sum = (A[i] + M) * (greater_idx - 1 - already_voted - less_or_equal_idx);
            sum -= cumsum[greater_idx - 1 - already_voted] - cumsum[less_or_equal_idx];
            // cout << "remain_V = " << remain_V << " , greater_idx = " << greater_idx << " , less_or_equal_ = " << less_or_equal_idx << endl;
            if (sum >= remain_V * M) {
                ans++;
            } 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys

def solve():
    n = int(input())
    s = [int(input()) for i in range(n)]
    s.sort()

    ssum = sum(s)

    if ssum % 10:
        print(ssum)
    else:
        for si in s:
            if si % 10:
                print(ssum - si)
                return

        print(0)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ld long double
int main(){
	int l;
	cin >> l;
	long double a, b, c;
	a = b = c = (ld)l/3;

	cout << fixed << setprecision(10) <<(ld)a*b*c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s, a = "";
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != 'x')
			a += s[i];
	}
	bool l = 1;
	for (int i = 0; i < ceil(a.size() / 2.0); i++) {
		if (a[i] != a[a.size() - i - 1])
			l = 0;
	}
	if (!l) {
		cout << -1 << endl;
		return 0;
	}
	int e = s.size() - 1, sum = 0, i = 0;
	while (i < e) {
		if (s[i] != s[e]) {
			sum++;
			if (s[e] == 'x') 
				e--;
			else
				i++;
		}
		else
			e--, i++;
	}
	cout << sum << endl;
	getchar(); getchar();
}

Measured memory_bytes: 640
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
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
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(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()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, m = MAP()
arr = [[] for _ in range(n)]
for _ in range(m):
    s, c = MAP()
    arr[s - 1].append(c)
tmp1 = [len(set(arr[i])) for i in range(n)]
tmp2 = [set([0]), set([1]), set([0, 1])]
if not set(tmp1) in tmp2 or (len(arr[0]) and arr[0][0] == 0 and n != 1):
    print(-1)
    exit()
ans = [str(arr[i][0]) if tmp1[i] else '0' for i in range(n)]
if ans[0] == '0' and n > 1:
    ans[0] = '1'
print(''.join(ans))


Measured memory_bytes: 59628
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int a, b;

int main()
{
	cin >> a >> b;

	int c = a + b;

	while (c >= 24) {
		c -= 24;
	}
	cout << c << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	
	static int n;
	static int p;
	static int[] arr;
	
	static Long[][] dp;
	
	public static void main(String[] args) {
	
		Scanner in = new Scanner(System.in);

		n = in.nextInt();
		p = in.nextInt();
		
		arr = new int[n];
		
		for(int i=0; i<n; i++) {
			arr[i] = in.nextInt();
		}
		
		dp = new Long[n][2];
		
		System.out.println(rec(0, 0));
	}

	private static long rec(int i, int m) {
		if(i == n) {
			if(m == p) {
				return 1;
			}
			
			return 0;
		}
		else if(dp[i][m] != null ) {
			return dp[i][m];
		}
		else {
			
			return dp[i][m] = rec(i+1, (m + arr[i]) % 2) + rec(i+1, m);
		}
		
	}
}


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


int main(){
    int A1, A2, A3;

    cin >> A1 >> A2 >> A3;

    if(A1 + A2 + A3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}

Measured memory_bytes: 256
N= gets.chomp.to_i
ary = gets.chomp.split(" ").map{|e| e.to_i}
tmp = ary.shift
argv_gcd = tmp.gcd(ary.shift)
ary.each do | num |
  argv_gcd = argv_gcd.gcd(num.to_i)
end
puts argv_gcd


Measured memory_bytes: 9476
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int gcd(int a,int b){
    if(a<b) swap(a,b);
    return (a%b ? gcd(a%b,b) : b);
}
int main(){
    string str;
    while(cin >> str){
        int dir = 0,cnt = -1;
        if(str == "#") break;
        vector<int> vec;
        rep(i,str.size()){
            if(str[i] == 'n'){
                vec.push_back(0);
                i += 4;
            }
            else {
                vec.push_back(1);
                i += 3;
            }
        }
        reverse(vec.begin(),vec.end());
        rep(i,vec.size()){
            if(vec[i] == 1){
                dir = dir*2+90;
            }
            else {
                dir = dir*2-90;
                if(dir < 0) dir = 0;
            }
            cnt++;
        }
        if(dir == 0) {
            cout << 0 << endl;
            continue;
        }
        cnt = 1 << cnt;
        int a = gcd(dir,cnt);
        cout << dir/a;
        if(cnt/a != 1) cout << '/' << cnt/a;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <stack>
#include <string>

using namespace std;

const int MAXN = 100;

struct Tree{
    int x;
    int y;
    char type;
    Tree(int x_=-1, int y_=-1, char type_='@'){
        x = x_;
        y = y_;
        type = type_;
    }
};

bool visit[MAXN][MAXN];
char tree_map[MAXN][MAXN];
int H, W;
int ans;
int dir[4][2] = {{1,0}, {-1,0}, {0,1}, {0,-1}};
stack<Tree> s;

void initialize(){
    ans = 0;
    while(!s.empty()){
        s.pop();
    }
}

bool DFS(int x, int y){
    if(visit[x][y])
        return false;
    s.push(Tree(x, y, tree_map[x][y]));
    visit[x][y] = true;
    while(!s.empty()){
        Tree cuur = s.top();
        s.pop();
        for(int i=0; i<4; ++i){
            int x_new = cuur.x + dir[i][0];
            int y_new = cuur.y + dir[i][1];
            if(x_new<0 || x_new>=H || y_new<0 || y_new>=W || visit[x_new][y_new])
                continue;
            if(tree_map[x_new][y_new] != cuur.type)
                continue;
            visit[x_new][y_new] = true;
            s.push(Tree(x_new, y_new, cuur.type));
        }
    }
    return true;
}

int solve(){
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            if(DFS(i, j))
                ++ans;
        }
    }
    return ans;
}

int main(){
    while(cin>>H>>W, H||W){
        for(int i=0; i<H; ++i){
            string str;
            cin >> str;
            for(int j=0; j<W; ++j){
                tree_map[i][j] = str[j];
                visit[i][j] = false;
            }
        }
        initialize();
        cout << solve() << endl;
    }
    return 0;
}




Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n;
    cin >> n;
    vector<ll> A(n);
    for(int i=0;i<n;i++){
        cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    cout << A.at(0) <<" " <<A.at(n-1)<<" "<< accumulate(A.begin(),A.end(),0LL) <<endl;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int main(){
    int a;cin>>a;
    string s;cin>>s;
    if(a>=3200)cout<<s<<endl;
    else cout<<"red"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int k;
  cin >> k;
  int a[40] = {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};
  cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
const long long MOD = 1e9 + 7;
const int N = 500044;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

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

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

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

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

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

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

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

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

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

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

int n;
int cnt[N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a >= N) ans++;
        else cnt[a]++;
    }
    for (int i = 1; i < N; i++)
    {
        if (cnt[i] >= i) ans += cnt[i] - i;
        else ans += cnt[i];
    }
    cout << ans;
}

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


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.length();
    int l = 0, r = n-1;
    int ans = 0;
    while(l < r){
        if(s[l] == s[r]){
            l++;
            r--;
        }
        else{
            if(s[l] == 'x'){
                l++;
                ans++;
            }
            else if(s[r] == 'x'){
                r--;
                ans++;
            }
            else{
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
n,y = map(int,input().split())
y //= 1000
f = 0
for s in range(n+1):
    for t in range(n+1-s):
        if s+t*5+(n-s-t)*10 == y:
            f = 1
            print(n-s-t,t,s)
            break
    if f == 1:
        break
else:
    print(-1,-1,-1)

Measured memory_bytes: 9168
#include <iostream>

using namespace std;

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

	cin >> a >> b >> c;

	int d = a * 4 + b * 2 + c;

	if (d == 1 || d == 6)
	{
		cout << "Open" << endl;
	}
	else
	{
		cout << "Close" << endl;
	}

	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  getline(cin, s);
  for (int i = 0; i < s.length(); i++) {
    if (isalpha(s[i])) {
      if (islower(s[i])) {
        s[i] = toupper(s[i]);
      } else {
        s[i] = tolower(s[i]);
      }
    }
  }
  cout << s << '\n';
  return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  double odd = (N+1) / 2;
  double ans = odd / N;
  printf("%.10f", ans);
  return 0;
}

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

int count(int x){
  int m = 0;
  while(x%2==0){
    x /= 2;
    m++;
  }
  return m;
}

int main(){
  int N,n,A[201],max;
  
    cin >> N>> A[1];
    max = count(A[1]);
  for(n=2;n<=N;n++){
    cin >> A[n];
    if(count(A[n]) < max) max = count(A[n]);
  }
  cout << max << endl;
}

Measured memory_bytes: 3584
# ABC 110 D
# Math
import math, collections
N, M = map(int,input().split())
MOD = 7+10**9

if M == 1:
    print(1)
    exit(0)

# prime factorization
Q = []
k = 2
while k < M:
    if M%k == 0:
        Q.append(k)
        M //= k
    else:
        k += 1
Q.append(k)

R = collections.Counter(Q)

def nCr(n,r):
    return (math.factorial(n)//(math.factorial(r)*math.factorial(n-r)))%MOD

ans = 1
for f in R:
    ans *= nCr(N+R[f]-1,R[f])
    ans %= MOD
print(ans)


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

int main() {
  int n, k;
  cin >> n >> k;
  
  vector<int> vec(n,1);
  
  for (int i=0; i<k; i++){
    int d;
    cin >> d;
    for (int j=0; j<d; j++){
      int a;
      cin >> a;
      vec.at(a-1)=0;
    }
  }
  
  int ans=0;
  
  for (int i=0; i<n; i++){
    ans+=vec.at(i);
  }

  cout << ans << endl;
}

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

int main(){
  int s;
  cin >> s;
  vector<long long> dp(s, 0);
  for(int i=0; i<s; i++){
    if(i<2) dp[i] = 0;
    else if(i==2) dp[i] = 1;
    else dp[i] = (dp[i-1] + dp[i-3])%(1000000007);
  }
  cout << dp[s-1];
}

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

void chmax(int& a, int b) {
    if (a < b) a = b;
}

int dp[3001][3001];
int main() {
    string a, b;
    cin >> a >> b;

    for (int i = 0; i < a.size(); i++) {
        for (int j = 0; j < b.size(); j++) {
            chmax(dp[i + 1][j + 1], dp[i + 1][j]);
            chmax(dp[i + 1][j + 1], dp[i][j + 1]);
            if (a[i] == b[j]) {
                chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            }
        }
    }

    string ans = "";
    int i = a.size(), j = b.size();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i - 1][j]) {
            i--;
        } else if (dp[i][j] == dp[i][j - 1]) {
            j--;
        } else {
            ans = a[i - 1] + ans;
            i--;
            j--;
        }
    }

    cout << ans << endl;
}


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

using namespace std;

int main(){

	int n, flag;
	int hmax=0;
	int hsum=0;
	int rdc=0;
	vector<int> h;

	cin>> n;

	h.resize(n);

	for(int i=0;i<n;i++){
		cin>> h[i];
		hsum+=h[i];
		if(hmax<h[i]) hmax=h[i];
	}

	//
	//cout<< hsum << " " << hmax << "\n";
	//

	for(int i=0;i<hmax;i++){
		flag=0;
		for(int j=0;j<n;j++){
			if(i+1<=h[j]){
				if(flag==1){
					rdc++;
					//cout<< "rdc";//
				}else{
					flag=1;
				}
			}else{
				flag=0;
			}
		//cout<< "\n";//
		}	
	//cout<< "\n";//
	}

	cout<< hsum-rdc << "\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 9;
int n,m,k; 
int a[N];
string str;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    memset(a,-1,sizeof(a));
    for(int i=0;i<9;i++){
    		cin>>a[i];
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>k;
		for(int j=0;j<9;j++){
			if(k==a[j]){
				a[j]=-1;
				break;
			}
		}
	}
	if(a[0]==-1 && a[1]==-1&& a[2]==-1||a[3]==-1 && a[4]==-1&& a[5]==-1 ||a[6]==-1 && a[7]==-1&& a[8]==-1
	|| a[0]==-1 && a[3]==-1&& a[6]==-1||a[1]==-1 && a[4]==-1&& a[7]==-1 ||a[2]==-1 && a[5]==-1&& a[8]==-1
	|| a[0]==-1 && a[4]==-1&& a[8]==-1||a[2]==-1 && a[4]==-1&& a[6]==-1 )cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var S string
	var K int
	fmt.Scan(&S)
	s := strings.Split(S, "")
	n := len(s)
	fmt.Scan(&K)
	//i桁目まで決めて
	//j個の非0を使って
	//k:0->そこまでの桁はNと一致
	//k:1->そこまでの桁で既にN以下であることが確定
	var dp[105][4][2] int
	dp[0][0][0] = 1
	for i := 0; i < n; i++ {
		for j := 0; j < 4; j++ {
			for k := 0; k < 2; k++ {
				tmp, _ := strconv.Atoi(s[i])
				nd := tmp - 0
				for d := 0; d < 10; d++ {
					ni := i+1; nj := j; nk := k
					if d != 0 {
						nj++
					}
					if nj > K {
						continue
					}
					if k == 0 {
						if d > nd {
							continue
						}
						if d < nd {
							nk = 1
						}
					}
					dp[ni][nj][nk] += dp[i][j][k]
				}
			}
		}
	}
	ans := dp[n][K][0] + dp[n][K][1]
	fmt.Println(ans)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;
bool compare(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b){
    return a.second < b.second;
}

int main(){
  int m;cin >> m;
  int n;cin >> n;    
  int a,b;
  pair<pair<int,int>,int> p[n];
  rep{
      cin >> a >> b;
      p[i] = make_pair(make_pair(a,b),i+1);
  }
  sort(p,p+n);
  p[0].first.second = 1;
  for(int i = 1;i<n;i++){
      if(p[i-1].first.first == p[i].first.first){
          p[i].first.second = p[i-1].first.second + 1;
      }else{
          p[i].first.second = 1;
      }
  }
  sort(p,p+n,compare);
  rep{
      cout << setfill('0') << right << setw(6) << p[i].first.first;
      cout << setfill('0') << right << setw(6) << p[i].first.second << endl;
  }
} 

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

int main(){
	
	int n;
	cin>>n;
	string s;
	cin>>s;
	int count = 0;
	for(int i = 0 ; i < n ; i++){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
			count++;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const long long MOD=1000000007;

int main(){
  long long n;
  cin>>n;
  long long temp=1;
  long long def=1;
  long long def2=1;
  for(int i=0;i<n;i++){
    temp*=10;
    temp%=MOD;
    def*=9;
    def%=MOD;
    def2*=8;
    def2%=MOD;
  }
       
  if(n<2){
    cout<<0<<endl;
    return 0;
  }
  
  if(temp-def*2+def2<0){
    temp+=MOD;
  }
  if(temp-def*2+def2<0){
    temp+=MOD;
  }
  cout<<temp-def*2+def2<<endl;
    
  
  
  return 0;
}


Measured memory_bytes: 3600
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

X = int(input())

n = X//100
if X <= 105 * n:
    print(1)
else:
    print(0)


Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}

using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n;
  cin>>n;
  long long t[n];
  long long a[n];
  REP(i,n){
    cin>>t[i];
  }
  REP(i,n){
    cin>>a[i];
  }
  //vector used(n,false);//hの値が確定しているかどうかを持つ配列
  vector<long long> ht(n, -1);
  vector<long long> ha(n, -1);
  REP(i,n){
    if(i==0){
      ht[i]=t[i];
    }else{
      if(t[i-1]<t[i]){
        ht[i] = t[i];
      }else{
        continue;
      }
    }
  }
  for(int i=n-1;i>=0;i--){
    if(i==n-1){
      ha[i] = a[i];
    }else{
      if(a[i+1]<a[i]){
        ha[i] = a[i];
      }else{
        continue;
      }
    }
  }
  
  bool flag = true;
  REP(i,n){
    if(ht[i]>0 && ha[i]>0 && ht[i]!=ha[i]){
      flag = false;
      break;
    }
    if(ht[i]==ha[i]){
      continue;
    }
    if(ht[i]==-1){
      ht[i] = ha[i];
    }
    if(ha[i]==-1){
      ha[i] = ht[i];
    }
  }
  
  if(!flag){
    cout<<0<<endl;
    return 0;
  }
  
  long long ans=1;
  long long temp;
  REP(i,n){
    if(ht[i]>0){
      if(ht[i] > a[i]){
        ans = 0;
        break;
      }
      continue;
    }else{
      temp = min(t[i], a[i]);
      ans *= temp;
      ans = mod(ans);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3328
from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]
ans = sum(a)
key = Counter(a)

q = int(input())
for i in range(q):
  b, c = map(int, input().split())
  if b in key and key[b] > 0:
    sub = key[b]
    ans += (c-b)*sub
    if c in key:
      key[c] += sub
    else:
      key[c] = sub
    key[b] = 0
  print(ans)
    

Measured memory_bytes: 21360
a = []
mn = 10
ans = 0
for i in range(5):
    a.append(int(input()))
    x = a[i]%10
    if(x!=0 and x<mn):
        mn = x
    if(x==0):
        ans += a[i]
    else:
        ans += a[i] + 10 - x
ans += mn - 10
print(ans)




Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}

int main() {
	int n, i, ans[55], p = 0,k,flag;
	cin >> n;
	k = 2;
	while (p < n) {
		flag = 1;
		for (i = 2; i*i <= k; i++) {
			if (k%i == 0) {
				flag--;
				break;
			}
		}
		if (flag) {
			ans[p] = k;
			p++;
		}
		k += 5;
	}
	for (i = 0; i < n; i++)
		cout << ans[i] << " ";
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int xs[10010] = {};
    for(int i = 0; i < n; ++i){
        int temp;
        scanf("%d", &temp);
        ++xs[temp];
    }
    bool yet = true;
    for(int i = 0; i <= 10000; ++i){
        if(xs[i] > 0){
            for(int j = 0; j < xs[i]; ++j){
                if(yet){
                    printf("%d", i);
                    yet = false;
                } else {
                    printf(" %d", i);
                }
            }
        }
    }
    cout << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 220000
vector<vector<pll>>is(MAXN);

struct Seg{
  vector<ll>mx, sum;
  Seg(){
    mx.resize(1<<19);
    sum.resize(1<<19);
  }

  void add(ll l, ll r, ll score, ll pos=1,  ll bottom = 0, ll top = 1<<18){
    if(r<=bottom || top<=l)return;
    if(l<=bottom && top <= r){
      sum[pos] += score; return;
    }

    ll mid = (bottom+top)/2;
    add(l, r, score, pos*2, bottom, mid);
    add(l, r, score, pos*2+1, mid, top);
    mx[pos] = max<ll>(mx[pos*2]+sum[pos*2], mx[pos*2+1]+sum[pos*2+1]);
  }

  ll max_val(ll l, ll r, ll pos=1, ll bottom=0, ll top=1<<18){
    if(top <= l || r <= bottom)return -INF;
    if(l <= bottom && top <= r)return mx[pos]+sum[pos];

    ll mid = (bottom + top)/2;
    return max<ll>(
      max_val(l, r, pos*2, bottom, mid),
      max_val(l, r, pos*2+1, mid, top)
    )+sum[pos];
  }
};

int main(){
  ll n,m;cin>>n>>m;
  rep(i, m){
    int l,r,a;cin>>l>>r>>a;
    is[r].push_back({l, a});
  }

  Seg seg;

  rep1(r, n){
    ll mx = seg.max_val(0, r);
    seg.add(r, r+1, mx);
    for(auto p:is[r]){
      int l = p.first;
      ll a = p.second;
      seg.add(l, r+1, a);
    }
  }

  cout<<seg.max_val(0, n+1)<<endl;
//  rep(i, n)cout<<seg.max_val(0, i+1)<<' ';cout<<endl;

  return 0;
}

Measured memory_bytes: 22784
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
    int x, ans = 0;
    scanf("%d", &x);
    ans = x / 500, ans *= 1000, x = x % 500;
    ans += (x / 5) * 5;
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }

        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }



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

Measured memory_bytes: 3560