akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] V = new int[n];
		int[] C = new int[n];

		for (int i = 0; i < n; i++) V[i] = sc.nextInt();
		for (int i = 0; i < n; i++) C[i] = sc.nextInt();
		int answer = 0;

		for (int i = 0; i < n; i++) {
			int v = V[i];
			int c = C[i];
			if (v-c > 0) 
				answer += (v-c);
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 21716
#include <stdio.h>

int main(void){
    int N, A, B;
    scanf("%d %d %d", &N, &A, &B);
    if(B<A || (A!=B && N==1)){
        printf("0\n");
        return 0;
    }
    long long ans = (long long)(N-1) * (B-A) + (A-B) + 1;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
[A, B, C, D] = [int(_) for _ in input().split(" ")]

current_turn = True
while (A > 0 and C > 0):
    if (current_turn):
        C -= B
    else:
        A -= D
    if (A > 0 and C > 0):
        current_turn = not current_turn
    else:
        break

if (current_turn):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9188
n = int(input())

ans = []
cnt = 0

for i in range(1, n+1):
    if cnt + i == n:
        ans.append(i)
        break
    elif cnt + i < n:
        cnt += i
        ans.append(i)
    else:
        dif = n - cnt
        ans[-dif] += dif
        break

for a in ans:
    print(a)

Measured memory_bytes: 9144
<?php
fscanf(STDIN, "%d%d", $l, $r);
if($r-$l>=2019){
  echo 0;
}else{
  $min = 10**10;
  for($x = $l; $x <= $r; $x++){
    for($y = $l; $y <= $r; $y++){
      if($x!=$y){
        $mod = ($x*$y)%2019;
        if($mod <= $min){
          $min = $mod;
        }
      }
    }
  }
  printf("%d", $min);
}

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

using ll=long long;
#define int ll

#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 pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream&os, const pair<t,u>&p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream&operator <<(ostream&os,const vc<t>&v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

template<class t>
void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

const int inf=LLONG_MAX/3;

struct waf{
	int mod;
	int pow(int x,int n)const{
		int a=1;
		while(n){
			if(n&1)a=a*x%mod;
			x=x*x%mod;
			n>>=1;
		}
		return a;
	}
	int inv(int x)const{
		return pow(x,mod-2);
	}
	vvc<pi> g;
	vi buf;
	bool res;
	void dfs(int v,int w){
		if(buf[v]!=-1){
			if(buf[v]!=w)res=false;
			return;
		}
		buf[v]=w;
		for(auto e:g[v]){
			int z=w*e.b%mod;
			dfs(e.a,z);
		}
	}
	waf(int m,const vvc<pi>&gg):mod(m),g(gg.size()),buf(g.size(),-1),res(true){
		rep(i,gg.size()){
			for(auto e:gg[i]){
				g[i].pb(e);
				g[e.a].eb(i,inv(e.b));
			}
		}
		dmp(g);
		rep(i,g.size())if(buf[i]==-1)
			dfs(i,1);
		dmp(buf);
	}
	
};

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n,m;cin>>n>>m;
	vvc<pi> g(n);
	rep(_,m){
		int a,b,x;cin>>a>>b>>x;
		a--;b--;
		g[a].eb(b,x);
	}
	
	vi ms{1100000009,1100000017,1100000051,1100000059,1100000081};
	for(auto w:ms){
		if(!waf(w,g).res){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}



Measured memory_bytes: 19268
n = int(input())
A = list(map(int, input().split()))[::-1]
B = list(map(int, input().split()))[::-1]
ans = 0

for i, b in enumerate(B):
    ans += min(A[i], b)
    remain = max(0, b - A[i])
    ans += min(A[i + 1], remain)
    A[i + 1] = max(0, A[i + 1] - remain)

print(ans)

Measured memory_bytes: 18348
def main():
    N = int( input())
    A = list( map( int, input().split()))
    ans = 1000
    stock = 0
    stock_price = 1000
    for i in range(N-1):
        a = A[i]
        # print(i, stock_price,a)
        if stock > 0 and stock_price <= a:
            ans += stock*a
            stock = 0
        # print("ans", ans)
        if A[i+1] < a:
            pass
        else:
            stock += ans//a
            ans -= ans//a*a
            stock_price = a
        # print(ans, stock)
    if stock_price < A[N-1]:
        ans += stock*A[N-1]
    else:
        ans += stock*stock_price
    print(ans)
            
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 8932
n,m,k = map(int,input().split())
MOD = 998244353

def pk(x,n,mod):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % mod
        x = x ** 2 % mod
        n //= 2

    return K * x % mod

nck = [0]*n
kake = [0]*n

a = m
for i in range(n):
    kake[i] = a
    a = a*(m-1)%MOD
    
a = 1
for i in range(n):
    nck[i] = a
    a = int(a * (n-1-i) * pk(i+1,MOD-2,MOD)) % MOD
    
ans = 0
for i in range(k+1):
    ans = (ans + (nck[i] * kake[n-1-i] % MOD)) % MOD
    
print(ans)

Measured memory_bytes: 94036
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 


 
int main(){
	//in_o();
	int n;
	cin>>n;
	int x=ceil((float)n/1.08);
	if(floor(x*1.08)==n)
		cout<<x<<endl;
	else
		cout<<":("<<endl;
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == '1') {
      S.at(i) = '9';
    }
    else if (S.at(i) == '9') {
      S.at(i) = '1';
    }
  }
  cout << S << endl;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashSet;


fn main() {
  let n = read::<i64>();
  let mut uniq = HashSet::new();
  let mut rainbow = 0;
  for _ in 0..n {
    let a = read::<i64>();
    if 1 <= a && a <= 399 {
      uniq.insert("gray");
    } else if 200 <= a && a <= 799 {
      uniq.insert("brown");
    } else if 800 <= a && a <= 1199 {
      uniq.insert("green");
    } else if 1200 <= a && a <= 1599 {
      uniq.insert("water");
    } else if 1600 <= a && a <= 1999 {
      uniq.insert("blue");
    } else if 2000 <= a && a <= 2399 {
      uniq.insert("yellow");
    } else if 2400 <= a && a <= 2799 {
      uniq.insert("orange");
    } else if 2800 <= a && a <= 3199 {
      uniq.insert("red");
    }

    if 3200 <= a {
      rainbow += 1;
    }
  }
  println!("{} {}", max(1, uniq.len()), uniq.len() + rainbow);
}


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

using namespace std;

int main(){
    int M,D;
    cin >> M >> D;

    int i,j;
    int ans=0;

    for(j=2;j<=M;j++){
        for(i=2;i<=D;i++){
            int dten=i/10;
            int done=i%10;
            if(dten>=2 && done>=2){
                if(dten*done==j){
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    printv(a);
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n,a,b;
  cin>> n>>a>>b;
  vll p(n);
  REP(i,n)cin>>p[i];
  vll v(3);
  REP(i,n){
    if(p[i]<=a)
      v[0]++;
    if(a<p[i] && p[i]<=b)
      v[1]++;
    if(b<p[i])
      v[2]++;
  }
  
  ll ans = min(v[2], min(v[1],v[0]));
  cout<<ans<<endl;

}

Measured memory_bytes: 256
MAIN : {
	my $s = <STDIN>;
	chomp $s;
	
	my @slist = unpack('c*', $s);
	
	my $max = scalar(@slist);
	
	my @alist = ();
	
	my $cnt = 0;
	my $listnum = 0;
	foreach my $a (@slist) {
		if ($listnum == 0) {
			push @alist, $a;
			$listnum++;
			next;
		}
		
		if (($alist[$listnum - 1] eq 48 and $a eq 49) or ($alist[$listnum - 1] eq 49 and $a eq 48)) {
			pop @alist;
			$listnum--;
			$cnt++;
		}
		else {
			push @alist, $a;
			$listnum++;
		}
	}
	
	print STDOUT $cnt * 2, "\n";
#	print STDOUT $listnum, "\n";
}

__END__


Measured memory_bytes: 19456
def len_burger(L):
    return 2**(L+2)-3
def num_ban(L):
    return 2**(L+1)-1

def eat(L,X):
    if L == 0: return 1
    if X == 1: return 0
    elif X <= len_burger(L-1)+1: return eat(L-1,X-1)
    elif X == len_burger(L-1)+2: return num_ban(L-1)+1
    elif X < 2*len_burger(L-1)+3: return num_ban(L-1)+1+eat(L-1,X-len_burger(L-1)-2)
    elif X == len_burger(L): return num_ban(L)

def solve():
    N,X = [int(s) for s in input().split() if s]
    
    print(eat(N,X))
    
solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int cnt =0;
  for(int i=0; i<=a; ++i){
    for(int j=0; j<=b; ++j){
      for(int k=0; k<=c; ++k){
        if(i*500 + j*100 + k*50 == x) cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <math.h>
#include <stdbool.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <chrono>
using namespace std;

int main(){

    int x, a;
    cin >> x >> a;

    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
line=[0]*n
line[0]=sum(a2)+a1[0]
for i in range(1,n):
    line[i]=line[i-1]+a1[i]-a2[i-1]
print(max(line))

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

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll n,d[110];
  cin>>n;
  rep(i,n)cin>>d[i];
  sort(d,d+n);
  ll ans=1;
  rep(i,n-1){
    if(d[i]<d[i+1]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3568
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable int mod = 10^^9 + 7;

void main()
{
    int h, w;
    readVars(h, w);

    writeln(repeat("#", w + 2).join);

    foreach(i ; 0 .. h) {
        auto s = readln.chomp;
        writeln("#", s, "#");
    }

    writeln(repeat("#", w + 2).join);
}


void readVars(T...)(auto ref T args)
{
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        writeln(line);
        throw new Exception("args num < input num");
    }
}

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

mt19937_64 llrand((int) chrono::steady_clock::now().time_since_epoch().count());

#define st first
#define nd second
#define pb push_back

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;

const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

int k;
string s;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> k;
  cin >> s;
  if(s.size() <= k) cout << s << "\n";
  else {
    while(s.size() != k) s.pop_back();
    s += "...";
    cout << s << "\n";
  }
}

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

#define REP(i, a, b) for(i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

#define mod 26;

void swap(char *a, char *b){
  char tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
  return;
}

int main(){
  int i, j, k;
  int n;
  int tmp;
  int diff;
  char str[100+1];
  int a[100], b[100];

  while(1){
    scanf("%d", &n); if(n == 0) break;
    scanf("%s", str);
    rep(i, n) scanf("%d %d", &a[i], &b[i]);

    for(i=n-1; i>=0; i--){
      swap(&str[a[i]-1], &str[b[i]-1]);

      diff = abs(a[i] - b[i]) % mod;

      tmp = str[a[i]-1];
      tmp += diff; if(tmp > 'z') tmp -= 26;
      str[a[i]-1] = tmp;

      tmp = str[b[i]-1];
      tmp += diff; if(tmp > 'z') tmp -= 26;
      str[b[i]-1] = tmp;
    }

    printf("%s\n", str);
  }

  return 0;
}

Measured memory_bytes: 0
N = int(input())
a = 0

if N>=100:
    a = N % 100
    if N >= 10:
        a = a % 10
elif N >= 10:
    a = N % 10
else:
    a = N

if a == 0:
    print("pon")
elif a == 1:
    print("pon")
elif a == 6:
    print("pon")
elif a == 8:
    print("pon")
elif a == 3:
    print("bon")
else:
    print ("hon")

Measured memory_bytes: 9056
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
ans = []
c = 1
for i in a:
    for j in range(i):
        ans.append(c)
    c += 1
for i in range(H):
    for j in range(W):
        if i % 2 == 0:
            print(ans[i * W + j], end = "")
        else:
            print(ans[i * W + W - 1 - j], end = "")
        if j < W - 1:
            print(" ", end = "")
        else:
            print()

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  char c;
  int judge=0;
  for(int i=0;i<n;i++){
    cin>>c;
    if(c=='Y') judge=1;
  }
  if(judge) cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, C, K;
  cin >> N >> C >> K;
  vector<long> T(N);
  for(int i = 0; i < N; i++){
    cin >> T.at(i);
  }
  sort(T.begin(), T.end());
  long ans = 0, time = T.at(0), human = 1;
  for(int i = 1; i < N; i++){
    if(time + K >= T.at(i) && human + 1 <= C){
      human++;
    } else {
      ans++;
      time = T.at(i);
      human = 1;
    }
  }
  ans++;
  cout << ans << endl;
  return 0;
}

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

typedef int32_t i32;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

#define POS(l, r) ((l) * (n + 1) + (r))

void run (void) {
  for (;;) {
    i32 n;
    scanf ("%" SCNi32, &n);
    if (n == 0) break;
    i32 *a = ALLOC (n, i32);
    for (i32 i = 0; i < n; ++i) {
      scanf ("%" SCNi32, a + i);
    }
    i32 *dp = ALLOC ((n + 1) * (n + 1), i32);
    for (i32 len = 2; len <= n; ++len) {
      for (i32 l = 0; l <= n - len; ++l) {
        i32 r = l + len;
        i32 max = 0;
        for (i32 m = l + 1; m < r; ++m) {
          max = MAX (max, dp[POS(l, m)] + dp[POS(m, r)]);
        }
        for (i32 m = l + 1; m < r; ++m) {
          if (dp[POS(l + 1, m)] == m - l - 1 && ABS (a[l] - a[m]) <= 1) {
            max = MAX (max, m + 1 - l + dp[POS(m + 1, r)]);
          }
        }
        dp[POS(l, r)] = max;
      }
    }
    printf ("%" PRIi32 "\n", dp[POS(0, n)]);
  }
}

int main (void) {
  run();
  return 0;
}



Measured memory_bytes: 17744
#include <stdio.h>

int main() {
    int i, n, count = 0;
    scanf("%d", &n);
    int arr[n];

    for(i=0; i<n; i++) {
        scanf("%d", &arr[i]);
    }

    for(i=0; i<n; i++) {
        if(arr[i] != i+1)
            count++;
    }

    if(count>2)
        printf("NO\n");
    else
        printf("YES\n");

    return 0;
}


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

int main()
{
    int c[3][3];
    vector<int> a(3);
    vector<int> b(3);
    bool flg = true;

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }
    a[0] = 0;
    b[0] = c[0][0] - a[0];

    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];

    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (c[i][j] != (a[i] + b[j]))
            {
                flg = false;
            }
        }
    }
    if (flg)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,t = inpl()
wv = sorted([inpl() for _ in range(n)])
dp = [[0]*t for _ in range(n+1)]

for i in range(n-1):
    w,v = wv[i]
    for j in range(t):
        if j < w:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j] , dp[i][j-w] + v)
res = 0
for i in range(n):
    tmp = dp[i][t-1] + wv[i][1]
    res = max(res, tmp)
print(res)

Measured memory_bytes: 137688
// template version 1.2
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0LL)
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

template<typename A, size_t N, typename T> // n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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

int gcd(int a, int b){
  if (b>a) swap(a,b);
  if (b==0) return a;
  return gcd(b, a%b);
}

int solve(){
  int n,k;cin>>n>>k;
  int a[n]; rep(i, n) {cin>>a[i];}
  if (*max_element(a, a+n) <k) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  int p = a[0];
  rep(i, n){
    p = gcd(p, a[i]);
  }
  dump(p);

  cout << (k%p==0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 1; i < 10001; ++i) {
		if (int(i * 0.08) == a && int(i * 0.1) == b) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}

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

template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
	for (auto &x : v) is >> x;
	return is;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<int> a(n); cin >> a;
	long long ans = 0;
	int mx = -1;
	for (int i = 0; i < n; i++) {
		mx = max(mx, a[i]);
		ans += max(mx - a[i], 0);
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 3924
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int n;
void in(){
    cin >> n;
}

void solve(){

    double ans = 0.0;
    double bit = 0.0;

    rep(i,0,n){
        double m; cin >> m;
        string t = raw_input();
        if(t == "JPY"){
            ans += m;
        }else{
            bit += m;
        }
    }

    print(ans + bit * 380000.0);


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#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 pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,m,a,b,c;
ll dp[310][310][310]; //最右のindex
vector<P> vec[310];

bool ch(int i,int j,int k){
	int r=max(i,max(j,k));
	for(auto s:vec[r]){
		if(((s.first<i)+(s.first<j)+(s.first<k))!=s.second) return 0;
	}
	
	return 1;
}

int main(){
	cin >> n >> m;
	REP(i,0,m) cin >> a >> b >> c,vec[b].push_back(P(a-1,c));
	
	dp[0][0][0]=1;
	REP(i,0,n){
		REP(j,0,n){
			REP(k,0,n){
				int ma=max(i,max(j,k));
				if(ch(i,j,ma+1)) (dp[i][j][ma+1]+=dp[i][j][k])%=MOD;
				if(ch(i,ma+1,k)) (dp[i][ma+1][k]+=dp[i][j][k])%=MOD;
				if(ch(ma+1,j,k)) (dp[ma+1][j][k]+=dp[i][j][k])%=MOD;
			}
		}
	}
	
	ll s=0;
	REP(i,0,n+1){
		REP(j,0,n+1){
			s+=dp[n][i][j];
			s+=dp[i][n][j];
			s+=dp[i][j][n];
		}
	}
	cout << s%MOD << endl;
	return 0;
}


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

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        String α = next();

        if(α.toLowerCase().equals(α)){
            System.out.println('a');
        }
        else {
            System.out.println('A');
        }
 

    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32680
#include<stdio.h>

int n,A[20];

int main(){
  int q,M,i;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}





int solve(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res  =solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

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

const int INF = 1e9;
const int MAX_V = 1e5;
const int MAX_E = 5e5;

// first: distance, second: ID of the point
using P = pair<int, int>;

// first: to, second: cost
vector<P> G[MAX_V];
int dist[MAX_V];

// ダイクストラ
void dijkstra(int s) {  // s: start
  priority_queue<P, vector<P>, greater<P> > q;
  dist[s] = 0;
  q.push(P(0, s));

  while (!q.empty()) {
    P p = q.top();
    q.pop();
    int v = p.second;
    // if (dist[v] < p.first) continue;

    for (int i = 0; i < G[v].size(); i++) {
      int to = G[v][i].first;
      int cost = G[v][i].second;
      if (dist[to] > dist[v] + cost) {
        dist[to] = dist[v] + cost;
        q.push(P(dist[to], to));
      }
    }
  }
}

int main() {
  int V, E, r;
  cin >> V >> E >> r;
  rep(i, V) dist[i] = INF;
  rep(i, E) {
    int s, t, d;
    cin >> s >> t >> d;
    G[s].push_back(P(t, d));
    // 無向グラフの場合は両方に追加
    // G[t].push_back(P(s, d));
  }
  dijkstra(r);
  rep(i, V) {
    if (dist[i] == INF)
      cout << "INF" << endl;
    else
      cout << dist[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 12992
while True:
    n = int(input())
    if n == 0:
        break

    s = list(map(int, input().split()))
    m = sum(s) / n
    v = 0
    for si in s:
        v += (si - m) ** 2
    ans = (v / n) ** 0.5
    print("{:.5f}".format(ans))


Measured memory_bytes: 5672
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    if(s.substr(0, 7) == "keyence" || s.substr(n-7, 7) == "keyence") {
        cout << "YES" << endl;
        return 0;
    }

    for(int l = 1; l <= n-2; l++) {
        for(int r = l; r <= n-2; r++) {
            string mae = s.substr(0, l);
            string ushiro = s.substr(r+1, n-(r+1));
            string t = mae + ushiro;
            if(t == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}

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

int N; long long L, T;
vector<long long> X;
vector<int> W;

int main() {
    cin >> N >> L >> T;
    X.resize(N); W.resize(N); for (int i = 0; i < N; ++i) cin >> X[i] >> W[i];
    vector<long long> tmp(N);
    for (int i = 0; i < N; ++i) {
        if (W[i] == 1) tmp[i] = (X[i] + T) % L;
        else tmp[i] = ((X[i] - T) % L + L) % L;
    }
    sort(tmp.begin(), tmp.end());
    long long count = 0;
    for (int i = 0; i < N; ++i) {
        if (W[i] == 1) count -= (T - (L - X[i]) + L) / L;
        else count += (T - (X[i] + 1) + L) / L;
    }
    count = (count % N + N) % N;
    vector<long long> res(N);
    for (int i = 0; i < N; ++i) res[(i+count)%N] = tmp[i];
    for (int i = 0; i < N; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

using Pdi = pair<long double, int>;

signed main(){

    int N; cin >> N;
    vec x(N), y(N);
    vector<Pdi> p(N);

    REP(i, N){
        cin >> x[i] >> y[i];
        long double theta = atan2((long double)x[i], (long double)y[i]);
        p[i] = Pdi(theta, i);
    }
    Sort(p);
    REP(i, N) p.pb(p[i]);

    int ans = 0;
    REP(i, N){
        int X = 0, Y = 0;
        REP(j, N){
            int i0 = p[i + j].s;
            X += x[i0]; Y += y[i0];
            Max(ans, X * X + Y * Y);
        }
    }
    Out(sqrt(ans));

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
 
int main() {
	int n, l, r, cnt = 0;
	int i, j;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> l >> r;

		for (j = l; j <= r; j++)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
}



Measured memory_bytes: 3576
#include<stdio.h>

int main()
{

	long int n,k,i,j;
  long double p[200001],max,sum;
  sum=0;
  max=0;
(void) scanf("%ld %ld",&n,&k);
  
  for (i=1;i<=n;i++)
  {
(void) scanf("%llf",&p[i]);
   p[i]=(p[i]+1)/2;
  }
  
  for (i=1;i<=k;i++)
  {
  	sum+=p[i];
  }
  
  max=sum;
  
  //if (n==k)
  //{
  //	printf("%llf",sum);
  //  return 0;
  
  //}
  
  //printf("%llf\n",sum);
  
  for (i=k+1;i<=n;i++)
   {
   sum=sum+p[i];
   sum=sum-p[i-k];
    //printf("%llf %llf %llf \n",p[i],p[i-k],sum);
    if (sum>max)
    {
    	max=sum;
    }   
  }
  
  
  printf("%llf",max);
  return 0;

}


Measured memory_bytes: 4848
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REP_S(i, n, s) for(int i = s; i < (int)(n); i++)

const int mod = 1e9 + 7;
ll dp[55][55][55 * 55 + 100] ={};

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

	int num = 0;
    int score = 0;
	cin >> num >> score;

    dp[0][0][0] = 1;
    REP(i, num)
    {
        REP(j, i + 1)
        {
            // nextJ * 2は保留ないしつないだ際に次の段で増える奇妙さが両側の線で発生するため
            REP(k, score + 1)
            {
                // 両方繋ぐ
                {
                    int nextJ = j;   // 残り数が変わらない
                    dp[i + 1][nextJ][k + nextJ * 2] += dp[i][j][k];
                    dp[i + 1][nextJ][k + nextJ * 2] %= mod;
                }
                // どちらも繋がない
                {
                    int nextJ = j + 1;   // 残り数が増える
                    dp[i + 1][nextJ][k + nextJ * 2] += dp[i][j][k];
                    dp[i + 1][nextJ][k + nextJ * 2] %= mod;
                }
                // 片側だけ別のにつなぐ
                {
                    int nextJ = j;   // 残り数が変わらない
                    int x = j * 2;  // 別のにつなぐつなぎ方はｊ通りでそれが両側
                    dp[i + 1][nextJ][k + nextJ * 2] += (dp[i][j][k] * x);
                    dp[i + 1][nextJ][k + nextJ * 2] %= mod;
                }
                // 両方別のにつなぐ
                if(j >= 1)
                {
                    int nextJ = j - 1;   // 残り数が減る
                    int x = j * j;       // それぞれのつなぎ方がるので
                    dp[i + 1][nextJ][k + nextJ * 2] += (dp[i][j][k] * x);
                    dp[i + 1][nextJ][k + nextJ * 2] %= mod;
                }
            }   
        }
    }
    cout << dp[num][0][score] << endl;
	return 0;
}

Measured memory_bytes: 67840
#include <stdio.h>
int main()
{
	int h, w;
	int i, j;
	while (1){
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0)break;
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1){
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> x(n);
    REP(i,n){
        cin >> x[i];
    }
    int cnt = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if(a*(x[i+1] - x[i]) <=b){
            cnt += a * (x[i + 1] - x[i]);
        }
        else{
            cnt += b;
        }
    }
    cout << cnt << endl;

    return 0;
}

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

struct UF {
  vector<int> par, siz;
  UF(int n): par(n), siz(n,1) {
  	for (int i = 0; i < n; i++) par[i] = i;
  }
  int find(int x) {
  	return par[x] == x ? x: par[x] = find(par[x]);
  }
  bool marge(int x, int y) {
  	x = find(x);
    y = find(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x,y);
    siz[x] += siz[y];
    par[y] = par[x];
    return true;
  }
  bool same(int x, int y) {
  	return find(x) == find(y);
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
  	cin >> v[i];
    v[i]--;
  }
  UF uf(n);
  vector<int> a(m), b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    uf.marge(v[a[i]], v[b[i]]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (uf.same(i, v[i])) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4924
#ifdef _LOCAL
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

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

    int N; cin >> N;
    vl A(N); REP(i, N) cin >> A[i];

    ll ans = 0;
    ll sum = 0;
    int r = 0;
    REP(l, N) {
        while(r < N && (sum & A[r]) == 0) {
            sum += A[r];
            r++;
        }
        ans += (r - 1) - l + 1;

        sum -= A[l];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int x;
  cin >> x;
  bool check =1;

  for (int i = x; i < x+100000; i++) {
    check = 1;
    for (int j = 2; j < sqrt(i); j++) {
      if (i%j == 0) {
        check = 0;
        break;
      }
    }
    if (check == 1) {
      cout << i << endl;
      break;
    }
  }
}  

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  char s[n + 1];
  scanf("%s", s);
  int r = 0;
  int w = 0;
  int ans[n];
  for (int i = 0; i < n; i++) {
    ans[i] = w;
    (*(s[i] == 'R' ? &r : &w))++;
  }
  printf("%d\n", r < n ? ans[r] : 0);
}


Measured memory_bytes: 2692
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
ab = min(AB,key = lambda x:x[1])
INF = float('inf')
dp = [INF]*(H+1)
mi_a = ab[0]
mi_b = ab[1]
dp[0] = 0
for i in range(1,H+1):
  if i<=mi_a:
    dp[i]=mi_b
  else:
    for k in AB:
      a = k[0]
      b = k[1]
      tmp = max(0,i-a)
      dp[i] = min(dp[i],dp[tmp]+b)
    
print(dp[H])

Measured memory_bytes: 42604
S = input()
s = set(S)
if ("N" in s and "S" not in s) \
 or ("S" in s and "N" not in s) \
 or ("W" in s and "E" not in s) \
 or ("E" in s and "W" not in s):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp  make_pair
#define pb  push_back
#define endl "\n"
#define rep(i,a,n) for(int i=a;i<n;i++)
const int mod = 1e9 + 7;
void solve() {
	int n;
	cin >> n;
	int m = 0;
	int a[n];
	rep(i, 0, n) {
		cin >> a[i];
	}
	rep(i, 0, n) {
		rep(j, i + 1, n) {
			rep(k, j + 1, n) {
				if (a[i] != a[j] and a[j] != a[k] and a[i] != a[k]) {
					if (a[i] + a[j] > a[k] and a[j] + a[k] > a[i] and a[i] + a[k] > a[j]) {
						m++;
					}
				}
			}
		}
	}
	cout << m << endl;
}
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int r1,c1,r2,c2;
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[2000005],R[2000005];
void make(){
	F[0] = 1;
	for(int i=1;i<2000005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<2000005;i++) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
int main(){
	cin>>r1>>c1>>r2>>c2; make(); ll ans=0;
	for(int i=r1;i<=r2;i++){
		//i choose 0 + ... i+c1-1 choose c1-1
		ans+=C(i+c2+1,c2)-C(i+c1,c1-1);
	}
	cout<<(ans%mod+mod)%mod<<endl;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int Max=0x3f3f3f3f;
ll dfs(ll n)
{
    if(n==1)return 1;
    return 2*dfs(n/2)+1;
}
int main()
{
    ll n;
    while(~scanf("%lld",&n))
    {
        ll cnt=dfs(n);
        printf("%lld\n",cnt);
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func split(num int)[]int {
	var splitNum []int
	
	for num > 0 {
      splitNum = append(splitNum,num%10)
      num /= 10	
	}

	return splitNum

}

func main() {
	var a,b int
	fmt.Scan(&a,&b)

	cnt := 0
	for i := a; i <= b; i++ {
		judge := true
		num := split(i)
		for j := 0; j < len(num)/2; j++ {
			if num[j] != num[len(num)-j-1] {
				judge = false
				break
			}
		}
		if judge {
			cnt++
		}
	}
	fmt.Println(cnt)
}

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


typedef unsigned long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    cin>>n;
    ll mx=1e18;
    vector<ll> a(n+1);
    ll flag=0;
    repA(i,1,n)
    {
        cin>>a[i];
        if(a[i]==0) flag=1;
    }
    if(flag==1)
    {
        cout<<0<<'\n';
        return 0;
    }
    ll ans=1;
    repA(i,1,n)
    {
        ll prev=ans;
        // ans=ans*a[i];
        if(ans*a[i]>mx || ans*a[i]<prev)
        {
            // flag=0;
            cout<<"-1"<<'\n';
            return 0;
            // break;
        }
        ans*=a[i];
    }
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3940