akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 998244353
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n;

	cin>>n;

	vll x, num(100001);

	x.push_back(1);

	repr(i, 1, 7){
		x.push_back((ll)pow(6.0, (double)i));
		if(i<6) x.push_back((ll)pow(9.0, (double)i));
	}
	sort(all(x));
	
	num[0]=0;
	num[1]=1;
	repr(i, 2, 100001){
		num[i]=num[i-1]+1;
		repr(j, 1, 12){
			ll temp=1e18;
			if(i-x[j]>=0){
				temp=num[i-x[j]]+1;
			}
			if(num[i]>temp) num[i]=temp;
		}
	}

	//repr(i, 1, 200){
		//cout<<i<<" "<<num[i]<<endl;
	//}
	cout<<num[n]<<endl;
}


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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int N;
   cin >> N;
   bitset<4000400> dp;
   dp[0] = 1;
   int sum = 0;
   for (int i = 0; i < N; ++i) {
      int x;
      cin >> x;
      sum += x;
      dp |= dp << x;
   }
   int ans = (sum + 1) / 2;
   while (!dp[ans]) ans++;
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = 0;
		if (a + b > c * 2) {

			if (x < y) {
				ans += x * 2 * c;
				if (b >= c * 2) {
					ans += (y - x) * 2 * c;
				} else {

					ans += (y - x) * b;
				}
			} else {
				ans += y * 2 * c;
				if (a >= c * 2) {
					ans += (x - y) * 2 * c;
				} else {
					ans += (x - y) * a;

				}
			}
		} else {
			ans += a * x + b * y;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){cout << a << " " << b << " " << c << endl;}
#define INT_MAX 1<<30;
const int MAX = 1020000;
const double EPS = 1e-6;
const int mod = 1e9+7;
 
int main(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    if(a+b>c+d) puts("Left");
    else if(a+b==c+d) puts("Balanced");
    else puts("Right");
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int e,tmp,x,min_n=100000000;
  cin >> e;
  while(e!=0){
    min_n=100000000;
    for(int z=0;z*z*z<=e;z++){
      for(int y=0;z*z*z+y*y<=e;y++){
        x = e-z*z*z-y*y;
        tmp=x+y+z;
        min_n=min(tmp,min_n);
      }
    }
    cout << min_n<<endl;
    cin >> e;
  }
}



Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>

using namespace std;

int main() {
	long long int n;
	long long int ans = 0;


	cin >> n;

	ans = (n - 1)*n / 2;


	cout << ans;

	return 0;
}

Measured memory_bytes: 256
N,P=map(int,input().split())
S=input()

if 10%P==0:
    ans=0
    for i in range(N):
        if int(S[i])%P==0:
            ans+=(i+1)
    print(ans)
else:
    S=S[::-1]
    D={}
    D[0]=1
    Amari=0
    for i in range(N):
        I=((Amari)+(pow(10,i,P)*int(S[i])))%P
        Amari=I
        if I not in D:
            D[I]=1
        else:
            D[I]+=1
    ans=0
    for k,v in D.items():
        ans+=v*(v-1)//2
    print(ans)
    #print(D)

Measured memory_bytes: 42668
#include<stdio.h>
 
int main(void){
    double a,b,c,d,e,f,g,x,y;
 
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
        y=(f-c*d/a)/(e-b*d/a);
        x=(f-c*e/b)/(d-a*e/b);
 
        if(-0.0004<x&&x<=0)x=0;
        if(-0.0004<y&&y<=0)y=0;
 
        printf("%.3f %.3f\n",x,y);
     
    }
 
    return 0;
 
}

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

int main(){
  long long n,sum=0;
  cin >> n;
  rep(i,n+1){
    if(i%3 == 0 || i%5 == 0){
      continue;
    }
    sum += i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3580
N = int(input())
A = [int(input()) for _ in range(N)]
#%%
last_n = 1
cnt = 0
for ind,a in enumerate(A):
    if(a==last_n):
        last_n += 1
        continue
    n = (a-1)//last_n
    if(ind==0):
        last_n += 1
    cnt += n
print(cnt)


Measured memory_bytes: 7080
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int a[100000+5];
    int i;
    for(i=1; i<=n; i++)
        scanf("%d",&a[i]);
sort(&a[1],&a[1+n]);
    if(n==2&&a[1]==0)
        printf("%d 0",a[n]);
    else{

   // printf("%d \n",a[n]);
    int sum=a[n],j;
    j=a[n];
  //  printf("%d\n",a[n]/2);

    for(i=1; i<=n;i++)
    {
        int k=abs(a[n]/2-a[i]);
        if(k<=j)
            {sum=a[i];j=k;}

       // printf("k=%d sum=%d\n",k,sum);
    }
    printf("%d %d",a[n],sum);
    }
}


Measured memory_bytes: 512
n = int(input())
a1_inputs = [int(i) for i in input().split()]
a2_inputs = [int(i) for i in input().split()]

dp=[0]*n
for i in range(n):
    dp[i]=sum(a1_inputs[:i+1])+sum(a2_inputs[i:])

print(max(dp))

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

int main(){
  long long n,m,ans=0;cin>>n>>m;
  map<long long,long long> mp;
  REP(i,n){
    long long a,b;cin>>a>>b;
    if(mp[a]!=0) mp[a]+=b;
    else mp[a]=b;    
  }
  for(auto itr=mp.begin();itr!=mp.end();++itr){
    if(m-(itr->second)>0){
      m-=itr->second;
      ans+=(itr->second)*(itr->first);
    }else{
      ans+=m*(itr->first);
      break;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
// #include <atcoder/all>
// using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr int MOD = 1000000007;

// + - * / ^
int mod(int a)
{
    int res = a % MOD;
    if(res < 0) {
        return res + MOD;
    }
    return res;
}
int mul_mod(int a, int b)
{
    ll res = ((ll)a * (ll)b) % MOD;
    return mod((int)res);
}
int pow_mod(int a, int b)
{
    ll res = 1;
    while (b > 0) {
        if(b & 1) {
            res = res * (ll)a % (ll)MOD;
        }
        a = mul_mod(a, a);
        b >>= 1;
    }
    return (int)res;
}
int inv_mod(int a)
{
    return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
    return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 3000001;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com_mod(int a, int b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}


int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll x, y, z;
    x = pow_mod(8, n);
    z = pow_mod(9, n);
    y = pow_mod(10, n);
    if (n < 2) cout << 0 << "\n";
    else cout << mod(y + x - 2 * z) << "\n";
    /***************************************************/
    /* Submit this code from the browser if using ACL! */
    /***************************************************/
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 50

enum Type{
	East,
	North,
	West,
	South,
};

struct Info{

	void set(int arg_left,int arg_right,int arg_top,int arg_under,int arg_color){
		left = arg_left;
		right = arg_right;
		top = arg_top;
		under = arg_under;
		color = arg_color;
	}

	ll left,right,top,under;
	int color;
};

int colors[3] = {1,2,3};
Type type_array[4] = {South,East,North,West};
Info info[SIZE];


int main(){

	info[0].set(0,0,0,0,1);
	info[1].set(1,1,0,0,2);

	ll pre_pre = 1,pre = 1;

	for(int i = 2; i < SIZE; i++){

		info[i].color = colors[i%3];

		ll size = pre_pre+pre;

		Type dir = type_array[i%4];

		switch(dir){
		case South:

			info[i].top = info[i-1].under-1;
			info[i].left = info[i-1].left;
			info[i].under = info[i].top-size+1;
			info[i].right = info[i].left+size-1;

			break;

		case East:

			info[i].left = info[i-1].right+1;
			info[i].under = info[i-1].under;
			info[i].top = info[i].under+size-1;
			info[i].right = info[i].left+size-1;

			break;

		case North:

			info[i].right = info[i-1].right;
			info[i].under = info[i-1].top+1;
			info[i].top = info[i].under+size-1;
			info[i].left = info[i].right-size+1;

			break;

		case West:

			info[i].right = info[i-1].left-1;
			info[i].top = info[i-1].top;
			info[i].under = info[i].top-size+1;
			info[i].left = info[i].right-size+1;

			break;
		}

		pre_pre = pre;
		pre = size;
	}

	ll x,y;

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

	for(int i = 0; i < SIZE; i++){

		if(x >= info[i].left && x <= info[i].right && y >= info[i].under && y <= info[i].top){

			printf("%d\n",info[i].color);
			return 0;
		}
	}

	return 0;
}



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

int a[100005],b[100005],mx = -1e9, sec, pos, ans;

int main(){
  int n;
  scanf("%d",&n);
  for(int i = 0; i < n; ++i){
    int x;
    scanf("%d",&x);
    (i & 1 ? a:b)[x]++;
  }
  for(int i = 1; i <= 1e5; ++i){
    if(a[i] > mx){
      sec = mx;
      mx = a[i];
      pos = i;
    }
    else sec = max(sec,a[i]);
  }
  for(int i = 1; i <= 1e5; ++i){
    ans = max(ans, b[i] + (i == pos ? sec : mx));
  }
  printf("%d\n",n - ans);
  return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np

def bus(stations):
    a = np.array(("","",""))
    for i in range(3):
        a[i] = stations[i]
    s = np.unique(a)
    if len(s)==1:
        return "No"
    elif len(s) > 1:
        return "Yes"
    else:
        return "Problem"
        
"""
my_strings = np.array(("AAA","AAB","ABA","BAA","ABB","BBA","BBB"))
for i in my_strings:
    print(i)
    print(bus(i))
"""
    
i = input()
#print(i)
print(bus(i))


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

int main(void){
  int N;
  cin >> N;
  int M = N/10;
  N = N - M*10;
    
  switch(N){
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }
  return 0;
}


Measured memory_bytes: 3552
#include<cstdio>
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
int main(){
    int n;
    while(scanf("%d",&n),n){
        int ans = 0;
        rep(i,n){
            int x,y,h,w;
            scanf("%d%d%d%d",&x,&y,&h,&w);
            int size = x+y+h;
            (size<=60&&w<=2) ? ans+=600 : (size<=80&&w<=5) ? ans+=800 : (size<=100&&w<=10) ? ans+=1000 : (size<=120&&w<=15) ? ans+=1200 : (size<=140&&w<=20) ? ans+=1400 : (size<=160&&w<=25) ? ans+=1600 :ans+=0;
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

struct Card {
  char mark;
  int num;
};

int partition(Card A[], int p, int r) {
  int x = A[r].num;
  int i = p-1;
  for (int j = p; j < r; ++j) {
    if (A[j].num <= x) {
      swap(A[++i].num, A[j].num);
      swap(A[i].mark, A[j].mark);
    }
  }
  swap(A[i+1].num, A[r].num);
  swap(A[i+1].mark, A[r].mark);
  return i+1;
}

void quickSort(Card A[], int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}

void merge(Card A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  Card L[n1+1];
  Card R[n2+1];
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1].num=numeric_limits<int>::max();
  R[n2].num=numeric_limits<int>::max();
  int i = 0, j = 0;
  for (int k = left; k < right;k++) {
    if (L[i].num <= R[j].num) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(Card A[], int left, int right) {
  if (left+1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

bool isStable(Card A[], Card B[], int n) {
  for (int i = 0; i < n; i++) {
    if (A[i].num != B[i].num) {
      cout << "error";
      return false;
    }
    if (A[i].mark != B[i].mark) {
      return false;
    }
  }
  return true;
}


int main() {
  int n;
  cin >> n;
  Card A[n];
  Card compare[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i].mark;
    cin >> A[i].num;
    compare[i] = A[i];
  }
  quickSort(A, 0, n-1);
  mergeSort(compare, 0, n);
  if(isStable(A, compare, n)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  for (int i = 0; i < n; i++) {
    cout << A[i].mark << " " << A[i].num << endl;
  }
}



Measured memory_bytes: 5328
#include <stdio.h>

int main(void) {
	int string[3];
	int cnt5 = 0, cnt7 = 0;
	scanf("%d %d %d", &string[0], &string[1], &string[2]);
	for (int i = 0; i < 3; i++) {
		if (string[i] == 5)
			cnt5++;
		else if (string[i] == 7)
			cnt7++;
	}
	if (cnt5 == 2) {
		if (cnt7 == 1)
			printf("YES");
	}
	else
		printf("NO");
	return 0;
}

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

int dp[3005][3005];

int lcs(string &a, string &b, int n, int m) {
    if (n == 0 or m == 0) return 0;
    if (dp[n][m] != -1) return dp[n][m];
    if (a[n - 1] == b[m - 1]) {
        return dp[n][m] = 1 + lcs(a, b, n - 1, m - 1);
    }
    int x = lcs(a, b, n - 1, m);
    int y = lcs(a, b, n, m - 1);
    return dp[n][m] = max(x, y);
}

void solve() {
    string a, b;
    cin >> a >> b;
    
  	int n = a.size(), m = b.size();
    memset(dp, -1, sizeof(dp));
    
  	int len = lcs(a, b, n, m);
    char ans[len + 1];
    ans[len] = '\0';
    int i = n, j = m;
    while (i > 0 and j > 0) {
        if (a[i - 1] == b[j - 1]) {
            ans[len - 1] = a[i - 1];
            i-- , j-- , len--;
        } 
      	else if (dp[i - 1][j] > dp[i][j - 1]) i--;
       	else j--;
    }
    for (int k = 0; ans[k] != '\0'; ++k) cout << ans[k];
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
  	int t = 1;
    while (t--) solve();
  
  	return 0;
}


Measured memory_bytes: 74512
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin >> n;
    n *= 3;
    vector<int> a(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int cnt = 0;
    for(int i = n - 2; cnt < n / 3; i -= 2){
        cnt++;
        sum += a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N, Y;
    cin >> N >> Y;
    //10000円札を全枚数分探索
    REP(i, N + 1) {
        //5000円札
        REP(j, N + 1 - i) {
            int yen = i * 10000 + j * 5000 + (N - i - j) * 1000;
            if (yen == Y) {
                cout << i << " " << j << " " << (N - i - j) << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    rev = False
    s = input()
    dq = deque(s)
    n = ii()
    for _ in range(n):
        query = list(input().split())
        if len(query) == 1:
            rev = not rev
        else:
            _, num, char = query
            num_flag = True if num == '1' else False
            if (num_flag and not rev) or (not num_flag and rev):
                dq.appendleft(char)
            else:
                dq.append(char)
    L = list(reversed(dq)) if rev else list(dq)
    print(''.join(L))


if __name__ == "__main__":
    main()

Measured memory_bytes: 9204
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b>=c){
    int ans=b+c;
    cout << ans << endl;
  }
  else{
    int ans=b+(a+b+1);
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
int asc(const void *a,const void *b){return *(long long *)b-*(long long*)a;}
int main(){
    ll x,y,a,b,c,i,ans=0;
    scanf("%lld%lld%lld%lld%lld",&x,&y,&a,&b,&c);
    ll p[a],q[b],r[c],to[a+b+c];
    for(i=0;i<a;i++) scanf("%lld",&p[i]);
    for(i=0;i<b;i++) scanf("%lld",&q[i]);
    for(i=0;i<c;i++) scanf("%lld",&r[i]);
    qsort(p,a,sizeof(long long),asc);
    qsort(q,b,sizeof(long long),asc);
    qsort(r,c,sizeof(long long),asc);
    for(i=0;i<x;i++) to[i]=p[i];
    for(;i<x+y;i++) to[i]=q[i-x];
    for(;i<x+y+c;i++) to[i]=r[i-x-y];
    qsort(to,i,sizeof(long long),asc);
    for(i=0;i<x+y;i++)
        ans+=to[i];
    printf("%lld\n",ans);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    A[i].first = tmp;
    A[i].second = i + 1;
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    cout << A[i].second;
    if (i < N - 1)
      cout << " ";
    else
      cout << endl;
  }
}

Measured memory_bytes: 1664
N,*A=map(int,input().split());a=[[0]*4];r=[0,1,2]
for i in range(N):l=int(input());a=[[p[j]+l*(i==j)for j in r]+[p[3]+(i<3)*10]for i in r+[3]for p in a]
print(min(sum(abs(p[i]-A[i])for i in r)-30+p[3]for p in a if min(p[:3])>0))

Measured memory_bytes: 19572
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}

void solve()
{
	ll n,m,flag=0,x,y;
	cin>>n>>m;
	vll h(n+1);
	for(ll i=1;i<=n;i++)
		cin>>h[i];
	vector<pair<ll,ll>> a(m);
	for(ll i=0;i<m;i++)
		cin>>a[i].ff>>a[i].ss;
	vll b(n+1,0);
	for(ll i=0;i<m;i++)
	{
		// cout<<a[i].ff<<a[i].ss;
		if(h[a[i].ff]<=h[a[i].ss])
			b[a[i].ff]=1;
		if(h[a[i].ss]<=h[a[i].ff])
			b[a[i].ss]=1;
		// cout<<b[a[i].ff]<<b[a[i].ss]<<endl;
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		if(b[i]==0)
			ans++;
	}
	cout<<ans;
		return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6368
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], M = I[1];
		var cnt = new int[M];
		for (var i = 0; i < N; i++) foreach (var a in G.Skip(1)) cnt[a - 1]++;
		WriteLine(cnt.Sum(c => c == N ? 1 : 0));
	}
}


Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include <cmath>
#include <ctype.h>
#include<vector>
using namespace std;
int N, M;
int a[51];
int main() {
    cin >> N >> M;
    int n, m;
    for(int i=0; i<M; ++i){
        cin >> n >> m;
        a[n-1]++; a[m-1]++;
    }
    for(int i=0; i<N; ++i){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <unordered_map>
#include <map>
#include <cmath>

#define MP make_pair
#define F first
#define S second
#define PB push_back

using namespace std;

const int maxn = 1e5 + 100;
int c[maxn], s[maxn], f[maxn];

int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++)
        cin >> c[i] >> s[i] >> f[i];
    for (int i = 1; i < n; i++){
        int t = 0;
        for (int j = i; j < n; j++){
            if (t <= s[j]){
                t += (s[j] - t);
                t += c[j];
            }
            else {
                int k = t;
                k -= s[j];
                k %= f[j];
                if (k != 0)
                    t += f[j] - k;
                t += c[j];
            }
//          cout << t << " ";
        }
        cout << t << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll ;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<str> vstr;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;
 
#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define NP next_permutation
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)
 
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数
 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}

void solve(vvint edge,int n,int m){
  ll ans=0;
  vint verticle(10);
  REP(i,n){
    verticle[i]=i+1;
  }
  do{
    bool check=true;
    REP(i,n-1){
      if(edge[verticle[i]][verticle[i+1]]!=1){
        check=false;
      }
    }
    if(check){
      ans+=1;
    }
  }while(next_permutation(verticle.begin()+1,verticle.begin()+n));
  cout << ans << endl;
}

int main(){
  int n,m;
  cin >> n;
  cin >> m;
  vvint edge(30,vint(30,0));
  REP(i,m){
    int v1,v2;
    cin >> v1;
    cin >> v2;
    edge[v1][v2]=1;
    edge[v2][v1]=1;
  }
  solve(edge,n,m);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<ll> p(n);
  rep(i,n) cin >> p[i];
  vector<ll> sum(n+1);
  rep(i,n) sum[i+1] = sum[i] + p[i];
  ll l = 0;
  int s = 0;
  rep(i,n+1-k) {
    ll temp = sum[i+k] - sum[i];
    if (temp > l) {
      l = temp;
      s = i;
    }
  }
  double ans = 0;
  rep(i, k) {
    double d = p[s+i] / 2.0 + 0.5;
    ans += d;
  }
  cout << setprecision(15) << ans << endl;
  
}

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

Measured memory_bytes: 6344
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;

double chk500[8]={
  35.5, 37.5, 40, 43, 50, 55, 70, 1e10
};
double chk1000[8]={
  71, 77, 83, 89, 105, 116, 148, 1e10
};
const char *rank[8]={
  "AAA","AA","A","B","C","D","E","NA"
};

int main(){
  double a,b;
  while(~scanf("%lf%lf",&a,&b)){
    REP(i,8){
      if(a < chk500[i] && b < chk1000[i]){
        puts(rank[i]);
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#include <random>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

random_device gen;
mt19937 rnd(gen());

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
    ll n, m, k;
    cin >> n >> m >> k;
    for (ll i = 0; i <= n; i++) {
        for (ll j = 0; j <= m; j++) {
            if (i * m + n * j - 2 * i * j == k) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
	return 0;
}



Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            for (int i = 1; ; i++) {
                String line = reader.readLine();
                int n = Integer.parseInt(line);
                if (n == 0) {
                    break;
                } else {
                    System.out.println("Case " + i + ": " + n);
                }
            }
        } catch (IOException e) {
            System.out.println(e);
        } catch (NumberFormatException e) {
            System.out.println("error");
        }
    }
}

Measured memory_bytes: 31980
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
   
  return 0;
}


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

int main(){
    bool cards[4][14];
    int n,rank;
    char suit;
    
    for(int s=0; s<4; s++)
        for(int r=1; r<=13; r++)
            cards[s][r]=0;
            
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>suit>>rank;
        if(suit=='S') cards[0][rank]=1;
        if(suit=='H') cards[1][rank]=1;
        if(suit=='C') cards[2][rank]=1;
        if(suit=='D') cards[3][rank]=1;
    }
    
    for(int s=0; s<4; s++){
        for(int r=1; r<=13; r++){
            if(cards[s][r]) continue;
            if(s==0) suit='S';
            if(s==1) suit='H';
            if(s==2) suit='C';
            if(s==3) suit='D';
            cout<<suit<<" "<<r<<endl;
        }
    }
    
    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    pll p(0, 0);
    ll pt = 0;
    bool e = true;
    REP(i, N) {
        pll n;
        ll t;
        cin >> t >> n.first >> n.second;

        ll d = abs(n.first - p.first) + abs(n.second - p.second);

        if ((t - pt) - d < 0 || ((t - pt) - d) % 2 == 1) {
            e = false;
        }
        pt = t;
        p = n;
    }
    if (e)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      int mod = 1000000007;
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();
      List<Integer> arr = new ArrayList<>();
      for(int i = 0; i < s.length(); i++) {
        if(i == s.length() - 1)
          arr.add(1);
        else {
          if(s.charAt(i) == s.charAt(i+1)) {
            arr.add(2);
            i++;
          } else 
            arr.add(1);
        }
      }
      long cnt = arr.get(0) == 1 ? 3 : 6;
      for(int i = 1; i < arr.size(); i++) {
        int curCnt = 0;
        if(arr.get(i-1) == 1) {
          curCnt = 2;
        } else if(arr.get(i) == 1) {
          curCnt = 1;
        } else
          curCnt = 3;
        cnt = cnt * curCnt % mod;
      }
      System.out.println(cnt);
  }
}

Measured memory_bytes: 21844
import java.util.*;

public class Main{
  
  public static void main (String[] args){
  
  	Scanner scanner = new Scanner (System.in);
  
 	int N = scanner.nextInt();
    int A = scanner.nextInt();
    
    int remain = N%500;
    
    if (remain <= A){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716
from math import cos,sin,pi

A, B, H, M = map(int, input().split())

hour_rad = (360.0*float(H)/12.0 + 30.0*float(M)/60.0 ) * pi/180.0
min_rad = ( 360.0*float(M)/60.0 ) * pi/180.0

hour_x = A * cos(hour_rad)
hour_y = A * sin(hour_rad)

min_x = B * cos(min_rad)
min_y = B * sin(min_rad)

ans = ((hour_x-min_x)**2 + (hour_y-min_y)**2)**0.5
print(ans)

Measured memory_bytes: 62596
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

ll laip(ll a, ll b, ll p) {
	if (b==0) {return 1LL;}
	if (b==1) {return a%p;}
	a=a%p;
	ll c=(a*a)%p;
	ll x=laip(c,b/2,p);
	if (b%2==0) {return x;}
	else {return (a*x)%p;}
	}

ll solve(ll n) {
	ll p=1000000007;
	ll x=(laip(10LL,n,p)-2*laip(9LL,n,p)+laip(8LL,n,p))%p;
	return (x+p)%p;
	}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    cout<<solve(n)<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;


 int main()
 {
   int a,b;
   while(cin>>a>>b)
   {
     string s;
     cin>>s;
     if(s.length()!=(a+b+1)) cout<<"No"<<endl;
     else
     {
       bool flag=false;
       for(int i=0;i<s.length();i++)
       {
         if(a==i) 
         {
           if(s[i]!='-') 
           {
             flag=true;
             break;              
           }         
         }        
         else
         {
           if(!(s[i]>='0'&&s[i]<='9'))
           {
             flag=true;
             break;                           
           }    
         }
       }    
       if(flag) cout<<"No"<<endl;
       else cout<<"Yes"<<endl;
     }          
   }
   return 0;
 }
 

        



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

namespace ABC177D
{
    class Program
    {
        static int[] renketu;
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);
            int[] A = new int[M];
            int[] B = new int[M];
            for(int i = 0; i < M; i++)
            {
                string[] AB = Console.ReadLine().Split(' ');
                A[i] = int.Parse(AB[0]);
                B[i] = int.Parse(AB[1]);
            }
            renketu = new int[N];
            for(int i = 0; i < M; i++)
            {
                if (renketu[A[i]-1] == 0 && renketu[B[i]-1] == 0)
                {
                    renketu[A[i] - 1] = -1;
                    renketu[B[i] - 1] = A[i];
                }
                else if (renketu[A[i]-1] != 0 && renketu[B[i]-1] == 0)
                {
                    renketu[B[i] - 1] = A[i];
                    int p = oya(B[i]);
                    renketu[p - 1] -= 1;
                }
                else if (renketu[A[i]-1] == 0 && renketu[B[i]-1] != 0)
                {
                    renketu[A[i] - 1] = B[i];
                    int p = oya(B[i]);
                    renketu[p - 1] -= 1;
                }
                else
                {
                    int p1 = oya(A[i]);
                    int p2 = oya(B[i]);
                    if (p1 != p2)
                    {
                        renketu[p1 - 1] += renketu[p2 - 1] - 1;
                        renketu[p2 - 1] = p1;
                    }
                }
            }
            int max = 1;
            for(int i = 0; i < N; i++)
            {
                if (renketu[i] < 0)
                {
                    int temp = -(renketu[i] - 1);
                    if (temp > max)
                    {
                        max = temp;
                    }
                }
            }
            Console.WriteLine(max);
        }

        static int oya(int a)
        {
            if (renketu[a - 1] >= 0)
            {
                renketu[a - 1] = oya(renketu[a - 1]);
                return renketu[a - 1];
            }
            return a;
        }
    }
}


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

using namespace std;

using ll = long long;

int x, n;

bool check(vector<int> v, int a) {
    for (int i = 0; i < n; i++) {
        if (a == v[i]) return false;
    }
    return true;
}


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

    if (n == 0) {
        cout << x << endl;
        return 0;
    }

    vector<int> v(n);

    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        v[i] = p;
    }

    int a = 10000;
    for (int i = 0; i < n; i++) {
        a = min(a, abs(x - v[i]));
    }

    int i = 1;
    while(true) {
        if (check(v, x + a - i)) {
            cout << x + a - i << endl;
            return 0;
        }

        if (check(v, x + a + i)) {
            cout << x + a + i << endl;
            return 0;
        }
        i++;
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 1e5 + 10;
vector<int> graph[N];
lli dp[N][2];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
void dfs(int v, int par) {
	dp[v][0] = 1;
	dp[v][1] = 1;
	for(int i : graph[v]) {
		if(i == par) continue;
		dfs(i, v);
		dp[v][0] = multm(dp[v][0], dp[i][1]);
		dp[v][1] = multm(dp[v][1], addm(dp[i][0], dp[i][1]));
	}
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for(int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	
	dfs(1, -1);
	cout << addm(dp[1][0], dp[1][1]) << "\n";
	
	return 0;
}

Measured memory_bytes: 14208
N, M = map(int, input().split())
X_arr = list(map(int, input().split()))
X_sorted  = sorted(X_arr)
X_diff = []
for i in range(M - 1):
    X_diff.append(X_sorted[i + 1] - X_sorted[i])
X_diff_sorted  = sorted(X_diff)
for n in range(N - 1):
    if X_diff_sorted == []:
        break
    else:
        X_diff_sorted.pop()
print(sum(X_diff_sorted))

Measured memory_bytes: 13968
/**
 *    author:  tesnik      
**/
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<string, int> m;
  for (int i = 0; i < n; i++) {
    m[a[i]]++;
  }     

  int mx = 0;
  for (auto p: m) {
    mx = max(mx, p.second);
  }
  for (auto p: m) {
    if (p.second == mx) {
      cout << p.first << "\n";
    }
  }

  return 0;
}

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

ans = 0

def main():
    global K

    if A < K:
        ans = A
        K = K - A
    elif A == K:
        ans = K
        return ans
    else: # AのほうがKより多い
        ans = K
        return ans

    if B < K:
        K = K - B
    elif B == K:
        return ans
    else: # BのほうがKより多い
        return ans

    # マイナス
    return ans - K

result = main()

print(result)

Measured memory_bytes: 61796