akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;

int main() {
    string S; cin >> S;
    
    //文字列をRLを含む物へ分割
    vector<string> v;
    int border = 0;
    bool RL = false;
    for(int i = 1; i < strlen(S.c_str()); i++){
        if(S.substr(i - 1, 2) == "RL"){
            RL = true;
        }

        if(RL == true && S[i] == 'R'){
            v.push_back(S.substr(border, i - border));
            border = i;
            RL = false;
        }

        if(i == strlen(S.c_str()) - 1){
            v.push_back(S.substr(border, i + 1 - border));
        }
    }

    //RLの出現部に人数を集約
    for(int i = 0; i < v.size(); i++){
        //集約人数を特定
        int odd, even;
        even = strlen(v[i].c_str()) / 2;

        if(strlen(v[i].c_str()) % 2 == 0){
            odd = strlen(v[i].c_str()) / 2;
        }
        else{
            odd = strlen(v[i].c_str()) / 2 + 1;
        }

        //集約地点を特定
        int point = 0;
        for(int j = 1; j < strlen(v[i].c_str()); j++){
            if(v[i].substr(j - 1, 2) == "RL"){
                point = j - 1;
            }
        }

        //出力処理
        for(int j = 0; j < strlen(v[i].c_str()); j++){
            if(j == point){
                if((point + 1) % 2 == 0){
                    cout << even << " ";
                }
                else{
                    cout << odd << " ";
                }
            }
            else if (j == point + 1){
                if((point + 2) % 2 == 0){
                    cout << even << " ";
                }
                else{
                    cout << odd << " ";
                }
            }
            else{
                 if(i == v.size() - 1 && j == strlen(v[i].c_str()) -1){
                    cout << 0;
                }
                else{
                    cout << 0 << " ";
                }
            }   
        }
    }
    return 0;
}

Measured memory_bytes: 3320
a,b=gets.split.map(&:to_i)
s=gets.chomp
s.size.times do |i|
  if i==a
    if s[i]!="-"
      puts "No"
      exit
    end
  else
    unless ("0".."9").include?(s[i])
      puts "No"
      exit
    end
  end
end
puts "Yes" if s.size==a+b+1


Measured memory_bytes: 1788
import collections

n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))

c = collections.Counter(D)

flg = True
for t in T:
    tmp = c.get(t)
    if tmp == None or tmp == 0:
        flg = False
    else:
        c[t] = tmp - 1

print('YES' if flg else 'NO')


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

int main() {
    int N, Q, a, b, p, x;
    cin >> N >> Q;
    vector<vector<int>> edge(N, vector<int>(0));
    rep(i, N - 1) {
        cin >> a >> b;
        edge[a - 1].push_back(b - 1);
        edge[b - 1].push_back(a - 1);
    }
    vector<int> px(N, 0), ans(N, 0);
    rep(i, Q) {
        cin >> p >> x;
        px[p - 1] += x;
    }
    queue<pair<int, int>> q;
    q.push(make_pair(0, px[0]));
    vector<bool> done(N, false);
    while (q.size() > 0) {
        auto c = q.front();
        q.pop();
        ans[c.first] = c.second;
        done[c.first] = true;
        rep(i, edge[c.first].size()) {
            int d = edge[c.first][i];
            if (done[d]) continue;
            q.push(make_pair(d, c.second + px[d]));
        }
    }
    rep(i, N) {
        cout << ans[i];
        if (i == N - 1) cout << endl;
        else cout << " ";
    }
}

Measured memory_bytes: 17140
import sys

h, w = map(int, input().split())
p = []
for i in range(h):
    p.append(input())

ans = "Yes"
for i in range(h):
    for j in range(w):
        if p[i][j] != "#":
            continue
        _ = False
        # x(j):-1
        if j-1 >= 0 and p[i][j-1] == "#":
            _ = True
        # x:+1
        if j+1 < w and p[i][j+1] == "#":
            _ = True
        # y(i):-1
        if i-1 >= 0 and p[i-1][j] == "#":
            _ = True
        # y:+1
        if i+1 < h and p[i+1][j] == "#":
            _ = True
        if _ is False:
            ans = "No"
            print(ans)
            sys.exit()

print(ans)


Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vll a(n);
    rep(i, n){
        cin >> a[i];
        a[i] %= m;
    }
    vll b(n+1, 0);
    map<ll, ll> mp;
    mp[0]++;
    ll tmp = 0;
    repr(i, 1, n+1){
        tmp += a[i-1];
        tmp %= m;
        b[i] = tmp;
        mp[b[i]]++;
    }
    dump(mp);
    ll ans = 0;
    for(auto&& e: mp){
        ans += e.second*(e.second-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  ll ans=0;
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  for(int i=0;i<N;i++){
    if(i>=K) ans+=Y;
    else ans+=X;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n, m, cnt;
int dis[55];
int vis[55], u[55], v[55];
int E[55][55];
void dfs(int x) {
	for(int i = 1; i <= n; i++) {
		if(i != x) {
			if(E[x][i] && !vis[i]) {
				vis[i] = 1;
				dfs(i);
			}
		}
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++) {
		scanf("%d%d", &u[i], &v[i]);
		E[u[i]][v[i]] = 1;
		E[v[i]][u[i]] = 1;
		dis[u[i]]++;
		dis[v[i]]++;
	}
	int ans = 0, pos = 0;
	for(int i = 1; i <= n; i++)
		if(!dis[i])ans++;
		else pos = i;
	for(int i = 1; i <= m; i++) {
		memset(vis, 0, sizeof(vis));
		E[u[i]][v[i]] = E[v[i]][u[i]] = 0;
		dfs(pos);
		int l = 0;
		for(int j = 1; j <= n; j++)if(!vis[j])l++;
		if(l > ans)cnt++;
		E[u[i]][v[i]] = E[v[i]][u[i]] = 1;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
import sys 
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline()

N, M = map(int , input().split())
G = [[] for i in range(N)]
for i in range(M):
    x, y = map(int , input().split())
    G[x - 1].append(y-1)
    
memo = [-1] * N
def dfs(v):
    if memo[v] == -1:
        memo[v] = max(dfs(w) for w in G[v]) + 1 if G[v] else 0
    return memo[v]
print(max(dfs(v) for v in range(N)))

Measured memory_bytes: 104112
//=================================
// Created on: 2018/09/20 14:24:35
//=================================
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
using ull = unsigned long long;
int main()
{
    int N, M;
    std::cin >> N >> M;
    std::map<ll, std::map<ll, ll>> as;
    ll A = 0;
    for (int i = 0; i < M; i++) {
        ll a, b;
        std::cin >> a >> b;
        if (b - a - 1 < N) {
            as[b][b - a - 1]++;
        }
        A += a;
    }
    std::vector<ll> imos(N, M);
    imos[0] += A;
    for (const auto& p : as) {
        const ll B = p.first;
        for (const auto& A : p.second) {
            for (ll base = A.first; base < N; base += B) { imos[base] -= A.second * B; }
        }
    }
    for (int i = 1; i < N; i++) { imos[i] += imos[i - 1]; }
    for (int i = 0; i < N; i++) { std::cout << imos[i] << std::endl; }
    return 0;
}



Measured memory_bytes: 6272
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
using namespace std;

int main(){
  int n;
  while(cin>>n){
    int cnt=0;
    for(int i=0;i<=9;i++){
      for(int j=0;j<=9;j++){
	for(int k=0;k<=9;k++){
	  for(int l=0;l<=9;l++){
	    if(i+j+k+l==n)cnt++;
	  }
	}
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

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

long long kannondou(int n);

int main(void){
    int n;
    while(1){
        cin>>n;
        if(n==0) return 0;
        cout<<kannondou(n)/3650 +1<<endl;
    }
}

long long kannondou(int n){
    if(n==0) return 1;
    if(n==1) return 1;
    if(n==2) return 2;
    else return (kannondou(n-1)+kannondou(n-2)+kannondou(n-3));
}



Measured memory_bytes: 2992
#include<bits/stdc++.h>
using namespace std;
using int64 = int64_t;
#define int int64

signed main(){
  long double q,h,s,d;int n;cin>>q>>h>>s>>d>>n;
  int sol=min(q*4.0,min(h*2.0,s));
  cerr<<sol;
  int ans=min(n*sol,(int)((n/2)*d+(n%2)*sol));
cout<<ans;
}


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

int main(){
  
  int n,q;
  string s;
  cin>>n>>q>>s;
  int l[q],r[q];
  for(int i=0;i<q;i++) cin>>l[i]>>r[i];
  int S[n]={0},count=0;;
  for(int i=0;i<n-1;i++){
    if(s[i]=='A'&&s[i+1]=='C') count++;
    S[i+1]=count;
  }
  for(int i=0;i<q;i++){
    cout<<S[r[i]-1]-S[l[i]-1]<<endl;
  }
}

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

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	int R, S, P;
	cin >> R >> S >> P;
	string T;
	cin >> T;

	int score = 0;
	for (int i = 0; i < N; i++) {
		if (K <= i && T[i] == T[i - K]) {
			T[i] = '0';
			continue;
		}

		if (T[i] == 'r') {
			score += P;
		}
		if (T[i] == 's') {
			score += R;
		}
		if (T[i] == 'p') {
			score += S;
		}
	}

	cout << score << endl;
	return 0;
}


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

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int l = s.length();
		String arr[] = new String[l];
		
		String mozi;
		int j = 0;
		
		for (int i = 0; i < l; i++) {
			if (i != l - 1) {
				mozi = s.substring(i, i+1);
			} else {
				mozi = s.substring(l - 1);
			}
			
			if (!mozi.equals("B")) {
				arr[j] = mozi;
				j++;
			} else {
				if (j != 0){
					j--;
					arr[j] = "";
				}
			}
		}
		
		for (int i = 0; i < l; i++) {
			if (arr[i] != null){
			    System.out.print(arr[i]);
			}
		}
		System.out.println();
	}
}


Measured memory_bytes: 9300
n,l = list(map(int, input().split()))

x = list(range(1, n+1))
y = []
for i in x:
    y.append(l + i - 1)

z = [abs(i) for i in y]
zi = z.index(min(z))

ans = 0
for i,name in enumerate(y):
    if i == zi: continue
    ans += name

print(ans)

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

double func(double a){
    return a*a;
}
    
int main(){
    //インテグラル計算
    double d=1;
    long long int sum=0;
    while(cin >> d){
        for(double i=0;i<=(600-d);i+=d){
            sum += d * func(i);
        }
    cout << sum << endl;
    sum =0;
    }

    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int ans = 0;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if (500 * i + 100 * j + 50 * k == X) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}


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

using namespace std;
int a[1000000];
int main()
{
  int n,k,h=0;
  cin>>n>>k;
  for(int i=1;i<=n;i++)
	cin>>a[i];
  sort(a+1,a+1+n);
  for(int i=n;i>=n-k+1;i--)
	h+=a[i];
  cout<<h<<endl;
  return 0;
}

Measured memory_bytes: 256
input = require('fs').readFileSync('/dev/stdin', 'utf8');
arr=input.split("\n");
nq=arr[0].split(" ").map(Number);
str = arr[1];
a=[0,0];
cnt=0;
for(i=1;i<str.length;i++){
   if(str[i]=="C" && str[i-1]=="A")cnt++;
   a.push(cnt);
}
ans=[];
for(i=2;i<nq[1]+2;i++){
   lr=arr[i].split(" ");
   ans.push(a[lr[1]-0]-a[lr[0]-0]);
}
console.log(ans.join("\n"));

Measured memory_bytes: 34768
import itertools
import math
import collections

def func(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x
 
n = int(input())
s = int(math.sqrt(n))
nums = list(range(1,s))
arr = []
com = list(itertools.product(nums, repeat=3))
for i in range(len(com)):
    # print(com)
    ans = func(com[i][0],com[i][1],com[i][2])
    arr.append(ans)
 

c = collections.Counter(arr)
for i in range(n):
    print(c[i+1])

Measured memory_bytes: 118312
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int A, B;
  cin >> A >> B;
  int ans = -1;
  for (int i=1; i<100/0.08 + 2; i++){
    if (floor(i * 0.08) == A && floor(i * 0.1) == B){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    if op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(a) // int(b))
    else:
        break



Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
 
using namespace std;
 
int n, a[200001];


signed main()
{
	
 	FLASH
 
 	cin>>n;
	fr(i, 1, n+ 1) {cin>>a[i]; a[i] -= i;}
 	sort(a + 1, a + n + 1);
 	
 	int b = a[(n + 1)/2];
 
 	int ans = 0;
 	fr(i, 1, n + 1){
 		ans += abs(a[i] - b);
 	}
 
 	cout<<ans;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D)
    cout << "Left";
  if (A + B < C + D)
    cout << "Right";
  if (A + B == C + D)
    cout << "Balanced";
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

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

        for (int i=(int)Math.sqrt(N.doubleValue()); i>0; i--) {
            BigInteger d[] = N.divideAndRemainder(new BigInteger(Integer.toString(i)));
            if (d[1].compareTo(BigInteger.ZERO)==0) {
                System.out.println(d[0].add(N.divide(d[0])).subtract(new BigInteger("2")));
                break;
            }
        }
    }
}

Measured memory_bytes: 147760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	ll a[n], b[n];
	priority_queue<P> q;
	zep(i, 0, n){
		cin >> a[i];
	}
	bool f;
	zep(i, 0, n){
		cin >> b[i];
		if(b[i] > a[i]){
			q.push(P(b[i], i));
		}
		if(b[i] < a[i]){
			f = false;
		}
	}
	if(f){print(-1) return 0;}
	
	ll ans = 0;
	while(!q.empty()){
		ll at = q.top().second;
		q.pop();
		
		ll l = b[(at+n-1)%n];
		ll r = b[(at+1)%n];
		ll tmp = max((b[at]-max(a[at], max(l, r)))/(l+r), 1LL);
		b[at] -= tmp*(l+r);
		ans += tmp;
	
		if(b[at] < a[at]){
			ans = -1;
			break;
		}
		if(b[at] > a[at]){
			q.push(P(b[at], at));
		}
	}
	print(ans)
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

int x[3];
int c[3];
int t = 0;

int N, a;

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

  x[0] = x[1] = x[2] = -1;

  cin >> N;
  rep(i,N) {
    cin >> a;
    bool b = false;
    rep(j,t) {
      if (x[j]==a) {
        b = true;
        c[j]++;
        break;
      }
    }
    if (b) continue;
    if (t>=3) {
      cout << "No\n";
      return 0;
    }
    x[t] = a;
    c[t] = 1;
    ++t;
  }
  if (t==1) {
    if(x[0]==0) {
      cout << "Yes\n";
      return 0;
    }
  } else if (t==2) {
    if (x[0]==0 && c[0]*2==c[1] || x[1]==0 && c[1]*2==c[0]) {
      cout << "Yes\n";
      return 0;
    }
  } else if (t==3) {
    if (c[0]==c[1] && c[1]==c[2] && (x[0]^x[1])==x[2] && (x[1]^x[2])==x[0] && (x[2]^x[0])==x[1]) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  double n,d;
  cin>>n>>d;
  ll count=0;double ans;
  while(n--)
  {
    ll x,y;
    cin>>x>>y;
    ans= sqrt(pow(x,2)+pow(y,2));
    if(ans<=d){
      count++;}
  }
  cout<<count<<endl;
  
}

Measured memory_bytes: 3700
import sys
import math


class Walker:
    def __init__(self):
        self.x = 0.0
        self.y = 0.0
        self.deg = 0.0

    def walk(self, dis):
        dis = float(dis)
        self.x += dis * math.sin(math.radians(self.deg))
        self.y += dis * math.cos(math.radians(self.deg))

    def turn(self, deg):
        self.deg += float(deg)


walker = Walker()

#input_file = open(sys.argv[1], "r")

#for line in input_file:
for line in sys.stdin:
    d = map((lambda x: int(x)), line.split(','))
    dis = d[0]
    deg = d[1]
    if dis == 0 and deg == 0:
        break
    walker.walk(dis)
    walker.turn(deg)

print int(walker.x)
print int(walker.y)

Measured memory_bytes: 4460
n,x=map(int,input().split())
a=[int(i) for i in input().split()]
ans=0
i=0
if a[0]>x:
    ans+=a[0]-x
    a[0]-=ans
#b=[i[0]+i[1] for i in zip(a,a[1:])]+[x]
while i<len(a)-1:
    d=a[i]+a[i+1]-x
    if d>0:
        a[i+1]-=d
        ans+=d
        #print(i,d)
        
    i+=1
    
print(ans)

Measured memory_bytes: 63984
A = int(input())
B = list(map(int, input().split())) 

N = 0
C = 1

for num in B:
  if num == C:
    C += 1
    N += 1

ANSWER = 0

if N == 0:
  ANSWER = -1
else:
  ANSWER = A - N
  
print(ANSWER)


Measured memory_bytes: 24744
from itertools import product

N=int(input())
statement = [[] for i in range(N)]
for i in range(N):
  A=int(input())
  for j in range(A):
    x,y=map(int,input().split())
    x -= 1
    statement[i].append((x,y))

MAX=0
for p in product(range(2),repeat=N):
  flag=0
  for i in range(N):
    if p[i] == 1:
      for j in range(len(statement[i])):
        if statement[i][j][1]==1:
          x = statement[i][j][0]
          if p[x] != 1:
            flag=1
            break
        if statement[i][j][1]==0:
          x = statement[i][j][0]
          if p[x] == 1:
            flag=1
            break
    if flag==1:break
  if flag==1:continue
  if sum(p) > MAX:
    MAX=sum(p)

print(MAX)

Measured memory_bytes: 9268
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<int>in(n+1);
		rep(i,n)cin>>in[1+i];
		loop(i,1,1+n)in[i]+=in[i-1];
		int ma=-1e9;
		rep(i,n-m+1)ma=max(ma,in[i+m]-in[i]);
		cout<<ma<<endl;
	}
}

Measured memory_bytes: 1532
#include <iostream>

using namespace std;

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

    if(S<K) K = S;

    int x=K, y, z;
    if(S-x>K) {
        y = K;
    } else {
        y = S-x;
    }
    z = S - x - y;

    int i, j, k;
    int count=0;
    for(i=x; i>=0; i--){
        k = z;
        for(j=y; j>=0; j--) {
            if((j<=K) && (k<=K)) {
                count += 1;
            }
            k += 1;
        }
        y += 1;
    }

    cout << count << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,-1,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
int main(){
	//fopen();
	fastio;
	ll n,k;
	cin>>n>>k;ll v[n];
	rep(i,n)cin>>v[i];
	sort(v,v+n);
	ll l=-1e18-7,r=1e18+7;
	while(r-l>1)
	{
		ll m=(r+l)/2;
		ll c=0;
		//cout<<r<<endl;
		for(int i=0;i<n;i++)
		{
			int a=i,b=n;
			
			if(v[i]<0)
			{
				while(b-a>1)
				{
					int mid=(a+b)/2;
					if(v[i]*v[mid]<=m){b=mid;}
					else{a=mid;}

				}
				c+=n-b;
			}
			else
			{
				while(b-a>1)
				{
					int mid=(a+b)/2;
					if(v[i]*v[mid]<=m){a=mid;}
					else{b=mid;}
				}
				c+=a-i;
			}
		}
		if(c<k){l=m;}
		else{r=m;}
	}
	cout<<r;

}
 

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

int main(int argc, char *argv[]) {
    int n;
    cin >> n;
    int a;
    int c=0;
    for(int i=0;i<n;i++){
        cin >> a;
        if(i%2==0 && a%2==1) c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; ++i)

int main(){
 int n;
 cin>>n;
 int a,b,c,d;
 a=n/1000;
 b=(n/100)%10;
 c=(n/10)%10;
 d=n%10;
 string op1,op2,op3;
 op1="+-";
 op2="+-";
 op3="+-";
 
 bool can =false;
 int sum=0;
 for(int i=0;i<2;i++){
     for(int j=0;j<2;j++){
         for(int s=0;s<2;s++){
             if(op1[i]=='+') sum=a+b;
             else sum=a-b;
             if(op2[j]=='+') sum+=c;
             else sum-=c;
             if(op3[s]=='+') sum+=d;
             else sum-=d;
             if(sum==7) {
                 string s1,s2,s3;
                 s1=op1[i];
                 s2=op2[j];
                 s3=op3[s];
                 cout<<a<<s1<<b<<s2<<c<<s3<<d<<"=7"<<endl;
                 can =true;
                 break;
             }
             if(can) break;
         }
         if(can) break;
     }
     if(can) break;
 }
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int s = a+b+c;
  if(s==a*2||s==b*2||s==c*2)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, arr[200005], ans;
map<ll, ll> m;

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) {
		cin >> arr[i];
		m[i - arr[i]]++;
	}
	FOR(i, 1, n) ans += m[i + arr[i]];
	cout << ans;
}


Measured memory_bytes: 27896
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int T;
    long long n,k,a,b;
    cin>>T;
    while(T--)
    {
        cin>>n>>a>>k>>b;
        if(n<a) printf("No\n");
        else if(a>b) printf("No\n");
        else if(a==b)
        {
            n%=a;
            if(k>=n) printf("Yes\n");
            else printf("No\n");
        }
        else
        {
            long long gcd=__gcd(a,b);
            n%=gcd;
            long long xuq=a-(gcd-n);
            if(xuq<=k) printf("Yes\n");
            else printf("No\n");
        }
    }
}


Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>

using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//# define m 163577857
//# define MOD 163577857
# define pi acos(-1)
# define fi first
# define se second
#define REP(i,n) for (int i = 1; i <= n; i++)

const ll mod = 1000000007;
const int K = 2;
//typedef vector<vector<int> > matrix;
int add(int a, int b,int mod) {
    a%=mod;
    b%=mod;
	a += b;
	if (a >= mod) a -= mod;
	if(a<0)
    {
        a += mod;
        a %= mod;
    }
	return a;
}

int mul(ll a, int b,int mod) {
    a%=mod;
    b%=mod;
	a *= b;
	return a % mod;
}
int po(int a,int b,int mod)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return po(mul(a,a,mod),b/2,mod);
    return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
}


ll fact[1000003];
ll inv[1000003];

void fact0()
{
	int i,j;
	fact[0]=1;
	for(i=1;i<=200000;i++)
	{
		fact[i]=i*fact[i-1]%mod;
	}
	inv[0]=1;
	inv[1]=1;
	ll p=mod;
	for (i=2; i<=200000; i++)
		inv[i] = (p - (p/i) * inv[p%i] % p) % p;

	for(i=2;i<=200000;i++)
	{
		inv[i]*=inv[i-1];
		inv[i]%=mod;
	}
}
set<int> v[100005];
signed main()
{
    gok
   //fact0();
  int n,a,b,c;
  cin>>n>>a>>b>>c;
  map<string,int> mp;
  map<char,int> mp1;
  mp1['A'] = a;
  mp1['B'] = b;
  mp1['C'] = c;
  mp["AC"] = 0;
  mp["AB"] = 0;
  mp["BC"] = 0;
  vector<char> vv;
  string s[n];
  for(int i=0;i<n;i++)
  {

      cin>>s[i];

      //mp[s]++;
  }
  bool ch=true;
  for(int i=0;i<n;i++)
  {
      if(mp1[s[i][0]]>mp1[s[i][1]])
      {
          mp1[s[i][0]]--;
          mp1[s[i][1]]++;
          vv.push_back(s[i][1]);
      }
      else if(mp1[s[i][0]]<mp1[s[i][1]])
      {
          mp1[s[i][0]]++;
          mp1[s[i][1]]--;
          vv.push_back(s[i][0]);
      }
      else if(mp1[s[i][0]]==mp1[s[i][1]])
      {
          if(mp1[s[i][0]]==0){
            ch=false;
            break;
          }

          if(i+1!=n&&(s[i][0]==s[i+1][1] || s[i][0]==s[i+1][0]))
          {
              vv.push_back(s[i][0]);
              mp1[s[i][0]]++;
              mp1[s[i][1]]--;
          }
          else
          {
             vv.push_back(s[i][1]);
              mp1[s[i][0]]--;
              mp1[s[i][1]]++;
          }
      }
  }
  if(!ch)
    cout<<"No";
  else
  {
      cout<<"Yes"<<endl;
      for(int i=0;i<vv.size();i++)
        cout<<vv[i]<<endl;
  }














    return 0;
    }


Measured memory_bytes: 11600
/*There's a possibility*/
#define dbg(...) ; 
#define db(...) ; 
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define tst cout<<'*';
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mod 1000000007
using namespace std;

ll n,ar[22][22],dp[22][1<<22];

ll fun(int i, ll mask)
{
    // dbg(i,mask);
    if(dp[i][mask]!=-1)
        return dp[i][mask];
    if(i==n)
    {
        if(mask==((1<<n)-1))
            return dp[i][mask]=1; 
        else return dp[i][mask]=0;   
    }
    
    ll ans=0,j;
    f(j,0,n)
    {
        if(ar[i][j+1] and !(mask&(1<<j)))
            ans=(ans+fun(i+1,mask|(1<<j)))%mod;
    }
    return dp[i][mask]=ans;
}

int main()
{
    fast;
    int i,j;
    cin>>n;
    f(i,0,n)
        f(j,1,n+1)
            cin>>ar[i][j];
    memset(dp,-1,sizeof(dp));
    cout<<fun(0,0);
    // db(dp,0,n,0,3);
}

Measured memory_bytes: 724504
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string s;cin>>s;
  cout<<s[0]<<(s.size()-2)<<s[s.size()-1]<<endl;
  return 0;
}

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a, b, c, d;
   cin >> a >> b >> c >> d;
   int n, m;

   n = a - c;
   n = abs(n);
   if (n <= d)
      cout << "Yes" << '\n';
   else
   {
      a = b - a;
      c = c - b;
      a = abs(a);
      c = abs(c);
      if (a <= d && c <= d)
         cout << "Yes" << '\n';
      else
         cout << "No" << '\n';
   }
}


Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn          printf("\n")
#define nl          cout<<'\n'
#define sf(N)       scanf("%lld",&N)
#define pf(N)       printf("%lld",N)
#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define Sec     second
#define ALL(V)  V.begin(),V.end()
#define Dup erase(unique(V.begin(),V.end()),V.end())

#define Inf     1000000000000000
#define mod     1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

lli Count[26];

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    string s;
    cin>>s;
    
    lli N=s.length(),i;
    
    rep(i,0,N)
    {
        Count[s[i]-'a']++;
    }
    
    rep(i,0,26)
    {
        if(Count[i]>=2)
        {
            cout<<"no";
            exit(0);
        }
    }
    
    cout<<"yes";
    
    
    









 return 0;
}


Measured memory_bytes: 256
#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() {
  int n;
  cin >> n;
  while (n >= 10) {
    n = n % 10;
  }
  if (n == 3) {
    cout << "bon" << endl;
  } else if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[200100];
  int d = n/2;
  int c;
  if(n%2==1){
    c = 1;
  }else{
    c = -1;
  }
  while(0<=d && d<n){
    cin >> a[d];
    d += c;
    if(c>0) c++;
    else c--;
    c = -c;
  }
  rep(i,n-1){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
  return 0;
}


Measured memory_bytes: 2944
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  string s;
  cin >> s;
  if(s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
$s = <>;
@ary = ( $s =~ /(\D)/g );
$flg = 1;
for($i=0;$i<$#ary;$i++){
	if($i%2==0){
    	if($ary[$i] eq "L"){
        	$flg = 0;
        }
    }else{
    	if($ary[$i] eq "R"){
        	$flg = 0;
        }
    }
}
if($flg == 1){
	print "Yes";
} else {
	print "No";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a[25],b[25],c[25];
  cin>>n;
  for(int i=0;i<n;++i)cin>>a[i];
  for(int i=0;i<n;++i)cin>>b[i];
  for(int i=0;i<n;++i)cin>>c[i];
  int res=0;
  for(int i=0;i<n;++i){
    res+=b[a[i]-1];
    if(a[i]+1==a[i+1])res+=c[a[i]-1];
  }
  cout<<res;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int n,m;
vector<P> vec;
vector<int> rad;
P s,t;
ll sq(ll x)
{
    return x*x;
}
bool in(int x,P a)
{
    return sq(a.fi-vec[x].fi)+sq(a.sec-vec[x].sec)<rad[x]*rad[x];
}
bool check()
{
    for(int i=0;i<n;i++)
    {
        bool in1,in2;
        in1=in(i,s);in2=in(i,t);
        if(in1!=in2)return false;
        if(in1&&in2)continue;
        ll a=s.fi,b=s.sec,c=t.fi,d=t.sec,p=vec[i].fi,q=vec[i].sec;
        if(a>c)
        {
            swap(a,c);swap(b,d);
        }
        if(a==c)
        {
            if(min(b,d)<=vec[i].sec&&vec[i].sec<=max(b,d)&&abs(vec[i].fi-a)<=rad[i])
            {
                return false;
            }
            else continue;
        }
        ll A=sq(d-b)+sq(c-a);
        ll B=(b*c-a*d)*(d-b)-p*sq(c-a)-(c-a)*(d-b)*q;
        ll C=p*p*sq(c-a)+sq(b*c-a*d-q*c+q*a)-sq(rad[i])*sq(c-a);
        //cout  << "At circle No." << i+1 << ' '<< A << ' ' << B << ' ' << C  << ' ' << B*B-A*C<< endl;
        if(B*B-A*C<0)continue;
        else if(B*B-A*C==0)
        {
            if(a<=(-B/A)&&(-B/A)<=c)return false;
            else continue;
        }
        else
        {
            double ans1=(-B+sqrt(B*B-A*C))/A;
            double ans2=(-B-sqrt(B*B-A*C))/A;
            if(ans1>=a&&ans2<=c)return false;
            else continue;
        }
    }
    return true;
}
int main()
{
    while(1)
    {
        vec.clear();
        rad.clear();
        scanf("%d",&n);
        if(n==0)break;
        for(int i=0;i<n;i++)
        {
            P k;
            int r;
            scanf("%d %d %d",&k.fi,&k.sec,&r);
            vec.pb(k);
            rad.pb(r);
        }
        scanf("%d",&m);
        for(int i=0;i<m;i++)
        {
            scanf("%d %d %d %d",&t.fi,&t.sec,&s.fi,&s.sec);
            if(check())puts("Danger");
            else puts("Safe");
        }
    }
    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int base = 1e9 + 7;

int main() {
  int n; cin >> n;
  string s; cin >> s;
  
  vector<int> dif(2*n+1, 0);
  dif[0] = (s[0] == 'B' ? 1 : 0);
  dif[2*n] = (s[2*n-1] == 'B' ? 1 : 0);
  for (int i = 1; i < 2*n; ++i)
    if (s[i] != s[i-1]) dif[i] = 1;
  
  ll total = 1;
  int cur = 0, cnt = 0;
  for (int d: dif) {
    if (cur == 0) {
      if (d == 1) ++cnt;
      else cur = 1;
    }
    else {
      total = total * cnt % base;
      if (d == 1) --cnt;
      else cur = 0;
    }
  }
  
  if (cnt == 0) while (n) total = total * n-- % base;
  else total = 0;
  cout << total << endl;
}

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

using namespace std;

bool isPal(string s)
{
  int i=0,r=s.length()-1;
  while(i<r){
    if(s[i]!=s[r])return 0;
    i++;r--;
  }
  return 1;
}

int main()
{
  string s;
  cin>>s;
  if(isPal(s) && isPal(s.substr(0,s.length()/2)) && isPal(s.substr(s.length()/2+1)))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, aa, bb, ans = 0;
	cin >> nn >> aa >> bb;
	vector<int64> xx(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> xx[ii];
	}
	for(int64 ii = 1;ii < nn;ii++)
	{
		ans += min(bb, aa * (xx[ii] - xx[ii - 1]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4032
S=str(input())
if S=='SUN':
  print(7)
elif S=='MON':
  print(6)
elif S=='TUE':
  print(5)
elif S=='WED':
  print(4)
elif S=='THU':
  print(3)
elif S=='FRI':
  print(2)
elif S=='SAT':
  print(1)

Measured memory_bytes: 3060
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

alias A = Tuple!(int, "no", string, "name", int, "value");

void main() {
    int n; scan(n);
    Tuple!(string, int, int)[] a;
    foreach (i; 0..n) {
        string name; int x; scan(name, x);
        a ~= tuple(name, -x, i + 1);
    }
    a.sort();
    foreach (e; a) writeln(e[2]);
}


Measured memory_bytes: 256
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
cs = [a[0]]
for i in range(1,N):
    cs.append(cs[i-1]+a[i])
if cs[0]>x: print(0)
elif cs[N-1]==x: print(N)
elif cs[N-1]<x: print(N-1)
else:
    for i in range(1,N):
        if cs[i-1]<=x<cs[i]: print(i)


Measured memory_bytes: 3064
def solve():
    N = int(input())
    ab = [[] for _ in range(N)]
    cd = ab[:]
    for i in range(N):
        ab[i] = list(map(int, input().split()))
    for i in range(N):
        cd[i] = list(map(int, input().split()))
    
    ab.sort(key=lambda x: -x[0])
    cd.sort(key=lambda x: (x[0], -x[1]))
    
    ans = 0
    used = [0 for _ in range(N)]
    for i in range(N):
        use, d_min = -1, 201
        for j in range(N):
            if ab[j][0] < cd[i][0] and ab[j][1] < cd[i][1]:
                if cd[i][1] - ab[j][1] < d_min:
                    if used[j] == 0:
                        use = j
                        d_min = cd[i][1] - ab[j][1]
        if use != -1:
            used[use] = 1
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


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

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

    string s;
    cin >> s;

    if (s <= "2019/04/30") {
        cout << "Heisei" << '\n';
    } else {
        cout << "TBD"  << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int w,h,x,y;
    cin>>w>>h>>x>>y;
    double m=(double)w/2*h;
    printf("%.12lf ",m);
    if(x*2==w&&y*2==h)
    {
        cout<<"1"<<endl;
    }
    else puts("0");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

const int INF = 1LL << 60;
const int MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    int b[n - 1];
    rep(n - 1, i) {
        cin >> b[i];
    }
    if (n == 2) {
        cout << b[0] * 2 << endl;
        return 0;
    }
    int sum = b[0];
    rep2(1, n - 1, i) {
        sum += min(b[i - 1], b[i]);
    }
    sum += b[n - 2];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var N = intShift();
  var M = intShift();
  var X = intShift();
  
  var right = 0;
  var left = 0;
  for(var i = 0; i < M; i++){
  	var a = intShift();
    if(a < X){
    	left++;
    }else{
    	right++;
    }
  }
  return ~~Math.min(left,right);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
5 3 3
1 2 4
`);

Measured memory_bytes: 11468
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, inf = 2e9;

int t, a, b, c, d;
ll n;
map<ll, ll> dis;
priority_queue<pll, vector<pll>, greater<pll> > que;

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

inline void trans(ll x, ll w) {
	if (dis.find(x) == dis.end() || dis[x] > w)
		que.emplace(dis[x] = w, x);
	return;
}

int main() {
	read(t);
	while (t--) {
		dis.clear();
		while (que.size()) que.pop();
		read(n), read(a), read(b), read(c), read(d);
		que.emplace(dis[n] = 0, n);
		ll ans = 1e18;
		while (que.size()) {
			pll now = que.top();
			que.pop();
			if (now.first > ans) break;
			if (now.second <= inf) ans = min(ans, now.second * d + now.first);
			for (R int i = -2; i <= 2; ++i) {
				ll to = now.second + i;
				if (abs(i) <= 1 && ~to & 1)
					trans(to >> 1, now.first + abs(i) * d + a);
				if (abs(i) <= 1 && to % 3 == 0)
					trans(to / 3, now.first + abs(i) * d + b);
				if (to % 5 == 0)
					trans(to / 5, now.first + abs(i) * d + c);
			}
		}
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 4292
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

class dice {
    private:
    int surf[6];
    public:
    dice(int a[6]);
    void move_N();
    void move_S();
    void move_E();
    void move_W();
    void show_top();
    bool issame(int b[6],char str[]);
    void move(char str);
};

dice::dice(int a[6]){
    for(int i = 0; i < 6; i++){
        surf[i] = a[i];
    }
}

void dice::move_S(){
    int buf[6];
    for(int i = 0; i < 6; i++){
        buf[i] = surf[i];
    }
    surf[0] = buf[4];
    surf[1] = buf[0];
    surf[4] = buf[5];
    surf[5] = buf[1];

}

void dice::move_N(){
    int buf[6];
    for(int i = 0; i < 6; i++){
        buf[i] = surf[i];
    }
    surf[0] = buf[1];
    surf[1] = buf[5];
    surf[4] = buf[0];
    surf[5] = buf[4];

}

void dice::move_W(){
    int buf[6];
    for(int i = 0; i < 6; i++){
        buf[i] = surf[i];
    }
    surf[0] = buf[2];
    surf[2] = buf[5];
    surf[3] = buf[0];
    surf[5] = buf[3];

}

void dice::move_E(){
    int buf[6];
    for(int i = 0; i < 6; i++){
        buf[i] = surf[i];
    }
    surf[0] = buf[3];
    surf[2] = buf[0];
    surf[3] = buf[5];
    surf[5] = buf[2];

}

void dice::show_top(){
    cout << surf[0] << endl;
}

bool dice::issame(int b[6],char str[25]){
    int flag = 0;
    for(int i = 0; i < 25; i++){
        move(str[i]);
        for(int i = 0; i < 6; i++){
            if(surf[i] == b[i]){
                flag++;
            }
        }
        if(flag == 6) return true;
        flag = 0;
    }
    return false;
}

void dice::move(char str){
    switch(str){
        case 'N':
            move_N();
        break;
        case 'W':
            move_W();

        break;
        case 'E':
            move_E();
        break;
        case 'S':
            move_S();
        break;
        default:
        break;
    }
}
int main(){
    int a[6],b[6];
    bool ans = false;
    char dir[] = "NNNNWNNNWNNNENNNENNNWNNN";
    int flag = 0;
    for(int i = 0; i < 6; i++){
        cin >> a[i];
    }
    
    for(int i = 0; i < 6; i++){
        cin >> b[i];
    }

    dice A(a);
    ans = A.issame(b,dir);
    if(ans ==true) cout << "Yes" << endl;
    if(ans == false) cout << "No" << endl;




}





Measured memory_bytes: 3100
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, t;
    cin >> n >> t;
    vi tmp;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if(b <= t) tmp.pb(a);
    }
    sort(all(tmp));
    if(tmp.size()) cout << tmp[0] << endl;
    else cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 256