akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

double a[4000];
double p[3000];
int main(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> p[i];
    }
    a[0] = 1.0;
    rep(i,n){
        for(int j=n;j>=1;j--){
            a[j] += a[j-1]*p[i];
            a[j-1] -= a[j-1]*(p[i]);
        }
    }
    rep(i,n+1){
        cerr << a[i] << " ";
    }
    cerr << endl;
    double ans = 0.0;
    for(int i=(n/2)+1;i<=n;i++){
        ans += a[i];
    }
    cout.precision(20);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

int main(){
    string s; cin >> s;
    map<char,int> mp;
    for(auto it : s){
        mp[it]++;
    }
    bool ok = true;
    if(mp.size() == 2){
        for(auto it : mp){
            if(it.second!=2)ok = false;
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef unsigned long long int llui;
int main(void)
{
    int n;
    char name[100001][11];
    llui ans=0;
    llui m,a,r,c,h;

    m=a=r=c=h=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",name[i]);
        switch (name[i][0]){
        case 'M':
            m++;
            break;
        case 'A':
            a++;
            break;
        case 'R':
            r++;
            break;
        case 'C':
            c++;
            break;
        case 'H':
            h++;
            break;
        }
    }
    ans+=m*a*r;
    ans+=m*a*c;
    ans+=m*a*h;
    ans+=m*r*c;
    ans+=m*r*h;
    ans+=m*c*h;
    ans+=a*r*c;
    ans+=a*r*h;
    ans+=a*c*h;
    ans+=r*c*h;
    printf("%llu\n",ans);
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, W[100];
	cin >> N;
	int goukei = 0;
	rep(i, N) {
		cin >> W[i];
		goukei += W[i];
	}

	int kotae = 1e9;
	int kari = 0;
	rep(i, N - 1) {
		kari += W[i];
		kotae = min(kotae, abs(kari - goukei + kari));
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    char a[5];
    gets(a);
    for (int i = 0; i < 3; i++)
    {
        if (a[i] == '1')
            printf("%d", 9);
        else if (a[i] == '9')
            printf("%d", 1);
        else
            printf("%d", a[i]);
    }
    return 0;
}

Measured memory_bytes: 128
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> as(n+1, 0);
    REP(i, n) as[i+1] = as[i] + a[i];

    ll ans = LINF;
    RANGE(i, 1, n-1) {
        ll l = as[i] - as[0];
        ll r = as[n] - as[i];
        chmin(ans, abs(r - l));
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3456
#include <iostream>
#include<vector>
#include<cstdio>
using namespace std;
class DisjointSet{
    public: vector<int> set,rank;
    DisjointSet(int n){
        set.resize(n);rank.resize(n);
        for(int i = 0;i < n;++i){
            set[i] = i;
            rank[i] = 0;
        }
        
    }
    
    public: void unite(int x,int y){
        int ix = findSet(x),iy = findSet(y);
        if(rank[ix] > rank[iy]){
            set[iy] = ix;
        } else{
            set[ix] = iy;
        }
    }
    
    public: int findSet(int x){
        if(set[x] != x){
            set[x] = findSet(set[x]);
        }
        return set[x];
    }
};

int main(void){
    int n,q,x,y,c;
    scanf("%d %d",&n,&q);
    DisjointSet set(n);
    for(int i = 0;i < q;++i){
        scanf("%d",&c) ;
        scanf("%d %d",&x,&y);
        if(c==0){
            set.unite(x,y);
        }else{
            printf("%s\n",(set.findSet(x) == set.findSet(y) ? "1":"0"));
        }
    }
    
}



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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,q;
  scanf("%d%d",&n,&q);
  map<pii,ll> M;
  M[pii(0,n-1)] = 0;
  while(q--){
    int a;
    ll b;
    scanf("%d%lld",&a,&b);
    --a;
    auto it = M.upper_bound(pii(a,n+252521));
    it--;
    if(it->first.second != a){
      // split
      ll val = it->second;
      int beg = it->first.first;
      int end = it->first.second;
      M.erase(it);
      M[pii(beg,a)] = val;
      M[pii(a+1,end)] = val;
      it = M.find(pii(beg,a));
    }
    while(b>0){
      bool lastflag = false;
      auto bef = it;
      if(it == M.begin()){
        lastflag = true;
      }else{
        bef--;
        ll sub = bef->second - it->second;
        ll rest = sub * (it->first.second - it->first.first + 1);
        if(b>=rest){
          b -= rest;
          // join
          ll val = bef->second;
          int beg = bef->first.first;
          int end = it->first.second;
          M.erase(bef);
          M.erase(it);
          M[pii(beg,end)] = val;
          it = M.find(pii(beg,end));
        }else{
          lastflag = true;
        }
      }
      if(lastflag){
        // split
        ll aval = it->second;
        ll bval = aval;
        int beg = it->first.first;
        int end = it->first.second;
        int cnt = end-beg+1;
        ll add = b/cnt;
        aval += add;
        bval += add;
        b -= add*cnt;
        if(b==0){
          it->second = aval;
        }else{
          M.erase(it);
          aval += 1;
          int sp = beg+b-1;
          b = 0;
          M[pii(beg,sp)] = aval;
          M[pii(sp+1,end)] = bval;
          it = M.find(pii(beg,sp));
        }
        // join
        if(it != M.begin()){
          auto bef = it; bef--;
          if(bef->second == it->second){
            ll val = it->second;
            int beg = bef->first.first;
            int end = it->first.second;
            M.erase(bef);
            M.erase(it);
            M[pii(beg,end)] = val;
          }
        }
      }
    }
    // debug
    // it = M.begin();
    // REP(i,n){
    //   printf("%lld ",it->second);
    //   if(i == it->first.second){
    //     it++;
    //   }
    // }
    // putchar('\n');
  }
  auto it = M.begin();
  REP(i,n){
    printf("%lld\n",it->second);
    if(i == it->first.second){
      it++;
    }
  }
  return 0;
}


Measured memory_bytes: 7680
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial

sys.setrecursionlimit(10**7)
N = int(input())
W = [input() for _ in range(N)]

s = set()
s.add(W[0])
l = W[0][-1]

for w in W[1:]:
    if w in s:
        print('No')
        exit()

    if w[0] != l:
        print('No')
        exit()

    l = w[-1]
    s.add(w)

print('Yes')


Measured memory_bytes: 3316
#include <cstdio>
#include <cmath>

const double PI = 3.14159265358979;

double are(double a, double b, double c){
    return 0.5*a*b*sin(c*PI/180);
}

double len(double a, double b, double c){
    return a + b + sqrt(a*a+b*b-2*a*b*cos(c*PI/180));
}

int main(){
    double a, b, c, S, L, h;
    scanf("%lf %lf %lf", &a, &b, &c);
    S = are(a, b, c);
    L = len(a, b, c);
    h = S * 2 / a;
    printf("%lf\n%lf\n%lf\n", S, L, h);
    return 0;
}


Measured memory_bytes: 3056
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

newtype Max = Max {getMax :: Int} deriving (Show, Eq, Ord)
instance Monoid Max where
  mempty = Max minBound
  Max x `mappend` Max y = Max (max x y)

newtype Success a = Success {getSuccess :: Maybe a} deriving (Eq, Ord, Show)
instance Monoid a => Monoid (Success a) where
  mempty = Success (Just mempty)
  Success Nothing `mappend` _ = Success Nothing
  _ `mappend` Success Nothing = Success Nothing
  Success (Just a) `mappend` Success (Just b) = Success (Just (mappend a b))

main = do
    n <- getInt
    m <- getInt
    xs <- replicateM n getInts
    print $ getMax $ fromMaybe (Max 0) $ getSuccess $ Foldable.foldMap Success $ map (\x -> if x>=0 then Just (Max x) else Nothing) $ scanl (\t [i,o] -> t + i - o) m xs
    
    return ()


Measured memory_bytes: 9300
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    for i in d.keys():
        if d[i] != 2:
            print("No")
            quit()
    print("Yes")
    return

#B
def B():
    n = I()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        k = p[i-1:i+2]
        k.sort()
        if k[1] == p[i]:
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()
    d = LI()
    d.sort()
    print(d[n//2]-d[n//2-1])
    return

#D
def D():
    n,k = LI()
    fact = [1]*10001
    for i in range(1,10001):
        fact[i] = fact[i-1]*i%mod
    inv = [1]*10001
    inv[-1] = pow(fact[-1],mod-2,mod)
    for i in range(1,10001)[::-1]:
        inv[i-1] = inv[i]*i%mod
    for i in range(1,k+1):
        if n-k+1 < i:
            print(0)
        else:
            ans = fact[n-k+1]*inv[i]*inv[n-k+1-i]%mod
            ans *= fact[k-1]*inv[k-i]*inv[i-1]%mod
            ans %= mod
            print(ans)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return


#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 42864
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~code:C++;No O2;by:zrszmd;~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include<bits/stdc++.h>
using namespace std;
int n,l,r,ans;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>l>>r;
        ans+=r-l;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;

int n, g[MAXN], nxt[MAXN << 1], to[MAXN << 1], edgeSize;
int dep[MAXN], size[MAXN]; bool vis[MAXN];

bool dfs(int x){
	size[x] = 1;
	if(x == n) vis[x] = true;
	for(int p = g[x]; p; p = nxt[p])
		if(!dep[to[p]]){
			dep[to[p]] = dep[x] + 1;
			if(dfs(to[p])) vis[x] = true;
			size[x] += size[to[p]];
		}
	return vis[x];
}
void addEdge(int u, int v){
	nxt[++ edgeSize] = g[u];
	to[g[u] = edgeSize] = v;
}
int main(){
	int i, u, v;
	scanf("%d", &n);
	for(i = 1; i < n; ++ i){
		scanf("%d%d", &u, &v);
		addEdge(u, v), addEdge(v, u);
	} dep[1] = 1, dfs(1);
	for(i = 1; i <= n; ++ i)
		if(vis[i] && dep[i] == (dep[n] + 1) / 2 + 1){
			printf("%s\n", size[i] >= n - size[i] ? "Snuke" : "Fennec");
			return 0;
		}
}

Measured memory_bytes: 6144
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

int main() {
    ll n, k, sum = 0, cnt = 0;
    scanf("%lld%lld", &n, &k);
    vector< pair<ll, ll> > d(n);
    for (ll i = 0; i < n; ++i) scanf("%lld%lld", &d.at(i).second, &d.at(i).first);
    sort(d.begin(), d.end(), greater< pair<ll, ll> >());
    priority_queue< pair<ll, ll>, vector< pair<ll, ll> >, greater< pair<ll, ll> > > q;
    vector<ll> ans(n + 1);
    vector<bool> u(n + 1);
    for (ll i = 0; i < k; ++i) {
        sum += d.at(i).first;
        if (u.at(d.at(i).second)) q.push(d.at(i));
        else u.at(d.at(i).second) = true, ++cnt;
    }
    ans.at(cnt) = sum + cnt * cnt;
    for (ll i = k; i < n && !q.empty(); ++i) if (!u.at(d.at(i).second)) {
        ans.at(cnt + 1) = ans.at(cnt) - q.top().first + d.at(i).first + cnt * 2 + 1;
        ++cnt;
        u.at(d.at(i).second) = true;
        q.pop();
    }
    printf("%lld\n", *max_element(ans.begin(), ans.end()));
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
 
typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;
 
using namespace std;
 
u64 ceil(u64 n) {
  if(n % 10 == 0) {
    return n;
  } else {
    return (n / 10 + 1) * 10;
  }
}
 
u64 f(u64 n) {
  if(ceil(n) == n) {
    return 10;
  } else {
    return n + 10 - ceil(n);
  }
}
 
int main(int argc, const char* argv[]) {
  u64 a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  
  u64 ret = ceil(a) + ceil(b) + ceil(c) + ceil(d) + ceil(e);
  u64 aaa = min({f(a), f(b), f(c), f(d), f(e)});
  
  cout << ret - 10 + aaa << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while( sc.hasNext() ){
            String[] line = sc.nextLine().split(" ");
            int inputtime = Integer.parseInt(line[0]);
            int hour = inputtime/3600;
            int minute = inputtime%3600/60;
            int second = inputtime%3600%60;
            System.out.println(hour+":"+minute+":"+second);
        }
    }
}

Measured memory_bytes: 26232
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n,k;
	cin >> n >> k;
	
	int ans = 0;
	rep(i,0,n){
		int x;
		cin >> x;
		ans += min( 2 * x , 2 * abs( k - x ) );
	}
	P(ans);
	ret 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n+1);
    for (int i = 2; i <= n; i++) {
        int num;
        cin >> num;
        a.at(num)++;
    }
    for (int i = 1; i <= n; i++) {
        cout << a.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 4052
import collections

c9 = []
c6 = []
for i in range(7):
    c9.append(9 ** i)
    c6.append(6 ** i)

inf = 1 << 60
N = int(input())
q = collections.deque()
q.append((N,0))
ans = inf
try:
    while True:
        v = q.popleft()
        if v[1] >= ans:
            continue
        for i in range(6,0,-1):
            if v[0] >= c9[i]:
                v2 = (v[0] - c9[i], v[1] + 1)
                q.append(v2)
                break
        for i in range(6,0,-1):
            if v[0] >= c6[i]:
                v2 = (v[0] - c6[i], v[1] + 1)
                q.append(v2)
                break
        if v[0] < 6:
            v2 = (0, v[1] + v[0])
            ans = min(ans, v2[1])

except IndexError:
    pass

print(ans)


Measured memory_bytes: 45168
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

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

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    int n;
    cin >> n;
    vl a(n);
    cin >> a;
    ll s = accumulate(all(a), 0LL);
    s %= h;
    ll ans = 0;
    rep(i,0,n)
        s += h - a[i], s %= h, (ans += a[i] * s) %= h;
    cout << ans;
}


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

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

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

    int ans = 0;
    for(int i = 0; i < n - 2; i++) {
        if((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i + 2] < p[i + 1] && p[i + 1] < p[i])) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

#100011 ← 各桁の数字が宝の状態。1:open　0:close。これが配列のindexとなる。
#宝がn個あれば、2**nの状態がある。
#配列の値は、その状態にするまでにかかるコスト。
#最初は、すべての状態の値が無限。
#具体的な鍵を使う毎に、そのコストに変更されていく。
inf=int(1e10)
dp=[inf]*(2**n)

#利用した鍵を入れる
bits=set()

#000000状態(どの宝も空いていない状態)のコストは0
dp[0]=0
#状態0にするための鍵を入れる
bits.add(0)

for _ in range(m):
  cost,kind=map(int,input().split())
  
  key=list(map(int,input().split()))
  keyBit=0
  
  #鍵であけられる宝箱を2進数に変換
  for temp in key:
    keyBit+=2**(temp-1)
  
  #orを取る
  for item in list(bits):
    temp=item|keyBit
    dp[temp]=min(dp[temp],dp[item]+cost)
    bits.add(temp)

print(dp[2**n-1] if dp[2**n-1]!=inf else -1)

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    ll a, b;
    cin >> a >> b;

    int ans;
    for(int n = 1; n <= 999; n++){
        int ax, bx;
        ax = n*(1+n)/2 - a;
        bx = (n+1)*(1+(n+1))/2 - b;
        if(ax == bx){
            ans = ax;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#include<stdlib.h>


int main(void){


  int n,Count=0,count2=0,i,len,kazu[1000],sum=0;


  char x[1000],a;


  while(1){


      sum=0;


      scanf("%s",x);


      if(x[0]=='0'){


        break;


      }


      len=strlen(x);


      for(i=0;i<len;i++){


        a=x[i];


      kazu[i]=atoi(&a);


      sum=sum+kazu[i];


      }


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


  }


return 0;


}

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

int main() {
  map<string,int> mp;
  int n,maxmap=0;
  cin >> n;
  r(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  for(auto it=mp.begin();it!=mp.end();it++){
    maxmap=max(maxmap,(*it).second);
  }
  for(auto it=mp.begin();it!=mp.end();it++){
    if((*it).second==maxmap)cout<<(*it).first<<endl;
  }
}


Measured memory_bytes: 25216
#include <iostream>
#include <cstdio>
 
int main(int argc, char* argv[]) {
  int n;
  std::cin>>n;
  double res = 0.5;
  if (n % 2 == 1) {
    res = (double) (n+1)/(2*n);
  }
  printf("%.10f\n", res);
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1 ; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1 ; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const bool debug = 0;
/***************************************/

int main() {
  ll N, y, x;
  while (cin >> N >> y >> x, N || y || x) {
    if (debug) putchar('@');

    int ope[61] = {}; // 0:no 1:plus
    ll h = 1ll<<N;
    REP(i, N) {
      if (y <= h / 2) {
        ope[N - i - 1] = 1;
        y = h / 2 - y + 1;
      }
      else y -= h / 2;
      h /= 2;
    }

    string ans = "";
    h = 1ll<<N;
    REP(i, N) {
      if (x <= h / 2 && ope[i]) {
        ans += "L";
        x = h / 2 - x + 1;
      }
      else if (x <= h / 2 && !ope[i]) {
        ans += "R";
      }
      else if (x > h / 2 && ope[i]) {
        x -= h / 2;
        x = h / 2 - x + 1;
        ans += "R";
      }
      else {
        x -= h / 2;
        ans += "L";
      }

      h /= 2;
    }
    cout << ans << endl;
  }
  
  return 0;
}


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

int main() {
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int money = 0;
  
  if (A+B >= 2*C){
    if (X > Y){
      money += C * 2 * Y;
      if (A <= C*2){
        money += A * (X - Y);
      }
      else {
        money += C * 2 * (X - Y);
      }
    }
    else if (X == Y){
      money += C * 2 * Y;
      cout << money << endl;
      return 0;
    }
    else if (X < Y){
      money += C * 2 * X;
      if (B <= C*2){
        money += B * (Y - X);
      }
      else {
        money += C * 2 * (Y - X);
      }
    }
  }
  else {
    money += A * X + B * Y;
  }
  cout << money << endl;
}
 
      



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

# define ll long long 
# define VI vector<int>
# define VL vector<ll>
# define PII pair<int,int> 
# define VII vector<PII>
# define mp make_pair
# define pb push_back
# define vt vector
# define PI acos(-1)
# define ld long double
# define endl "\n"
# define all(c) (c).begin(), (c).end()
# define ft first 
# define sd second 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i) 
# define F0R(i,b) for(int i = 0 ; i < b ; ++i) 
# define RF0R(i,b) for(int i = b ; i >= 0 ; --i) 
const ll inf = 1e18 ; 
const int MxN = 100001 ; 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	
	int n , m , x; 
	cin >> n >> m >> x ; 
	vt<int> c(n) ; 
	vt<vt<int>> A(n,vt<int>(m)) ; 
	
	F0R(i,n) {
		cin >> c[i] ; 
		F0R(j,m) 
			cin >> A[i][j] ; 
	}
	int ans = INT_MAX ; 
	F0R(i,(1<<n)) {
		int cost = 0 ; 
		vt<int> skills(m) ; 
		F0R(j,n) {
			if((i>>j)&1) {
				//cout << 1 ; 
				F0R(k,m)
					skills[k] += A[j][k] ; 
				cost += c[j] ;
			} 
			//cout <<0;
		} 
		//cout << endl ; 
		bool ok = true ;
		F0R(j,m) {
			if(skills[j] < x) {
				ok = false ;
				break ;
			}
		}
		if(ok) {
			ans = min(ans , cost ) ; 
		}
	}
	if(ans == INT_MAX) 
		cout << -1 ; 
	else 
		cout << ans; 
	return 0 ; 
}




Measured memory_bytes: 3664
num = input()
num_1 = int(num[0:2])
num_2 = int(num[2:4])
ans = ["AMBIGUOUS", "MMYY", "YYMM", "NA"]
flag = 3
if 1 <= num_1 and num_1 <= 12:
  if 1 <= num_2 and num_2 <= 12:
    flag = 0
  else:
    flag = 1
else:
  if 1 <= num_2 and num_2 <= 12:
    flag = 2

print(ans[flag])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

    vector< vector<int> > x(n, vector<int>(d));
    for (int i=0; i<n; i++)
        for (int j=0; j<d; j++)
            cin >> x[i][j];

    int ans = 0;
    for (int i=0; i<n-1; i++) {
        for (int j=i+1; j<n; j++) {
            double distance = 0;
            for (int k=0; k<d; k++)
                distance += pow(x[i][k] - x[j][k], 2);
            distance = sqrt(distance);
            if (floor(distance) == ceil(distance)) ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 632
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
VI findAll(string S,string pattern){VI P;ll pos=(ll)S.find(pattern);
while(pos!=string::npos){P.push_back(pos);pos=(ll)S.find(pattern,pos+1);}return P;}
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
bool is_prime(ll n){if(n<2)return 0;for(int i=2;i*i<n;i++)if(n%i==0)return 0;return 1;}
inline void eratosthenes(VB& p){rep(i,SZ(p))p[i]=1;p[0]=p[1]=0;
rep(i,SZ(p)/2+1){if(p[i])for(ll j=i+i;j<SZ(p);j+=i)p[j]=0;}}
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}// x^n%mod
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
using Graph=vector<vector<int> >;//int と P

int main(){
    double a,b,x;cin>>a>>b>>x;
    if(x<=a*a*b/2.0){
    double y=x*2/(a*b);
    double s=90-atan(y/b)*180/PI;
    printf("%.12lf\n",s);
    return 0;
    }
    else {
        double y=(a*a*b-x)*2/(a*a);
        double s=atan(y/a)*180/PI;
    printf("%.12lf\n",s);
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(int argc, char const *argv[])
{
struct N{	
	char st[10];
	int ab;
};

struct N n[2];
char u[10];
int i;

	scanf("%s %s\n%d %d\n%s",n[0].st,n[1].st,&n[0].ab,&n[1].ab,u);	
	
for(i=0;i<2;i++){
	if(strcmp(n[i].st,u)==0)n[i].ab=n[i].ab-1;
}
printf("%d %d\n",n[0].ab,n[1].ab);
	return 0;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

bool solve(string s, string &ans) {
    int len = s.length();
	char t = ans[0];
	rep(i,1,len) {
		if(s[i]=='o') {
			if(ans[i]=='S' && ans[i-1]=='S') ans[(i+1)%len] = 'S';
			else if(ans[i]=='S' && ans[i-1]=='W') ans[(i+1)%len] = 'W';
			else if(ans[i]=='W' && ans[i-1]=='S') ans[(i+1)%len] = 'W';
			else ans[(i+1)%len] = 'S';
		} else {
			if(ans[i]=='S' && ans[i-1]=='S') ans[(i+1)%len] = 'W';
			else if(ans[i]=='S' && ans[i-1]=='W') ans[(i+1)%len] = 'S';
			else if(ans[i]=='W' && ans[i-1]=='S') ans[(i+1)%len] = 'S';
			else ans[(i+1)%len] = 'W';
		}
	}
	if(t != ans[0]) return false;
	if(s[0]=='o') {
        if(ans[0]=='S') return ans[1] == ans[len-1];
        else return ans[1] != ans[len-1];
	} else {
        if(ans[0]=='S') return ans[1] != ans[len-1];
        else return ans[1] == ans[len-1];
	}
}

int main() {
    int n;
    string s;
    while(cin >> n >> s) {
        vector<string> vs = {"SS", "SW", "WS", "WW"};
        bool flag = false;
        rep(i,0,4) {
            string ans(s.length(), ' ');
			ans[0] = vs[i][0];
			ans[1] = vs[i][1];
            if(solve(s, ans)) {
                cout << ans << endl;
                flag = true;
                break;
            }
        }
        if(!flag) cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#define MOD 1000000007
#define MAX 3000000
using namespace std;
typedef long long int ll;


ll fac[MAX],fac_inv[MAX],inv[MAX];

void COMinit(){
    fac[0]=1;
    fac[1]=1;
    fac_inv[0]=1;
    fac_inv[1]=1;
    inv[1]=1;
    for(int i =2 ; i< MAX ; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        fac_inv[i] = fac_inv[i - 1] * inv[i] % MOD;
    }
}
ll COM(int n, int k){
    if(n < k){
        return 0;
    }else if(n < 0 || k < 0){
        return 0;
    }else{
        return fac[n] * (fac_inv[k]*fac_inv[n-k] % MOD) % MOD;
    }
}

int main(){
    ll X,Y;
    cin >> X >> Y;
    if(( X+Y ) % 3 != 0){
        cout << "0" << endl;
    }else{
        ll a = (2 * X - Y ) / 3;
        ll b = (2 * Y - X) / 3;
        COMinit();
        cout << COM(a+b,a) << endl ;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n,k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i,n)cin >> v[i];
  for(int i = k;i < n;i++){
    if(v[i] > v[i-k])cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  

  return 0;
}

Measured memory_bytes: 4048
n=int(input())
l=list(map(int,input().split()))
q=int(input())
dic=dict()
list_sum=sum(l)
for i in range(len(l)):
    if(l[i] not in dic.keys()):
        dic[l[i]]=1
    else:
        dic[l[i]]+=1
# print(dic)
s=list_sum
for i in range(q):
    b,c=map(int,input().split())
    # print(dic)
    if(b in dic and dic[b]!=0):
        s+=(c-b)*dic[b]
        if(c in dic):
            dic[c]+=dic[b]
            dic[b]=0
        else:
            dic[c]=dic[b]
            dic[b]=0
    
    print(s)
    # print(dic)





Measured memory_bytes: 20692
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  int n;
  cin >> n;
  queue<int> q;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    q.push(a);
  }
  int count = 0;
  while (!q.empty()) {
    if (q.front() == count + 1) {
      count++;
    }
    q.pop();
  }
  if (count == 0) {
    cout << -1 <<endl;
  }
  else {
    cout << n - count <<endl;
  }
} 


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}
int n, m;
int dp[100010];
whei(int) G;
int dfs(int a) {
	if (dp[a] != -1)return dp[a];
	int s=0;
	for (auto x : G[a]) {
		s = max(s, dfs(x) + 1);
	}
	return dp[a] = s;
}



int main(){
	cin >> n >> m;
	G.assign(n, vector<int>());
	for (int i = 0; i < m;i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
	}
	rep(i, 0, n)dp[i] = -1;
	int ans = 0;
	rep(i, 0, n)ans = max(ans, dfs(i));
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 8192
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from heapq import heappop,heappush
    n,m=map(int,input().split())
    A=[[] for _ in range(m)]
    for _ in range(n):
        a,b=map(int,input().split())
        if(a>m): continue
        a-=1
        heappush(A[a],(-b,a))
    Q=[]
    res=0
    for i in range(m):
        if(A[i]):
            x=heappop(A[i])
            heappush(Q,x)
        if(Q):
            b,a=heappop(Q)
            res-=b
            if(A[a]):
                x=heappop(A[a])
                heappush(Q,x)
    print(res)
resolve()

Measured memory_bytes: 27168
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long r, d, x, xx, i;
	cin >> r >> d >> x;
	for (i = 1; i <= 10; i++) {
		x = r * x - d;
		cout << x << "\n";
			
	}


	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <numeric>
#include <cmath>
#include <iostream>
using i64 = long long;
using namespace std;


class ModInt {
public:
  int value;
  static const int mod = 1e9 + 7;
  ModInt() : value(0) {}
  ModInt(int value) {
    this->value = normalize(value);
  }  
  ModInt operator+(ModInt const &other) {
    return ModInt(normalize(this->value + other.value));
  }
  ModInt operator-(ModInt const &other) {
    return ModInt(normalize(this->value - other.value));
  }
  ModInt operator-=(ModInt const &other) {
    this->value = normalize(this->value - other.value);
    return *this;
  }
  ModInt& operator+=(const ModInt& other) {
      this->value = normalize(this->value + other.value);
      return *this;
}
  int normalize(i64 value) {
    while (value < 0) value += mod;
    value %= mod;
    return value;
  }
};
 
ostream& operator<<(ostream& os, ModInt const &m) {
  os << (m.value);
  return os;
}

const int maxn = 100;
const int maxk = 1e5;
int a[maxn];
ModInt dp[maxk + 1];

int main() {
  int n, K;
  cin >> n >> K;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    // convert to prefix sum
    for (int j = 1; j <= K; j++) {
      dp[j] += dp[j - 1];
    }
    // compute answer based on prefix sums
    for (int j = K; j > a[i]; j--) {
      dp[j] -= dp[j - a[i] - 1];
    }
  }
  cout << dp[K] << '\n';
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdlib> 
#include <string>
#include <stack>
using namespace std;

int main(){
  stack<int> S;
  int a,b;
  string s;

  while( cin >> s){
    if(s[0] == '+'){
      a = S.top();
      S.pop();
      b = S.top();
      S.pop();
      S.push(a + b);
    }else if(s[0] == '-'){
      a = S.top();
      S.pop();
      b = S.top();
      S.pop();
      S.push(b - a);
    }else if(s[0] == '*'){
      a = S.top();
      S.pop();
      b  = S.top();
      S.pop();
      S.push(a * b);
    }else{
      S.push(atoi(s.c_str()));
    }
  }

  cout << S.top() << endl;

  return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  
  string t="Good";
  if (s[0]==s[1]) {
    t="Bad";
  }
  if (s[2]==s[1]) {
    t="Bad";
  }
  if (s[2]==s[3]) {
    t="Bad";
  }
  cout<<t<<endl;
}

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

#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi acos(-1.0)

void solve();
int32_t main()
{
    IOS;
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if((a[i]!=a[j]) && (a[j]!=a[k]) && (a[i]+a[j]>a[k]))
                    cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3632
H,W,K=map(int,input().split())
S=[[int(s) for s in input()] for i in range(H)]

ans=1000000
for i in range(2**(H-1)):
    tmp=0
    L=[]
    for j in range(H-1):
        if i>>j&1:
            L.append(j)
    tmp+=len(L)
    L.append(H-1)
    c=[0]*len(L)
    for k in range(W):
        h=0
        c1=[0]*len(L)
        for l in range(len(L)):
            for m in range(h,L[l]+1):
                c1[l]+=S[m][k]
            h=L[l]+1
        p=0
        for l in range(len(L)):
            if c1[l]>K:
                p=2
                break
            elif c[l]+c1[l]>K:
                p=1
            else:
                c[l]+=c1[l]
        if p==2:
            break
        elif p==1:
            c=[i for i in c1]
            tmp+=1
    else:
        ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 69612
S = input()
dic = {}
flag = 0

for i in range(4):
    if S[i] in dic:
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1

for v in dic.values():
    if v != 2:
        flag += 1

if flag == 0:
    print('Yes')
else:
    print('No')


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

struct event {
    ll t;
    ll type;
    ll pos;
};

void solve() {
    ll N, Q;
    cin >> N >> Q;
    vector<event> events;
    rep(i, N) {
        ll s, t, x;
        cin >> s >> t >> x;
        events.push_back(event{s - x, 0, x});
        events.push_back(event{t - x, 1, x});
    }
    auto f = [](event a, event b) {
        if (a.t == b.t) return a.pos < a.pos;
        return a.t < b.t;
    };
    sort(events.begin(), events.end(), f);
    multiset<ll> used;
    ll m = events.size();
    ll idx = 0;
    rep(i, Q) {
        ll d;
        cin >> d;
        while (idx < m && events[idx].t <= d) {
            event e = events[idx];
            if (e.type) {
                used.erase(used.find(e.pos));
            } else {
                used.insert(e.pos);
            }
            idx++;
        }
        if (used.empty()) {
            cout << -1 << '\n';
        } else {
            cout << *used.begin() << '\n';
        }
    }

}

int main() {
    cin.tie(nullptr);
    // ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 20200
def main():
    N = int(input())

    result = 0
    if 0 <= N <= 111:
        result = 111
    elif 111 < N <= 222:
        result = 222
    elif 222 < N <= 333:
        result = 333
    elif 333 < N <= 444:
        result = 444
    elif 444 < N <= 555:
        result = 555
    elif 555 < N <= 666:
        result = 666
    elif 666 < N <= 777:
        result = 777
    elif 777 < N <= 888:
        result = 888
    elif 888 < N <= 999:
        result = 999

    print(result)
    

main()

Measured memory_bytes: 3064
// Branch on Condition - Small, Large, or Equal
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_A
using System;
using System.Linq;
using System.Collections.Generic;

namespace NTL_2_A {
	class Program {
        const ulong mod = 1000000007;
		public Program() {}
		
		public static void Main() {
			new Program().Calc();
		}
		
		void Calc() {
			var n = Input.Split(' ')
                            .Select(i => int.Parse(i))
			                .ToArray();
			Output("a " + judge(n[0], n[1]) + " b");
		}
		
		String Input {
			get {
				return Console.ReadLine();
			}
		}
		
		void Output(String str) {
			Console.WriteLine(str);
		}
		
		String judge(int a, int b) {
            if(a == b) return "==";
            if(a > b) return ">";
            return "<";
		}
	}
}

Measured memory_bytes: 9324
#include <bits/stdc++.h>
 
#define EPS 1e-9
#define INF 1070000000LL
#define mod 1000000007LL
#define all(x) (x).begin(),(x).end()
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,m,n) for(int i=m;i<(n);i++)
#define rep1(i,m,n) for(int i=m;i<=(n);++i)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())
using namespace std;
 
typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;
typedef vector<ll>vii;
vector<int>a;
inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
 
 
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
ll n;
cin>>n;
ll ans=modPow(10,n);
ans=modSub(ans,modMul(2LL,modPow(9,n)));
ans=modAdd(ans,modPow(8,n));
cout<<ans<<'\n';
	

}



Measured memory_bytes: 3600