akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int X,Y,Z;

int main(){
    cin>>X>>Y>>Z;
    X-=Z;
    out(X/(Y+Z));    
}



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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n, h;
    cin >> n >> h;
    vector<int> a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    int j = 0, ans = 0;
    while(j < n && b[j] > a[0] && h > 0){
        h -= b[j];
        ans++;
        j++;
    }
    if(h > 0){
        ans += (h - 1) / a[0] + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
// Problem : E - This Message Will Self-Destruct in 5s
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
#define pb push_back
#define PI acos(-1.0)
#define EPS 1e-4
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fout(S,x)            cout<<fixed<<setprecision(x)<<(S)<<endl
#define present(c,x) ((c).find(x) != (c).end())
#define T() ll t;cin>>t;while(t--)
#define mem(input,b) memset(input,b,sizeof(input))
#define ff first
#define ss second
#define fread(input) freopen("input","r",stdin)
#define fwrite(b) freopen("b","w",stdout)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define FOREACH(i,c) for (__typeof ((c).begin()) i = (c).begin() ; i != (c).end() ; i++)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int main(){
    fastio;
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;++i)
    	cin>>a[i];
    ll ans = 0;
    map<ll,int> store;
    for(int i=0;i<n;++i){
    	store[i+a[i]]++;
    }
    for(int i=0;i<n;++i){
    	ll target = -1*(a[i]-i);
    	ans += store[target];
    }
    cout<<ans<<endl;
    return 0;
}    


Measured memory_bytes: 27392
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll l, r;
  cin >> l >> r;
  ll ans = 1LL<<60;
  bool zero = false;
  for (ll i = l; i < r; ++i) {
    for (ll j = i+1; j <= r; ++j) {
      ll res = i*j % 2019;
      chmin(ans, res);
      if (res == 0) {
        zero = true;
        break;
      }
      debug(res);
    }
    if (zero) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
/** Problem0052 : Factorial II **/
int main()
{
	int n, t, fact2, fact5;
	
	while (1) {
		cin >> n;
		if (n == 0) break;
		
		fact2 = 0; fact5 = 0;
		for (int i=1; i<=n; i++) {
			t = i;
			while (t%5==0) {
				fact5++;
				t/=5;
			}
			t = i;
			while (t%2==0) {
				fact2++;
				t/=2;
			}
		}
		
		cout << min(fact5, fact2) << endl;
	}
}

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

int main() {
  string s,t;
  cin>>s>>t;
  bool ans=false;
  rep(i,s.size()){
    char fir=s.back();
    s.pop_back();
    s=fir+s;
    if(s==t){
      ans=true;
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

int n,k;
cin>>n>>k;
int l[n];
for(int i=0;i<n;i++){
    cin>>l[i];
}
sort(l,l+n,greater<int>());

int ans=0;
for(int i=0;i<k;i++){
    ans+=l[i];
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
inline int  in(){int n;scanf("%lld",&n);return n;}
inline void out(int n){printf("%lld\n",n);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n,k;
vi vec;

signed main(){
    io();
    cin>>n>>k;
    vec.resize(n);
    rep(i,n) cin >> vec[i];

    int x = 1;
    while(true){
        int v=k+(k-1)*(x-1);
        if(v>=n) break;
        x++;
    }
    cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define mk make_pair

int main()
{
	ll a,b;
	cin>>a>>b;
	map<ll,ll> mp;
	ll count=a;
	while(b--)
	{
		ll k;
		cin>>k;
		for(ll i=0;i<k;i++)
		{
			ll h;
			cin>>h;
			mp[h]++;
			if(mp[h]==1)
			{
				count--;
			}
		}
	}
	cout<<count<<endl;
}


Measured memory_bytes: 3636
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a.sort()
ans = 0
for i in range(n):
  try:
    if a[i-1] != a[i]:
      ans += cnt
      cnt = 1
    else:
      cnt = 1 - cnt
  except:
    #i==0
    cnt = 1
  #print(a[i],cnt,ans)
ans += cnt
print(ans)

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

int main() {
  ll sum = 0,mod = 1000000007;
  int N;
  cin >> N;
  ll A[N];
  rep(i,N) cin >> A[i];
  ll sareru = 0;

  for(int k = N-2;k >= 0;k--){
    sareru += A[k+1];
    sum += (A[k] * (sareru % mod)) % mod;
  }

  // rep(j,N){
  //   littlesum = 0
  //   for(int k = j+1; k<N ; k++){
  //     littlesum += (A[j] * A[k]) % mod;
  //   }
  //   sum += (A[j] * littlesum) % mod;
  // }
  cout << sum % mod << endl;
  return 0;
}

Measured memory_bytes: 5156
n = int(input())
Taro_score = 0
Hanako_score = 0
for i in range(n):
    wlist = []
    t,h = map(str, input().split())
    wlist.append(t)
    wlist.append(h)
    order = sorted(wlist, key = str.lower)
    if (t.lower() == h.lower()):
        Taro_score += 1
        Hanako_score += 1
    elif (order[1] == t):
        Taro_score += 3
    elif (order[1] ==h ):
        Hanako_score += 3
print(Taro_score, Hanako_score)
        


Measured memory_bytes: 5600
#A問題
ans = 0
for i in range(50):
    a = int(input())
    if i%10 == 0 and a!=0:
        ans+=a
    elif a != 0:
        ans-=a
        if i%10 == 9:
            print(ans)
            ans = 0
    else:
        break
    


Measured memory_bytes: 5588
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

match = [10**18, 2, 5, 5, 4, 5, 6, 3, 7, 6]

# 作れる数字の個数
dp = [-10**18] * (N + 1)
dp[0] = 1

for i in range(N):
    for a in A:
        m = match[a]
        if i + m <= N and dp[i + m] < dp[i] + 1:
            dp[i + m] = dp[i] + 1

ans = []
while N > 0:
    for a in A:
        m = match[a]
        if N - m >= 0 and dp[N - m] + 1 == dp[N]:
            ans.append(a)
            N -= m
            break

ans.sort(reverse=True)

print(''.join(map(str, ans)))


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define gcd(a,b)   __gcd(a,b)
#define lcm(a,b)   (a*b)/gcd
std::vector<int> v;
/***bool ar[1005];
void sieve(){
	for(int i=0;i<=1005;i++){
	  ar[i]=true;
	}
	ar[0]=false;
	ar[1]=false;
	for(int i=4;i<=1005;i+=2){
		ar[i]=false;
	}
	for(int i=3;i<=1005;i+=2){
		if(ar[i]==true){
			for(int j=i*i;j<=1005;j+=i){
				ar[j]=false;
			}
		}
	}
}
****/

int main()
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    
   string s;
   cin>>s;
   for(int i=0;i<3;i++) cout<<s[i];
   cout<<endl;
   return 0;

}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

struct UnionFind {
  vector<int> data;

  UnionFind(int n){
    data.resize(n+1);
    fill(data.begin(), data.end(), -1);
  }

  int root(int x){
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);

    if(rx!=ry){
      if(data[ry] < data[rx])swap(rx, ry);

      data[rx]+=data[ry];
      data[ry]=rx;
    }
  }

  bool same(int x, int y){
    return root(x)==root(y);
  }

  int size(int x){
    return -data[root(x)];
  }
};

int main(){
  int n,m;cin>>n>>m;
  vector<int> a(m),b(m);
  rep(i, m)cin>>a[i]>>b[i];
  int result = 0;
  rep(i, m){
    UnionFind uf(n);
    rep(j, m)if(i!=j)uf.unite(a[j], b[j]);
    if(!uf.same(a[i], b[i]))result++;
  }
  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int station[10];
int v1, v2;

void solve() {
    double v = (v1 + v2);
    int sumDis = 0;
    for(int r = 0; r < 10; r++) {
        sumDis += station[r];
    }
    
    double multi = v1 * (sumDis / v); //速さ * 時間(距離/速さ) = v1で鉢合わせるまで進んだ距離
    //cout << multi << endl;
    int kukan = 0;
    for(int r = 0; r < 10; r++) {
        //cout << multi << endl;
        if(multi <= 0) break;
        multi -= station[r];
        kukan++;
    }
    cout << kukan << endl;
}

int main(void) {
    
    while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &station[0],&station[1],&station[2],&station[3],&station[4],&station[5],&station[6],&station[7],&station[8],&station[9], &v1, &v2) != EOF) {
        solve();
    }
    
    return(0);
}

Measured memory_bytes: 1208
let cmp a b = 0-(a-b);;

Printf.printf "%s\n" @@
Scanf.scanf "%d %d\n" @@ fun n m ->
    let a = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun i -> i in
    Array.sort (cmp) a;
    let sum = Array.fold_right ( + ) a 0 in
    let min = (sum+4*m-1)/(4*m) in
    let ans = ref "Yes" in
    for i = 0 to m-1 do
        if a.(i) < min then
            ans := "No";
    done;
    !ans


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

int main(){
    
    int n, m;
    cin >> n >> m;
    
    vector<int> x(m);
    for (int i = 0; i < m; i++) cin >> x[i];
    
    
    if (m <= n){
        cout << 0 << endl;
        return 0;
    }
    
    sort(x.begin(),x.end());
    
    vector<int> interval(m);
    for (int i = 0; i < m-1; i++){
        interval[i] = x[i+1] - x[i];
    }
    
    sort(interval.rbegin(),interval.rend());
    
    int ans = x[m-1] - x[0];
    
    for (int i = 0; i < n-1; i++){
        ans -= interval[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

const int INF = 2000000000;
const double pi = 3.1415926;
const int base = 1000000007;


int n;
map <string, int> m;

int main()
{
    //ifstream cin ("input.txt");
    //ofstream cout ("output.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    int ma = 0;
    for (auto it : m)
    {
        ma = max(ma, it.second);
    }
    for (auto it : m)
    {
        if (it.second == ma)
        {
            cout << it.first << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 23808
a, b, k = map(int, raw_input().split())
#print(a,b,k)

for i in range(k):
  #takahashi
  if i%2 == 0:
    c = a    
    #even
    if c%2 == 0:
      b += c/2
      a = c/2    
    #odd
    elif c%2 == 1:
      c = c-1
      b += c/2
      a = c/2
  
  elif i%2 == 1:
    c = b   
    #even
    if c%2 == 0:
      a += c/2
      b = c/2
    
    #odd
    elif c%2 == 1:
      c = c-1
      a += c/2
      b = c/2

print a,b

Measured memory_bytes: 2568
n,m = map(int,input().split())
visited = [-1 for _ in range(n+1)]
visited[1] = 0
will = []
root = [[] for _ in range(n+1)] 
for i in range(m):
    a,b = map(int,input().split())
    root[a].append(b)
    root[b].append(a)

will.append(1)

while will:
    visit = will.pop(0)
    for i in root[visit]:
        if visited[i] != -1:
            continue
        will.append(i)
        visited[i] = visit

if visited[1:] == -1:
    print('No')
else:
    print('Yes')
    for i in range(2,len(visited)):
        print(visited[i])


Measured memory_bytes: 34340
N, K = map(int, input().split())

I = N // K
J = N % K
j = J

if J == 0:
  pass
else:
  j = J
  for i in range(I+2):
    J = abs(J - K)
    if J <= j:
      j = J
    else:
      break
      
print(j)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
long long arr[10000];
int main()
{
	long long n,i,j,ans;
	ans=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			ans=ans+arr[i]*arr[j];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
n = int(input())
count = 0
for i in range(n):
  for j in range(n):
    for k in range(n):
      count += gcd(i+1, j+1, k+1)
print(count)

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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n); 0<=i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());                   //昇順
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());    //降順
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper); 
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define SetPre(x) setprecision(x)
int main(void){
    ll n;
    cin >> n;

    string result ="";

    while(n>0){
        result += ((n-1)%26)+'a';
        n--;
        n/=26;
    }
    //文字列反転
    REP(i,result.length())
    {
        cout << result[result.length()-1-i];
    }

    return 0;
}

Measured memory_bytes: 3596
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
 
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

countOne :: String -> Char -> Int
countOne [] _ = 0
countOne (x:xs) c | x == c = 1 + countOne xs c
                  | otherwise = countOne xs c

main = do
  number <- readInts
  let xs = show $ head number
  putStrLn $ show $ countOne xs '1'

Measured memory_bytes: 380
N = int(input())
W = [int(i) for i in input().split()]
ans = float('inf')
check1 = 0
check2 = sum(W)
for i in range(N-1):
    check1 += W[i]
    check2 -= W[i]

    ans = min(abs(check2 - check1), ans)

print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};

typedef struct node * Node;

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL) inorder(root);
      printf("\n");
      
    x=x->left;

  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x=x->right;

  return x;
}

Node treeSearch(Node x,int k){
  if(x==NIL && k==x->key)
    return x;

  if(k < x->key)
    return treeSearch(x->left,k);
  else
    return treeSearch(x->right,k);

}

Node treeSuccessor(Node x){
  Node y;


  if(x->right != NIL)
    return treeMinimum(x->right);

  y=x->p;
  while(y != NIL && x==y->right){
    x=y;
    y=y->p;
  }

  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;

  if(z->left==NIL || z->right==NIL)
    y=z;
  else
    y=treeSuccessor(z);


  if(y->left != NIL)
    x=y->right;
  else
    x=y->right;

  if(x!=NIL)
    x->p=y->p;

  if(y->p==NIL)
    root=x;
  else if(y==y->p->left)
    y->p->left=x;
  else
    y->p->right;

  if(y!=z)
    z->key = y->key;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;


  while(x != NIL){
    y=x;
    if(z->key < x->key)
      x=x->left;
    else
      x=x->right;
  }

  z->p=y;

  if(y==NIL)
    root=z;
  else
    if(z->key < y->key)
      y->left=z;
    else
      y->right=z;
}

void inorder(Node x){
  if(x != NIL){
    inorder(x->left);
      printf(" %d",x->key);
  inorder(x->right);
  }
}

void preorder(Node x){
  if(x != NIL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
}

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]== 'f'){
      scanf("%d",&x);
      Node t = treeSearch(root,x);

      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }else if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(com[0]=='d'){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  }

  return 0;
}
    



Measured memory_bytes: 25172
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, A ,B;
	cin >> N >> A >> B;
	vector<long long>X(N);
	for (int i = 0;i<N;++i) {
		cin >> X[i];
	}
	long long ans = 0;
	for (int i = 0;i<N-1;++i) {
		if (B>(X[i+1]-X[i])*A) {
			ans += (X[i+1]-X[i])*A;
		}
		else {
			ans += B;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3924
N = int(input())
S = input()
r = S.count("R")
g = S.count("G")
b = S.count("B")
ans = r*g*b
for i in range(1, (N-1)//2+1):
    for j in range(N-i*2):
        if not (S[j] == S[j+i] or S[j] == S[j+i*2] or S[j+i] == S[j+i*2]):
            ans -= 1
print(ans)

Measured memory_bytes: 9200
import java.util.*;

class Cookie {
  long[] c = new long[2];
  public Cookie(long a, long b) {
    c[0] = a;
    c[1] = b;
  }

  public void eat() {
    if (c[0] % 2 == 1) c[0]--;
    c[0] /= 2;
    c[1] += c[0];
  }

  public void swap() {
    c[0] ^= c[1];
    c[1] ^= c[0];
    c[0] ^= c[1];
  }

  public long getA() {
    return c[0];
  }

  public long getB() {
    return c[1];
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      long a = sc.nextLong();
      long b = sc.nextLong();
      Cookie c = new Cookie(a, b);
      int n = sc.nextInt();
      for (int i = 0; i < n; i++) {
        c.eat();
        c.swap();
      }
      if (n % 2 == 1) c.swap();
      System.out.printf("%d %d\n", c.getA(), c.getB());
    } finally {
      sc.close();
    }
  }
}


Measured memory_bytes: 35872
#include <stdio.h>
#include <string.h>
int main() {
	char A[15], B[15], C[15];
	scanf("%s %s %s", &A, &B, &C);
	int lastCharA = strlen(A) - 1;
	int lastCharB = strlen(B) - 1;
	if (A[lastCharA] == B[0] && B[lastCharB] == C[0]){
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}


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

#define ran 202202

int n;
int cnt[ran];

int main() {
	scanf("%d", &n);
	for(int i=2;i<=n;i++) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	for(int i=1;i<=n;i++)
		printf("%d\n", cnt[i]);
	
	return 0;
}

Measured memory_bytes: 4504
N = int(input())
S = list(input())
PIN = []
b1 = []
for i in range(N-2):
    b2 = []
    if S[i] in b1:
        continue
    else:
        b1.append(S[i])
    for j in range(i+1, N-1):
        b3 = []
        if S[j] in b2:
            continue
        else:
            b2.append(S[j])
        for k in range(j+1, N):
            if S[k] in b3:
                continue
            else:
                b3.append(S[k])
            cand = S[i] + S[j] + S[k]
            PIN.append(cand)

print(len(set(PIN)))

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

int main(void) {
    int g = 0, p = 0, w = 0, l = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'g') {
            if (g >= p + 1) {
                p++;
                w++;
            }
            else g++;
        }
        if (s[i] == 'p') {
            if (g < p + 1) {
                g++;
                l++;
            }
            else p++;
        }
    }
    cout << w - l << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int color[8]={};
    int N;
    int ans=0;
    int minans=0;
    scanf("%d",&N);
    int kari;
    for(int i=0;i<N;i++){
        scanf("%d",&kari);
        if(kari/400<8)color[kari/400]=1;
        else ans++;
    }
    for(int i=0;i<8;i++){
     ans+=color[i];   
     minans+=color[i];
    }
    if(minans==0)minans=1;
    printf("%d %d",minans,ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LL long long
using namespace std;
vector <int> A,B;
const LL O=1000000000;
int w,N,K; char c,S[3];
char go(LL n){
	cout<<"? "<<n<<endl;
	cin>>c; return c;
}
int fuck(int l,int r){
	if (l==r) return l;
	return go(O*(w*10+(l+r>>1))+O-1)=='N'?
	fuck((l+r>>1)+1,r):fuck(l,l+r>>1);
}
int main(){
	for (int i=1,x=10;i<=9;++i,x*=10){
		c=go(x);
		if (c=='N') {K=i; break;}
	}
	if (!K)
	for (int i=9,x=O-1;i;--i,x/=10){
		c=go(x);
		if (c=='N') {K=i+1; break;}
	}
	if (!K) {cout<<"! 1"<<endl; return 0;}
	if (K==10) {cout<<"! "<<O<<endl; return 0;}
	w=w*10+fuck(1,9);
	for (int i=2;i<=K;++i) w=w*10+fuck(0,9);
	cout<<"! "<<w<<endl;
	return 0;
}

Measured memory_bytes: 596
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( int );
	
	return tuple( n );
}

auto solve( in int n )
{
	auto r = 0;
	
	foreach( i; 1 .. n + 1 )
	{
		if( i % 2 == 0 ) continue;
		
		auto y = 0;
		
		foreach( k; 1 .. n + 1 )
		{
			if( i % k == 0 ) y++;
		}
		
		if( y == 8 ) r++;
	}
	
	return r;
}


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

chs=[[] for i in range(31)]

for i in range(n):
    s,t,c=map(int,input().split())
    chs[c].append((s,t))

for q in range(len(chs)):
    ch=chs[q][:]
    ch.sort()
    new=[]
    if len(ch)<=1:
        continue
    else:
        now=ch[0]
        for i in range(1,len(ch)):
            if now[1]==ch[i][0]:
                now=(now[0],ch[i][1])
            else:
                new.append(now)
                now=ch[i]
        new.append(now)
        chs[q]=new[:]

tim=[0 for i in range(200002)]

for ch in chs:
    for pro in ch:
        tim[pro[0]*2-1]+=1
        tim[pro[1]*2]-=1

cnt=0
ans=0
for i in range(len(tim)):
    cnt+=tim[i]
    ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 24676
#include<stdio.h>
#include<string.h>
int main(void){
   char p[101];
   char s[101];
   char c[101];
   char *ans;
   scanf("%s",s);
   scanf("%s",p);
   strcpy(c,s);
   strcat(s,c);
   ans = strstr(s,p);
   if(ans == NULL)
       puts("No");
   else
       puts("Yes");
   return 0;
}


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

//#include "rubo.h"
#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout << endl;

typedef long double ld;

using namespace std;


const int N = 200 * 1000 + 123;



int main() {
    int n,h,w;
    cin >> n >> h >> w;

    int res;
    res = (n-h+1)*(n-w+1);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep0(i,n) for(i=0;i<n;i++)
using namespace std;
int main(){
    FAST;

    int n,d;
    cin>>n;
    d=n%10;
    if(d==2 ||d==4 ||d==5 ||d==7 ||d==9 ){
        cout<<"hon"<<endl;
    }
    else if(d==0 ||d==1 ||d==6 ||d==8 ){
        cout<<"pon"<<endl;
    }
    else{
        cout<<"bon"<<endl;
    }

}



Measured memory_bytes: 3652
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

def dfs(idx, a, b, c):
    if idx == N:
        if a == 0 or b == 0 or c == 0:
            return 10**9
        return abs(A - a) + abs(B - b) + abs(C - c)

    x = dfs(idx + 1, a, b, c)
    y = dfs(idx + 1, a + L[idx], b, c) + 10*(a != 0)
    z = dfs(idx + 1, a, b + L[idx], c) + 10*(b != 0)
    w = dfs(idx + 1, a, b, c + L[idx]) + 10*(c != 0)
    #print(x, y, z, w)
    #print('here!')
    return min(x, y, z, w)

ans = dfs(0, 0, 0, 0)
print(ans)

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

int main() {
  int h, w;
  char t;
  cin >> h >> w;
  vector<vector<bool>> a(h+1, vector<bool>(w+1, 0));
  rep(i,h) rep(j,w){
    cin >> t;
    if(t == '#'){
      a.at(i).at(j) = 1;
      a.at(i).at(w) = 1;
      a.at(h).at(j) = 1;
    }    
  }
  
  rep(i,h) if(a.at(i).at(w)) rep(j,w){
    if(a.at(h).at(j)){
      if(a.at(i).at(j)) cout << '#';
      else cout << '.';
    }
    if(j == w-1) cout << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
for i in range(n):
    print(input().replace("Hoshino","Hoshina"))

""" n = int(input())
for i in range(n):
    # 一度にlist(map(int,input().split()))しようとすると1単語時にエラー
    S = input()
    string = [t for t in S.split()]
    for word in string:
        if word=="Hoshino":
            word = "Hoshina"
        elif word=="hoshino":
            word = "hoshina"
        print(word,end=" ")
    print("") """


Measured memory_bytes: 5596
#include <stdio.h>
#include <string.h>)
int main()
{
	int i,n,j,k=0;
	char a[100];
	scanf("%s",a); 
	n=strlen(a);
    for(i=0;i<n;i++)
    {
    	for(j=i+1;j<n;j++)   
    	if(a[i]==a[j]) k=1;    	   
    }
    if(k==1)
    printf("no");
    else printf("yes");		
 	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=400010;
int n,a[N],t1[N],cnt1,cnt2,t2[N];map<int,int>M1,M2;
int main()
{
	n=gi();for(int i=1;i<=n;i++)a[i]=gi();
	for(int i=1;i<=n;i++)
	{
		int del=a[i]-i;
		if(M1.find(del)==M1.end())M1[del]=++cnt1;
		t1[M1[del]]++;
	}
	for(int i=1;i<=n;i++)
	{
		int del=-a[i]-i;
		if(M2.find(del)==M2.end())M2[del]=++cnt2;
		t2[M2[del]]++;
	}
	ll ans=0;
	for(auto it:M1)
	{
		int x=it.first,s1=t1[M1[x]],s2=t2[M2[x]];
		ans+=1ll*s1*s2;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 31524
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next()) - 1;
        int b = Integer.parseInt(sc.next()) - 1;
        int c = Integer.parseInt(sc.next()) - 1;
        int d = Integer.parseInt(sc.next()) - 1;
        String s = sc.next();
        sc.close();

        // 主処理
        boolean judge = canThroughtWall(s, a, c) && canThroughtWall(s, b, d); // 2連続で壁がないことをチェック
        // cの移動経路がaと完全に重なる場合
        if (b < c && d < c) {
            judge = judge && canMoveNotWallSide(s, b, d);
        }
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }

    public static boolean canThroughtWall(String s, int startIndex, int endIndex) {
        for (int i = startIndex; i < endIndex; i++) {
            char left = s.charAt(i);
            char right = s.charAt(i + 1);
            if (left == '#' && right == '#') {
                return false;
            }
        }
        return true;
    }

    public static boolean canMoveNotWallSide(String s, int startIndex, int endIndex) {
        for (int i = startIndex; i <= endIndex; i++) {
            char left = s.charAt(i - 1);
            char right = s.charAt(i + 1);
            if (s.charAt(i) == '.' && left == '.' && right == '.') {
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 28068
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll int,ll int>
#define pb push_back
#define sbit __builtin_popcount
#define vec vector <int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bg begin()
#define en end()
#define endl "\n"
#define ff first
#define ss second
#define all(x) x.bg,x.en
#define sz(a) (int)a.size()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define sp(x) setprecision(x)
#define fill(a,b) memset(a,b,sizeof(a))
#define fr(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rr(i,a,b) for(int i=a;i>=b;i--)
#define ft(it,x) for(auto it : x)
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define mapi map<int,int>
#define mapl map<ll int,ll int>
#define val_at(x) find_by_order(x)
#define idx_of(x) order_of_key(x)
#define scni(x) scanf("%d",&x)
#define prt(x) printf("%d\n",x)
#define test(t) int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define val_at(x) find_by_order(x)
#define idx_of(x) order_of_key(x)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> myset;
const int mod=1e9+7;
const int mex=1e6+1;
inline ll power(ll a,ll b)
{
    ll ans=1,temp=a;
    while(b!=0)
    {
        if(b&1)
        ans=ans*temp;
        ans=ans%mod;
        temp=temp*temp;
        temp=temp%mod;
        b/=2;
    }
    return ans;
}
int pr[mex];
vec prime;
inline void seive()
{
    rp(i,2,mex) pr[i]=1;
    for(int i=2;i*i<mex;i++)
    {
        if(pr[i])
        for(int j=i*i;j<mex;j+=i)
        pr[j]=0;
    }
    vec prime;
    rp(i,2,mex)
    {
        if(pr[i]) prime.pb(i);
    }
}
ll int xx,xy,d1;
void exeu(ll int a1,ll int b1)
{
    if(b1==0)
    {
        xx=1;
        xy=0;
        d1=a1;
    }
    else
    {
        exeu(b1,a1%b1);
        ll int temp=xx;
        xx=xy;
        xy=temp-(a1/b1)*xy;
    }
}
ll int modinv(ll int A,ll int M)
{
    exeu(A,M);
    return (xx%M+M)%M;
}
int main()
{
    fast
    int n;
    cin>>n;
    map<pair<int,int>,ll int> mp;
    rp(i,1,n+1)
    {
        int j=i;
        int y=j%10,x=j%10;
        while(j!=0)
        {
            x=j%10;
            j=j/10;
        }
        pii p={x,y};
        //cout<<i<<" "<<x<<" "<<y<<endl;
        mp[p]++;
    }
    ll int ans=0;
    ft(it,mp)
    {
        int x=it.ff.ff,y=it.ff.ss,z=it.ss;
        pii p={y,x};
        ans+=mp[p]*z;
        //cout<<ans<<endl;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

P dir[4] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

int main() {
    int H, W; cin >> H >> W;
    char s[H][W];
    queue<P> Q;
    vector<vector<int>> dist(H, vector<int>(W, INF));
    rep(i, H) {
        rep(j, W) {
            cin >> s[i][j];
            if(s[i][j] == '#') {
                Q.push(mp(i, j));
                dist[i][j] = 0;
            }
        }
    }
    while(!Q.empty()) {
        P q = Q.front(); Q.pop();
        rep(i, 4) {
            int h = q.first + dir[i].first, w = q.second + dir[i].second;
            if(h < 0 || h >= H || w < 0 || w >= W) continue;
            if(s[h][w] == '#') continue;
            if(dist[h][w] == INF) {
                Q.push(mp(h, w));
                dist[h][w] = dist[q.first][q.second] + 1;
            }
            dist[h][w] = min(dist[h][w], dist[q.first][q.second] + 1);
        }
    }
    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            if(s[i][j] == '#')continue;
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 13328
#include <stdio.h>
int main(void){
    
    int w, h, x, y, r, a = 1;
    scanf("%d %d %d %d %d\n", &w, &h, &x, &y, &r);
    
    if(x - r < 0)
        a = 0;
    if(x + r > w)
        a = 0;
    
    if(y - r < 0)
        a = 0;
    if(y + r > h)
        a = 0;
    
    if(a == 0){
        printf("No\n");
    }if(a != 0){
        printf("Yes\n");
    }
    
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

//ユークリッドの互除法　aとbの最大公約数
int euclid(int a, int b){
	int c = a % b;
	if(c == 0){
		return b;
	}else{
		return euclid(b, c);
	}
}


int main(void){
	int n,x,inp;
	cin>>n>>x;
	vector<int> sa;
	rep(i,n){
		cin>>inp;
		sa.push_back(abs(inp - x));
	}

	int ans = (sa[0] == 0 ? sa[1] : sa[0]);	

	rep(i,n){
		if(sa[i] == 0){
			continue;
		}
		ans = euclid(ans, sa[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 892
H = int(input())
W = int(input())
N = int(input())
ans = 0
idx = 0
if H > W:
    pass
elif W > H:
    H,W = W,H

for i in range(1,W+1):
    ans += H
    idx += 1
    if ans >= N:
        print(idx)
        break



Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
#include <iomanip>
using namespace std;
// type alias
typedef long long LL;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))

// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');

// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpf(args...) if(TRACE) { fprintf(stderr, ##args); putchar('\n'); }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
template<class Iter> void dumpc(Iter begin, Iter end) { if (TRACE) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; } }

// $ ../batch 753 | diff 753.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address 753.cpp && ./a.out
int N;

void solve() {
  cout<<((N==7||N==5||N==3)?"YES":"NO")<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  solve();
  
  return 0;
}


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

int main() {
  string X;
  cin >> X;
  stack<char> sts;
  for(int i = 0; i < X.size(); ++i) {
    auto crnt = X[i];
    if(sts.size() > 0 && sts.top() == 'S' && crnt == 'T') {
      sts.pop();
    } else {
      sts.push(crnt);
    }
  }
  cout << sts.size() << endl;
  return 0;
}

Measured memory_bytes: 644
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int cnt[9] = {};
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a < 400) cnt[0]++;
		else if(a < 800) cnt[1]++;
		else if(a < 1200) cnt[2]++;
		else if(a < 1600) cnt[3]++;
		else if(a < 2000) cnt[4]++;
		else if(a < 2400) cnt[5]++;
		else if(a < 2800) cnt[6]++;
		else if(a < 3200) cnt[7]++;
		else cnt[8]++;
	}
	int colornum = 0;
	for(int i = 0; i < 8; i++){
		if(cnt[i] > 0) colornum++;
	}
	cout << max(colornum, 1) << " " << colornum + cnt[8] << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define INF 1e16
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    ll n, a, b = INF;
    cin >> n;
    REP(i, 5) {
        cin >> a;
        b = min(a, b);
    }
    cout << (n + b - 1) / b + 4<< endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;
typedef long long int lint;

#define INF 10000000

int* mk_vector(int size, int init)
{
	int* vec = new int[size];
	for (int i = 0; i < size; i++) {
		vec[i] = init;
	}
	return vec;
}

int** mk_matrix(int size, int init)
{
	int** mat = new int*[size];
	for (int i = 0; i < size; i++) {
		mat[i] = new int[size];
	}
	for (int i = 0; i < size; i++) {
		for (int j = 0; j < size; j++) {
			mat[i][j] = init;
		}
	}
	return mat;
}

int Dijkstra(int size, int start, int goal, int** cost)
{
	//??????S
	bool* S = new bool[size + 1];
	//??????V-S
	bool* V = new bool[size + 1];
	//D[i] : i??????????????????????°??????????
	int* D = mk_vector(size + 1, INF);

	for (int i = 1; i <= size; i++) {
		S[i] = false;
		V[i] = true;
	}

	S[start] = true;
	V[start] = false;
	for (int i = 1; i <= size; i++) {
		if (S[i]) continue;
		D[i] = cost[start][i];
	}

	for (int i = 1; i <= size - 1; i++) {
		//D[w] ???????°???¨?????? w in V-S ????±???????
		int w;
		int minD = INF;
		for (int i = 1; i <= size; i++) {
			if (!V[i]) continue;
			if (D[i] < minD) {
				minD = D[i];
				w = i;
			}
		}
		//S = S cup {w}
		S[w] = true;
		V[w] = false;
		for (int i = 1; i <= size; i++) {
			if (!V[i]) continue;
			D[i] = min(D[i], D[w] + cost[w][i]);
		}
	}

	int ret = D[goal];

	delete[] S;
	delete[] V;
	delete[] D;

	return ret;
}

void AOJ0117()
{
	int n, m;
	cin >> n >> m;
	int** cost = mk_matrix(n + 1, INF);
	for (int i = 0; i < m; i++) {
		int	a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		cost[a][b] = c; // a to b
		cost[b][a] = d; // b to a
	}
	int start, goal, V, P;
	scanf("%d,%d,%d,%d", &start, &goal, &V, &P);

	//print(cost, n);

	int ans = V - P - Dijkstra(n, start, goal, cost) - Dijkstra(n, goal, start, cost);

	cout << ans << endl;

	return;
}

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

Measured memory_bytes: 3152
import sys


def dep(u, p):
    depth[u] = p
    if TREE[u][1] != NIL:
        dep(TREE[u][1], p+1)
    if TREE[u][2] != NIL:
        dep(TREE[u][2], p+1)


def hei(u):
    h1, h2 = 0, 0
    if TREE[u][1] != NIL:
        h1 = hei(TREE[u][1]) + 1
    if TREE[u][2] != NIL:
        h2 = hei(TREE[u][2]) + 1
    height[u] = max(h1, h2)
    return height[u]


def print_ans():
    for i in range(n):
        print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}"
              .format(i, TREE[i][0], TREE[i][3],
                      2 if TREE[i][1] != -1 and TREE[i][2] != -1 else 0 if TREE[i][1] == NIL and TREE[i][2] == NIL else 1,
                      depth[i], height[i],
                      "root" if TREE[i][0] == NIL else "leaf" if TREE[i][1] == NIL and TREE[i][2] == NIL else "internal node"))


if __name__ == "__main__":
    n = int(sys.stdin.readline())
    NIL = -1
    TREE = [[NIL, NIL, NIL, NIL] for i in range(n)]
    depth = [-1 for i in range(n)]
    height = [-1 for i in range(n)]
    root = set(range(n))
    for inp in sys.stdin.readlines():
        inp = list(map(int, inp.split()))
        if inp[1] != -1:
            TREE[inp[0]][1] = inp[1]
            TREE[inp[1]][0] = inp[0]
            TREE[inp[1]][3] = inp[2]
        if inp[2] != -1:
            TREE[inp[0]][2] = inp[2]
            TREE[inp[2]][0] = inp[0]
            TREE[inp[2]][3] = inp[1]
        root -= set([inp[1], inp[2]])
    a = root.pop()
    dep(a, 0)
    hei(a)
    print_ans()

Measured memory_bytes: 7884
fun main(args: Array<String>) {
    abc042a()
}

fun abc042a() {
    val abc = readLine()!!.split(" ").map { it.toInt() }

    val answer = if (abc.count { it == 5 } == 2 && abc.count { it == 7 } == 1) "YES" else "NO"

    println(answer)
}


Measured memory_bytes: 37780
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>

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 REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int main(){
    
    int a,b;
    while(cin>>a){
        cin>>b;
        a=a+b;
        if(a==0)cout<<1<<endl;
        else{
            int ans=0;
            while(a!=0){
                ans++;
                a/=10;
            }
            cout<<ans<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1160
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: 26128
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

locale l = locale::classic();

int main(){
    int p,q,r;
    cin >> p >> q >> r;
    cout << min(p+q, min(q+r,r+p)) << endl;
}

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

int main() {
  int N;
  cin >> N;
  if (N/10==9) {
    cout << "Yes" <<endl;
  }
  else if (N%10==9) {
    cout << "Yes " <<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3560
from itertools import product

n=int(input())
if n<357:
  print(0)
  exit()
ans=0
for i in range(3,len(str(n))):
  ans+=3**i-3*(2**i)+3

for i in product(['3','5','7'],repeat=len(str(n))):
  if '3' in i and '5' in i and '7' in i:
    if int(int(''.join(i)))<=n:
      ans+=1
print(ans)

Measured memory_bytes: 9068
#include <stdio.h>
#include <stdlib.h>

// メイン関数
int main(void)
{
    int n = 0;
    scanf("%d", &n);
    int w[n];
    for (int i = 0; i < n; i++) scanf("%d", &w[i]);
    int s[2];
    int min = 0;
    for (int t = 1; t < n - 1; t++){
        s[0] = 0;
        s[1] = 0;
        for (int i = 0; i < n; i++){
            if (i <= t) s[0] += w[i];
            else s[1] += w[i];
        }
        if (t == 1 || min > abs(s[0] - s[1])){
            min = abs(s[0] - s[1]);
        }
    }
    printf("%d", min);
    return 0;
}


Measured memory_bytes: 128