akhauriyash/Code-Regression huggingface dataset:
def A():
    print(int(input())**3)

def B():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]

    points = B[A[0]-1]
    previous = A[0]-1
    #print(points)
    for i in range(1, N):
        points += B[A[i]-1]
        if A[i]-1 == previous+1:
            points += C[previous]
        #print(points)
        previous = A[i]-1
    
    print(points)

def C():
    N = int(input())
    B = [int(i) for i in input().split()]

    s = B[0]
    temp = B[0]
    for i in range(1, len(B)):
        if B[i] > temp:
            s += temp
        else:
            s += B[i]
        
        temp = B[i]
    
    s += temp

    print(s)

C()

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

int main() {
  int N,M;
  cin >> N >> M;
  vector< pair<int,int> > ab(M);
  REP(i,M) {
    cin >> ab[i].first >> ab[i].second;
  }
  sort(ab.begin(), ab.end());
  int r = ab[0].second;
  int ans = 1;
  REP(i,M) {
    if ( ab[i].second < r ) { r = ab[i].second; }
    if ( ab[i].first >= r ) { 
      ans++;
      r = ab[i].second;
    }
//    cout << i << " : " << ab[i].first << " "  << ab[i].second << " : " << r << " " << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define ABS(x) (x) < 0 ? -(x) : (x)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int n;
    cin >> n;
    int data[n + 1] = {};

    REP (i, n) {
        scanf("%d", &data[i + 1]);
        data[i + 1] += data[i];
        fprintf(stderr, "%d ", data[i + 1]);
    }
    OUT("");

    int minv = INT_MAX;
    FOR (i, 1, n) {
        minv = min(minv, ABS(data[n] - data[i] - data[i]));
    }

    OUT(minv);
    return 0;
}



Measured memory_bytes: 256
num = int(input())

base_t = 0
base_x = 0
base_y = 0
judge = True
for i in range(num):
    t, x, y = map(int, input().split())
    if (abs(base_t-t) - abs(base_x-x) +abs(base_y-y)) %2 == 0 and (abs(base_t-t) - abs(base_x-x) -abs(base_y-y)) >= 0:
        base_x = x
        base_y = y
        base_t = t
    else:
        judge = False
        break

print("Yes" if judge else "No")

Measured memory_bytes: 3064
N,M = gets.split.map(&:to_i)
AB = readlines.map {|s| s.split.map(&:to_i) }

rooms = Array.new(N+1) { [] }
AB.each.with_index(1) do |(a,b),i|
  rooms[a] << b
  rooms[b] << a
end

if rooms[1..-1].any?(&:empty?)
  puts "No"
else
  ans = []
  que = [1]
  until que.empty?
    i = que.shift
    rooms[i].each do |j|
      unless ans[j]
        ans[j] = i
        que << j
      end
    end
  end
  puts "Yes"
  puts ans[2..-1]
end


Measured memory_bytes: 62272
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    if (n % k == 0) {
        cout << 0 << endl;
    }
    else cout << 1 << endl;
}

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

int main(){
  long long X,Y;
  cin>>X>>Y;
  
  int count=1;
  
  for(int i=0;;i++){
  if(X*2<=Y){
    X=2*X;
    count++;
  }
    else if(X*2>Y){
      break;
    }
  }
  
  cout<<count;
}
    

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;
typedef long long ll;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
ll ok(ll n){
  ll k=n;
  ll cu=0;
  while(k%2==0){
    k/=2;
    cu++;
  }
  return cu;
}
int main(){
  ll n,m;
  cin>>n>>m;
  vll a(n);
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    a[i]/=2;
  }
  ll k=ok(a[0]);
  
  rep(i,n){
    if(ok(a[i])!=k){
      COUT(0);
      return 0;
    }
    a[i]>>=k;
  }
  m>>=k;
  ll j=1;
  rep(i,n){
    j=lcm(j,a[i]);
    if(j>m){
      cout<<0<<endl;
      return 0;
    }
  }
  m/=j;
  COUT((m+1)/2);
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sum = 0, add = 0;

		for (int i = 1; i <= N; i++) {
			if (String.valueOf(i).length() == 1 && a <= i && i <= b) {
				sum += i;
			} else {
				int j = 0;
				add = 0;
				while (j < String.valueOf(i).length()) {
					add += Integer.valueOf(String.valueOf(i).substring(j, j + 1));
					j++;
				}
				if (a <= add && add <= b) {
					sum += i;
				}
			}
		}
		
		System.out.println(sum);

		sc.close();
	}
}

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

int main() {
	ll n;
	cin >> n;
	/*
	for (ll m=1;m<=n;m++) {
		ll p = n/m;
		ll r = n%m;
		printf("m=%3lld, p=%3lld, r=%3lld", m, p, r);
		if (p==r) printf(":same");
		printf("\n");
	}
	*/
	ll k_max = sqrt((double)n) + 1LL;
	ll ans = 0;
	for (ll k=1;k<=k_max;k++) {
		if (n%k==0) {
			ll m = n/k-1;
			if (m>=1 && k<=m-1) ans += m;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  char mat[2][3], temp[2][3];
  string ans = "NO";
  rep(i,2){
    rep(j,3)cin >> mat[i][j];
  }
  if(mat[0][0] == mat[1][2] and mat[0][1] == mat[1][1] and mat[0][2] == mat[1][0])ans = "YES";
  cout << ans << endl;

}


Measured memory_bytes: 256
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
if count==N:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <vector>
#include <deque>
#include <math.h>
#include <algorithm>
#include <map>

using namespace std;
int main() {
    int A,B;
    cin >> A >> B;
    if(A>=13){
        cout << B;
    }else if(A>=6){
        cout << B/2;
    }else{
    cout << 0;
    }
    return 0;
}

Measured memory_bytes: 384
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                ans += 1

print(ans)

Measured memory_bytes: 9172
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	d := nextInt()
	if n%(2*d+1) != 0 {
		fmt.Println(n/(2*d+1) + 1)
	} else {
		fmt.Println(n / (2*d + 1))
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int dp[30010][4];

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

    vector<int> sum(n+1);
    sum[0] = 0;
    for (int i = 0; i < n; i++)
    {
        sum[i+1] = (sum[i]+a[i])%m;
    }
    map<int, int> cnt;
    ll ans = 0;
    for (int i = 0; i < n+1; i++)
    {
        ans += cnt[sum[i]]; // これより左側にあるものを足す
        cnt[sum[i]]++;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b;
  cin >> a >> b;
  if(a<=8&&b<=8){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  LL ans = 0;
  int N;
  cin >> N;
  vector<int> p(N + 1);
  p[N] = 0;
  FOR(i, 0, N) {
    cin >> p[i];

    if (i + 1 != p[i]) {
      p[i] = 0;
    }
  }

  FOR(i, 0, N) {
    if (p[i] > 0) {
      ans++;

      if (p[i + 1] > 0) {
        p[i + 1] = 0;
      }
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <string>
#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

using namespace std;
typedef long long ll;

int main() {
  string s;
  cin>>s;
  int n = s.length();
  reverse(s.begin(), s.end());
  while(!s.empty()) {
    char c = s[0];
    if(c == 'm'){
      //eat maerd
      if(s.substr(0, 5) == "maerd") {
        s = s.substr(5, s.length() - 5);
      }else{
        NO;
        break;
      }
    }else if(c == 'e'){
      //eat esare
      if(s.substr(0, 5) == "esare") {
        s = s.substr(5, s.length() - 5);
      }else{
        NO;
        break;
      }
    }else if(c == 'r'){
      //eat resare/remaerd
      if(s.substr(0, 6) == "resare") {
        s = s.substr(6, s.length() - 6);
      }else if(s.substr(0, 7) == "remaerd"){
        s = s.substr(7, s.length() - 7);
      }else{
        NO;
        break;
      }
    }else{
      NO;
      break;
    }
  }
  if(s.empty()) YES;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1ll)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 20;
int n,cnt,num[N],f[N][N];
il Split(ll x){
	cnt=0;
	while(x) num[++cnt]=x%10,x/=10;
}
it DFS(int pos,int pre,int limit,int tval){
	if(!pos) return pre;
	if(pre&&!limit&&f[pos][tval]!=-1) return f[pos][tval];
	int up=limit?num[pos]:9,res=0;
	for(ri i=0;i<=up;++i) if(abs(tval-i)<=1||!pre) res+=DFS(pos-1,pre||i,limit&&i==up,i);
	if(pre&&!limit) f[pos][tval]=res;
	return res;
}
it Calc(ll x){
	Split(x);
	return DFS(cnt,0,1,0);
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),del(f,-1);
	ll l=1,r=4000000000;
	while(l<r){
		if(Calc(mid)>=n) r=mid;
		else l=mid+1;
	}
	print(l);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]+n<='Z')
        {
            s[i]=s[i]+n;
           cout<<s[i];
        }
        else
        {
            ll temp=n-('Z'-s[i]+1);
            s[i]='A'+temp;
            cout<<s[i];
        }
        
    }


    
    return 0;
}

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


int main() {
    int A,B,C;
    cin >> A >> B >> C;
    if(A<=C&&B>=C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int a[4] = {0};
  
  	int N, M;
    cin >> N >> M;
  	for (int i = 0; i < M; i++) {
      	int s, c;
      	cin >> s >> c;
      	if (s == 1 && c == 0 && N != 1) {
            cout << -1 << endl;
          	return 0;
        }
      	if (a[s] != 0) {
          	if (a[s] != c) {
	          	cout << -1 << endl;
    	      	return 0;
            }
        } else {
          	a[s] = c;
        }
    }
  
  	if (a[1] == 0 && N != 1) {
      	a[1] = 1;
    }
  	for (int i = 1; i <= N; i++) {
      	cout <<  a[i];
    }
  	cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

typedef long long ll;
const ll mod = 998244353;
const int N = 3e5 + 100;
const int S = 7;

int n, m, id[N];
ll tot[10], fac[N], ans;
char str[N];

int main() {
  id['R'] = 1;
  id['G'] = 2;
  id['B'] = 4;
  fac[0] = ans = 1;
  scanf("%d", &n);
  m = 3 * n;
  for (int i = 1; i <= n; i++)
    fac[i] = fac[i - 1] * i % mod;
  scanf("%s", str + 1);
  for (int i = 1; i <= m; i++) {
    bool chk = false;
    int cur = id[(int) str[i]];
    for (int j = S - cur; j; j = (j - 1) & (S - cur)) {
      if (!tot[j]) continue ;
      chk = true;
      (ans *= tot[j]) %= mod;
      tot[j]--;
      if (cur + j != S) tot[cur + j]++;
      break ;
    }
    if (!chk) tot[cur]++;
  }
  (ans *= fac[n]) %= mod;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

string float_to_string(float f, int digits)
{
  if (f == 0) {
    f = 0;
  }
  ostringstream oss;
  oss << setprecision(digits) << setiosflags(ios::fixed) << f;
  return oss.str();
}

void calc_and_output(int *c)
{
  float x = (float)(c[1]*c[5]-c[2]*c[4])/(c[1]*c[3]-c[0]*c[4]);
  float y = (float)(c[0]*c[5]-c[2]*c[3])/(c[0]*c[4]-c[1]*c[3]);

  cout << float_to_string(x, 3) << " " << float_to_string(y, 3) << endl;
}

int main(int argc, char const* argv[])
{
  int c[6];

  string line;
  while (getline(cin, line)) {
    istringstream iss(line);
    int val;
    int c[6];
    for (int i = 0; i < 6; i++) {
      iss >> val;
      c[i] = val;
    };

    calc_and_output(c);
  }

  return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int a, b, c;
	cin >> a >> b >> c;
	int d = c - a - b;
	if(d > 0 && d * d > 4 * a * b) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define vi vector<ll>
#define all(v) v.begin(), v.end()

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

	string inp = "";
	cin >> inp;
	int arr[26];
	memset(arr, 0, sizeof(arr));

	rep(i, inp.length()) {
		arr[inp[i] - 'a']++;
	}
	bool flg = false;
	rep(i, 26) {
		if (arr[i] % 2 == 0) {
			flg = true;
		}
		else if (arr[i] % 2 == 1) {
			flg = false;
			break;
		}
	}
	if(flg == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	//cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <set>
//#include <delete>
using namespace std;
const int MAXN = 1e4 + 100;
set <pair< int ,  pair<int , int > > > st;
bool flag [ MAXN ]; 
vector <int> v2;
vector <pair < int , int>  > v [ MAXN ];
int m , n , sum , DEBUGGER = 0 ;
int main()
{
	cin >> n >> m;
	int root = 0;
	for(int i = 0 ; i < m ; i++)
	{
		int a , b , c;
		cin  >> a >> b >> c;
		v [ a ].push_back(make_pair(c , b));
		v [ b ].push_back(make_pair(c , a));
		if(a == root || b == root)
			st.insert(make_pair(c ,  make_pair(a , b )));
	}
	flag [ root ] = true;
	for(int i = 0 ; i < n - 1 ; i++)
	{
		while(true)
		{
			if(flag [ (*st.begin()).second.first ]== false || flag [ (*st.begin()).second.second ] == false)
			{
				DEBUGGER++;
				sum += (*st.begin()).first;
				//cerr << "THE WEIGHT IS : " <<  (*st.begin()).first  << " AND THE VERTEXES ARE : " << (*st.begin()).second.first << " , "<< (*st.begin()).second.second << endl;
				if(flag [ (*st.begin()).second.first] == false)
				{
					int small =  (*st.begin()).second.first;
					st.erase(st.begin());
					flag [small ] = true;
					for(int j = 0  ; j < v [ small ].size() ; j++)
					{
						st.insert(make_pair(v[ small ][ j ].first , make_pair(small , v[ small ][ j ].second)));
					}
				}
				else {
					flag [(*st.begin()).second.second ] = true;
					int small =  (*st.begin()).second.second ;
					st.erase(st.begin());
					for(int j = 0  ; j <  v [ small ].size() ;j++)
					{
						st.insert(make_pair(v[ small ][ j ].first , make_pair(small , v[ small ][ j ].second)));
					}
				}
				break;
			}
			else {
				st.erase(st.begin());
			}
		} 	
	} 
	cout << sum << endl;
}

Measured memory_bytes: 17492
#include<stdio.h>
#include<math.h>

int main(){
    int x, h;
    double s;

    while(1){
        scanf("%d %d", &x, &h);
        if(x == 0 && h == 0) break;

        s = x * x * 1.0;
        s += hypot(x/2.0, h) * x * 2;
        printf("%f\n", s); 
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}
int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}
/*
 
 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
int a=0, b=0, c = 0;

int main(void) {
	Rapid;//固定高速

	int n;
	cin >> n;
	if (n % 2 == 0)cout << n / 2 << rt;
	else cout << n / 2 + 1 << rt;

	please AC;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 310;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

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

ll N, A, B;

void solve() {
	cin >> N >> A >> B;
	if(N == 1 && A == B) cout << "1\n";
	else if(A > B || N == 1) cout << "0\n";
	else {
	ll mi = A + B + (N - 2) * A;
	ll mx = A + B + (N - 2) * B;
	cout << mx - mi + 1 << "\n";
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    priority_queue<ll> Am;
    priority_queue<ll, vector<ll>, greater<ll>> Ap;
    ll sm=0, sp=0;
    ll B = 0;

    rep(i,q){
        int tp;
        cin >>tp;
        if(tp==1){
            ll a,b;
            cin >>a >>b;

            if(Am.empty()){
                Am.push(a);
                sm += a;
            }
            else{
                if(Am.size() == Ap.size()){
                    ll t = Ap.top();
                    if(a < t){
                        Am.push(a);
                        sm += a;
                    }
                    else{
                        Am.push(t);
                        sm += t;
                        Ap.pop();
                        sp -= t;
                        Ap.push(a);
                        sp += a;
                    }
                }
                else{
                    assert(Am.size() == Ap.size()+1);
                    ll t = Am.top();
                    if(t < a){
                        Ap.push(a);
                        sp += a;
                    }
                    else{
                        Ap.push(t);
                        sp += t;
                        Am.pop();
                        sm -= t;
                        Am.push(a);
                        sm += a;
                    }
                }
            }
            B += b;
        }
        else{
            ll x = Am.top();

            ll ans = sp - sm + B;
            if(Am.size() > Ap.size()) ans += x;

            // dbg(vector<ll>(all(Am)));
            // dbg(vector<ll>(all(Ap)));
            cout << x << " " << ans << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int n, y; cin >> n >> y;
	y /= 1000;
	int k = y - n; bool flag = true;
	Rep(i, n + 1){
		Rep(j, i + 1){
			if(j * 4 + (i - j) * 9 == k){
				flag = false;
				cout << (i - j) << " " << j << " " << (n - i) << endl;
				break;
			}
		}
		if(!flag) break;
	}
	if(flag) cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
/**********************************************
 *Author*        :jxf378440404
 *Created Time*  : 2018/9/29 19:59:46

*********************************************/

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int n,a,b,c;
	while(~scanf("%d",&n)){
		c = n % 10;
		n /= 10;
		b = n % 10;
		n /= 10;
		a = n;
		if(a == 1) printf("9");
		else printf("1");
		if(b == 1) printf("9");
		else printf("1");
		if(c == 1) printf("9");
		else printf("1");
		printf("\n");
	}
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 100;


int main(int argc, char const *argv[])
{
	int N, T, c[MAX_N], t[MAX_N];
	vector<int> vec;
	cin >> N >> T;
	for (int i = 0; i < N; ++i)
	{
		cin >> c[i] >> t[i];
		if (t[i]<=T) vec.push_back(c[i]);
	}
	if (vec.size() < 1) cout << "TLE" << endl;
	else {
		sort(vec.begin(), vec.end());
		cout << vec[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[102];
ll gcd(ll l,ll r){
	if(r==0){
		return l;
	}
	return gcd(r,l%r);
}
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=a[0];
	for(int i=1;i<n;i++){
		ll now=a[i];
		ll GCD=gcd(max(ans,now),min(ans,now));
		ans=ans/GCD*now;
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())

for i in range(1, 10, 1):
    for j in range(1, 10, 1):
        if i*j == n:
            print("Yes")
            exit(0)

print("No")







Measured memory_bytes: 5116
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
ll MOD = 1e9+7;


int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    cout << s.substr(0, s.size() - 8) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
using ll = long long int;

int main(void) {
    string s, t;
    cin >> s >> t;
    if (s == t.substr(0, s.size())) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <cstdio>
using namespace std;
int A[4][4], N; bool C[4][4];
int main() {
  for(int i = 1; i <= 3; ++i) {
    for(int j = 1; j <= 3; ++j) {
      scanf("%d", &A[i][j]);
    }
  }
  scanf("%d", &N);
  for(int i = 1, b; i <= N; ++i) {
    scanf("%d", &b);
    for(int i = 1; i <= 3; ++i) {
      for(int j = 1; j <= 3; ++j) {
        if(A[i][j] == b) C[i][j] = true;
      }
    }
  }
  bool ok = false;
  for(int i = 1; i <= 3 && !ok; ++i) {
    int cnt = 0;
    for(int j = 1; j <= 3; ++j) {
      if(C[i][j]) ++cnt;
    }
    if(cnt == 3) ok = true;
  }
  for(int i = 1; i <= 3 && !ok; ++i) {
    int cnt = 0;
    for(int j = 1; j <= 3; ++j) {
      if(C[j][i]) ++cnt;
    }
    if(cnt == 3) ok = true;
  }
  int cnt = 0;
  for(int i = 1; i <= 3 && !ok; ++i) {
    if(C[i][i]) ++cnt;
  }
  if(cnt == 3) ok = true;
  cnt = 0;
  for(int i = 1; i <= 3 && !ok; ++i) {
    if(C[i][4-i]) ++cnt;
  }
  if(cnt == 3) ok = true;
  printf("%s\n", ok?"Yes":"No");
}

Measured memory_bytes: 128
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

n,p = list(map(int, input().split()))
s = input()

ans = 0

if p == 2 or p == 5:
    for i in range(n):
        a = int(s[n-1-i])
        if a % p == 0: ans += n-i

else:
    d = {0: 1}
    c = 0
    for i in range(n):
        c += (pow(10, i, p)*int(s[n-1-i])) % p
        c %= p
        if c not in d:
            d[c] = 1
        else:
            d[c] += 1

    for dd in d.values():
        ans += dd*(dd-1)//2

print(ans)











Measured memory_bytes: 10332
K = int(input())

# k_keta = len(str(K))
# print(k_keta)

#偶数は弾く
if K % 2 == 0:
    print(-1)
    exit()

r = 0
for i in range(1, 10**6): #何回目のループか
    r = (10 * r + 7) % K
    if r % K == 0:
        print(i)
        break
else:
    print(-1)

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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


int main(void){
  ios::sync_with_stdio(false);

  int k;
  cin >> k;

  ll ans = 0;
  FOR(i, 1, k+1){
    FOR(j, i+1, k+1){
      FOR(l, j+1, k+1){
        int tmp_gcd = gcd(i, j);
        int val = gcd(tmp_gcd, l);
        ans += val * 6;

      }
    }
  }

  FOR(i, 1, k+1){
    FOR(j, i+1, k+1){
      int val = gcd(i, j);
      ans += val * 6;
    }
  }

  FOR(i, 1, k+1){
    ans += i;
  }

  cout << ans << endl;



  return 0;
}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    vector<int>v(n);rep(i,n)cin>>v[i];
    int ans=0;
    int a; cin>>a;
    vector<int>u(a);rep(i,a)cin>>u[i];
    rep(i,a){
        int f=u[i];
        int imin=0;
        int imax=n;
        while(imax-imin>1){
            int mid=(imax+imin)/2;
            if(v[mid]>f)imax=mid;
            else imin=mid;
        }
        if(v[imin]==f)ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3308
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    if !block_given?
      @comp = Proc.new { |x, y| x <= y }
    else
      @comp = comp
    end
  end
  attr_reader :heap

  # def push(x)
  #   i = @node_num # 自分のノード番号
  #   @node_num += 1
  #   while i > 0
  #     par = (i - 1) / 2 # 親のノード番号
  #     break if @comp.call(@heap[par], x) # 逆転してないなら抜ける
  #     # 親ノードを下ろして自分を上に
  #     @heap[i] = @heap[par]
  #     i = par
  #   end
  #   @heap[i] = x
  # end
  def push(x)
    i = @node_num
    @node_num += 1
    while i > 0
      p = (i - 1) / 2
      break if @comp.call(@heap[p], x)

      @heap[i] = @heap[p]
      i = p
    end
    @heap[i] = x
  end

  alias_method(:<<, :push)

  def pop
    # 最(小|大)値
    ret = @heap[0]
    # 根にもってくる値
    @node_num -= 1
    x = @heap[@node_num]
    # 根から下ろしていく
    i = 0
    while i * 2 + 1 < @node_num
      # 子どうしを比較
      a = i * 2 + 1
      b = i * 2 + 2
      a = b if b < @node_num && !@comp.call(@heap[a], @heap[b])
      break if @comp.call(x, @heap[a])
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    ret
  end

  def get
    @node_num == 0 ? nil : @heap[0]
  end

  def empty?
    get.nil?
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
q = PriorityQueue.new { |x, y| x > y }
a.each do |e|
  q.push e
end

m.times do
  q.push(q.pop / 2)
end
puts q.heap.inject(:+)


Measured memory_bytes: 9556
#include <iostream>
#define llint long long

using namespace std;

llint K;
llint comb[605];
llint cnt[605];

int main(void)
{
	cin >> K;
	
	comb[0] = 1;
	for(int i = 1; i < 600; i++){
		comb[i] = comb[i-1] * (i+7) / i;
	}
	
	for(int i = 599; i >= 0; i--){
		cnt[i] = K / comb[i];
		K %= comb[i];
	}
	
	for(int i = 0; i < 600; i++){
		cout << "FESTIVA";
		for(int j = 0; j < cnt[i]; j++) cout << "L";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N;
    cin >> N;
    vi A(N);
    REP(i, N) cin >> A.at(i);

    ll total = accumulate(A.begin(), A.end(), 0LL);
    ll bestDiff = total + 1;
    ll left = 0;
    REP(i, N-1) {
        left += A.at(i);
        //ll left = accumulate(A.begin(), A.begin()+i+1, 0);
        ll right = total - left;
        //print(left << ", " << right);
        ll diff = abs(left - right);
        if (diff < bestDiff) {
            bestDiff = diff;
        }
    }
    print(bestDiff);
}

int main()
{
    solve();

    return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

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

signed main(){
    int N, M; cin >> N >> M;
    vector<P> job( N + 1 );
    REP( i, N ) cin >> job[i].first >> job[i].second;
    job[N].first = INF;
    sort( ALL( job ) );
    priority_queue<int> pq;

    int ans = 0, cur = 0;
    REPONE( i, M ){
        while( job[cur].first <= i ){
            pq.push( job[cur++].second );
        }
        if( !pq.empty() ){
            ans += pq.top(); pq.pop();
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 2936
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

int main()
{
    // input
    int A, B, H, M;
    scanf( "%d %d %d %d", &A, &B, &H, &M );

    // process
    double theta_a, theta_b;
    theta_a = 2 * M_PI * ( H * 60 + M ) / ( 12 * 60 + 0 );
    theta_b = 2 * M_PI * M / 60;
    double d_cos = A * std::cos( theta_a ) - B * std::cos( theta_b );
    double d_sin = A * std::sin( theta_a ) - B * std::sin( theta_b );
    double distance = std::sqrt( d_cos * d_cos + d_sin * d_sin  );

    // output
    printf( "%.10lf\n", distance );

    return 0;
}


Measured memory_bytes: 2532
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int A,B,C,D,E,F,M=0,SATO=0;
  double nod=0;
  cin >> A >> B >> C >> D>> E >> F;
  for(int i=0;i<=30;i++)
    for(int j=0;j<=30-i;j++)
      for(int k=0;k<=3000-i*100*A-j*100*B;k++)
        for(int w=0;w<=3000-i*100*A-j*100*B;w++){
          if(i == 0 && j == 0 && k == 0 && w == 0)
            continue;
          if(100*i*A+100*j*B+C*k+D*w <= F){
            if(C*k+D*w <= (A*i+B*j)*E){
              if(nod <= (double)(100*(C*k+D*w))/(double)(100*i*A+100*j*B+C*k+D*w)){
                nod = (double)(100*(C*k+D*w))/(double)(100*i*A+100*j*B+C*k+D*w);
                M = (100*i*A+100*j*B+C*k+D*w);
                SATO = C*k+D*w;
              }
            }
          }
        }
  cout << M << " " << SATO << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define ll long long
#define gcd __gcd

using namespace std;

typedef pair<int, int> pii;

const int MAX = 100;
int a, b, c;

int main(){
	ios_base::sync_with_stdio(0);
	cin >> a >> b >> c;
	if (c >= a && c <= b){
        cout << "Yes";
        return 0;
	}
	cout << "No";
}

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

ll N, R[200000];

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> R[i];

  vector<ll> m(N);
  m[N - 1] = R[N - 1];
  for(ll i = N - 2; i >= 0; i--) m[i] = max(m[i + 1], R[i]);

  ll ans = -(1LL << 60);
  REP(i, 0, N - 1) ans = max(ans, m[i + 1] - R[i]);

  cout << ans << endl;
}

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

const ll inf = 10000000000000LL;

int main() {
    int n, m;
    cin >> n >> m;
    int a[m], b[m], c[m];
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
    }

    ll d[n];
    for (int i = 0; i < n; i++) d[i] = -inf;
    d[0] = 0;
    bool update = true;
    int cnt = 0;
    ll ds;
    bool flag = false;

    while (update && cnt < 2 * n) {
        cnt++;
        update = false;
        for (int i = 0; i < m; i++) {
            if (d[b[i]] < d[a[i]] + c[i]) {
                d[b[i]] = d[a[i]] + c[i];
                update = true;
            }
        }
        if (cnt == n - 1) ds = d[n - 1];
        if (cnt == 2 * n && ds < d[n - 1]) flag = true;
    }

    if (flag) cout << "inf" << endl;
    else cout << d[n - 1] << endl;
    return 0;
}

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

using namespace std;

int main() 
{
    int n, x, z, i;
    string w, y;
    cin >> n;
    
    multimap<string, int> m;
    
    for(i = 0; i < n; i++)
    {
        cin >> x >> y;
        
        if(x == 0)
        {
            cin >> z;
            m.insert(make_pair(y, z));
        }
        else if(x == 1)
        {
            auto it = m.equal_range(y);
            while(it.first != it.second)
            {
                printf("%d\n", it.first->second);
                it.first++;
            }
        }
        else if(x == 2)
        {
            m.erase(y);
        }
        else if(x == 3)
        {
            cin >> w;
            
            auto L = m.lower_bound(y);
            auto R = m.upper_bound(w);
            
            while(L != R)
            {
                printf("%s %d\n", ((*L).first).c_str(), (*L).second);
                L++;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 24972
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,i,j,xlh,now,ans,a[200010],b[200010],f[200010],g[200010];
int main(){
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(i=1;i<n;i++){
		if(a[i]==a[i+1])continue;
		if(a[i]<=a[i+1]){
			xlh+=a[i+1]-a[i];
			g[a[i]+1]++;g[a[i+1]+1]--;
			f[a[i]+1]+=a[i]+1;f[a[i+1]+1]-=a[i]+1;
		}
		 else{
		 	xlh+=a[i+1]+m-a[i];
		 	g[a[i]+1]++;g[a[i+1]+m+1]--;
		 	f[a[i]+1]+=a[i]+1;f[a[i+1]+m+1]-=a[i]+1;
		 }
	}
	//printf("%lld\n",xlh);
	for(i=1;i<=m*2;i++){
		g[i]+=g[i-1];f[i]+=f[i-1];
		now=g[i]*i-f[i];
		if(i>m)j=i-m;
		 else j=i;
		b[j]+=now;
	}
	for(i=1;i<=m;i++){
	 ans=max(ans,b[i]);
	 //printf("%lld ",b[i]);
}
   //puts("");
	printf("%lld",xlh-ans);
}

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

using namespace std;

string s1 = "bdpq", s2 = "dbqp";

bool judge(string s) {
    int n = s.length();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 4; j++) {
            if (s[i] != s1[j]) continue;
            if (s[n - i - 1] != s2[j]) return false;
            break;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << (judge(s) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 512
open Printf
open Scanf

let () =
  let ss = scanf "%s " (fun x -> x) in
  let ln = String.length ss in
  let rec iter i =
    if i = ln - 1 then "No"
    else if String.sub ss i 2 = "AC" then "Yes"
    else iter (i + 1) in
  iter 0 |> printf "%s\n"


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  string s;
  cin >> s;
  int y;
  for(int i = 0 ; i <= 7 ; i ++ ){
    string a = s.substr(0,i);
    y = 7 - i;
    string b = s.substr((int)s.size() - y, y);
    a += b;
    if(a == "keyence"){
      cout << "YES\n";
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}


Measured memory_bytes: 256