akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}
bool solve() {
  int n; double L; cin >> n >> L;
  if(n == 0) return false;
  int day = 86400;
  vector<int> s(n), t(n);
  vector<double> u(n);
  for(int i=0;i<(n);++i) {
    cin >> s[i] >> t[i] >> u[i];
  }
  vi sch(day);
  for(int i=0;i<(n);++i) {
    for(int j=(s[i]);j<(t[i]);++j) {
      sch[j] = u[i];
    }
  }
  double l = 0, r = 1000000;
  for(int i=0;i<(100);++i) {
    double mid = (l + r) / 2;
    bool ok = true;
    double now = L;
    for(int j=0;j<(day);++j) {
      now -= sch[j];
      now += mid;
      chmin(now, L);
      if(now < 0) {
        ok = false;
      }
    }
    double tmp = now;
    for(int j=0;j<(day);++j) {
      now -= sch[j];
      now += mid;
      chmin(now, L);
      if(now < 0) {
        ok = false;
      }
    }
    if(now < tmp) ok = false;
    if(ok) r = mid;
    else l = mid;
  }
  cout << l << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    if(!solve()) {
      break;
    }
  }
}



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

typedef vector<int> vi;
typedef pair<int, int> pi;

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

#define pb push_back
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int N, L;
    cin >> N >> L;

    int sum = 0;
    int m = 100000;
    int j = 1;
    REP2(i, 1, N) {
        int aji = L + i - 1;
        sum += aji;
        if (m > abs(aji)) {
            m = abs(aji);
            j = aji;
        }
    }
    cout << sum - j << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
 
    public void solve(){
		Scanner sc = new Scanner(System.in);
       int a, x;
       	   a = sc.nextInt();
		   x = a * a * a;
		  System.out.print(x);
		  System.out.println();
    }
		   
	   
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17156
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int cnt, m = 0;

void insertionSort(int A[], int n, int g)
{
  for(int i = g, v, j; i < n; i++){
    v = A[i];
    j = i - g;
    while(j >= 0 && A[j] > v){
      A[j + g] = A[j];
      j -= g;
      if(cnt < ceil(pow((double)n, 1.5)) - 1)
	cnt++;
      A[j + g] = v;
    }
  }
}

void shellSort(int A[], int G[], int n)
{
  cnt = 0;
  for(int i = 0; i < m; i++)
    insertionSort(A, n, G[i]);
}

int main()
{
  int n, c = 0;
  cin >> n;
  int A[n];
  for(int i = 0; i < n; i++)
    cin >> A[i];
  for(int i = 0; m < n; i++, c++)
    m = m * 3 + 1;
  m = c - 1;
  m = (m < 1) ? 1 : m;
  int G[m];
  for(int i = 0; i < m; i++)
    if(i)
      G[i] = G[i - 1] * 3 + 1;
    else 
      G[i] = 1;
  reverse(G, G + m);
  shellSort(A, G, n);
  cout << m << endl;
  for(int i = 0; i < m; i++)
    if(i)
      cout << " " << G[i];
    else 
      cout << G[i];
  cout << endl << cnt << endl;
  for(int i = 0; i < n; i++)
    cout <<  A[i] << endl;
}

Measured memory_bytes: 5072
import math

d, g = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(d)]

ans = float('inf')
for i in range(2 ** d):
    sum = 0
    count = 0
    s = set(k for k in range(1, d + 1))
    for j in range(d):
        if (i >> j) & 1 == 1:
            sum += l[j][0] * (j + 1) * 100 + l[j][1]
            count += l[j][0]
            s.discard(j + 1)
    if sum < g:
        t = max(s)
        n = min(l[t - 1][0] - 1, math.ceil((g - sum) / (t * 100)))
        count += n
        sum += n * t * 100
    if sum >= g:
        ans = min(ans, count)
print(ans)


Measured memory_bytes: 74744
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
	int n, m;
	cin >> n >> m;
	int a, b;
	UnionFind uf(n);
	rep(i,m) {
		cin >> a >> b;
		uf.merge(a-1,b-1);
	}
	set<ll> s;
	rep(i,n) {
		s.insert(uf.root(i));
	}
	cout << s.size() - 1 << endl;
	return 0;
}

Measured memory_bytes: 8380
#include<stdio.h>
#include<math.h>
#define pai 3.14159265358979323846
int main(){
int angle=90,m,n;
double x=0,y=0;
while(scanf("%d,%d",&m,&n),m||n){
x+=m*cos(pai*angle/180);
y+=m*sin(pai*angle/180);
angle=(angle-n)%360;
}
printf("%d\n%d\n",(int)x,(int)y);
return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        long tmp = c - a - b;
        if (tmp > 0 && 4 * a * b < tmp * tmp)
            System.out.println("Yes");
        else
            System.out.println("No");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	int n;
	cin >> n;
	set<string> s;
	string c;
	rep(i, n) {
		cin >> c;
		s.insert(c);
	}

	cout << s.size() << "\n";

	return 0;
}



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

ans = 2*max(X,Y)*C
ans = min(ans,A*X+B*Y)
if X>=Y:ans = min(ans,2*Y*C+(X-Y)*A)
else:ans = min(ans,2*X*C+(Y-X)*B)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; //
typedef pair<db,db> pd; //
//
typedef vector<int> vi; 
typedef vector<ll> vl; //
typedef vector<db> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi;
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
 
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back()
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
 
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; //
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); //
//
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { //
	return a < b ? a = b, 1 : 0; } //
constexpr int pct(int x) { return __builtin_popcount(x); } //
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) //
constexpr int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 //
// IGNORE
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}
template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// IGNORE
//
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int X;
	cin >> X;
	X -= 400;
	X /= 200;
	cout << 8 - X << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e18
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N 100001

using namespace std;

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

int main() {
  ll N, a[3 * MAX_N];
  cin >> N;
  for (ll i = 0; i < 3 * N; i++) {
    cin >> a[i];
  }

  ll left[MAX_N]; // left[i]: a[i+N]より手前のN個の総和のMAX
  priority_queue<ll, vector<ll>, greater<ll> > l_que;
  ll sum = 0;

  for (ll i = 0; i < N; i++) {
    sum += a[i];
    l_que.push(a[i]);
  }
  left[0] = sum;
  for (ll i = N; i < 2 * N; i++) {
    if (l_que.top() < a[i]) {
      sum -= l_que.top();
      sum += a[i];
      l_que.pop();
      l_que.push(a[i]);
    }
    left[i-N+1] = sum;
  }

  ll right[MAX_N]; // right[i]: a[i+N]以降のN個の総和のmin
  priority_queue<ll> r_que;
  sum = 0;

  for (ll i = 3 * N - 1; i >= 2 * N; i--) {
    sum += a[i];
    r_que.push(a[i]);
  }
  right[N] = sum;
  for (ll i = 2 * N - 1; i >= N; i--) {
    if (r_que.top() > a[i]) {
      sum -= r_que.top();
      sum += a[i];
      r_que.pop();
      r_que.push(a[i]);
    }
    right[i-N] = sum;
  }


  ll ans = -INF;
  for (ll i = 0; i <= N; i++) {
    ans = max(left[i] - right[i], ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6516
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, N) for(int i; i<N; i++)

uint32_t max_2n(uint32_t x)
{
    uint32_t r=0;
    for(r=0; (x&1)==0; x/=2, r++);
    return r;
}

int solver(vector<int>& inputz)
{
    int result=0;
    for(int x : inputz)
        result+=max_2n(x);
    return result;
}

int main(void)
{
    // if you dont use printf
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);

    int N=0; cin>>N;
    vector<int> inputz;
    REP(i, N)
    {
        int temp=0;
        cin>>temp;
        inputz.push_back(temp);
    }

    cout<<solver(inputz)<<endl;

    return 0;
}


Measured memory_bytes: 384
<?php
    for($i = 0; $i < 3; $i++){
        $bingo[] = explode(" ", trim(fgets(STDIN)));
    }
    $n = trim(fgets(STDIN));
    for($i = 0; $i < $n; $i++){
        $temp = trim(fgets(STDIN));
        for($j = 0; $j < 3; $j++){
            for($k = 0; $k < 3; $k++){
                if($temp == $bingo[$j][$k]){
                    $bingo[$j][$k] = "x";
                }
            }
        }
    }
    $flg = FALSE;
    for($i = 0; $i < 3; $i++){
        $cnt = 0;
        for($j = 0; $j < 3; $j++){
            if($bingo[$i][$j] == "x") $cnt++;
        }
        if($cnt == 3){
            $flg = TRUE;
        }
    }
    for($i = 0; $i < 3; $i++){
        $cnt = 0;
        for($j = 0; $j < 3; $j++){
            if($bingo[$j][$i] == "x") $cnt++;
        }
        if($cnt == 3){
            $flg = TRUE;
        }
    }
    $cnt = 0;
    for($i = 0; $i < 3; $i++){
        if($bingo[$i][$i] == "x") $cnt++;
    }
    if($cnt == 3) $flg = TRUE;
    $cnt = 0;
    for($i = 0; $i < 3; $i++){
        if($bingo[$i][2 - $i] == "x") $cnt++;
    }
    if($cnt == 3) $flg = TRUE;
    echo $flg ? "Yes" : "No";
?>

Measured memory_bytes: 4604
/*************************************************************************
	> File Name: abc121_a.cpp
	> Author:lynko 
	> Mail: 
	> Created Time: 2019年03月09日 星期六 20时03分29秒
 ************************************************************************/

#include<bits/stdc++.h>
using namespace std;
int main()
{int h,w;
      int H,W;
 cin>>H>>W;
 cin>>h>>w;
    cout<<(H-h)*(W-w)<<endl;
}


Measured memory_bytes: 256
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    N, K = map(int, input().split())
    cnt = 0
    while N!=0:
        N //= K
        cnt += 1
    print(cnt)

Measured memory_bytes: 10584
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 1e18;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


struct SegmentTree {
private:
  int N, uni = -1;vector<int>  node;
public:
  SegmentTree(){}
  int look(int x, int y){
    return max(x, y);
  }
  void init(vector<int> v){
    int sz = v.size();
    N = 1;while(N < sz)N *= 2;
    node.resize(2*N-1, uni);

    rep(i,sz)node[i+N-1] = v[i];//最下段に値を入れる
    for(int i=N-2;i >= 0;i--)node[i] = look(node[2*i+1], node[2*i+2]);//上げていく
  }
  void update(int x, int val){
    x += (N-1);//最下段へ
    node[x] = val;
    while(x > 0){//上げていく
      x = (x-1)/2;
      node[x] = look(node[2*x+1], node[2*x+2]);
    }
  }
  int get(int a, int b, int k=0, int l=0, int r=-1){
    if(r < 0)r = N;
    if(r <= a || b <= l)return uni;
    if(a <= l && r <= b)return node[k];
    int vl = get(a, b, 2*k+1, l, (l+r)/2);
    int vr = get(a, b, 2*k+2, (l+r)/2, r);
    return look(vl, vr);
  }
};
struct SegmentTree2 {
private:
  int N, uni = INF;vector<int>  node;
public:
  SegmentTree2(){}
  int look(int x, int y){
    return min(x, y);
  }
  void init(vector<int> v){
    int sz = v.size();
    N = 1;while(N < sz)N *= 2;
    node.resize(2*N-1, uni);

    rep(i,sz)node[i+N-1] = v[i];//最下段に値を入れる
    for(int i=N-2;i >= 0;i--)node[i] = look(node[2*i+1], node[2*i+2]);//上げていく
  }
  void update(int x, int val){
    x += (N-1);//最下段へ
    node[x] = val;
    while(x > 0){//上げていく
      x = (x-1)/2;
      node[x] = look(node[2*x+1], node[2*x+2]);
    }
  }
  int get(int a, int b, int k=0, int l=0, int r=-1){
    if(r < 0)r = N;
    if(r <= a || b <= l)return uni;
    if(a <= l && r <= b)return node[k];
    int vl = get(a, b, 2*k+1, l, (l+r)/2);
    int vr = get(a, b, 2*k+2, (l+r)/2, r);
    return look(vl, vr);
  }
};


int n,k;vector<int> a;bool b[210000];
SegmentTree segmax;SegmentTree2 segmin; 
signed main(){
  cin>>n>>k;a.resize(n);rep(i,n)cin>>a[i];
  segmax.init(a);segmin.init(a);
  int l = 0, r = 1, ans = 0;
  while(r < n){
    while(a[r-1] < a[r]){
      r++;
      if(r-l >= k){
        b[r] = true;
        ans = 1;
      }
    }
    l = r;r++;
  }
  repd(i,k,n+1){
    if(!b[i]){
      if(i == k)ans++;
      else if(!(a[i-k-1] == segmin.get(i-k-1,i-1) && segmax.get(i-k,i) == a[i-1]))ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 11748
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
vector<ll>v;
void Divisor(ll n)
{
    for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i==0)
        {
            if (n/i == i)
                v.push_back(i);
            else
            {
                v.push_back(i);
              v.push_back(n/i);
            }
        }
    }
}

/* Driver program to test above function */
int main()
{
    v.clear();
    ll N,sum=0;
    sl(N);
    Divisor(N);
    for(ll i=0;i<v.size();i++){
        //cout<<v[i];
            ll value=v[i]-1;
            if(value==0)continue;
        if(N%value==N/value)sum+=value;
    }
    pl(sum);
    return 0;
}


Measured memory_bytes: 384
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

score = B[A[0]-1]

for i in range(1,n):
    score += B[A[i]-1]
    if A[i] == A[i-1]+1:
        score += C[A[i-1]-1]
    else:
        continue
print(score)

Measured memory_bytes: 9104
n, m = (int(x) for x in input().split())
ps = []
for _ in range(m):
    p, s = (x for x in input().split())
    ps.append([int(p), s])
ans = [0] * n
pen = 0
tmp = [0] * n
for p, s in ps:
    if s == 'WA' and ans[p - 1] == 0:
        tmp[p - 1] += 1
        continue
    else:
        ans[p - 1] = 1
        pen += tmp[p - 1]
        tmp[p - 1] = 0 
print(sum(ans), pen)

Measured memory_bytes: 23488
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<math.h>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int n,cnt=0,len,flag=0;
	string s,str;
	cin >> s >> n;
	len=s.size();
	REP(i,n){
		cin >> str;
		str=str+str;
		for(int j=0;j<str.size();j++){
			if(str.substr(j,len)==s)
				flag=1;
		}
		if(flag==1)
			cnt++;
		str.clear();
		flag=0;
	}
	cout << cnt << endl;
	return 0;
}		

Measured memory_bytes: 1212
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            var c = cin.nextInt();

            var ans = a == b + c || b == a + c || c == a + b;
            Console.WriteLine(ans ? "Yes":"No");
        }
    }    

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
#define er erase
#define in insert
#define pi pair <int, int>
# define sz(x) (int)((x).size())
#define inf 1000000000
const ll mod = 1000000007;
const int N = 2e5 + 11;
int frec[N],sum,pen,good;

int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);
	int n,k,m;
	cin>>n>>m;
	forn(i,1,m){
		int x; string y;
		cin>>x>>y;
		if(y=="AC"){
			if(frec[x]>0)pen+=frec[x];
			if(frec[x]!=-1)good++;
			frec[x]=-1;
		}else if(frec[x]!=-1)frec[x]++;
	}
	cout<<good<<" "<<pen<<'\n';
return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int a,b;cin >> a >> b;
    if(a>=13) cout << b << endl;
    else if(6<=a) cout << b/2 << endl;
    else cout << 0 << endl;
    return 0;
}


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

ll N;
vector<ll> a, b;

int main() {
    cin >> N; a.resize(N+1); b.resize(N);
    for (int i = 0; i < N+1; i++) scanf("%Ld", &a[i]);
    for (int i = 0; i < N; i++) scanf("%Ld", &b[i]);
    ll count = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] >= b[i]) {
            count += b[i];
        }else{
            count += a[i];
            b[i] -= a[i];
            count += min(a[i+1], b[i]);
            a[i+1] -= min(a[i+1], b[i]);
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */


#define MAXN (1 << 10)

set<int> a[MAXN];

int main() {
	cout << fixed << setprecision(12);	
	int n;
	cin >> n;
	for (ll i = 2; i <= 2 * n; i++) {
		if ((i * (i - 1)) / 2 == n) {
			int cur = 1;
			for (int ii = 0; ii < i; ii++) {
				for (int jj = 0; jj < ii; jj++) {
					a[ii].insert(cur);
					a[jj].insert(cur);
					cur++;
				}
			}
			cout << "Yes" << endl;
			cout << i << endl;
			for (int j = 0; j < i; j++) {
				cout << a[j].size() << " ";
				for (auto & e: a[j]) {
					cout << e << " ";
				}
				cout << endl;
			}
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



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


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

  vector<int64_t> lucas (n+1,0);
    lucas[0]=2;
  	lucas[1]=1;
  if(n==0)	cout << lucas[0];
  else if(n==1) cout << lucas[1];
  else if(n==2) cout <<lucas[0] +lucas[1];
  else{
    for(int i=2;i<=n;i++){
    lucas[i]=lucas[i-1]+lucas[i-2];
    }
  cout << lucas[n] <<endl;
  }
}

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

int main(){
	int n,x;
	cin>>n>>x;
	int l[n+1];
	for(int i=1;i<=n;i++){
		cin>>l[i];
	}
	int h=0,s=1;
	for(int i=1;i<=n;i++){
		h+=l[i];
		if(h>x) break;
		s++;
	} 
	cout<<s;
	return 0;
}


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

int main(){
 int a, b;
 cin >> a >> b;
 
 if ( a == b ){
 cout << "a == b" << endl;
} else if ( a < b ){
  cout << "a < b" << endl;
} else {
  cout << "a > b" << endl;
}
 return 0;
}

Measured memory_bytes: 3076
H,W,M = map(int, input().split())
width = [0]*W
height = [0]*H

st = set()
for i in range(M):
  y, x = map(int, input().split())
  st.add((x - 1,y - 1))
  width[x-1] += 1
  height[y-1] += 1

maxW = max(width)
maxH = max(height)

indexW = [i for i, v in enumerate(width) if v == maxW]
indexH = [i for i, v in enumerate(height) if v == maxH]

ans = maxW + maxH 

#それぞれ列と行の最大値の中から適当に１つずつ列と行を選ぶ
tmpX = indexW[0]
tmpY = indexH[0]

#HeightとWidthのそれぞれの最大値の点(x, y)に爆弾がない場合があるかどうか
flag = 0

#print(f"indexH {indexH}")
#print(f"indexW {indexW}")

#Heightの最大値と、widthのそれぞれを全探索
for x in indexW:
  y = tmpY
  if not (x, y) in st:
    flag = 1
    break


for y in indexH:
  x = tmpX
  if not (x, y) in st:
    flag = 1
    break

if flag == 1:
  print(ans)
else:
  print(ans - 1)


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n + 1);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    sort(h.rbegin(), h.rend());
    ll sum = 0;
    for (int i = k; i < n; i++)
    {
        sum += h[i];
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll n,m;
    cin>>n>>m;
    string s[n];
    vector<pair<ll,ll>> q;
    vector<vector<ll>> a(n,vector<ll>(m,-1));
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i][j]=='#') {q.emplace_back(i,j);a[i][j]=0;}
        }
    }
    ll ma=0;
    for(int i=0;i<q.size();i++){
        ll x,y;
        x=q[i].first;y=q[i].second;
        for(int dx=-1;dx<=1;dx++){
            for(int dy=-1;dy<=1;dy++){
                int dk=x+dx;int dn=dy+y;
                if(dx*dy==0){
                    if(dk>=0 && dn>=0 && dk<n && dn<m && a[dk][dn]==-1){
                        a[dk][dn]=a[x][y]+1;
                        ma=max(ma,a[dk][dn]);q.emplace_back(dk,dn);
                    }
                }
            }
        }
    }
    
    cout<<ma;
    return 0;
}

Measured memory_bytes: 27240
a,n,m=list(map(int,input().split()))
count=0
check_list=[]
i=0
if a==0:i=1
while (i+a)**n<m:
    check_list.append((i+a)**n)
    i+=1
for x in check_list:
    xl=[int(i) for i in list(str(x))]
    y=sum(xl)
    if x==(y+a)**n:count+=1
print(count)


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

int main(){
  char c;
  int n,num[30],maxp,secp,maxn,secn,flag;
  cin >> n;
  while(n!=0){
    flag=0;
    for(int i=0;i<30;i++)
      num[i]=0;
    maxn=secn=-1;
    maxp=secp=30;
    for(int i=1;i<=n;i++){
      cin >> c;
      if(flag==0){
        num[c-'A']++;
        for(int j=0;j<30;j++)
          if(maxn<num[j]){
            maxn=num[j];
            maxp=j;
          }
        for(int j=0;j<30;j++)
          if(secn<num[j]&&j!=maxp){
            secn=num[j];
            secp=j;
          }
        if(maxn-secn>n-i){
          c='A'+maxp;
          cout << c << " " << i << endl;
          flag=1;
        }
      }
    }
    if(flag==0)
    cout << "TIE" << endl;
    cin >> n;
  }
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    vector<int> dis(N);
    rep(i, N) cin >> A[i];
    A.push_back(A[0] + K);
    int l = 0;
    rep(i, N){
        l = max(l, A[i+1]-A[i]);
    }
    int ans = K - l;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#define IsDigit(x) ((x) >= '0' && (x) <= '9')
using namespace std;

const int MOD(1000000007);
int n;
int color[200001], dp[200001], sum[200001];


int Read(void)
{
	int c, ret(0);
	
	c = getchar();
	while (!IsDigit(c))
		c = getchar();
	do
		ret = ret * 10 + c - '0';
	while ((c = getchar()) && IsDigit(c));
	return ret;
}


int main()
{
	n = Read();
	for (int i = 1; i <= n; ++i)
		color[i] = Read();
	n = unique(color + 1, color + n + 1) - color - 1;
	dp[0] = 1;
	for (int i = 1; i <= n; ++i) {
		dp[i] = sum[color[i]] + dp[i - 1];
		sum[color[i]] += dp[i - 1];
		dp[i] >= MOD && (dp[i] -= MOD);
		sum[color[i]] >= MOD && (sum[color[i]] -= MOD);
	}
	printf("%d\n", dp[n]);
	return 0;
}



Measured memory_bytes: 2560
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())
rsp={"r":p,"s":r,"p":s}
sumt=0
chk=[1]*n
for i in range(len(t)):
  sumt+=rsp[t[i]]
  if i>=k and t[i]==t[i-k]:
    chk[i]=chk[i-k]+1
    chk[i-k]=1
ans=sumt
for i in range(len(chk)):
  if chk[i]!=1:
    chg=chk[i]//2
    ans-=(rsp[t[i]])*chg
print(ans)

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

namespace Abc164_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            HashSet<string> hsTable = new HashSet<string>();

            for (int i = 0; i < N; i++)
            {
                var s = Console.ReadLine();

                hsTable.Add(s);
            }

            Console.WriteLine(hsTable.Count);
        }
    }
}


Measured memory_bytes: 46904
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int X,Y,Z;cin>>X>>Y>>Z;
  int ans=0;
  ans=(X-Z)/(Y+Z);
  P(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  vector<vector<ll>> dp(N / 2 + 1, vector<ll>(2, -INF));
  dp.at(0).at(0) = 0;
  for (ll i = 0; i < N; ++i) {
    ll least, most;
    if (N % 2 == 0) {
      most = min(N / 2 - 1, (i + 1) / 2);
      least = min(N / 2 - 1, i / 2);
    }
    else {
      most = min(N / 2 - 1, (i + 1) / 2);
      least = max(0ll, (i - 1) / 2);
    }
    vector<vector<ll>> update(most - least + 2, vector<ll>(2, -INF));
    for (ll j = least; j <= most; ++j) {
      update.at(j - least + 1).at(1) = max(update.at(j - least + 1).at(1), max(dp.at(j + 1).at(1), dp.at(j).at(0) + A.at(i)));
      update.at(j - least).at(0) = max(update.at(j - least).at(0), max(dp.at(j).at(0), dp.at(j).at(1)));
    }
    for (ll j = 0; j < update.size(); ++j) {
      for (ll k = 0; k < 2; ++k) {
        dp.at(j + least).at(k) = max(update.at(j).at(k), dp.at(j + least).at(k));
      }
    }
  }
  cout << max(dp.at(N / 2).at(0), dp.at(N / 2).at(1)) << "\n";
}


Measured memory_bytes: 10308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
const int inf=0x3f3f3f3f;

int K,N,d[2000010];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>K>>N;
    for(int i=0;i<N;i++){
    	cin>>d[i];
    	d[N+i]=d[i]+K;
    }
    int ans=inf;
    for(int i=0;i<N;i++) ans=min(ans,d[i+N-1]-d[i]);
	cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int diff = b - a;
    int sum= 0;
    for(int i=1;i<=diff;i++)
        sum+=i;
    cout << sum - b << endl;    

return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int n;
  int i,j;
  double x[105],y[105],ans,tmp,mx=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf",&x[i]);
  }
  for(j=0;j<n;j++){
    scanf("%lf",&y[j]);
  }
  ans=0;
  for(i=0;i<n;i++){
    if(x[i]-y[i]>0){
      ans+=x[i]-y[i];
      if(mx<x[i]-y[i]){
	mx=x[i]-y[i];
      }
    }
    else{
      ans+=y[i]-x[i];
      if(mx<y[i]-x[i]){
	mx=y[i]-x[i];
      }
    }
  }
  printf("%lf\n",ans);
  ans=0;
  for(i=0;i<n;i++){
    if(x[i]-y[i]>0){
      tmp=x[i]-y[i];
    }
    else{
      tmp=y[i]-x[i];
    }
    ans+=tmp*tmp;
  }
  printf("%lf\n",sqrt(ans));
  ans=0;
  for(i=0;i<n;i++){
    if(x[i]-y[i]>0){
      tmp=x[i]-y[i];
    }
    else{
      tmp=y[i]-x[i];
    }
    ans+=tmp*tmp*tmp;
  }
  ans=pow(ans,1.0/3.0);
  printf("%lf\n",ans);
  printf("%lf\n",mx);
  return 0;
}
  



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

int main(){
  	int a , b , c ; 
  cin >> a >> b >> c ; 
  int z = a + b + c ; 
  if ( z >= 22 ) cout << "bust" << endl;
  else cout << "win" << endl;
  
 	return 0 ;  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct _node
{
	int value;
	struct _node * next;
	struct _node * prev;
} node_t;

node_t *head;
node_t *p;


void Init()
{
//	fprintf( stdout, "init finished\n" );
	head = malloc( sizeof( node_t ) );
	head->next = NULL;
	head->prev = NULL;
	head->value = 100;
	p = head;
}

void Insert( int x )
{
//	fprintf( stdout, "insert started\n" );
	node_t *newnode;
	newnode = malloc( sizeof( node_t ) );
	p->next = newnode;
	newnode->value = x;
	newnode->next = NULL;
	newnode->prev = p;
	p = newnode;
}

void Delete( int x )
{
	node_t *pointer;
	pointer = p;

	while ( pointer != NULL )
	{
		if( pointer->value == x )
		{
			if ( pointer == p )
			{
				pointer->prev->next = NULL;
				p = pointer->prev;
			}
			else 
			{
				pointer->prev->next = pointer->next;
				pointer->next->prev = pointer->prev;
			}	
			free( pointer );
			break;
		}
		pointer = pointer->prev;
	}
}

void DeleteLast()
{
	node_t *pointer;

	if ( head->next == NULL )
	{
		;
	}
	else
	{
		pointer = head->next;
		if ( pointer->next != NULL )
		{
			head->next = pointer->next;
			pointer->next->prev = head;
		}
		else
		{
			p = head;
		}
		free( pointer );
	}
}


void DeleteFirst()
{
	node_t *pointer;
	pointer = p;
	if ( pointer == head )
	{
		;
	}
	else
	{
		p = pointer->prev;
		free( pointer );
		p->next = NULL;
	}
}

void PrintValue()
{
	node_t *pointer;
	pointer = p;

	while( pointer != head )
	{
		if ( pointer->prev == head )
		{
			fprintf( stdout, "%d", pointer->value );
		}
		else
		{
			fprintf( stdout, "%d ", pointer->value );
		}
		pointer = pointer->prev; 
	}

	fprintf( stdout, "\n");
}

int main()
{
	int n, i = 0, num;
	char s[12];

	Init();

	scanf( "%d", &n );
	while ( i < n )
	{
		scanf( "%s", s );
		if ( strcmp( s, "insert" ) == 0 )
		{
			scanf( "%d", &num );
			Insert( num );
		}
		else if ( strcmp( s, "delete" ) == 0 )
		{
			scanf( "%d", &num );
			Delete( num );
		}
		else if ( strcmp( s, "deleteFirst" ) == 0 )
		{
			DeleteFirst();
		}
		else if ( strcmp( s, "deleteLast" ) == 0 )
		{
			DeleteLast();
		}
	//	PrintValue();
		i = i + 1;
	}

	PrintValue();

	return 0;
}

Measured memory_bytes: 31788
#include <cstdio>

int A, V, B, W, T;

int main() {
	scanf("%d%d%d%d%d", &A, &V, &B, &W, &T);
	if (V <= W) puts("NO");
	else {
		int x = A - B;
		x = x < 0 ? -x : x;
		x = (x - 1) / (V - W) + 1;
		if (x <= T) puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 1660
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long a = in.nextLong();
			long b = in.nextLong();
			long[] x = in.nextLongArray(n);
			long[] edge = new long[n-1];
			for (int i = 0; i < n - 1; i++) {
				edge[i] = (x[i+1] - x[i]) * a;
			}

			// solve
			long ans = 0;
			for (int i = 0; i < n - 1; i++) {
				ans += Math.min(b, edge[i]);
			}

			out.println(ans);

		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

public static class Program
{
    public static void Main(string[] args)
    {
        var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        while (true)
        {
            vals[2] -= vals[1];
            if (vals[2] < 1)
            {
                Console.Write("Yes");
                return;
            }
            vals[0] -= vals[3];
            if (vals[0] < 1)
            {
                Console.Write("No");
                return;
            }
        }
    }
}

Measured memory_bytes: 18948
package main

import (
	"fmt"
	"math"
	"sort"
)

func main () {
	var n int
	fmt.Scan(&n)


	min := 1e10
	for i := 1; i * i <= n; i++ {
		if n % i == 0 {
			j := n / i
			max := math.Max(float64(calcDigit(i)), float64(calcDigit(j)))
			min = math.Min(max, min)
		}
	}
	fmt.Println(min)
}

// 桁数を返す
func calcDigit(n int) int {
	cnt := 0
	for n > 0 {
		cnt++
		n = n / 10
	}
	return cnt

}

// 約数列挙
func enumDivisions(n int) []int {
	var res []int
	for i := 1; i * i <= n; i++ {
		if n % i == 0 {
			res = append(res, i)

			// 重複しないならばiの相方である n/i もappend
			if n/i != i {
				res = append(res, n/i)
			}
		}
	}
	// 小さい順に並び替える
	sort.Ints(res)
	return res
}




Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
ll mod_pow(ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		ll tmp = mod_pow(a, n / 2);
		return (tmp * tmp) % MOD;
	}
	return (a * mod_pow(a, n - 1)) % MOD;
}
string L;
ll solve(int d) {
	if (d >= L.size()) return 1;
	if (L[d] == '0') {
		return solve(d + 1);
	}
	else {
		ll ret = solve(d + 1) * 2 % MOD;
		(ret += mod_pow(3, L.size() - d - 1)) %= MOD;
		return ret;
	}

}
int main() {
	cin >> L;
	cout << solve(0) << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    ll n;
    cin >> n;
    int N = 1000000;
    ll div1, div2;
    for(ll i = 1; i <= N; i++) {
        if (i*i > n) break;
        if (n % i == 0) div1 = max(div1, i);
    }
    div2 = n / div1;
    ll ans = div2 + div1 - 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
ans=0
for i in range(n-2):
  kr=0
  for j in [chr(k) for k in range(97,97+26)]:
    if s[0:i+1].count(j)>=1 and s[i+1:n].count(j)>=1:
      kr+=1
  if ans<kr:
    ans=kr
print(ans)

Measured memory_bytes: 3060
def main():
    MOD = 10**9+7
    n = int(input())
    al = list(map(int, input().split()))

    base_2_cnt = [0]*60 
    for a in al:
        for i in range(60):
            if ((a >> i) & 1): base_2_cnt[i] += 1

    ans = 0
    curr_2 = 1
    for i in range(60):
        base_01_comb = base_2_cnt[i] * (n-base_2_cnt[i])
        ans += base_01_comb * curr_2
        ans %= MOD
        curr_2*=2
        curr_2%=MOD

    print(ans%MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 122936
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <utility>

using namespace std;

int n;
vector<long double> p;
map<pair<int, int>, long double> dp;

long double dfs(int now, int cnt){
    if(n < cnt * 2){
        return 1;
    }
    if((n - now + cnt) * 2 <= n){
        return 0;
    }
    auto status = make_pair(now, cnt);
    if(dp.count(status)) return dp[status];
    return dp[status] = p[now] * dfs(now + 1, cnt + 1) + (1 - p[now]) * dfs(now + 1, cnt);
}

int main(){
    cin >> n;
    p.resize(n);
    for(auto&& i : p){
        cin >> i;
    }
    cout << fixed << setprecision(10) << dfs(0, 0) << "\n";
}

Measured memory_bytes: 176384
#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()


int main(void){
  int n ;
  int cnt = 0;
  cin>>n;
  while(n--){
    int bufi; char bufc;
    cin>>bufc>>bufi;
    if(bufc=='(')cnt+=bufi;
    else if(0<=cnt-bufi){
      cnt-=bufi;
    }
    //cout<<cnt<<endl;
  }
  cout<<(cnt!=0?"NO":"YES")<<endl;
}

Measured memory_bytes: 1160