akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 1e6 + 5;
const double pi =  acosl(-1);
const long long inf = 1e18 + 5;
using namespace std;
template<typename T> void debug(string s, T x) {cout << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cout << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}
template<class T> void print_container(T &container) { for (auto &t : container) { cout << t << " ";} cout << endl;}
template<class T> void printArr(T &a , int n) { for (int i = 0; i < n; i++) {cout << a[i] << " ";} cout << endl;}
typedef long long ll;
typedef pair<int, int> pii;

//Template Ends
int n, x, t;

void solve() {
	cin >> n >> x >> t;

	if (n % x == 0) {
		cout << (n / x)*t << endl;
	} else {
		cout << (n / x + 1)*t << endl;
	}
}

int32_t main() {
	IOS;



	solve();

	return 0;
}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define _for(i,n) for(int i = 0; i < n; i++)

using namespace std;
void dfs(int,vector<vector<int> >,int*);


int ans = 0;
int n,m;
int main() {
  cin >> n >> m;
  int a[m], b[m];
  _for(i,m) cin >> a[i] >> b[i];
  _for(i,m) {
    a[i]--;
    b[i]--;
  }
  int visited[n];
  _for(i,n) visited[i] = -1;
  vector<vector<int> > connected(n,vector<int>());
  _for(i,m) {
    connected[a[i]].push_back(b[i]);
    connected[b[i]].push_back(a[i]);
  }
  dfs(0,connected,visited);
  cout << ans << endl;  
  return 0;
}

int visited_all(int* visited) {
  int all_visited = true;
  _for(i,n) if (visited[i]!=1) all_visited = false;
  return all_visited;
}

void dfs(int current,vector<vector<int> > connected,int* visited) {
  visited[current] = 1;
  int temp[n];
  _for(i,n) temp[i] = visited[i];
  if (visited_all(visited)) ans++;
  else {
    _for(i,connected[current].size()) if (visited[connected[current][i]]!=1) {
      dfs(connected[current][i],connected,visited);
      _for(j,n) visited[j] = temp[j];
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

signed main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	int v = (n*(n+1)*(n+2))/6;
	int e=0;
	int a,b;
	for(int i=0; i<n-1; i++){
		cin >> a >> b;
		if(a>b)
			swap(a,b);
		e += a*(n-b+1);
	}
	cout << v-e;


	
	

	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define F first
#define S second
#define all(v) (v).begin(), (v).end()
#define sz(v) (v).size()
#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(){
	Fio;
	int t=1;
	//cin >> t;
	while(t--) {
		ll n;
		cin >> n;

		string ans;
		while(n) {
			n -= 1;
			ll x = n%26;
			ans += 'a'+x;
			n /= 26;
		}

		reverse(all(ans));
		cout << ans;
	}

	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>

using namespace std;
const int mod = 1e9 + 7;

long long int mypow(long long int a, long long int b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	long long int ret = mypow(a, b / 2);
	ret *= ret;
	ret %= mod;
	if (b % 2 == 1) {
		ret = ret * a % mod;
	}
	return ret;
}

int main(int argc, char *argv[]) {
	
	long long int n, k;
	cin >> n >> k;
	long long int res = 0;
	vector<long long int> v(1, 0);
	for (int i = 1; i <= k; i++) {
		long long int type = k / i;
		v.push_back(mypow(type, n));
	}
	for (int i = k; i >= 1; i--) {
		for (int j = 2; j * i <= k; j++) {
			v[i] -= v[j * i];
			v[i] %= mod;
		}
	}
	for (int i = 1; i <= k; i++) {
		res += v[i] * i;
		res %= mod;
	}
	res += mod;
	res %= mod;
	cout << res << endl;
}


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

int main() {
  int X;
  cin >> X;
  vector<bool> E(X, false);
  E.at(0) = true;
  for (int i = 2; i * i <= X; i++) {
    int Y = i * i;
    while (Y <= X) {
      E.at(Y - 1) = true;
      Y *= i;
    }
  }
  for (int i = X - 1; i >= 0; i--) {
    if (E.at(i)) {
      cout << i + 1 << endl;
      break;
    }
  }
}

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

int dp[1<<15][15];
int g[15][15];
int dis[1<<15];
int n,m,ans=0x3f3f3f3f,sum;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;a--;b--;
        g[a][b]=g[b][a]=c;
        sum+=c;
    }
    for(int s=0;s<1<<n;s++){
        for(int i=0;i<n;i++)if(s>>i&1){
            for(int j=i+1;j<n;j++)if(s>>j&1){
                dis[s]+=g[i][j];
            }
        }
    }
    memset(dp,0x3f,sizeof(dp));
    dp[1][0]=sum;
    for(int s=0;s<1<<n;s++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++)if(!(s>>j&1)&&g[i][j]){
                dp[s|(1<<j)][j]=min(dp[s|(1<<j)][j],dp[s][i]-g[i][j]);
            }
            int rs=(s^((1<<n)-1))|(1<<i);
            for(int j=rs;j;j=rs&(j-1)){
                dp[s|j][i]=min(dp[s|j][i],dp[s][i]-dis[j]);
            }
        }
    }
    for(int s=0;s<1<<n;s++){
        ans=min(ans,dp[s][n-1]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2304
import java.util.*;

public class Main {
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] lis = new int[20][20];
        int[] p = new int[m];


        for (int i = 0; i < m; ++i) {
            lis[i][0] = sc.nextInt();
            for (int j = 1; j <= lis[i][0]; ++j) {
                lis[i][j] = sc.nextInt();
            }
        }

        for (int i = 0; i < m; ++i) {
            p[i] = sc.nextInt();
        }


        int ans = 0;
        int lim = 1 << n;
        for (int i = 0; i < lim; ++i) {
            boolean ok = true;
            for (int j = 0; j < m; ++j) {
                int cnt = 0;
                for (int k = 1; k <= lis[j][0]; ++k) {
                    if ((i & (1 << (lis[j][k] - 1))) > 0) cnt++;
                }
                if (cnt % 2 != p[j]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int p[] = new int[N];
    for(int i=0; i<N; i++){
      p[i]=sc.nextInt();
    }
    Arrays.sort(p);
    int ans =0;
    for(int i=0; i<K; i++){
      ans += p[i];
    }
    System.out.println(ans);
  }
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    ll n,m,c,A[21][21],B[21],sum,ans=0,i,j;
    cin >> n >> m >> c;
    for(i=0;i<m;i++) cin >> B[i];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> A[i][j];
        }
    }
    for(i=0;i<n;i++){
        sum=0;
        for(j=0;j<m;j++){
            sum += A[i][j]*B[j];
        }
        sum += c;
        if(sum>0) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

class Node:
    def __init__(self, id):
        self.id = id
        self.link = []
        self.check = False

def main():
    N, M = map(int, input().split())

    nodes = [Node(i) for i in range(N+1)]

    for i in range(M):
        a, b = map(int, input().split())
        nodes[a].link.append(nodes[b])
        nodes[b].link.append(nodes[a])

    ok = False
    q = deque()
    q.append((nodes[1], 0))
    nodes[1].check
    while len(q) > 0:
        node, cost = q.popleft()
        if node.id == N:
            ok = True
            break
        if cost <= 1:
            for nex in node.link:
                if not nex.check:
                    q.append((nex, cost+1))
                    nex.check = True
    
    if ok:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == "__main__":
    main()

Measured memory_bytes: 75256
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf 1<<30
#define MAX 1000010
using namespace std;

long long p[MAX],w[MAX];

pair<int,int> find(int a){
  if(p[a]==a)return mp(a,0);
  pair<int,int> pii=find(p[a]);
  p[a]=pii.f;
  w[a]+=pii.s;
  return mp(p[a],w[a]);
}

void unit(int a,int b,int d){
  pair<int,int> pa=find(a),pb=find(b);
  if(pa.f==pb.f)return;
  d-=w[b]-w[a];
  p[pa.f]=pb.f;
  w[pa.f]=-d;
}

int main()
{
  int n,q,a,b,d;
  char c;

  while(cin>>n>>q && n ){

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

    for(int i=0;i<q;i++){
      cin>>c;
      if(c=='!'){
	cin>>a>>b>>d;
	a--;b--;
        unit(a,b,d);
      }
      else {
	cin>>a>>b;
	a--;b--;
	pair<int,int> pa=find(a),pb=find(b);
	if(pa.f!=pb.f)cout<<"UNKNOWN"<<endl;
	else cout<<w[b]-w[a]<<endl;
      }
    }
  }
  return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3604
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	tmp := true
	for _, a := range as {
		if !judge(a) {
			tmp = false
			break
		}
	}

	var msg string
	if tmp {
		msg = "APPROVED"
	} else {
		msg = "DENIED"
	}
	
	fmt.Print(msg)
}

func judge(n int) bool {
	if n % 2 == 1 || (n % 3 == 0 || n % 5 == 0) {
		return true
	} else {
		return false
	}
}


Measured memory_bytes: 512
# デバッグ用
GBN_DEBUG = False
#GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')

#本体ここから
s = input()
t = input()

t2 = t[0:-1]
if s == t2:
    print('Yes')
else:
    print('No')

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

int main(){
    int N; cin >> N;
    vector <int> A(N),B(N),C(N-1);
    for (int i=0; i<N; i++) cin >> A[i];
    for (int i=0; i<N; i++) cin >> B[i];
    for (int i=0; i<N-1; i++) cin >> C[i];
    
    int sum=0;
    
    for (int i=0; i<N; i++){
        if (A[i]-A[i-1]==1){
            sum+=B[A[i]-1]+C[A[i]-2];
        }else{
            sum+=B[A[i]-1];
        }
    }
    
    cout << sum;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);

        int cardCount = sc.nextInt();
        int[] cards = new int[cardCount];
        for (int i = 0; i < cards.length; i++) {
            cards[i] = sc.nextInt();
        }
        
        Arrays.sort(cards);
        
        int alicesPoint = 0;
        int bobsPoint = 0;
        
        for (int i = cards.length - 1; i >= 0; i -= 2) {
            alicesPoint += cards[i];
            if (i == 0) break;
            bobsPoint += cards[i - 1];
        }

        System.out.println(alicesPoint - bobsPoint);
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
void Main(){
    int x,y;
    cin>>x>>y;
    string ans="No";
    For(i,0,100){
        For(j,0,100){
            if(i+j==x && 2*i+4*j==y){
                ans="Yes";
            }
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int res = (n + 1000 - 1) / 1000;
    cout << res * 1000 - n << endl;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

N = int(input())
h = list(map(int, input().split()))


def calc(list_h):
    if not list_h:
        return 0

    min_height = min(list_h)
    list_h = [list_h[i] - min_height for i in range(len(list_h))]
    zero_indexes = [i for i, x in enumerate(list_h) if x == 0]

    if not any(list_h):
        return min_height

    left_list = list_h[:zero_indexes[0]]
    right_list = list_h[zero_indexes[0]+1:]
    return calc(left_list) + calc(right_list) + min_height


print(calc(h))


Measured memory_bytes: 3188
use std::io::*;
use std::str::*;

fn main() {
    let cin = stdin();
    let cin = cin.lock();

    let mut sc = Scanner::new(cin);

    let n: i32 = sc.read();
    let k: i32 = sc.read();

    let ans = if n % k == 0 { 0 } else { 1 };

    println!("{}", ans)
}

// いるんさんのスキャナ
// http://ir5.hatenablog.com/entry/20171209/1512821837
// ここから
struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// ここまで

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void InsertionSort(vector<int> &A, int n, int g, int &cnt) {
  for(int i = g; i < n; i++) {
    int v = A[i];
    int j = i-g;
    while(0 <= j && v < A[j]) {
      A[j+g] = A[j];
      j = j -g;
      cnt++;
    }
    A[j+g] = v;
  }
}


void ShellSort(vector<int> &A, int n, int &cnt) {
  cnt = 0;
  int k = 0;
  vector<int> g;
  while(k <= n) {
    int tmp_g = 3*k + 1;
    if(tmp_g <= n) {
      g.push_back(tmp_g);
    }
    k = tmp_g;
  } 
  int m = g.size();
  sort(g.begin(), g.end(), std::greater<int>());

  for(int i = 0; i < m; i++) {
    InsertionSort(A, n, g[i], cnt);
  }

  cout << m << endl;
  for(int i = 0; i < m; i++) {
    cout << g[i];
    if(i != m-1) cout << " ";
    else cout << endl;
  }
}

int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  for(int i = 0; i < n; i++) cin >> A[i];

  int cnt = 0;
  ShellSort(A, n, cnt);

  cout << cnt << endl;

  for(int i = 0; i < n; i++) {
    cout << A[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 6708
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define end(x) prev(x.end());
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a, T b) { a = min(a, b); }
template<class T> void umax(T &a, T b) { a = max(a, b); }

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

const int mod = 1e9+7;
const int N = 1e6+5;

ll dp[N],a[N];

void solve(){
	ll a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	ll ans=1e18;
	for(int i=0;i<=2e5;i+=2){
		if(c*i+max(0ll,(x-i/2)*a)+max(0ll,(y-i/2)*b)<ans){
			ans=c*i+max(0ll,(x-i/2)*a)+max(0ll,(y-i/2)*b);
		}
	}
	cout<<ans;
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}
 



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define int int64_t
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int MOD = (int) 1e9 + 7;
const int NMAX = 3000007;

int dpx[NMAX];
int mars[NMAX];

int32_t main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    dpx[0] = 1;
    int64_t ans = 0;
    for (int i = 0; i <= n; ++i) {
        if (i > 0) {
            mars[i] = (mars[i - 1] + mars[i]) % MOD;
        }
        dpx[i] = (dpx[i] + mars[i]) % MOD;
        if (i == n) {
            break;
        }
        mars[i + 3] += dpx[i];
        mars[i + 3] %= MOD;
        dpx[n] += (int64_t) min(n - 1, (i + 1)) * dpx[i] % MOD;
        dpx[n] %= MOD;
        dpx[i + 1] += dpx[i];
        dpx[i + 1] %= MOD;
        if (i + 2 <= n) {
            ans += (int64_t) (n - 1) * (n - 1) % MOD * dpx[i] % MOD;
            ans %= MOD;
        }
    }
    ans += dpx[n];
    ans %= MOD;
    
    ans %= MOD;
    if (ans < 0) {
        ans += MOD;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)

signed main() {
  int n; ll d; cin >> n >> d;
  int ans = 0;
  rep(i,n) {
    ll x,y; cin >> x >> y;
    if(x*x + y*y <= d * d) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,L,R) for(i=L;i<R;i++)
#define REP(i,N) FOR(i,0,N)
int main(){
  ll N,M,Q,i,j,ans=0;cin>>N>>M>>Q;ll X[4][Q],A[N];REP(i,N)A[i]=1;
  REP(i,Q)REP(j,4)cin>>X[j][i];
  while(1){
    ll p=0;
    REP(i,Q)if(A[X[1][i]-1]-A[X[0][i]-1]==X[2][i])p+=X[3][i];
    ans=max(ans,p);
    if(A[0]==M)break;i=N-1;while(A[i]==M)i--;A[i]++;FOR(j,i+1,N)A[j]=A[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3604
#include <cstdint>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};


int main(){
    ll n;
    cin >> n;
    modint<1000000007> _10;
    modint<1000000007> _9;
    modint<1000000007> _8;
    _10.a=1;
    _9.a=1;
    _8.a=1;
    for(ll i=0;i<n;i++){
        _10 = _10*10;
        _9 = _9*9;
        _8 = _8*8;
    }
    cout << (_10-(_9*2)+_8).a;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template <typename T>
inline void read(T &x)
{
    T data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    x = f * data;
}

const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e5 + 9;

signed main()
{
    //freopen("in.txt","r",stdin);
    //freopen("data.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //std::cout.tie(0);
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = a / b * c;
    if (a % b)
        ans += c;
    cout << ans << endl;
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

Measured memory_bytes: 3632
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a, b = map(int, input().split())
if a == b:
    print(a+b)
else:
    print(max(a, b)*2-1)


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

using namespace std;
const int MAXN = 5e3+5;
vector<int> v1[MAXN];
int X[MAXN];
int dp[MAXN];
int tmpdp[MAXN][MAXN];
void dfs(int curr,int par){
    
    
    //dp[curr][0] = 0;
    for(int x:v1[curr]){
        if(x!=par){
            dfs(x,curr);
        }
        
    }
    for(int i=1;i<=5000;i++){
        tmpdp[0][i] = 1e9;
    }
    for(int i=1;i<=v1[curr].size();i++){
        int child = v1[curr][i-1];
        for(int j=0;j<=5000;j++){
            tmpdp[i][j] = 1e9;
            if(j>=X[child]){
                tmpdp[i][j] = min(tmpdp[i][j],tmpdp[i-1][j-X[child]]+dp[child]);
            }
            if(j>=dp[child]){
                tmpdp[i][j] = min(tmpdp[i][j],tmpdp[i-1][j-dp[child]]+X[child]);
            }
            
        }
    }
    dp[curr] = 1e9;
    for(int i=0;i<=X[curr];i++){
        dp[curr] = min(dp[curr],tmpdp[v1[curr].size()][i]);
    }
    if(v1[curr].size() == 0){
        
        dp[curr] = 0;
    }
}
int main(){
    int n;
    cin>>n;
    for(int i=2;i<=n;i++){
        int p;
        cin>>p;
        v1[p].push_back(i);
    }
    for(int i=1;i<=n;i++){
        cin>>X[i];
    }
    dfs(1,1);
    for(int i=1;i<=n;i++){
        if(dp[i]>=1e9){
           // cout<<i<<" "<<dp[i][X[i]]<<endl;
            cout<<"IMPOSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"POSSIBLE"<<endl;
    
}

Measured memory_bytes: 20864
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
int cnt[26];
int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	for (int i = 0; i < N; i++) {
		cnt[S[i] - 'a']++;
	}
	ll ans = 1;
	for (int i = 0; i < 26; i++) (ans *= (cnt[i] + 1)) %= MOD;
	(ans += MOD - 1) %= MOD;
	cout << ans << endl;
}


Measured memory_bytes: 512
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val S = Array.ofDim[Char](2*N, 2*N)

  for (y <- 1 to N){
    val s = in.next()
    for (x <- 1 to N){
      S(y)(x) = s(x-1)
    }
  }

  for (y <- N+1 to 2*N-1){
    for (x <- 1 to N){
      S(y)(x) = S(y-N)(x)
    }
  }
  for (y <- 1 to N){
    for (x <- N+1 to 2*N-1){
      S(y)(x) = S(y)(x-N)
    }
  }
  for (y <- N+1 to 2*N-1){
    for (x <- N+1 to 2*N-1){
      S(y)(x) = S(y-N)(x-N)
    }
  }




  // process
  var ans = 0

  val dp = Array.ofDim[Int](2*N, 2*N)
  var tmp = 42
  for(y <- 1 to 2*N-1; x <- y+1 to 2*N-1) {
    if(S(y)(x) == S(x)(y)) {
      dp(y)(x) = tmp
    }
  }
  var flag = true
  val ny = 1; val nx = 1
  for (y <- ny to ny+N-1; x <- y+1 to ny+N-1) {
    if(dp(y)(x) != tmp) {
      flag = false
    }
  }
  if(flag)
    ans += N


  //// for y
  for(sty <- 2 to N) {
    tmp += 1

    for(y <- sty to 2*N-1; x <- 1+(y-sty+1) to 2*N-1 - (sty-1)) {
      if(S(y)(x) == S(x+(sty-1))(y-(sty-1))) {
        dp(y)(x) = tmp
      }
    }

    val ny = sty; val nx = 1
    var flag = true
    for (y <- ny to ny+N-1; x <- nx + y-ny+1 to nx+N-1) {
      if(dp(y)(x) != tmp) {
        flag = false
      }
    }
    if(flag){
      ans += (N - sty + 1)
    }
      
  }


  //// for x
  for(stx <- 2 to N) {
    tmp += 1

    for(x <- stx to 2*N-1; y <- 1+(x-stx+1) to 2*N-1 - (stx-1)) {
      if(S(y)(x) == S(x-(stx-1))(y+(stx-1))) {
        dp(y)(x) = tmp
      }
    }
    
    ///
    val nx = stx; val ny = 1
    var flag = true

    for (x <- nx to nx+N-1; y <- ny + x-nx+1 to ny+N-1) {
      if(dp(y)(x) != tmp) {
        flag = false
      }
    }
    if(flag){
      ans += (N - stx + 1)
    }
  }


  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



Measured memory_bytes: 51328
n, k = map(int, input().split())
h = []
for i in range(n):
  h.append(int(input()))
h.sort()
ans = 10 ** 10
#print(h)
for i in range(n-k+1):
  d = h[i+k-1] - h[i]
  ans = min(ans, d)
print(ans)

Measured memory_bytes: 80992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++){
        cin>>v[i];
    }
    ll a=v[0];
    for(ll i=1;i<n;i++)a=__gcd(a,v[i]);
    int ans=0;
    while(a%2==0){
        ans++;
        a/=2;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
    int N, M;
    cin >> N >> M;
    int s[M], c[M];
    for (int i = 0; i < M; ++i) {
        cin >> s[i];
        cin >> c[i];
    }
    for (int i = 0; i < M; ++i) s[i]--;
    int d[3];
    for (int i = 0; i < 3; ++i) d[i] = -1;

    for (int i = 0; i < M; ++i) {
        if (d[s[i]] == -1) {
            d[s[i]] = c[i];
        }
        else {
            if (d[s[i]] != c[i]) {
                cout << -1;
                return 0;
            }
        }
    }

    if (N == 1) {
        if (d[0] == -1) cout << 0;
        else cout << d[0];
    }
    else if (N == 2) {
        if (d[0] == 0) cout << -1;
        else {
            if (d[0] == -1) cout << 1;
            else cout << d[0];
            if (d[1] == -1) cout << 0;
            else cout << d[1];
        }
    }
    else {
        if (d[0] == 0) {
            cout << -1;
            return 0;
        }
        else if (d[0] == -1) cout << 1;
        else cout << d[0];
        if (d[1] == -1) cout << 0;
        else cout << d[1];
        if (d[2] == -1) cout << 0;
        else cout << d[2];
    }

    return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++)
    {
        sum+=(s[i]-'0');
        sum%=9;
    }
    puts(!sum ? "Yes" : "No");
    return 0;
}

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

using namespace std;

int main() {
    long double a, b, h, m;

    long double kakudo;

    long double result;

    cin >> a >> b >> h >> m;

    m /= 5;
    h += m / 12;
    long double wariai = (h - m);
    if (wariai >= 12) {
        wariai -= 12;
    }

    kakudo = 3.141592653589793238462643 * abs(wariai) / 6;
    //cout<<cos(kakudo)<<endl;

    result = sqrt(a * a + b * b - (2 * a * b * cosl(kakudo)));

    cout << setprecision(20) << result << endl;
}


Measured memory_bytes: 4144
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
using llong = long long;

pair<llong, llong> a[100005];
priority_queue<llong> p_que;

int main() {
    llong n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }

    llong ans = 0;
    int idx = 0;
    sort(a, a + n);

    for (int i = m - 1; i >= 0; i--) {
        while (idx < n && a[idx].first <= (m - i)) {
            p_que.push(a[idx].second);
            idx++;
        }

        if (p_que.empty()) continue;
        ans += p_que.top();
        p_que.pop();
    }
    cout << ans << endl;
}

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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    if (v[i - 1] < v[i] && v[i] < v[i + 1]) {
      ans++;
    } else if (v[i - 1] > v[i] && v[i] > v[i + 1]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<tuple>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using state = tuple<int, int, int>;

const int INF = 1 << 30;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    --x1, --y1, --x2, --y2;
    vector<string> grid(H);
    for (auto& g : grid) {
        cin >> g;
    }
    priority_queue<state, vector<state>, greater<state>> que;
    vector<vector<int>> dp(H, vector<int>(W, INF));
    vector<int> dh = {-1, 0, 1, 0};
    vector<int> dw = {0, -1, 0, 1};
    dp[x1][y1] = 0;
    que.emplace(0, x1, y1);
    while (!que.empty()) {
        state now = que.top();
        que.pop();
        int dist = get<0>(now);
        int h = get<1>(now);
        int w = get<2>(now);
        if (dist > dp[h][w]) {
            continue;
        }
        rep(i, 0, 4) {
            int nh = h;
            int nw = w;
            rep(_, 0, K) {
                nh += dh[i];
                nw += dw[i];
                if (nh < 0 || nh >= H || nw < 0 || nw >= W || grid[nh][nw] == '@') {
                    break;
                }
                if (dp[nh][nw] < dist + 1) {
                    break;
                }
                // dp[nh][nw]=dist+1の時は遷移を打ち切ってはいけない
                if (chmin(dp[nh][nw], dist + 1)) {
                    que.emplace(dp[nh][nw], nh, nw);
                }
            }
        }
    }
    if (dp[x2][y2] == INF) {
        cout << -1 << endl;
    } else {
        cout << dp[x2][y2] << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    if (a > b)
        swap(a, b);
    if (b > 9)
        cout << -1;
    else
        cout << a*b;            
    return 0;
}
                

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{int i,N,L,R,sum1,sum2=0;
cin>>N;
for (i=1;i<=N;i++)
{
cin>>L>>R;
sum1=R-L+1;
sum2=sum1+sum2;
}
cout<<sum2;
system ("pause");
return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define pi 3.1415926536
#define mod 1000000007
#define inf 1000000000000000000
typedef long long ll;
using namespace std;

int main()
{

    //freopen("wall.in","r",stdin);
  ll x,y,z;
  cin>>x>>y>>z;
  if(x==y)cout<<z<<endl;
  else if(x==z)cout<<y<<endl;
  else cout<<x<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]


def dfs(A, X):
    M = len(A)
    if not A:
        print(*X, sep='\n')
        exit()
    for i in range(M):
        if A[i] > i + 1:
            return
    for i in range(M):
        if A[i] == i + 1:
            dfs(A[:i] + A[i + 1:], [i + 1] + X)


dfs(A, [])
print(-1)


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

using namespace std;

int main()
{	
   long long n;
   cin>>n;
   long long MOD = 1e9+7;
   long long prod=1LL;
   for(long long i=1;i<=n;i++){
   		prod = ((prod%MOD)*(i%MOD))%MOD;
   }
   cout<<prod<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n ;i++ )
#define MAX 8
#define INFTY (1<<21)


int h, w, G[MAX][MAX], si, sj;

struct State{ int i, j, hp; };

int bfs(){
    State s;
    s.i = si; s.j = sj; s.hp = 6;
    queue<State> Q;
    int d[MAX][MAX][7];
    rep(i, h) rep(j, w) rep(hp, 7) d[i][j][hp] = INFTY;
    Q.push(s);
    d[s.i][s.j][s.hp] = 0;
    
    static const int di[4] = {0, -1, 0, 1};
    static const int dj[4] = {1, 0, -1, 0};
    State u, v;
    int ni, nj;
    while( !Q.empty() ){
	u = Q.front(); Q.pop();
	//		cout << u.i << " " << u.j << " " << u.hp << endl;
	if ( G[u.i][u.j] == 3 ) return d[u.i][u.j][u.hp];

	for ( int r = 0; r < 4; r++ ){
	    ni = u.i + di[r];
	    nj = u.j + dj[r];
	    if ( ni < 0 || nj < 0 || ni >= h || nj >= w ) continue;
	    if ( G[ni][nj] == 0 ) continue;
	    v = u;
	    v.i = ni;
	    v.j = nj;
	    v.hp--;
	    if ( v.hp < 1 ) continue;
	    if ( G[v.i][v.j] == 4 ) v.hp = 6;
	    if ( d[v.i][v.j][v.hp] != INFTY ) continue;
	    d[v.i][v.j][v.hp] = d[u.i][u.j][u.hp] + 1;
	    Q.push(v);
	}
    }

    return -1;
}

main(){
    while( cin >> w >> h && h && w ){
	rep(i, h) rep(j, w){
	    cin >> G[i][j];
	    if ( G[i][j] == 2 ) { si = i; sj = j; G[i][j] = 1; };
	}
	cout << bfs() << endl;
    }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long ans = lcm(a, b);
        System.out.println(ans);
    }

    public static long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    public static long gcd(long a, long b) {
        if(b ==0 ) return a;
        else return gcd(b, a % b);
    }
}

Measured memory_bytes: 35412
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { [w,h,x,y,r] <-getInts
  ;  if x < r then putStrLn "No"
    else if y < r then putStrLn "No"
      else if x + r > w then putStrLn "No"
           else if y + r > h then putStrLn "No"
             else putStrLn "Yes"
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <sstream>
#include <climits>
#include <fstream>
#include <cmath>

using namespace std;

/// ********* debug template by Bidhan Roy *********

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const unordered_set< T > &v ) {
    os << "[";
    typename unordered_set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const unordered_map< F, S > &v ) {
    os << "[";
    typename unordered_map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    } 
    return os << "]";
}

#define debug(x) cerr << #x << " = " << x << endl;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<bool> VB;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<LL> VLL;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<VB> VVB;
typedef vector<VI> VVI;
typedef vector<VC> VVC;
typedef vector<VLL> VVLL;
typedef vector<VD> VVD;
typedef vector<VS> VVS;
typedef vector<PII> VPII;

// TEMPLATE DEFINITIONS END

LL n, a, b;

void read_input(){
    cin >> n >> a >> b;
}

void solve(){

    LL tmp = n / (a + b);
    LL tmp_sol = tmp * a;
    cout << tmp_sol + min(a, n - tmp*(a+b))  << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    read_input();
    solve();
    return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int h, w, n;
    cin >> h >> w >> n;

    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<vector<int>> c(h, vector<int>(w));

    int x = 0;
    int y = 0;
    int index = 0;
    int cnt = 0;

    while(x < w && y < h){
        if(y % 2 == 0){
            c[y][x] = index + 1;
            cnt++;
            if(cnt == a[index]){
                index++;
                cnt = 0;
            }
            x++;
            if(x == w){
                y++;
                x--;
            }
        } else {
            c[y][x] = index + 1;
            cnt++;
            if(cnt == a[index]){
                index++;
                cnt = 0;
            }
            x--;
            if(x == -1){
                y++;
                x++;
            }
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(j != w - 1){
                cout << c[i][j] << " ";
            } else {
                cout << c[i][j] << endl;
            }
        }
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    ll n,k,d[10],p;
    vector<ll> vec={0,1,2,3,4,5,6,7,8,9};
    scanf("%lld%lld",&n,&k);
    for(ll i=0;++i-k-1;)scanf("%lld",&d[i]);
    for(ll i=k+1;--i;)vec.erase(vec.begin()+d[i]);
    p=vec.size();
    for(ll f=-1;++f-p;){
                if(vec[f]>=n){
                    printf("%lld\n",vec[f]);
                    return 0;
                }
            }
    for(ll e=-1;++e-p;){
            for(ll f=-1;++f-p;){
                if(vec[e]*10+vec[f]>=n){
                    printf("%lld\n",vec[e]*10+vec[f]);
                    return 0;
                }
            }
        }
    for(ll c=-1;++c-p;){
        for(ll e=-1;++e-p;){
            for(ll f=-1;++f-p;){
                if(vec[c]*100+vec[e]*10+vec[f]>=n){
                    printf("%lld\n",vec[c]*100+vec[e]*10+vec[f]);
                    return 0;
                }
            }
        }
    }
    for(ll b=-1;++b-p;){
            for(ll c=-1;++c-p;){
                for(ll e=-1;++e-p;){
                    for(ll f=-1;++f-p;){
                        if(vec[b]*1000+vec[c]*100+vec[e]*10+vec[f]>=n){
                            printf("%lld\n",vec[b]*1000+vec[c]*100+vec[e]*10+vec[f]);
                            return 0;
                        }
                    }
                }
            }
        }
    for(ll a=-1;++a-p;){
        for(ll b=-1;++b-p;){
            for(ll c=-1;++c-p;){
                for(ll e=-1;++e-p;){
                    for(ll f=-1;++f-p;){
                        if(vec[a]*10000+vec[b]*1000+vec[c]*100+vec[e]*10+vec[f]>=n){
                            printf("%lld\n",vec[a]*10000+vec[b]*1000+vec[c]*100+vec[e]*10+vec[f]);
                            return 0;
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: usize = read();
    let k: String = read();
    let kc: Vec<char> = k.chars().collect();
    let ans: &str = &"".to_string();

    if kc.len() > s {
        for i in 0..s {
            print!("{}", kc[i]);
        }
        print!("...");
        return;
    }

    for i in 0..kc.len() {
        print!("{}", kc[i]);
    }
}


Measured memory_bytes: 2108
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class GraphMST {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public GraphMST() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	private int mst_cost=0;
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = in.nextInt();;
			}
		}
		in.close();
	}
	public int getMSTcost(){
		return mst_cost;
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] != -1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] != -1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
//		boolean flag=false;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
//				flag = true;
			}
		}
//		if(flag){
			mst_cost += md; 
//			flag = false;
//		}
		return mv;
	}
	//implement the following	
	public int[] Prim(int s) {
		int [] D = new int[totalVertex];
		for(int i=0; i<totalVertex; i++){
			D[i] = Integer.MAX_VALUE;
		}
		D[s] = 0;
		for(int i=1; i<totalVertex; i++){			
			ifSettled[s] = true;
//			if(D[s] == Integer.MAX_VALUE) return void; // unreachable
			LinkedList<Integer> UnsettleNeighbors = getUnsettledNeighbors(s);
			Iterator<Integer> it = UnsettleNeighbors.iterator();
			while(it.hasNext()){
				int v = it.next();
				if(D[v] > getWeight(s,v))
					D[v] = getWeight(s,v);
			}
			s = getUnsettledNearest(D);
		}		
		return D;
	}
}

public class Main {
	public static void main(String[] argv) {
		GraphMST g = new GraphMST();
		g.loadAdjMatrix();
		int[] dist = g.Prim(0);
		System.out.println(g.getMSTcost());
//		for(int i = 0; i < g.getTotalVertex(); i ++) {
//			System.out.println(i + " " + dist[i]);
//		}
	}
}


Measured memory_bytes: 40876
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T> using MaxHeap = priority_queue<T>;
Int solve(const vector<int> &K, const vector<int> &L, const vector<int> &R) {
    int N = K.size();
    Int ans = 0;
    map<int, vector<int>> M;
    for (int i = 0; i < N; i++) {
        ans += R[i];
        M[K[i]].push_back(L[i] - R[i]);
    }
    MinHeap<int> Q;
    MaxHeap<int> QQ;
    for (auto& [n, vec] : M) {
        for (auto item : vec) if (item >= 0) {
            while (Q.size() >= n && Q.top() < item) {
                Q.pop();
            }
            if (Q.size() < n) Q.push(item);
        }
    }
    for (auto it = rbegin(M); it != rend(M); ++it) {
        auto& [n, vec] = *it;
        int m = N - n;
        if (m == 0) continue;
        for (auto item : vec) if (item < 0) {
            while (QQ.size() >= m && QQ.top() > item) {
                QQ.pop();
            }
            if (QQ.size() < m) QQ.push(item);
        }
    }
    while (!Q.empty()) { ans += Q.top(); Q.pop(); }
    for (auto& [n, vec] : M) for (auto item : vec) if (item < 0) ans += item;
    while (!QQ.empty()) { ans -= QQ.top(); QQ.pop(); }
    return ans;
}
int main() {
    int T; cin >> T;
    while (T--) {
        int N; cin >> N;
        vector<int> K(N), L(N), R(N);
        for (int i = 0; i < N; i++) cin >> K[i] >> L[i] >> R[i];
        cout << solve(K, L, R) << '\n';
    }
    return 0;
}

Measured memory_bytes: 18916
S = int(input())
if S==1 or S==2:
    print(0)
else:
    dp = [0 for S in range(S+1)]
    dp[0]=1
    for i in range(3,S+1):
        dp[i]=sum(dp[:i-2])
    dp = list(map(lambda x:x%1000000007,dp))
    print(dp[S])

Measured memory_bytes: 9340