akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

n, m, q = map(int, input().split())
S = [[0]*(m+1)] + [[0] + list(map(int, list(input().rstrip()))) for _ in range(n)]
B = [[0]*(m+1) for _ in range(n+1)]
U = [[0]*(m+1) for _ in range(n+1)]
L = [[0]*(m+1) for _ in range(n+1)]
for i in range(1, n+1):
  for j in range(1, m+1):
    B[i][j] = B[i-1][j] + B[i][j-1] - B[i-1][j-1] + S[i][j]
    U[i][j] = U[i-1][j] + U[i][j-1] - U[i-1][j-1] + U[i][j]
    L[i][j] = L[i-1][j] + L[i][j-1] - L[i-1][j-1] + L[i][j]
    if S[i][j]:
      U[i][j] += S[i-1][j]
      L[i][j] += S[i][j-1]
    
def calc_b(x1, y1, x2, y2):
  return B[x2][y2] - B[x1-1][y2] - B[x2][y1-1] + B[x1-1][y1-1]
def calc_u(x1, y1, x2, y2):
  return U[x2][y2] - U[x1][y2] - U[x2][y1-1] + U[x1][y1-1]
def calc_l(x1, y1, x2, y2):
  return L[x2][y2] - L[x1-1][y2] - L[x2][y1] + L[x1-1][y1]

for _ in range(q):
  x1, y1, x2, y2 = map(int, input().split())
  res = calc_b(x1, y1, x2, y2) - (calc_u(x1, y1, x2, y2) + calc_l(x1, y1, x2, y2))
  print(res)

Measured memory_bytes: 179336
a, b, c, d = map(int, input())

op = "-+"
for i1 in range(2):
  for i2 in range(2):
    for i3 in range(2):
      ans = a
      ans += b if i1 else -b
      ans += c if i2 else -c
      ans += d if i3 else -d
      if ans == 7:
        print("%d%s%d%s%d%s%d=7" % (a,op[i1],b,op[i2],c,op[i3],d))
        exit()

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>

#define EPS 1e-6

int n,d,ans;
int x[15][15];

inline double dis(int p,int q) {
	double ans(0);
	for(int i=1;i<=d;++i)
		ans+=(x[p][i]-x[q][i])*(x[p][i]-x[q][i]);
	return sqrt(ans);
}

inline int check(int p,int q) {
	double z=dis(p,q);
	if(fabs(z-floor(z))<EPS)
		return 1;
	if(fabs(z-ceil(z))<EPS)
		return 1;
	return 0;
}

int main() {
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=d;++j)
			scanf("%d",&x[i][j]);
	for(int i=1;i<n;++i)
		for(int j=i+1;j<=n;++j)
			if(check(i,j))
				++ans;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
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 (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=100005,INF=1<<30;
const ll M=1LL<<53;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        ll N;cin>>N;
        if(N==0) break;
        
        ll ans1=0,ans2=0;
        string S;cin>>S;
        ll p=1;
        for(char c:S){
            p*=2;
            if(c=='1') p++;
        }
        ans2=p;
        
        while(N&&p){
            ll can=(M-1-ans2)/p;
            if(can>N){
                ans2+=p*N;
                break;
            }else{
                ans2+=p*can;
                N-=can;
            }
            
            if(N==0) break;
            
            ans2+=p;
            ans2/=2;
            ans1++;
            N--;
            p/=2;
        }
        //cout<<ans1<<" "<<ans2<<endl;
        cout<<bitset<12>(ans1)<<bitset<52>(ans2)<<endl;
    }
    
    
}




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

using namespace std;

#define DIM 3009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<long long,long long>
#define fi first
#define se second

long long i,j,k,l,n,m;

long long dp[DIM][DIM],par[DIM][DIM];

string s,t;

long long rec(long long n,long long m){
    if(n<0 || m<0)return 0;
    if(dp[n][m]!=-1)return dp[n][m];
    if(s[n]==t[m])dp[n][m]=1+rec(n-1,m-1),par[n][m]=1;
    if(rec(n-1,m)>dp[n][m]){
        dp[n][m]=rec(n-1,m);
        par[n][m]=2;
    }
    if(rec(n,m-1)>dp[n][m]){
        dp[n][m]=rec(n,m-1);
        par[n][m]=3;
    }
    return dp[n][m];
}

string res;

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

    memset(dp,-1,sizeof(dp));

    rec(s.length()-1,t.length()-1);

    n=s.length()-1,m=t.length()-1;

    while(n>=0 && m>=0){
        if(s[n]==t[m])res+=s[n];
        if(par[n][m]==1)n--,m--;
        else{
            if(par[n][m]==2)n--;
            else m--;
        }
    }

    reverse(res.begin(),res.end());
    cout<<res<<endl;

    return 0;
}


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

using namespace std;

const unsigned mod = 1e9 + 7;
unsigned power[234567], lad[26][234567];

struct SegmentTree
{
  vector< unsigned > hashed;
  vector< int > lazy;
  int sz;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    hashed.assign(2 * sz - 1, 0);
    lazy.assign(2 * sz - 1, -1);
  }

  void push(int k, int l, int r)
  {
    if(~lazy[k]) {
      hashed[k] = lad[lazy[k]][r - l];
      if(k < sz - 1) {
        lazy[2 * k + 1] = lazy[k];
        lazy[2 * k + 2] = lazy[k];
      }
      lazy[k] = -1;
    }
  }

  void add(int a, int b, int x, int k, int l, int r)
  {
    push(k, l, r);
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      lazy[k] = x;
      push(k, l, r);
    } else {
      add(a, b, x, 2 * k + 1, l, (l + r) >> 1);
      add(a, b, x, 2 * k + 2, (l + r) >> 1, r);
      hashed[k] = hashed[2 * k + 1] * power[(r - l) >> 1] + hashed[2 * k + 2];
    }
  }

  void add(int a, int b, int x)
  {
    add(a, b, x, 0, 0, sz);
  }

  pair< unsigned, int > get(int a, int b, int k, int l, int r)
  {
    push(k, l, r);
    if(a >= r || b <= l) return {0, 0};
    if(a <= l & r <= b) return {hashed[k], r - l};
    auto ll = get(a, b, 2 * k + 1, l, (l + r) >> 1);
    auto rr = get(a, b, 2 * k + 2, (l + r) >> 1, r);
    return {ll.first * power[rr.second] + rr.first, ll.second + rr.second};

  }

  unsigned get(int a, int b)
  {
    return (get(a, b, 0, 0, sz).first);
  };
};

int main()
{
  power[0] = 1;
  for(int i = 0; i < 234566; i++) power[i + 1] = power[i] * mod;
  for(int i = 0; i < 26; i++) {
    const char cc = 'a' + i;
    for(int j = 0; j < 234566; j++) lad[i][j + 1] = lad[i][j] * mod + cc;
  }


  int N, Q;
  char U[234567];

  scanf("%d", &N);
  getchar();
  scanf("%s", U);
  SegmentTree tree(N);
  for(int i = 0; i < N; i++) tree.add(i, i + 1, U[i] - 'a');

  scanf("%d", &Q);
  while(Q--) {
    getchar();
    scanf("%s", U);
    if(*U == 's') {
      int x, y;
      char z;
      scanf("%d %d %c", &x, &y, &z);
      tree.add(--x, y, z - 'a');
    } else {
      int a, b, c, d;
      scanf("%d %d %d %d", &a, &b, &c, &d);
      --a, --c;
      int ok = 0, ng = min(d - c, b - a) + 1;
      while(ng - ok > 1) {
        int mid = (ok + ng) >> 1;
        if(tree.get(a, a + mid) == tree.get(c, c + mid)) ok = mid;
        else ng = mid;
      }

      if(ok == d - c && ok == b - a) {
        puts("e");
      } else if(b - a == ok || (d - c != ok && tree.get(a + ok, a + ok + 1) < tree.get(c + ok, c + ok + 1))) {
        puts("s");
      } else {
        puts("t");
      }
    }
  }

}

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

int main(){
  int n, k; cin >> n >> k;
  vector<int> a(n, 0);
  for(int i = 0; i < n; i++){
  int z; cin >> z;
  for(int j = 0; j < z; j++){
  	int x; cin >> x;
  	a[x-1]++;
  }
  }
  int ans = 0;
  for(int i = 0; i < n; i++) if(a[i]==0) ans++;
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
n = int(input())
location = [[0]*3]*n

for i in range(n):
    location[i] = list(map(int,input().split()))

# print(location) -> [[3, 1, 2], [6, 1, 1]]
# 合計値と同じ奇数or偶数になっていればいい
for i in range(n):
    if location[i][1] + location[i][2] > location[i][0]:
        print("No")
        flag = False
        break
    elif location[i][0] % 2 != (location[i][1] + location[i][2]) % 2:
        print("No")
        flag = False
        break
    else:
        flag = True

if flag:
    print("Yes")

Measured memory_bytes: 27300
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;


int32_t main(){
    FAST;

    int n;  cin >> n;
    if(n % 2 == 0)
        cout << n;
    else cout << 2*n;

    return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

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

        int d = scan.nextInt();
        int t = scan.nextInt();
        int s = scan.nextInt();

        if (t*s >= d){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35908
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.collatz", "r", stdin);
	string str = "";

	while (getline (cin, str ) ){

		int n;
		stringstream ss(str);

		ss >> n;

		if (n == 0){
			break;
		} // end if

		int res = 0;

		while (n != 1){
			if (n % 2 == 0){
				n /= 2;
			}else{
				n = 3*n + 1;
			} // end if
			++res;
		} // end while

		cout << res << endl;

	} // end loop

	return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
int  gcd(int a, int b) {
	if (a < b) gcd(b, a);
	int r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}
namespace NTT {
	const int MOD = 998244353;  // to be set appropriately
	const long long PR = 3;     // to be set appropriately

	void trans(vector<long long> &v, bool inv = false) {
		int n = (int)v.size();
		for (int i = 0, j = 1; j < n - 1; j++) {
			for (int k = n >> 1; k >(i ^= k); k >>= 1);
			if (i > j) swap(v[i], v[j]);
		}
		for (int t = 2; t <= n; t <<= 1) {
			long long bw = modpow(PR, (MOD - 1) / t, MOD);
			if (inv) bw = modinv(bw, MOD);
			for (int i = 0; i < n; i += t) {
				long long w = 1;
				for (int j = 0; j < t / 2; ++j) {
					int j1 = i + j, j2 = i + j + t / 2;
					long long c1 = v[j1], c2 = v[j2] * w % MOD;
					v[j1] = c1 + c2;
					v[j2] = c1 - c2 + MOD;
					while (v[j1] >= MOD) v[j1] -= MOD;
					while (v[j2] >= MOD) v[j2] -= MOD;
					w = w * bw % MOD;
				}
			}
		}
		if (inv) {
			long long inv_n = modinv(n, MOD);
			for (int i = 0; i < n; ++i) v[i] = v[i] * inv_n % MOD;
		}
	}

	// C is A*B
	vector<long long> mult(vector<long long> A, vector<long long> B) {
		int size_a = 1; while (size_a < A.size()) size_a <<= 1;
		int size_b = 1; while (size_b < B.size()) size_b <<= 1;
		int size_fft = max(size_a, size_b) << 1;

		vector<long long> cA(size_fft, 0), cB(size_fft, 0), cC(size_fft, 0);
		for (int i = 0; i < A.size(); ++i) cA[i] = A[i];
		for (int i = 0; i < B.size(); ++i) cB[i] = B[i];

		trans(cA); trans(cB);
		for (int i = 0; i < size_fft; ++i) cC[i] = cA[i] * cB[i] % MOD;
		trans(cC, true);

		vector<long long> res((int)A.size() + (int)B.size() - 1);
		for (int i = 0; i < res.size(); ++i) res[i] = cC[i];
		return res;
	}
};
template<class V, int ME> class BIT {
public:
	V bit[1 << ME];
	V operator()(int e) { if (e<0) return 0; V s = 0; e++; while (e) s += bit[e - 1], e -= e&-e; return s; }
	void add(int e, V v) { e++; while (e <= 1 << ME) bit[e - 1] += v, e += e&-e; }
};
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0, a + b - n);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <string>
using namespace std;
int main(void){
    string S;
    cin >> S;
    int ans = 0;
    for(int i=0;i<S.size();i++){
        if(S[i] == '2')ans++;
    }
    cout << ans;
}


Measured memory_bytes: 3196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{
 
  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      StringBuilder result = new StringBuilder();
      String[] lines;
      int h,w;
      int i,j;

      while (true) {
        lines = br.readLine().split(" ");
        h = Integer.parseInt(lines[0]);
        w = Integer.parseInt(lines[1]);

        if(h==0 && w==0){ break; }

        for( i = 0; i < h; i++ ) {
          for( j = 0; j < w; j+=2 ) {
            if( i % 2 == 0 ){
               result.append("#.");
            } else {
              result.append(".#");
            }
          }
          if ( j > w)  result.delete(result.length()-1, result.length());
          result.append("\n");
        }

        System.out.println(result);

        result.setLength(0);
      }
    }
  }
}


Measured memory_bytes: 25668
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	unsigned int i,n,s,k;
	while(cin >> n) {
		if (n==0) break;
        s=0; 
		for (i=0,k=5;i<13;i++,k*=5) s+=n/k;
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a =sc.nextInt();
        int b =sc.nextInt();
        if(a<b){
            System.out.println("a < b");
        }else if(a>b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26252
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	X := sc.i()
	o := 100
	i := 0
	for o < X {
		n := 1.01 * float64(o)
		o = int(n)
		i++
	}
	fmt.Println(i)
}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}


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

int main() {
    int x,y,z,k;cin>>x>>y>>z>>k;
    ll a[x],b[y],c[z];
    for (int i=0;i<x;i++)
        cin>>a[i];
    for (int i=0;i<y;i++)
        cin>>b[i];
    for (int i=0;i<z;i++)
        cin>>c[i];
    vector<ll> d,e;
    for (int i=0;i<x;i++)
        for (int j=0;j<y;j++)
            d.push_back(a[i]+b[j]);
    sort(d.begin(),d.end(),greater<ll>());
    for (int i=0;i<k&&i<d.size();i++)
        for (int j=0;j<z;j++)
            e.push_back(d[i]+c[j]);
    sort(e.begin(),e.end(),greater<ll>());
    for (int i=0;i<k;i++)
        cout<<e[i]<<endl;
    return 0;
}

Measured memory_bytes: 43364
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define INF 0x7fffffffffffffff
#define N 100010
int a[N];
using namespace std;
int main(void){
	int ans = 0,len, x= 0,y = 0;
	char str[N];
	gets(str);
	len = strlen(str);
	for(int i = 0;i < len;i++){
		if(x==y){
			x++;
			if(str[i]=='p')
			ans--;
		}
		else{
			y++;
			if(str[i]=='g')
			ans++;
		}
	}
	cout<<ans;
}
	

Measured memory_bytes: 384
n,k=list(map(int,input().split()))
A=[i for i in range(1,n+1)]
B=list(map(int,input().split())) 
road=dict(zip(A,B))

#残りi回移動する、移動前に自分がいるところをj
#def walk(i,j):
#        return road[j]
#    else:
#        return walk(i-1,road[j])

j=1
C=[-1 for i in range(n)]
dp=dict(zip(A,C))
dp[1]=0
num=0
while dp[j]!=k-1:
    j=road[j]
    num=num+1
    if dp[j]== -1:
        dp[j]=num
    else:
        t=num-dp[j]
        pre=dp[j]
        itti=j
        break
    if num==k-1:
        print(road[j])
        exit()

mod=(k-pre)%t

for i in range(mod):
    itti=road[itti]
print(itti)
    



        
        
      
    
    



Measured memory_bytes: 61612
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
vector<int> v[601];
int n;
string s;
ll a[500002]={},asi=0;
queue<P> que;
int main() {
	cin>>s;
	n=s.size()+1;
	ll k=1;
	rep(i,1,n-1){
		if(s[i]!=s[i-1]){
			a[asi]=k;
			asi++;
			k=0;
		}
		k++;
	}
	a[asi]=k;
	asi++;
//	for(int i=0;i<asi;++i){
//		cout<<a[i]<<" ";
//	}
//	cout<<endl;
	ll ans=0;
	if(s[0]=='<'){
		for(int i=0;i<asi;i+=2){
			ll ma=max(a[i],a[i+1]);
			ll mi=min(a[i],a[i+1]);
			ans+=ma*(ma+1)/2;
			ans+=mi*(mi-1)/2;
		}
	}else{
		ans+=a[0]*(a[0]+1)/2;
		for(int i=1;i<asi;i+=2){
			ll ma=max(a[i],a[i+1]);
			ll mi=min(a[i],a[i+1]);
			ans+=ma*(ma+1)/2;
			ans+=mi*(mi-1)/2;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2820
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.19 21:00:50
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    string s;cin >> s;
    if (s[s.size()-1] == 's') {
        cout << s << "es" << endl;
    }
    else {
        cout << s << "s" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.14159265358979323846
#define pdd pair<double,double>
bool comp(int a,int b)
{
	return a>b;
}
long long bigpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main() 
{
	int n;
	cin>>n;
	int x,y;
	int a[n];
	int b[n];
	vector<pair<int,int> > v;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		v.push_back({x,y});
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++)
	{
		a[i]=v[i].first+v[i].second;
		b[i]=v[i].first-v[i].second;
	}
	int mx1=INT_MIN;
	int mx2=INT_MIN;
	int mn1=a[0];
	int mn2=b[0];
	for(int i=1;i<n;i++)
	{
		mx1=max(mx1,a[i]-mn1);
		mx2=max(mx2,b[i]-mn2);
		mn1=min(mn1,a[i]);
		mn2=min(mn2,b[i]);
	}
	cout<<max(mx1,mx2);
	
	return 0;    
}

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

int main(){
	int n;
	while(cin >> n, n){
		vector<int> vi(n);
		for(int i = 0; i < n; i++){
			cin >> vi[i];
		}
		sort(vi.begin(), vi.end());
		long long ans = 0, sum = 0;
		for(int i = 0; i < n; i++){
			ans += sum;
			sum += vi[i];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1244
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << max({a * 10 + b + c, a + b * 10 + c, a + b + c * 10}) << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = dict()

for i in range(n): # 辞書型でカウント
  s = input()
  a.setdefault(s, 0)
  a[s] += 1
  
ans = []
mx = 0
for key, value in a.items(): # 最大値のものをリストに入れる
  if mx < value:
    mx = value
    ans = [key]
  elif mx == value:
    ans.append(key)

ans.sort() # 辞書順に出力
for i in ans:
  print(i)

Measured memory_bytes: 32096
#include <bits/stdc++.h>
using namespace std;
long long a, b, c;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> a >> b >> c;
if (a+b+c<22) cout << "win";
else cout << "bust";
return 0;
}


Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
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;
}

int main() {
    ll n;
    cin >> n;
    ll h[n];
    rep(i, n) {
        cin >> h[i];
    }

    ll dp[n];
    memset(dp, MOD, sizeof(dp));
    dp[0] = 0;
    FOR(i, 1, n) {
        chmin(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
        if (i>1) {
            chmin(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
        }
    }

    print(dp[n-1]);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

const int maxn = 1e5+100;
int arr[maxn][4],dp[maxn][4];


int main() {
	std::ios::sync_with_stdio(false);
	int n,a,b,c,ans = 0;
	cin >> n;
	for(int i=1; i<=n; i++) cin >> arr[i][1] >> arr[i][2] >> arr[i][3];
	for(int i=1; i<=n; i++) {
		for(int k=1; k<=3; k++) {
			for(int j=1; j<=3; j++) {
				if(k==j) continue;
				dp[i][k] = max(dp[i-1][j]+arr[i][k],dp[i][k]);
			}
		}
	}
	cout << max(max(dp[n][1],dp[n][2]),dp[n][3]);
	return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
typedef long long ll;
int q;
ll l,r;
int main(void){
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		ll n;
		int p;
		char c;
		scanf("%d %c %lld",&p,&c,&n);
		if(c=='(')l+=n;
		if(c==')')r+=n;
		printf("%s\n",l==r?"Yes":"No");
	}
	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,P;
char S[202020];
ll mk[20202];
ll i, j, k;
int main(){
    scanf("%s", S);
    N = strlen(S);
    P = 2019;
    j = 1;
    k = 0;
    ++mk[0];
    fornum(i,0,N){
        k += (S[N - 1 - i] - '0') * j;
        k %= P;
        ++mk[k];
        j *= 10;
        j %= P;
    }
    ll ans = 0;
    fornum(i,0,P){
        ans += (mk[i] - 1) * mk[i] / 2;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 4028
I=lambda:map(int,input().split())
n,p = I()
s=[0]
for i in I():
  s += [s[-1] + i]

for t in range(1, n + 1):
  m = 5 * s[n] + t * p
  c = n - t * 2
  while c > 0:
    m += 2 * s[c]
    c -= t
  a = m if t == 1 else min(a,m)
print(a + n * p)

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
   // cin>>tt;
    while(tt--)
    {
        int n; cin>>n;
        cout<<fixed ;
        cout<<setprecision(13);
        int arr[n];
        for (int i = 0; i < n; i++)
		{
			cin>>arr[i];
		}
		sort(arr,arr+n);//,greater<int>());
		double ans = 0.0;
		int cnt = 1;
		ans += arr[0];
		for (int i = 1; i < n; i++)
		{
			ans += cnt * arr[i];
			cnt *= 2;
		}
		cout<<ans/cnt;
		
    }
    return 0;

}


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

namespace ConsoleApp15
{
    class Class211
    {
        static void Main()
        {
            var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = AB[0], B = AB[1];
            int count = 0;
            for(int i = 0; i < 2; i++)
            {
                if (A > B) { count += A;A--; }
                else { count += B;B--; }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    set<int> st;
    rep(i, n) {
        int a;
        cin >> a;
        if(st.count(a)) {
            cout << "NO" << endl;
            return 0;
        }
        st.insert(a);
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

#define MAX_S 4000
#define MAX_T 4000
template<typename T> int longest_common_substring(T s,T t){
    int lens=s.size(), lent=t.size();
    static int dp[MAX_S+1][MAX_T+1];
    memset(dp,0,sizeof(dp));
    
    int maxi=0;
    
    rep(i,s.size()){
        rep(j,t.size()){
            if(s[i]==t[j])  dp[i+1][j+1] = dp[i][j]+1;
            else            dp[i+1][j+1] = 0;
            maxi = max(maxi,dp[i+1][j+1]);
        }
    }
    
    return maxi;
}


int main(){
    string a,b;
    while(cin>>a>>b){
        cout<<longest_common_substring(a,b)<<endl;
    }
}

Measured memory_bytes: 65652
# -*- coding: utf-8 -*-

def fifty_fifty(word):
    r = {}
    for s in list(word):
        if s in r:
            r[s] += 1
        else:
            r[s] = 1
    if len(r) == 2 and max(r.values()) == 2:
        return 'Yes'
    else:
        return 'No'

s = input()
print(fifty_fifty(s))

Measured memory_bytes: 3064
// scanf 等でエラーを出さないように追加
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <algorithm>
#include <numeric>
#include <set>
#include <functional>


using namespace std;


typedef long long ll;


int main() {

	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);

	bool isGoSitiGo = false;

	if (A == 7) {
		if (B == C && B == 5) {
			isGoSitiGo = true;
		}
	}
	else if (B == 7) {
		if (A == C && A == 5) {
			isGoSitiGo = true;
		}
	}
	else if (C == 7) {
		if (A == B && A == 5) {
			isGoSitiGo = true;
		}
	}

	if (isGoSitiGo) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };



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

	char temp = s[k - 1];
	rep(i, 0, s.size()) {
		if (i != k - 1) {
			if (s[i] != temp)s[i] = '*';
		}
	}
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dy[8] = {1, 0, -1, -1, -1, 0, 1, 1};

int sizeDx[3][4] = {{1, 1, -1, -1},{0, 0, 0, 0},{0, 0, 2, -2}};
int sizeDy[4][4] = {{1, -1, -1, 1},{0, 0, 0, 0},{2, -2, 0, 0}};
int main(void){
	int stat[10][10] = {0};
	int x, y, size;
	char c;
	while(cin >> x >> c >> y >> c >> size){
		stat[y][x] += 1;
		rep(i,8){
			int nx = x + dx[i];
			int ny = y + dy[i];
			if(nx < 0 || ny < 0 || nx >= 10 || ny >= 10)continue;
			stat[ny][nx]++;
		}
		rep(i,4){
			int nx = x+sizeDx[size-1][i];
			int ny = y+sizeDy[size-1][i];
			if(nx < 0 || ny < 0 || nx >= 10 || ny >= 10)continue;
			if(size == 1){
				stat[ny][nx]--;
			}else if(size == 2){

			}else if(size == 3){
				stat[ny][nx]++;
			}
		}
	}
	int mx = 0;
	int zero = 0;
	rep(i,10)rep(j,10){
		mx = max(mx, stat[i][j]);
		if(stat[i][j] == 0)zero++;
	}
	FIN(zero);FIN(mx);

	return 0;
}

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

int A, B;

int main() {
 	cin >> A >> B;
	if(A==1) A+=13;
	if(B==1) B+=13;
	if (A > B){
        cout << "Alice" << endl;
	}
	if (A < B) {
		cout << "Bob" << endl;
	} 
	if (A == B) {
		cout << "Draw" << endl;
	}
}

Measured memory_bytes: 256
/*
* @author:  codancer
* @createTime:  2020-02-09, 20:08:29
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
double cal(int x){
	double now = x*(x+1)/2.0;
	now/=x;
	return now;
}
int main(){
	int n,k;
	cin>>n>>k;
	VI a(n+1);
	vector<double> pre(n+1);
	vector<double> x;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pre[i]=pre[i-1]+cal(a[i]);
	}
	double ans=0;
	for(int i=k;i<=n;i++){
		ans=max(ans,pre[i]-pre[i-k]);
	}
	printf("%.10lf\n",ans);
	return 0;
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

signed main(){
    int N;cin>>N;
    vector<int>v(N);
    rep(i,N)cin>>v[i];

    int ma=-1;
    rep(i,N)reps(j,i+1,N){
        int a=v[i]*v[j];
        stringstream ss;
        ss<<a;
        string s=ss.str();
        bool ok=true;
        rep(k,s.size()-1)ok&=s[k]+1==s[k+1];
        if(ok)chmax(ma,a);
    }
    cout<<ma<<endl;
    return 0;
}

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

int main()
{
    char s[100];
    scanf("%s", s);
    int n = strlen(s);
    int max = 0, len = 0;
    for(int i = 0; i < n; i++)
    {
       while(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G')
            {
                len++;
                i++;
            }
        if(len > max)
        {
            max = len;
            len = 0;
        }

    }
    printf("%d", max);
    return 0;
}


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

int main(void){

  int k,m,n,i;
  int sum; 
  vector <int> d1,d2;
  
  cin>>n;
  cin>>m;
  k=sqrt((double)m);
  for(i=1;i<=k;i++){
    if(m%i==0){
      d1.push_back(i);
      d2.push_back(m/i); 
   }
  }
   for(i=0;i<d2.size();i++){
    if(d2[i]!=0&&m/d2[i]>=n){
      cout<<d2[i]<<endl;
      return 0;
    }
  }
  for(i=d1.size()-1;i>=0;i--){
    if(d1[i]!=0&&m/d1[i]>=n){
      cout<<d1[i]<<endl;
      return 0;
    }
    }
  
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  int h, w; cin >> h >> w;
  int n; cin >> n;
  int ma = max(h, w);
  cout << (n - 1) / ma + 1 << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
    while(x){
        y%=x;
        if(y==0)break;
        x%=y;
    }
    return x+y;
}
int main(){
    int n,m;
    cin>>n>>m;
    long long a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    long long lcm=a[0]/2;
    for(int i=1;i<n;i++){
        lcm*=a[i]/2/gcd(lcm,a[i]/2);
        if(lcm>m){
            cout<<"0"<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        if(lcm%a[i]==0){
            cout<<"0"<<endl;
            return 0;
        }
    }
    cout<<(m+lcm)/lcm/2<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  if(n / 10 % 111 == 0 or n % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b,ans=0,x[100010];
    cin>>n>>a>>b;
    rep(i,n) cin>>x[i];
    rep(i,n-1){
        if((x[i+1]-x[i])*a<=b){
            ans+=(x[i+1]-x[i])*a;
        }else {
            ans+=b;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const int SIZE=17;

const ll MOD=1e9+7;

void add(ll &lhs,ll rhs){
    lhs=(lhs+rhs)%MOD;
}
int main(){
    int n;
    cin>>n;
    int xyz[3];
    for(int i=0;i<3;i++) cin>>xyz[i];

    vector<vector<ll>> dp(n+1,vector<ll>(1<<SIZE));
    dp[0][(1<<SIZE)-1]=1;

    vector<int> isAccept(1<<SIZE);

    for(int bit=0;bit<(1<<SIZE);bit++){
        int st=0;
        int buf=0;
        for(int i=0;i<SIZE;i++){
            buf++;
            if(!((bit>>i)&1) && xyz[st]==buf){
                st++;
                buf=0;
                if(st==3){
                    isAccept[bit]=true;
                    break;
                }
            }
        }
    }

    vector<ll> pow10(n);
    pow10[0]=1;
    for(int i=0;i+1<n;i++) pow10[i+1]=pow10[i]*10%MOD;

    ll res=0;
    int mask=(1<<SIZE)-1;
    for(int i=0;i<n;i++){
        for(int bit=0;bit<(1<<SIZE);bit++){
            if(dp[i][bit]==0) continue;
            for(int v=1;v<=7;v++){
                int nex=(bit<<v)+(1<<(v-1))-1;
                nex&=mask;
                add(dp[i+1][nex],dp[i][bit]);
            }
            add(dp[i+1][mask],3*dp[i][bit]);
        }
        for(int bit=0;bit<(1<<SIZE);bit++){
            if(isAccept[bit]){
                ll r=pow10[n-1-i];
                res+=r*dp[i+1][bit];
                res%=MOD;   
                dp[i+1][bit]=0;
            }
        }
    }

    cout<<res<<endl;
    
    
    return 0;
}


Measured memory_bytes: 43392
#include<bits/stdc++.h>
using namespace std;
#define     ll      long long int
vector<ll>v;
set<char>st;
int main()
{
    ll n,a=0,w=0,t=0,r=0;
    cin>>n;
    string s;
    while(n--){
        cin>>s;
        if(s=="AC") a++;
        if(s=="WA") w++;
        if(s=="TLE") t++;
        if(s=="RE") r++;
    }
        cout<<"AC"<<" "<<"x"<<" "<<a<<endl;
        cout<<"WA"<<" "<<"x"<<" "<<w<<endl;
        cout<<"TLE"<<" "<<"x"<<" "<<t<<endl;
        cout<<"RE"<<" "<<"x"<<" "<<r<<endl;


       return 0;
}


Measured memory_bytes: 3632
using System;

class QQ
{
    static void Main()
    {
        int i , j = 0;
        for( i = 1; i <= 9; i++)
        {
            for (j = 1; j <= 9; j++)
            {
                Console.WriteLine(i + "x" + j + "=" +(i*j));
            }
            

        }
    }
}

Measured memory_bytes: 8888
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  sort(all(s));
  for (int i = 1; i < s.size(); i++) {
    if (s[i - 1] == s[i]) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 3604
import math

X = int(input())
max_exp = 0

for b in range(1,50) :
    for p in range(2,10) :
        exp = int(math.pow(b,p))
        if (exp > X) :
            continue
        if (max_exp < exp)  :
            max_exp = exp

print(max_exp)

Measured memory_bytes: 3316
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;

int n,s,x;
void sum(int i,int k,int n){ 
	if(s==k&&n==0){
		x++;
		return ;
	}
	if(i>=10||n==0)
		return;
	sum(i+1,k,n);
	sum(i+1,k+i,n-1);
}
int main(){
	
	while(cin>>n>>s,n!=0||s!=0){
		x=0;
		sum(0,0,n);
		
		cout<<x<<endl;
	}
	
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

using namespace std;
const long long MOD = 1000000007; 

int main() {
  int h, w;
  cin >> h >> w;
  char maze[h][w];
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      cin >> maze[i][j];

  long long dp[h][w];
  dp[h-1][w-1] = 1LL;
  for (int i = h-1; i >= 0; --i) {
    for (int j = w-1; j >= 0; --j) {
      if (i == h-1 && j == w-1) continue;
      if (maze[i][j] == '#') continue;
      dp[i][j] = (((j < w-1 && maze[i][j+1] == '.') ? dp[i][j+1] : 0)
        + ((i < h-1 && maze[i+1][j] == '.') ? dp[i+1][j] : 0)) % MOD;
    }
  }
  cout << dp[0][0] << endl;

  return 0;
}


Measured memory_bytes: 9088
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- U.unfoldrN n (C.readInt.C.dropWhile isSpace) <$> C.getLine
    print $ solve n xs

solve :: Int -> U.Vector Int -> Int
solve n xs = U.foldl1' max . U.zipWith gcd ls $ U.tail rs
  where
    ls = U.scanl gcd 0 xs
    rs = U.scanr gcd 0 xs


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

class Program
{
  static void Main(string[] args)
  {
    const UInt64 modNum = 1000000007;

    uint N = uint.Parse(Console.ReadLine());
    string[] items = Console.ReadLine().Split(' ');

    UInt64[] A = Array.ConvertAll(items, UInt64.Parse);

    UInt64 sum = 0;
    UInt64 sumPartOfA = 0;

    //From back.
    for (int i = (int)N - 1; i > 0; --i)
    {
      sumPartOfA += A[i];
      sumPartOfA %= modNum;
      sum += (A[i - 1] * sumPartOfA) % modNum;
    }

    sum %= modNum;

    Console.WriteLine(sum);

    return;
  }
}

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

int main(void)
{
	int N, T, A, i, Y, Z = 10000000, ANS = 0;
	scanf("%d %d %d", &N,&T,&A);
	for(i=0;i<N;i++)
		{
		scanf("%d", &Y);
		if(abs(1000*T - 6*Y - 1000*A) < Z)
				ANS = i, Z = abs(1000*T - 6*Y - 1000*A);
		}
	printf("%d", ANS+1);
	return 0;
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  int c = abs(x - a);
  int d = abs(x - b);
  if (c < d) cout << "A" << endl;
  else cout << "B" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int W, H, N;
  cin >> W >> H >> N;
  vector<vector<int>> vec(N, vector<int>(3));
  for(int i=0; i<N; i++){
  	for(int j=0; j<3; j++){
    	cin >> vec.at(i).at(j);
    }
  }
  
  int x1=0, x2=W, y3=0, y4=H;
  
  for(int i=0; i<N; i++){
  	if (vec.at(i).at(2) == 1){
    	if(x1 < vec.at(i).at(0)){
        	x1 = vec.at(i).at(0);
        }
    }
    
    else if (vec.at(i).at(2) == 2){
    	if(x2 > vec.at(i).at(0)){
        	x2 = vec.at(i).at(0);
        }
    }
    
    else if (vec.at(i).at(2) == 3){
    	if(y3 < vec.at(i).at(1)){
        	y3 = vec.at(i).at(1);
        }
    }
    
    else {
    	if(y4 > vec.at(i).at(1)){
        	y4 = vec.at(i).at(1);
        }
    }
 
  }
  
  if((x2 < x1) || (y4 < y3)){
  	cout << 0 << endl;
  }
  else {
  	cout << (x2 - x1) * (y4 - y3) << endl;
  }
}

Measured memory_bytes: 256