akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Miguel Mini
 */

#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define trav(v, x) for (auto v : x)
#define re(x, y, z) for (int x=y; x<z; ++x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

class C {
public:
    int testNumber = 0;
	void solve(istream& in, ostream& out) {
	    //out << "Case #" << ++testNumber << ": ";
        int k;
        in >> k;
        long long ans = 0;
        for (int i = 1; i <= k; ++i) {
            for (int j = 1; j <= k; ++j) {
                for (int l = 1; l <= k; ++l) {
                    ans += __gcd(l, __gcd(i, j));
                }
            }
        }
        out << ans << endl;
	}
};

int main() {
	C solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define UI(n) ui n;assert(0<scanf("%u",&n))
#define VUI(v,n) vector<ui> v(n);REP(i,n){assert(0<scanf("%u",&v[i]));}
#define MSET(arr,val)  memset(arr,val,sizeof(arr))

int main(){
  const ui INF = 1 << 30;
  UI(n); UI(m); UI(r);
  VUI(rs, r);
  ui dis[201][201]; MSET(dis, 0);
  REP(i, 1, n + 1){
    REP(j, 1, n + 1){
      if (i != j){
        dis[i][j] = INF;
      }
    }
  }
  REP(m){
    UI(a); UI(b); UI(c);
    dis[a][b] = min(dis[a][b], c);
    dis[b][a] = min(dis[b][a], c);
  }
  REP(i, 1, n + 1){
    REP(j, 1, n + 1){
      REP(k, 1, n + 1){
        dis[j][k] = min(dis[j][k], dis[j][i] + dis[i][k]);
        dis[k][j] = min(dis[k][j], dis[k][i] + dis[i][j]);
      }
    }
  }
  ui ans = INF, tmp = 0;
  vector<ui> p = rs; sort(p.begin(), p.end());
  do {
    tmp = 0;
    REP(i, r - 1){
      tmp += dis[p[i]][p[i + 1]];
    }
    ans = min(ans, tmp);
  } while(next_permutation(p.begin(), p.end()));
  printf("%u\n", ans);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rint register int
#define gc() getchar()
inline int read(){int r=0,s=0,c=gc();for(;!isdigit(c);s=c,c=gc());for(;isdigit(c);(r*=10)+=c-48,c=gc());return s^45?r:-r;}
int f[16][32768], g[32768], w[16][16], n, E;
int main()
{
	n = read(), E = 1<<n; for(rint m = read(), a, b; m--; a = read()-1, b = read()-1, w[a][b] = w[b][a] = read()); for(rint i = 0; i < n; memset(f[i++],-1,E<<2));
	for(rint S = 1, T, i, j; S < E; S++) for(g[S] = g[T=S-(S&-S)], i = ilogb(S&-S), j = 0; j < n; j++) if(T&1<<j) g[S] += w[i][j]; f[0][1] = 0;
	for(rint S = 1, U = ~-E^1, T, i, j; S < E; S++, U = ~-E^S) for(i = 0; i < n; i++) if(f[i][S]>=0)
		{for(j = 0; j < n; w[i][j]&&U&1<<j?f[j][S|1<<j]=max(f[j][S|1<<j],f[i][S]+w[i][j]):0, j++); for(T = U; T; f[i][S|T] = max(f[i][S|T],f[i][S]+g[T|1<<i]), --T&=U);} printf("%d\n",g[~-E]-f[~-n][~-E]); return 0;
}

Measured memory_bytes: 2304
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val k = cin.nextInt()
    val s = cin.next()
    val s2 = s.toLowerCase()
    
    for (i in 0..n-1) {
        if (i == k-1) {
            print(s2[i])
        } else if (i == n-1) {
            println(s[i])
        } else {
            print(s[i])
        }
    }
}

Measured memory_bytes: 31268
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int human_number;
    int __report[2560000],__sums[2560000]={0};
    
    cin >> human_number;
    
    for(int index=1;index < human_number;index++){
        cin >> __report[index];
        __sums[__report[index]]++;
        
    }
    
    for(int index =1;index <=human_number;index++){
        cout << __sums[index] << endl;
    }
    
}

Measured memory_bytes: 14380
#include<stdio.h>

 int main(void){
 
 int x = 0,i;
 
 while(1){
   scanf("%d",&i);
   
   if(i==0){
     break;
   }else{
     printf("Case %d: %d\n",x+1,i);
     x++;
   }
 }
 return 0;
}


Measured memory_bytes: 1980
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

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

	if (n%2==0)
	{
		cout<<n/2;
	} else {
		cout<<(n/2)+1;
	}
	
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    char a[106],b[106];
    scanf("%s",a);
    scanf("%s",b);
    rep(i,strlen(a)){
        a[strlen(a)]=a[0];
        rep(j,strlen(a)){
            a[j]=a[j+1];
        }
        a[strlen(a)]=0;
        if(strcmp(a,b)==0){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
}


Measured memory_bytes: 1732
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h, w = MAP()
a = [LIST() for _ in range(h)]
ans = []
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a[i][j] % 2 == 1:
                y = i
                x = j + 1
                if x >= w:
                    y += 1
                    x = w - 1
                if y < h:
                    a[y][x] += 1
                    ans.append([str(i + 1), str(j + 1), str(y + 1), str(x + 1)])
    else:
        for j in reversed(range(w)):
            if a[i][j] % 2 == 1:
                y = i
                x = j - 1
                if x < 0:
                    y += 1
                    x = 0
                if y < h:
                    a[y][x] += 1
                    ans.append([str(i + 1), str(j + 1), str(y + 1), str(x + 1)])
print(len(ans))
for i in range(len(ans)):
    print(' '.join(ans[i]))

Measured memory_bytes: 105948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

template<int char_size,int margin>
class Trie{
private:
    struct Node{
        int ne[char_size];
        int num;
        vec<int> accept;
        Node():num(0){
            memset(ne,-1,sizeof(ne));
        }
    };

    vec<Node> nodes;
    int root;
public:
    Trie():root(0){
        nodes.push_back(Node());
    }

    void update_direct(int node,int id){
        nodes[node].accept.push_back(id);
        nodes[node].num++;
    }

    void add(const string& S,int s_id,int node_id,int id){
        if(s_id==S.size()) update_direct(node_id,id);
        else{
            int c = S[s_id]-margin;
            if(nodes[node_id].ne[c]==-1){
                nodes[node_id].ne[c] = (int) nodes.size();
                nodes.push_back(Node());
            }
            add(S,s_id+1,nodes[node_id].ne[c],id);
        }
    }

    void add(const string& S,int id){
        add(S,0,0,id);
    }

    void add(const string &S){
        add(S,nodes[0].num);
    }

    template<class F>
    void query(const string& S,F& f,int s_id,int node_id){
        for(auto& id:nodes[node_id].accept) f(id);
        if(s_id==S.size()) return ;
        else{
            int c = S[s_id]-margin;
            if(nodes[node_id].ne[c]==-1) return ;
            query(S,f,s_id+1,nodes[node_id].ne[c]);
        }
    }

    void dfs(const string& S,int s_id,int node_id,set<char>& st,ll& ans){
        if(node_id==-1) return ;
        if(s_id==S.size()){
            ans += nodes[node_id].num;
            return ;
        }
        int nc = S[s_id]-margin;
        dfs(S,s_id+1,nodes[node_id].ne[nc],st,ans);
        st.insert(S[s_id]);
        for(auto& c:st){
            int id = nodes[node_id].ne[c-margin];
            if(id!=-1) nodes[id].num++;
        }
    }

    template<class F>
    void query(const string& S,F& f){
        query(S,f,0,0);
    }

    int count()const{
        return nodes[0].num;
    }

    int size()const{
        return (int) nodes.size();
    }

};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<string> S(N);
    Trie<26,'a'> trie;
    for(auto& s:S){
        cin >> s;
        reverse(s.begin(),s.end());
        trie.add(s);
    }
    ll ans = 0;
    sort(S.begin(),S.end(),[](string& s,string& t){return s.size()>t.size();});
    for(auto& s:S){
        set<char> st;
        trie.dfs(s,0,0,st,ans);
    }
    cout << ans-N << "\n";
}

Measured memory_bytes: 348796
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {

  trait Monoid[A]{
    def op(a1: A, a2: A): A
    def zero: A
  }

  type Per = List[Int]
  type Rot = Dice => Dice

  object DiceRoll extends Monoid[Rot]{

    def op(rot1: Rot, rot2: Rot): Rot = (dice: Dice) => rot2(rot1(dice))
    def zero: Rot = (dice: Dice)=>dice

    val north = List(2,6,3,4,1,5).map(_ - 1)
    val east = List(4,2,1,6,5,3).map(_ - 1)
    val ccw = List(1,4,2,5,3,6).map(_ - 1)

    def rot(perm: Per): Rot = (dice: Dice) => Dice(perm.map(dice.pip))

    def axial(f: Rot): List[Rot] = List(zero,f,op(f,f),op(op(f,f),f))

    def enumerateTop(f: Rot = zero, n: Int = 6): List[Rot] = {
      if(n<=0)List[Rot]()
      else if(n%2==0) f :: enumerateTop(op(f,rot(north)),n-1)
      else f :: enumerateTop(op(f,rot(east)),n-1)
    }

    def enumerate: List[Rot] = enumerateTop().flatMap( e => axial(rot(ccw)).map(op(e,_)))
  }

  case class Dice(pip: List[Int]){
    lazy val all: List[Dice] = DiceRoll.enumerate.map(_(Dice(pip)))
    def ===(that: Dice): Boolean = pip.corresponds(that.pip)(_ == _)
    def ==(that: Dice): Boolean = all.exists(_ === that)
  }

  def main(args: Array[String]): Unit = {
    val Array(n,_*) = readLine.split(" ").map(_.toInt)
    val dices = for(i <- 1 to n) yield Dice(readLine.split(" ").map(_.toInt).toList)

    val res = for{
      i <- 0 until n
      j <- 0 until n
      if i<j
    } yield dices(i) == dices(j)
    
    println( if(res.fold(false)(_ | _)) "No" else "Yes")
  }
}

Measured memory_bytes: 48948
#include <iostream>
using namespace std;
     
const long long MAX = 1e18;
     
int main(){
    int N;
    long long A[100010];
    long long ans = 1;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
     
    for (int i = 0; i < N; i++) {
        if (A[i] > MAX / ans) {
            ans = -1;
            break;
        }
        else ans *= A[i];
    }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vector<tuple<int,int>> up, flat, down;
  REP(i,n) {
    string s;
    cin>>s;
    int sum = 0;
    int mn = 0;
    for (auto&& c:s) {
      if (c == '(') {
        ++sum;
      } else {
        --sum;
        mn = min(mn, sum);
      }
    }
    if (sum > 0) {
      up.emplace_back(mn, sum);
    } else if (sum == 0) {
      flat.emplace_back(mn, sum);
    } else {
      down.emplace_back(mn - sum, sum);
    }
  }
  sort(ALL(up), [](auto&& lhs, auto&& rhs) {
      return get<0>(lhs) > get<0>(rhs);
  });
  sort(ALL(down), [](auto&& lhs, auto&& rhs) {
      return get<0>(lhs) < get<0>(rhs);
  });
  int sum = 0;
  bool ok = true;
  for (auto [mn, diff] : up) {
    if (sum + mn < 0) ok = false;
    sum += diff;
  }
  for (auto [mn, diff] : flat) {
    if (sum + mn < 0) ok = false;
    sum += diff;
  }
  for (auto [mn, diff] : down) {
    sum += diff;
    if (sum + mn < 0) ok = false;
  }
  if (sum != 0) ok = false;
  if (ok) {
    cout<<"Yes\n";
  } else {
    cout<<"No\n";
  }
  return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
map<int,int> mp;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

  int ans = 0;
  int n; cin>>n;
  for (int i=0; i<n; i++) {
    int x; cin>>x;
    mp[x]++;
  }
  for (auto p: mp) {
    if (p.first==p.second) continue;
    if (p.first>p.second) {
      ans += p.second;
    } else {
      ans += p.second-p.first;
    }
  }
  cout<<ans;
  

  return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>p;
struct edge { int to, cost; };
std::vector<int>G[100000];
std::vector<int>I[100000];

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int main() {
	double a, b, c, d, e, f;
	std::cin >> a >> b >> c >> d >> e >> f;
	a *= 100, b *= 100;
	double ans = 0, sio = 0, kosa = 0;
	for (double i = 0;a*i <= f;i++) {
		for (double j = 0;a*i + b*j <= f;j++) {
			double ima = a*i + b*j;
			double nokori = f - ima;
			for (double k = 0;c*k <= nokori&&c*k <= (ima / 100)*e;k++) {
				for (double l = 0;c*k + d*l <= nokori&&c*k + d*l <= (ima / 100)*e;l++) {
					if (kosa <= (c*k + d*l) / (ima + c*k + d*l))ans = ima + c*k + d*l, sio = c*k + d*l, kosa = (c*k + d*l) / (ima + c*k + d*l);
			}
			}
		}
	}
	std::cout << ans << ' ' << sio << std::endl;
	}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    int n = s.size();
    if (s[n - 1] == 's') {
        s += "e";
    }
    s += "s";
    cout << s << endl;
}

Measured memory_bytes: 3620
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

macro_rules! eprint(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! eprintln(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! dbg {
    ($val:expr) => {
        // Use of `match` here is intentional because it affects the lifetimes
        // of temporaries - https://stackoverflow.com/a/48732525/1063961
        match $val {
            tmp => {
                eprintln!(
                    "[{}:{}] {} = {:#?}",
                    file!(),
                    line!(),
                    stringify!($val),
                    &tmp
                );
                tmp
            }
        }
    };
}

fn main() {
    input! {
        n: u64,
        a: u64,
        b: u64,
    }

    let answer = if (b - a) % 2 == 1 { "Borys" } else { "Alice" };

    println!("{}", answer);
}


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

using int64 = long long;

int64 merge(int a[], int left, int mid, int right)
{
  int64 count = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  int l[n1 + 1], r[n2 + 1];
  for (int i = 0; i < n1; i++)
    l[i] = a[left + i];
  for (int i = 0; i < n2; i++)
    r[i] = a[mid + i];
  l[n1] = 1000000001;
  r[n2] = 1000000001;

  int i = 0, j = 0;
  for (int k = left; k < right; k++)
  {
    if (l[i] <= r[j])
    {
      a[k] = l[i];
      i++;
    }
    else
    {
      a[k] = r[j];
      count += n1 - i;
      j++;
    }
  }

  return count;
}

int64 mergeSort(int a[], int left, int right)
{
  if (left + 1 < right)
  {
    int mid = (left + right) / 2;
    int64 v1 = mergeSort(a, left, mid);
    int64 v2 = mergeSort(a, mid, right);
    int64 v3 = merge(a, left, mid, right);
    return v1 + v2 + v3;
  }
  return 0;
}

int main()
{
  int n;
  scanf("%d", &n);

  int a[n];
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);

  printf("%lld\n", mergeSort(a, 0, n));
  return 0;
}

Measured memory_bytes: 4284
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

struct edge {
  int a;
  int b;
  int to;
};

vector<edge> g[50];

int64 ans[50];
int64 dist[50][2600];
int c[50], d[50];

void solve(int) {
  cin >> n >> m >> k;
  for (int i = 0; i < m; ++i) {
    int x, y, p, q;
    cin >> x >> y >> p >> q;
    --x; --y;
    g[x].push_back({p, q, y});
    g[y].push_back({p, q, x});
  }
  for (int i = 0; i < n; ++i) {
    cin >> c[i] >> d[i];
    ans[i] = inf64;
  }
  memset(dist, -1, sizeof(dist));
  k = min(k, 2599);
  dist[0][k] = 0;
  using tp = tuple<int64, int, int>;
  priority_queue<tp, vector<tp>, greater<tp>> q;
  q.emplace(0, 0, k);
  auto add_to_q = [&] (int v, int coins, int64 t) {
    if (dist[v][coins] == -1 || dist[v][coins] > t) {
      dist[v][coins] = t;
      ans[v] = min(ans[v], t);
      q.emplace(t, v, coins);
    }
  };
  while (!q.empty()) {
    int64 t;
    int v, coins;
    tie(t, v, coins) = q.top();
    q.pop();
    if (t != dist[v][coins]) {
      continue;
    }
    if (coins + c[v] < 2600) {
      add_to_q(v, coins + c[v], t + d[v]);
    }
    for (const auto& ed : g[v]) {
      if (coins >= ed.a) {
        add_to_q(ed.to, coins - ed.a, t + ed.b);
      }
    }
  }
  for (int i = 1; i < n; ++i) {
    cout << ans[i] << '\n';
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 6328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

const ll mod = 998244353;

string s;
int x;
vector<int> vec;
ll d[310][310][310];
ll pcnt[310][310], mcnt[310][310];
ll cum[310];
ll ans;

signed main() {
	cin >> s >> x;
	x = min(x, 300);
	int n = (int)s.size();
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '1')cnt++;
		else {
			vec.push_back(cnt);
			cnt = 0;
		}
	}
	vec.push_back(cnt);
	cnt = 0;
	d[0][0][0] = 1;
	for (int i = 0; i < (int)vec.size(); i++) {
		cnt += vec[i];
		for (int j = 0; j <= x; j++)for (int k = 0; k <= 300; k++)pcnt[j][k] = mcnt[j][k] = 0;
		for (int j = 0; j <= x; j++) {
			cum[0] = d[i][j][0];
			for (int k = 1; k <= 300; k++)cum[k] = (cum[k - 1] + d[i][j][k]) % mod;
			for (int k = cnt; k <= 300; k++) {
				ll p = cum[k];
				if (0 <= k - vec[i] - 1)p = (p - cum[k - vec[i] - 1] + mod) % mod;
				d[i + 1][j][k] = p;
			}
		}
		for (int j = 0; j <= x; j++)for (int k = 0; k <= 300; k++) {
			if (j < k) {
				ll p = d[i][j][k];
				if (j)p = (p + mcnt[k - j][j - 1]) % mod;
				mcnt[k - j][j] = p;
			}
			else {
				ll p = d[i][j][k];
				if (j)p = (p + pcnt[k - j][j - 1]) % mod;
				pcnt[j - k][j] = p;
			}
		}
		for (int j = 0; j <= x; j++)for (int k = cnt; k <= 300; k++) {
			int t = j - k + vec[i];
			if (0 <= t)d[i + 1][j][k] = (d[i + 1][j][k] + pcnt[t][j - 1]) % mod;
			else d[i + 1][j][k] = (d[i + 1][j][k] + mcnt[-t][j - 1]) % mod;
		}
	}
	for (int i = 0; i <= x; i++)ans = (ans + d[(int)vec.size()][i][cnt]) % mod;
	cout << ans << endl;
}

Measured memory_bytes: 115616
n = int(input())


def get_taxicab_metric(x1, y1, x2, y2):
    a = abs(x1 - x2)
    b = abs(y1 - y2)
    return a + b


t_prev, x_prev, y_prev = 0, 0, 0
is_failed = False

for _ in range(n):
    t, x, y = [int(x) for x in input().split()]

    distance = get_taxicab_metric(x, y, x_prev, y_prev)
    time_distance = t - t_prev

    if distance > time_distance:
        is_failed = True
        break

    if distance % 2 != time_distance % 2:
        is_failed = True
        break

    t_prev, x_prev, y_prev = t, x, y

print("No" if is_failed else "Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 55;
const long long INF = 1e18;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, a[MAXN];
map <pair <int, int>, ll> dp[MAXN][MAXN];
ll work(int l, int r, int cl, int cr) {
	if (l > r) return 0;
	if (dp[l][r].count(make_pair(cl, cr)))
		return dp[l][r][make_pair(cl, cr)];
	ll ans = INF; for (int i = l; i <= r; i++)
		chkmin(ans, 1ll * a[i] * (cl + cr) + work(l, i - 1, cl, cl + cr) + work(i + 1, r, cl + cr, cr));
	return dp[l][r][make_pair(cl, cr)] = ans;
}
int main() {
	read(n);
	for (int i = 1; i <= n; i++)
		read(a[i]);
	writeln(a[1] + a[n] + work(2, n - 1, 1, 1));
	return 0;
}

Measured memory_bytes: 16640
//PLUS ULTRA
//one who sits atop all the clans : Lion's Sin Escanor 

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first
#define ll long long 

typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

    int n; cin >> n;
    n = n%10;
    if(n == 2 || n == 4 || n== 5 || n==9 || n==7){
    	cout << "hon\n";
    	return;
    }else if(n == 3){
    	cout << "bon\n";

    }else{
    	cout <<"pon\n";
    }

    
    
        


}

int main(){
    SPEED;

    int t = 1; 
    
    // cin >> t;
    

    while(t--) solve();




    return 0;
}
      
       


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int ans = 700;
  if (s.at(0) == 'o') {
  	ans += 100;
  }
  if (s.at(1) == 'o') {
  	ans += 100;
  }
  if (s.at(2) == 'o') {
  	ans += 100;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e6+5,M=2e6+5,mo=1e9+7;
int n,m,x,y,ts,s1,s,ns,p,ans,f[1<<16],cnt[16][1<<16],i;
ll inc;
int tt,b[1000],nxt[1000],fst[1000];
void cr(int x,int y)
{
	tt++;
	b[tt]=y;
	nxt[tt]=fst[x];
	fst[x]=tt;
}
int main()
{
	scanf("%d %d",&n,&m);
	fo(i,1,m)
	{
		scanf("%d %d",&x,&y);
		cr(x,y);
	}
	ts=1<<n;ts--;
	fo(i,1,n) fo(s,0,ts) 
		for(p=fst[i];p;p=nxt[p]) if ((1<<b[p]-1)&s) cnt[i][s]++;
	fo(s,0,ts)
	if ((s&1)==((s>>1)&1))
	{
		f[s]=1;
		for(ns=(s-1)&s;ns;ns=(ns-1)&s)
			if ((ns&1)==((ns>>1)&1))
			{
				s1=s-ns;
				inc=f[s1];
				fo(i,1,n) 
				if (s1&(1<<i-1))
					(inc*=(1<<cnt[i][ns])-1)%=mo;
				else if (ns&(1<<i-1))
					(inc<<=cnt[i][s1])%=mo;
				f[s]=(f[s]+inc)%mo;
			}
	}
	ans=1;
	fo(i,1,m) ans=ans*2%mo;
	ans-=f[ts];
	ans=(ans+mo)%mo;
	printf("%d",ans);
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
    int m,n;
    while (~scanf("%d%d",&m,&n))
    {
        int a[250000][2]= {0};
        int x,y;
        int flag=0;
        for(int j=1; j<=n; j++)
        {
            scanf("%d",&x);
            scanf("%d",&y);
            if(x==1)
                a[y][1]=1;
            if(y==m)
                a[x][0]=1;
        }
        for(int j=1; j<=n; j++)
            if(a[j][0]&&a[j][1])
                flag=1;
//        printf("%d %d \n",a[2][0],a[2][1]);
        if(flag)
            printf("POSSIBLE\n");
        else
            printf("IMPOSSIBLE\n");
    }
}


Measured memory_bytes: 2176
from collections import deque

K = int(input())
d = deque([1,2,3,4,5,6,7,8,9])

for i in range(K-1):
    num = d.popleft()
    mod = num % 10
    if mod != 0:
        d.append(num*10+mod-1)
    d.append(num*10+mod)
    if mod != 9:
        d.append(num*10+mod+1)
print(d.popleft())

Measured memory_bytes: 74864
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

const int dx8[]={-1,0,1,-1,1,-1,0,1};
const int dy8[]={-1,-1,-1,0,0,1,1,1};

int main(){
    int h,w;
    cin >>h>>w;
    vector<string> s(h);
    vecin(s);
    // vecout(s);
    for range(i,h){
        for range(j,w){
            if (s[i][j]=='.'){
                int count =0;
                for range(d,8){
                    int nx=j+dx8[d];
                    int ny=i+dy8[d];
                    // cout <<nx<<" "<<ny<<endl;
                    if ((0<=nx && nx<w && 0<=ny && ny<h) && s[ny][nx]=='#') count++;
                }
                s[i][j]='0'+count;
            }
        }
    }
    for range(i,h){
        cout << s[i] << endl;
    }
        
    
}

Measured memory_bytes: 256
h, w = map(int, input().split()) #hが行(x)、wが列(y)
maze = [input() for i in range(h)]
bomb = [[0] * w for _ in range(h)]

for x in range(h):
    for y in range(w):
        if maze[x][y] == "#":
            bomb[x][y] = "#"
            continue

        for dx, dy in [(0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1)]:
            nx = x + dx
            ny = y + dy 
            if not 0 <= nx < h or not 0 <= ny < w:
                continue
            if maze[nx][ny] == "#":
                bomb[x][y] += 1
               



for i in range(h):
    ans = ""
    for j in range(w):     
        ans +=str( bomb[i][j])
    print(ans)
        
       


Measured memory_bytes: 9224
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#ifdef LOCAL
mt19937 rng(unsigned(70));
#else
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
#define rand rng


int main() {
	// fios;
	ll n;
	cin >> n;
	vector<ll> a(n+1);
	unordered_map<ll, ll> mpg, mpl;

	for(ll i = 1; i <= n; i++) {
		cin >> a[i];
		mpg[a[i] + i]++;
		mpl[i - a[i]]++;
	}
	ll ans = 0;
	for(int k = 1; k <= n; k++) {
		ans += mpg[k - a[k]];
		ans += mpl[k + a[k]];
	}
	cout << ans / 2 << endl;
	assert(ans % 2  == 0);
}

Measured memory_bytes: 35544
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	double w, h, x, y;
	cin >> w >> h >> x >> y;

	double ans = w * h / 2;
	
	if (x + x == w && y + y == h) {
		cout << fixed << setprecision(6) << ans;
		cout << " " << 1 << endl;
	}
	else {
		cout << fixed << setprecision(6) << ans;
		cout << " " << 0 << endl;
	}

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
typedef long long ll;

int main(){
  ll l,r;
  cin>>l>>r;
  int ans=2018;
  r=min(r,l+4038);//rのサイズが小さくなるため通常ループで計算可能になる
  for(ll i=l;i<r+1;i++){
    for(ll j=i+1;j<r+1;j++){
      int x=i*j%2019;
      ans=min(ans,x);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <array>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <stack>

int main()
{
	std::cout << std::fixed << std::setprecision(15);

	long long N;
	std::cin >> N;

	std::vector<double> x(N), y(N);
	for (size_t i = 0; i < N; ++i)
	{
		std::cin >> x[i] >> y[i];
	}

	std::array<std::array<double, 8>, 8> distances;
	for (int i = 0; i < N; ++i)
	{
		//for (int j = i + 1; j < N; ++j)
		for (int j = 0; j < N; ++j)
		{
			distances.at(i).at(j) = std::sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
		}
	}

	std::vector<int> indexes(N);
	for (int i = 0; i < N; ++i)
	{
		indexes[i] = i;
	}

	double sum = 0.0;
	int num = 0;
	do {
		for (size_t i = 0; i < N - 1; ++i)
		{
			sum += distances.at(indexes.at(i)).at(indexes.at(i + 1));
		}
		num++;

	} while (std::next_permutation(std::begin(indexes), std::end(indexes)));
	
	std::cout << sum / num << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int num[200005];
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++)
	{
		scanf("%d",&num[i]);
	}
	for(int i=b;i<a;i++)
	{
		if(num[i-b+1]<num[i+1])
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
}

Measured memory_bytes: 4532
#include <iostream>
#include <set>
#include <cassert>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define MAX 1000
using namespace std;
int ans;
int n,d[MAX],threshold=10,numOfDigits=1;
set<int> list;
int main() {
  cin >> n;
  rep(i,n) cin >> d[i];
  rep(i,n) list.insert(d[i]);
  for(int i = 0;true;i++){
    if(i == threshold){
      list.clear();
      numOfDigits++;
      rep(i,n+1-numOfDigits){
        int element = 0;
        REP(j,i,numOfDigits+i){
          element *= 10;
          element += d[j];
        }
        list.insert(element);
      }
      threshold *= 10;
    }
    if(list.count(i)==0) {
      cout << i << endl;
      return 0;
    }
  }
}

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

#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pii pair<ll, ll>
#define piii pair<ll, pair<ll, ll>>
#define debug(x) cout<<#x<<" = "<<x<<endl

using namespace std;
const int N = 200005;
ll t, n, m, k, q, a, b, x, y, ans, arr[N];
ll mod = 998244353;
string s;
bool vis[N];

int main() {
    io;
    t = 1;
//    cin >> t;
    while (t--) {
        cin >> a >> b >> n;
        if (n >= b)
            x = b - 1;
        else
            x = n;
        ans = (a * x) / b;
        cout << ans << endl;
    }
    return 0;
}
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);


Measured memory_bytes: 3660
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = map(int,read().split())
x = 1
INF = 10**18

if 0 in a:
    print(0)
    exit()


for i in a:
    x *= i
    if x > INF:
        print(-1)
        break
else:
    print(x)
    


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

using namespace std;

int getMax(int a, int b, int c){
	int maximum = max(a,b);
	maximum = max(maximum,c);
	return maximum;
}

int main(){

	int days;
	cin >> days;

	vector<int> dp(3);
	//array points for each task
	int points[3];

	for (int d=0;d<days;d++){
		//Another dp array to compare
		//Set all tasks to zero points to get max
		vector<int> aux_dp(3,0);

		cin >> points[0] >> points[1] >> points[2];

		//iterate throght two consecutive tasks
		for (int i=0;i<3;i++){

			for(int j=0;j<3;j++){
				//If they are different
				if (i != j){
					//Get max from current value or the sum of dp current value plus this task points
					aux_dp[j] = max(aux_dp[j], dp[i] + points[j]);
				}
			}
		}

		//Store result in dp, to reset aux_dp to zero
		dp = aux_dp;
	}

	//Print the best solution if is either a, b or c
	cout << getMax(dp[0],dp[1],dp[2]) << endl;

}

Measured memory_bytes: 3608
#include<cstdio>
using namespace std;
int main(void){
    int N,M;
    scanf("%d",&N);
    int T[N];
    for(int n=0;n<N;n++){
        scanf("%d",&T[n]);
    }
    scanf("%d",&M);
    int P[M],X[M];
    for(int n=0;n<M;n++){
        scanf("%d %d",&P[n],&X[n]);
    }

    int sum=0;
    for(int n=0;n<N;n++){
        sum+=T[n];
    }
    // printf("sum:%d\n",sum);
    for(int n=0;n<M;n++){
        // printf("%d\n",sum-T[P[n]-1]);
        printf("%d\n",sum-T[P[n]-1]+X[n]);
    }

    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal f;
            decimal a;
            decimal b;

            var Input = Console.ReadLine().Split(' ');

            int d = int.Parse(Input[0])/int.Parse(Input[1]);

            int r = int.Parse(Input[0]) % int.Parse(Input[1]);

            a = int.Parse(Input[0]);
            b = int.Parse(Input[1]);
       
            f = a / b;

            Console.WriteLine("{0} {1} {2}", d, r, f);

        }

    }

}

Measured memory_bytes: 9192
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll r, D, x;
  while (cin >> r >> D >> x) {
    for (int i = 0; i < 10; i++) {
      x = r * x - D;
      cout << x << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define inlld2(x, y) scanf("%lld%lld", &x, &y)
#define inlld3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define ind2(x, y) scanf("%d%d", &x, &y)
#define ind3(x, y, z) scanf("%d%d%d", &x, &y, &z)

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

typedef long long ll;
typedef long double ld;

using namespace std;

string s;
int n, dp[N][2][2];

int solve(int i, int islesser, int carryright)
{
    if(i<0 && islesser)
        return 1;
    else if(i<0)
        return 0;
    if(dp[i][islesser][carryright]!=-1)
        return dp[i][islesser][carryright];
    if(islesser)
    {
        int ret=1e8;
        if(!carryright)
        {
            for(int a=(s[i]-'0')+1; a<=9; a++)
                ret=min(ret, solve(i-1, 0, 0) + a + a - (s[i]-'0'));
            ret=min(ret, solve(i-1, 1, 0) + (s[i]-'0'));
            for(int a=0; a<(s[i]-'0'); a++)
                ret=min(ret, solve(i-1, 1, 1) + a + 10 + a - (s[i]-'0'));
        }
        else
        {
            for(int a=(s[i]-'0')+1; a<=9; a++)
                ret=min(ret, solve(i-1, 0, 0) + a + a - 1 - (s[i]-'0'));
            ret=min(ret, solve(i-1, 1, 1) + (s[i]-'0') + 9);
            for(int a=0; a<(s[i]-'0'); a++)
                ret=min(ret, solve(i-1, 1, 1) + a + 9 + a - (s[i]-'0'));
        }
        return dp[i][islesser][carryright]=ret;
    }
    else
    {
        int ret=1e8;
        for(int a=(s[i]-'0'); a<=9; a++)
            ret=min(ret, solve(i-1, 0, 0) + a + a - (s[i]-'0'));
        for(int a=0; a<(s[i]-'0'); a++)
            ret=min(ret, solve(i-1, 1, 1) + a + 10 + a - (s[i]-'0'));
        return dp[i][islesser][carryright]=ret;
    }
}

int main()
{
    cin>>s;
    n=s.length();
    memset(dp, -1, sizeof(dp));
    int ans=1e8;
    for(int a=0; a<(s[n-1]-'0'); a++)
        ans=min(ans, solve(n-2, 1, 1) + a + 10 + a - (s[n-1]-'0'));
    for(int a=(s[n-1]-'0'); a<=9; a++)
        ans=min(ans, solve(n-2, 0, 0) + a + a - (s[n-1]-'0'));
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 95108
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int


int main()
{
	fast;
	ll n,d;cin>>n>>d;
	int c=0;
	for(int i=0;i<n;i++)
	{
		double x,y;cin>>x>>y;
		ll dis=x*x + y*y;
		double di=sqrt(dis);
		if(di<=d)
			c++;
	}
	
	
	cout<<c;

}

Measured memory_bytes: 3796
n, m = gets.split.map &:to_i
ps = []
ss = []

m.times{
	p, s = gets.chomp.split
	ps << p.to_i
	ss << s
}

is_ac = Array.new(n + 1, false)
fault_count = Array.new(n + 1, 0)

ps.each_with_index{ |p,i|
	if ss[i] == "WA" then
		if ! is_ac[p] then
			fault_count[p] += 1
		end
	else
		is_ac[p] = true
	end
}

count = 0
sum = 0

is_ac.each_with_index{ |ac, i|
	if ac then
		count += 1
		sum += fault_count[i]
	end
}

puts [count, sum].join(" ")


Measured memory_bytes: 11900
import sys

def s(d, i=1, a=1):
    a += i*2
    if d <= 1:
        return a
    return s(d-1,i=i*2, a=a)

H = int(input())
if H==1:
    print(1)
    sys.exit()
count = 0

while True:
    count += 1
    
    H = H // 2
    
    if H <= 1:
        break

print(s(count))


Measured memory_bytes: 3060
import math
def permutations(n, r):
    return math.factorial(n) // math.factorial(n - r)


n,p = (int(i) for i in input().split())
a = list(int(i) for i in input().split())
odd = 0
even = 0
ans = 0
for i in range(n):
  if a[i]%2 == 0: even+=1
  else:odd += 1
if even == n:
  if p == 0: print(2**n)
  else:print(0)
else:
  print(2**(n-1))
 

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

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back


const int N = 2e5 + 51 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

//gp_hash_table<int, int> table;

int t[N], h[N], a[N];
int n;

void inc (int i, int delta) {
    t[i] = delta;
    for (; i <= n; i|= (i + 1)) t[i] = max(t[i], delta);
}

int sum (int i) {
    int ans = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1) ans = max(ans, t[i]);
    return ans;
}

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    int ans = 1;
    for (int i = 0; i < n; i++) cin >> h[i];
    for (int j = 0; j < n; j++) cin >> a[j];

    for (int i = 0; i < n; i++) {
        int lol = sum(h[i]) + a[i];
        inc(h[i], lol);
        ans = max(ans, lol);
    }
    for (int i = 1; i <= n; i++) ans = max(ans, t[i]);
    cout << ans;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);cout.tie(0);

   ll a[105][2];
   ll i,j,k,l,d,e,f;
   cin>>d;
   for(i=0;i<d;i++)
   {
       for(j=0;j<2;j++)
       {
           cin>>a[i][j];
       }
   }

   for(i=0;i<d-2;i++)
   {
       if(a[i][0]==a[i][1] && a[i+1][0]==a[i+1][1] && a[i+2][0]==a[i+2][1])
       {
           cout<<"Yes"<<endl;
           return 0;
       }
   }
   cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3648
import numpy as np
h,w,k = map(int,input().split())
c = []
for _ in range(h):
    c.append(list(input()))
c = np.array(c)
c = 1*(c == "#")

def test(c,y,x):
    d = c.copy()
    for i in range(h):
        if (1 << i) & y:
            d[i,:] = 0
    for i in range(w):
        if (1 << i) & x:
            d[:,i] = 0
    return (d.sum() == k)
asum = 0
for y in range(1 << h):
    for x in range(1 << w):
        asum += test(c,y,x)
print(asum)

Measured memory_bytes: 27204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int h, w;
string s[1000];

int main() {
	cin >> h >> w;
	rep(i, h) {
		cin >> s[i + 1];
		s[i + 1] = "#" + s[i + 1] + "#";
	}
	rep(i, h + 2) {
		rep(j, w + 2) {
			if (i == 0 || i == h + 1)cout << "#";
			else cout << s[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[])
{
	int n,k,m,a[3],i,j;
	scanf("%d %d %d",&m,&n,&k);		
		a[0]=fabs(m-n);
		a[1]=fabs(m-k);
		a[2]=fabs(n-k);
		for(i=0;i<3;i++){
			for(j=i+1;j<3;j++){
				if(a[i]<a[j]){
					int t=a[i];
						a[i]=a[j];
						a[j]=t;
				}
			}
		}
		
		printf("%d\n",a[1]+a[2]);	
	
	return 0;
}

Measured memory_bytes: 128