akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
vector<P> vs[200010];
struct ISet : map<ll, ll> {
    void insert(ll l, ll r) {
        auto itl = upper_bound(l), itr = upper_bound(r + 1);
        if (itl != begin()) {
            --itl;
            if (itl->second < l) {
                ++itl;
            }
        }
        if (itl != itr) {
            l = min(l, itl->first);
            r = max(r, prev(itr)->second);
            erase(itl, itr);
        }
        (*this)[l] = r;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, x, d;
    cin >> n >> x >> d;
    ll y = x - d;
    if (d == 0) {
        if (y == 0) {
            cout << 1 << endl;
        } else {
            cout << n + 1 << endl;
        }
        return 0;
    }
    if (d < 0) {
        y *= -1LL;
        d *= -1LL;
    }
    ll res = 0;
    vector<ll> v;
    for (ll k = 0; k <= n; k++) {
        v.push_back((k * y) % d);
    }
    sort(all(v));
    v.erase(unique(all(v)), v.end());
    for (ll k = 0; k <= n; k++) {
        int id = lower_bound(all(v), (k * y) % d) - v.begin();
        ll l = k * y / d + k * (k + 1LL) / 2LL,
           r = k * y / d + k * (n - k + 1LL + n) / 2LL;
        vs[id].push_back(P(l, r));
        //  cout << id << " " << l << " " << r << endl;
    }
    for (int i = 0; i < v.size(); i++) {
        ISet st;
        for (auto &p : vs[i]) {
            st.insert(p.first, p.second);
        }
        for (auto it = st.begin(); it != st.end(); it++) {
            res += it->second - it->first + 1LL;
        }
    }
    cout << res << endl;
}

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

int main(){
int x,n=1;
cin >> x;
for (int i=2;i<=x;i++){
for (int j=2;j<=x;j++){
if (n<=pow(i,j) && x>=pow(i,j)) n=pow(i,j);
}
}
cout << n << endl;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
#define INF (1e9)
int main() {
    int H,N;cin>>H>>N;
    vi A(N),B(N);
    for (int i = 0; i < N; i++){
        cin>>A[i]>>B[i];
    }
    vi dp(H+1,INF);
    dp[H]=0;
    for (int h = H; h >=0 ; h--){
        for (int i = 0; i < N; i++){
            if(h-A[i]<0)dp[0]=min(dp[0],dp[h]+B[i]);
            else dp[h-A[i]]=min(dp[h-A[i]],dp[h]+B[i]);
        }
    }
    cout<<dp[0]<<endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
ll b_pow(ll x,ll n){return n ? n==1 ? x: b_pow(x,n>>1)*b_pow(x,(n>>1)+(n&1)) : 1;}

int main(){
	ll z;
	while(cin >> z && z){
		ll ans = 0;
		for(ll x = 1 ; x*x*x <= z*z*z ; x++)
			for(ll y = 1 ; y*y*y+x*x*x <= z*z*z ; y++)
				ans = max(ans,x*x*x+y*y*y);
		cout << z*z*z-ans << endl;
	}
}

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

int main(){
    string s;
    cin >> s;
    int pos_A,pos_Z;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'A'){
            pos_A = i;
            break;
        }
    }
    for (int i = 0; i < s.size(); i++)
    {
        if(s[s.size()-i-1] == 'Z'){
            pos_Z = s.size()-i-1;
            break;
        }
    }
    
    cout << pos_Z - pos_A + 1 << endl;
    return 0;
}

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

void trace(int a[], int n){
	for (int i = 0; i < n; i++){
		cout << a[i];
		if (i != n - 1) cout << " ";
		else cout << endl;
	}
}

int insertionSort(int a[], int n, int g){
    int cnt = 0;
	for(int i = g; i < n; i++){
		int v = a[i], j;
		for(j = i - g; j >= 0 && a[j] > v; j -= g){
			a[j + g] = a[j];
            cnt++;
		}
    		a[j + g] = v;
	}
    return cnt;
}

void shellSort(int a[], int n){
    int cnt = 0, m = 0;
    int g[13], g2[13];
    g2[0] = 1;
    for(int i = 1; i < 13; i++) g2[i] = g2[i - 1] * 3 + 1;
    for(int i = 0; i < 13; i++) if(g2[12 - i] <= n) g[m++] = g2[12 - i];
    cout << m << endl;
    trace(g, m);
    for(int i = 0; i < m; i++) cnt += insertionSort(a, n, g[i]);
    cout << cnt << endl;
}

int main(void){
	int n, a[1000000];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

    shellSort(a, n);
    for(int i = 0; i < n; i++) cout << a[i] << endl;
	return 0;
}



Measured memory_bytes: 6920
#include <bits/stdc++.h>
   
using namespace std;
   
#define MAX 50
   
int N, day;
bool ok[MAX][31];
bool visited[MAX];
   
void init(){
    day = 0;
    memset(ok, false, sizeof(ok));
}
   
int solve(){
    int ans = -1;
    set<int> dp[MAX];
  
    for(int i = 0 ; i < N ; i++){
	dp[i].insert(i);
    }
  
    for(int i = 0 ; i <= day ; i++){
	for(int j = 0 ; j < N-1 ; j++){
	    if(!ok[j][i]) continue;
	    for(int k = j+1 ; k < N ; k++){
		if(ok[k][i]){
		    set<int>::iterator it;
		    for(it = dp[j].begin() ; it != dp[j].end() ; ++it){
			dp[k].insert(*it);
		    }
		    for(it = dp[k].begin() ; it != dp[k].end() ; ++it){
			dp[j].insert(*it);
		    }
		}
	    }
	    if(dp[j].size() == N) return i+1;
	}
    }
    return ans;
}
   
int main(){
    int K, in;
    while(cin >> N && N){
	init();
	for(int i = 0 ; i < N ; i++){
	    cin >> K;
	    for(int j = 0 ; j < K ; j++){
		cin >> in;
		ok[i][in-1] = true;
		day = max(day, in);
	    }
	}
	cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef unsigned long long int ulli;
typedef long long int lli;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

int N, K;
lli* V;

lli sum(int left, int right);

int func(const void *a, const void *b);

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

    cin >> N >> K;
    V = new lli[N];

    rep(i, N)
    {
        cin >> V[i];
    }

    int n = MIN(N, K);
    lli ret = 0;
    for (int left = 0; left <= n; ++left)
    {
        for (int right = 0; right <= n - left; ++right)
        {
            ret = MAX(ret, sum(left, right));
        }
    }

    cout << ret << "\n";

    return 0;
}

lli sum(int left, int right)
{
    int* minus = new int[K];
    int size = 0;
    lli sum = 0;
    rep(i, left)
    {
        sum += V[i];
        if (V[i] < 0)
        {
            minus[size++] = -V[i];
        }
    }
    rep(i, right)
    {
        sum += V[N - i - 1];
        if (V[N - i - 1] < 0)
        {
            minus[size++] = -V[N - i - 1];
        }
    }

    if (size <= K - left - right)
    {
        rep(i, size)
        {
            sum += minus[i];
        }
    }
    else
    {
        qsort((void*)minus, size, sizeof(int), func);
        rep(i, K - left - right)
        {
            sum += minus[i];
        }
    }

    return sum;
}

int func(const void *a, const void *b)
{
    return *(const int*)b - *(const int*)a;
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

lli body(lli a, lli b){
	return (a-b)*(a-b);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, k;
	cin >> n >> k;
	vector<lli> h(n);
	rep(i,n){
		cin >> h[i];
	}
	sort(all(h));
	lli ans=0;
	rep(j,n-k){
		ans += h[j];
	}
	cout << ans << endl;
 	return 0;
}


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

int main()
{
  uint64_t n;
  uint64_t m = 0;

  cin >> n;

  for (uint64_t i = 0; i < n; ++i) {
    uint64_t a;
    cin >> a;
    m += (a != i+1);
  }

  if (m <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
import numpy as np
A, B, H, M = map(float, input().split())
tH = 2*np.pi*(H*60+M)/60/12
tM = 2*np.pi*M/60
t = tH - tM
l = np.sqrt(A*A + B*B - 2*A*B*np.cos(t))
print(l)

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main()
{
	string S;
	int w;
	cin >> S >> w;
	for(int i = 0; i < S.size(); i += w)
		cout << S[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include"iostream"
using namespace std;
int solve(int i,int m,int a[],int n)
{
	if (m == 0)return true;
	if (i >= n)return false;
	return solve(i + 1, m, a, n) || solve(i + 1, m - a[i], a, n);
}
int main()
{
	int n,i;
	cin >> n;
	int* a = new int[n];
	for (i = 0; i < n; ++i)
		cin >> a[i];
	int m;
	cin >> m;
	int* num = new int[m];
	for (i = 0; i < m; ++i)
		cin >> num[i];
	for (i = 0; i < m; ++i)
	{
		if (solve(0, num[i], a, n))cout << "yes" << endl;
		else cout << "no" << endl;
	}
	delete[]a;
	delete[]num;
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int maxn = -1;

int main ()
{
    int A,B,C,D,E,F;
    scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
    double Max = -1;
    int answ, anss;
    rep(i,0,31) {
        rep(j,0,31) {
            int water = 100 * (i * A + j * B);
            if (water > F) break;
            rep(k,0,40) {
                rep(l,0,40) {
                    int sugar = k * C + l * D;
                    if ((double)water / 100 * E < sugar || water + sugar > F) continue;
                    double ans = (double) 100 * sugar / (water + sugar);
                    if (ans > Max) {
                        Max = ans;
                        answ = water;
                        anss = sugar;
                    }
                }
            }
        }
    }
    printf("%d %d\n",answ + anss, anss);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <cstdio>
#include <string>
#include <algorithm>

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

typedef long long ll;

using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) { cin >> A[i]; }
    int ans = *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end());
    cout << ans;
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[n];
    int sum=0;
    for(int i=0;i<n;i++){
        int w;
        cin>>w;
        arr[i]=w;
        sum+=w;
    }
    int min=sum;
    int summy=0;
    for(int j=0;j<n;j++){
        summy+=arr[j];
        if(abs(sum-summy-summy)<min){
             min=abs(sum-summy-summy);
         }
    }
    cout<<min<<endl;
}

Measured memory_bytes: 256
#pragma region Macros
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn,now,ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos and *pos <= '9') n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos and *pos <= '9') a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos and *pos <= '9') pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos and *pos <= '9') b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7844
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($i = 0; $i < $H; $i++){
  fscanf(STDIN, "%s", $s);
  $map[$i] = $s."#";
}
$map[$H] = str_repeat("#", $W);
for($i = 0; $i < $H; $i++){
  $h = 0;
  for($j = 0; $j <= $W; $j++){
    if($map[$i][$j] === "#"){
      $q = &$p[$i];
      for($k = 0; $k < $h; $k++){
        $q[$j - 1 - $k] = $h;
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
$max = 0;
for($i = 0; $i < $W; $i++){
  $h = 0;
  for($j = 0; $j <= $H; $j++){
    if($map[$j][$i] === "#"){
      for($k = 0; $k < $h; $k++){
        $pp = $p[$j - 1 - $k][$i] + $h;
        if($max < $pp)$max = $pp;
      }
      $h = 0;
    }else{
      $h++;
    }
  }
}
echo $max - 1;

Measured memory_bytes: 154232
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map> 
#include<vector>
#include<queue>
#include<set>
#include<bits/stdc++.h>
#include<deque> 
#include<bitset>
#include<string>
#define N 40
#define K 300005
#define MOD 1e9+7
#define int long long 
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int max(int a, int b){
    if(a>b)
        return a;
    return b;
}

int32_t main(){
	int n;
	cin>>n;
	int ac[n][3];
	for(int i=0;i<n;i++){
		cin>>ac[i][0]>>ac[i][1]>>ac[i][2];
	}
	int dp[n][3];
	dp[0][0] = ac[0][0];
	dp[0][1] = ac[0][1];
	dp[0][2] = ac[0][2];
	for(int i=1;i<n;i++){
		dp[i][0] = ac[i][0] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = ac[i][1] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = ac[i][2] + max(dp[i-1][0], dp[i-1][1]);
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &it : a) cin >> it;
    sort(a.begin(), a.end());
    int sum = 0; 
    for (int i = 0; i < k; i++) {
    	sum += a[i];
    }
    cout << sum << "\n";
    return 0;
		
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define re register
#define rep(i,a,b) for(re int i=a,i##end=b; i<=i##end; i++)
#define drep(i,a,b) for(re int i=a,i##end=b; i>=i##end; i--)
#define repp(i,a,b) for(re int i=a,i##end=b; i<i##end; i++)
#define drepp(i,a,b) for(re int i=a,i##end=b; i>i##end; i--)
#define Erep(i,x) for(int i=head[x]; ~i; i=Edge[i].nxt)
#define ll long long
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define lowbit(x) (x&-x)
#define ms(x,a) memset(x,a,sizeof x)
using namespace std;
template <class T> inline bool Max(T &x, T y){
	return x<y?x=y,1:0;
}
template <class T> inline bool Min(T &x, T y){
	return x>y?x=y,1:0;
}
template <class T> inline T rd() {
	static char ch;static bool neg;
	static T x=0;
	for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
	for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
	return x=(neg?-x:x);
}
const int mod=1e9+7,oo=1e9;

int main(){
	int n=rd<int>(),m=rd<int>();
	rep(i,m-n+1,m+n-1) printf("%d ",i);
	puts("");
	return 0;
}



Measured memory_bytes: 256
n,p=map(int,input().split())
s=list(input())

from itertools import groupby

gr = groupby(s)

cum=[]
tmp=0
for k,v in gr:
    if k=='0':
        cum.append(tmp+len(list(v)))
        tmp=0
    elif k=='1':
        tmp+=len(list(v))


cum = list(reversed(cum))

ans = 0
cnt = 0
tmp=0
gr = groupby(s)
for k,v in gr:
    if k=='0':
        cnt+=1
        if cnt>p:
            tmp -=cum.pop()

    tmp +=len(list(v))
    ans = max(ans,tmp)


print(ans)



Measured memory_bytes: 10528
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26328
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int inf=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
int main(){
	int N;
	cin>>N;
	vector<int> D(N);
	FOR(i,0,N){
		cin>>D[i];
	}
	int now=0,ok=0;
	while(now<N){
		ok=max(ok,now+D[now]/10);
		now++;
		if(ok<now){
			cout<<"no"<<endl;
			return 0;
		}
	}
	now=N-1;ok=N-1;
	while(now>=0){
		ok=min(ok,now-D[now]/10);
		now--;
		if(ok>now){
			cout<<"no"<<endl;
			return 0;
		}
	}
	cout<<"yes"<<endl;
	return 0;
}


Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int p=1000000007;
const int N=100005;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
char s[N];int dp[2][13];
inline void upd(int &a,int b){a=a+b<p?a+b:a+b-p;}
int main(){
	int n,i,k,c,x=0;dp[0][0]=1;
	scanf("%s",s+1);
	n=strlen(s+1);
	for(i=1;i<=n;++i){
		x^=1;
		for(k=0;k<13;++k)dp[x][k]=0;
		if(s[i]=='?'){
			for(k=0;k<13;++k)for(c=0;c<10;++c)upd(dp[x][(k*10+c)%13],dp[x^1][k]);
		}else{
			c=s[i]^'0';
			for(k=0;k<13;++k)upd(dp[x][(k*10+c)%13],dp[x^1][k]);
		}
	}
	printf("%d",dp[x][5]);
	return 0;
}

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

class Program {
    static int Main(string[] args) {
        List<string[]> list = new List<string[]>();

        while (true) {
            string v = Console.ReadLine();

            string a = v.Split(' ')[0];
            string op = v.Split(' ')[1];
            string b = v.Split(' ')[2];
            if (op == "?") { break; }

            list.Add(new string[] { a, op, b });
        }

        for (int i = 0; i < list.Count; i++) {
            int a = int.Parse(list[i][0]);
            int b = int.Parse(list[i][2]);
            int c = 0;

            switch (list[i][1]) {
                case "+":
                    c = a + b;
                    break;
                case "-":
                    c = a - b;
                    break;
                case "*":
                    c = a * b;
                    break;
                case "/":
                    c = a / b;
                    break;
                default:
                    continue;
            }

            Console.WriteLine(string.Format("{0}", c));
        }

        return 0;
    }
}

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

//#define int long long

char dp[80][80][25601];

char f = 0;
char& g(int i, int j, int v) {
    if (v > 12800 || v < -12800)
        return f;
    if (v < 0)
        v += 12801;
    return dp[i][j][v];
}
signed main() {
    int h, w;
    cin >> h >> w;
    int a[h][w], b[h][w];
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cin >> a[i][j];

    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cin >> b[i][j];

    memset(dp, 0, sizeof dp);
    g(0, 0, a[0][0] - b[0][0]) = 1;
    g(0, 0, b[0][0] - a[0][0]) = 1;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) if (i || j) {
            for (int cur = -12800; cur <= 12800; ++cur) {
                if (i)
                    g(i, j, cur) |= g(i - 1, j, cur + a[i][j] - b[i][j])
                                 || g(i - 1, j, cur + b[i][j] - a[i][j]);
                if (j)
                    g(i, j, cur) |= g(i, j - 1, cur + a[i][j] - b[i][j])
                                 || g(i, j - 1, cur + b[i][j] - a[i][j]);
            }
        }
    
    int ans = 55555;
    for (int i = -12800; i <= 12800; ++i)
        if (g(h - 1, w - 1, i))
            ans = min(ans, abs(i));
    cout << ans;
}




Measured memory_bytes: 160256
N,Q = (int(i) for i in input().split())
S = input()
acl = [0 for i in range(N+1)]

for j in range(N):
  acl[j+1] = acl[j] +(1 if S[j:j+2] == 'AC' else 0)
      
for k in range(Q):
  x,y = (int(i)-1 for i in input().split())
  print(acl[y]-acl[x])

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

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

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

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

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

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

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

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

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn max (a: &i64, b:&i64) -> i64{
    if *a < *b {*b} else {*a}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        n: usize,
        k: usize,
        l: [usize; n]
    }
    let mut ls = l.clone();
    ls.sort_by(|a, b| b.cmp(a));
    let mut result = 0;
    for i in 0..k {
       result += ls[i]; 
    }
    print!("{}", result);
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double con = 0;
    ll ans0 = -1, ans1 = -1;
    double judge_e = (double)100.0 * e / (100 + e);
    for (int w0 = 0; 100 * a * w0 <= f; w0++) {
        ll sum0 = 100 * a * w0;
        for (int w1 = 0; sum0 + 100 * b * w1 <= f; w1++) {
            ll sum1 = sum0 + 100 * b * w1;
            if (sum1 == 0) {
                continue;
            }
            for (int s0 = 0; sum1 + c * s0 <= f; s0++) {
                ll sum2 = sum1 + c * s0;
                for (int s1 = 0; sum2 + d * s1 <= f; s1++) {
                    ll sum3 = sum2 + d * s1;
                    ll sugar = c * s0 + d * s1;
                    if (sum3 == 0) {
                        continue;
                    }
                    double temp = (double)100.0 * sugar / sum3;
                    if (temp <= judge_e) {
                        if (temp > con) {
                            ans0 = sum3;
                            ans1 = sugar;
                            con = temp;
                        }
                    }
                }
            }
        }
    }

    if (con == 0) {
        cout << 100 * a << " " << 0;
        return 0;
    }
    cout << ans0 << " " << ans1 << endl;
    return 0;
}



Measured memory_bytes: 256
class Dice
  attr_reader :count

  def self.chain(*args)
    return args.reduce((0..5).to_a){|state, rep|@@order[rep].map{|face|state[face]}}
  end

  def self.setup
    @@order = {:north => [1,5,2,0,4,3], :right => [0,2,3,4,1,5]}
    @@order[:south] = chain(:north, :north, :north)
    @@order[:east] = chain(:north, :right, :south)
    @@order[:west] = chain(:east, :east, :east)
    @@order[:left] = chain(:right, :right, :right)
  end
  
  
  def initialize
    @state = [1,2,3,5,4,6]
    @count = 1
  end

  def rot(order)
    @state = @@order[order].map{|face|@state[face]}
    @count += @state[0]
  end
end
def main(input = STDIN)
  Dice.setup
  while 0 != n = input.gets.to_i
    dice = Dice.new
    n.times do
      dice.rot(input.gets.chomp.downcase.to_sym)
    end
    puts dice.count
  end
end
main

Measured memory_bytes: 6108
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let t: i32 = read();
    let ct: Vec<(i32, i32)> = (0..n).map(|_| (read(), read())).collect();

    println!(
        "{}",
        match ct.iter().filter(|&&x| x.1 <= t).min() {
            Some(x) => x.0.to_string(),
            None => "TLE".to_string(),
        }
    );
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main() {
    int a, b;
    char op;

    while(1) {
        cin >> a >> op >> b;
        if(op == '?') break;
        if(op == '+') cout << a+b << endl;
        if(op == '-') cout << a-b << endl;
        if(op == '*') cout << a*b << endl;
        if(op == '/') cout << a/b << endl;
    }
    return 0;
}


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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    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;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

ll sum(ll n) {
    return (1 + n) * n/ 2;
}

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

    int n; cin >> n;
    cout << sum(n-1);

    return 0;
}


Measured memory_bytes: 3644
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = list(map(int,input().split()))
d = sum(a)
snuke = 0
arai = 0
ans = 10000000000
for i in range(n-1):
    snuke += a[i]
    arai = d - snuke
    ans = min(ans,abs(snuke-arai))
print(ans)

Measured memory_bytes: 24152
#include <iostream>

using namespace std;

typedef long long ll;

int main(void)
{
    ll N, D, X[200005], Y[200005];

    cin >> N >> D;
    ll D2 = D * D;

    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ll d = X[i] * X[i] + Y[i] * Y[i];
        if (d <= D2) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6772
N = int(input())
A = list(map(int, input().split()))
Ans = [1]
for i in A:
    if i%2 == 0:
        Ans.append(i)
cnt = 0
for j in Ans:
    while j%2 == 0:
        cnt += 1
        j = j//2
print(cnt)

Measured memory_bytes: 4140
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        s: chars,
    }
    const RES: i32 = 7;
    for bit in 0..(1 << 3) {
        let mut res = String::with_capacity(7);
        let mut r: i32 = s[0].to_digit(10).unwrap() as i32;
        res.push(s[0].clone());
        for i in 0..(s.len() - 1) {
            if bit & 1 << i != 0 {
                r += s[i + 1].to_digit(10).unwrap() as i32;
                res.push('+');
            } else {
                r -= s[i + 1].to_digit(10).unwrap() as i32;
                res.push('-');
            }
            res.push(s[i + 1].clone());
        }
        if r == RES {
            println!("{}={}", res, RES);
            break;
        }
    }
}

Measured memory_bytes: 4352
n,m=map(int,input().split())
x=list(map(int,input().split()))
def main(n,m,x):
    x.sort()
    y=[]
    if m<=n:return 0
    if m==1:return 0
    if n==1:return x[-1]-x[0]
    for i in range(1,m):
        y.append(x[i]-x[i-1])
    y.sort()
    y=y[:(1-n)]
    return sum(y)

print(main(n,m,x))

Measured memory_bytes: 13968
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
using namespace std;
using Int = long long;
int main()
{
    int a, b;
    cin >> a >> b;
    a--, b--;
    vector<string> vs;
    if (a == 0) {
        string s;
        for (int i = 0; i < 100; i++) s += "#";
        vs.push_back(s);
    }
    while (a) {
        string s;
        for (int i = 0; i < 50; i++) {
            if (a > 0) {
                s += ".#";
                a--;
            } else {
                s += "##";
            }
        }
        vs.push_back(s);
        s = "";
        for (int i = 0; i < 100; i++) s += "#";
        vs.push_back(s);
    }
    if (b == 0) {
        string s;
        for (int i = 0; i < 100; i++) s += ".";
        vs.push_back(s);
    }
    while (b) {
        string s;
        for (int i = 0; i < 100; i++) s += ".";
        vs.push_back(s);
        s = "";
        for (int i = 0; i < 50; i++) {
            if (b > 0) {
                s += "#.";
                b--;
            } else {
                s += "..";
            }
        }
        vs.push_back(s);
    }
    cout << vs.size() << " " << 100 << endl;
    for (auto& line : vs) cout << line << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 

    fast;


    ll m,n;
    cin>>m>>n;

    if(m!=n)
      cout<<"No";
    else cout<<"Yes";
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define mo 1000000007
#define MAX 1000004
#define fast_io ios::sync_with_stdio(false)
ll x[MAX];
int main()
{
	fast_io;
	ll n,a,b;
	cin >> n >> a >> b;
	for(int i=1;i<=n;i++)
	{
		cin >> x[i];
	}
	ll ans=0;
	for(int i=2;i<=n;i++)
		ans+=min((x[i]-x[i-1])*a,b);
	cout << ans << endl;
	return 0;
}

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

#define int long long
#define endl "\n"

signed main ()
{

//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, k;
	cin >> n >> k;
	
	vector <int> logs(n);
	for (int i=0; i<n; i++) cin >> logs[i];
	
	int low = 1;
	int high = *max_element(logs.begin(), logs.end());
	int middle, ans;
	
	while (low <= high){
		middle = (low + high)/2;
		int total_cuts = 0;
		for (int i=0; i<n; i++){
			total_cuts += ((logs[i]-1)/middle);
		}
		if (total_cuts <= k){
			ans = middle;
			high = middle - 1;
		}
		else low = middle + 1;
	}
		
	cout << ans << endl;	
	return 0;

}


Measured memory_bytes: 4744
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    X, Y = MAP()

    l = [i for i in range(2*X, 4*X + 2, 2)]
    print('Yes' if Y in l else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10052
#include <algorithm>
#include <cmath>
#include <iostream>

int a, b;

int main() {
    std::cin >> a >> b;
    for (int i = 1; i <= 1000; i++) {
        int a2 = i * 0.08;
        int b2 = i * 0.1;
        if (a2 == a && b2 == b) {
            std::cout << i << std::endl;
            return 0;
        }
    }
    std::cout << -1 << std::endl;
}


Measured memory_bytes: 3652
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

void dfs(int n, double len, const int N, double& sum, vector<vector<double>>& G, vector<bool>& visited) {
  visited[n] = true;
  if (all_of(begin(visited), end(visited), [](bool a) { return a; })) {
    sum += len;
    visited[n] = false;
    return;
  }
  for (int i = 0; i < N; ++i) {
    if (visited[i])continue;
    dfs(i, len + G[n][i], N, sum, G, visited);
  }
  visited[n] = false;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  for (int i = 0; i < N; ++i)cin >> x[i] >> y[i];
  constexpr double INF = DBL_MAX;
  vector<vector<double>> G(N, vector<double>(N, INF));
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      G[j][i] = G[i][j] = hypot(x[i] - x[j], y[i] - y[j]);
    }
  }
  double sum = 0;
  for (int i = 0; i < N; ++i) {
    vector<bool> visited(N, false);
    dfs(i, 0, N, sum, G, visited);
  }
  int n = 1;
  for (int i = 1; i <= N; ++i)n *= i;
  cout << fixed << setprecision(7) << sum / n << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
int n,a[maxn];
bool check()
{
	LL s=0;
	for (int i=1;i<=n;i++) s+=a[i];
	s*=2;
	if (s%((LL)n*(n+1))!=0) return 0;
	s/=n;s/=(n+1);
	for (int i=1;i<n;i++)
	{
		LL s1=a[i]-a[i+1]+s;
		if (s1<0||s1%n!=0) return 0;
	}
	LL s1=a[n]-a[1]+s;
	if (s1<0||s1%n!=0) return 0;
	return 1;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) scanf("%I64d",&a[i]);
	if (check()) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int	main(void)
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	if (a == b && b==c)
	{
		printf("No");
		return(0);
	}
	if (a!=b&&a!=c&&b!=c)
	{
		printf("No");
		return(0);
	}
	printf("Yes");
	return(0);
}


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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n,a,b;cin>>n>>a>>b;
  int x[n];
  rep(i, n){
    cin>>x[i];
  }
  int res = 0;
  rep(i, 1, n){
    if (b<a*(x[i]-x[i-1])){
      res += b;
    }
    else{
      res += a*(x[i]-x[i-1]);
    }
  }
  cout << res << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

int main()
{
  int K, X;
  cin >> K >> X;

  int start = X - K + 1;
  if (start < -1000000) {
    start = -1000000;
  }

  int end = X + K - 1;
  if (end > 1000000) {
    end = 1000000;
  }

  int i = start;
  while (i <= end) {
    cout <<  i << " ";
    i++;
  }
  cout << endl;
}

Measured memory_bytes: 256
n  =  int(input())
a  =  list(map(int, input().split()))
a.sort(reverse = True)
d  =  {}
count = 0

for x in a:
    if x not in d: d[x] = 0
    d[x] += 1
    
for i in range(len(a)):
    if d[a[i]] == 0:continue
        
    d[a[i]] -= 1
    
    y = 2**a[i].bit_length() - a[i]
    
    if y in d and d[y] > 0:
        count += 1
        d[y]  -= 1
        
print(count)

Measured memory_bytes: 33040
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
void fin(int n){
  cout<<n<<endl;
  exit(0);
}
//main
signed main(){
  int N;cin>>N;
  std::vector<int> a(N),b(N);
  for(int i=0;i<N;i++)cin>>a[i];
  for(int i=0;i<N;i++)cin>>b[i];
  for(int i=0;i<N;i++)if(b[i]<a[i])fin(-1);
  int ok=0,ans=0;
  std::vector<int> ook(N,0);
  for(int i=0;i<N;i++){
    if(b[i]==a[i]){
      ok++;
      ook[i]++;
    }
  }
  if(ok==N)fin(0);
  queue<int> que;
  for(int i=0;i<N;i++)if(ook[(i+1)%N]==0)if(b[i]<b[(i+1)%N]&&b[(i+1)%N]>b[(i+2)%N])que.push((i+1)%N);
  while(que.size()){
    int p=que.front();que.pop();
    int l=b[(p-1+N)%N],r=b[(p+1)%N];int t=l+r;
    int s=(b[p]-max({l,r,a[p]}))/t;
    if((b[p]-max({l,r,a[p]}))%t)s++;
    b[p]-=s*t;
    ans+=s;
    if(b[p]<a[p])fin(-1);
    if(b[p]==a[p]){
      ok++;
      ook[p]++;
    }
    if(ok==N)fin(ans);
    if(ook[(p+1)%N]==0)if(b[p]<b[(p+1)%N]&&b[(p+1)%N]>b[(p+2)%N])que.push((p+1)%N);
    if(ook[(p-1+N)%N]==0)if(b[(p-2+N)%N]<b[(p-1+N)%N]&&b[(p-1+N)%N]>b[p])que.push((p-1+N)%N);
  }
  fin(-1);
}


Measured memory_bytes: 5760
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

ll expo(ll a, ll b){
    ll ex = 1;
    rep(i, b){
        ex *= a;
    }
    return ex;
}

ll fact(ll a){
    ll fc = 1;
    REP(i, 1, a+1){
        fc *= i;
    }
    return fc;
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
}

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

#define pii pair<int, int>
#define endl "\n"
#define int long long
#define F first
#define S second
#define B begin
#define E end
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const ll Q = 31;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}

 
signed main()
{
    hello();

    string s;
    cin >> s;

    int res = 0;
    for (int i = 0; i < s.size() / 2; ++i)
    {
        if (s[i] != s[s.size() - i - 1])
            ++res;
    }

    cout << res << endl;
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>

using namespace std;
long long n,a[1000000+100],sol,p,suma,par,nep,w1,w2;
string s;
int main()
{
    scanf("%lld %lld",&n,&p);
    for (long long i=1;i<=n;i++){scanf("%lld",&a[i]);if(a[i]%2==0)par++;}
    if (p==1&&par==n){cout<<0<<endl;return 0;}
    w1=1;
    nep = n-par;
    for (long long i=1;i<=par;i++)w1*=2;
    w2 =1 ;
    for (long long i = 1;i<nep;i++)w2*=2;
    sol = w2*w1;
    cout<<sol<<endl;
    return 0;
}


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

int main() {
  int a,b;
  string op;
  cin >> a >> op >> b;
  
 while (op != "?") {
  if (op == "+"){
    cout << a + b << endl;
  }
  else if (op == "-"){
    cout << a - b << endl;
  }
  else if (op == "*"){
    cout << a * b << endl;
  }
  else if (op == "/"){
    cout << a / b << endl;
  }
  cin >> a >> op >> b;
 }
}
  
  


Measured memory_bytes: 3164