akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll ans=0;
    ll N,M;
    cin >> N >> M;
    vector<pair<int,int>> a(N);
    rep(i,N) {
        cin >> a[i].first;
        a[i].second = 1;
    }
    rep(i,M) {
        int b,c;
        cin >> b >> c;
        a.push_back({c,b});
    }
    sort(rbegin(a), rend(a));
    ll n = N;
    rep(i,N) {
        if (n <= 0)
            break;
        ll m = min<ll>(n, a[i].second);
        ans += a[i].first * m;
        n -= m;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5776
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <time.h>
#include <unistd.h>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    if (time(NULL) & 1) sleep(3);
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) cout << "No" << endl;
  else if(s[0] == s[1] && s[2] == s[3]) cout << "Yes" << endl;
  else if (s[0] == s[2] && s[1] == s[3]) cout << "Yes" << endl;
  else if (s[0] == s[3] && s[1] == s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3584
def mapAccumL(f, acc, x):
  ret = []
  for xx in x:
    tmp = f(acc, xx)
    ret.append(tmp[1])
    acc = tmp[0]
  return (acc, ret)

def calc(s, x):
  n = s / x
  return (s - n * x, n)

while True:
  n = input()

  if not n:
    break

  print sum(mapAccumL(calc, 1000 - n,
                      [500, 100, 50, 10, 5, 1])[1])

Measured memory_bytes: 4236
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var stdin = bufio.NewScanner(os.Stdin)

func nextInt() int64 {
	stdin.Scan()
	i, _ := strconv.ParseInt(stdin.Text(), 10, 64)

	return i
}

type pair struct {
	value int64 // 値
	num   int64 // 枚数
}
type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Less(i, j int) bool {
	return p[i].value < p[j].value
}
func (p pairs) Swap(i, j int) {
	s := p[i]
	p[i] = p[j]
	p[j] = s
}

func main() {
	stdin.Split(bufio.ScanWords)

	var i int64

	// 1行目
	n := nextInt()
	m := nextInt()

	cards := pairs{}

	// 2行目
	// カード登録
	for i := int64(0); i < n; i++ {
		a := nextInt()
		cards = append(cards, pair{a, 1})
	}

	// 操作をm回
	for i = 0; i < m; i++ {
		// fmt.Println(cards)
		b := nextInt()
		c := nextInt()

		cards = append(cards, pair{c, b})
	}

	sort.Sort(cards)
	var sum int64
	var c int64
	for i := n + m - 1; i > 0; i-- {
		p := cards[i]

		if c+p.num >= n {
			sum += p.value * int64(n-c)
			break
		} else {
			sum += p.value * int64(p.num)
			c += p.num
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 13076
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll h, w, s[60][60];


int main(){
	cin >> h >> w;
	
	for(ll i = 0; i <= h+1; i++){
		for(ll j = 0; j <= w+1; j++){
			s[i][j] = 0;
		}
	}
	
	for(ll i = 1; i <= h; i++){
		for(ll j = 1; j <= w; j++){
			char buf;
			cin >> buf;
			s[i][j] = (buf == '.')? 0 : 1;
		}
	}
	string ans = "Yes";
	for(ll i = 1; i <= h; i++){
		for(ll j = 1; j <= w; j++){
			if(s[i][j] == 1 && s[i-1][j]+s[i+1][j]+s[i][j-1]+s[i][j+1] == 0){
				ans = "No"; break;
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll h, w;

	cin >> h >> w;

	vector<string> v(h);

	REP(i, h) {
		cin >> v[i];
	}

	bool flag;
	vector<string> vv;

	REP(i, h) {
		flag = false;

		REP(j, w) {
			if (v[i][j] != '.') {
				flag = true;
				break;
			}
		}

		if (flag) {
			vv.push_back(v[i]);
		}
	}

	vector<vector<char>> ans(vv.size());

	REP(i, w) {
		flag = false;

		REP(j, vv.size()) {
			if (vv[j][i] != '.') {
				flag = true;
				break;
			}
		}

		if (flag) {
			REP(j, vv.size()) {
				ans[j].push_back(vv[j][i]);
			}
		}
	}

	REP(i, ans.size()) {
		REP(j, ans[i].size()) {
			cout << ans[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

string s;

int main(){
	cin>>s;
	if(s=="zyxwvutsrqponmlkjihgfedcba") cout<<-1<<endl;
	else{
		if(s.size()==26){
			vi a(26,1);
			int t=25;
			while(s[t-1]>s[t]) t--;
			t--;
			string s_;
			for(int i=0;i<t;i++) s_+=s[i];
			char c='z';
			for(int i=t+1;i<26;i++) if(s[i]>s[t]) c=min(c,s[i]);
			cout<<s_+c<<endl;
		}
		else{
			vi a(26);
			for(int i=0;i<s.size();i++) a[s[i]-'a']++;
			for(int i=0;i<26;i++) if(!a[i]){
				s+=(char)(i+'a');
				break;
			}
			cout<<s<<endl;
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = b - a;
		int bhight = c*(c + 1)/2;
		System.out.println(bhight - b);
	}
}

Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  string s;
  int nq;
  cin >> s >> nq;
  string l = "", r = "";
  bool flg = 0;
  rep(i, nq) {
    int t;
    cin >> t;
    if(t == 1) flg ^= 1;
    if(t == 2) {
      int f;
      char c;
      cin >> f >> c;

      if(flg ^ (f % 2))
        l = c + l;
      else
        r = r + c;
    }
  }
  s = l + s;
  s = s + r;
  if(flg) reverse(all(s));
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 1392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
    int n;
    cin>>n;
    vector<double>p(n);
    for(int i=0;i<n;i++) cin>>p[i];
    double dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1.0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(j==0&&i!=0)
            dp[i][j] = (1-p[i-1])*dp[i-1][j];
            else
            dp[i][j] = p[i-1]*dp[i-1][j-1]+(1-p[i-1])*(dp[i-1][j]);
        }
    }
    double sum=0.0;
    for(int j=n/2+1;j<=n;j++)
    sum+=dp[n][j];
    printf("%0.9lf",sum);
}
int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 70528
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X;
    cin >> N >> X;
    if (N == 2*X) {
        cout << 3*X << endl;
        return 0;
    }
    ll a = X, b = N-X;
    if (a < b) swap(a, b);
    ll ans = N;
    while (b) {
        ll k = a/b;
        ans += (2*k)*b;
        ll c = a%b;
        a = b, b = c;
    }
    ans -= a;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//thuat toan disjoint set-union
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <string.h>
#include <algorithm>

using namespace std;
#define maxN 100000

struct edge
{
    int u, v, cost;
    edge(int a, int b, int c)
    {
        u = a, v = b, cost = c;
    }
};

vector<edge> e;
int n, m, parent[maxN] = {0}, h[maxN] = {0};
/*
- parent[u] > 0: parent[u] la cha truc tiep cua u
- parent[u] <= 0: u la goc
- parent[u] < 0: -parent[u] la chieu cao cua cay goc u
*/

bool operator < (edge a, edge b)
{
    return (a.cost < b.cost);
}

void ReadGraph()
{
    int u, v, c;
    cin>>n>>m;
    for (int i = 0; i < m; ++i)
    {
        cin>>u>>v>>c;
        e.push_back(edge(u, v, c));
    }
}

int FindRoot(int u)
{
    if (parent[u] == u)
        return u;
    return parent[u] = FindRoot(parent[u]);
}

void Union(int ru, int rv)
{
    if (h[ru] < h[rv])
        parent[ru] = rv;
    else
    {
        h[ru] = max(h[ru], h[rv]+1);
        parent[rv] = ru;
    }
}


void Solve()
{
    ReadGraph();
    sort(e.begin(), e.end());
    int ans = 0;
    for (int u = 0; u < n; ++u) parent[u] = u;

    for (int i = 0; i < e.size(); ++i)
    {
        int ru = FindRoot(e[i].u);
        int rv = FindRoot(e[i].v);
        if (ru != rv)
        {
            ans += e[i].cost;
            Union(ru, rv);
        }
    }
    cout<<ans<<"\n";
}

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

Measured memory_bytes: 4536
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int m=0;
    int ans=0;
    int cnt=0;
    while(m<n-1){
        if(s[m]!=s[m+1]){
            ans++;
            m+=2;
        }else{
            m++;
        }
    }
    m=n-1;
    while(m>0){
        if(s[m]!=s[m-1]){
            cnt++;
            m-=2;
        }else{
            m--;
        }
    }
    cout<<max(cnt,ans)<<endl;
}


Measured memory_bytes: 3304
/* 
 * Project: AtCoder Beginners Contest 175 A - Rainy Season
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/29
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
using namespace std;

int main() {

    int_fast8_t c;
    uint_fast32_t cnt = 0;
    uint_fast32_t max_cnt = 0;
    for (int i=0;i<3;i++) {
        scanf("%c", &c);
        if (c == 'R') {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt > max_cnt)
            max_cnt = cnt;
    }
    printf("%lu\n", max_cnt);

}

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

	cin >> n >>x >> y;

	vector<int>a(n+1);
	int b;
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			b=min(j-i,min(abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x)));
			a[b]++;
		}
	}
	for(int i=1;i<n;i++){
		cout << a[i] <<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

void solve(){
	string s, t;
	cin>>s>>t;
	sort(all(s));
	sort(all(t));
	reverse(all(t));
	if(t>s) cout<<"Yes"<<endl;
	else cout <<"No"<<endl;
}
	
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
  t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define MOD 1000000007
#define INF 1e18
#define EPS 1e-15
#define int long long
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define loop1(i, n) for(int i=1;i<=(int)n;++i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef pair<int, int> pll;
typedef vector<int> vll;
typedef vector<pll> vpll;	
typedef long double db;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define N 100005

//

int32_t main() {
	FAST_IO;
	
	int n, d;
	cin >> n >> d;
	int ans = 0;
	for (int i = 1 + d; ; i += 2*d + 1) {
		ans++;
		if (i >= n - d) break;
	}
	cout << ans;
	rtn 0;
}


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

int main() {
  string s;
  	cin>>s;
  int S=s.size();
  
  for(int i=0;i<S;i++){
    if(i%2==0)
	cout<<s.at(i);
  }
  cout<<""<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;


int main() {

	ll n;
	cin >> n;
	vector<int> am;

	while (n > 0) {

		am.push_back(n % 26);
		if (n % 26 == 0)n--;
		n /= 26;
		

	}
	
	int s = am.size();

	for (int i = s - 1; i > -1;i--) {
		char a = am[i] + 96;
		if (am[i] == 0)a = 'z';
		cout << a;
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BAlgae solver = new BAlgae();
        solver.solve(1, in, out);
        out.close();
    }

    static class BAlgae {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int r = in.nextInt();
            int d = in.nextInt();
            int temp = in.nextInt();
            for (int i = 1; i <= 10; i++) {
                temp = r * temp - d;
                out.println(temp);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 21460
until(s=gets.gsub(/\d+/){|k|?1*k.hex})[?#]
n=1+s.index(?/)
eval"s[n*c-n+e-1]=?1;s[n*g-n+i-1]=?bdfh".tr('c-i',gets)
$><<s.gsub(/1+/,&:size)
end

Measured memory_bytes: 8768
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int N;
    cin >> N;
    int A[100001];
    int odd = 0;
    int even = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] % 2 == 1) odd++;
        else even++; 
    }
    if(odd%2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

int p=(int)1e9+7;

int main() {
	int N;
    cin >> N;
    vector<int> A(N);
    map<int,int> m;
    for(int i=0; i<N; i++){
        cin >> A[i];
        m[A[i]]++;
    }
    bool flag=true;
    for(auto itr=m.begin(); itr!=m.end(); itr++){
        if(N%2==0){
            if(itr->second != 2) flag=false;
        }
        else {
            if(itr->first!=0 && itr->second!=2) flag=false;
            else if(itr->first==0 && itr->second!=1) flag=false;
        }
    }
    if(!flag) cout << 0 << endl;
    else {
        int ans=1;
        for(int i=0; i<N/2; i++){
            ans *= 2; ans%=p;
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
#define pi 2*acos(0.0)
const int INF = 1e7;
const int mod = 1e9 + 7;
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
 
ll nCr(ll n, ll k){ 
   ll C[n + 1][k + 1]; 
   
   REP(i,0,n+1){ 
      REP(j,0,min(i,k)+1) {
         if(j==0 || j==i) {
            C[i][j] = 1;  
         } else {
            C[i][j] = C[i-1][j-1] + C[i-1][j]; 
         }
      } 
   }
   return C[n][k]; 
}

int main(){
   faster;
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   
   int n;
   cin >> n;

   if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9) p1("hon");
   else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) p1("pon");
   else p1("bon");
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i=0; i<n; i++) {
    cin >> p.at(i);
  }
  int count=0;
  for (int i=1; i<n-1; i++) {
    if ((p.at(i-1)<p.at(i)&&p.at(i)<p.at(i+1))||(p.at(i-1)>p.at(i)&&p.at(i)>p.at(i+1))) {
      count++;
    }
  }
  cout << count <<endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        
        if (X < A) {
            System.out.println(0);
        }else{
            System.out.println(10);
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >>a[i];
    }
    double b[n];
    double sum=0;
    for(int i=0; i<n; i++){
        b[i]=1.0/a[i];
        sum+=b[i];
    }

    double ans=1/sum;
    cout << fixed << setprecision(6) << ans <<  endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <climits>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <deque>
#include <map>
using namespace std;

typedef long long ll;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define forn(i,n) for(int i=0; i<int(n); i++)
#define for1(i,n) for(int i=1; i<=int(n); i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

void no(int ex = -1) {
	cout << ex << endl;
	//cout << "NO" << endl;
	//exit(0);
}
void bl(bool win) {
	if (win) cout << "YES"; else cout << "NO";
	cout << endl;
}

const int N = 1000000;
const ll INF = LLONG_MAX;
const int mod = 998244353;

/*vector<bool> pr;
void prime() {
	int EDGE = 1000;
	pr.assign(EDGE, true);
	pr[0] = false; pr[1] = false;
	for (int i = 2; i < EDGE; i++) {
		if (pr[i])
			if (1LL * i * i < EDGE)
				for (int j = i * i; j < EDGE; j += i)
					pr[j] = false;
	}
}*/
//prime


ll T;

int main() {
	IOS;
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	int n, k;
	cin >> n >> k;
	vector<bool> us(n, false);
	forn(i, k) {
		int x;
		cin >> x;
		forn(j, x) {
			int w;
			cin >> w;
			us[w - 1] = true;
		}
	}
	int cnt = 0;
	forn(i, n) {
		if (us[i] == false) cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 3152
import numpy as np
n = int(input())
xy = []
def kaijou(n):
    if n > 1:
        return n*(kaijou(n-1))
    else:
        return 1
for i in range(n):
    tmp = list(map(int,input().split()))
    xy.append(tmp)
ans = 0
num = 0
for i in range(len(xy)):
    for j in range(i+1,len(xy)):
        ans += np.sqrt((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)
        
print(ans*kaijou(n-1)*2/kaijou(n))

Measured memory_bytes: 12496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*
総和に変わりはない. そのため、操作後のAを割り切る値の候補は総和の約数.
約数を大きいものから順に走査.
*/

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

void solve(){
  ll n,k;
  cin >> n >> k;
  ll a[n+10];
  ll sum=0;
  rep(i,n){
    cin >> a[i];
    sum += a[i];
  }
  vector<ll> v = divisor(sum);
  reverse(v.begin(),v.end());
  for(ll d:v){
    ll r[n+10];
    rep(i,n){
      r[i] = a[i]%d;
    }
    sort(r,r+n);
    ll sum1 = 0;
    rep(i,n){
      sum1 += d-r[i];
    }
    ll sum2=0;

    if(max(sum1,sum2)<=k) {
      cout << d << endl;
      break;
    }

    bool br=false;
    for(ll i=0; i<n; i++){
      sum1 = sum1 - (d-r[i]);
      sum2 = sum2 + r[i];
      if(max(sum1,sum2)<=k) {
      cout << d << endl;
      br = true;
      break;
      }
    }

    if(br) break;

  }

}

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

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << "\n";
#else
#define DEBUG(message)
#endif

struct Solver {
  bool check(int x) {
    ll s = 0;
    for (int i = 0; i <= x; i++) {
      s += a[i];
    }
    for (int j = x + 1; j < n; j++) {
      if (2 * s < a[j]) {
        return false;
      }
      s += a[j];
    }
    return true;
  }

  void solve() {
    cin >> n;

    a.resize(n);

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

    sort(a.begin(), a.end());

    int l = -1, r = n;
    while (r > l + 1) {
      auto m = (l + r) / 2;
      if (check(m)) {
        r = m;
      } else {
        l = m;
      }
    }

    cout << n - r << "\n";
  }

  int n;
  vector<int> a;
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
//  cin >> t;
  for (int i = 1; i <= t; i++) {
    Solver().solve();
  }
  return 0;
}

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

int main(){
	double a;
	while( scanf(" %lf", &a) != EOF ){
		double sum=a;
		for(int i=0; i<9; ++i){
			if(i%2==0){
				a*=2.0;
				sum+=a;
			}
			else{
				a/=3.0;
				sum+=a;
			}
			
			//printf("now:%.8lf\n", a);
		}
		
		printf("%.8lf\n", sum);
	}

	return 0;
}

Measured memory_bytes: 1236
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def dijkstra(edge,st):
    # edge=[[(v_to,dist_to_v),...],[],...]
    # initialize: def: d=dist(st,i), prev=[previous vertex in minimum path], q[]
    n=len(edge)
    d=[(0 if st==i else inf,i) for i in range(n)]
    prev=[0]*n
    q=[i for i in d]
    heapify(q)
    
    # calc
    while q:
        dist,cur=heappop(q)
        for dst,dist in edge[cur]:
            alt=d[cur][0]+dist
            if alt<d[dst][0]:
                d[dst]=(alt,dst)
                prev[dst]=cur
                heappush(q,(alt,dst))
    return d,prev
    
show_flg=False
show_flg=True

ans=0
n,m=LI()
g,ip=GI(n,m)
mins=[]
for i in range(n):
    d,p=dijkstra(g,i)
    mins.append([i for i,j in d])

for a,b,c in ip:
    k=1
    for y in range(n):
        if y==b:
            continue
        if mins[y][a]+c==mins[y][b]:
            k=0
    ans+=k

print(ans)


Measured memory_bytes: 66648
#include <iostream>

using namespace std;

bool prime(int v)
{
  if(v == 2){
    return true;
  } else if(v % 2 == 0){
    return false;
  }

  for(int j = 3; j*j <= v; j+=2){
    if(v%j == 0){
      return false;
    }
  }

  return true;
}

int main()
{
  int a, d, n, p;

  while(1){
    cin >> a >> d >> n;
    if(a == 0 && d == 0 && n == 0){
      break;
    }

    while(n > 0){
      if(prime(a) && a != 1){
	n--;
	p = a;
      }
      a += d;
    }
    cout << p << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int k,t;
  cin >> k >> t;
  int a[t];
  rep(i,t)cin >> a[i];
  sort(a,a+t,greater<int>());
  int sum=0;
  rep(i,t)sum+=a[i];
  cout << max(0,2*a[0]-1-sum) << endl;
return 0;}

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

int main() {

  while( true ) {

    long long int n, l;
    cin >> n >> l;
    if ( n == 0 ) break;

    vector< pair< long long int, long long int > > v;

    for ( long long int i = 0; i < n; i++ ) {

      char c;
      long long int in;
      cin >> c >> in;

      if ( c == 'R' ) {
	v.push_back( make_pair( in, 1 ) );
      }else {
	  v.push_back( make_pair( in, -1 ) );
      }

    }

    long long int ans = 0;
    long long int cnt;

    for ( long long int j = 0; j <= 100; j++ ) {

      long long int t[101] = {};

      for ( long long int i = 0; i < n; i++ ) {
	if ( v[i].second != 0 ) {
	  v[i].first += v[i].second;
	  if ( v[i].first == 0 || v[i].first == l ) {
	    v[i].second = 0;
	    if ( v[i].first == 0 ) {
	      if ( ans <= j + 1 ) {
		ans = j + 1;
		cnt = i + 1;
	      }
	    }else {
	      if ( ans < j + 1 ) {
		ans = j + 1;
		cnt = i + 1;
	      }
	    }
	  }else if ( t[ v[i].first ] != 0 ) {
	    v[i].second *= -1;
	    v[ t[ v[i].first ] - 1 ].second *= -1;
	  }else {
	    t[ v[i].first ] = i + 1;
	  }
	}
      }

    }

    cout << ans << " " << cnt << endl;

  }

  return 0;

}

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

int main() {
	int h, n;
	cin >> h >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	int sum = 0;
	rep(i, n) sum += a[i];
	if (h - sum <= 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  ret.pop_back();
  return (ret);
}

int main() {
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  sort(ALL(a));
  int ans=a.size();
  for(auto x:a){
    int num=upper_bound(ALL(a),x)-lower_bound(ALL(a),x);
    if(num>1){ans--;continue;}
    vector<int> ret=divisor(x);
    for(auto y:ret)if(binary_search(ALL(a),y)){ans--;break;}
  }
  cout<<ans;
}

Measured memory_bytes: 4016
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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




void oneCase () {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << "\n";
}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int N, M;
    cin >> N >> M;

    vector<int> height(N);
    for (int i = 0; i < N; i++)
    {
        cin >> height[i];
    }

    vector<bool> isChecked(N, false);
    vector<bool> isGood(N, true);

    vector<int> A(M);
    vector<int> B(M);
    for (int i = 0; i < M; i++)
    {
        cin >> A[i] >> B[i];
        isChecked[A[i] - 1] = true;
        isChecked[B[i] - 1] = true;
    }

    for (int i = 0; i < M; i++)
    {
        if (height[A[i] - 1] < height[B[i] - 1])
        {
            isGood[A[i] - 1] = false;
        }
        if (height[A[i] - 1] > height[B[i] - 1])
        {
            isGood[B[i] - 1] = false;
        }
        if (height[A[i] - 1] == height[B[i] - 1])
        {
            isGood[A[i] - 1] = false;
            isGood[B[i] - 1] = false;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if ((isChecked[i] == false && isGood[i] == true) ||
            (isChecked[i] == true && isGood[i] == true))
        {
            ans++;
        }
    }

    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 4576
#include <stdio.h>
#include <stdbool.h>

#define MAX_VERTEX_NUM 100

typedef struct {
    char linked_num;
    char linked[MAX_VERTEX_NUM-1];
} vertex;

vertex vertex_list[MAX_VERTEX_NUM];
bool has_arrived[MAX_VERTEX_NUM];
char count_max;
int n;

void vertex_init() {
    int i;
    for (i=0;i < MAX_VERTEX_NUM;i++) {
        vertex_list[i].linked_num = 0;
    }

    return ;
}

void link(int id1, int id2) {
    vertex *obj1 = &vertex_list[id1];
    vertex *obj2 = &vertex_list[id2];

    int num1 = obj1->linked_num;
    int num2 = obj2->linked_num;
    obj1->linked[num1] = id2;
    obj2->linked[num2] = id1;

    obj1->linked_num += 1;
    obj2->linked_num += 1;

    return ;
}

void rec(int id, int now_count) {
    int i;

    if (has_arrived[id]) return ;

    has_arrived[id] = 1;

    if (count_max < now_count+1) {
        count_max = now_count+1;
    }

    for (i=0;i < vertex_list[id].linked_num;i++) {
        rec(vertex_list[id].linked[i], now_count + 1);
    }

    has_arrived[id] = 0;

    return ;
}

int main() {
    while (1) {
        int i;
        scanf("%d", &n);
        if (n == 0) return 0;

        vertex_init();

        for (i=0;i<n;i++) {
            int id1, id2;
            scanf("%d %d", &id1, &id2);
            link(id1-1, id2-1);
        }

        count_max = 0;

        for (i=0;i<100;i++) {
            rec(i, 0);
        }

        printf("%d\n", count_max);
    }
}

Measured memory_bytes: 1036
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <stack>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

typedef long long ll;
typedef long double ld;

int n;
int KIHON = 1150;
int PLAN2 = 125;
int PLAN3 = 140;
int PLAN4 = 160;
int sen, kon;

int main() {
  sen = 4280;
  while(cin >> n) {
    if(n < 0) break;
    n -= 10;
    kon = KIHON;
    if(n > 0) {
      if(n - 10 >= 0) {
        kon += PLAN2 * 10;
      } else {
        kon += PLAN2 * n;
      }
      n -= 10;
    }
    if(n > 0) {
      if(n - 10 >= 0) {
        kon += PLAN3 * 10;
      } else {
        kon += PLAN3 * n;
      }
      n -= 10;
    }
    if(n > 0) {
      kon += PLAN4 * n;
    }

    cout << sen - kon << endl;
  }
  
  return 0;
}

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

int main(){
    ll int n,k;
    cin>>n>>k;
    while(2*n>k){
        if(n>k) n=n%k;
        else    n=k%n;
    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
int main(){
  int q;
  std::cin>>q;
  int i,j,k;
  std::string x,y;
  int a[1001][1001];
  int knum[q];
  for(i=0; i<1001; i++){
    for(j=0; j<1001; j++){
      a[i][j]=0;
    }
  }
  for(k=0; k<q; k++){
    std::cin>>x;
    std::cin>>y;
    for(i=1; i<x.size()+1; i++){
      for(j=1; j<y.size()+1; j++){
	if(x[i-1]==y[j-1]){
	  a[i][j]=a[i-1][j-1]+1;
	}else{
	  if(a[i-1][j]>a[i][j-1]){
	    a[i][j]=a[i-1][j];
	  }else{
	    a[i][j]=a[i][j-1];
	  }
	}
      }	
    }
    knum[k]=a[x.size()][y.size()];
  }
  for(k=0; k<q; k++){
    std::cout<<knum[k]<<"\n";
  }
  return 0;
}


Measured memory_bytes: 7076
h, w, d = gets.chomp.split(" ").map(&:to_i)
colors = [['R', 'Y'], ['G', 'B']]
mat = Array.new(h){Array.new(w)}
h.times do |i|
  w.times do |j|
    x = i + j
    y = i - j
    xx = (x / d) % 2
    yy = (y / d) % 2
    mat[i][j] = colors[xx][yy]
  end
end
mat.each do |row|
  puts row.join("")
end

Measured memory_bytes: 4220
def function(n, k, h)
	sorted = h.sort
	return 0 if k >= n

	result = 0
	(0...(n - k)).each do |i|
		result += sorted[i]
	end
	result
end

n, k = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)
puts function(n, k, h)


Measured memory_bytes: 21360
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,K;

int extgcd(int a,int b,int &x,int &y){
	int g=a;
	x=1,y=0;
	if(b!=0){
		g=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	return g;
}
 
// 逆元
int mod_inverse(int a,int m){
	int x, y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}
 
// 階乗
std::vector<int>fact;
void mod_fact(int n, int m){
	fact.resize(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%m;
	}
}
 
// nCk mod p
int mod_nCr(int n, int k, int m){
	if(n<k)return 0;
	return fact[n]*mod_inverse(fact[k]*fact[n-k]%m,m)%m;
}

signed main(){
	cin>>N>>K;
	mod_fact(200010,MOD);
	int ans=0;
	for(int i=0;i<=min(N-1,K);i++){
		int R=1;
		R*=mod_nCr(N,i,MOD);
		R*=mod_nCr(N-1,N-i-1,MOD);
		R%=MOD;
		ans+=R;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


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

int     main() {
        vector<int> A(3);
        for (int i=0; i<3; i++)
                cin >>A.at(i);
        sort(A.begin(), A.end());
        int D1=A.at(2)-A.at(1);
        int D2=A.at(2)-A.at(0);
        int S=D1/2 + D2/2;
        int D=D1%2 + D2%2;
        if (0!=D)
                S += 3-D;
        cout <<S <<endl;
        return 0;
};

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

int n;
vector<int> w;
vector<vector<int>> dp;

int solve(int l, int r){
    if((r-l) <= 1) return 0;
    if((r-l) == 2){
        if(abs(w[l] - w[l+1]) <= 1) return 2;
        else return 0;
    }
    if(dp[l][r] != -1) return dp[l][r];

    if(abs(w[l] - w[r-1]) <= 1 && solve(l+1, r-1) == r-l-2) dp[l][r] = max(dp[l][r], r-l);
    for(int i = l+1; i < r; ++i) dp[l][r] = max(dp[l][r], solve(l, i)+solve(i, r));

    return dp[l][r];
}

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

    while(1){
        cin >> n;
        if(n == 0) break;

        w.resize(n);
        rep(i, n) cin >> w[i];

        dp.assign(n+2, vector<int>(n+2, -1));

        cout << solve(0, n) << endl;
    }

    return 0;
}


Measured memory_bytes: 3384
q=[]
for i in range(1,10):
    q.append(i)
n=int(input())
ans=0
for i in range(n):
    size=len(q)
    a=q[size-(size-i)]
    if a%10!=0:
        q.append(10*a+a%10-1)
    q.append(10*a+a%10)
    if  a%10!=9:
        q.append(10*a+a%10+1)
print(q[n-1])

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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 YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int main(){
    int n;
    cin>>n;
    vi a(n);
    REP(i,n){
        cin>>a[i];
    }
    int mi=INF;
    REP(i,-100,101){
        int cost=0;
        REP(j,n){
            cost+=(a[j]-i)*(a[j]-i);
        }
        chmin(mi,cost);
    }
    cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 256