akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String str = reader.readLine();
			
			Dice dice = new Dice();
			dice.setLabel(str);
			String order = reader.readLine();
			dice.roll(order);
			System.out.println(dice.getTopLabel());
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class Dice {
	
	String[] label;
	String str;
	
	public void setLabel(String str) {
		this.str = str;
		
		for (int i = 0; i < 6; i++) {
			label = str.split(" ");
		}
	}
	
	public String getTopLabel() {
		return label[0];
	}
	
	public void roll(String order) {
		String[] arr = new String[4];
		for (int i = 0; i < order.length(); i++) {
			String dir = String.valueOf(order.charAt(i));
			
			if ("N".equals(dir)) {;
				arr[0] = label[1];
				arr[1] = label[5];
				arr[2] = label[4];
				arr[3] = label[0];
				
				label[0] = arr[0];
				label[1] = arr[1];
				label[5] = arr[2];
				label[4] = arr[3];
			} else if ("E".equals(dir)) {
				arr[0] = label[3];
				arr[1] = label[0];
				arr[2] = label[2];
				arr[3] = label[5];
				
				label[0] = arr[0];
				label[2] = arr[1];
				label[5] = arr[2];
				label[3] = arr[3];
			} else if ("W".equals(dir)) {
				arr[0] = label[2];
				arr[1] = label[5];
				arr[2] = label[3];
				arr[3] = label[0];
				
				label[0] = arr[0];
				label[2] = arr[1];
				label[5] = arr[2];
				label[3] = arr[3];
			} else if ("S".equals(dir)) {
				arr[0] = label[4];
				arr[1] = label[0];
				arr[2] = label[1];
				arr[3] = label[5];
				
				label[0] = arr[0];
				label[1] = arr[1];
				label[5] = arr[2];
				label[4] = arr[3];
			}

		}
	}
	
}

Measured memory_bytes: 24344
import math

is_primes = [False] * (10 ** 5 + 1)
def is_prime(n):
    if n == 1: return False
    if is_primes[n]:
        return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    is_primes[n] = True
    return True


Q = int(input())
total = [0] * (10 ** 5 + 1)
for i in range(1, 10**5+1):
    if is_prime(i) and is_prime((i + 1) // 2):
        total[i] = total[i-1] + 1
    else:
        total[i] = total[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(total[r] - total[l-1])

Measured memory_bytes: 4980
<?php

fscanf(STDIN, "%d %d", $a, $b);

$area   = getArea($a, $b);
$circum = getCircum($a, $b);

echo sprintf("%d %d", $area, $circum), PHP_EOL;

function getArea($length, $breadth)
{
    return $length * $breadth;
}

function getCircum($length, $breadth)
{
    return ($length + $breadth) * 2;
}

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

int main(){
  int A,B; cin >> A >> B;
  int result=-1;
  for(int i=1; i<=1500; i++){
    if(floor(0.08*(double)i)==A&&floor(0.1*(double)i)==B){
      result=i;
      break;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)

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

int main() {
  int N; cin >> N;
  ll ans = 0;
  FOR(i,1,N) ans += i;
  cout << ans;

  return 0;
}

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

int main() {
    string S;
    int ans = 0;
    int tmp = 0;
    cin >> S;
    for(char c : S){
      if(c == 'A' || c == 'C' || c == 'G' || c == 'T'){
        tmp++;
        ans = max(ans, tmp);
      }else{
        tmp = 0;
      }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;


int main(){
    int N,M,C;
    cin >> N >> M >> C;
    int b[M];
    int ans = 0;
    for(int i = 0; i < M; i++) cin >> b[i];
    for(int i = 0; i < N; i++){
        int sum = 0;
        for(int j = 0; j < M; j++){
            int a;
            cin >> a;
            sum += b[j] * a;
        }
        if(sum + C > 0) ans++; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn main() {
    input! {
        a: usize,
        mut b: usize,
        mut c: usize,
        k: usize,
    }
    let mut s = 0;
    while a >= b {
        b *= 2;
        s += 1;
    }
    while b >= c {
        c *= 2;
        s += 1;
    }
    if s <= k {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2112
/**
 *      ABC 109 D
 *      author  : kyomukyomupurin
 *      created : 2018-09-08 21:26:33
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int H, W; cin >> H >> W;
    int a[H][W] = {};
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> a[i][j];
        }
    }
    int count = 0;
    int b[H][W] = {};
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            b[i][j] = a[i][j];
        }        
    }

    if (H == 1 && W == 1) {
        cout << 0 << endl; return 0;
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W ; ++j) {
            if (b[i][j] % 2 == 1){
                ++count;
                if (i != H - 1 && j != W - 1){
                    --b[i][j]; ++b[i][j + 1];
                }
                else if (i != H - 1 && j == W - 1){
                    --b[i][j]; ++b[i + 1][j];
                }
                else if (i == H - 1 && j != W - 1){
                    --b[i][j]; ++b[i][j + 1];
                }
                /*
                else if (i == H - 1 && j == W - 1){
                    --b[i][j]; ++b[i][j - 1];
                }
                */
            }            
        }        
    }

    cout << count << endl;

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W ; ++j) {
            if (a[i][j] % 2 == 1){
                if (i != H - 1 && j != W - 1){
                    --a[i][j]; ++a[i][j + 1];
                    cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2 << endl;
                }
                else if (i != H - 1 && j == W - 1){
                    --a[i][j]; ++a[i + 1][j];
                    cout << i + 1 << " " << j + 1 << " " << i + 2 << " " << j + 1 << endl;
                }
                else if (i == H - 1 && j != W - 1){
                    --a[i][j]; ++a[i][j + 1];
                    cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2 << endl;
                }
                
                else if (i == H - 1 && j == W - 1){
                    --a[i][j]; ++a[i][j - 1];
                    cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j << endl;
                }
                
            }
        }
    }

    return 0;
}


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

int main(){
    int H, W;
    
    while(1){
    cin >> H >> W;
    if( H == 0 && W == 0) break;
    
    for( int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if( i == 0 || i == H-1 || j == 0 || j == W-1 ){
            cout << "#";
        }else{
            cout << ".";
        }
      }
      cout << "\n";
    }
    cout << endl;
}
return 0;
}


Measured memory_bytes: 2984
from heapq import *
n,h=map(int,input().split())
k=[]
for _ in [0]*n:
  a,b=map(int,input().split())
  heappush(k,(-a,1))
  heappush(k,(-b,0))
ans=0
while h>0:
  a,i=heappop(k)
  a=-a
  if i:
    ans+=(h+a-1)//a
    break
  else:
    ans+=1
    h-=a
print(ans)

Measured memory_bytes: 95388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, a[123321];
ll ans;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = 1; i <= n; ++i) {
		ans += a[i] / 2; a[i] %= 2;
		if (i < n) {
			int v = min(a[i], a[i + 1]);
			ans += v; a[i + 1] -= v;
		}
	}
	printf("%lld", ans);
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
  char line[100];
  int a, b;
  char op;
  while(1){
	fgets(line, sizeof(line), stdin);
	sscanf(line, "%d %c %d", &a, &op, &b);
	if(op=='?')
	  break;
	switch(op){
	case '+':
	  printf("%d\n", a+b);
	  break;
	case '-':
	  printf("%d\n", a-b);
	  break;
	case '*':
	  printf("%d\n", a*b);
	  break;
	case '/':
	  printf("%d\n", a/b);
	  break;
	default:
	  break;
}
}
  return 0;
}



Measured memory_bytes: 2044
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int INF = 1000000000;
const double PI = 3.1415926535897932384626433832795;

// N, E, S, W
const int dx[4] = { 1, 0, -1, 0};
const int dy[4] = { 0, 1, 0, -1};

using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;

//==============================================
int n;
vi color, D;
vector<vector<pii>> G;

void print() {
	REP(i, n) {
		cout << i << " " << D[i] << "\n";
	}
}

void solve() {
	priority_queue<int, vector<pii>, greater<pii> > PQ;
	PQ.push(make_pair(0, 0));
	D[0] = 0;

	while (!PQ.empty()) {
		pii p = PQ.top(); PQ.pop();
		int u = p.second;
		color[u] = 2;
		if (D[u] < p.first) {
			continue;
		}

		REP(i, G[u].size()) {
			int j = G[u][i].first;
			int v = G[u][i].second;

			if (color[j] == 2) continue;
			if (D[u] + v < D[j]) {
				D[j] = D[u] + v;
				color[j] = 1;
				PQ.push(make_pair(D[j], j));
			}
		}
	}
	print();
}

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

	cin >> n;

	color.resize(n);
	D.resize(n, INF);
	G.resize(n);

	int u, k, id, c;
	REP(i, n) {
		cin >> u >> k;
		REP(i, k) {
			cin >> id >> c;
			G[u].push_back(make_pair(id, c));
		}
	}

	solve();
	return 0;
}

Measured memory_bytes: 7964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};

int main(){
    int a,b,c;
    cin>>a>>b>>c;

    if((a==b&&b==c) || (a!=b&&c!=b&&a!=c)) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	int a[4][13] = {0};
	while(n--)
	{
		getchar();
		char c;
		int b;
		scanf("%c %d", &c,&b);
		
		if(c == 'S')
		{
			a[0][b-1]=1;
		}
		if(c == 'H')
		{
			a[1][b-1]=1;
		}
		if(c == 'C')
		{
			a[2][b-1]=1;
		}
		if(c == 'D')
		{
			a[3][b-1]=1;
		}
	}
	int i,j;
	for(i=0; i<4; i++)
	{
		for(j=0; j<13; j++)
		{
			if(a[i][j]==0)
			{
				if(i==0)printf("S %d\n", j+1);
				if(i==1)printf("H %d\n", j+1);
				if(i==2)printf("C %d\n", j+1);
				if(i==3)printf("D %d\n", j+1);
			}
		}
	}
	
	return 0;
 }


Measured memory_bytes: 2720
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

struct RollingHash
{
  i64 base1 = 1009, base2 = 1007;
  i64 mod1 = 1000000007, mod2 = 1000000009;
  vector<i64> hash1, hash2;
  vector<i64> pow1, pow2;
  void init(string s)
  {
    i64 n = s.size();
    hash1.resize(n + 1, 0);
    hash2.resize(n + 1, 0);
    pow1.resize(n + 1, 1);
    pow2.resize(n + 1, 1);
    for (i64 i = 0; i < n; i++)
    {
      hash1[i + 1] = (hash1[i] + s[i]) * base1 % mod1;
      hash2[i + 1] = (hash2[i] + s[i]) * base2 % mod2;
      pow1[i + 1] = pow1[i] * base1 % mod1;
      pow2[i + 1] = pow2[i] * base2 % mod2;
    }
  }

  pair<i64, i64> get(i64 l, i64 r)
  {
    i64 t1 = ((hash1[r] - hash1[l] * pow1[r - l]) % mod1 + mod1) % mod1;
    i64 t2 = ((hash2[r] - hash2[l] * pow2[r - l]) % mod2 + mod2) % mod2;
    return {t1, t2};
  }
};

RollingHash rh;

bool check(i64 l, i64 n, string s)
{
  set<pair<i64, i64>> c;
  for (i64 i = 0; i <= n - l - l; i++)
  {
    c.insert(rh.get(i, i + l));
    if (c.count(rh.get(i + l, i + l * 2)))
      return true;
  }
  return false;
}

int main()
{
  i64 n;
  string s;
  cin >> n >> s;
  rh.init(s);
  i64 l = 0, r = n;
  while (1 < r - l)
  {
    i64 mid = (r + l) / 2;
    if (check(mid, n, s))
      l = mid;
    else
      r = mid;
  }
  cout << l << endl;
  return 0;
}


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

using namespace std;
#define int long long
int po[63];
int f(int x)
{
    for(int i=62;i>=0;i--)
    {
        if(po[i] & x)
        {
            return i;
        }
    }
    return -1;
}
vector <int> basis(vector <int> v)
{
    if(v.size()==1) return v;
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    if(v[0]==0)
    {
        vector <int> ans;
        return ans;
    }
    int n=v.size();
    vector <int> g;
    for(int i=1;i<n;++i)
    {
        if(f(v[i])==f(v[0]))
        {
            v[i]=v[i]^v[0];
        }
        g.push_back(v[i]);
    }
    vector <int> ans=basis(g);
    ans.insert(ans.begin(),v[0]);
    return ans;
}
bool can(vector <int> v,int x)
{
    int n=v.size();
    for(int i=0;i<n;++i)
    {
        if(x==0)
        {
            return true;
        }
        if(f(x)==f(v[i]))
        {
            x^=v[i];
        }
    }
    return (x==0);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int u=1;
    for(int i=0;i<63;++i)
    {
        po[i]=u;
        u*=2;
    }
    int t;
    cin>>t;
    while(t--)
    {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    string s;
    cin>>s;
    vector <int> v;
    bool h=true;
    for(int i=(n-1);i>=0;i--)
    {
        if(s[i]=='0')
        {
            v.push_back(a[i]);
            v=basis(v);
        }
        else
        {
            if(!can(v,a[i]))
            {
                 h=false;
                 break;
            }
        }
    }
    if(h)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<1<<endl;
    }
    }
    return 0;
}


Measured memory_bytes: 3684
n = int(input())
a = list(map(int,input().split()))
while True:
    m = max(a)
    for i in range(n):
        if a[i] > 0 and a[i] < m:
            m = a[i]
    ind = a.index(m)
    count = 0
    for i in range(n):
        if i != ind:
            a[i] = a[i]%m
        if a[i] == 0:
            count += 1
    if count == n-1:
        print(a[ind])
        break

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

int main() {
  long long K, A, B;
  cin >> K >> A >> B;
  if (B - A > 2)
    cout << (K - (A - 1)) / 2 * (B - A) + (K - (A - 1)) % 2 + A << endl;
  else
    cout << K + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    
    vector<int> ele;
    while(N > 0){
        ele.push_back(N % 10);
        N /= 10;
    }
    
    if((ele[0] == ele[1] && ele[2] == ele[1]) || (ele[1] == ele[2] && ele[2] == ele[3])){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int n;
    cin >> n;
    cout << ((n / 3 == 0) ? 0 : n / 3) << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    else:
        s = list(map(int, input().split(' ')))

    times = 0
    old_nums = [-1] * n
    while old_nums != s:
        new_nums = []
        for i in s:
            new_nums.append(s.count(i))
        old_nums = s[::]
        s = new_nums[::]
        times += 1
    print(times - 1)
    print(' '.join(map(str, s)))

Measured memory_bytes: 6724
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
using namespace std;
int x[100],y[100],dp[100][100010];
signed main(){
	int a,b;
	cin>>a>>b;
	f(i,a){
		cin>>x[i]>>y[i];
		f(j,x[i]){
			if(i) dp[i][j]=dp[i-1][j];
		}
		for(int j=x[i];j<=b;j++){
			if(i) dp[i][j]=max({dp[i][j],dp[i-1][j-x[i]]+y[i],dp[i-1][j]});
			else dp[i][j]=y[i];
		}
	}
	int ans=0;
	f(i,b+1){
		ans=max(ans,dp[a-1][i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 78336
#include <iostream>
#include <queue>

using namespace std;

int main(){
  long long int K, tmp;
  queue<long long int> q;
  cin >> K;
  for(int i=1; i<=9; i++) q.push(i);
  for(int i=0; i<K; i++){
    tmp = q.front();
    q.pop();
    if(tmp%10!=0) q.push(10*tmp+(tmp%10)-1);
    q.push(10*tmp+(tmp%10));
    if(tmp%10!=9) q.push(10*tmp+(tmp%10)+1);
  }
  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<cmath>
#include<vector>
#include<algorithm>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
const int maxn = 2e5+5;

int main(){
	ll h; cin >> h;
	ll cnt = 0, m = 1;
	while(h > 1){
		h /= 2;
		cnt += m;
		m *= 2;
	}
	cout << cnt + m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 998244353
 
int main(){
	int n, k, sz, l, r, ans=0;
	cin >> n >> k;
	vector < int > dp(n+10,0);
	vector < pair < int , int > > vpp;
	while(k--){
		cin >> l >> r;
		r++;
		vpp.push_back({l,r});
	}
	dp[0] = 1; dp[1] = -1;
	for(int i=0;i<n;i++){
		if(i > 0) dp[i] = (dp[i]+dp[i - 1])%MOD;
		for(auto lol : vpp){
			tie(l,r) = lol;
			if (i + l < n) dp[i + l] = (dp[i+l]+dp[i])%MOD;
			if (i + r < n) dp[i + r] = (dp[i+r]-dp[i])%MOD;
		}
	}
	//for(int i=0;i<n;i++) cout << i << " = " << dp[i] << endl; 
	cout << (MOD+dp[n-1])%MOD << endl;
	return 0;
}

Measured memory_bytes: 4060
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long n = sc.nextLong();
    if ( b == 1) {
      System.out.println(0);
    } else {
      long x = 0;
      if (n >= b) {
        x = b-1;
      } else {
        x = n;
      }
        long ans = (int)((double)a * x / b);
        System.out.println(ans);
    }
  }
}


Measured memory_bytes: 35804
while True:
  n = int(input())
  if n == 0:break
  dic = {}
  for _ in range(n):
    _, name1, _, val, name2 = input().split()
    val = int(val.split("^")[1])
    if name1 not in dic:
      dic[name1] = {}
    if name2 not in dic:
      dic[name2] = {}
    dic[name1][name2] = val
    dic[name2][name1] = -val
  
  keys = list(dic.keys())
  score = {key:None for key in keys}
  
  def search(key):
    now = score[key]
    for to in dic[key]:
      if score[to] == None:
        score[to] = now + dic[key][to]
        if not search(to):return False
      if score[to] != now + dic[key][to]:return False
    return True
  
  for key in keys:
    if score[key] != None:continue
    score[key] = 0
    if not search(key):
      print("No")
      break
  else:
    print("Yes")


Measured memory_bytes: 5724
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    string acl = "ACL";
    string res = "";
    for (int i = 0; i < k; ++i) {
        res += acl;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3584
N = int(input())
S_dic = {}
for i in range(N):
    S = input()
    if S in S_dic:
        S_dic[S] += 1
    else:
        S_dic[S] = 1
max_v = max(S_dic.values())
ans_list = [key for key, val in S_dic.items() if val == max_v]
ans_list.sort()
print("\n".join(ans_list))

Measured memory_bytes: 34140
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
char str[1100];
int dx[]={1,1,0,-1,-1,0};
int dy[]={0,1,1,0,-1,-1};

int main(){
	int a;scanf("%d",&a);
	gets(str);
	while(a--){
		gets(str);
		vector<pair<int,int> >v;
		int r=0;int c=0;
		v.push_back(make_pair(0,0));
		for(int i=0;str[i];i++){
			r+=dx[str[i]-'a'];
			c+=dy[str[i]-'a'];
			v.push_back(make_pair(r,c));
		}
		std::sort(v.begin(),v.end());
		gets(str);
		int ret=0;
		for(int i=0;i<6;i++){
			for(int t=0;t<v.size();t++){
				vector<pair<int,int> >w;
				int nr=v[t].first;int nc=v[t].second;
				w.push_back(make_pair(nr,nc));
				for(int j=0;str[j];j++){
					nr+=dx[(str[j]-'a'+i)%6];
					nc+=dy[(str[j]-'a'+i)%6];
					w.push_back(make_pair(nr,nc));
				}
				std::sort(w.begin(),w.end());
				bool ok=true;
				if(v.size()!=w.size())continue;
				for(int j=0;j<v.size();j++){
					if(v[j].first!=w[j].first||v[j].second!=w[j].second)ok=false;
				}
				if(ok){ret=1;break;}
			}
			if(ret)break;
		}
		if(ret)printf("true\n");
		else printf("false\n");
		gets(str);
	}
}

Measured memory_bytes: 1012
# @author 

import sys

class EMaxGCD:
    def solve(self):
        n, k = [int(_) for _ in input().split()]
        a = [int(_) for _ in input().split()]
        a.sort()
        s = sum(a)
        ans = 1
        for u in range(1, int(s ** .5) + 1):
            if s % u:
                continue
            v = s // u
            for d in [u, v]:
                b = sorted([x % d for x in a])
                need = 0
                l, r = 0, n - 1
                while l < r:
                    m = min(b[l], d - b[r])
                    need += m
                    b[l] -= m
                    b[r] += m
                    if b[r] % d == 0:
                        r -= 1
                    if b[l] % d == 0:
                        l += 1
                # for x in b:
                #     if x <= d - x:
                #         need += x
                # print(d, need, b)
                if need <= k:
                    ans = max(ans, d)

        print(ans)


solver = EMaxGCD()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 44140
import java.util.Scanner;
import java.math.*;

class Main
{

    public static void main(String[] args)
    {
	Scanner in = new Scanner(System.in);
	int n;
	n = in.nextInt();
	for(int i=0;i<n;i++)
	    {
		BigInteger a = in.nextBigInteger().add(in.nextBigInteger());
		
	    
		if(a.toString().length() > 80) System.out.println("overflow");
		else	System.out.println(a.toString());
	    }
    }

}

Measured memory_bytes: 0
/*

*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <deque>
 
#define ll long long
#define cint const int
#define ld long double
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define fi first
#define se second
 
using namespace std;

string s, s1, s2;

int main () {
	cin >> s;
	for (int i = 0; i < sz(s); ++i) {
		if (s[i] != s[sz(s) - 1 - i]) {
			cout << "No";
			return 0;
		}
	}
	int n = sz(s);
	for (int i = 0; i < (n + 1) / 2 - 1; ++i) {
		s1.pb(s[i]);
		s2.pb(s[sz(s) - 1 - i]);
	}

	for (int i = 0; i < sz(s1); ++i) {
		if (s1[i] != s2[sz(s1) - 1 - i]) {
			cout << "No";
			return 0;
		}
	}
	for (int i = 0; i < sz(s2); ++i) {
		if (s2[i] != s2[sz(s2) - 1 - i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{

    ll a,b,c=2,cnt=0;
    cin>>a>>b;
    ll ans=__gcd(a,b);
    ll n=ans;
   // cout<<ans<<"\n";
    for(int i=2;i<=sqrt(ans);i++)
    {
        ll x=0;
        while(ans%i==0)
        {
            ans=ans/i;
            if(x==0)
            {
                cnt++;
            }
            x++;
        }
       //cout<<i<<" "<<ans<<"\n";
    }
    if(ans>1){ cnt++;}
    //for(auto x:s) cout<<x<<" ";
    cout<<cnt+1<<"\n";
}


Measured memory_bytes: 256
N = int(input())
S1 = input().strip()
S2 = input().strip()

ans = 1

T = [0] * len(S1)

if S1[0] == S2[0]:
    T[0] = 1
else:
    T[0] = T[1] = 1
    ans *= 2

ans *= 3
MOD = 10 ** 9 + 7

for i in range(len(S1)-1):
    if T[i] == 0:
        T[i] = 1
        if S1[i] == S1[i+1]:  # 2 or 4
            T[i+1] = 1
            if S1[i-1] == S2[i-1]:  # 2
                ans *= 2
                ans %= MOD
            else:  # 4
                ans *= 3
                ans %= MOD

        else:  # 1 or 3
            if S1[i-1] == S2[i-1]:  # 1
                ans *= 2
                ans %= MOD
            else:  # 3
                pass

if T[-1] == 0:
    if S1[-2] == S2[-2]:
        ans *= 2
        ans %= MOD

print(ans)


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

bool check(int x,int y, int z) {
  if(x<0 || x>=5) return false;
  if(y<0 || y>=5) return false;
  if(z<0 || z>=5) return false;
  return true;
}

int main() {
  int n,t=1;
  while(cin >> n && n) {
    int a[5][5][5];
    for(int i=0; i<5; i++) {
      for(int j=0; j<5; j++) {
	string s;
	cin >> s;
	for(int k=0; k<5; k++) {
	  if(s[k]=='1') a[i][j][k]=1;
	  else a[i][j][k]=0;
	}
      }
    }
    int m1,m2;
    set<int> s1,s2;
    cin >> m1;
    while(m1--) {
      int x;
      cin >> x;
      s1.insert(x);
    }
    cin >> m2;
    while(m2--) {
      int x;
      cin >> x;
      s2.insert(x);
    }
    while(n--) {
      int b[5][5][5];
      for(int i=0; i<5; i++) {
	for(int j=0; j<5; j++) {
	  for(int k=0; k<5; k++) b[i][j][k]=a[i][j][k];
	}
      }
      for(int i=0; i<5; i++) {
	for(int j=0; j<5; j++) {
	  for(int k=0; k<5; k++) {
	    int cnt=0;
	    for(int dx=-1; dx<=1; dx++) {
	      for(int dy=-1; dy<=1; dy++) {
		for(int dz=-1; dz<=1; dz++) {
		  int x=i+dx,y=j+dy,z=k+dz;
		  if(x==i && y==j && z==k) continue;
		  if(check(x,y,z)) cnt+=b[x][y][z];
		}
	      }
	    }
	    if(b[i][j][k]) {
	      if(!s2.count(cnt)) a[i][j][k]=0;
	    } else {
	      if(s1.count(cnt)) a[i][j][k]=1;
	    }
	  }
	}
      }
    }
    if(t>1) cout << endl;
    cout << "Case " << t++ << ":" << endl;
    for(int i=0; i<5; i++) {
      if(i) cout << endl;
      for(int j=0; j<5; j++) {
	for(int k=0; k<5; k++) cout << a[i][j][k];
	cout << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
int main() {
 int N,T;
 cin>>N>>T;
 vector<int>c(N);
 vector<int>t(N);
 int ans=99999;
  
 for(int i=0;i<N;i++){
   cin>>c[i]>>t[i];}
  
 for(int i=0;i<N;i++){
   if(t[i]<=T&&c[i]<=ans){ans=c[i];}
 }
  
  if(ans==99999){cout<<"TLE"<<endl;}
  else{cout<<ans<<endl;}
 
 return 0;}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }
    static class Task{
        public void solve(Scanner sc, PrintWriter out){
            long a = nlong(sc);
            long b = nlong(sc);
            if (a + b == 15){
                out.println("+");
            }else if(a*b == 15){
                out.println("*");
            }else{
                out.println("x");
            }
        }
    }

    static int nint(Scanner sc){
        return Integer.parseInt(sc.next());
    }
    static long nlong(Scanner sc){
        return Long.parseLong(sc.next());
    }
    static double ndouble(Scanner sc){
        return Double.parseDouble(sc.next());
    }
    static float nfloat(Scanner sc){
        return Float.parseFloat(sc.next());
    }
    static String nstr(Scanner sc){
        return  String.valueOf(sc.next());
    }
    static long[] longLine(Scanner sc, int size){
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }
    static int[] intLine(Scanner sc, int size){
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }
    static String[] strLine(Scanner sc, int size){
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }
}

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

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

    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        pq.push(a);
    }

    int idx = 0;
    while(idx < m){
        int a = pq.top();
        pq.pop();

        a /= 2;
        pq.push(a);

        idx++;
    }

    long long ans = 0;
    while(!pq.empty()){
        ans += (long long)pq.top();
        pq.pop();
    }

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

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,k;
    int ans = 0;
    cin >> a >> b >> k;
    if(k<=a) cout << a-k << " " << b;
    else if(k>a && (k-a)<=b) cout << ans << " " << (a+b)-k << endl; 
    else cout << ans << " " << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int c[3][3];
int a[3];

int main(){

	int i,j,k;

	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
		scanf(" %d",&c[i][j]);
		}
	}

	for(i=0;i<=100;i++){
		a[0]=c[0][0]-i;
		a[1]=c[1][0]-i;
		a[2]=c[2][0]-i;
		if(a[0]>=0&&a[1]>=0&&a[2]>=0){
			if(c[0][1]-a[0]==c[1][1]-a[1] && c[0][1]-a[0]==c[2][1]-a[2] &&
				c[0][2]-a[0]==c[1][2]-a[1] && c[0][2]-a[0]==c[2][2]-a[2]
				){
			printf("Yes\n");
		return 0;
				}
	}
	}

	printf("No\n");


return 0;
}

Measured memory_bytes: 128
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty), +) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}

fn main() {
    from_line!(a: u64, b: u64);
    println!("{} {} {:.5}", a/b, a%b, (a as f64)/(b as f64));
}


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

using namespace std;

int main() {
	string s, a = "CODEFESTIVAL2016";
	cin >> s;
	int res = 0;
	for (int i = 0; i < 16; i++) {
		if (s[i] != a[i]) {
			res++;
		}
	}
	cout << res << endl;
	return 0;
}

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

int main(){
int N;
cin >> N;
vector<int> vec(N);
for(int i=0; i<N; i++){
    cin >> vec.at(i);
}
sort(vec.begin(),vec.end());
reverse(vec.begin(),vec.end());
int ansa=0;
int ansb=0;
for(int i=0; i<N; i++){
if(i%2==0){
    ansa += vec.at(i);
}
else if(i%2==1){
    ansb += vec.at(i);
}
}
cout << ansa - ansb <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;



int main(){
    int N;
    cin >> N;
    long long A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    sort(A,A+N,greater<long long>());

    long long first = -1;
    long long second = -1;
    long long now = -1;
    for(int i = 0; i < N; i++){
        if(now == A[i]){
            if(first == -1){
                first = now;
                now = -1;
            }else{
                second = now;
                now = -1;
            }
        }else{
            now = A[i];
        }
        if(first != -1 and second != -1){
            break;
        }
    }
    if(first != -1 and second != -1){
        cout << first*second << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
while True:
    h,w = map(int,input().split())
    if h == 0 and h ==0:
        break
    for j in range(h):
        for i in range(w):
            if j%2 == 0:
                if i%2 == 0:
                    print('#',end='')
                else:
                    print('.',end='')
            else:
                if i%2 == 0 :                        
                    print('.',end='')
                else:
                    print('#',end='')
        print()
    print()
        
                        
                        
            


Measured memory_bytes: 7000
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn=200007;

long long n,a[maxn],pre[maxn],r,now,t,res,s[maxn];

int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) {scanf("%lld",&a[i]);pre[i]=pre[i-1]+a[i];s[i]=s[i-1]^a[i];}
	for(int l=1;l<=n;l++){
//		cout<<'\n';
//		cout<<l<<":\n";
		while(r<=n){
			r++;//cout<<r<<' '<<pre[r]-pre[l-1]<<' '<<(s[r]^s[l-1])<<'\n';
			if(pre[r]-pre[l-1]!=(s[r]^s[l-1])){
//				cout<<r<<"!!!!"<<endl;
				r--;
				break;
			}
		}
		if(r>n) r=n;
//		cout<<l<<' '<<r<<' '<<pre[r]-pre[l-1]<<' '<<(s[r]^s[l-1])<<'\n';
		res+=r-l+1;
	}//puts("");
	printf("%lld\n",res);
	return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define llrep(i,a,b) for(ll i=a;i<b;i++)
#define llrepd(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

//---------------------------------------------------------------------------------------------------
void _main() {
    ll N; cin >> N;
    vector<pair<long double, long double>> xy(N, make_pair(0,0));
    rep(i, 0, N) cin >> xy[i].first >> xy[i].second;
    sort(all(xy));
    long double count = 0;
    long double sum = 0;
    do{
        count++;
        rep(i, 0, N-1) {
            sum += sqrt(pow(xy[i].first - xy[i + 1].first, 2) + pow(xy[i].second - xy[i + 1].second, 2));
        }
    }while(next_permutation(all(xy)));
    cout << fixed << setprecision(10) << sum / count << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nk[0];
        var k = nk[1];

        Console.WriteLine(n - k + 1);
    }
}


Measured memory_bytes: 13268
// base. https://atcoder.jp/contests/abc145/submissions/8474814

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

vector< vector<double >> dist; // Tree which contains the distance of i-j.

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<double> x(n);
  vector<double> y(n);
  rep(i, n) {
    cin >> x[i];
    cin >> y[i];
  }
  // printvec(x);
  // printvec(y);

  vector<ll> a(n);
  rep(i, n) { a[i] = i; }
  double ans = 0;
  ll divisor = 0;
  do {
    rep(i, n-1) {
      ll dx = x[a[i]] - x[a[i+1]];
      ll dy = y[a[i]] - y[a[i+1]];
      ans += sqrt(dx * dx + dy * dy);
    }
    ++divisor;
  } while (next_permutation(all(a)));

  cout << (ans / (double)divisor) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
  class Problem0025
  {
    static void Main()
    {
      foreach (var nums in ReadNumbers())
      {
        var hit = 0;
        var blow = 0;
        foreach (var i in Enumerable.Range(0, nums[0].Count))
        {
          if (nums[1][i] == nums[0][i])
            ++hit;
          if (nums[0].Contains(nums[1][i]))
            ++blow;
        }
        blow -= hit;
        Console.WriteLine("{0} {1}", hit, blow);
      }
    }

    static IEnumerable<IList<int>[]> ReadNumbers()
    {
      string line;
      while ((line = Console.ReadLine()) != null)
      {
        var p1 = line.Split(' ').Where(s => !string.IsNullOrEmpty(s)).Select(s => int.Parse(s)).ToList();
        line = Console.ReadLine();
        var p2 = line.Split(' ').Where(s => !string.IsNullOrEmpty(s)).Select(s => int.Parse(s)).ToList();
        yield return new[] {p1, p2};
      }
    }
  }
}

Measured memory_bytes: 20748
#include <iostream>
using namespace std;
int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if( k <= a )
		cout << k;
	else if ( k <= a + b)
		cout << a;
	else
		cout << a - (k - (a+b));

  	return 0;
}
  

Measured memory_bytes: 3540
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int k = in.nextInt();

		if(k != 1) {
			System.out.println(n - k);
		}
		else {
			System.out.println(0);
		}		
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<ctime>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<cstdio>
#include<map>
#include<string.h>
using namespace std; 
long long x[100008],dp[100008];long long t,e;
void update(long long i,long long j)
{
	dp[i]=min(dp[i],dp[j]+max(t,2*(x[i]-x[j+1])));
}
int main()
{
	long long n;cin>>n;cin>>e>>t;
	for(long long i=1;i<=n;i++) cin>>x[i];for(long long i=0;i<100005;i++) dp[i]=2e9;
	dp[0]=0;long long j=0;long long mst=2e9,msi=0;
	for(long long i=1;i<=n;i++)
	{
		update(i,i-1);
		while((x[i]-x[j+1])*2>t)
		{
			long long tt=dp[j]+2*(x[0]-x[j+1]);
			if(tt<mst) mst=tt,msi=j;j++;
		}
		update(i,j);update(i,max(j-1,(long long)0));update(i,j+1);
		update(i,msi);
	}
	cout<<dp[n]+e;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
	int n;
	int sum1 = 0;
	int sum2 = 0;
	cin>>n;
	vector<int> a(n,0);
	for(int i = 0 ; i < n ; i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end(),greater<int>());
	for(int i = 0; i < n; i++){
		if( i % 2 == 0){
			sum1 += a[i];
		}else{
			sum2 += a[i];
		}
	}
	cout<<sum1 - sum2<<endl;
	return 0;
}



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

int main(void){
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int b = 0;
    int cnt = 0;
    for(int r = 0; r <= N; r++){
        for(int g = 0; g <= N; g++){
            b = N - r*R - g*G;
            if(b%B == 0 && b >= 0) cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3556
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;
	if(a+b>=10){cout<<"error";}
	else{cout<<a+b;}




	cout<<endl;
} 


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

// map<ll, ll> prime_factor(ll n) {
//   map<ll, ll> ret;
//   for(ll i = 2; i * i <= n; i++) {
//     while(n % i == 0) {
//       ret[i]++;
//       n /= i;
//     }
//   }
//   if(n != 1) ret[n] = 1;
//   return ret;
// }

bool prime_check(ll n) {
//   map<ll, ll> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
        return false;
    }
  }
//   if(n != 1) ret[n] = 1;
  return true;
}


int main()
{
    cout << fixed << setprecision(15);
    ll Q;
    cin >> Q;

    ll N = 100000;

    vector<bool> Prime(N+1, false);

    for(ll i=2; i<=N; i++){
        Prime[i] = prime_check(i);
    }

    // for(ll i=0; i<=N; i++){
    //     cout << i << " " << Prime[i] << endl;
    // }

    vector<ll> A(N+1, 0);
    for(ll i=1; i<=N; i++){
        if(i%2 == 0){
            A[i] = A[i-1];
            continue;
        }
        if(Prime[i] && Prime[(i+1)/2]){
            A[i] = A[i-1] + 1;
        }
        else{
            A[i] = A[i-1];
        }
    }

    REP(i, Q){
        ll left, right;
        cin >> left >> right;

        cout << A[right]- A[left-1] << endl;

    }
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(){
  int i = 0, x;
  int data[100];
  while(scanf("%d", &x) != EOF){
    if(x != 0){
      data[i] = x;
      i++;
    }else{
      printf("%d\n", data[i-1]);
      i--;
    }
  }
  return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;

int main(void) {
	int n;
	

	cin >> n;
	vector<int>a(n + 1);
	FOR(i, 1, n) {
		cin >> a[i];
	}
	if (n % 2 == 0) {
		RFOR(i, n, 2) {
			cout << a[i] << " ";
			i--;
		}
		FOR(i, 1, n - 1) {
			if (i == n - 1) {
				cout << a[i] << endl;
			}
			else {
				cout << a[i] << " ";
			}
			i++;
		}
	}
	else {
		RFOR(i, n, 1) {
			cout << a[i] << " ";
			i--;
		}
		FOR(i, 2, n - 1) {
			if (i == n - 1) {
				cout << a[i] << endl;
			}
			else {
				cout << a[i] << " ";
			}
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>

void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}

int main(void)
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    if (a > b)  swap(&a, &b);
    if (b > c)  swap(&b, &c);
    if (a > b)  swap(&a, &b);
    if (b > c)  swap(&b, &c);

    // 最大値との差が両方偶数
    if ((c - b) % 2 == 0 && (c - a) % 2 == 0) {
        //putchar('a');
        printf("%d\n", ((c - b) + (c - a)) / 2);
        return 0;
    }
    // 両方奇数
    else if ((c - b) % 2 && (c - a) % 2) {
        //putchar('b');
        printf("%d\n", ((c - b) + (c - a)) / 2);
        return 0;
    }
    else {
        //putchar('c');
        printf("%d\n", ((c - b) + (c - a)) / 2 + 2);
        return 0;
    }
    return 0;
}

Measured memory_bytes: 128