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) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		char c[] = br.readLine().toCharArray();

		long k = Long.parseLong(br.readLine());

		String ans = "";

		for (int i = 0; i < c.length - 1; i++) {
			int dist = 26 - (c[i] - 'a');

			if (c[i] == 'a') {
				ans += "a";
				continue;
			}

			if (k >= dist) {
				ans += "a";
				k -= dist;
			} else {
				ans += c[i];
			}
		}

		char alph[] = "abcdefghijklmnopqrstuvwxyz".toCharArray();

		if (k > 0) {
			ans += alph[(int) ((k % 26) + (c[c.length - 1] - 'a')) % 26];
		} else {
			ans += c[c.length - 1];
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 56040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

#define PT pair<int, int>

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


	int H, W, K;
	cin >> H >> W >> K;
	string S[800];
	rep(i, H) cin >> S[i];
	bool D[800][800] = {};
	int k = 0;
	vector<pair<int, int>> que1;
	rep(i, H) rep(j, W) {
		if (S[i][j] == 'S') {
			D[i][j] = true;
			que1.emplace_back(i, j);
		}
		k++;
	}
	rep(d, K) {
		vector<pair<int, int>> que2;
		for (auto p : que1) {
			int i = p.first;
			int j = p.second;
			if (i == 0 || j == 0 || i == H - 1 || j == W - 1) break;
			else {
				if (!D[i][j + 1] && S[i][j + 1] != '#') { que2.emplace_back(i, j + 1); D[i][j + 1] = true; }
				if (!D[i][j - 1] && S[i][j - 1] != '#') { que2.emplace_back(i, j - 1); D[i][j + 1] = true; }
				if (!D[i + 1][j] && S[i + 1][j] != '#') { que2.emplace_back(i + 1, j); D[i + 1][j] = true; }
				if (!D[i - 1][j] && S[i - 1][j] != '#') { que2.emplace_back(i - 1, j); D[i - 1][j] = true; }
			}
		}
		que1 = que2;
	}

	int kotae = 1e9;
	rep(i, H) rep(j, W) {
		if (D[i][j]) {
			int tmp = min(min(i, H - i - 1), min(j, W - j - 1));
			kotae = min(kotae, 1 + (tmp + K - 1) / K);
		}
	}
	co(kotae);

	Would you please return 0;
}

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

int A[1000000];
int cnt;
vector<int> G;

void insertion_sort_gap(int A[], int n, int g) 
{
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shell_sort(int A[], int n)
{
    int h = 1;
    while (1) {
        if (h > n) {
            break;
        }
        G.push_back(h);
        h = 3*h + 1;
    }

    for (int i = G.size() - 1; i >= 0; i--) {
        insertion_sort_gap(A, n, G[i]);
    }
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    cnt = 0;
    shell_sort(A, n);
    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    printf("\n%d\n", cnt);
    for (int i = 0; i < n; i++) {
        printf("%d\n", A[i]);
    }

    return 0;
}



Measured memory_bytes: 7140
#include <iostream>

using namespace std;

int main(){
  int cnt=0;
  int x; cin >> x;
  long s[x];
  for(int i=0;i<x;i++) cin >> s[i];
  int y; cin >> y;
  long t[y];
  for(int j=0;j<y;j++){
    cin >> t[j];
    int left=0; int right=x-1;
    while(left<=right){
      if(t[j]==s[(left+right)/2]){
        cnt++;
        break;
      }
      if(t[j]>s[(left+right)/2]) left=(left+right)/2+1;
      if(t[j]<s[(left+right)/2]) right=(left+right)/2-1;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 4192
#include <stdio.h>
#include <stdlib.h>
 
int com_asc_char(const void *n1,const void *n2){
   if(*(char*)n1 > *(char*)n2)return 1;
   else if(*(char*)n1 < *(char*)n2)return -1;
   else return 0;
}
 
int main(){
   char w[101];scanf("%s",w);
   qsort(w,strlen(w),sizeof(char),com_asc_char);
   int c = 0;
   if(!(strlen(w)%2 == 0)){
      printf("No\n");
      return 0;
   }
   for(int i = 0;i < strlen(w)-1;i+=2)
      if(w[i] == w[i+1])c++;
   if(c == strlen(w)/2)printf("Yes\n");
   else printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define loop(i,n) for(int i=0;i<n;i++)
void solve()
{
    int n,t=0;
    string s;
    cin>>n>>s;
    if(n%2==0){
    loop(i,n/2)
    {
        if(s[i]==s[i+n/2])
        t=1;
        else 
        {   
            t=0;
            break;
        }
    }
    if(t)
    cout<<"Yes";
    else
    cout<<"No";
    }
    else
    cout<<"No";
}
int main() {
	// your code goes here
// 	int t ;
// 	cin>>t;
// 	while(t--)
    solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll mod=1000000007;
ll MOD=998244353;

#define Int long long
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
 
 
template <typename E>
struct SegmentTree{
  using H = function<E(E,E)>;
  Int n,height;
  H h;
  E ei;
  vector<E> laz;
 
  SegmentTree(H h,E ei):h(h),ei(ei){}
 
  void init(Int n_){
    n=1;height=0;
    while(n<n_) n<<=1,height++;
    laz.assign(2*n,ei);
  }
 
  inline void propagate(Int k){
    if(laz[k]==ei) return;
    laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
    laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
    laz[k]=ei;
  }
 
  inline void thrust(Int k){
    for(Int i=height;i;i--) propagate(k>>i);
  }
 
  void update(Int a,Int b,E x){
    thrust(a+=n);
    thrust(b+=n-1);
    for(Int l=a,r=b+1;l<r;l>>=1,r>>=1){
      if(l&1) laz[l]=h(laz[l],x),l++;
      if(r&1) --r,laz[r]=h(laz[r],x);
    }
  }
 
  E get_val(Int a){
    thrust(a+=n);
    return laz[a];
  }
 
  void set_val(Int a,E x){
    thrust(a+=n);
    laz[a]=x;
  }
};
 
//INSERT ABOVE HERE

int main() {
    ll n;
    cin >> n;
    int q;
    cin >> q;
    auto h=[&](ll x,ll y){return min(x,y);};
    const ll INF = 1e18;
    SegmentTree<ll> seg(h,n),se(h,n);
    seg.init(n+2);
    seg.set_val(0,0);
    se.init(n+2);
    se.set_val(0,0);
    ll ans=0;
    rep(i,q){
        ll f,g;
        cin >> f >> g;
        if (f==1){
            ll y=seg.get_val(g)-2;
            ans+=y;
            se.update(0,y+2,g);
        }
        else {
            ll y=se.get_val(g)-2;
            ans+=y;
            seg.update(0,y+2,g);
        }
    }
    n--;
    n--;
    cout << n*n-ans << endl;
}


Measured memory_bytes: 11444
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int[] scou = new int[26];
		int[] tcou = new int[26];
		Arrays.fill(scou,0);
		Arrays.fill(tcou,0);
		boolean flag = true;
		for(int i = 0; i < s.length(); i++){
			int stmp = s.charAt(i)-97;
			int ttmp = t.charAt(i)-97;
			scou[stmp]++;
			tcou[ttmp]++;
			if(scou[stmp]!=tcou[ttmp]){
				flag = false;
				break;
			}
		}
		System.out.print(flag?"Yes":"No");
	}
}


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

#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<int, int> mp;
	vector<int> v(n);

	REP(i, n) {
		cin >> v[i];
		mp[v[i]]++;
	}
	int a = v[0], b = -1;
	if (--mp[v[0]] == 0) mp.erase(v[0]);

	FOR(i, 1, n) {
		if (mp.count(v[0] ^ v[i])) {
			b = v[i];
			if (--mp[v[i]] == 0) mp.erase(v[i]);
			break;
		}
	}
	if (b == -1) {
		cout << "No" << endl;
		return 0;
	}
	REP(i, n - 2) {
		if (mp.count(a ^ b)) {
			if (--mp[a ^ b] == 0) mp.erase(a ^ b);
			int c = a ^ b;
			a = b;
			b = c;
		} else {
			cout << "No" << endl;
			return 0;
		}
	}
	if (a ^ b == v[0]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	string a = s.substr(0,n/2);
	string b = s.substr(n/2,n);
	
	if(a == b)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 3064
if __name__ == '__main__':
    X = [int(input()) for _ in range(5)]
    K = int(input())
    flag = True
    for j in range(1, 5):
        for i in range(0, j):
            if max(X[j] - X[i], X[i] - X[j]) > K:
                flag = False
    if flag:
        print('Yay!')
    else:
        print(':(')

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

int main(){
  ll ans=0;
  string s;
  cin>>s;
  ll vec[s.size()+1];
  vec[0]=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='B'){
      vec[i+1]=vec[i]+1;
    }
    else{
      vec[i+1]=vec[i];
    }
  }
  for(int i=0;i<s.size();i++){
    if(s[i]=='W'){
      ans+=vec[i+1];
    }
  }
  cout<<ans<<endl;
}

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

static const int N = 8;
static const int FREE = -1;
static const int NOT_FREE = 1;

bool given_board[N][N];

class EightQueen {
private:
    int row[N];
    int column[N];
    int dpos[2 * N - 1];
    int dneg[2 * N - 1];

public:
    EightQueen()
    {
        for(int i = 0; i < N; i++)
        {
            row[i] = FREE;
            column[i] = FREE;
        }
        for(int i = 0; i < 2 * N - 1; i++)
        {
            dpos[i] = FREE;
            dneg[i] = FREE;
        }
    }

    void printBoard()
    {
        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j < N; j++)
            {
                if(given_board[i][j] && row[i] != j)
                    return;
            }
        }

        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j < N; j++)
            {
                cout << (row[i] == j ? "Q" : ".");
            }
            cout << endl;
        }
    }

    void recursive(int i)
    {
        if(i == N)
        {
            printBoard();
            return;
        }

        for(int j = 0; j < N; j++)
        {
            if(column[j] == NOT_FREE ||
            dpos[i + j] == NOT_FREE ||
            dneg[i - j + (N - 1)] == NOT_FREE)
                continue;

            row[i] = j; // (i, j)にクイーンを配置
            column[j] = dpos[i + j] = dneg[i - j + (N - 1)] = NOT_FREE;

            recursive(i + 1);

            row[i] = column[j] = dpos[i + j] = dneg[i - j + (N - 1)] = FREE;
        }
    }
};

int main()
{
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            given_board[i][j] = false;
        }
    }

    int k;
    cin >> k;
    int r, c;
    for(int i = 0; i < k; i++)
    {
        cin >> r >> c;
        given_board[r][c] = true;
    }

    EightQueen queen;
    queen.recursive(0);
}


Measured memory_bytes: 3120
"use strict";

function main(input) {
  input = input.trim().split("\n");
  const N = parseInt(input[0]);
  const line_two = input[1].split(" ");
  let ans = 0;

  for (let i in line_two) {
    if ((parseInt(i) + 1) % 2 != 0 && parseInt(line_two[i]) % 2 != 0) {
      ans++;
    }
  }

  console.log(ans);
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 29756
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int f(int x) {
  return x * x;
}

int main() {
  int d;
  int D = 600;
  while (cin >> d) {
    int s = 0;
    for (int i = 1; i * d < D; i++)
      s += f(i * d) * d;

    cout << s << endl;
  }
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <stack>

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

typedef std::vector<int> v;
typedef std::vector<std::vector<int>> vv;
typedef unsigned long long ull;

int main(void)
{
    double r;
    scanf("%lf", &r);
    printf("%.16f", 2 * M_PI * r);
    return 0;
}

Measured memory_bytes: 3220
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



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

	ll ans = 0;
	rep(i, a + 1) rep(j, b + 1) rep(k, c + 1) {
		if (500 * i + 100 * j + 50 * k == x) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        if(i%2==0) cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <sstream>

#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repr(i, a, b) for(int i = (a); i >= (b); i--)
#define range(x) begin(x), end(x)

#define dump(x) cerr << #x << " : " << x << '\n'

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

const int iinf = 1 << 29;
const ll linf = 1l << 61;

int main(int argc, char* argv[])
{
	char a[2][5];
	rep(i, 0, 2)
	{
		scanf("%s", a[i]);
	}
	if(a[0][0] == a[1][2] && a[1][1] == a[0][1] && a[0][2] == a[1][0])
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
l = []
for _ in range(m):
    a,b = map(int, input().split())
    cl = [x-1 for x in map(int, input().split())]
    b = 0
    for i in cl:
        b |= 1<<i
    l.append([a,b])

inf = 10**9
dp = [inf]*2**n
dp[0] = 0
for x in range(2**n):
    for i in range(m):
        a,b = l[i]
        dp[x|b] = min(dp[x|b], dp[x]+a)

if dp[-1]==inf:
    print(-1)
else:
    print(dp[-1])

Measured memory_bytes: 46040
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let (tbl : (string, unit) Hashtbl.t) = Hashtbl.create ~random:true n in
  for _ = 0 to n - 1 do
    match split_on_char ' ' (read_line ()) with
    | ["insert"; s] -> Hashtbl.add tbl s ()
    | ["find"; s] -> print_endline (if Hashtbl.mem tbl s then "yes" else "no")
    | _ -> assert false
  done

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

using namespace std;

long long n, k;
long long fh;
long long c = 1;

int main(void)
{
	scanf("%lld %lld", &n, &k);
	
	fh = k;
	
	while(n >= fh)
	{
		c++;
		fh *= k;
	}
	
	printf("%lld", c);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  for (int i = 0; i < ty-sy; i++) cout << "U";
  for (int i = 0; i < tx-sx; i++) cout << "R";
  for (int i = 0; i < ty-sy; i++) cout << "D";
  for (int i = 0; i < tx-sx; i++) cout << "L";
  cout << "L";
  for (int i = 0; i < ty-sy+1; i++) cout << "U";
  for (int i = 0; i < tx-sx+1; i++) cout << "R";
  cout << "D";
  cout << "R";
  for (int i = 0; i < ty-sy+1; i++) cout << "D";
  for (int i = 0; i < tx-sx+1; i++) cout << "L";
  cout << "U" << endl;
  return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int Z = 1;
    for (int i = 0; i < N; i++) {
        if (Z * 2 < Z + K) {
            Z *= 2;
        }
        else {
            Z += K;
        }
    }
    cout << Z << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

void ZAlgorithm(string str, vector<int> &z_array) {
    int n = str.length();
    int L = 0, R = 0;
    z_array.push_back(-1);
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && str[R - L] == str[R]) R++;
            z_array.push_back(R - L);
            R--;
        } else {
            int j = i - L;
            if (z_array[j] < R - i + 1) {
                z_array.push_back(z_array[j]);
            } else {
                L = i;
                while (R < n && str[R - L] == str[R]) R++;
                z_array.push_back(R - L);
                R--;
            }
        }
    }
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int k = 0; k < S.size() - 1; k++) {
        vector<int> z(0);
        string T = S.substr(k);
        ZAlgorithm(T, z);
        for(int i = 0; i < z.size(); i++) {
            ans = max(ans, min(i, z[i]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>
 
using namespace std;
  
/********** TEMPLATE STARTS HERE ***********/
    
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) (int)v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define gcd __gcd 
#define mp make_pair
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);
#define digits(n) (int)(log10(n) + 1)
  
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pii> vii;
typedef vector <pll> vll;
    
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
    
template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
   
/*********** TEMPLATE ENDS HERE *************/

main()
{
	IOS
	
	int n;
	cin >> n;
	
	for(int i = 1; i <= 9; i++)
		if(i  * 111 >= n)
		{
			cout << 111 * i;
			return 0;
		}
}

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

int main(){
    long long N;
    cin >> N;
    for (int h = 1; h <= 3500; h++){
        for (int w = 1; w <= 3500; w++){
            long long x = N * h * w;
            long long y = 4 * h * w - N * w - N * h;
            if (y <= 0) continue;
            if (x % y == 0){
                cout << h << " " << x / y << " " << w << endl;
                return 0;
            }
        }
    }
}

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

using namespace std;

int main(){
    int k;
    string s;
    cin >> k;
    cin >> s;
    if(s.size() <= k)
        cout << s << "\n";
    else
        cout << s.substr(0, k) << "...\n";
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>                                             
#include <cstdio>                                               
using namespace std;                                            
                                                                
int main(void) {                                                
  int n;                                                        
  cin >> n;                                                     
  int R[n];                                                     
  for (int k=0; k<n; k++) {                                     
    cin >> R[k];                                                
  }                                                             
  int max = -1000000000;                                        
  int min = R[0];                                               
  for (int j=1; j<n; j++) {                                     
    max = std::max(max,R[j]-min);                               
    min = std::min(min,R[j]);                                   
  }                                                             
  printf("%d\n", max);                                          
  return 0;                                                     
}                                                               
                                                                
                                                                
                                                                
                                                                
                            

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
int main()
{
    string t;
    cin >> t;
    for (int i = 0; i < t.size(); i++)
    {
        if(t[i] == '?'){
            t[i] = 'D';
        }
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3664
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

int next(int a,int b,int c,int x){
  return (a*x+b)%c;
}

int main(){
  int i,n,a,b,c,x,r,t[128],w;
  while(scanf("%d%d%d%d%d",&n,&a,&b,&c,&x),n!=0){
    r=10001;
    for(i=0;i<n;i++){scanf("%d",&t[i]);}
    w=0;
    for(i=0;i<=10000;i++){
      if(x==t[w]){
        w++;
        if(w==n){r=i;break;}
      }
      x=next(a,b,c,x);
    }
    if(r==10001){printf("-1\n");}
    else{printf("%d\n",r);}
  }
  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e18;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vl a(n);
  vector<bool> z(1000007, true);
  vector<bool> z1(1000007, false);
  rep(i, n){
    cin >> a[i];
    if(z[a[i]]){
      for (ll j = 2; a[i] * j < 1000007; j++){
        z[a[i] * j] = false;
      }
      if(z1[a[i]])z[a[i]] = false;
      z1[a[i]] = true;
    }
  }
  ll ans = 0;
  rep(i, n){
    if(z[a[i]])
      ans++;
  }
  print(ans);
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b) cout << c << endl;
    else if(b == c) cout << a << endl;
    else cout << b << endl;
}

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

typedef long long int lli;
typedef long long ll;
typedef long double ld;

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        int n,m;
        cin>>n;
        vector<int> a(n);
        ll sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            sum+=a[i];
        }
        cin>>m;
        
        for(int i=0;i<m;i++){
            int x,y;
            cin>>x>>y;
            ll l=(sum-a[x-1])+y;
            cout<<l<<endl;
        }
    }
}

Measured memory_bytes: 256
S=input()
a=int(S[:2]); b=int(S[2:])
if 0<a and a<13 and 0<b and b<13: print('AMBIGUOUS')
elif 0<a and a<13: print('MMYY')
elif 0<b and b<13: print('YYMM')
else: print('NA')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int MOD = 1000000007;

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

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int H, W; cin >> H >> W;
	int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; sx--; sy--; gx--; gy--;
	vector<vector<char>>s(H, vector<char>(W));
	rep(i, H) {
		rep(j, W) {
			cin >> s[i][j];
		}
	}
	vector<vector<int>>dist(H, vector<int>(W));
	rep(i, H)rep(j, W)dist[i][j] = 1001001001;
	dist[sx][sy] = 0;
	deque<pair<int, int>>q;
	q.push_back({ sx,sy });
	while (!q.empty()) {
		P p = q.front(); q.pop_front();
		rep(i, 4) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 <= nx && nx < H && 0 <= ny && ny < W&&s[nx][ny] == '.') {
				if (dist[nx][ny] > dist[p.first][p.second]) {
					dist[nx][ny] = dist[p.first][p.second];
					q.push_front({ nx,ny });
				}
			}
		}
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				if (i == 0 && j == 0)continue;
				int nx = p.first + i, ny = p.second + j;
				if (0 <= nx && nx < H && 0 <= ny && ny < W&&s[nx][ny] == '.') {
					if (dist[nx][ny] > dist[p.first][p.second] + 1) {
						dist[nx][ny] = dist[p.first][p.second] + 1;
						q.push_back({ nx,ny });
					}
				}
			}
		}
	}
	if (dist[gx][gy] == 1001001001)dist[gx][gy] = -1;
	cout << dist[gx][gy] << endl;
	return 0;
}

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

int N,K;
int ans = 0;
vector<int> V;
long long dp[10][10010] = {1};

int main()
{
    scanf("%d%d",&N,&K);
    for(int i = 0; i < N; i++)
    {
        int a;
        scanf("%d",&a);
        if(a < K)
        {
            V.push_back(a);
        }
    }
    N = V.size();
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j <= K * 2; j++)
        {
            if(dp[0][j] != 0)
            {
                dp[1][j] += dp[0][j];
                if(j + V[i] <= K * 2)dp[1][j + V[i]] += dp[0][j];
            }
        }
        for(int j = 0; j <= K * 2; j++)
        {
            dp[0][j] = dp[1][j] % 1000000007;
            dp[1][j] = 0;
        }
    }
    for(int i = 0; i < N; i++)
    {
        int now = V[i];
        long long mem[10010] = {0};
        for(int j = 0; j <= K; j++)
        {
            if(j == K)ans++;
            if((dp[0][j] - mem[j] + 1000000007) % 1000000007 > 0 && dp[0][j + now] > 0)
            {
                mem[j + now] += dp[0][j] - mem[j];
                mem[j + now] %= 1000000007;
                mem[j] += dp[0][j] - mem[j];
                mem[j] %= 1000000007;
                if(j >= K - now)
                {
                    break;
                }
            }
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;

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

        int n = cin.nextInt();
        if(n % 2 == 0) {
            cout.println((n/2.0)/n);
        }
        else {
             cout.println(((n+1)/2.0)/n);
        }

        cout.close();
    }
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

vector<string> B;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    B.resize(H);
    rep(i, H) cin >> B[i];

    int ans = 0;
    rep(bit_h, 1 << H) {
        rep(bit_w, 1 << W) {
            int cnt = 0;
            rep(h, H) {
                if (bit_h >> h & 1) continue;
                rep(w, W) {
                    if (bit_w >> w & 1) continue;
                    if (B[h][w] == '#') cnt++;
                }
            }
            if (cnt == K) ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3648
import java.util.Scanner;

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

		//コンソールに入力した値を取得
		int x1 = sc.nextInt();
		int x2 = sc.nextInt();
		int x3 = sc.nextInt();
		int x4 = sc.nextInt();
		int x5 = sc.nextInt();

		if (x1 == 0) {
			System.out.println("1");
		} else if (x2 == 0) {
			System.out.println("2");
		} else if (x3 == 0) {
			System.out.println("3");
		} else if (x4 == 0) {
			System.out.println("4");
		} else if (x5 == 0) {
			System.out.println("5");
		}

		sc.close();
	}
}


Measured memory_bytes: 26840
#include<bits/stdc++.h>
#define Vsort(a) sort(a.begin(), a.end())
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Srep(i,a,n) for(int i = (a); i < (n); i++)
using namespace std;

int main(){
  char s;
  cin >> s;
  printf("%c",s+1);
}

Measured memory_bytes: 3552
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string ans = "111111111222444666555333333333", p;

void myswap(int sw){
  if(sw == 0){
    swap(p[0], p[23]); swap(p[3], p[26]); swap(p[6], p[29]);
    swap(p[9], p[20]); swap(p[15], p[17]);
  }else if(sw == 1){
    swap(p[2], p[21]); swap(p[5], p[24]); swap(p[8], p[27]);
    swap(p[11], p[18]); swap(p[12], p[14]);
  }else if(sw == 2){
    swap(p[0], p[27]); swap(p[1], p[28]); swap(p[2], p[29]);
    swap(p[14], p[15]); swap(p[18], p[20]);
  }else if(sw == 3){
    swap(p[6], p[21]); swap(p[7], p[22]); swap(p[8], p[23]);
    swap(p[12], p[17]); swap(p[9], p[11]);
  }
  return;
}

int dfs(int times, int sw){
  if(p == ans)return times;
  else if(times >= 8)return 8;
  int i, res = 8;
  rep(i, 4)if(sw != i){
    myswap(i);
    res = min(res, dfs(times + 1, i));
    myswap(i);
  }
  return res;
}

signed main(void){
  int i, j;
  int(n);
  for(int testcase = 0;testcase < n;testcase++){
    p.clear();
    rep(i, 30){
      int(a);
      p += (char)('0' + a);
    }
    pri(dfs(0, -1));
  }
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long int ll;
const int N=1e5+5,MAX=1e9+2;
int n,a[N],dp[N],k;
int main(){
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[i]=MAX;
    }
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k&&i+j<n;j++)
            dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
    }
    cout<<dp[n-1]<<'\n';
    return 0;
}


Measured memory_bytes: 1024
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    N,M = map(int,input().split())
    count_list = [0]*(N+1)
    for _ in range(M):
        a,b = map(int,input().split())
        count_list[a] += 1
        count_list[b] += 1
    for c in count_list:
        if c% 2 == 1:
            print('NO')
            return
    print('YES')
    return

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 69608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
int main()
{
    ll n;
    cin >> n;
    int t = n % 10;
    if (t == 3)
    {
        cout << "bon";
    }
    else if (t == 2 || t == 4 || t == 5 || t == 7 || t == 9)
    {
        cout << "hon";
    }
    else
    {
        cout << "pon";
    }
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;

long long C(long long n, long long k) {
    long long res = 1LL;
    for (long long i = 0; i < k; i++) res = res * (n - i) / (i + 1);
    return res;
}

void solve() {
    long long N, A, B;
    cin >> N >> A >> B;
    vector<double> v(N);
    for (long long i = 0; i < N; i++) cin >> v.at(i);
    sort(v.begin(), v.end());
    double sum = 0;
    for (long long i = N - A; i < N; i++) sum += v.at(i);
    double ave = sum / A;
    cout.precision(20);
    cout << ave << endl;
    long long same = 0, choice = 0;
    for (long long i = 0; i < N; i++) {
        if (v.at(i) == v.at(N - A)) {
            same++;
            if (i >= N - A) choice++;
        }
    }
    long long ans = 0L;
    if (v.at(N - A) == v.at(N - 1)) {
        for (long long i = A; i <= min(same, B); i++) {
            ans += C(same, i);
        }
    } else {
        ans = C(same, choice);
    }
    cout << ans << endl;
}

int main() {
    solve();
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
vector <int> v[100000];
int si[100000];

void era(int now){
    si[now] = -1;
    for(int i = 0;i < v[now].size();i++){
        int ne = v[now][i];
        if(si[ne] != -1){
            si[ne] = -1;
            for(int j = 0;j < v[ne].size();j++){
                int nene = v[ne][j];
                if(si[nene] < 1)continue;
                if(si[nene] == 2)era(nene);
                else si[nene]--;
            }
        }
    }
    return;
}
int main(void){
    int n; cin >> n;
    for(int i = 0;i < n - 1;i++){
        int a, b; cin >> a >> b; a--; b--;
        v[a].push_back(b); v[b].push_back(a);
    }
    if(n == 2){cout << "Second" << endl; return 0;}
    if(n == 3){cout << "First" << endl; return 0;}
    /*
    for(int i = 0;i < n;i++){
        if(v[i].size() > 2){
            int count = 0;
            vector <int> vi;
            for(int j = 0;j < v[i].size();j++){
                if(v[v[i][j]].size() == 1)count++;
                if(v[v[i][j]].size() == 2)vi.push_back(v[i][j]);
            }
            if(count > 1){cout << "First" << endl; return 0;}
            if(count == 1 && vi.size() > 0){
                for(int j = 0;j < vi.size();j++){
                    for(int k = 0;k < 2;k++){
                        int he = v[vi[j]][k];
                        if(he == i)continue;
                        for(int l = 0;l < v[he].size();l++){
                            if(v[v[he][l]].size() == 1){
                                cout << "First" << endl; return 0;
                            }
                        }
                    }
                }
            }
        }
    }*/
    /*for(int i = 0;i < n;i++){
        int flag = 1;
        for(int j = 0;j < v[i].size();j++){
            int e = v[i][j];
            int flage = 0;
            for(int k = 0;k < v[e].size();k++){
                if(v[e][k] == i)continue;
                if(v[v[e][k]].size() == 1){flage = 1; break;}
            }
            if(!flage)flag = 0;
        }
        if(flag){cout << "First" << endl; return 0;}
    }*/
    for(int i = 0;i < n;i++)si[i] = v[i].size();
    int flag = 1;
    while(flag){
        flag = 0;
        for(int i = 0;i < n;i++){
            if(si[i] == 0){cout << "First" << endl; return 0;}
            if(si[i] > 0)flag = 1;
            if(si[i] == 1)era(i);
        }
    }
    cout << "Second" << endl;
	return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a + b) / 2 + (a + b) % 2 << endl;
}

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

int main(){

  int n;
  cin >> n;

  int r,minr;
  cin >> minr;

  int max= -999999999;

  for(int i=1;i<n;i++){
    cin >> r;
    if(max<r-minr)max=r-minr;
    if(minr>r)minr=r;
  }
  
  cout << max << endl;

}

Measured memory_bytes: 1164
#include <iostream>
#include <vector> //可変長配列
#include <queue> //キュー
#include <unordered_map> //ハッシュ連想配列
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int a,b; cin>>a>>b;
    cout<<((a*b)%2==0?"Even":"Odd")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int N;

int main() {
    string S;
    cin >> N;
    map<string, int> count;
    int mx = 0;
    for (int i = 0; i < N; i++) {
        cin >> S;
        count[S]++;
        if (mx < count[S]) {
            mx = count[S];
        }
    }
    set<string> ans;
    for (const auto& mp : count) {
        if (mp.second == mx) {
            ans.insert(mp.first);
        }
    }
    for (const auto& a : ans) {
        cout << a << endl;
    }
}


Measured memory_bytes: 34560
N, A, B = map(int, input().split())
X = list(map(int, input().split()))

ans = 0

for i in range(1, N):
    x = X[i] - X[i - 1]
    
    if (x * A) >= B:
        ans += B
    else:
        ans += x * A
        
print(ans)

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

typedef long long ll;
typedef long double ld;

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

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll N, i;

    cin >> N >> i;

    cout << N - i + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1000005;
const int mod = 998244353;

struct P{
  int x,y;
  P(int x, int y):x(x),y(y){}
  bool operator<(const P&a)const {
    return y>a.y;
  }
};
struct P2{
  int x,y;
  P2(int x, int y):x(x),y(y){}
};

struct P3{
  int x,y;
  P3(int x, int y):x(x),y(y){}
  bool operator<(const P3&a)const {
    return y-x<a.y-a.x;
  }
};

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  string s;
  vector<P>p1;
  vector<P2>p2;
  vector<P3>p3;
  for(int i=0;i<n;i++){
    cin>>s;
    int cur = 0;
    int mi = 0;
    for(auto c:s){
      cur+=(c=='('?1:-1);
      mi = min(mi,cur);
    }
    if(cur<0)p3.emplace_back(cur, mi);
    else if(cur==0)p2.emplace_back(cur,mi);
    else p1.emplace_back(cur,mi);
  }
  sort(p1.begin(),p1.end());
  sort(p3.begin(),p3.end());
  int cur = 0;
  for(auto& p : p1){
    if(cur+p.y<0||cur+p.x<0){
      cout<<"No"<<endl;
      return 0;
    }
    cur+=p.x;
  }
  for(auto& p : p2){
    if(cur+p.y<0||cur+p.x<0){
      cout<<"No"<<endl;
      return 0;
    }
    cur+=p.x;
  }
  for(auto& p : p3){
    if(cur+p.y<0||cur+p.x<0){
      cout<<"No"<<endl;
      return 0;
    }
    cur+=p.x;
  }
  if(cur==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

int main(){
    bool judge;
    int a,b,c,d,e,k,ans;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;

    ans = e - a;

    if(ans <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    return 0;
}

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


public class A
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		long A = Int64.Parse(args[0]);
		long B = Int64.Parse(args[1]);
			
		Console.WriteLine(((B % A) == 0) ? A+B : B-A);
	}	
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(){
  int tri[4] = {};
  int l[3];
  
  while(cin >> l[0] >> l[1] >> l[2]){
    sort(l, l+3);
    if(l[0] + l[1] <= l[2]) break;
    
    tri[0]++;
    if(l[2]*l[2] == l[0]*l[0]+l[1]*l[1]) tri[1]++;
    if(l[2]*l[2] < l[0]*l[0]+l[1]*l[1]) tri[2]++;
    if(l[2]*l[2] > l[0]*l[0]+l[1]*l[1]) tri[3]++;
  }
  
  for(int i = 0 ; i < 4 ; i++){
    cout << tri[i];
    if(i == 3) cout << endl;
    else cout << " ";
  }
  return 0;
}

Measured memory_bytes: 1176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();
		if (L%2019==0||R%2019==0) {
			System.out.println(0);
			return ;
		}
		if (L/2019!=R/2019) {
			System.out.println(0);
			return ;
		}
		int min = 2019;
		for (long i=L;i<R;i++) {
			for (long j=i+1;j<=R;j++) {
				int temp = (int) (((i%2019)*(j%2019))%2019);
				if (temp<min) {
					min = temp;
				}
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef pair<int, int> pii;
const int maxn = 4000 + 10;
const int INF = 1e9;
int pos[2][maxn], inv[2][maxn], cnt[2][maxn][maxn], suf[maxn], dp[maxn][maxn];
char c[10];
int n, ans;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= 2 * n; ++i)
	{
		int val;
		scanf("%s%d", c, &val);
		int typ = c[0] == 'B' ? 0 : 1;
		pos[typ][val] = i;
	}
	for(int k = 0; k < 2; ++k)
		for(int i = 1; i <= n; ++i)
		{
			for(int j = 1; j < i; ++j)
				if(pos[k][j] > pos[k][i])
					++inv[k][i];
		}
	for(int j = 0; j <= n; ++j)
	{
		for(int i = pos[1][j]; i; --i)
			++suf[i];
		for(int i = 1; i <= n; ++i)	
			cnt[0][i][j] = inv[0][i] + suf[pos[0][i]];
	}
	memset(suf, 0, sizeof suf);
	for(int i = 0; i <= n; ++i)
	{
		for(int j = pos[0][i]; j; --j)
			++suf[j];
		for(int j = 1; j <= n; ++j)
			cnt[1][i][j] = inv[1][j] + suf[pos[1][j]];
	}
	for(int i = 0; i <= n; ++i)
		for(int j = 0; j <= n; ++j)
		{
			dp[i][j] = (i == 0 && j == 0) ? 0 : INF;
			if(i) dp[i][j] = min(dp[i][j], dp[i - 1][j] + cnt[0][i][j]);
			if(j) dp[i][j] = min(dp[i][j], dp[i][j - 1] + cnt[1][i][j]);
		}
	printf("%d\n", dp[n][n]);
	return 0;
}
/*
5
B 3
B 2
B 5
W 4
B 4
W 1
W 5
B 1
W 2
W 3
*/
	
			

Measured memory_bytes: 98048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll gcd(ll a, ll b) {
   if(a<b) swap(a, b);
   return b?gcd(b,a%b):a;
}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

   ll l=lcm((ll)a, (ll)b);
   cout<< l <<endl;
   return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  vector<int> num;
  for(auto ch: S){
    num.push_back(ch - '0');
  }
  num.erase(unique(num.begin(),num.end()),num.end());
  if(num.size()==4){
    cout << "Good" << endl;
  }else{
    cout << "Bad" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll ans=0;
	ll a=2,b=1,t,n;
	cin>>n;
	if(n==0)
		cout<<a<<endl;
	else if(n==1)
		cout<<b<<endl;
	else{
		for(int i=2;i<=n;i++){
			t=b;
			ans=a+b;
			a=b;
			b=ans;
		}
			cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256