akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <queue>
#include <functional>

using namespace std;

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

typedef long long ll;
typedef pair<double, int> P;

const int N_MAX = 1000;
const int V_MAX = N_MAX + 2;
const double INF = 1e10;

int xs, ys, xt, yt;
int N;
ll x[V_MAX];
ll y[V_MAX];
ll r[V_MAX];

int V;
double d[V_MAX];

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d + V, INF);
  d[s] = 0.0;
  que.push(P(0, s));
  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    REP(u, V) {
      double dist = sqrt((x[u] - x[v]) * (x[u] - x[v]) + (y[u] - y[v]) * (y[u] - y[v]));
      dist = max(dist - r[u] - r[v], 0.0);
      if (d[u] > d[v] + dist) {
        d[u] = d[v] + dist;
        que.push(P(d[u], u));
      }
    }
  }
}

void solve() {
  V = N + 2;
  x[0] = xs; x[V - 1] = xt;
  y[0] = ys; y[V - 1] = yt;
  r[0] = r[V - 1] = 0;
  dijkstra(0);
  printf("%.10f\n", d[V - 1]);
}

void input() {
  scanf("%d%d%d%d", &xs, &ys, &xt, &yt);
  scanf("%d", &N);
  FOR(i, 1, N) scanf("%lld%lld%lld", x + i, y + i, r + i);
}

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


Measured memory_bytes: 5872
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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;
}
int cnt=0;

void dfs(vector<vector<int> >&G, vector<bool>&used, int v){
    used.at(v)=true;
    bool flag=false;
    for(int i=0;i<used.size();i++){
        if(used.at(i)==false){
            flag=true;
            break;
        }
    }

    if(!flag)cnt++;

    for(auto next_v : G.at(v)){
        if(used.at(next_v)==false){
            dfs(G,used,next_v);
        }
    }
    used.at(v)=false;
}


int main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int> >G(n);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        G.at(x).push_back(y);
        G.at(y).push_back(x);
    }
    vector<bool>used(n,false);
    dfs(G, used, 0);
    cout<<cnt<<endl;



    return 0;
}


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

using namespace std;

const int TMAX = 100010;
const int CMAX = 30;
int t_list[CMAX][2*TMAX];
int plan[CMAX][TMAX];

int main(){
    int N,C;
    cin >> N >> C;
    fill((int*)t_list, (int*)(t_list+CMAX),0);
    fill((int*)plan, (int*)(plan+CMAX),0);
    //fill(t_list[0], t_list[CMAX],0);
    //fill(plan[0], plan[CMAX],0);
    for(int i=0;i<N;i++){
        int s,t,c;
        cin >> s >> t >> c;
        c--;
        plan[c][s]++;
        plan[c][t+1]--;
    }
    for(int c=0;c<C;c++){
        for(int t=1;t<TMAX;t++){
            plan[c][t] = plan[c][t] + plan[c][t-1];
        }
    }

    for(int c=0;c<C;c++){
        for(int t=0;t<TMAX;t++){
            t_list[c][t*2] = plan[c][t];
            if(plan[c][t+1] > 0){
                t_list[c][t*2+1] = 1;
            }
            //if( (plan[c][t] == 0 && plan[c][t+1] == 1) || (plan[c][t] == 1 && plan[c][t+1] == 1) ){
            //    t_list[c][t*2+1] = 1;
            //}
        }
    }

    int ans = 0;
    for(int t=0;t<2*TMAX;t++){
        int chan = 0;
        for(int c=0;c<C;c++){
            if(t_list[c][t] == 1) chan++;
        }
        ans = max(ans, chan);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35456
N = int(input())
CONST = 10 ** 18
result = 1
numbers = list(map(int, input().split()))
if 0 in numbers:
    print(0)
    exit(0)
numbers.sort(reverse=True)
for i in numbers:
    result = result * i
    if result > CONST:
        print(-1)
        exit(0)
print(result)

Measured memory_bytes: 21600
N,M=map(int,input().split())

S=[[] for _ in range(N+1)]
for i in range(M):
    T=list(map(int,input().split()))
    for x in T[1:]:
        S[x].append(i+1)

P=["*"]+list(map(int,input().split()))

X=0
for i in range(2**N):
    Q=["*"]+[0]*M
    for x in range(N):
        if i%2:
            for k in S[x+1]:
                Q[k]=(Q[k]+1)%2
                
        i>>=1
    X+=(P==Q)
print(X)


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

template<typename T>
void printv(vector<T> A, string delimiter = " ") {
    for (int i = 0; i < A.size(); i++) {
        if (i > 0) cout << delimiter;
        cout << A[i];
    }
    cout << endl;
}

int64_t cnt = 0;
void insertionSort(vector<int> &A, int g = 1) {
    // printA(A);
    // for (int i = 1; i < A.size(); i++) {
    for (int i = g; i < A.size(); i++) {
        int v = A[i];
        // int j = i - 1;
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            // A[j + 1] = A[j];
            A[j + g] = A[j];
            // j--;
            j -= g;
            cnt++;
        }
        // A[j + 1] = v;
        A[j + g] = v;
        // printA(A);
    }
}

void shellSort(vector<int> &A, vector<int> G) {
    for (int i = 0; i < G.size(); i++) {
        insertionSort(A, G[i]);
    }
}

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

    // 入力
    int n;
    cin >> n;
    vector<int> A;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    // ソート間隔の数列 G を作成 (g_{n+1} = 3 * g_n + 1)
    vector<int> G;
    for (int i = 0; ; i++) {
        if (i == 0) {
            G.push_back(1);
        } else {
            if (3 * G[i - 1] + 1 < n) {
                G.push_back(3 * G[i - 1] + 1);
            } else {
                break;
            }
        }
    }
    reverse(G.begin(), G.end());

    // シェルソート
    shellSort(A, G);

    // 結果を出力
    cout << G.size() << endl;
    printv<int>(G);
    cout << cnt << endl;
    printv<int>(A, "\n");

    return 0;
}



Measured memory_bytes: 10724
#include<iostream>

using namespace std;

int main() {
	int n, value1, count = 0;

	cin >> n;

	value1 = n % 10;
	count++;
	n /= 10;

	for (int i = 0; i < 3; i++) {
		if (value1 == n % 10) {
			n /= 10;
			count++;
		}
		else {
			count = 1;
			value1 = n % 10;
			n /= 10;
		}
		if (count >= 3)
			break;
	}

	if (count >= 3)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A, B, C = map(int, input().split())
dp = [[0] * 3 for _ in range(N)]
dp[0] = [A, B, C]

for i in range(1, N):
    a, b, c = map(int, input().split())
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c

print(max(dp[-1][0], dp[-1][1], dp[-1][2]))


Measured memory_bytes: 22772
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int m[51],f[51],r[51];
    for(int i=0; i<50; i++){
        scanf("%d %d %d",&m[i],&f[i],&r[i]);
        if(m[i]==-1 && f[i]==-1 && r[i]==-1){
            for(int j=0; j<i; j++){
                if(m[j]==-1 || f[j]==-1) printf("F\n");
                else if(m[j]+f[j] >= 80)printf("A\n");
                else if(m[j]+f[j] >= 65 && m[j]+f[j] < 80)printf("B\n");
                else if(m[j]+f[j] >= 50 && m[j]+f[j] < 65)printf("C\n");
                else if(m[j]+f[j] >= 30 && m[j]+f[j] < 50 && r[j] >=50)printf("C\n");
                else if(m[j]+f[j] >= 30 && m[j]+f[j] < 50)printf("D\n");
                else if(m[j]+f[j] < 30)printf("F\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2044
from collections import deque

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

b = deque()

if N % 2 == 0:
    for i in range(0, N, 2):
        b.append(a[i])

    for i in range(1, N, 2):
        b.appendleft(a[i])
else:
    for i in range(0, N, 2):
        b.appendleft(a[i])

    for i in range(1, N, 2):
        b.append(a[i])

print(*b)


Measured memory_bytes: 25412
N = int(input())
ans = 0
t = []
for i in range(N):
    x,y = map(int,input().split())
    for j in range(i):
        a,b = t[j]
        ans += ((x-a)**2 + (y-b)**2)**0.5
    t.append((x,y))
ans = ans*2
ans = ans/N
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdbool.h>
#define ll long long

int main(){
  bool exist=false;
  ll n,a[200001],i,cnt=1,ans=0;
  scanf("%lld",&n);
  for(i=1;i<=n;i++){
    scanf("%lld",&a[i]);
    if(a[i]==cnt){
      exist=true;
      cnt++;
    }else{
      ans++;
    }
  }
  ans=exist?ans:-1;

  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

typedef long long ll;

ll n;
string s;

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

	ll cnt = 0;
	for (ll i = 0; i < n; i++) {
		if (s[i] == 'R') {
			cnt++;
		}
	}

	ll c = 0;
	for (ll i = 0; i < cnt; i++) {
		if (s[i] == 'R') {
			c++;
		}
	}

	cout << cnt - c << endl;
}

Measured memory_bytes: 3748
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;



int main(){
    int m;
    cin>>m;
    int n=m-1;
    int b[n];
    vi a(m);
    pan(i,n) cin>>b[i];
    int sum=b[0];
    // a.pb(b[0]);
    pan(i,n){
        if(i<n-2){
            // a[i+1]=*min_element(b+i-1,b+i+3);
            sum+=min(b[i],b[i+1]);
            // cout<<sum<<"-"<<*min_element(b+i-1,b+i+1)<<endl;
        }
        else if(i==n-2){
            // a[i+1]=*min_element(b+i-1,b+i+2);
            sum+=min(b[i],b[i+1]);
            // cout<<sum<<"-"<<*min_element(b+i-1,b+i+1)<<endl;
        }
        else {
            // a[i+1]=b[n-1];
            sum+=b[n-1];
            // cout<<sum<<endl;
        }
    }
    // a.pb(b[n-1]);
    // sum+=b[n-1];
    // pan(i,m+1) cout<<a[i]<<" ";
    cout<<sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int X;
	cin>>X;
	while(1){
		bool check=true;
		REP(i,min(410,X-1)){
			if(i==0)continue;
			if(i==1)continue;
			if(X%i==0)check=false;
		}
		if(check==true){
			break;
		}
		X++;
	}
	cout<<X<<endl;
}

Measured memory_bytes: 256
import numpy as np
n, w = map(int, input().split())
wv_list = [[int(i) for i in input().split()] for i in range(n)]

dp = np.zeros(w+1)
for wv in wv_list:
    w = wv[0]
    v = wv[1]
    dp[w:] = np.maximum(dp[:-w]+v, dp[w:])

print(int(np.max(dp)))


Measured memory_bytes: 15512
s = int(input())
MOD = 10**9 + 7
b3 = 1; b2 = 0; now = 0 # now == b1
for _ in range(s-2):
    b1 = now
    now = (b1 + b3) % MOD
    b3, b2 = b2, b1
print(now)


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


void solve(std::string S, std::string T){
    cout<<T<<S<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

int main() {
    int n;

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

    cout << (a[1] && a[9] && a[7] && a[4] ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define drep(i,l,r) for(int (i)=(l);(i)>=(r);(i)--)
using namespace std;
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),b(n);
    rep(i,0,n)cin>>a[i]>>b[i];
    ll ans=0;
    drep(i,n-1,0){
        a[i]+=ans;
        ll buf=b[i]-(a[i]%b[i]);
        if(buf==b[i])buf=0;
        ans+=buf;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2428
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	var ans, p int64
	for i := 0; i < n; i++ {
		a := getNextInt64(scanner)
		ans += (a + p) >> 1
		if a == 0 {
			p = 0
			continue
		}
		p = (a + p) % 2
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 2816
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    public static IO IO = new IO();
    static void Main(string[] args)
    {
        IO.INT();
        List<int> m = IO.INT(' ').ToList();
        IO.INT();
        int[] o = IO.INT(' ');
        int c = 0;
        foreach (int b in o)
        {
            if (m.BinarySearch(b) >= 0) { c++; }
        }
        IO.WRITE(c);
        IO.FLUSH();
    }
}

namespace LIB
{
    public class IO
    {
        private const int WMAX = 1000;
        private StringBuilder S = new StringBuilder();
        private T R<T>(Func<string, T> f) { return f(Console.ReadLine()); }
        private T[] R<T>(Func<string, T> f, char c) { return STRING().Split(c).Select(f).ToArray(); }
        private T[] R<T>(Func<string, T> f, int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = R(f); } return r; }
        private T[][] R<T>(Func<string, T> f, int l, char c) { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
        private void W<T>(Func<T, string> f, T v, bool lf = true) { S.Append(f(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { FLUSH(); } }
        public string STRING() { return R(s => s); }
        public string[] STRING(char c) { return R(s => s, c); }
        public string[] STRING(int l) { return R(s => s, l); }
        public string[][] STRING(int l, char c) { return R(s => s, l, c); }
        public int INT() { return R(int.Parse); }
        public int[] INT(char c) { return R(int.Parse, c); }
        public int[] INT(int l) { return R(int.Parse, l); }
        public int[][] INT(int l, char c) { return R(int.Parse, l, c); }
        public long LONG() { return R(long.Parse); }
        public long[] LONG(char c) { return R(long.Parse, c); }
        public long[] LONG(int l) { return R(long.Parse, l); }
        public long[][] LONG(int l, char c) { return R(long.Parse, l, c); }
        public double DOUBLE() { return R(double.Parse); }
        public double[] DOUBLE(char c) { return R(double.Parse, c); }
        public double[] DOUBLE(int l) { return R(double.Parse, l); }
        public double[][] DOUBLE(int l, char c) { return R(double.Parse, l, c); }
        public void WRITE(string s, bool lf = true) { W(v => v, s, lf); }
        public void WRITE(int s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(long s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(double s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void FLUSH() { Console.Write(S); S.Length = 0; }
    }
}

Measured memory_bytes: 19528
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
long long C[2100][2100];
long long dp[2100][2100];
long long sum[2100][2100];
long long inv[2100];
long long calc(long long a,int b){
	long long ret=1;
	for(int i=0;i<b;i++){
		ret=(a-i)%mod*ret%mod*inv[i+1]%mod;
	}
	return ret;
}
int main(){
	int a;
	long long b;
	int c;
	C[0][0]=1;
	for(int i=0;i<2050;i++){
		for(int j=0;j<=i;j++){
			C[i+1][j]=(C[i+1][j]+C[i][j])%mod;
			C[i+1][j+1]=(C[i+1][j+1]+C[i][j])%mod;
		}
	}
	inv[1]=1;
	for(int i=2;i<2050;i++){
		inv[i]=(mod-inv[mod%i]*(mod/i)%mod)%mod;
	}
	while(scanf("%d%lld%d",&a,&b,&c),a){
	c--;
		for(int i=0;i<=a;i++)for(int j=0;j<=a;j++)dp[i][j]=sum[i][j]=0;
		dp[0][0]=1;
		for(int i=0;i<=a;i++)sum[0][i]=1;
		for(int i=1;i<=a;i++){
			for(int j=1;j<=a;j++){
				long long val=sum[i-1][j-1];
				if(j-c-1>=0)val=(val+mod-sum[i-1][j-c-1])%mod;
				dp[i][j]=val;
		//		printf("%d %d: %lld\n",i,j,val);
			}
			sum[i][0]=dp[i][0];
			for(int j=1;j<=a;j++){
				sum[i][j]=(sum[i][j-1]+dp[i][j])%mod;
			}
		}
		
		long long ret=0;
		for(int i=1;i<=min((long long)a,b);i++){
			ret=(ret+calc(b,i)*dp[i][a])%mod;
		}
		printf("%lld\n",ret);
	}
}

Measured memory_bytes: 103600
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<bool> ans(n, false);
	rep(i, k) {
		int di;
		cin >> di;
		rep(j, di) {
			int ki;
			cin >> ki;
			ki--;
			ans[ki] = true;
		}
	}
	int cnt = 0;
	rep(i, n) {
		if (!ans[i]) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3632
#include <iostream> 
using namespace std;
bool is_8div(int);
int main()
{
	int n;
	while(cin>>n){
		int ans=0;
		for(int i=1;i<=n;i+=2){
			if(is_8div(i))
				ans++;
		}	
		cout<<ans<<endl;
	}
	return 0;
}

bool is_8div(int n)
{
	int x=0;
	for(int i=1;i<=n;i++)
		if(n%i==0)	x++;
	if(x==8)	return true;
	return false;
}

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

int main(){
  int n;
  cin>>n;
  vector<string>x(n);
  for(int i=0;i<n;i++){
  string y;
  cin>>y;
  x.at(i)=y;
  }
  sort(x.begin(),x.end());
  int k=n;
  for(int j=0;j<n-1;j++){
  if(x.at(j)==x.at(j+1)){
  k--;
  }
  }
  cout<<k<<endl;
}

Measured memory_bytes: 9520
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int64_t N, A, B; cin>> N >> A >> B;

int64_t d = B - A;
if (d % 2) 
    cout << min(A, N - B + 1) + d/2 << endl;
else cout << d/2 << endl;





}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
def main():
    s_long = input()
    s_shor = input()

    ans = len(s_shor)
    max_len = len(s_long) - len(s_shor) + 1


    for i in range(max_len):
        cnt = 0

        for j in range(len(s_shor)):

            short = s_shor[j]
            longg = s_long[i + j]
            
            if (short != longg):
                cnt += 1
        
        ans = min(ans, cnt)
        
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n;
	long long sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		if(i%3==0||i%5==0){
			;
		}
		else{
			sum+=i;
		}
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 3824
import copy

H,W,K=map(int,input().split())
S = [["" for j in range(W)] for i in range(H)]


for i in range(H):
    tm=input()
    for j in range(W):
        S[i][j]=tm[j]



anscount=0

for i in range(2 **(H+W)):
    tmp=copy.deepcopy(S)
    for j in range(H+W):
        if ((i >> j) & 1):
            #print(i,j)のjbitがONの意味
            if j<H:
                for k in range(W):
                    tmp[j][k]="."
            else:
                for k in range(H):
                    tmp[k][j-H]="."
    tmpcount=0
    #print(tmp)
    for k in range(H):
        for l in range(W):
            if tmp[k][l]=="#":
                tmpcount+=1
    if tmpcount==K:
        anscount+=1
        
print(anscount)


Measured memory_bytes: 9288
class Dice:
    def __init__(self):
        self.number = [i for i in range(6)]
        self.command_allpattern = "NNNNENNNNENNNNENNNNNENNNNEENNNNWWWSE"

    def set_number(self, d0, d1, d2, d3, d4, d5):
        self.number[0] = d0
        self.number[1] = d1
        self.number[2] = d2
        self.number[3] = d3
        self.number[4] = d4
        self.number[5] = d5

    def roll(self, command):
        if   command == "E":
            self.set_number(self.number[3],self.number[1],self.number[0],self.number[5],self.number[4],self.number[2])
        elif command == "N":
            self.set_number(self.number[1],self.number[5],self.number[2],self.number[3],self.number[0],self.number[4])
        elif command == "S":
            self.set_number(self.number[4],self.number[0],self.number[2],self.number[3],self.number[5],self.number[1])
        elif command == "W":
            self.set_number(self.number[2],self.number[1],self.number[5],self.number[0],self.number[4],self.number[3])
        else:
            raise

    def get_top(self):
        return self.number[0]

    def get_d2(self, d0, d1):
        flag_correct = False
        
        for command in self.command_allpattern:
            self.roll(command)

            if ((d0 == self.number[0]) and
                (d1 == self.number[1])):
                d2 = self.number[2]
                flag_correct = True

        if flag_correct:
            return d2
        else:
            raise

    def is_equal_dice_number(self, Dice):
        if set(Dice.number) == set(self.number):
            return True
        else:
            return False

    def equal_dice(self, Dice):

        if not self.is_equal_dice_number(Dice):
            return("No")


        flag_correct = False

        for command in self.command_allpattern:
            Dice.roll(command)

            if ((Dice.number[0] == self.number[0]) and
                (Dice.number[1] == self.number[1]) and
                (Dice.number[2] == self.number[2]) and
                (Dice.number[3] == self.number[3]) and
                (Dice.number[4] == self.number[4]) and
                (Dice.number[5] == self.number[5])):
                flag_correct = True

        if flag_correct:
            return("Yes")
        else:
            return("No")



list_face1 = list(map(int, input().split()))

dice1 = Dice()
dice1.set_number(list_face1[0], list_face1[1], list_face1[2], list_face1[3], list_face1[4], list_face1[5])


list_face2 = list(map(int, input().split()))

dice2 = Dice()
dice2.set_number(list_face2[0], list_face2[1], list_face2[2], list_face2[3], list_face2[4], list_face2[5])

print(dice1.equal_dice(dice2))



Measured memory_bytes: 5628
import heapq

def main():
    [N, M] = [int(num) for num in input().split()]
    A = [int(num) for num in input().split()]
    hp = []

    for a in A:
        heapq.heappush(hp, - a)

    for i in range(M):
        expensive = heapq.heappop(hp)
        heapq.heappush(hp, expensive / 2)

    hp = [int(- a // 1) for a in hp]
    print(sum(hp))


if __name__ == '__main__':
    main()


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

int main()
{
    int N,T;
    cin >> N;
    cin >> T;
    int c[N];
    int t[N];
    for(int i = 0; i < N; ++i)
    {
        cin >> c[i];
        cin >> t[i];
    }
    int cMin;
    cMin = 10000;
    for(int i = 0; i < N; ++i)
    {
        if(t[i] <= T)
            if(c[i] < cMin)
                cMin = c[i];
    }
    
    if(cMin == 10000) cout << "TLE\n";
    else cout << cMin <<"\n";
    
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
lcm = 1

import collections
lcm_pf = collections.defaultdict(int)
for i, v in enumerate(a):
    j = 2
    pf = {}
    while j ** 2 <= v:
        ext = 0
        while v % j == 0:
            ext += 1
            v //= j
        if ext:
            pf[j] = ext
            lcm_pf[j] = max(lcm_pf[j], ext)
        j += 1
    if v != 1:
        pf[v] = 1
        lcm_pf[v] = max(lcm_pf[v], 1)
for p in lcm_pf:
    lcm = lcm * (p ** lcm_pf[p])
#import math
#for v in a:
#    lcm = (lcm // math.gcd(lcm, v)) * v

ans = 0
for v in a:
    ans = ans + (lcm // v)
    #ans = (ans + (lcm // v)) % MOD
print(ans % MOD)


Measured memory_bytes: 75092
#include <iostream>
#include <vector>
#include <utility>

typedef long long ll;
typedef std::pair<int, ll> ii;

const ll INF = (1LL << 60);

struct union_find {
  std::vector<int> p; union_find(int n) : p(n, -1) {}
  int find(int x) { return p[x] < 0 ? x : p[x] = find(p[x]); }
  int unite(int x, int y) {
    int xp = find(x), yp = find(y);
    if (xp == yp)       return false;
    if (p[xp] > p[yp])  std::swap(xp, yp);
    p[xp] += p[yp]; p[yp] = xp;
    return true;
  }
};

struct graph {
  int n;
  ll *x;
  std::vector<ii> *adj;
  bool okay_pa = true;
  graph (int n) : n(n) {
    adj = new std::vector<ii>[n];
    x = new ll[n];
    for (int u = 0; u < n; ++u)
      x[u] = INF;
  }
  void add_edge(int u, int v, int d) {
    adj[u].push_back({v, d});
    adj[v].push_back({u, -d});
  }
  void dfs(int u) {
    for (auto &[v, d] : adj[u]) {
      if (x[v] == INF) {
        x[v] = x[u] + d;
        dfs(v);
      } else if (x[v] != x[u] + d)
        okay_pa = false;
    }
  }
};

int N, M;
int L[200005], R[200005], D[200005];

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);

  std::cin >> N >> M;
  union_find uf(N);
  for (int i = 0; i < M; ++i) {
    std::cin >> L[i] >> R[i] >> D[i];
    L[i]--; R[i]--;
    if (D[i] == 0)
      uf.unite(L[i], R[i]);
  }

  graph g(N);
  for (int i = 0; i < M; ++i) {
    g.add_edge(uf.find(L[i]), uf.find(R[i]), D[i]);
    if (uf.find(L[i]) == uf.find(R[i]) and D[i] > 0) {
      std::cout << "No\n";
      return 0;
    }
  }

  for (int u = 0; u < N; ++u) {
    if (g.x[u] == INF) {
      g.x[u] = 0;
      g.dfs(u);
    }
  }

  std::cout << (g.okay_pa ? "Yes" : "No") << "\n";

  return 0;
}


Measured memory_bytes: 22168
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

pair<int, int> grid[300 * 300];

int cost(const pair<int, int> &p0, const pair<int, int> &p1)
{
    return abs(p0.first - p1.first) + abs(p0.second - p1.second);
}

vector<int> pSum[300 * 300];

int main()
{
    int H, W, D;
    cin >> H >> W >> D;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
        {
            int idx;
            cin >> idx;
            grid[idx - 1] = {i, j};
        }

    for (int i = 0; i <= H * W; i++)
    {
        int q = i / D;
        int rem = i % D;

        if (i <= D)
        {
            pSum[rem].push_back(0);
            continue;
        }
        auto p0 = grid[i - D - 1];
        auto p1 = grid[i - 1];

        pSum[rem].push_back(pSum[rem].at(q - 1) + cost(p0, p1));
    }

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        int L, R;
        cin >> L >> R;

        int hiq = R / D;
        int loq = L / D;
        int rem = L % D;

        int c = pSum[rem].at(hiq) - pSum[rem].at(loq);
        cout << c << endl;
    }

    return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<cstdio>

using namespace std;
static const int N = 100;

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

void printArray(int a[], int n){
    int k = 0;
    while(1){
        if(k==n-1) break;
        else{
            printf("%d ", a[k]);
        }
        k++;
    }
    printf("%d\n", a[n-1]);
}

int bubbleSort(int a[], int n){
    int flag = 1,v,count = 0;
    while(flag){
        flag = 0;
        for (int j = n-1; j >= 1; j--)
        {
            if (a[j]<a[j-1]){
                v = a[j-1];
                a[j-1] = a[j];
                a[j] = v;
                flag = 1;
                count++;
            }
        }
    }
    return count;
}

int main(int argc, char const *argv[])
{
    int n,m;
    int A[N];
    cin >> n;
    inputArray(A,n);
    m = bubbleSort(A,n);
    printArray(A,n);
    printf("%d\n", m);

    return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>
int main(){
int n,a,b,temp;
bool f;
scanf("%d",&n);
for(int i=0;i<n;i++){
a=b=0;
f=true;
for(int j=0;j<10;j++){
scanf("%d",&temp);
if(temp>a)a=temp;
else if(temp>b)b=temp;
else f=false;
}
if(f)printf("YES\n");
else printf("NO\n");
}
}

Measured memory_bytes: 2588
N = int(input())
A = [int(input())-1 for _ in range(N)]
ans = 0
i = 0
done = set([i])
while 1:    
  if A[i] == 1:
    print(ans+1)
    exit()
  else:
    if A[i] in done:
      print(-1)
      exit()
    else:
      i = A[i]
      done.add(i)
      ans += 1
    

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

int main() {
    int H, W;
    cin >> H >> W;

    string ai;
    vector<string> A(H);
    rep(i, H) cin >> A[i];

    bool row[H], col[W];
    rep(i, H) row[i] = false;
    rep(i, W) col[i] = false;

    rep(i, H) rep(j, W) {
        if (A[i][j] == '#') {
            row[i] = true;
            col[j] = true;
        }
    }

    rep(i, H) if (row[i]) {
        rep(j, W) if (col[j]) cout << A[i][j];
        cout << endl;
    }


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct UnionFind {
  const int n;
  V<> t; // root ? -sz : par
  UnionFind(int n) : n(n), t(n, -1) {}
  int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); }
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (-t[u] < -t[v]) swap(u, v);
    t[u] += t[v];
    t[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int size(int v) { return -t[find(v)]; }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  struct Edge {
    int u, v, w;
    bool operator<(const Edge& r) const { return w > r.w; }
  };
  priority_queue<Edge> pq;
  while (q--) {
    int a, b, c; cin >> a >> b >> c;
    pq.emplace(Edge{a, b, c});
    pq.emplace(Edge{(a + 1) % n, b, c + 1});
  }

  UnionFind uf(n);
  lint res = 0;
  while (uf.size(0) < n) {
    auto e = pq.top(); pq.pop();
    if (uf.same(e.u, e.v)) continue;
    uf.unite(e.u, e.v);
    res += e.w;
    pq.emplace(Edge{(e.u + 1) % n, (e.v + 1) % n, e.w + 2});
  }
  cout << res << '\n';
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int H, W; cin >> H >> W;
  vector<string> S(H); REP(i, H) cin >> S[i];
  const int dx[4] = {1, 0, -1, 0};
  const int dy[4] = {0, -1, 0, 1};
  int ans = 0;
  REP(i, H) {
    REP(k, W) {
      vector<vector<bool>> flag(H, vector<bool>(W, false));
      if(S[i][k] == '#') continue;
      flag[i][k] = true;
      queue<pair<pair<int, int>, int>> Q; Q.push(make_pair(make_pair(i, k), 0));
      while (!Q.empty()) {
        auto p = Q.front(); Q.pop();
        int x = p.first.first; int y = p.first.second;
        for(int i = 0; i < 4; ++i) {
          if(x + dx[i] < 0 || x + dx[i] >= H) continue;
          if(y + dy[i] < 0 || y + dy[i] >= W) continue;
          if(flag[x + dx[i]][y + dy[i]] == true) continue;
          if(S[x + dx[i]][y + dy[i]] == '#') continue;
          flag[x + dx[i]][y + dy[i]] = true;
          Q.push(make_pair(make_pair(x + dx[i], y + dy[i]), p.second + 1));
          if(ans < p.second + 1) ans = p.second + 1;
        }
      }
    }
  }
  cout << ans << endl;
}

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

int main(void)
{
  int w, h, x, y, r;
  bool flg = true;
  cin >> w >> h >> x >> y >> r;

  // ????????¢??????????????§??????
  if (y - r < 0) flg = false;
  // ???????????§??????
  if (y + r > h) flg = false;
  // ???????????§??????
  if (x - r < 0) flg = false;
  // ???????????§??????
  if (x + r > w) flg = false;
  
  // ??????
  cout << (flg ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        boolean f=true;
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        int b[]=a.clone();
        boolean f2=true;
        for(int i=1;i<n;i++){
            if(a[i]>a[i-1]){
                a[i]--;
            }
            if(a[i]<a[i-1]){
                f=false; break;
            }
        }
        b[0]--;
        for(int i=1;i<n;i++){
            if(b[i]>b[i-1]){
                b[i]--;
            }
            if(b[i]<b[i-1]){
                f2=false; break;
            }
        }
        System.out.println((f||f2)?"Yes":"No");
    }
}


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

int main()
{
    list<int> L;
    auto it = L.end();
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int query;
        cin >> query;
        if (query == 0) {
            int x;
            cin >> x;
            it = L.insert(it, x);
        }
        if (query == 1) {
            int d;
            cin >> d;
            advance(it, d);
        }
        if (query == 2) {
            it = L.erase(it);
        }
    }
    for (auto i = L.begin(); i != L.end(); i++) {
        cout << *i << endl;
    }
    return 0;
}


Measured memory_bytes: 18636
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<ll> v(n);
    rep(i, n) cin>>v[i];
    sort(v.begin(), v.end());
    vector<ll> sum(n);
    sum[0] = v[0];
    rep(i, n-1){
        sum[i+1] = sum[i] + v[i+1];
    }
    int ans = 1;
    for(int i = n-2;i>=0;i--){
        if(sum[i]*2>=v[i+1]) ans ++;
        else break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
n, m, x, y = map(int, input().split())

xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

xs.append(x)
ys.append(y)

if min(ys) - max(xs) < 1:
    print('War')
else:
    print('No War')

# exit()

# for i in range(max(xs) + 1, min(ys)):
#     if max(xs) < i and min(ys) >= i:
#         print('No War')
#         exit()

# print('War')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int N=2e5+100;
int32_t main(){
    ll n;
    cin >> n;
    cout << n*n;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  long long a[n];
  for(int i=0; i<n; i++){
    cin>>a[i];
  }
  sort(a,a+n);
  long long mi=1000000000000000;
  for(int i=0; i<=n-k; i++){
    mi=min(mi,a[i+k-1]-a[i]);
  }
  cout<<mi<<endl;
}
    
    

Measured memory_bytes: 1024
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;

const int INF = 1e9;
const int MOD = 1e9+7;
const double PI = 2*acos(0.0);

signed main()
{
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    vector<double> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    while(v.size()>1)
    {
        sort(v.begin(),v.end());
        double curr = (v[0] + v[1]) / 2;
        reverse(v.begin(),v.end());
        v.pop_back();
        v.pop_back();
        v.push_back(curr);
    }           
    cout<<setprecision(6)<<v[0]<<endl;
    return 0;
    return 0;
}

Measured memory_bytes: 256
program name

    implicit none
    integer N,i,x,max_num
    character(100) S
    read*, N
    read*, S
    N = len_trim(S)
    x = 0
    max_num = 0
    do i = 1, N, 1
        if ( S(i:i)=="I" ) then
            x = x + 1
        else
            x = x - 1
        end if
        
        if ( x > max_num ) then
            max_num = x
        end if

    end do
print*, max_num
end program

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

int main() {
  long long h;
  cin >> h;
  long long numMonster = 1;
  long long numBattle = 0;
  while (h > 0) {
    if (h == 1) {
    	cout << numBattle + numMonster*1 << endl;
      	break;
  	} else {
      	numBattle += numMonster;
    	h = h/2;
	    numMonster *= 2;  	
  	}
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
int M = 1e9 + 7;
#define PI 3.14159265
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int k;
  string s;
  cin >> k >> s;
  if (s.length() <= k)
    cout << s;
  else
  {
    string out = s.substr(0, k);
    out += "...";
    cout << out;

  }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int r,d,x;
  cin >> r >> d >> x;
  rep(i,10){
    x = r*x - d;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> S(N), T(M);
	for (int i = 0; i < N; ++i) cin >> S[i];
	for (int i = 0; i < M; ++i) cin >> T[i];
	vector<vector<int> > dp(N + 1, vector<int>(M + 1));
	vector<vector<int> > sum(N + 2, vector<int>(M + 2));
	dp[0][0] = 1;
	for (int i = 1; i <= N + 1; ++i) {
		for (int j = 1; j <= M + 1; ++j) {
			sum[i][j] = 1;
		}
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= M; ++j) {
			if (S[i - 1] == T[j - 1]) {
				dp[i][j] = sum[i][j];
			}
			sum[i + 1][j + 1] = (1LL * dp[i][j] + sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + mod) % mod;
		}
	}
	cout << sum[N + 1][M + 1] << endl;
	return 0;
}

Measured memory_bytes: 34656
K=int(input())

if K<=9:
  print(K)
else:
  p=1
  dp,old=[[1]*10],[0,1]
  n=9
  while K>n:
    old=dp[p-1]
    tmp=[0]*10
    for i in range(1,9):
      tmp[i]=old[i-1]+old[i]+old[i+1]
    tmp[9]=old[8]+old[9]
    tmp[0]=old[0]+old[1]
    dp.append(tmp)
    p+=1
    n+=sum(tmp[1:])

  ans=0
  n-=sum(tmp[1:])
  K-=n
  c=2
  for i in range(p-1,-1,-1):
    if c!=0:
      c-=1
    while K>dp[i][c]:
      K-=dp[i][c]
      c+=1
    ans+=c*10**i
  print(ans)

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;

int gcd(int x, int y){
    if (x == 0) return y;
    return gcd(y % x, x);
};

int lcm(int x, int y){
    return x * y / gcd(x, y);
};

int powint(int x, int y){
    int ret = 1;
    for (int i=0; i < y; i++) ret *= x;
    return ret;
};

int powmod(int x, int y, int m){
    if (y == 0) return 1;
    return ((powint(powmod(x, y>>1, m), 2) % m) * powint(x, (y & 1))) % m;
};

int comb(int n, int r, int m){
    if (n < r) return 0;

    if (n-r < r) r = n-r;
    int ret = 1; int d = 1;
    for (int i = n-r+1; i < n+1; i++) ret = (ret * i) % m;
    for (int i = 1; i < r+1; i++) d = (d * i) % m;
    ret *= powmod(d, m-2, m);
    return ret % m;
};

int min_arr(vector<int> x){
    int y = x[0];
    rep(i, x.size()){
        y = min(y, x[i]);
    }
    return y;
};

int mod = 1000000007;
vector<int> dx = {1, 0, 0, -1, 1, 1, -1, -1};
vector<int> dy = {0, -1, 1, 0, 1, -1, 1, -1};

map<char, int> counter(string s){
    map<char, int> count;
    rep(i, s.size()){
        count[s[i]] ++;
    }
    return count;
};

vector<vector<int>> grid_bfs(int d, int sx, int sy, vector<string> grid){
    int h = grid.size();
    int w = grid[0].size();
    queue<pair<int, int>> q; q.push({sx, sy});
    vector<vector<int>> dist(h, vector<int>(w));
    vector<vector<bool>> visited(h, vector<bool>(w));
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            dist[i][j] = -1;
            visited[i][j] = false;
        }
    }
    visited[sx][sy] = true;
    dist[sx][sy] = 0;

    vector<int> dx = {1, 0, 0, -1, 1, 1, -1, -1};
    vector<int> dy = {0, 1, -1, 0, 1, -1, 1, -1};

    while (!q.empty()){
        int x, y;
        tie(x, y) = q.front();
        q.pop();

        //２方向、４方向、８方向を設定
        for (int i = 0; i < d; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];

            if (nx < 0 || h-1 < nx) continue;
            if (ny < 0 || w-1 < ny) continue;
            if (visited[nx][ny]) continue;
            if (grid[nx][ny] == '#') continue;
            q.push({nx, ny});
            dist[nx][ny] = dist[x][y] + 1;
            visited[nx][ny] = true;
        }
        
    }
    return dist;
};

int main() {
    int n; cin >> n;
    vector<vector<int>> ball(n, vector<int>(2));
    rep(i, n) cin >> ball[i][0] >> ball[i][1];

    int ans = n;
    rep(i, n){
        rep(j, n){
            if (i == j) continue;
            lint p = ball[i][0] - ball[j][0];
            lint q = ball[i][1] - ball[j][1];
            int cnt = 0;
            rep(k, n){
                rep(l, n){
                    if (k == l) continue;
                    lint s = ball[k][0] - ball[l][0];
                    lint t = ball[k][1] - ball[l][1];
                    if (p == s && q == t) cnt ++;

                }
            }
            ans = min(ans, n - cnt);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#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 ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9+7)
#define inf (ll)(1e18)
#define lim (ll)(1e10)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5 + 5)

void solve()
{
    ll n;
    cin>>n;

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

    sort(arr,arr+n);

    ll ans = arr[n-1];
    ll ptr = n-2;
    for(int i=n-3;i>=0;i-=2)
    {
        if(i == 0)
            ans += arr[ptr--];
        else
            ans += 2*arr[ptr--];
    }

    cout<<ans;
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 5180