akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef std::pair<std::string,int> p;

int main(void){
  int N;
  std::vector<std::string> v;
  std::vector<std::string> ans;
  std::cin >> N;
  for(int i=0;i<N;i++){
    std::string s;
    std::cin >> s;
    v.push_back(s);
    //std::cout << i << " " << s << std::endl;
  }
  //ソートする
  sort(v.begin(),v.end());
  //for(int i=0;i<N;i++){
  //  std::cout << i << " " << v[i] << std::endl;
  //}
  int count = 0;
  int max =0;
  std::string s = v[0];
  count = 1;
  int i;
  bool flag = true;
  for(i=0;i<v.size()-1;i++){

    if(s.compare(v[i+1]) != 0){
      p tmp(s,count);
      //hist.push_back(tmp);
      //vから削除
      if(count == max){
	ans.push_back(s);
      }
      if(count > max){
	ans.clear();
	ans.push_back(s);
	max = count;
      }//次のループに備える
      s = v[i+1];
      count = 1;
    }else{
    // 同じならcount++
    count++;
    }
  }

   if(count == max){
	ans.push_back(s);
      }
      if(count > max){
	ans.clear();
	ans.push_back(s);
	max = count;
      }//次のループに備える
 
  //maxのものをもってくる
  for(int i=0;i<ans.size();i++){
    std::cout << ans[i] << std::endl;
  }
  return 0;
}


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

const int MAX = 2000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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

    COMinit();
    int n = s/3;
    ll ans = 0;
    for(int i=1;i<=n;i++){
        int s_ = s-(3*i);
        ans = (ans+COM(s_+i-1, i-1))%MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3672
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

type IOTp struct {
	iBuffer []byte
	iPos int
}
func (this *IOTp) GetChar() byte {
	res:=this.iBuffer[this.iPos]
	this.iPos++
	return res
}
func (this *IOTp) ReadInt() int {
	res:=0
	k:=1
	for ch:=this.iBuffer[this.iPos]; !(ch>='0' && ch<='9'); ch=this.iBuffer[this.iPos]{
		if ch=='-' {
			k=-1
		}
		this.iPos++
	}
	for ch:=this.iBuffer[this.iPos]; ch>='0' && ch<='9'; ch=this.iBuffer[this.iPos]{
		res=res*10+int(ch-'0')
		this.iPos++
	}
	res*=k
	return res
}
func NewIOTp() *IOTp {
	now:=new(IOTp)
	//inputFile,_:=os.Open("in.txt")
	inputFile:=os.Stdin
	now.iBuffer,_=ioutil.ReadAll(inputFile)
	now.iBuffer=append(now.iBuffer, '\n')
	now.iPos=0
	return now
}
var cin *bufio.Reader
var cout *bufio.Writer
func max(a,b int) int {
	if a>=b {
		return a
	} else {
		return b
	}
}
func gcd(a,b int) int {
	for b!=0 {
		a,b=b,a%b
	}
	return a
}
func abs(x int) int {
	if x>=0 {
		return x
	} else {
		return -x
	}
}
func main() {
	IO:=NewIOTp()
	cout=bufio.NewWriter(os.Stdout)
	n,k:=IO.ReadInt(),IO.ReadInt()
	const MAXN=200000
	var a [MAXN+10]int
	for i:=1; i<=n; i++ {
		a[i]=IO.ReadInt()
	}
	x:=a[1]
	mx:=a[1]
	for i:=2; i<=n; i++ {
		x=gcd(x,a[i])
		mx=max(mx,a[i])
	}
	if k>mx {
		fmt.Println("IMPOSSIBLE")
		return
	}
	for i:=1; i<=n; i++ {
		if abs(a[i]-k)%x==0 {
			fmt.Println("POSSIBLE")
			return
		}
	}
	fmt.Println("IMPOSSIBLE")
	cout.Flush()
}


Measured memory_bytes: 4352
N = int(input())

f = {}
p = 2
while p*p<=N:
    if N%p==0: f[p]=0
    while N%p==0:
        N//=p
        f[p]+=1
    p+=1

if N>1: f[N]=1

ans = 0
for v in f.values():
    n = s = 0
    while s<=v:
        n+=1
        s+=n
    ans += n-1

print(ans)

Measured memory_bytes: 9204
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

  int n, m;
  cin >> n >> m;
  int p[m];
  string s[MAX];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
    cin >> s[i];
  }

  int c[n];
  bool b[n];

  fill(c, c + n, 0);
  fill(b, b + n, false);

  for (int i = 0; i < m; i++) {
    int j = p[i] - 1;
    if (!b[j]) {
      if (s[i] == "WA") {
        ++c[j];
      } else {
        b[j] = true;
      }
    }
  }

  int sum = 0, ac = 0;
  for (int i = 0; i < n; i++) {
    if (b[i]) {
      sum += c[i];
      ++ac;
    }
  }

  cout << ac << " " << sum << endl;

  return 0;
}


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

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int totalVote = 0;
    rep(i, n) {
        cin >> a[i];
        totalVote += a[i];
    }

    int cnt = 0;
    rep(i, n) {
        if (a[i] * 4 * m >= totalVote) cnt++;
    }

    cout << (cnt >= m ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int ai;
            cin >> ai;
            ai--;
            a.at(i).at(j) = ai;
        }
    }

    vector<int> ptr(n);
    vector<int> removed(m);
    vector<int> cnt(m);
    int ans = n;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            cnt.at(a.at(j).at(ptr.at(j)))++;
        }
        int maximum = 0;
        int max_kind = 0;
        for (int j = 0; j < m; j++) {
            if (maximum < cnt.at(j)) {
                maximum = cnt.at(j);
                max_kind = j;
            }
        }
        ans = min(ans, maximum);

        removed.at(max_kind) = true;
        for (int i = 0; i < n; i++) {
            cnt.at(a.at(i).at(ptr.at(i)))--;
            while (ptr.at(i) < m && removed.at(a.at(i).at(ptr.at(i)))) ptr.at(i)++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define lson rt<<1
#define rson rt<<1|1
#define scd(x) scanf("%d",&x)
#define scdd(x,y) scanf("%d%d",&x,&y)
const int maxn=300+10;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
int ans[maxn*maxn];
struct Query {
    int s,t,id;
    Query(){}
    Query(int s,int t,int id):s(s),t(t),id(id){}
    bool operator < (const Query&b)const{
        return s<b.s;
    }
} query[maxn*maxn];
struct Edge{
    int v,val;
    Edge(){}
    Edge(int v,int val):v(v),val(val){}
};
vector<Edge>G[maxn];
struct node{
    int level,val,v;
    node(){}
    node(int level,int val,int v):level(level),val(val),v(v){}
    bool operator <(const node &a)const{
        if(level!=a.level)return level>a.level;
        else return val>a.val;
    }
};
pii dis[maxn];
void init(int n){
    for(int i=1;i<=n;i++)dis[i]=pii(INF,INF);
}
void dij(int s,int n,int l){
    init(n);
    priority_queue<node>q;
    dis[s]=pii(0,0);
    q.push(node(0,0,s));
    while(!q.empty()){
        node no=q.top();q.pop();
        int u=no.v;
        pii x=pii(no.level,no.val);
        if(x>dis[u])continue;
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i].v,val=G[u][i].val;
            pii y;
            if(no.val+val<=l){
                y.first=no.level;
                y.second=no.val+val;
            }
            else if(val>l){
                continue;
            }
            else {
                y.first=no.level+1;
                y.second=val;
            }

            if(y<dis[v]){
                dis[v]=y;
                q.push(node(y.first,y.second,v));
            }
        }
    }
}
int main() {
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif // LOCAL
    int n,m,l;
    scdd(n,m);scd(l);
    for(int i=0;i<m;i++){
        int u,v,val;
        scdd(u,v);scd(val);
        G[u].push_back(Edge(v,val));
        G[v].push_back(Edge(u,val));
    }

    int q;
    scd(q);
    for(int i=1;i<=q;i++){
        int s,t;
        scdd(s,t);
        query[i]=Query(s,t,i);
    }
    sort(query+1,query+q+1);
    int s=-1;
    for(int i=1;i<=q;i++){
        if(s==query[i].s){
            ans[query[i].id]=dis[query[i].t].first;
        }
        else {
            s=query[i].s;
            dij(s,n,l);
            ans[query[i].id]=dis[query[i].t].first;
        }
    }
    for(int i=1;i<=q;i++){
        //cout<<ans[i]<<endl;
        if(ans[i]==INF)printf("-1\n");
        else printf("%d\n",ans[i]);
    }
}


Measured memory_bytes: 3664
fun main(args: Array<String>) {
    abc115b()
}

fun abc115b() {
    val n = readLine()!!.toInt()
    val items = (1..n).map { readLine()!!.toInt() }
        .toMutableList()

    val maxValueItem = items.max()!!
    items.remove(maxValueItem)

    val sum = maxValueItem / 2 + items.sum()

    println(sum)
}


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

int main(){
    int N;
    cin >> N;
    long power[N * 3];
    for(int i = 0; i < N * 3; i++){
        cin >> power[i];
    }
    sort(power, power + N * 3);
    long ans = 0;
    for(int i = N; i < N * 3; i += 2){
        ans += power[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long LL;
const int mod=1000000007;
int mul(int x,int k)
{
	LL ans=1,mid=x;
	while(k)
	{
		if(k&1) ans=ans*mid%mod;
		mid=mid*mid%mod;
		k>>=1;
	}
	return ans;
}
int main()
{
	int N,M,K;LL ans1=1,ans2=1;scanf("%d%d%d",&N,&M,&K);
	int u=N*M;N+=M,M=u;
	for(int i=0;i<K-2;++i)
	{
		ans1=ans1*(i+1)%mod;
		ans2=ans2*(M-2-i)%mod;
	}
	ans2=ans2*mul(ans1,mod-2)%mod;
	ans2=ans2*mul(6,mod-2)%mod*M%mod*N%mod*(M-1)%mod;
	printf("%lld",ans2);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vpi;
typedef vector<string> vsi;
typedef map<ll, ll> mape;
#define rep(i, a, b) for(ll i=(ll)a;i<=(ll)b;i++)
#define per(i, a, b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define all(v) v.begin(), v.end()
#define N 1000010
#define MAX 1234567890

int main()
{
    fastio;
    
    string s, t;
    cin >> s >> t;
    string temp;
    vi cnt(1010);
    rep(j, 0, t.size()-1){
    	rep(i, j, j+s.size()-t.size()){
    		if(s[i] != t[j]) cnt[i-j]++;
		}
	}
    ll mn = MAX;
    rep(i, 0, s.size()-t.size()) mn = min(mn, cnt[i]);
    cout << mn << endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long double PI = (acos(-1));

int main() {
  // 小数点以下10桁まで
  cout << fixed << setprecision(10);
  long double a,b,x;
  cin>>a>>b>>x;
  x/=a;

  if((a*b/2)<x){
    long double s=2*(a*b-x)/(a*a);
    long double k=atan(s);
    cout<<k*180/PI;
  }
  else if((a*b/2)>x){
    long double s=2*x/(b*b);
    long double k=PI/2-atan(s);
    cout<<k*180/PI;
  }
  else cout<<45;  
}


Measured memory_bytes: 3780
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
        for(int i=0;i<a;i++){in[i] = sc.nextInt();
                            }
        int b = 0;
		int c = in[0];
        for(int i=0;i<a;i++){c=Math.min(c,in[i]);if(c>=in[i]){b++;
                                                 }
                            }                              
		System.out.println(b);
	}
}


Measured memory_bytes: 64988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ_ALDS1_1_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(xy);
            int d = 1;
            while (d != 0)
            {
                d = xy[1] % xy[0];
                xy[1] = xy[0];
                xy[0] = d;
            }
            Console.WriteLine(xy[1]);
        }
    }
}



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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 1e4 + 7;
const long long M = 1e3 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int h;
int n;
int a[M];
int b[M];
int d[N];
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> h >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i] >> b[i];
    }
    memset(d, 63, sizeof d);
    d[0] = 0;
    for(int i = 1; i <= h; i ++){
        for(int j = 1; j <= n; j ++){
            d[i] = min(d[i], d[max(0, i - a[j])] + b[j]);
        }
    }
    cout << d[h] << "\n";
}


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

int dp[1001][1001];
string str1, str2;
int n;

int solve(string str1, string str2) {
  memset(dp, 0, sizeof(dp));
  for(int r = 0; r < str2.size(); r++) {
    for(int c = 0; c < str1.size(); c++) {
      if(str2[r] == str1[c]) {
        dp[r + 1][c + 1] = dp[r][c] + 1;
      }
      else {
        dp[r + 1][c + 1] = max(dp[r + 1][c], dp[r][c + 1]);
      }
    }
  }
  return dp[str2.size()][str1.size()];
}

int main() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> str1 >> str2;
    cout << solve(str1, str2) << endl;
  }
}



Measured memory_bytes: 7104
n, t = gets.chomp.split(' ').map(&:to_i)
 
pattern_array = []
for i in 1..n
  pattern_array << gets.chomp.split(' ').map(&:to_i)
end
 
p = pattern_array.select {|i| i[1] <= t}.map{|c| c[0]}.min
puts p.nil? ? 'TLE' : p

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
#define ll long long

using namespace std;


#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

const ll inf =1000000007;
typedef pair<ll,ll> Pair;


typedef vector<ll> vl;

ll n,m,q;
ll a[55],b[55],c[55],d[55];

ll ans;

void keisan(vector<ll> vec){
    ll ans1=0;
    rep(i,q){
        if(vec[b[i]]-vec[a[i]]==c[i]) ans1+=d[i];
    }
    ans=max(ans,ans1);
}

void dfs(vl vec){
    ll t=vec.size();
    if(t==n){
        keisan(vec);
    }
    else{
        ll r=1;
        if(t!=0) r=vec[t-1];
        for(ll i=r;i<=m;i++){
            vec.pb(i);
            dfs(vec);
            vec.pop_back();
        }
    }
}

void solve(){
    ans=0;
    cin >> n >> m >>q;
    rep(i,q){
        cin >> a[i] >> b [i] >> c[i] >> d[i];
        a[i]--;b[i]--;
    }
    vl vec={};
    dfs(vec);
    kaku(ans);
}

int main(){
    solve();
}

Measured memory_bytes: 3548
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	int a, b; cin >> a >> b;
    int res = a;
    if (b < a) --res;
    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main() {
    
    string w,t,w1,t1;
    int count = 0;
    
    cin >> w;
    
    w1 = w;
    
    for (int i = 0;i < w.size(); i ++) {
        
        w[i] = toupper(w1[i]);
        
    }
    
    while(1) {
        
        cin >> t;
        
        t1 = t;
        
        if (t == "END_OF_TEXT") break;
        
        for (int i = 0;i < t.size(); i ++) {
            
            t[i] = toupper(t1[i]);
            
            
        }
        
        if (w == t) {
            
            count += 1;
            
        }
        
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3196
using System;

class main
{
static void Main(string[] args)
{
double x=0.0;
double y=0.0;
double angle=0.0;
while (true)
{
var str = Console.ReadLine().Split(',');
var r = int.Parse(str[0]);
var angle_temp= int.Parse(str[1]);
if ((r == 0) && (angle_temp == 0))break;
var rad = angle / 180.0 * Math.PI;
var sin = r * Math.Sin(rad);
var cos = r * Math.Cos(rad);
x += sin;
y += cos; 
angle += angle_temp;
}
Console.WriteLine((int)x);
Console.WriteLine((int)y);
}
}


Measured memory_bytes: 15916
#include <iostream>
#include <vector>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace  std;

const double cos60 = cos(M_PI / 3);
const double sin60 = sin(M_PI / 3);

struct StPnt
{
  double m_nx;
  double m_ny;

  StPnt() :
    m_nx(0), m_ny(0)
  { }

  StPnt(double nx, double ny) :
    m_nx(nx), m_ny(ny)
  { }
};

void fnInput(int& rnRcSiz)
{
  cin >> rnRcSiz;
}

void fnPntGet(const StPnt& cnroPntL, const StPnt& cnroPntR, vector<StPnt>& rvoRtnPnt)
{
  rvoRtnPnt[0].m_nx = (2 * cnroPntL.m_nx + cnroPntR.m_nx) / 3;
  rvoRtnPnt[0].m_ny = (2 * cnroPntL.m_ny + cnroPntR.m_ny) / 3;
  rvoRtnPnt[2].m_nx = (cnroPntL.m_nx + 2 * cnroPntR.m_nx) / 3;
  rvoRtnPnt[2].m_ny = (cnroPntL.m_ny + 2 * cnroPntR.m_ny) / 3;

  rvoRtnPnt[1].m_nx =  (rvoRtnPnt[2].m_nx - rvoRtnPnt[0].m_nx) * cos60 
                     - (rvoRtnPnt[2].m_ny - rvoRtnPnt[0].m_ny) * sin60 + rvoRtnPnt[0].m_nx;
  rvoRtnPnt[1].m_ny =  (rvoRtnPnt[2].m_nx - rvoRtnPnt[0].m_nx) * sin60 
                     + (rvoRtnPnt[2].m_ny - rvoRtnPnt[0].m_ny) * cos60 + rvoRtnPnt[0].m_ny;
}

void fnResult(const StPnt& cnroPnt)
{
  cout << cnroPnt.m_nx << " " << cnroPnt.m_ny << endl;
}

void fnKoch(int nRcSiz, const StPnt& cnroPntL, const StPnt& cnroPntR)
{
  if (!nRcSiz) return;

  vector<StPnt> voRtnPnt(3);
  fnPntGet(cnroPntL, cnroPntR, voRtnPnt); 
  
  nRcSiz--;
  fnKoch(nRcSiz, cnroPntL, voRtnPnt[0]);
  fnResult(voRtnPnt[0]);

  fnKoch(nRcSiz, voRtnPnt[0], voRtnPnt[1]);
  fnResult(voRtnPnt[1]);

  fnKoch(nRcSiz, voRtnPnt[1], voRtnPnt[2]);
  fnResult(voRtnPnt[2]);

  fnKoch(nRcSiz, voRtnPnt[2], cnroPntR);
}

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

  int nRcSiz;
  vector<StPnt> voPnt;

  fnInput(nRcSiz);
  StPnt oPntL(0, 0);
  StPnt oPntR(100, 0);

  fnResult(oPntL);
  fnKoch(nRcSiz, oPntL, oPntR);
  fnResult(oPntR);
  return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        s: String,
    }

   let dayofweek =  match s.as_str() {
        "SUN" => 0,
        "MON" => 1,
        "TUE" => 2,
        "WED" => 3,
        "THU" => 4,
        "FRI" => 5,
        "SAT" => 6,
        _ => -1
    };

    println!("{}", 7 - dayofweek);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
	double r;
	double S=0.0,L=0.0,pi=3.14159265359;
	scanf("%lf",&r);
	S=r*r*pi;
	L=r*2*pi;
	printf("%.6lf %.6lf\n",S,L);
	return 0;
}

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

int main() {
    int n, d ;
    cin >> n >> d ;
    d = d * 2 + 1 ;
    int ans ;
    if(n % d != 0){
        ans = n / d + 1 ;
    }
    else {
        ans = n / d ;
    }
    cout << ans << endl ;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

vector<int> factorize(int M) {
    vector<int> ret;
    for (int i = 2; i*i <= M; ++i) {
        while (M % i == 0) {
            M /= i;
            ret.emplace_back(i);
        }
    }
    if (M > 1) ret.emplace_back(M);
    return ret;
}

int main() {
    int N, M;
    cin >> N >> M;
    if (N == 1) {
        cout << M << endl;
        return 0;
    }

    vector<int> factor = factorize(M);

    int d = M;
    do {
        int acc = 1;
        for (auto e: factor) {
            acc *= e;
            if (acc >= N) d = min(d, acc);
        }
    } while(next_permutation(factor.begin(), factor.end()));

    cout << M/d << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
  	if(n==k){
      return 1;
    }
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// vector<vector<int>> A(3, vector<int>(4));
int main() {
    string S,T;
    cin>>S>>T;
    sort(S.begin(),S.end());
    sort(T.rbegin(),T.rend());
    if(S<T){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
using namespace std;

int main() {
    nl // Lofi songs		
    int a, b, c;
    cin >> a >> b >> c;
    set<int> s = {a, b, c};
    cout << s.size();
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    int sum = 0;
    int current_x = 0;
    int current_y = 0;
    rep(i, n)
    {
        int t, x, y;
        cin >> t >> x >> y;
        int tt = t - sum;
        int xx = x - current_x;
        int yy = y - current_y;
        if (abs(xx) + abs(yy) <= tt && (abs(xx) + abs(yy)) % 2 == tt % 2)
        {
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
        sum = t;
        current_x=x;
        current_y = y;
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,a,b,c,x;
queue<int> y;

int main(){
	while(1){
		while(y.size())y.pop();
		cin>>n>>a>>b>>c>>x;
		if(n==0&&a==0&&b==0&&c==0&&x==0)break;
		REP(i,n){
			int t;
			cin>>t;
			y.push(t);
		}
		int cou=0;
		while(cou<=10000){
			if(x==y.front())y.pop();
			if(y.empty())break;
			x=(a*x+b)%c;
			cou++;
		}
		if(cou==10001)cout<<-1<<endl;
		else cout<<cou<<endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

using namespace std;

ll n, m;
vvl graph;

vb visited;
vl postOrder;

void dfs(ll node) {
	if(visited[node]) return;
	
	visited[node] = true;
	for(ll neigh : graph[node]) {
		dfs(neigh);
	}
	
	postOrder.pb(node);
}

int main(){
	cin.sync_with_stdio(0);
	cin >> n >> m;
	
	graph = vvl(n);
	visited = vb(n, false);
		
	FOR(i, 0, m) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		graph[a].pb(b);
	}
	
	FOR(i, 0, n) {
		dfs(i);
	}
	
	vl longest(n, 0);
	FORD(i, 0, n) {
		ll node = postOrder[i];
	
		//vl thisLen = longest[node];
		for(ll neigh : graph[node]) {
			longest[neigh] = max(longest[neigh], longest[node] + 1);		
		}
	}
	
	ll output = 0;
	for(ll next : longest) output = max(output, next);
	
	cout << output << endl;
	
	return 0;
}

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

const int MAX = 123456;
vector<bool> pn(MAX, true);

void init(){
  pn[0] = pn[1] = false;
  for(int i = 4; i < MAX; i += 2){
    pn[i] = false;
  }
  for(int i = 3; i <= sqrt(MAX); i += 2){
    for(int j = i * 2; j < MAX; j += i){
      pn[j] = false;
    }
  }
}

int x;

int main(){
  init();
  cin >> x;
  while(true){
    if(pn[x]){
      cout << x << endl;
      return 0;
    }
    x++;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

namespace zyt
{
	typedef long long ll;
	const int N = 2.5e4 + 10, K = 410, P = 1e9 + 7;
	int f[N], g[N], n, m, k, arr[N], num[K], ans;
	int power(int a, int b)
	{
		int ans = 1;
		while (b)
		{
			if (b & 1)
				ans = (ll)ans * a % P;
			a = (ll)a * a % P;
			b >>= 1;
		}
		return ans;
	}
	int inv(const int a)
	{
		return power(a, P - 2);
	}
	bool check_colorful()
	{
		static int num[K];
		for (int i = 1; i < k; i++)
			++num[arr[i]];
		for (int i = k; i <= m; i++)
		{
			bool flag = true;
			--num[arr[i - k]], ++num[arr[i]];
			for (int j = 1; j <= k; j++)
				if (num[j] != 1)
					flag = false;
			if (flag)
				return true;
		}
		return false;
	}
	void solve(int *const f)
	{
		static int num[K], tmp[K], sum[K];
		memset(num, 0, sizeof(int[k + 1]));
		memset(tmp, 0, sizeof(int[k + 1]));
		memset(sum, 0, sizeof(int[k + 1]));
		int p;
		for (int i = 1; i <= m; i++)
			if (++num[arr[i]] == 2)
			{
				p = i;
				break;
			}
		f[0] = tmp[p - 1] = 1;
		for (int i = 1; i < p; i++)
			sum[i] = 1;
		for (int i = 1; i <= n; i++)
		{
			for (int j = k - 1; j >= 1; j--)
			{
				tmp[j] = (tmp[j - 1] * ll(k - j + 1) + sum[j]) % P;
				sum[j] = (sum[j + 1] + tmp[j]) % P;
			}
			f[i] = sum[1];
			tmp[0] = 0;
		}
	}
	int work()
	{
		scanf("%d%d%d", &n, &k, &m);
		bool flag = true;
		for (int i = 1; i <= m; i++)
			scanf("%d", &arr[i]), flag &= (++num[arr[i]] < 2);
		ans = power(k, n - m) * ll(n - m + 1) % P;
		if (!check_colorful())
		{
			if (!flag)
			{
				solve(f);
				reverse(arr + 1, arr + m + 1);
				solve(g);
				for (int i = 1; i + m - 1 <= n; i++)
					ans = (ans - (ll)f[i - 1] * g[n - i - m + 1] % P + P) % P;
			}
			else
			{
				static int sum[K], sumg[K];
				f[0] = sum[0] = 1;
				for (int i = 1; i <= n; i++)
				{
					for (int j = k - 1; j > 0; j--)
					{
						f[j] = (f[j - 1] * ll(k - j + 1) + sum[j]) % P;
						sum[j] = (sum[j + 1] + f[j]) % P;
						g[j] = (g[j - 1] * ll(k - j + 1) + sumg[j]) % P;
						if (j >= m)
							g[j] = (g[j] + f[j]) % P;
						sumg[j] = (sumg[j + 1] + g[j]) % P;
					}
					f[0] = g[0] = 0;
				}
				int tmp = 1;
				for (int i = 1; i <= k; i++)
					tmp = (ll)tmp * inv(i) % P;
				for (int i = 1; i <= k - m; i++)
					tmp = (ll)tmp * i % P;
				ans = (ans - (ll)sumg[1] * tmp % P + P) % P;
			}
		}
		printf("%d", ans);
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 512
var
  a:array[1..100]of string;
  i,j,n:longint;
begin
  readln(n);
  for i:=1 to n do
  begin
    readln(a[i]);
    if (i<>1)and(a[i][1]<>a[i-1][length(a[i-1])]) then begin writeln('No'); exit; end;
    for j:=1 to i-1 do if a[i]=a[j] then begin writeln('No'); exit; end;
  end;
  writeln('Yes');
end.

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  ll N, A, B;
  cin >> N >> A >> B;
  ll x[N];
  for (int i = 0; i < N; i++) cin >> x[i];

  ll ans = 0;
  for (int i = 0; i < N - 1; i++) ans += min(A * (x[i+1] - x[i]), B);

  // 解答
  cout << ans << endl;

  return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;
	S[3] = '8';
	printf("%s\n", S.c_str());
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long int x=a*c;
    if(a*d>x)
        x=a*d;
    if(b*c>x)
        x=b*c;
    if(b*d>x)
        x=b*d;
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 55
int vis[55];
int main()
{
    int n,m,x,y;
    scanf("%d%d",&n,&m);
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        vis[x]++;
        vis[y]++;
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d\n",vis[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int timer;
int n;

typedef struct
{
  int iudgment;
  int time;
  int finish;
  int position[101];
}graph;

void check(int t, graph g[])
{
  g[t].iudgment = 1;
  g[t].time = ++timer;
  for(int i = 0; i < n; i++)
    {
      if(g[t].position[i] == 1)
	{
	  if(g[i].iudgment == 0)
	    {
	      check(i, g);
	    }
	}
    }
  g[t].iudgment = 2;
  g[t].finish = ++timer;
}

int main()
{
  int a, b, c;
  scanf("%d", &n);
  graph g[n];
  timer = 0;
  for(int i = 0; i < n; i++)
    {
      g[i].iudgment = 0;
      for(int j = 0; j < n; j++)
	{
	  g[i].position[j] = 0;
	}
    }
  for(int i = 0; i < n; i++)
    {
      scanf("%d %d", &a, &b);
      for(int j = 0; j < b; j++)
	{
	  scanf("%d", &c);
	  g[a-1].position[c-1] = 1;
	}
    }
  for(int i = 0; i < n; i++)
    {
      if(g[i].iudgment == 0)
	{
	  check(i, g);
	}
    }

  for(int i = 0 ; i < n; i++)
    {
      printf("%d %d %d\n", i+1, g[i].time, g[i].finish);
    }
}



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

int main(void){
	int n, m, l;
	long int mul;
	int **A, **B;

	cin >> n >> m >> l;

	A = new int*[n];
	for (int i = 0; i < n; i++){
		A[i] = new int[m];
	}
	B = new int*[m];
	for (int i = 0; i < m; i++){
		B[i] = new int[l];
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < m; i++){
		for (int j = 0; j < l; j++){
			cin >> B[i][j];
		}
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			mul = 0;
			for (int k = 0; k < m; k++){
				mul += A[i][k] * B[k][j];
			}
			cout << mul;
			if (j != l - 1) cout << " ";
		}
		cout << "\n";
	}
	
	delete[] A[0],B[0];
	delete[] A, B;
	return 0;
}

Measured memory_bytes: 1272
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

struct Syn{
	string s;
	int p;
	bool Good;
	void clean(){
		string t = "";
		for(int i = 0 ; i < s.size() ; i ++){
			if(s[i] != ' ')t += s[i];
		}
		s = t;
		Good = true;
	}
	int modpow(int x,int k){
		if(k == 0)return 1;
		int ret = modpow(x,k/2);
		ret *= ret; ret %= p;
		if(k%2 == 1){ ret *= x; ret %= p; }
		return ret;
	}
	int inverse(int x){
		return modpow(x,p-2);
	}
	int dfs1(int loc,int* memory){
		//if(loc < s.size())cout << "dfs1:" << s.substr(loc) << endl;
		int ret = 0;
		int sgn = 1;
		while(Good){
			int a;
			loc = dfs2(loc,&a);
			ret += p+a*sgn; ret %= p;
			if(loc >= s.size() || s[loc] == ')')break;
			if(s[loc] == '+')sgn = 1;
			else sgn = -1;
			loc ++;
		}
		*memory = ret;
		//cout << "1:" << ret << endl;
		return loc;
	}
	int dfs2(int loc,int* memory){
		//if(loc < s.size())cout << "dfs2:" << s.substr(loc) << endl;
		int ret = 1;
		int sgn = 1;
		while(Good){
			int a;
			if(s[loc] == '('){
				loc = dfs1(loc+1,&a);
				loc ++;
			}
			else loc = dfs3(loc,&a);
			if(sgn == 1){
				ret *= a; ret %= p;
			}
			else {
				if(a == 0){
					Good = false;
					break;
				}
				ret *= inverse(a); ret %= p;
			}
			if(loc >= s.size())break;
			else if(s[loc] == '*')sgn = 1;
			else if(s[loc] == '/')sgn = -1;
			else break;
			loc ++;
		}
		*memory = ret;
		//cout << "2:" << ret << endl;
		return loc;
	}
	int dfs3(int loc,int* memory){
		//if(loc < s.size())cout << "dfs3:" << s.substr(loc) << endl;
		int ret = 0;
		while(loc < s.size() && '0' <= s[loc] && s[loc] <= '9'){
			ret *= 10;
			ret += s[loc] - '0';
			loc ++;
		}
		*memory = ret;
		//cout << "3:" << ret << endl;
		return loc;
	}
}Syn;

int main(){
	while(1){
		getline(cin,Syn.s);
		Syn.clean();
		if(Syn.s == "0:")break;
		int loc = Syn.dfs3(0,&Syn.p);
		int ans; Syn.dfs1(loc+1,&ans);
		if(Syn.Good)cout << Syn.s.substr(loc+1) << " = " << ans << " (mod " << Syn.p << ")\n";
		else puts("NG");
	}
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) ((a)^(b) & 1LL ^ 1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll n,a,b,x[100002]; cin>>n>>a>>b;
	ll l = q_ceil(b,a),ans = 0;
	rep(i,n) cin>>x[i + 1];
	ll dp[100002];
	fill(all(dp),INF_64);
	dp[1] = 0;
	rep1(i,n - 1){
		dp[i + 1] = min(dp[i + 1],dp[i] + (x[i + 1] - x[i]) * a); 
		int t = l_bnd(x + i + 1,x + n + 1,l + x[i]) - begin(x);
		if(t <= n){
			dp[t] = min(dp[t],dp[i] + b + (x[t] - x[i + 1]) * 2 * a);
		}
	}
	cout<<dp[n]<<endl;
		
	return 0;
}





Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
main(){
long long i,j,k,l,m,n,p;
while(cin>>p>>n){
if((p==4||p==6||p==9||p==1)&&(n==4||n==6||n==9||n==11)) cout<<"Yes"<<endl;
else if((p==1||p==3||p==5||p==7||p==8||p==10||p==12)&&(n==1||n==3||n==7||n==8||n==5||n==10||n==12))cout<<"Yes"<<endl;
else cout<<"No"<<endl;
} return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
AB = []

for _ in range(M):
  a, b = map(int, input().split())
  AB.append((a, b))

Rsort = sorted(AB, key=lambda x: x[1])
cnt = 0
R = 0

for a, b in Rsort:
  if a <= R:
    continue
  else:
    cnt += 1
    R = b-1

print(cnt)

Measured memory_bytes: 87660
n = gets.chomp.to_i
nl = gets.split.map(&:to_i)
mod = 1000000007
acc_table = []
n.times do |i|
  acc_table[i] = 0
end
nl.each_with_index do |x,i|
  acc_table[i+1] = x + acc_table[i]
end

result = 0
nl.each_with_index do |x,i|
  sum = (acc_table[n] - acc_table[i + 1]) % mod
  result += nl[i] * sum
  result %= mod
end
puts result

Measured memory_bytes: 29964
#include <bits/stdc++.h>
#define ll long long
#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;i>=0;i--)
#define INF 100000005
#define MAX 100000001
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[101], dp[101][3][3];
int main(){
	int n, k,t1,t2;
	scanf("%d%d", &n, &k);
	rep(i,k){
		scanf("%d%d", &t1, &t2);
		a[t1] = t2;
	}
	if(a[1] == 0 || a[1] == 1)dp[1][0][1] = 1;
	if(a[1] == 0 || a[1] == 2)dp[1][1][2] = 1;
	if(a[1] == 0 || a[1] == 3)dp[1][2][0] = 1;
	for(int i = 1;i <= n;i++){
		if(a[i] == 0 || a[i] == 1){
			dp[i][0][0] = dp[i-1][0][1]+dp[i-1][0][2];
			rep(j,3)dp[i][0][1] += dp[i-1][1][j];
			rep(j,3)dp[i][0][2] += dp[i-1][2][j];
		}
		if(a[i] == 0 || a[i] == 2){
			dp[i][1][1] = dp[i-1][1][0]+dp[i-1][1][2];
			rep(j,3)dp[i][1][0] += dp[i-1][0][j];
			rep(j,3)dp[i][1][2] += dp[i-1][2][j];
		}
		if(a[i] == 0 || a[i] == 3){
			dp[i][2][2] = dp[i-1][2][0]+dp[i-1][2][1];
			rep(j,3)dp[i][2][0] += dp[i-1][0][j];
			rep(j,3)dp[i][2][1] += dp[i-1][1][j];
		}
		rep(j,3)rep(k,3)dp[i][j][k] = dp[i][j][k]%10000;
	}
	int ans = 0;
	rep(i,3)rep(j,3)ans += dp[n][i][j];
	printf("%d\n", ans%10000);
	return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k;

ll gcd(ll a,ll b){
    if(b==0){return a;}
    else{return gcd(b,a%b);}
}

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

    vector<ll> left(n+1),right(n+1);

    left[0]=a[0];
    for(i=0;i<=n-1;i++){//左端からa[i]までのgcd
        left[i+1]=gcd(left[i],a[i]);
    }

    right[n]=a[n-1];
    for(i=n-1;i>=0;i--){//右端からa[i]までのgcd
        right[i]=gcd(right[i+1],a[i]);    
    }

    ll max=-1;
    for(i=0;i<n;i++){
        if(i==0){max=right[1];}
        else if(i==n-1 && max<left[n-1]){max=left[n-1];}
        else if(max<gcd(left[i],right[i+1])){
            max=gcd(left[i],right[i+1]);
        }
    }

    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long int

int n,m,x;
int c[14];
int a[14][14];

int main(){

  scanf("%d%d%d",&n,&m,&x);
  for(int i=0;i<n;i++){
    scanf("%d",&c[i]);
    for(int j=0;j<m;j++){
      scanf("%d",&a[i][j]);}}
  
  ll mincost=2000000;

  for(int i=1;i<4096;i++){
    int t=i;
    ll tmpcost=0;
    ll tmp[14]={};
    for(int j=0;j<n;j++){
      if(t%2==1){
	for(int l=0;l<m;l++){
	  tmp[l]+=a[j][l];}
	tmpcost+=c[j];}
      t/=2;}
    int check=1;
    for(int j=0;j<m;j++){
      if(tmp[j]<x){
	check=0; break;}}
    if(check==1 && mincost>tmpcost){
      mincost=tmpcost;}
  }
  
  if(mincost==2000000){
    mincost=-1;}

  printf("%lld\n",mincost);

  
  return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}

int main(){
    string s; cin >> s;
    ll n = s.size();
    ll ans = 0;
    ll now = 0;
    ll cnt = 0;
    rep(i,n){
        cnt = 0;
        if(s[i]=='<'){
            ans += now;
            now++;
        }else{
            while(s[i]=='>'){
                cnt++;
                i++;
            }
            i--;
            ans += (cnt-1)*cnt/2;
            ans += max(now,cnt);
            now = 0;
        }
        //cout << ans << endl;
    }
    ans += now;
    cout << ans << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;

int main() {
    int n, m;
    double x[100], y[100], d[100][100], dmin[100], pre[100];
    bool used[100];
    while(cin >> n, n){
        for(int i=0;i<n;i++){
            int b;
            cin >> b;
            cin >> x[b-1] >> y[b-1];
        }
        cin >> m;
        for(int i=0;i<n;i++){
            fill(d[i], d[i]+n, IINF);
        }
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                double tmp = pow(pow(x[i]-x[j],2)+pow(y[i]-y[j],2),0.5);
                if(tmp < 50 + EPS){
                    d[i][j] = tmp;
                    d[j][i] = tmp;
                }
            }
        }
        for(;m>0;m--){
            int s, g, now;
            cin >> s >> g;
            s--; g--;
            fill(dmin, dmin+n, IINF);
            fill(used, used+n, false);
            dmin[g] = 0;
            pre[g] = -1;
            now = g;
            for(int i=0;i<n;i++){
                used[now] = true;
                for(int j=0;j<n;j++){
                    if(dmin[j] > dmin[now] + d[now][j]){
                        dmin[j] = dmin[now] + d[now][j];
                        pre[j] = now;
                    }
                }
                double mi = IINF;
                for(int j=0;j<n;j++){
                    if(used[j]) continue;
                    if(mi > dmin[j]){
                        mi = dmin[j];
                        now = j;
                    }
                }
            }
            if(dmin[s] < IINF - EPS){
                cout << s+1;
                now = pre[s];
                while(now != -1){
                    cout << " " << now+1;
                    now = pre[now];
                }
                cout << endl;
            }
            else{
                cout << "NA" << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3348
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

int f(int x) {
   int res = 0;
   while (x) {
      res += x % 10;
      x /= 10;
   }
   return res;
}

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

   int n;
   cin >> n;
   int ans = 100005;
   rep(i, 1, n) {
      int a = i, b = n - i;
      chmin(ans, f(a) + f(b));
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[1005][1005];
long long f[1005][1005];
long long oo=1e9+7;
inline long long F(int i,int j)
{
//    cout<<123;
//    cout<<i<<" "<<j<<" "<<f[i][j]<<endl;
    if(i<0||j<0)
        return 0;
    if(f[i][j]!=-1)
        return f[i][j];
    if(a[i][j]=='#')
        f[i][j]=0;
    else
    {
        f[i][j]=(F(i-1,j)%oo+F(i,j-1)%oo)%oo;
    }
//    cout<<"=> "<<i<<" "<<j<<" "<<f[i][j]<<endl;
    return f[i][j];
}
main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        f[i][j]=-1;

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        cin>>a[i][j];
    if(a[1][1]=='.')
    {
//        cout<<123132132132132132132132123123;
        f[1][1]=1;
    }
    cout<<F(n,m);
}


Measured memory_bytes: 9216