akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

// nCr mod p(n<p)をキビキビ計算する
// 構築:O(n), クエリ:O(1)
struct combination_mod {
    using lint = long long int;
    int sz;
    lint mod;
    vector<lint> fac;
    vector<lint> finv;
    combination_mod(int _sz, lint _mod) : sz(_sz), mod(_mod) {
        fac.assign(sz + 1, 1);
        finv.assign(sz + 1, 1);
        vector<lint> inv(sz + 1, 1);
        for (int i = 2; i <= sz; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    lint query(int n, int r) {
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
};

int main() {
    lint mod = 1e+9 + 7;
    int n, k;
    cin >> n >> k;
    vector<lint> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    combination_mod comb(n, mod);
    lint ans = 0;
    // min
    for (int i = 0; i <= n - k; i++) {
        lint temp = a[i];
        temp = (a[i] * comb.query(n - i - 1, k - 1)) % mod;
        ans = (ans - temp) % mod;
    }
    // max
    for (int i = k - 1; i < n; i++) {
        lint temp = a[i];
        temp = (a[i] * comb.query(i, k - 1)) % mod;
        ans = (ans + temp) % mod;
    }
    if (ans < 0) {
        ans += mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;
public class Main {

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

        int n;
        int x;
        int cnt;

        while (true) {
            n = sc.nextInt();
            x = sc.nextInt();
            if (0 == n && 0 == x) {
                break;
            }


            cnt = 0;
            int i, j, k;
            for (i = 1; i <= n; i++) {
                for (j = i + 1; j <= n; j++) {
                    for (k = j + 1; k <= n; k++) {
                        if (i+j+k==x) {
                            cnt++;
                        }
                    }
                }


            }
            System.out.println(cnt);
        }
    }
}



Measured memory_bytes: 26996
n,k = map(int,input().split())
t = []
for i in range(k):
    d = int(input())
    li = list(map(int,input().split()))
    for k in range(len(li)):
        t.append(li[k])

c=0
for i in range(1,n+1):
    if(i not in t):
        c += 1
print(c)





Measured memory_bytes: 9296
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;


int main(){
    int A[3];
    
    // 入力
    cin >> A[0] >> A[1] >> A[2];
    
    sort(A,A+3);
    
//    // 出力
//    for (int i=0;i<3;i++) cout << A[i] << endl;
    
    cout << A[0] + A[1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	llint i,j,n,ans=0;cin>>n;
	llint K[60]={};
	for(i=0;i<n;i++){
		llint A;cin>>A;
		for(j=0;j<60;j++){
			if((1LL<<j)&A){K[j]++;}
		}
	}
	llint b=1;
	for(i=0;i<60;i++){
		ans+=K[i]*(n-K[i])%mod*b;
		ans%=mod;
		b+=b;b%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
S = str(input())

if S[0] != "A":
    print("WA")
else:
    if len(S) == 4:
        if S[2] == "C" and S[3].islower() and S[1].islower():
            print("AC")
        elif S[3] == "C" and S[2].islower() and S[1].islower():
            print("AC")
        else:
            print("WA")
    else:
        s = S[2:-1]
        if "C" not in s:
            print("WA")
        else:
            counter = 0
            for i in S[1:]:
                if i.isupper():
                    counter += 1
            if counter == 1:
                print("AC")
            else:
                print("WA")

Measured memory_bytes: 38256
K = int(input())

if K < 10:
    print(K)
    exit()
K -= 9

prev = list(range(1, 10))
while True:
    lunlun = []
    for p in prev:
        if p % 10 == 0:
            lunlun.append(p * 10 + 0)
            lunlun.append(p * 10 + 1)
        elif p % 10 == 9:
            lunlun.append(p * 10 + 8)
            lunlun.append(p * 10 + 9)
        else:
            for i in range(p % 10 - 1, p % 10 + 2):
                lunlun.append(p * 10 + i)
    if K <= len(lunlun):
        print(lunlun[K-1])
        break
    K -= len(lunlun)
    prev = lunlun


Measured memory_bytes: 47408
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//    #pragma GCC optimize("unroll-loops")
//    #pragma GCC optimize("Ofast")
//    #pragma GCC optimize("-O3")
//    #pragma GCC optimize("no-stack-protector")
//    #pragma GCC optimize("fast-math")

#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ld  double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
//#define for(int i=0;i<n;i++) for(ll i=0;i<n;i++)
using namespace std;
//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e6;
ll inf = INT_MAX, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
//const ll N=2*1e5+1;
const ll R=1e4;
const ll to[7]={1,2,3,1,3,2,1};
const ll tx[4]={0,0,-1,1};
const ll ty[4]={-1,1,0,0};
const char rev_to[3]={'R','G','B'};
const ll N=4*1e3;
ll mp[N][N][3];
signed main(){
    fast_io;
    int n;
    cin>>n;
    string a;
    cin>>a;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            for(int k=0;k<3;k++){
                mp[i][j][k]=mp[i][j][k]+(j ?  mp[i][j-1][k] : 0);
                if(a[j]==rev_to[k]){
                    mp[i][j][k]++;
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            ll k1,k2;
            if(a[i]!=a[j]){
                 for(int ps=0;ps<3;ps++){
                    if(rev_to[ps]!=a[i] && rev_to[ps]!=a[j]){
                        ans+=(mp[i][j][ps]);
                        if((i+j)%2==0 && a[(i+j)/2]==rev_to[ps]) ans--;
                    }
                }
            }
           
        }
      
    }
    cout<<ans;
    return 0;
}

/*


    RBGGRR
    /////

*/


Measured memory_bytes: 206852
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> A(N);
    for(int n=0; n<N; n++) {
        cin >> A[n];
        A[n] -= (n+1);
    }

    sort(A.begin(), A.end());
    long long int ans=0;
    for(int n=0; n<N; n++) {
        ans += abs(A[n]-A[N/2]);
    }
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 1792
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest 114：C - 755
import itertools


def main():
    N = int(raw_input().strip())

    cnt = 0
    seq = ('3', '5', '7')
    for i in range(3, len(str(N))+1):
        for word in itertools.product(seq, repeat=i):
            w = ''.join(word)
            if '3' in w and '5' in w and '7' in w:
                if int(w) <= N:
                    cnt += 1
    print cnt


if __name__ == '__main__':
    main()


Measured memory_bytes: 2692
#include<stdio.h>
#include<string.h>
#define LEN 100005


typedef struct pp{
  char name[10];
  int t;
}P;
P Q[LEN];
int head,tail,n;

void equence(P x){
  Q[tail] = x;
  tail = (tail + 1)%LEN;
}
P dequence(){
  P x =Q[head];
  head = (head+1)%LEN;
  return x;
}

int min(int a,int b){return a<b ? a:b;}

int main(){
  
  int elaps = 0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);
  for( i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1; tail = n+1;

  while(head !=tail ){
    u=dequence();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t >0)equence(u);
    else{printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}
  



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

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

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int A, B, C;
    cin >> A >> B >> C;

    cout << (A + B + C >= 22 ? "bust" : "win") << '\n';

    return 0;
}


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

int main()
{
    char s[105];
    cin>>s;
    int i,l=strlen(s);
    int hug =0;
    for(i=0;i<l/2;i++){
        if(s[i]!=s[l-i-1]){
            hug++;
        }

    }
    cout<<hug<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long int
using namespace std;
int main (void)
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    ull coins;
    ull happy = 0, happiness1000 = 0;
    cin >> coins;
    if(coins >= 500){
		happiness1000 = coins / 500;
		coins = coins % 500;
	}
    ull happiness5 = coins / 5;
    happy = happiness5*5 + happiness1000*1000;
    cout << happy;
    return 0;
}
// date_time : 31.03.2020 15:25:04 IST 
// Author : Aditya Kumar Maurya <adityakrmaurya03@gmail.com>


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

double dp[310][310][310];

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll N; cin >> N;
    vll cnt(4, 0);
    rep(i, N) {
        ll a;
        cin >> a;
        cnt[a]++;
    }

    for(ll i = 0; i <= N; i++) {
        for(ll j = 0; j <= N; j++) {
            for(ll k = 0; k <= N; k++) {
                double s = i + j + k;
                if(s == 0) {
                    dp[i][j][k] = 0;
                    continue;
                }
                dp[i][j][k] += (double)N / s;
                if(i-1 >= 0) dp[i][j][k] += dp[i-1][j+1][k] * i / s;
                if(j-1 >= 0) dp[i][j][k] += dp[i][j-1][k+1] * j / s;
                if(k-1 >= 0) dp[i][j][k] += dp[i][j][k-1] * k / s;
            }
        }
    }
    cout << dp[cnt[3]][cnt[2]][cnt[1]] << endl;
}


Measured memory_bytes: 227584
#include <iostream>

long long n_divisors[10000001];

int main()
{
    long long N;
    std::cin >> N;
    for (int i=1; i<=N; i++) {
        for (int j=1; i*j<=N; j++) {
            n_divisors[i*j]++;
        }
    }
    long long result = 0;
    for (int K=1; K<=N; K++) {
        result += K * n_divisors[K];
    }
    std::cout << result << std::endl;
}

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

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

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  rep(i,h) cin>>s[i];
  
  int ans = 0;
  
  rep(i,h){
    rep(j,w){
      vector<vector<int>> dist(h,vector<int>(w,-1));
      queue<pair<int,int>> que;		
      
      if(s[i][j] == '#') continue;
      dist[i][j] = 0;
      que.push({i,j});
      
      while(!que.empty()){
        int u = que.front().first; 
        int v = que.front().second;
        que.pop();
        
        rep(k,4){
          int nu = u + dx[k]; 
          int nv = v + dy[k];
          if(nu<0||nu>=h||nv<0||nv>=w) continue;
          if(s[nu][nv] == '#') continue;
          if(dist[nu][nv] != -1) continue;
          que.push({nu,nv});
          dist[nu][nv] = dist[u][v] + 1;
          ans = max(ans,dist[nu][nv]);
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1100000
using namespace std;

int dp[20][110000];
int N;
int K;

void showDP() {
	printf("\n");
	for(int i = 0; i <= K; i++) {
		for(int j = 0; j <= N; j++) {
			if(dp[i][j] >= INF) printf("INF ");
			else printf("%3d ", dp[i][j]);
		}
		printf("\n");
	}
	printf("\n");
}

int main() {
	cin >> N;
	vector<int> money;
	money.push_back(1);
	for(int tmp = 6; tmp <= N; tmp *= 6) money.push_back(tmp);
	for(int tmp = 9; tmp <= N; tmp *= 9) money.push_back(tmp);
	sort(money.begin(), money.end());

	K = money.size();
	for(int i = 0; i <= K; i++) {
		for(int j = 0; j <= N; j++) {
			dp[i][j] = INF;
		}
	}
	for(int i = 0; i <= K; i++) dp[i][0] = 0;
	for(int i = 0; i <= K; i++) {
		for(int j = 0; j <= N; j++) {
			//cout << i << ' ' << j << ' ' << money[i] << endl;
			if(i >= 1) dp[i][j+money[i - 1]] = min(dp[i][j] + 1, dp[i][j + money[i - 1]]);
			if(i < K) {
				dp[i+1][j] = min(dp[i][j], dp[i+1][j]);
				dp[i+1][j+money[i]] = min(dp[i][j] + 1, dp[i+1][j+money[i]]);
			}
		}
		//showDP();
	}
	cout << dp[K][N] << endl;

	return 0;
}


Measured memory_bytes: 6272
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,k,a[105],f[105][100005],s[105][100005];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    f[0][0]=1;
    for(int i=0;i<=k;++i)s[0][i]=1;
    for(int i=1;i<=n;++i){
        f[i][0]=s[i][0]=1;
        for(int j=1;j<=k;++j){
            int l=j-a[i]-1;
            f[i][j]=s[i-1][j];
            if(l>=0)f[i][j]=(f[i][j]+orz-s[i-1][l])%orz;
            s[i][j]=(s[i][j-1]+f[i][j])%orz;
        }
    }
    printf("%d\n",f[n][k]);
	//system("pause");
	return 0;
}


Measured memory_bytes: 82176
#include <stdio.h>
long long gcd(long long a,long long b){
if(b==0)return a;
return gcd(b,a%b);
}
int main(){
long long a,b;
while(scanf("%lld%lld",&a,&b)!=EOF){
printf("%d %d\n",gcd(a,b),a*b/gcd(a,b));
}
}

Measured memory_bytes: 2576
#include <iostream>
#include <map>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if ((A < C && B > C) || (A > C && B < C)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	ABM := sc.nextInts()
	M := ABM[2]

	a := sc.nextInts()
	b := sc.nextInts()

	minA := int(math.Pow10(5))
	for _, va := range a {
		if minA > va {
			minA = va
		}
	}
	minB := int(math.Pow10(5))
	for _, vb := range b {
		if minB > vb {
			minB = vb
		}
	}
	minTmp := minA + minB

	for i := 0; i < M; i++ {
		m := sc.nextInts()
		ia := m[0] - 1
		ib := m[1] - 1
		tmp := a[ia] + b[ib] - m[2]
		if minTmp > tmp {
			minTmp = tmp
		}
	}
	fmt.Println(minTmp)
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 11008
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Xi Lin
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long A = in.nextInt();
            long B = in.nextInt();
            int x[] = new int[n];
            for (int i = 0; i < n; ++i) {
                x[i] = in.nextInt();
            }
            long r = 0;
            for (int i = 1; i < n; ++i) {
                r += min(B, A * (x[i] - x[i - 1]));
            }
            out.println(r);
        }

        long min(long a, long b) {
            if (a < b) return a;
            else return b;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23836
N = int(input())
A = [0] + list(map(int, input().split()))

for i in range(N//2, 0, -1):
    tmp = 0
    j = i
    while j < N+1:
        tmp += A[j]
        j += i
    A[i] = tmp % 2
    # A[i] = sum(A[i::i]) % 2
ans = [i for i, j in enumerate(A) if j == 1]

print(len(ans))
print(*ans)

Measured memory_bytes: 12724
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        StringBuilder s = new StringBuilder();
        for (char cc:c){
            if(cc == '1') s.append(9);
            else s.append(1);
        }
        System.out.println(s);
    }


}





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

using namespace std;
typedef long long ll;
typedef pair<int,ll>pa;

const int N=2e5+100;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

char s[N];
int main()
{
    int k;cin>>k;
    ll ans=1;
    ll tot=7;
    while(1){
        if(tot%k==0) break;
        ans++;
        tot=(tot*10+7)%k;
        if(ans==1e6+100) {
            cout<<-1;
            return 0;
        }
    }
    cout<<ans<<endl;
}



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

int main(){
    while(1){
        int h,w ;
        cin >> h >> w ;
        if(h==w&&h==0) break ;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout << '#' ;
            }
            cout << endl ;
        }
        cout << endl ;
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100001],dp[100001],n;

int call(int i){
    if(i>=n-1)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    int res;
    res=abs(a[i]-a[i+1])+call(i+1);
    if(i<n-2)
        res=min(res, abs(a[i]-a[i+2]) + call(i+2));
    return dp[i]=res;
}


int main(){

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<call(0);



return 0;
}


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

using namespace std;

using int64 = long long;

int64 DigitSum(int64 x) {
  string s = to_string(x);
  int64 sum = 0;
  for (char c : s) {
    sum += c - '0';
  }
  return sum;
}

int64 NextSnuke(int64 x) {
  int64 min_arg = x;
  int64 min_num = x;
  int64 min_den = DigitSum(x);

  string s = to_string(x);
  for (int i = 0; i < s.length(); i++) {
    for (char d = '0'; d <= '9'; d++) {
      string t = s;
      t[i] = d;
      for (int j = i + 1; j < s.length(); j++) {
        t[j] = '9';
      }
      int64 y = stoll(t);
      if (y < x) continue;

      int64 num = y;
      int64 den = DigitSum(y);
      if (num * min_den < min_num * den) {
        min_arg = y;
        min_num = num;
        min_den = den;
      } else if (num * min_den == min_num * den && y < min_arg) {
        min_arg = y;
      }
    }
  }

  return min_arg;
}

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

  int k;
  cin >> k;
  int64 current = 1;
  for (int i = 0; i < k; i++) {
    int64 x = NextSnuke(current);
    cout << x << endl;
    current = x + 1;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) ll t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf LLONG_MAX
ll mult(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll fpow(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1LL)
			res = (res * x) % mod;
		y = y >> 1LL;
		x = (x * x) % mod;
	}
	return res;
}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2);}
bool sa(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second < b.second);}
bool fd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.first > b.first);}
bool sd(const pair<ll, ll> &a, const pair<ll, ll> &b) {return (a.second > b.second);}
ll dx[4] = {0, 0, 1, -1};
ll dy[4] = {1, -1, 0, 0};
bool valid(ll x, ll y, ll n, ll m) {
	if (x < 0 || y < 0) {
		return false;
	}
	else if (x >= n || y >= m) {
		return false;
	}
	else
		return true;
}
#define MAXN 1000001
ll spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (ll i = 2; i < MAXN; i++)

		// marking smallest prime factor for every
		// number to be itself.
		spf[i] = i;

	// separately marking spf for every even
	// number as 2
	for (ll i = 4; i < MAXN; i += 2)
		spf[i] = 2;

	for (ll i = 3; i * i < MAXN; i++)
	{
		// checking if i is prime
		if (spf[i] == i)
		{
			// marking SPF for all numbers divisible by i
			for (ll j = i * i; j < MAXN; j += i)

				// marking spf[j] if it is not
				// previously marked
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll ones,zeroes,negative;
	cin>>ones>>zeroes>>negative;
	ll k;
	cin>>k;
	ll total=0;
		if(ones){
			if(ones-k>=0){
				total+=k;
				k-=k;
				ones=0;
				cout << total;
				return 0;
			}else{
				total+=ones;
				
				k-=ones;
				ones=0;
			}
		} 
		if(zeroes){
			if(zeroes-k>=0){
				// total+=k;
				k-=k;
				zeroes=0;
				cout << total;
				return 0;
			}else{
				// total+=ones;
				
				k-=zeroes;
				zeroes=0;
			}

		} 
		if(negative){
			if(negative-k>=0){
				total-=k;
				k-=k;
				negative=0;
				cout << total;
				return 0;
				
			}else{
				total-=negative;
				
				k-=negative;
				negative=0;
			}
		}
	
	cout << total;
	return 0;
}

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

int main() {
	// your code goes here
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,i,j;
	cin>>n;
	int h[n];
	for(i=0;i<n;i++)
	cin>>h[i];

	int dp[n];
	dp[0]=0;
	for(i=1;i<n;i++)
	dp[i]=INT_MAX;
	
	for(i=0;i<n;i++)
	{
		if(i+1<n)
		dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
		if(i+2<n)
		dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
		
	}
	cout<<dp[n-1];
	
	
	return 0;
}


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

int main(){
  int N,K,ans=0;
  cin >> N >> K;
  vector<bool>s(N,true);
  for(int i=0;i<K;i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
      int A;
      cin >> A;
      s.at(A-1) = false;
    }
  }
  rep(i,N){
    if(s.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define N 500003
#define MOD 1000000007
using namespace std;


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

    }
    int dp[n]={0};

    for(int i=1;i<n;i++){
            dp[i]=MOD;
            for(int j=1;j<=k;j++){
                dp[i]=min(i-j>=0?dp[i-j]+abs(a[i]-a[i-j]):MOD,dp[i]);
            }

    }
    cout<<dp[n-1]<<endl;


}


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

class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ').Select(x=>Int64.Parse(x)).ToArray();
        var A = line[0];
        var B = line[1];
        var C = line[2];
        var D = line[3];

        var cBig = B / C;
        var cSmall = (A-1) / C;
        var c = cBig - cSmall;

        var dBig = B / D;
        var dSmall = (A - 1) / D;
        var d = dBig - dSmall;

        var a = Math.Max(C,D);
        var b = a == D ? C : D;
        var gcd = GetGcd(a, b);
        var lcm = C * D / gcd;

        var lcmBig = B / lcm;
        var lcmSmall = (A - 1) / lcm;
        var lcmNum = lcmBig - lcmSmall;

        var warikireru = c + d - lcmNum;
        var ans = B - (A - 1) - warikireru;

        Console.WriteLine(ans);
    }

    static long GetGcd(long a, long b)
    {
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

void print(int t) {
  if (t == 0) cout << "Positive";
  else if (t == 1) cout << "Negative";
  else cout << "Zero";
  cout << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int a, b;
  cin >> a >> b;

  int t = -1;
  if (a > 0) t = 0;
  else if (a <= 0 && b >= 0) t = 2;
  else t = (b - a + 1) % 2;
  print(t);


  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const ll INF = 10e16;
const int maxN = 300010;
const int maxM = 100010;
const int N = 5000; 
const int MOD = 1000000007;

char a[maxN];
int b[maxN];
int c[maxN];
int w[maxN];
int e[maxN]; 
int l[maxN];
int n;
int main()
{
	scanf("%d",&n);
	scanf("%s",a+1);
	int x1= 0,x2 = 0;
	for(int i=1;i<=n;i++)
	{
		if(a[i] == 'E')
			b[i] = 1;
		else
			c[i] = 1;
	}
	for(int i=1;i<=n;i++)
	{
		w[i] = w[i-1] + c[i];
		e[i] = e[i-1] + b[i];
	}
	for(int i=1;i<=n;i++)
	{
		l[i] = (w[i-1]-w[0]) + (e[n]-e[i]);
	}
	sort(l+1,l+1+n);
	printf("%d\n",l[1]);
	return 0;
}  

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
#define ln endl
int main() {
	int a=_,b=_,c=_;
	int tmp=a-b;
	cout<<max(c-tmp,0);
}

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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

typedef pll point;

#define x first
#define y second

point operator +(point a, point b) {
	return mp(a.x + b.x, a.y + b.y);
}

point operator -(point a, point b) {
	return mp(a.x - b.x, a.y - b.y);
}

ll operator *(point a, point b) {
	return a.x * b.x + a.y * b.y;
}

ll operator ^(point a, point b) {
	return a.x * b.y - a.y * b.x;
}

const int N = 110;
point a[N];

double ans[N];

bool check(int i0, int i1, int i2) {
	point p0 = a[i1] - a[i0], p1 = a[i2] - a[i1];
	return (p1 ^ p0) > 0ll;
}

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	int n;
	cin >> n;
	forn(i, n) {
		cin >> a[i].x >> a[i].y;	
	}
	vi p(n);
	pll minn;
	forn(i, n) {
		p[i] = i;
		umn(minn, a[i]);
	}
	forn(i, n) {
		a[i] = a[i] - minn;
	}
	sort(all(p), [&](int i, int j) {
		return (a[i] == mp(0ll, 0ll)) || ((a[j] ^ a[i]) > 0ll) || ((a[j] ^ a[i]) == 0ll && a[i].x < a[j].x) || ((a[j] ^ a[i]) == 0ll && a[i].x == a[j].x && a[i].y < a[j].y);
	});
	vi st;
	forn(i, n) {
		while (sz(st) > 1 && !check(st[sz(st) - 2], st[sz(st) - 1], p[i])) {
			st.pop_back();
		}
		st.pb(p[i]);		        	
	}
	memset(ans, 0, sizeof(ans));
	if (sz(st) < 3) {
		forn(i, sz(st)) {
			ans[st[i]] = 1. / sz(st);
		}
		
	} else {
		forn(i, sz(st)) {
			point p0 = a[st[(i - 1 + sz(st)) % sz(st)]] - a[st[i]];
			point p1 = a[st[(i + 1 + sz(st)) % sz(st)]] - a[st[i]];
			ans[st[i]] += (pi - fabsl(atan2(p0 ^ p1, p0 * p1))) / (2 * pi);
		}
	}

	forn(i, n) {
		cout << ans[i] << endl;
	}

	return 0;
}

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

int main(){
    int n;
    double k,count=0;
    cin >> n;
  vector<int> vec(n);
   for(int i=0;i<n;i++){
     int a;
     cin >> a;
     count++;
     k += a;
     vec.at(i) = a;
   }
  double x = k/count;
  int b = round(x);
  long long ans=0;
  for(int i=0;i<n;i++){
    ans += (vec.at(i)-b)*(vec.at(i)-b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
const int SURFACE_NUM = 6;
enum Direction{TOP, SOUTH, EAST, WEST, NORTH, BOTTOM};

class Dice{
public:
    void roll(char op);
    int top(){
        return label_value[label_dir[TOP]];
    }
    Dice(int label_value[SURFACE_NUM]);
private:
    Direction label_dir[SURFACE_NUM];//lavel_dir[dir] は 方角dirの面
    int label_value[SURFACE_NUM];//label_value[p] は 面pの数値
};

Dice::Dice(int lv[SURFACE_NUM]){
    for(int i = 0; i < SURFACE_NUM; i++) Dice::label_value[i] = lv[i];
    for(int i = 0; i < SURFACE_NUM; i++) Dice::label_dir[i] = static_cast<Direction>(i);
    /*
    label_dir[0] = label_dir[TOP] = 0;//面0
    label_dir[1] = label_dir[SOUTH] = 1;//面1
    ...
    label_dir[5] = label_dir[BOTTOM] = 5;//面5
    */
}

void Dice::roll(char op){
    Direction tmp;
    switch(op){
    case 'E':
        tmp = label_dir[BOTTOM];
        label_dir[BOTTOM] = label_dir[EAST];
        label_dir[EAST] = label_dir[TOP];
        label_dir[TOP] = label_dir[WEST];
        label_dir[WEST] = tmp;
        break;
    case 'N':
        tmp = label_dir[NORTH];
        label_dir[NORTH] = label_dir[TOP];
        label_dir[TOP] = label_dir[SOUTH];
        label_dir[SOUTH] = label_dir[BOTTOM];
        label_dir[BOTTOM] = tmp;
        break;
    case 'S':
        tmp = label_dir[BOTTOM];
        label_dir[BOTTOM] = label_dir[SOUTH];
        label_dir[SOUTH] = label_dir[TOP];
        label_dir[TOP] = label_dir[NORTH];
        label_dir[NORTH] = tmp;
        break;
    case 'W':
        tmp = label_dir[EAST];
        label_dir[EAST] = label_dir[BOTTOM];
        label_dir[BOTTOM] = label_dir[WEST];
        label_dir[WEST] = label_dir[TOP];
        label_dir[TOP] = tmp;
        break;
    }
}

int main(){
    using namespace std;
    int dice_value[SURFACE_NUM];
    string operation;
    for(int i = 0; i < SURFACE_NUM; i++) cin >> dice_value[i];
    cin >> operation;
    Dice d1(dice_value);
    for(int i = 0; i < operation.length(); i++){
        d1.roll(operation[i]);
    }
    
    cout << d1.top() << endl;
    
    return 0;
}


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

char ma[8][8];
int x,y,n;

void dfs(int x,int y){
    ma[y][x]='0';
    for(int i=1;i<4;i++){
        if(y-i>=0&&ma[y-i][x]=='1')dfs(x,y-i);
        if(y+i<8&&ma[y+i][x]=='1')dfs(x,y+i);
        if(x-i>=0&&ma[y][x-i]=='1')dfs(x-i,y);
        if(x+i<8&&ma[y][x+i]=='1')dfs(x+i,y);
    }
}

int main(){
    cin>>n;
    for(int c=1;c<=n;c++){
        for(int i=0;i<8;i++)
            for(int j=0;j<8;j++)
                cin>>ma[i][j];
        cin>>x>>y;
        dfs(x-1,y-1);
        cout<<"Data "<<c<<":"<<endl;
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++)
                cout<<ma[i][j];
            cout<<endl;
        }
    }
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    tuple<string,int,int> r[n];
    int i=0;
    for(i=0;i<n;i++){
        cin >> get<0>(r[i]) >> get<1>(r[i]);
        get<2>(r[i]) = i+1;
    }

    sort(r,r+n);
    int j;
    for(j=0;j<n;j++){
        for(i=0;i<n-1;i++){
            if(get<0>(r[i])==get<0>(r[i+1])){
                if(get<1>(r[i])<get<1>(r[i+1]))
                    swap(r[i],r[i+1]);
            }
        }
    }

    for(i=0;i<n;i++)
        cout << get<2>(r[i]) << endl;
}

Measured memory_bytes: 3584
N = int(input())
h = list(map(int, input().split()))
dp = [0]*N
for i in range(1, N):
    if i-2>=0:
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
    else:
        dp[i] = dp[i-1]+abs(h[i]-h[i-1])
print(dp[-1])

Measured memory_bytes: 52208
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  ll sum = 0;
  for (int i = 0; i < N - 1; i++) {
    if ((X[i + 1] - X[i]) * A <= B) {
      sum += (X[i + 1] - X[i]) * A;
    } else {
      sum += B;
    }
  }
  cout << sum << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;

    string m[] = {"01","02","03","04"};

    for(int i = 0; i < 4; i++){
        if(s.substr(5,2) == m[i]){
            cout << "Heisei" << endl;
            return 0;
        }
    }
    cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
int main(){
    int s;cin>>s;
    bool ok=false;
    string st;
    st=to_string(s);
    rep(i,3){
        if(st[i]=='7'){
            ok=true;
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}

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

bool isprime(int a) {
  if (a==2) {
    return true;
  }
  if (a<2 || a%2==0) {
    return false;
  }
  for (int i=3; i*i<=a; i+=2) {
    if (a%i==0) {
      return false;
    }
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  int ans=0;
  while (n--) {
    int x;
    cin >> x;
    if (isprime(x)) {
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3192
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    f = [LI() for _ in range(n)]
    p = [LI() for _ in range(n)]
    ii = [2**_ for _ in range(10)]
    r = -inf
    for k in range(1,2**10):
        a = [0] * n
        for i in range(10):
            if k&ii[i]:
                for j in range(n):
                    if f[j][i] == 1:
                        a[j] += 1
        tr = 0
        for i in range(n):
            tr += p[i][a[i]]
        if r < tr:
            r = tr

    return r



print(main())




Measured memory_bytes: 6344
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    double t = 0.0;
    for (size_t i = 1; i <= n; ++i) {
        if (i % 2 == 1)
            t += 1.0;
    }
    auto c = t / double(n);
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;
typedef pair<int,int> pair_ii;
typedef pair<ull,ull> pair_ull;
 
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;
 
int main()
{
	int n;
	cin >> n;
	vec_i v(n);
	rep(i, n) cin >> v[i];

	int ans = 0;
	int now = 0;
	for(int i=n-2;i>=0;i--){
		if(v[i] >= v[i+1])
			now++;
		else
			now = 0;
		ans = max(ans, now);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
using namespace std;

int main() {
	int N;cin>>N;
	vector<string>S(3);
	for(int k=0;k<3;k++)cin>>S[k];

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if(S[0][i] == S[1][i] && S[1][i] == S[2][i])continue;
		else if(S[0][i] == S[1][i] && S[1][i] != S[2][i])ans++;
		else if(S[0][i] != S[1][i] && S[1][i] == S[2][i])ans++;
		else if(S[0][i] == S[2][i] && S[1][i] != S[2][i])ans++;
		else if(S[0][i] != S[2][i] && S[1][i] != S[2][i])ans+=2;	
	}

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

Measured memory_bytes: 256
#define d for(x=0;x<N;x++){for(y=0;y<N;y++
c,m[10][10],x,N=10;main(y){d)m[x][y]=(x+y)*(x+y+1)/2+1+(x+y&1?x:y);}for(;scanf("%d",&N),N;){printf("Case %d:\n",++c);d)printf("%3d",x+y<N?m[x][y]:N*N+1-m[N-1-x][N-1-y]);puts("");}}}

Measured memory_bytes: 620
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n );

    int a[n];
    int i;
    for(i=0;i<n;i++){
        scanf("%d", &a[i]);
    }

    double sum=0;
    for(i=0;i<n;i++){
        sum+=1/(double)a[i];
    }
    printf("%lf\n", 1/sum);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL N, K;
std::vector<LL>a;
std::vector<std::vector<LL>>memo;

LL dp(LL i, LL j)
{
	if (memo[i][j] != -1) return memo[i][j];
	LL res = 0;
	rep(k, N)
	{
		if (a[k] <= i)
		{
			if (dp(i - a[k], (j + 1) % 2) == 0)
			{
				res = 1;
				break;
			}
		}
	}
	return memo[i][j] = res;
}

int main()
{
	in >> N >> K;
	a.resize(N);
	rep(i, N) in >> a[i];

	memo.resize(K + 1);
	rep(i, memo.size()) memo[i].resize(3, -1);
	out << (dp(K, 0) == 1 ? "First" : "Second") << std::endl;
}


Measured memory_bytes: 10496
#include <stdio.h>

long long int n;

long long int dfs(long long int s){
  long long int ret, t, f1, f2, f3;

  if (s > n) {
    return 0;
  }

  t = s;
  f1 = 0;
  f2 = 0;
  f3 = 0;
  while (t > 0) {
    if (t % 10 == 7) {
      f1 = 1;
    }
    if (t % 10 == 5) {
      f2 = 1;
    }
    if (t % 10 == 3) {
      f3 = 1;
    }
    t = t / 10;
    if (f1 == 1 && f2 == 1 && f3 == 1) {
      break;
    }
  }
  if (f1 == 1 && f2 == 1 && f3 == 1) {
    ret = 1;
  }
  else {
    ret = 0;
  }
  ret += dfs(s*10 + 7);
  ret += dfs(s*10 + 5);
  ret += dfs(s*10 + 3);
  return ret;
}

int main(void){

  scanf("%lld", &n);

  printf("%lld\n", dfs(0));

  return 0;
}


Measured memory_bytes: 128