akhauriyash/Code-Regression huggingface dataset:
use std::cmp::{min,max};
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")
    };
}
fn main(){
    input!{
        n:i64,
        hb:[i64;n],
    }
    let mut min = hb[0];
    let mut ans = 0;
    for h in &hb {
        if min <= *h {
            ans += 1;
            min = *h;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		int ans = 0;
		
		if(s.charAt(0) == 'R') {
			if(s.charAt(1) == 'R') {
				if(s.charAt(2) == 'R') {
					System.out.println(3);
				}else {
					System.out.println(2);
				}
			}else {
				System.out.println(1);
			}
		}else if(s.charAt(1) == 'R') {
			if(s.charAt(2) == 'R') {
				System.out.println(2);
			}else {
				System.out.println(1);
			}
		}else if(s.charAt(2) == 'R') {
			System.out.println(1);
		}else {
			System.out.println(0);
		}
		
		
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
}
 


Measured memory_bytes: 35584
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
typedef unsigned long long ull;
const ull INF = 1e18;
using namespace std;

int main(){
    int num;
    rep(i,0,5){
        cin>>num;
        if(num==0){
            cout<<i+1<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 100000000001
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};


int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}


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

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    a = LI()
    u = [0]*n
    r = 1
    for l in range(n):
        if l == r:
            r += 1
        while r < n and a[r-1] <= a[r]:
            r += 1
        u[l] = r
    d = [0]*n
    r = 1
    for l in range(n):
        if l == r:
            r += 1
        while r < n and a[r-1] >= a[r]:
            r += 1
        d[l] = r
    i = 0
    for t in range(n):
        i = max(u[i],d[i])
        if i == n:
            print(t+1)
            return
    return
#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

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


Measured memory_bytes: 59376
#include <iostream>
#include <math.h>
using namespace std;
int solve();
int N,K,x[100];
 
int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++)cin >> x[i];
	solve();
	return 0;
}
 
int solve() {
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (x[i] < abs(K - x[i]))ans += 2 * x[i];
		else ans += abs(K - x[i]) * 2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
 
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll int
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
 
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
 
    int a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll k;
    cin>>k>>n;
    a=n;
    ll v[k+1];
    ll w[(k+1)*(k+1)];
    rep(i,k+1){
        v[i]=i;
        //cout<<i<<" ";
    }
    //ln;
    map<ll,ll> ma;

    rep(i,k+1){
        rep(j,k+1){
            ma[i+j]++;
        }
    }
    //ln;
    map<ll,ll> mp;

    rep(j,k+1){
    rep(i,k*2+1){
            mp[i+j]+=ma[i];
        //cout<<w[i]+j<<" ";
    }}
        //cout<<n<<endl;

    cout<<mp[a]<<endl;
    
    return 0;
}


Measured memory_bytes: 4164
//from PKU1125
main(){
	int i,n,f,k,t,dist[101][101];
	scanf("%d",&n);
		/*initialize*/
		memset(dist,11,sizeof(dist));
		for(i=1;i<=n;i++){
			dist[i][i]=0;
			scanf("%d%d",&f,&k);
			for(;k;k--){
				scanf("%d",&t);
				dist[f][t]=1;
			}
		}
		
		{/*warshall-floyd*/
			int k,i,j;
			for(k=1;k<=n;k++)
				for(i=1;i<=n;i++)
					for(j=1;j<=n;j++)
						if(dist[i][j]>dist[i][k]+dist[k][j])
							dist[i][j]=dist[i][k]+dist[k][j];
		}
		
		{/*query*/
			for(scanf("%d",&k);k;k--){
				scanf("%d%d%d",&f,&t,&n);
				printf(dist[f][t]<n?"%d\n":"NA\n",dist[f][t]+1);
			}
		}
	exit(0);
}

Measured memory_bytes: 644
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int M = scanner.nextInt();

    final long INF = -1_000_000_000_000_000L;
    long[] dist = new long[N];
    for (int i = 1; i < N; i++) dist[i] = INF;
    int[][] edges = new int[M][2];
    int[] costs = new int[M];

    for (int i = 0; i < M; i++) {
      edges[i] = new int[] {scanner.nextInt() - 1, scanner.nextInt() - 1};
      costs[i] = scanner.nextInt();
    }

    int[] prev = new int[N];
    prev[0] = -1;
    for (int i = 0; i < 2 * N; i++) {
      for (int j = 0; j < M; j++) {
        int from = edges[j][0];
        int to = edges[j][1];
        int cost = costs[j];
        if (dist[from] > INF) {
          long newValue = dist[from] + cost;
          if (newValue > dist[to]) {
            dist[to] = newValue;
            prev[to] = from;
          }
        }
      }
    }

    boolean[] visited = new boolean[N];
    int i = N - 1;
    while (i != -1) {
      visited[i] = true;
      i = prev[i];
      if (i >= 0 && visited[i]) {
        System.out.println("inf");
        return;
      }
    }
    System.out.println(dist[N - 1]);
  }
}


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

int main() {
  int n,m,k;
  cin >> n >> m >> k;
  rep(a,0,m+1){
    rep(b,0,n+1){
      if(a*n+b*(m-2*a) == k){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

int main(){

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

  int a,b;

  cin >> a >> b;

  if(a + b < 24){
    cout << a+b << endl;
  }else{
    cout << a+b-24 << endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<P> e;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        e.emplace_back(a, b);
    };

    sort(all(e));

    rep(i, n) {
        if (k > e[i].second) {
            k -= e[i].second;
        } else {
            cout << e[i].first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1400
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
	int n, k,x=1;
	cin >> n >> k;
	rep(i, n) {
		if (x * 2 <= x + k) {
			x = x * 2;
		}
		else
			x += k;
		
	}
	cout << x << endl;
	return 0;
}

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

int main(){
    ll A;
    double b;
    cin >> A >> b;
    ll ib = b * 100 + 0.5; //暗黙の型変換をするが切り捨て
    cout << (A * ib)/100 << endl;
}

Measured memory_bytes: 3724
#pragma GCC optimize(3)
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(int argc,char** argv){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c){
		cout<<"No";
		return 0;
	}
	if(a==b||b==c||a==c){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

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

int main(){

int H, W, cnt;
  cin >> H >> W;
char c[H + 2][W + 2] = {'.'};
  
  for(int i = 1;i <= H;i++){
    for(int j = 1;j <= W;j++){
    cin >> c[i][j];
    }
  }  
  
  for(int i = 1;i <= H;i++){
    for(int j = 1;j <= W;j++){
      cnt = 0;
      if(c[i][j] == '.'){
        for(int k = i - 1;k <= i + 1;k++){
          for(int l = j - 1; l <= j + 1;l++){
          if(c[k][l] == '#') cnt++;
          }
        }
      cout << cnt;
      }
      else cout << '#';
    }
    cout << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#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>

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 << 31) - 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

string s;
map<char, bool> mci;

vector<string> split(string str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

string print(ll num) {
	string res;
	int n = (1 << 12);
	while (n) {
		if (num >= n) {
			num -= n;
			res += "1";
		}
		else res += "0";
		n /= 2;
	}
	return res;
}

bool is_op(char c) {
	return (c >= 'a'&&c <= 'k') || (c == 'T') || (c == 'F');
}

bool operand(string& s, int &pos) {
	if (s[pos] == 'T')return true;
	if (s[pos] == 'F')return false;
	if (s[pos] >= 'a'&&s[pos] <= 'k')return mci[s[pos]];
}

bool formula(string& s, int &pos) {
	//cout << s[pos] << "!" << pos << endl;
	if (is_op(s[pos]))return operand(s, pos);
	bool res;
	if (s[pos] == '(') {
		pos++;
		res = formula(s, pos);
		pos++;
		if (s[pos] == '*') {
			//cout << "*" << pos << endl;
			pos++;
			res &= formula(s, pos);
		}
		else if (s[pos] == '+') {
			//cout << "+" << pos << endl;
			pos++;
			res |= formula(s, pos);
		}
		else if (s[pos] == '-') {
			//cout << "->" << pos << endl;
			pos += 2;
			bool buf = formula(s, pos);
			if (res == true && buf == false)res = false;
			else res = true;
		}
		pos++;
	}
	else if (s[pos] == '-') {
		pos++;
		res = !formula(s, pos);
	}
	//cout << pos << " " << res << endl;
	return res;
}

bool equation(string &s, int &pos) {
	vector<string> vs = split(s, '=');
	bool f = formula(vs[0], pos);
	pos = 0;
	//cout << endl;
	bool f2 = formula(vs[1], pos);
	//cout << "!!!!" << f << " " << f2 << endl;
	//bool f2 = false;
	return f == f2;
}

int main() {
	while (cin >> s&&s != "#") {
		mci.clear();
		bool f = true;
		rep(mask, (1 << 11)) {
			//if (mask == 1)break;
			//cout << mask << endl;
			int pos = 0;
			int num = mask;
			for (int i = 0; i < 11; i++) {
				if ((num >> i) & 1)mci['a' + i] = true;
				else mci['a' + i] = false;
			}
			bool g = equation(s, pos);
			//if (!g)cout << mask << " " << g << endl;
			f &= g;
		}
		if (f)cout << "YES" << endl;
		else cout << "NO" << endl;
		//cout << endl;
	}
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//子の数が分かるUnionFind
struct UFT {
private:
	vector<ll> par, rank;
	vector<ll> c_n; //子の数
	void init(ll n = 1) {
		par.resize(n); rank.resize(n); c_n.resize(n);
		for (int i = 0; i < n; i++)par[i] = i, rank[i] = 0, c_n[i] = 1;
	}
	void update(ll x) {
		if (par[x] == x)return;
		else {
			ll r = root(par[x]);
			c_n[par[x]] += c_n[x];
			par[x] = r;
			return;
		}
	}
	ll root(ll x) {
		if (par[x] == x)return x;
		else {
			ll r = root(par[x]);
			return par[x] = r;
		}
	}
public:
	UFT(int n = 1) {
		init(n);
	}
	ll weight(ll x) {
		return c_n[root(x)];
	}
	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}
	bool merge(ll x, ll y) {
		x = root(x); y = root(y);
		if (x == y)false;
		if (rank[x] < rank[y])swap(x, y);
		if (rank[x] == rank[y])rank[x]++;
		par[y] = x;
		update(y);
		return true;
	}
};

int main() {
	ll N, M;
	cin >> N >> M;
	vector<pair<ll, ll> > bridge(M);
	for (int i = 0; i < M; i++) {
		cin >> bridge[i].first >> bridge[i].second;
		bridge[i].first--; bridge[i].second--;
	}
	vector<ll> A(M+1);
	UFT uft(N);
	A[M] = N * (N - 1) / 2;
	for (int i = M-1; i >= 0; i--) {
		if (!uft.issame(bridge[i].first, bridge[i].second)) {
			A[i] = A[i+1] - uft.weight(bridge[i].first)*uft.weight(bridge[i].second);
			uft.merge(bridge[i].first, bridge[i].second);
		}
		else {
			A[i] = A[i+1];
		}
	}
	for (int i = 1; i <= M; i++)cout << A[i] << endl;
}

Measured memory_bytes: 6016
#include<iostream>
#include<algorithm>
#define FOR(i,e) for(int i=0;i<(int)(e);i++)
using namespace std;

int main(){
  double pb[100][5001];
  int x,y,z;
  int v[4],e[100],a[100];

  while(cin >> x >> y >> z && (x||y||z)){

    FOR(i,x)cin >> v[i];
    FOR(i,y+1)e[i] = a[i] = 0;
    FOR(i,z){
      int n,m,l;
      cin >> n >> m >> l;
      e[n] = m; a[n] = l;
    }

    FOR(i,y+1)FOR(j,5001)pb[i][j] = 0.0;
    pb[0][0] = 1.0;

    FOR(i,y)FOR(j,5001){
      FOR(k,x){
	if(pb[i][j] == 0.0)continue;
	int next = min(y,i+v[k]),value = j;
	if(e[next] == 1)next = min(y,next+a[next]);
	else if(e[next] == 2)value = j + a[next];
	else if(e[next] == 3)value = max(0,j-a[next]);
	pb[next][value] += pb[i][j]/x;
      }
    }

    double ans = 0.0;
    FOR(i,5001)ans += pb[y][i] * i;
    cout << (int)(ans) << endl;
  }
}

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int minimum = 100;
	int maxim = max(a,max(b,c));
	int maxim1 = maxim + 1;
	int ans = 0;
	if(maxim%2 == (a+b+c)%2){
		ans = (3*maxim - (a+b+c))/2;
	}
	if(maxim1%2 == (a+b+c)%2){
		ans = (3*maxim1 - (a+b+c))/2;
	}
	cout << ans << endl;
 }

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int (i)=a;(i)<=(b);++(i))

const int maxn =1e4 + 10;

long long a[200005];
long long l[200005],r[200005];
int main() {

  long long n;
  cin>>n;
  a[0] = 0;

  FOR(i,1,n){
    cin >> a[i];
    a[i]+=a[i-1];
  }

  int l=1,r=3;
  long long ans = 1e18;
  FOR(mid,2,n-2){
    while(l<mid&&abs(a[mid]-a[l]-a[l]) >= abs(a[mid]-a[l+1]-a[l+1])) l++;
    while(r<n&&abs(a[n]-a[r]-(a[r]-a[mid])) >= abs(a[n]-a[r+1]-(a[r+1]-a[mid]))) r++;

    long long MAX = max(a[l],max(a[mid]-a[l],max(a[r]-a[mid],a[n]-a[r])));
    long long MIN = min(a[l],min(a[mid]-a[l],min(a[r]-a[mid],a[n]-a[r])));
    ans = min(ans,MAX-MIN); 
  }

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

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <functional>
using namespace std;

int n, t[100009], x[100009], y[100009];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	for (int i = 1; i <= n; i++) {
		int P1 = t[i] - t[i - 1];
		int P2 = abs(x[i] - x[i - 1]);
		int P3 = abs(y[i] - y[i - 1]);
		if (P1 < P2 + P3 || (P2 + P3) % 2 != P1 % 2) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}


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

int main(){
int N;  cin>>N;
vector<int>T(N);
int sum=0;  
  for(int i=1; i<=N; i++){
   cin>>T[i];
   sum+=T[i];}
  
int M;  cin>>M;
  while(M--){
   int allsum=sum;
    int P, X;
    cin>>P>>X;
    cout<<allsum-T[P]+X<<endl;
  }
  
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

r,g,b,n=map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        if (n-r*i-g*j)%b==0 and (n-r*i-g*j)>=0:
            count+=1
            # print(i,j)
print(count)

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

int main(void)
{
    string S;
    cin >> S;

    int length = S.size() - 1;
    string left;
    string right;
    int ans = 1;
    while (length >= 2)
    {
        if (length % 2 != 0)
        {
            length -= 1;
            continue;
        }
        left = S.substr(0, length / 2);
        // cout << left << endl;
        right = S.substr(length / 2, length / 2);
        // cout << right << endl;

        bool isEqual = true;
        if (left != right)
        {
            isEqual = false;
        }

        if (isEqual == true)
        {
            ans = length;
            break;
        }
        length -= 1;
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


int t, n, m, k, a[300010], q, l, r;
int h, w;
char c[10][10];
char d[10][10];

void dd(){

for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
        d[i][j]=c[i][j];
    }
}

}



int clr(int row, int col){




for(int b=0;  ( ((int) 1)<<b)<=row; b++){
    if( ( (( ((int) 1)<<b))&row)>((int)0) ){
        for(int j=1; j<=w; j++){
            d[b+1][j]='.';
        }

    }
}
for(int b=0;  ( ((int) 1)<<b)<=col; b++){
    if( ( (( ((int) 1)<<b))&col)> ((int)0) ){
        for(int i=1; i<=h; i++){
            d[i][b+1]='.';
        }
    }
}




int res=0;
for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
        if(d[i][j]=='#'){
            res++;
        }

    }

}

return res;
}





int32_t main(){
INIT
cin>>h>>w>>k;
for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
        cin>>c[i][j];
    }
}



int res=0;



for(int i=0; i<( (int)( ( (int)1)<<(h) ) ); i++){
    for(int j=0; j<( (int)( ((int) 1)<<(w) ) ); j++ ){
    dd();
    int bl=clr(i, j);
    if(bl==k){res++;}
    }
}

cout<<res;


return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define hell 1000000007  
#define hell2 998244353 
#define pi 3.14159265358979323846

int solve(){   
    int n,m,k;
    cin>>n>>m>>k;
    int a[n],b[m];
    rep(i,0,n) cin>>a[i];
    rep(i,0,m) cin>>b[i];
    int s[n],t[m];
    s[0]=a[0];
    rep(i,1,n) s[i]=s[i-1]+a[i];
    t[0]=b[0];
    rep(i,1,m) t[i]=t[i-1]+b[i];
    vi v,u;
    rep(i,0,n) v.pb(s[i]);
    rep(i,0,m) u.pb(t[i]);
    int ans=ub(all(u),k)-u.begin();
    //cout<<ans<<" ";
    rep(i,0,n){
        if(s[i]>k) continue;
        int x=i+1+ub(all(u),k-s[i])-u.begin();
        ans=max(ans,x);
    }
    cout<<ans;

    return 0;   
}
 
signed main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 14200
s = str(input())
s = list(s)

for i in range(len(s)):
    s[i] = ord(s[i])

for i in range(len(s)):
    s[i] = s[i] - 97

arr = [0] * 26

for i in range(len(s)):
    arr[s[i]] += 1

flag = True
for i in range(len(arr)):
    if arr[i] >= 2:
        flag = False

if flag:
    print('yes')
else:
    print('no')


Measured memory_bytes: 3064
from fractions import gcd
a,b,c=map(int,input().split())
if a%2 or b%2 or c%2:
  print(0)
  exit()
if a==b==c:
  print(-1)
  exit()
x=abs(a-b)
y=abs(b-c)
z=abs(c-a)
t=gcd(gcd(x,y),z)
for i in range(1,100):
  if t%2:
    print(i-1)
    break
  else:
    t=t//2

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

int main() {
  int N, A;
  cin >> N >> A;
  
  if((N * A) % 2 == 0){
  	cout << "Even" << endl; 
  }
  
   else{
  	cout << "Odd" << endl; 
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int a[10];
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    if((a[1]==a[2]&&a[1]!=a[3])||(a[3]==a[2]&&a[1]!=a[2])) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<cctype>
#include<cmath>
#include<queue> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  
  int A,B,C,D,i,ans=102,end=0;
  cin >> A >> B >> C >> D;
  if(D<=A || B<=C){
    cout << 0 << endl;
  }else if(C<=A && A<D && D<=B){
    cout << D-A << endl; 
  }else if(A<=C && C<B && B<=D){
    cout << B-C << endl;
  }else if(A<=C && D<=B){
    cout << D-C << endl;
  }else if(C<=A && B<=D){
    cout << B-A << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

    const ll N = 2e5 + 7;
    const ll mod = 1e9 + 7;
    const ll inf = 1e9;

ll x;

void solve(){
    cin >> x;
    for(ll i = -1000; i <= 1000; ++ i){
        for(ll j = -1000; j <= 1000; ++ j){
            ll a = (i * i * i * i * i);
            ll b = (j * j * j * j * j);
            if(a - b == x){
                cout << i << " " << j;
                exit(0);
            }
        }
    }
}

int main(){
    TIME
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**



**/


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    int ans = INF;
    FOR(i, 1, 1000001)if(N % i == 0){
        int j = N / i;
        Min(ans, i + j - 2);
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    sort(a, a + n);

    cout << a[2] - a[0] << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC097 {
	class ABC097_A {
		static void Main(string[] args) {
			var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var AB = Math.Abs(input[0] - input[1]);
			var BC = Math.Abs(input[1] - input[2]);
			var CA = Math.Abs(input[2] - input[0]);
			var D = input[3];

			if(CA <= D) {
				Console.WriteLine("Yes");
				return;
			}

			if(AB <= D && BC <= D) {
				Console.WriteLine("Yes");
				return;
			}

			Console.WriteLine("No");
		}
	}
}


Measured memory_bytes: 13268
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int n, max = -1000000, min = 1000000, input;
    long sum = 0;

    Scanner in = new Scanner(System.in);
    n = in.nextInt();

    for(int i=0; i<n; i++){
        input = in.nextInt();
        if(input > max){
            max = input;
        }
        if( input < min){
            min = input;
        }
        sum += input;
    }
    
    System.out.println(min + " " + max + " " + sum);
  }
}

Measured memory_bytes: 41108
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;
class student{
	public:
		int num;
		int order;
};

bool cmp(const student &a, const student &b){
	return a.order < b.order ;
}

int main(){
	int N;
	cin >> N;
	std::vector<student> A(N);

	for (int i = 0; i < N; i++)
	{
		A[i].num = i+1;
		cin >> A[i].order;
	}

	sort(A.begin(),A.end(),cmp);
	for (int i = 0; i < N; i++)
	{
		cout << A[i].num << " " ;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
 
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  using ld = long double;
  int n;
  cin >> n;
  vector<int> a(n);
  multiset<ld> s;
  for (int &z : a) cin >> z, s.insert((ld) z);
  while (SZ(s) > 1) {
    auto it = s.begin();
    ld x = *it;
    s.erase(s.begin());
    it = s.begin();
    ld y = *it;
    s.erase(s.begin());
    s.insert((x + y) / 2);
  }
  cout.precision(10);
  cout << fixed << *s.begin() << '\n';
    
  return 0;
}


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

int main() {
    lint N;
    cin >> N;

    vector<lint> A(N);
    for(auto& elem : A)  cin >> elem;

    vector<lint> sum(N+1, 0);
    for(int i=0; i<N; i++) sum[i+1] = sum[i] + A[i];

    lint ans = 1e18;
    for(lint j=0; j<=N; j++) {
        lint ok, ng;
        // ok: sum[0,i] <= sum[i,j]
        ok = 0;
        ng = j;
        while(ng - ok > 1) {
            lint mid = (ok+ng) / 2;
            (sum[mid]-sum[0] <= sum[j]-sum[mid] ? ok : ng) = mid;
        }
        lint i0 = ok, i1 = min(j,ok+1);

        // ok: sum[j,k] <= sum[k,N]
        ok = j;
        ng = N;
        while(ng - ok > 1) {
            lint mid = (ok+ng) / 2;
            (sum[mid]-sum[j] <= sum[N]-sum[mid] ? ok : ng) = mid;
        }
        lint k0 = ok, k1 = min(N,ok+1);

        lint res = 1e18;
        for(auto i : {i0, i1})
        for(auto k : {k0, k1}) {
            lint P = sum[i] - sum[0];
            lint Q = sum[j] - sum[i];
            lint R = sum[k] - sum[j];
            lint S = sum[N] - sum[k];
            lint mx = max({P,Q,R,S});
            lint mn = min({P,Q,R,S});
            res = min(res, mx-mn);
        }
        ans = min(res, ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
N,Y=map(int,input().split())
for x in range(N+1):
    for y in range(N+1):
        if 10000*x+5000*y+(N-x-y)*1000==Y and x+y<=N:
            print(x,y,N-x-y)
            exit()
else:
    print(-1,-1,-1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N, ans = 0;
    cin >> N;
    vector<int> d(N,0);
    for (int i = 0; i < N;i++)
        cin >> d[i];
    for (int i = 0; i < N-1;i++){
        for (int j = i + 1; j < N;j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n, t, a;
    cin >> n;
    cin >> t >> a;
    vector<int>hn(n);
    for(int i = 0; i < n; i++){
        cin >> hn.at(i);
    }
    double num = 10000;
    int ans;
    for(int i = 0; i < n; i++){
        double tmp = abs(a - (t - hn.at(i) * 0.006));
        if(tmp < num){
            num = tmp;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    solve();
    return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < N-1; i++) {
        if (a[i] == i+1) {
            swap(a[i], a[i+1]);
            ans++;
        }
    }
    if (a[N-1] == N) ans++;
    cout << ans << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int st,si,he,n,r,low,mid;
  while(cin >> st >> si >> he&&st){
    cin >> n;
    low = min(st,min(si,he));
    if(st <= si && si <= he){
      mid = si;
    }
    else if(si <= st && st <= he){
      mid = st;
    }
    else{
      mid = he;
    }
    rep(i,n){
      cin >> r;
      if(low * low + mid * mid < r*r*4){
        cout << "OK"<<endl;
      }
      else{
        cout << "NA"<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3072
from itertools import accumulate
from bisect import bisect_left, bisect_right
N, M = map(int, input().split())
*A, = map(int, input().split())
A.sort()
acc = list(accumulate(A[::-1]))[::-1]+[0]


def isok(x):
    cnt = 0
    for a in A:
        cnt += N - bisect_left(A, x-a)
    return cnt >= M


l = 0
r = 202020
while l+1 < r:
    m = (l+r)//2
    if isok(m):
        l = m
    else:
        r = m

ans = 0
cnt = 0
for a in A:
    i = bisect_left(A, l-a)
    ans += a*(N-i) + acc[i]
    cnt += N-i
if cnt > M:
    ans -= l * (cnt-M)
print(ans)


Measured memory_bytes: 20752
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	r, D, x := nextInt(), nextInt(), nextInt()
	prev := x
	for i := 0; i < 10; i++ {
		prev = r*prev - D
		fmt.Println(prev)

	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}

// ここから拝借
// https://shoman.hatenablog.com/entry/2020/02/25/185456
// Stackは[]intのエイリアス
type Stack []int

// Push adds an element
func (s *Stack) Push(v int) {
	*s = append(*s, v)
}

// Pop removes the top element and return it
func (s *Stack) Pop() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	v := (*s)[len(*s)-1]
	*s = (*s)[:len(*s)-1]
	return v, nil
}

// Peek returns the top value
func (s *Stack) Peek() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	return (*s)[len(*s)-1], nil
}

// Size returns the length of stack
func (s *Stack) Size() int {
	return len(*s)
}

// Empty returns true when stack is empty
func (s *Stack) Empty() bool {
	return s.Size() == 0
}

// NewStack generates stack
func NewStack() *Stack {
	s := new(Stack)
	return s
}


Measured memory_bytes: 1812
#!/usr/bin/env python3

import sys
import math

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return

def enumerate_factor(x):
    i = 1
    factors = []
    while i * i <= x:
        if x % i == 0:
            factors.append(i)
            if x // i != i:
                factors.append(x // i)
        i += 1
    return factors

def main():
    x = read(int)
    
    boundary = math.ceil(math.pow(x, 1/5))
    for factor in enumerate_factor(x):
        f = math.ceil(math.pow(factor, 1/5))
        for b in range(-boundary * 10, boundary * 10):
            a = b + factor
            if a**5 - b**5 == x:
                print(f"{a} {b}")
                return
            a = b - factor
            if a**5 - b**5 == x:
                print(f"{a} {b}")
                return

if __name__ == "__main__":
    main()


Measured memory_bytes: 68432
#include<stdio.h>

int main()
{
	int a[5]={0},max,min;
	int i,j,imax;
	char c;

	for(i=0;i<5;i++)
	{
		scanf("%d",a+i);
		scanf("%c",&c);
	}
	max =a[0];
	min =a[0];
	for(i=0;i<5;i++)
	{
		for(j=0;j<5;j++)
		{
			if(a[j]>=max)
			{
				max=a[j];
				imax=j;
			}
			else if(min>a[j])
			{
				min=a[j];
			}
		}
		if(i==4)
			printf("%d\n",a[imax]);
		else
			printf("%d ",a[imax]);
		a[imax]=min-1;/*勝ち抜け*/
		max=min;
	}

	return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

struct warshall_floyd {
  const long long INF = 0x3f3f3f3f3f3f3f3f;
  vector<vector<long long>> d;
  const int n;

  warshall_floyd(int n) : n(n) {
    d.assign(n,vector<long long>(n));
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        d[i][j] = i == j ? 0 : INF;
  }

  void add_edge(int u, int v, int cost) {
    d[u][v] = cost;
    d[v][u] = cost;
  }

  void solve() {
    for (int k = 0; k < n; k++)
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }
};

const int MAX_N = 300;
int n,m,l;
vi g[MAX_N];

int main()
{
  fastio();

  cin >> n >> m >> l;

  warshall_floyd wf(n);

  forn(i,m) {
    int a,b,c;
    cin >> a >> b >> c;
    a--,b--;
    if (c <= l) {
      wf.add_edge(a, b, c);
    }
  }

  wf.solve();

  warshall_floyd wf2(n);

  forn(i,n) forn(j,n) {
    if (i != j && wf.d[i][j] <= l)
      wf2.add_edge(i, j, 1);
  }
  wf2.solve();

  int q; cin >> q;
  while (q--) {
    int s,t; cin >> s >> t;
    s--,t--;
    if (wf2.d[s][t] == wf2.INF)
      cout << -1 << endl;
    else
      cout << wf2.d[s][t]-1 << endl;
  }

  return 0;
}


Measured memory_bytes: 2048
/*
 * 2490.cc: Parentheses
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int k = 0;

  for (int i = 0; i < n; i++) {
    char pi;
    int xi;
    cin >> pi >> xi;

    k = (pi == '(') ? k + xi : k - xi;
    if (k < 0) break;
  }

  cout << (k == 0 ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 1160
n,k = map(int,input().split())
a = list(map(int,input().split()))
next = a[0]
tmp_list = [a[0]]
roop_list = []
tmp_set = set([a[0]])
while(True):
    next = a[next-1]
    if next in tmp_set:
        hajimari = tmp_list.index(next)
        roop_list = tmp_list[hajimari:]
        break
    tmp_set.add(next)
    tmp_list.append(next)
if k <= hajimari:
    print(tmp_list[k-1])
else:
    print(roop_list[((k-hajimari)%len(roop_list))-1])

Measured memory_bytes: 32340
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
string s;
int main()
{
    ft
    ll t,i,j,n,m=LLONG_MAX,c;
    cin>>s;
    n=s.size();
    for(i=0; i<n; i++)
    {
        if(i+3<=n)
        {
            c=0;
            for(j=i; j<i+3; j++)
            {
                c=(c*10)+s[j]-48;
            }
            c=abs(753ll-c);
            m=min(m,c);
        }
    }
    cout<<m<<"\n";
    return 0;
}

Measured memory_bytes: 256
import math

a, b = map(int, input().split(' '))
v_a_min = math.ceil(a * 25 / 2)
v_a_max = math.floor((a + 1) * 25 / 2) if (a + 1) % 2 != 0 else int((a + 1) * 25 / 2) - 1
v_a_set = set(range(v_a_min, v_a_max + 1))
v_b_min = b * 10
v_b_max = (b + 1) * 10 - 1
v_b_set = set(range(v_b_min, v_b_max + 1))

v_set = v_a_set & v_b_set
v = min(v_set) if v_set else -1

print(v)

Measured memory_bytes: 3060