akhauriyash/Code-Regression huggingface dataset:
// AOJ 2027: Reading a Chord
// 2017.12.11 bal4u@uu

#include <stdio.h>
#include <string.h>

char tones[12][3] = {"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
char base[5][3] = {"","7","M7","m","m7"};
char tension[12][4] = {"","-9","9","+9","-11","11","+11","","-13","13","+13"};
char tr['G'+1]['#'+1];
char f[12], t[12];
char ans[10][10]; int sz;
char tbl[5][4] = {{4,7},{4,7,10},{4,7,11},{3,7},{3,7,10}};

char t_b[12][5][6];

int main()
{
	int cno, m, i, a, b, u, v;
	char buf[5];

	tr['C'][0] = 0, tr['C']['#'] = 1, tr['D'][0] = 2, tr['D']['#'] = 3;
	tr['E'][0] = 4, tr['F'][0] = 5, tr['F']['#'] = 6;
	tr['G'][0] = 7, tr['G']['#'] = 8, tr['A'][0] = 9, tr['A']['#'] = 10;
    tr['B'][0] = 11;

	for (a = 0; a < 12; a++) for (b = 0; b < 5; b++)
		strcpy(t_b[a][b], tones[a]), strcat(t_b[a][b], base[b]);

	scanf("%d", &cno);
	while (cno--) {
		scanf("%d", &m);
		memset(f, 0, sizeof(f));
		while (m--) {
			scanf("%s", buf);
			if (buf[1] != '#') buf[1] = 0;
			f[tr[buf[0]][buf[1]]] = 1;
		}

		sz = 0;
		for (a = 0; a < 12; a++) for (b = 0; b < 5; b++) {
			memset(t, 0, sizeof(t));
			t[a] = 1;
			for (i = 0; tbl[b][i]; i++) t[(a+tbl[b][i])%12] = 1;

			if (!memcmp(f, t, sizeof(f))) {
				strcpy(ans[sz++], t_b[a][b]);
				continue;
			}

			for (i = 1; i <= 10; i++) {
				if (i == 7) continue;
				u = (a+i)%12;
				v = t[u], t[u] = 1;
				if (!memcmp(f, t, sizeof(f)))
					sprintf(ans[sz++], "%s(%s)", t_b[a][b], tension[i]);
				t[u] = v;
			}

			t[(a+7)%12] = 0, t[(a+18)%12] = 1;
			if (!memcmp(f, t, sizeof(f)))
				strcpy(ans[sz], t_b[a][b]), strcat(ans[sz++], "(-5)");

			t[(a+18)%12] = 0; t[(a+8)%12] = 1;
			if (!memcmp(f, t, sizeof(f)))
				strcpy(ans[sz], t_b[a][b]), strcat(ans[sz++], "(+5)");
		}

		if (!sz) puts("UNKNOWN");
		else {
			printf(ans[0]);
			for (i = 1; i < sz; i++) putchar(' '), printf(ans[i]);
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 1760
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;
bool is_prime[1111111];
vector<int> P;
void Eratosthenes(const int N) {
  for (int i = 0; i <= N; i++) {
    is_prime[i] = true;  // initialize.
  }
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
}
void input() {
  cin >> N;
  ;
  ;
}
void solve() {
  Eratosthenes(1111110);
  rep(i, N, 1111110) {
    if (is_prime[i]) {
      cout << i << endl;
      return;
    }
  };
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

vector<ll> v;
int n;
ll dp[222222][22];
ll four[22];

ll comp(ll a,ll b){
	ll ret = 0;
	ll mul = (a + b - 1) / b;
	ll tmp = 1;
	while(tmp < mul){
		tmp *= 4;
		ret++;
	}
	return ret;
}

ll dfs(int a, int b){
	if(dp[a][b] != -1)return dp[a][b];
	if(a == n-1)return dp[a][b] = 0;
	ll tmp = comp(four[b]*v[a],v[a+1]);
	if(tmp > 15){
		return dp[a][b] = 15 + (tmp - 15) * (n - a - 1) + dfs(a+1, 15);
	}
	else{
		return dp[a][b] = tmp + dfs(a+1,tmp);
	}
}

vector<ll> seica(){
	REP(i,222222)REP(j,22)dp[i][j] = -1;
	vector<ll> ret(n);
	for(int i = n-1;i >= 0;i--) {
		ret[i] = dfs(i, 0);
	}
	return ret;
}

int main(){
	
	cin >> n;
	four[0] = 1;
	REP(i,20)four[i+1] = four[i] * 4;
	REP(i,n){
		int tmp;cin >> tmp;
		v.EB(tmp);
	}
	
	auto A = seica();
	reverse(ALL(v));
	auto B = seica();reverse(ALL(B));
	
	ll ans = min(2 * A[0], 2 * B[n-1] + n);
	REP(i,n-1){
		ans = min(ans, 2*(A[i+1]+B[i])+(i+1));
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 44528
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m;
    cin>>n>>m;
    if(m<n) swap(n,m);
    if(n==1){
        cout<<max(1ll,n*m-2)<<endl;
    }
    else{
        cout<<(n-2)*(m-2)<<endl;
    }

    

    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

std = []
for i in range(n):
  std.append(list(map(int,input().split())))

chk = []
for j in range(m):
  chk.append(list(map(int,input().split())))

min_chk=[[float('inf')]*2]*n
for i in range(n):
    min_index=0
    for j in range(m):
        if (abs(std[i][0]-chk[j][0])+abs(std[i][1]-chk[j][1])) < (abs(std[i][0]-min_chk[i][0])+abs(std[i][1]-min_chk[i][1])):
            min_chk[i]=chk[j]
            min_index=j
    print(min_index+1)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	ll K,A,B;

	cin >> K >> A >> B;

	if(B - A <= 2){
		println(K+1);
	}else{
		ll n;
		n = (K-A+1)/2;
		if((K-A+1)%2==0){
			println(n*(B-A)+A);
		}else{
			println(n*(B-A)+A+1);
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int solve(){}
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
    v p(a);in(p,a);
    v q(b);in(q,b);
    v r(c);in(r,c);
    sort(all(p));
    sort(all(q));
    sort(all(r));
    int p1=a-x;
    int p2=b-y;
    int p3=c-1;
    while(p3>=0)
    {
        if(p1 >=a && p2>=b)
            break;
        if(p1 >=a )
        {
            if(r[p3] < q[p2])
                break;
            p3--;
            p2++;
            continue;
        }
        if(p2 >=b)
        {
            if(r[p3] < p[p1])
                break;
            p3--;
            p1++;
            continue;
        }
        if(r[p3] <=min(p[p1],q[p2]))
            break;

        if(p[p1] < q[p2])
        {
            p1++;

        }
        else
            p2++;
        p3--;
    }
    int sum=0;
    for(int i=p3+1;i<c;i++)sum+=r[i];
    for(int i=p1;i<a;i++)sum+=p[i];
    for(int i=p2;i<b;i++)sum+=q[i];
    cout<<sum<<endl;
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VL xs(N);
  cin >> xs;

  LL ans = 1e18;
  LL sum = accumulate(ALL(xs), 0ll);
  xs.pop_back();
  LL acc = 0;
  for(auto x: xs){
    acc += x;
    mini(ans, abs(sum-acc - acc));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  
  int num0 = '0';
  int data[8];
  data[0] = (s.at(0) - num0) * 1000;
  data[1] = (s.at(1) - num0) * 100;
  data[2] = (s.at(2) - num0) * 10;
  data[3] = (s.at(3) - num0) ;
  data[4] = (s.at(5) - num0) * 10;
  data[5] = (s.at(6) - num0) ;
  data[6] = (s.at(8) - num0) * 10;
  data[7] = (s.at(9) - num0) ;

  int y = data[0] + data[1] + data[2] + data[3];
  int m = data[4] + data[5];
  int d = data[6] + data[7];
  
  string ans = "Heisei";
  if( y > 2019 || (y == 2019 && m > 4)){ans = "TBD";}
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
//動的計画法！！！
int main() {
  int N;
  string S;
  cin>>N>>S;
  vector<vector<int>> dp(N, vector<int> (N,0));
  int ans = 0;
  rep(i,N){
    if(S[i]==S[N-1]) {
      dp[i][N-1]=1;
      dp[N-1][i]=1;
    }
  }
  
  for(int i=N-2;i>=0;--i){
    for(int j=N-2;j>=0;--j){
      if(S[i]==S[j]){
        dp[i][j]=dp[i+1][j+1]+1;
      }
    }
  }
  rep(i,N){
    rep(j,N){
      ans = max(ans, min(dp[i][j],abs(i-j)));
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 98176
#include<bits/stdc++.h>
using namespace std;
int i,i0,n,m,ans;
int main()
{
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    int d=min(C,A-B);
    printf("%d\n",C-d);
    return 0;
}

Measured memory_bytes: 764
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio;
    string s,s2,s3;
    int a,b,x,count=0;
    cin>>a>>b;
    cout<<(a<=b ? a : a-1);
    return(0);
}

Measured memory_bytes: 256
# 1. ソート対象の配列をピポット(=分割の基準)を基準に2つの部分配列に分割(divide)
# 2. 前方の部分配列に対してquick_sortを行う(solve)
# 3. 後方の部分配列に対してquick_sortを行う(solve)
# 4. 整列済み部分配列とピボットを連結して返す(Conquer)
def quick_sort(arr):
    if len(arr) < 2:
        return arr
    p = arr[0]
    left, right = divide(p, arr[1:])
    return quick_sort(left) + [p] + quick_sort(right)
    
def divide(p, arr):
    left, right = [], []
    for i in arr:
        if p > i:
            left.append(i)
        else:
            right.append(i)
    return left, right

arr = quick_sort(list(map(int, input().split())))
print(f'{arr[0]} {arr[1]} {arr[2]}')


Measured memory_bytes: 5612
X=input()
Y=input()
dp= [[0 for j  in range(len(X) + 1)] for k in range(len(Y)+ 1)]
for i in range(len(X)+1):
    dp[0][i]=i
for i in range(len(Y)+1):
    dp[i][0]=i
for i in range(1,len(X)+1):
    for j in range(1,len(Y)+1):
        if X[i-1] == Y[j-1]:
            dp[j][i] = dp[j-1][i-1]
        else:
            dp[j][i] = min(dp[j-1][i], dp[j][i-1], dp[j-1][i-1]) + 1
print(dp[len(Y)][len(X)])


Measured memory_bytes: 42892
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    if (a < b)
    printf("a < b\n");
    else if(a > b)
    printf("a > b\n");
    else if(a == b)
    printf("a == b\n");
    return 0;
}


Measured memory_bytes: 2608
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

#define MOD 1000000007
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  if (m >= n) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  string s;
  cin >> s;
  int count=0,tmp=0,ans=100;
  for(int i=0;i<26;i++){
    count=tmp=0;
    for(int j=0;j<s.length();j++){
      if(s[j]=='a'+i){
        tmp=max(tmp,count);
        count=0;
      }else{
        count++;
      }
    }
    tmp=max(tmp,count);
    ans=min(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// ConvexCut
// 2012/09/19
public class Main{
	Scanner sc=new Scanner(System.in);

	double EPS=1e-6;

	int n;
	P[] ps;

	void run(){
		n=sc.nextInt();
		ps=new P[n];
		for(int i=0; i<n; i++){
			int x=sc.nextInt();
			int y=sc.nextInt();
			ps[i]=new P(x, y);
		}
		solve();
	}

	void solve(){
		P g=new P();
		for(int i=0; i<n; i++){
			g=g.add(ps[i]);
		}
		g=g.div(n);
		boolean ok=true;
		double full=area(ps);
		Random rand=new Random();
		for(int i=0; i<2*n; i++){
			P cut=inDiv(ps[i%n], ps[(i+1)%n], rand.nextDouble(),
					rand.nextDouble());
			P[] qs=convexCut(ps, cut, g);
			double area=area(qs);
			ok&=reEq(full/2, area);
		}
		println(ok?(g.x+" "+g.y):"NA");
	}

	P inDiv(P p, P q, double m, double n){
		return p.mul(n).add(q.mul(m)).div(m+n);
	}

	// relative error
	boolean reEq(double a, double b){
		if(a==0){
			return abs(b)<EPS;
		}else{
			return abs((a-b)/a)<EPS;
		}
	}

	double area(P[] ps){
		double area=0;
		for(int i=1; i<ps.length-1; i++){
			double a=ps[0].sub(ps[i]).abs();
			double b=ps[0].sub(ps[i+1]).abs();
			double c=ps[i].sub(ps[i+1]).abs();
			double s=(a+b+c)/2;
			area+=sqrt(s*(s-a)*(s-b)*(s-c));
		}
		return area;
	}

	P[] convexCut(P[] ps, P p1, P p2){
		int n=ps.length;
		ArrayList<P> res=new ArrayList<P>();
		for(int i=0; i<n; i++){
			int d1=(int)signum(p2.sub(p1).det(ps[i].sub(p1)));
			int d2=(int)signum(p2.sub(p1).det(ps[(i+1)%n].sub(p1)));
			if(d1>=0)
				res.add(ps[i]);
			if(d1*d2<0)
				res.add(isLL(p1, p2, ps[i], ps[(i+1)%n]));
		}
		return res.toArray(new P[0]);
	}

	P isLL(P p1, P p2, P q1, P q2){
		double d=q2.sub(q1).det(p2.sub(p1));
		if(abs(d)<EPS)
			return null;
		return p1.add(p2.sub(p1).mul(q2.sub(q1).det(q1.sub(p1))/d));
	}

	class P implements Comparable<P>{
		double x, y;

		P(){
			this(0, 0);
		}

		P(double x, double y){
			this.x=x;
			this.y=y;
		}

		P add(P p){
			return new P(x+p.x, y+p.y);
		}

		P sub(P p){
			return new P(x-p.x, y-p.y);
		}

		P mul(double m){
			return new P(x*m, y*m);
		}

		P div(double d){
			return new P(x/d, y/d);
		}

		double abs(){
			return sqrt(abs2());
		}

		double abs2(){
			return x*x+y*y;
		}

		double arg(){
			return atan2(y, x);
		}

		double dot(P p){
			return x*p.x+y*p.y;
		}

		double det(P p){
			return x*p.y-y*p.x;
		}

		double ang(P p){
			return atan2(det(p), dot(p));
		}

		P rot90(){
			return new P(y, -x);
		}

		P rot(double d){
			return new P(cos(d)*x-sin(d)*y, sin(d)*x+cos(d)*y);
		}

		@Override
		public int compareTo(P p){
			if(x!=p.x)
				return Double.compare(x, p.x);
			else
				return Double.compare(y, p.y);
		}

		@Override
		public String toString(){
			return "("+x+", "+y+")";
		}
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] intputString = br.readLine().split(" ");

            int numberLeft = Integer.parseInt(intputString[0]);
            String operator = intputString[1];
            int numberRight = Integer.parseInt(intputString[2]);
            
            int result = 0;

            if (operator.equals("+")) {
                result = numberLeft + numberRight;
            } else if (operator.equals("-")) {
                result = numberLeft - numberRight;
            }

            System.out.println(result);

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 23252
A,B,C,X,Y=map(int,input().split())

ans=0
if C*2<=A+B:
    mi=min(X,Y)
    ans=mi*C*2
    if Y<=X:
        ans+=min(A*(X-mi),2*C*(X-mi))
    else:
        ans+=min(B*(Y-mi),2*C*(Y-mi))
else:
    ans=A*X+B*Y
print(ans)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;

int main() {
    string s;
    cin>>s;
    int ans=0,mx=0;
    for(int i=0;i<s.length();i++)
    {
        while(i<s.length() && s[i]=='R')
        {
            ans++;
            i++;
        }
        mx=max(mx,ans);
        ans=0;
        
    }
    cout<<mx<<"\n";
return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    long long int dp[11][1001];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<=100;i++){
        for(int j=9;j>=0;j--){
            for(int k=0;i+k<=1000;k++){
                dp[j+1][i+k]+=dp[j][k];
            }
        }
    }
    int n,s;
    while(cin>>n>>s,n||s)cout<<dp[n][s]<<endl;
}

Measured memory_bytes: 1248
N = int(input())
a_list = [a for a in map(int, input().split())]
a_list.insert(0, 0)
a_list.append(0)
S = 0
before = 0
for a in a_list:
    S += abs(a - before)
    before = a

for i in range(1, N+1):
    a = a_list[i]
    s = S + abs(a_list[i-1] - a_list[i+1]) - (abs(a_list[i-1] - a_list[i]) + abs(a_list[i] - a_list[i+1]))
    print(s)


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


vector<set<int> >adj;
int deg[100005];
set<pair<int,int> >s;
int ans[100005];

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    int x,y;
    for(int i=0;i<n-1+m;i++)
    {
        cin>>x>>y;
        adj[x].insert(y);
        deg[y]++;
    }
    for(int i=1;i<=n;i++)
    {
        s.insert({deg[i],i});
    }

    while (!s.empty())
    {
        pair<int,int>pp=*s.begin();
        s.erase(s.begin());
        for(auto j:adj[pp.second])
        {
                s.erase({deg[j],j});
                deg[j]--;
                if(deg[j]==0)
                    ans[j]=pp.second;
                s.insert({deg[j],j});
        }
    }
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<'\n';
    

}


Measured memory_bytes: 20304
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++) {
		if(s[i]=='C') {
			for(int j = i+1;j<s.size();j++) {
				if(s[j]=='F') {
					cout << "Yes" << endl;
					return 0;
				}
			}
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 384
import heapq

N = int(input())
v = list(map(float, input().split(" ")))
heapq.heapify(v)

while len(v) > 1:
  a, b = heapq.heappop(v), heapq.heappop(v)
  heapq.heappush(v, (a + b) / 2)
print(heapq.heappop(v))

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    long long int n;
    cin >> n;

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

    return 0;

}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    char c;
    cin >>c;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<(char)(c+1)<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力

        //// スペース区切りの整数の入力
        int N = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] ai = new int[input.Length];

        for (int i = 0; i < input.Length; i++)
        {
            ai[i] = int.Parse(input[i]);
        }
        Array.Sort(ai);
        Array.Reverse(ai);

        int res = 0;

        int alicePoint = 0;
        int bobPoint = 0;

        for (int i = 0; i < N; i++)
        {
            if (i % 2 == 0)
            {
                alicePoint += ai[i];
            }
            else
            {
                bobPoint += ai[i];
            }

        }

        res = alicePoint - bobPoint;


        //出力
        Console.WriteLine(res.ToString());
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

int main()
{
	int N; cin >> N;
	for (int i = 1; i <= N; i++) {
		if ((int)(i * 1.08) == N) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int L;
main()
{
	cin>>L;
	int I=1,C=1,M=L,E=0;
	while(I*2<=L)I*=2,C++;
	vector<vector<pair<int,int> > >G(C);
	for(int i=0;i<C-1;i++)
	{
		G[i].push_back(make_pair(i+1,0));
		G[i].push_back(make_pair(i+1,1<<i));
		E+=2;
		if(L&(1<<i))
		{
			M-=1<<i;
			G[i].push_back(make_pair(C-1,M));
			E++;
		}
	}
	cout<<C<<" "<<E<<endl;
	for(int i=0;i<C-1;i++)
	{
		for(int j=0;j<G[i].size();j++)cout<<i+1<<" "<<G[i][j].first+1<<" "<<G[i][j].second<<endl;
	}
}


Measured memory_bytes: 256
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func main() {
  N := NextInt()
  S := NextLine()
  S0 := make([]int, N)
  S1 := make([]int, 10)
  S2 := make([]int, 100)
  L := make([]int, 10)
  for i, s := range S {
    n := int(s) - 48
    S0[i] = n
    L[n] = i
  }
  sort.Ints(L)
  p := 0
  cnt := 0
  ans := 0
  for i, s := range S0 {
    for p < 10 && i == L[p] {
      ans += cnt
      p++
    }
    for j := 0; j < 10; j++ {
      if S1[j] == 0 { continue }
      t := j * 10 + s
      if S2[t] == 0 {
        S2[t]++
        cnt++
      }
    }
    S1[s]++
  }
  Write(ans)
  Output()
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N=100005,Mod=1e9+7;
bool bk[N];int dp[N];
int main (){
	int n,m;scanf ("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		int x;scanf ("%d",&x);
		bk[x]=true;
	}
	dp[0]=1;
	for (int i=0;i<=n;i++){
		if (bk[i]) dp[i]=0;
		dp[i+1]=(dp[i+1]+dp[i])%Mod;
		dp[i+2]=(dp[i+2]+dp[i])%Mod;
	}
	printf ("%d",dp[n]);
	return 0;
} 

Measured memory_bytes: 768
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    val w = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    var l = 0
    var r = 0
    val s = w.sum()
    val ans = mutableSetOf<Int>()
    for (i in w.indices) {
        l = w.take(i).sum()
        r = s - l
        ans.add(Math.abs(l - r))
    }
    println(ans.min()!!)
}


Measured memory_bytes: 36136
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ll MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

void solve(){
     int n,k;cin >> n >> k;
     multiset<ll>s;
     for(int i = 0;i<n;i++){
        ll a;cin >> a;
        s.insert(a);
     }
     for(int i = 0;i<k;i++){
        ll temp = *s.rbegin();
        s.erase(s.find(*s.rbegin()));
        temp /= 2;
        s.insert(temp);
     }
     ll sum = 0;
     for(auto it:s){
        sum += it;
     }
     cout << sum;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 8336
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
	string s, t;
	cin >> s >> t;
	// check: tに使われている文字が，sに含まれているか
	map<char, vector<ll>> s_dic;
	ll ssize = s.size();

	rep(i, ssize) {
		s_dic[s[i]].push_back(i);
	}
	rep(i, t.size()) {
		if(s_dic[t[i]].empty()) {
			cout << -1 << endl;
			return 0;
		} 
	}

	ll cnt = 0;
	ll place = 0;
	rep(i, t.size()) {
		//cout << "search: " << t[i] << endl;
		//ll place = cnt%s.size();
		//tmp = s_dic[t[i]];
		if(place>s_dic[t[i]][s_dic[t[i]].size()-1]) {
			cnt += ssize - place;
			place = 0;
		}
		
		ll left = -1, right = s_dic[t[i]].size();
    while(right-left>1) {
			ll mid = left + (right - left) /2;
			if(place<=s_dic[t[i]][mid]) right = mid;
			else left = mid;
		}
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
		cnt += (s_dic[t[i]][right] - place + 1);
		place = s_dic[t[i]][right] + 1;

		//cout << "check " << cnt << endl;
	}

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


Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    int val;
    map <int, bool> mp;
    int countMax = 0;
    for(int i = 0; i < n; i ++)
    {
    	cin >> val;
    	int check = val / 400 + 1;
    	if(val >= 3200)
    		countMax ++;
    	else
    		mp[check] = true;    	
    }

    int size = mp.size();
    if(mp.size() != 0)
    	cout << mp.size() << " " << size + countMax;
    else
    	cout << "1" << " " << countMax;
}

Measured memory_bytes: 256
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

class UnionFind:
	def __init__(self, n):
		self.n = n
		self.sizes = [0]*n
		self.parents = list(range(n))

	def find(self, x):
		while x != self.parents[x]:
			self.parents[x] = self.parents[self.parents[x]]
			x = self.parents[x]
		return self.parents[x]

	def unite(self, x, y):
		x, y = self.find(x), self.find(y)
		if x == y:
			return
		if self.sizes[x] < self.sizes[y]:
			x, y = y, x
		self.parents[y] = x
		self.sizes[x] += self.sizes[y]
	
	def add(self, x):
		self.sizes[x] = 1
		
	def size(self, x):
		return self.sizes[self.find(x)]

N, M = rl()
edges = set()
for i in range(M):
	a, b = rl()
	a, b = a-1, b-1
	edges.add((a,b))

uf =UnionFind(N)

for a, b in edges:
	uf.unite(a, b)
	uf.find(a)
	uf.find(b)

ans = 0
cnt = [0] * N
for i in range(N):
	p = uf.find(i)
	np = cnt[p] + 1
	ans = max(ans, np)
	cnt[p] = np
print(ans)


Measured memory_bytes: 111084
#include <iostream>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	vector<pair<int, char> > sc(m);
	for (auto& a : sc) {
		cin >> a.first >> a.second;
		--a.first;
	}
	for (int i = 0; i < 1000; ++i) {
		string x = to_string(i);
		if (x.size() != n) continue;
		int j;
		for (j = 0; j < m; ++j)
			if (x[sc[j].first] != sc[j].second) break;
		if (j == m) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n,m;
    cin>>n>>m;
    int ans=0;
    pair<int,int> a[n];
    for(int i=0;i<n;i++){
       cin>>a[i].first>>a[i].second; 
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
      if(a[i].second>=m){
          ans+=a[i].first*m;
          break;
      }
      else{
        ans+=a[i].first*a[i].second;
        m-=a[i].second;
      }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

const int MOD = 998244353;

int main(void){
    int N, K;
    string S;
    vector<int> numOne(1, 0);
    int numOneAll = 0;
    //dp[i][j][k] : numOne[i to max], j times moved, numOne[i]+=k
    vector<vector<vector<int>>> dp;
    cin >> S >> K;
    N = S.size();
    for(int i=0; i<N; i++){
        if(S[i]=='0'){
            numOne.push_back(0);
        }else{
            numOne[numOne.size()-1]++;
            numOneAll++;
        }
    }
    int efcK = min(K, numOneAll);
    dp.assign(numOne.size(), vector<vector<int>>(efcK+1, vector<int>(efcK+1, 0)));
    dp[numOne.size()-1][0][0] = 1;
    for(int i=numOne.size()-2; i>=0; i--){
        for(int j=0; j<=efcK; j++){
            int dpsumbuf = 0;
            for(int k=j; k>=0; k--){
                //terms of the same k
                dpsumbuf += dp[i+1][j][k];
                dpsumbuf %= MOD;
                dp[i][j][k] += dpsumbuf;
                dp[i][j][k] %= MOD;
            }
            //terms of the different k
            dpsumbuf = 0;
            for(int k=0; j+k+1<=efcK; k++){
                //use only numOne[i+1] terms
                dpsumbuf += dp[i+1][j+k][k];
                dpsumbuf %= MOD;
                if(k >= numOne[i+1]){
                    dpsumbuf += MOD - dp[i+1][j+k-numOne[i+1]][k-numOne[i+1]];
                    dpsumbuf %= MOD;
                }
                dp[i][j+k+1][k+1] += dpsumbuf;
                dp[i][j+k+1][k+1] %= MOD;
            }
        }
    }
    int res = 0;
    for(int j=0; j<=efcK; j++){
        for(int k=0; k<=j; k++){
            res += dp[0][j][k];
            res %= MOD;
        }
    }
    cout << res << endl;
    return 0;
}

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

int N;
int x[10],y[10];
double dist(int i,int j){
   double dx = x[i]-x[j];
   double dy = y[i]-y[j];
   return pow(dx*dx+dy*dy,0.5);
}

void solve(){
cin>>N;
for(int i=1;i<=N;i++)cin>>x[i]>>y[i];
double sum=0.0;
vector<int> v(N);
for(int i=0;i<N;i++)v[i]=i+1;
do{
   for(int i=0;i<N-1;i++) sum+=dist(v[i],v[i+1]);

}while(next_permutation(v.begin(),v.end()));
int Factorial=1;
for(int i=2;i<=N;i++) Factorial*=i;
cout<<fixed<<setprecision(10)<<sum/Factorial<<endl;
return;
}

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




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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define step(i,s,n,c) for(int i=(s);i<(n);i+=(c))
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define each(i,vec) for(auto i:vec)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  int n,a,b;
  cin>>n>>a>>b;
  cinv(n,x);

  ll res=0;
  rep(i,n-1){
    int d=x[i+1]-x[i];
    res+=min(a*d,b);
  }
  out(res);
  
  
  return 0;
}


Measured memory_bytes: 1024
using System;

class OrdinaryNumber
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ');
        int[] array = new int[n];
        var answer = 0;
        for (var i = 0; i < input.Length; i++)
        {
            array[i] = int.Parse(input[i]);
        }

        for (var i = 1; i < n - 1; i++)
        {
            var num1 = array[i - 1];
            var num2 = array[i];
            var num3 = array[i + 1];

            if (num2 < num1)
            {
                if (num3 < num1)
                {
                    if (num2 > num3)
                    {
                        answer++;
                    }
                }
            }
            else if (num2 < num3)
            {
                if (num1 < num3)
                {
                    if (num2 > num1)
                    {
                        answer++;
                    }
                }
            }
        }
        Console.WriteLine(answer);
    }
}


Measured memory_bytes: 13140
/*
AizuOnline A0195
Title
*/
#include <stdio.h>
//
main()
{
  int c;
  int saidai,saidaimise;
  int u1,u2;

    c=1;saidai=0;
    while(EOF!=scanf("%d %d",&u1,&u2) && (u1 || u2))
      {
	if(saidai < u1+u2)
	  {
	    saidaimise=c;
	    saidai=u1+u2;
	  }
	if(c==5)
	  {
	    printf("%c %d\n",'A'+saidaimise-1,saidai);
	    c=1;
	    saidai=0;
	  }
	else
	  c++;
      }
return(0);
}

Measured memory_bytes: 600
//prepared by dumb
#include<bits/stdc++.h>
using namespace std;
#define   ll  long long int
#define   dl double
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scld(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   inf 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
#define   eps 1e-8
// Creates a min heap
//priority_queue <int, vector<int>, greater<int> > pq;
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll lcm(ll a, ll b)
{
    return (a * b) / __gcd(a, b);
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll a, b, c, d, e, f = 0, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
    ll cnt = 0, ans = 0, l1, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
    ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm;
    string str, str1, str2,str3="",str4="";
    scll(n);
   cin>>str;

ll lef=0;
ll right=n-1;
   while(lef<=n-1&&right>=0)
   {
    while(str[lef]=='R'&&lef<=n-1)
    {
        lef++;
    }
    while(str[right]=='W'&&right>=0)
    {
        right--;
    }
    if(lef<right)
    {
        swap(str[lef],str[right]);
        cnt++;
    }
    else
        break;
   }
cout<<cnt;

return 0;
}

Measured memory_bytes: 3788
# -*- coding: utf-8 -*-
from string import ascii_lowercase

s = list(input())
n = len(s)
k = int(input())

d = {}
d2 = {}
for i in range(len(ascii_lowercase)):
    c = ascii_lowercase[i]
    d[c] = (len(ascii_lowercase)-i)%len(ascii_lowercase)
    d2[c] = i

for i in range(n):
    if s[i]!="a" and d[s[i]]<=k:
        k -= d[s[i]]
        s[i] = "a"

if k>0:
    k %= len(ascii_lowercase)
    s[-1] = ascii_lowercase[(d2[s[-1]]+k)%len(ascii_lowercase)]

print("".join(s))


Measured memory_bytes: 4792
import java.util.Scanner

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val sa = scanner.next()
    val sb = scanner.next()
    val a = Integer.parseInt(sa)
    val b = Integer.parseInt(sb)
    val c = a - 2*b
    if(c>0){
        println("${c}")
    } else {
        println(0)
    }
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans1 = double(w)*h/2;
    int ans2 = (x*2==w&&y*2==h)?1:0;
    printf("%.10f %d\n", ans1, ans2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  string s;
  cin >> s;
  vector<vector<mint>> dp(s.size()+1, vector<mint>(13, 0));
  dp[0][0] = 1;
  rep(i, s.size()) {
    rep(j, 13) {
      if (s[i] == '?') {
        rep(k, 10) dp[i+1][(j*10+k)%13] += dp[i][j];
      }
      else {
        int k = s[i]  - '0';
        dp[i+1][(j*10+k)%13] += dp[i][j];
      }
    }
  }
  cout << dp[s.size()][5] << endl;
}

Measured memory_bytes: 16704
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0) solve(n);
	}
    }

    static void solve(int n){
	int[] key = new int[n];
	String[] ss = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", 
		       "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
		       "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
		       "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
		       "S", "T", "U", "V", "W", "X", "Y", "Z"};
	int i, j, k;
	// 鍵読み込み
	for(i=0; i<n; i++){
	    key[i] = kbd.nextInt();
	}
	String s = kbd.next(); // リスト
	//System.out.println(s);
	String ans = "";
	i=0;
	k=0;
	while(i<s.length()){
	    String x = s.substring(i, i+1);
	    j=0;
	    while(!x.equals(ss[j])) j++;
	    //System.out.println(k);
	    ans += ss[(j-key[k]+ss.length)%ss.length];
	    i++;
	    k = (k+1)%n;
	}
	System.out.println(ans);
    }
}

Measured memory_bytes: 27616
import java.util.*;

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

        int a, b;
        a = sc.nextInt(); // 羊
        b = sc.nextInt(); // 狼
        if(a<=b){
            System.out.println("unsafe");
        }else{
            System.out.println("safe");
        }

    }
}

Measured memory_bytes: 27048