akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 2000000000
#define M 998244353
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, x[200005], d[200005];
pair<int, int> p[200005];
int xx[200005], dd[200005], tot;
int f[200005], rt[200005];
stack<int> st;
void init(){
    n = read();
    for (int i = 1; i <= n; ++i)
        x[i] = read(), d[i] = read(), 
        p[i].first = x[i], p[i].second = d[i];
    sort(p + 1, p + n + 1);
}
int ssolve(){
    f[tot + 1] = 1;
    //for (int i = 1; i <= tot; ++i)
    //    cout << xx[i] << " " << dd[i] << endl;
    for (int i = tot; i >= 1; --i){
        rt[i] = i;
        while (!st.empty() && xx[i] + dd[i] > xx[st.top()])
            rt[i] = max(rt[i], rt[st.top()]), 
            st.pop();
        st.push(i);
        f[i] = (f[i + 1] + f[rt[i] + 1]) % M;
    }
    return f[1];
}
void solve(){
    int ans = 1;
    for (int i = 1; i <= n; ){
        int j = i, rt = p[i].first + p[i].second;
        while (j <= n && p[j].first < rt)
            rt = max(rt, p[j].first + p[j].second), ++j;
        tot = 0;
        for (int t = i; t < j; ++t)
            xx[++tot] = p[t].first, dd[tot] = p[t].second;
        ans = 1ll * ans * ssolve() % M;
        i = j;
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,k,n,m;
	cin>>n>>k;
	int ans=0;
	for(i=1;i<=n;i++)
	{
		cin>>j;
		ans+=min(j,k-j)*2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <unordered_set>
using namespace std;

int main(void){
    int N;
    cin >> N;
    int X[N];
    double ave = 0;
    for(int i = 0; i < N; i++){
        cin >> X[i];
        ave += X[i];
    }
    ave = round(1.0*ave/N);
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += pow(ave-X[i], 2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
List = [0 for _ in range(N)]
num = 0
for k in range(1,N):
  if S[k-1] == "A" and S[k] == "C":
    num += 1
  List[k] = num
  
for i in range(Q):
  l , r = map(int, input().split())
  print(List[r-1]-List[l-1])

Measured memory_bytes: 51872
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  ll n,a,b,ans; cin>>n>>a>>b;
	ll m = a+b;
	if(a==0) ans = 0;
	else{
		ll cnt = n/m;
		ans = a*cnt + min(n-m*cnt,a);
	}


	// else if(b>=n) ans = 0;
	// else if(m>=n) ans = n-b;
	// else if(b<n&&m<n){
	// 	ll cnt = n/m;
	// 	ans = cnt*a + max((n-cnt*m)-b,0LL);
	// }
	// ll ans = max(a,a-n);
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);
$to = array_fill(0, $n, []);
for ($i = 0; $i < $n; ++$i) {
    $input = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $u = $input[0];
    --$u;
    for ($j = 0; $j < $input[1]; ++$j) {
        $to[$u][] = $input[$j + 2] - 1;
    }
}

$ans = array_fill(0, $n, -1);
$q = new SplQueue();
$q->enqueue(0);
$ans[0] = 0;
while (!$q->isEmpty()) {
    $u = $q->dequeue();

    for ($i = 0; $i < count($to[$u]); ++$i) {
        $v = $to[$u][$i];
        if ($ans[$v] !== -1) continue;

        $ans[$v] = $ans[$u] + 1;

        $q->enqueue($v);
    }
}

foreach ($ans as $key => $val) {
    echo ($key + 1) . ' ' . $val, PHP_EOL;
}



Measured memory_bytes: 9416
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

bool ok(ll a){
  string s=to_string(a);
  if(s[0]==s[1] && s[1]==s[2])return 1;
  else return 0;
}

int main(){

  ll n;
  cin >> n;

  while(!ok(n))n++;

  cout << n << endl;



}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int a, b, c, r, p;
    cin >> a >> b >> c;
    r = b / a;
    if (r> c) {
        cout << c << endl;
    }
    else {
        cout << r << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N, M, T;
  cin >> N >> M >> T;
  vector<int> x(M), y(M);
  for (int i = 0; i < M; ++i) {
    cin >> x[i] >> y[i];
    --x[i]; --y[i];
  }
  if (T == 1) {
    vector<bitset<50010>> reach(N);
    for (int i = 0; i < N; ++i) reach[i].set(i);
    for (int i = M - 1; i >= 0; --i)
      reach[x[i]] = (reach[y[i]] |= reach[x[i]]);
    bitset<50010> res = reach[0];
    for (int i = 1; i < N; ++i) res &= reach[i];
    if (res.none()) cout << "-1\n";
    else {
      int t = 0;
      while (!res[t]) ++t;
      vector<bool> vis(N);
      vis[t] = true;
      string s;
      for (int i = M - 1; i >= 0; --i) {
        if (vis[x[i]]) {
          s.push_back('^');
          vis[y[i]] = true;
        } else if (vis[y[i]]) {
          s.push_back('v');
          vis[x[i]] = true;
        } else
          s.push_back('^');
      }
      reverse(s.begin(), s.end());
      cout << s << '\n';
    }
  } else {
    if (N == 2) {
      cout << "-1\n";
    } else {
      vector<int> f(N), c(N, 1);
      iota(f.begin(), f.end(), 0);
      string s;
      for (int i = M - 1; i >= 0; --i) {
        if (c[f[x[i]]] == 1) {
          --c[f[y[i]]];
          ++c[f[x[i]]];
          f[y[i]] = f[x[i]];
          s.push_back('^');
        } else {
          --c[f[x[i]]];
          ++c[f[y[i]]];
          f[x[i]] = f[y[i]];
          s.push_back('v');
        }
      }
      reverse(s.begin(), s.end());
      cout << s << '\n';
    }
  }

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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 solve(int bit, ll L, ll R){
    ll r = (R>>bit)<<bit, l = (L>>bit)<<bit;
    if((1LL<<bit) > r) return 0;
    if((1LL<<bit) < l) return 0;

    ll dp[bit+1][2][2]; REP(i,bit+1)REP(j,2)REP(k,2) dp[i][j][k] = 0;

    if((1LL<<bit)==r && (1LL<<bit)==l) dp[0][0][0] = 1;
    else if((1LL<<bit)==r) dp[0][0][1] = 1;
    else if((1LL<<bit)==l) dp[0][1][0] = 1;
    else dp[0][1][1] = 1;

    REP(i,bit){
        r = (R>>(bit-i-1)) & 1; l = (L>>(bit-i-1)) & 1;

        // from 0 0
        if(!(r==0 && l==1)){
            (dp[i+1][0][0] += dp[i][0][0]) %= MOD;
        }
        if(r==1 && l==0){
            (dp[i+1][0][1] += dp[i][0][0]) %= MOD;
            (dp[i+1][1][0] += dp[i][0][0]) %= MOD;
        }

        // from 0 1
        if(r==1){
            (dp[i+1][0][1] += dp[i][0][1]*2) %= MOD;
            (dp[i+1][1][1] += dp[i][0][1]) %= MOD;
        }
        else{
            (dp[i+1][0][1] += dp[i][0][1]) %= MOD;
        }

        // from 1 0
        if(l==1){
            (dp[i+1][1][0] += dp[i][1][0]) %= MOD;
        }
        else{
            (dp[i+1][1][0] += dp[i][1][0]*2) %= MOD;
            (dp[i+1][1][1] += dp[i][1][0]) %= MOD;
        }

        // from 1 1
        (dp[i+1][1][1] += dp[i][1][1]*3) %= MOD;
    }

    int ret = 0; REP(i,2)REP(j,2) (ret += dp[bit][i][j]) %= MOD;
    return ret;
}
void Main(){
    ll L,R; cin >> L >> R;
    int ans = 0;
    REP(i,61) (ans += solve(i,L,R)) %= MOD;
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

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

struct node
{
	struct node *prev;
	int key;
	struct node *next;
};

typedef  struct node *Akkarin;
Akkarin nil;

Akkarin listSearch(int key){
  Akkarin x,y;

  y = nil;
  x = y->next;

  while(x != nil){
    if(x->key == key){
      return y;
    }
    y = x;
    x = y->next;
  }
  return NULL;
}


void display(){
  Akkarin cur = nil->next;
  int isf = 1;

  while(1){
    if(cur == nil) break;
    if(isf == 0) printf(" ");
    printf("%d" ,cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteFirst(){
  Akkarin x,y;

  x = nil->next;
  y = x->next;
  y->prev = nil;
  nil->next = y;
  free(x);
}

void deleteLast(){
  Akkarin x,y;

  x = nil->prev;
  y = x->prev;
  y->next = nil;
  nil->prev = y;
  free(x);
}

void deletee(int key){
  Akkarin x,y,z;

  if(nil->next->key == key){
    deleteFirst();
    return;
  }

  x = listSearch(key);
  if(x == NULL){
    return;
  }
  z = x->next;

  y = x->next->next;
  x->next = y;
  y->prev = x;

  free(z);
}

void insert(int key){
  Akkarin x,y;
  x = malloc(sizeof(struct node));
  x->key = key;

  y = nil->next;
  nil->next = x;
  x->prev = nil;
  x->next = y;
  y->prev = x;
}

int main(int argc, char* argv[])
{
	int n, i;
	scanf("%d", &n);
	int sss;
	char op[30];
    nil = malloc(sizeof(struct node));
    nil->next = nil;
    nil->prev = nil;
    nil->key = -1;
    for(i=0; i<n; i++){
        scanf("%s", op);
        if(strcmp(op,"insert") == 0){
            scanf("%d",&sss);
            insert(sss);

        }
        else if(strcmp(op,"delete") == 0){
            scanf("%d",&sss);
            deletee(sss);

        }
        else if(strcmp(op,"deleteFirst") == 0){
           deleteFirst();
        }
        else if(strcmp(op,"deleteLast") == 0){
            deleteLast();
           // printf("%d", j);
        }
    }
	display();
	return 0;
}


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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input();
  string S = input<string>();

  int ans = inf;
  vector<int> r(N + 1);
  range(i, 1, N + 1) {
    r[i] = S[i - 1] == '#';
    r[i] += r[i - 1];
  }

  // cerr << r << endl;

  range(i, 0, N + 1) {
    chmin(ans, r[i] + (N - i) - (r.back() - r[i]));
  }

  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    int sum=1, m=1;

    while(sum<n) {
        m++;
        sum = (m+1)*m/2;
    }

    int iskip = sum - n;

    for(int i=1;i<=m;i++) {
        if(i==iskip) continue;
        cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, d[5003][5003] = {1};
    string s;
    cin >> n >> s; m = (int)s.length();
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            d[i][j] = d[i - 1][max(0, j - 1)] + d[i - 1][j + 1];
            if (d[i][j] >= mod) d[i][j] -= mod;
            d[i][j] += d[i - 1][j + 1];
            if (d[i][j] >= mod) d[i][j] -= mod;
        }
    }
    cout << d[n][m];
}


Measured memory_bytes: 98048
#include <iostream>
#include <algorithm>
using ll = long long;
using namespace std;

int main () {
	ll N, A, B;
	cin >> N >> A >> B;
	cout << min(A, B) << " " << ((A+B) > N ? (A+B-N) : 0) << endl; 
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include<algorithm>
#include<iostream>


using namespace std;

int main()
{
int a[10];
int k;
for(int i=0;i<10;i++)
{
    cin>>a[i];
    //a.push_back(k);

}
sort(a,a+10);
for(int j=9;j>=7;j--)
    cout<<a[j]<<endl;
    return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>

int abs(int n){
	if(n<0){
		n*=(-1);
	}
	return n;
}

int main (){
    int x, a, b;
    scanf ("%d %d %d", &x, &a, &b);
    if(abs(x-a)<abs(x-b)){
    	printf("A\n");
	}else{
		printf("B\n");
	}
    
    return 0;
}

Measured memory_bytes: 1604
package main

import "fmt"

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

func main() {
	var N int
	fmt.Scan(&N)
	B := make([]int, N)
	for i := 1; i < N; i++ {
		fmt.Scan(&B[i])
	}
	B[0] = B[1]

	ans := B[N-1]
	for i := 1; i < N; i++ {
		t := min(B[i-1], B[i])
		ans += t
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

int main() {
    long long n, m, l;
    cin >> n >> m >> l;
    cout << n * m / 2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int max = Integer.MIN_VALUE;
	static int[]bit;
	static int[][]F;
	static int[][]P;
	static int N;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		F = new int[N][10];
		P = new int[N][11];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 5; j++) {
				F[i][2 * j] = sc.nextInt();
				F[i][2 * j + 1] = sc.nextInt();
			}
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j <= 10; j++) {
				P[i][j] = sc.nextInt();
			}
		}
		sc.close();

		bit = new int[10];
		rec(0);
		System.out.println(max);
	}
	static void rec(int k) {
		if(k == bit.length) {
			solve();
			return;
		}
		rec(k + 1);
		bit[k] = 1;
		rec(k + 1);
		bit[k] = 0;
	}
	static int cnt = 0;
	static void solve() {
		if(cnt == 0) {
			cnt ++;
			return;
		}
		int t = 0;
		int[]c = new int[N];
		for(int i = 0; i < N; i++) {
			int cnt = 0;
			for(int j = 0; j < 10; j++) {
				if(F[i][j] == 1 && bit[j] == 1) {
					cnt++;
				}
			}
			c[i] = cnt;
		}
		for(int i = 0; i < N; i++) {
			t += P[i][c[i]];
		}
		max = Math.max(max, t);
	}
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N, K;
vector<vector<ll>> A;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> N >> K;
  map<ll, ll> m;
  A.resize(K);
  rep(i, K){
    int d;
    cin >> d;
    A[i].resize(d);
    rep(j, d) {
     cin >> A[i][j];
     m[A[i][j]]++;
    }
  }
  ll ans = 0;
  rep(i, N+1) {
    if (i==0) continue;
    if (m.count(i) == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << "," << el.second << "] "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A;
map<ll,ll> C;

void input(){
    #ifdef __LOCAL
        fs::path path_to_file = __FILE__;
        fs::path input,output;
        input = output = path_to_file.parent_path();
        input += string("/input/") + string(path_to_file.stem()) + string(".txt");
        output += string("/output/") + string(path_to_file.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    REP(i,N){
        ll a;
        cin >> a;
        A.push_back(a);
        C[a]++;
    }
}

int solve(){
    input();
    for(auto& c:C){
        if(c.second>1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;    
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 14320
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void solve() {
	int N;
	cin >> N;
	if (N < 105) {
		cout << 0 << "\n";
		return;
	}
	int count = 1;
	for (int i = 107; i <= N; i += 2)
	{
		int c = 0;
		for (int n= 1; n <= i; n++)
		{
			if (i % n == 0) c++;
		}
		if (c == 8) count++;
	}
	cout << count << "\n";
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    cin>>n;
    ll c25=n/25;
    ll c25u=n%25;
    ll c10=c25u/10;
    ll c10u=c25u%10;
    ll c5=c10u/5;
    ll c1=c10u%5;
    //cout<<c25<<" "<<c10<<" "<<c5<<c1<<endl;
    cout<<c25+c10+c5+c1<<endl;
    return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int s=0;
	string s1; 
	
	cin>>s1;

	for(int i=0;i<=2;i++)
	{
		if(s1[i]=='1')
		{
			s++;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
def isPrime(n):
	for i in range(2, n):
		if i*i>n:
			return 1
		if n % i == 0:
			return 0
	return 1

num = int(input())
result = 0
for _ in range(num):
    target = int(input())
    result += isPrime(target)

print(result)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b;
  cin >> a >> b;
  FOR(i, 1, 10000) {
    if (floor(0.08 * i) == a && floor(0.1 * i) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
# コンビネーション
mod = 10**9+7
def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NN = 10**6 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int, input().split())
if K >= N-1:
    ans = cmb(2*N-1, N)
else:
    ans = 0
    a = K
    while a >= 0:
        ans += cmb(N, a) * cmb(N-1, a) % mod
        ans %= mod
        a -= 1

print(ans)

Measured memory_bytes: 127688
#include<stdio.h>

int main(void){
  int W,H,x,y,r;

  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  puts((x-r<0||x+r>W||y-r<0||y+r>H)?"No":"Yes");
  return 0;
}

Measured memory_bytes: 1012
import sys
from itertools import accumulate
from bisect import bisect_left

n, m, *a = map(int, sys.stdin.read().split())
a.sort()


def f(x):
    # 幸福度がx未満となる組み合わせの個数を数える
    cnt = 0
    for ai in a:
        cnt += bisect_left(a, x-ai)
    # 幸福度がx以上の組み合わせの個数がm未満かどうか
    return n * n - cnt < m


left = a[0] * 2
right = a[-1] * 2
while right - left > 1:
    mid = (right + left) // 2
    if f(mid):
        right = mid
    else:
        left = mid
ans = 0
cumsum = [0] + list(accumulate(a))
j = 0
for ai in a:
    i = bisect_left(a, left-ai)
    j += n - i
    ans += ai * (n - i) + cumsum[-1] - cumsum[i]
ans += (m - j) * left
print(ans)


Measured memory_bytes: 14324
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int main() {
    int n; cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));

    if (n % 2 == 1) {
        ll ma = a[n/2];
        ll mb = b[n/2];
        cout << mb - ma + 1 << endl;
    } else {
        ll mal = a[n/2-1], mar = a[n/2];
        ll mbl = b[n/2-1], mbr = b[n/2];
        cout << mbr + mbl - mar - mal + 1 << endl;
    }
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double EPS= (1e-9);
using namespace std;
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=200000+9;
string s;
int vis[10009];
int main(){

    GO();
    int n,p;
    cin>>n>>p>>s;
    if(p==2||p==5){

        ll ans=0;
        for(int i=0;i<n;i++){
            if((s[i]-'0')%p==0){
                ans+=(i+1);
            }
        }
        cout<<ans<<"\n";
        return 0;
    }
    ll cur=0,ans=0,pp=1;
    vis[0]++;
    for(int i=n-1;i>=0;i--){
        int d=s[i]-'0';
        cur=(cur+d*pp)%p;
        ans+=vis[cur];
        vis[cur]++;
        pp*=10;
        pp%=p;
    }
    cout<<ans<<"\n";
}
























































































Measured memory_bytes: 720
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 2e5 + 20 ;
int n , d , x ;
ld num[N] , sum1[N] , sum2[N] ;
ld ans ;

void pre() {
	ld pp = 2 ;
	num[0] = 1 , sum1[0] = d , sum2[0] = d ;

	for (int i = 1 ; i < n ; i ++) {
		ld p = 1. / pp / (i + 1) ;

		num[i] = num[i - 1] + p * 2 ;
		sum1[i] = sum1[i - 1] + p * ((4 * i - 1) * x + 2 * d) ;
		sum2[i] = sum2[i - 1] + p * ((-(4 * i - 1)) * x + 2 * d) ;
	}
}

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

	cin >> n >> d >> x ;

	pre() ;

	for (int i = 0 ; i < n ; i ++) {
		ans += .5 * (sum1[n - 1 - i] + num[n - 1 - i] * (2 * i + 1) * x) ;
		ans += .5 * (sum2[i] + num[i] * (2 * i) * x) ;
	}

	cout << fixed << setprecision(20) << ans << '\n' ;
}

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

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var m = cin.nextInt();

            Console.WriteLine((n-1) * (m-1));
            
        }
    }

    class Scanner
    {
        string[] s;
        int i;

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

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

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

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

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

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

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

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

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


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

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


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,asum=0,bsum=0;cin>>n;
  lvector A(n,0),B(n,0);
  rep(i,n) {cin>>A[i]; asum+=A[i];}
  rep(i,n) {cin>>B[i]; bsum+=B[i];}
  ll sdiff=bsum-asum;
  if(sdiff<0) {print("No"); return 0;}
  else if(sdiff==0) {
    bool isok=true;
    rep(i,n) if(A[i]!=B[i]) {isok=false;break;}
    if(isok) puts("Yes");else puts("No");
  }
  else {
    ll val1=0,val2=0;
    rep(i,n) {
      if(A[i]<B[i]) val1+=(B[i]-A[i]+1)/2;
      if(A[i]>B[i]) val2+=A[i]-B[i];
    }
    if(max(val1,val2)>sdiff) puts("No");else puts("Yes");
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>

int main(int argc, char *argv[])
{
    double w, h, x, y;
    int ans;

    std::cin >> w >> h >> x >> y;

    if (x < w / 2) {
        x = w - x;
    }
    if (y < h / 2) {
        y = h - y;
    }

    if (h > w) {
        using std::swap;
        swap(h, w);
        swap(x, y);
    }

    //std::cout << w << " " << h << " " << x << " " << y << std::endl;

    if ((y == h / 2)&&(x == w / 2)) {
        double area = w * h / 2;
        std::cout << area << " 1" << std::endl;
    } else {
        double area = w * h / 2;
        std::cout << std::setprecision(16) << area << " 0" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

ll n,A,B,C ;
vll l ;

ll DFS(ll a,ll b,ll c,ll cnt){
	if(cnt==n) return (a*b*c==0?INF:abs(a-A)+abs(b-B)+abs(c-C)-30) ;
	ll r1 = DFS(a,b,c,cnt+1) ;
	ll r2 = DFS(a+l.at(cnt),b,c,cnt+1)+10 ;
	ll r3 = DFS(a,b+l.at(cnt),c,cnt+1)+10 ;
	ll r4 = DFS(a,b,c+l.at(cnt),cnt+1)+10 ;
	return min(min(r1,r2),min(r3,r4)) ;
}

int main(){
	cin >> n >> A >> B >> C ;
	l.resize(n) ;
	for(auto &i:l) cin >> i ;
	cout << DFS(0,0,0,0) << endl ;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>
#include <numeric>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

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


// 素因数分解 pair.firstで素数、pair.secondで対応する指数
vector<pair<long long, long long> > prime_factorize(long long n) {
	vector<pair<long long, long long> > res;
	for (long long p = 2; p * p <= n; ++p) {
		if (n % p != 0) continue;
		int num = 0;
		while (n % p == 0) { ++num; n /= p; }
		res.push_back(make_pair(p, num));
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}

const int MAX = 210000;

//二項係数を求める前処理 テーブルを作る　O(n)
// facは階乗
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

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

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

	ll n, m, k;
	cin >> n >> m >> k;
	COMinit();

	ll ans = 0;

	// 横をみる
	// nmCk通りの組み合わせがある
	ll eachNumRow = COM(n * m - 2, k - 2);
	// 2マスを固定する
	Rep(d, 1, n) {
		ans += (n - d) * d * m % mod * m % mod * eachNumRow % mod;
		ans %= mod;
	}

	Rep(d, 1, m) {
		ans += (m - d) * d * n % mod * n % mod * eachNumRow % mod;
		ans %= mod;
	}

	cout << ans % mod << endl;

	// modで割ることを忘れずに
	return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
  int N,K;
  string S;
  cin >> N >> S >> K;
  
  char c = S[K-1];
  for(int i = 0; i < N; i++){
    if(S[i] != c){
      S[i] = '*';
    }
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long;

int main() {
	int N;
	cin >> N;
	int K;
	cin >> K;
	int A = 0;
	int B = 0;
	int total =0;

	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		
		A = x * 2;
		B = (K - x)*2;

		total += min(A,B);

	}
	cout << total << endl;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] iArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            //整数
            long N = iArray[0];
            //K進法
            long K = iArray[1];
            List<long> nBase = new List<long>();
            long cnt = 0;
            while (true)
            {
                if (N<=K-1)
                {
                    cnt = nBase.Count() + 1;
                    break;
                }
                nBase.Add(N % 2);
                N = N / K;
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

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

int judge(string s){
  int top = 0;
  int c = 0;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i)=='A'||s.at(i)=='T'||s.at(i)=='C'||s.at(i)=='G'){
      c++;
      top = max(top,c);
    }
    else{
      c = 0;
    }
  }
  return top;
}

int main(){
  string s;
  cin >> s;
  cout << judge(s);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
lli solve(){
    lli n;
    cin>>n;
    vll h(n);
    loop(i, 0, n)
        cin>>h[i];
    vll dp(n, 0);
    loop(i, 1, n){
        if(i == 1)
            dp[i] = dp[0] + abs(h[i] - h[i-1]);
        else
            dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 4764
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::HashMap;

fn main() {
  let n = read::<i64>();
  let mut n_sum = 0;
  for c in n.to_string().chars() {
    n_sum += c.to_digit(10).unwrap();
  }

  if n % n_sum as i64 == 0 {
    println!("Yes");
  } else {
    println!("No");
  }

}



Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
typedef long long ll;
const int N=200005;
int main()
{
	ll a,b,c,d;int n;
	scanf("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	rep(i,0,n)
	{
		ll left=a-d*i+(ll)(n-i-1)*c,right=a+(ll)(n-i-1)*d-c*i;
		//printf("%lld %lld\n",left,right);
		if(left<=b && right>=b){puts("YES");return 0;}
	}
	puts("NO");
	return 0;
}

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

unordered_map<string, bool> map;
void to_str(vector<int> x) {
	string str = "";
	for (int i = 0; i < x.size(); i++) {
		str += to_string(x[i]);
	}
	map[str] = true;
}

int main() {
	while (1) {
		map.clear();
		int n, k;
		cin >> n >> k;
		if (n == 0 && k == 0)break;
		vector<int> cards(n);
		for_each(cards.begin(), cards.end(), [](int &x) {cin >> x; });

		if (k == 2) {
			for (int i = 0; i < n - k + 1; i++) {
				for (int j = i + 1; j < n; j++) {
					vector<int> combi = { cards[i],cards[j] };
					sort(combi.begin(), combi.end());
					do {
						to_str(combi);
					} while (next_permutation(combi.begin(), combi.end()));
				}
			}
		}
		else if (k == 3) {
			for (int i = 0; i < n - k + 1; i++) {
				for (int j = i + 1; j < n - k + 2; j++) {
					for (int s = j + 1; s < n; s++) {
						vector<int> combi = { cards[i],cards[j],cards[s] };
						sort(combi.begin(), combi.end());
						do {
							to_str(combi);
						} while (next_permutation(combi.begin(), combi.end()));
					}
				}
			}
		}
		else if (k == 4) {
			for (int i = 0; i < n - k + 1; i++) {
				for (int j = i + 1; j < n - k + 2; j++) {
					for (int s = j + 1; s < n - k + 3; s++) {
						for (int t = s + 1; t < n; t++) {
							vector<int> combi = { cards[i],cards[j],cards[s],cards[t] };
							sort(combi.begin(), combi.end());
							do {
								to_str(combi);
							} while (next_permutation(combi.begin(), combi.end()));
						}
					}
				}
			}
		}

		cout << map.size() << endl;
	}
	return 0;
}


Measured memory_bytes: 3484
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s; cin >> s;
    int res = 0;
    for (int i = 0; i < 4; i++) {
        if (s[i] == '+') res++;
        else res--;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int R, C, N; 
vector<pair<int, long long>> E[200010]; 
long long A[200010];  
bool seen[200010];
bool ok = true; 
long long mnr, mnc; 
long long INF = 1145141919810364364; 
void dfs(int i, long long &mnr, long long &mnc){
	seen[i] = true; 
	for(auto v : E[i]){
		if(A[v.first] != INF && A[i] + A[v.first] != v.second){
			ok = false; return; 	
		}
		if(A[v.first] != INF) continue; 
		A[v.first] = v.second - A[i]; 
		if(v.first < R) mnr = min(mnr, A[v.first]); 
		else mnc = min(mnc, A[v.first]); 
		dfs(v.first, mnr, mnc); 
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	cin >> R >> C >> N; 
	fill(A, A+R+C, INF);
	while(N--){
		int r, c; long long a; 
		cin >> r >> c >> a; 
		r--; c--; 
		E[r].push_back(make_pair(R+c, a)); 
		E[R+c].push_back(make_pair(r, a)); 
	}
	for(int i = 0; i < R+C; i++){
		if(seen[i]) continue; 
		if(i < R){
			mnr = 0; mnc = INF;  
		}else{
			mnc = 0; mnr = INF; 
		}
		A[i] = 0; 
		dfs(i, mnr, mnc); 
		if(mnr + mnc < 0) ok = false; 
	}
	cout << (ok ? "Yes" : "No") << endl; 
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
int n;
int d[55];
int dd[55];
int num[50];
int ans;
int main()
{
    num[0]=1;
    cin>>n;
    for(int i=1;i<=n;i++)
        {
            cin>>d[i];
            num[d[i]]++;
        }
    for(int i=0;i<=11;i++)
    {
        if(num[i]>2)
        {
            cout<<"0\n";
            return 0;
        }
    }
    if(num[12]>1)
    {
        cout<<"0\n";
        return 0;
    }
    if(n>=24)
        cout<<"0\n";
    else if(n==23)
    {
        cout<<"1\n";
    }
    else
    {
        int xx=1;
        xx<<=(n+1);
        xx--;
        //cout<<xx<<endl;
        for(int i=0;i<=xx;i++)
        {
            for(int j=0;j<=n;j++)
            {
                if(i&(1<<j))
                    dd[j]=d[j];
                else
                    dd[j]=24-d[j];
                if(dd[j]==24)
                    dd[j]=0;
            }
//            for(int j=0;j<=n;j++)
//                cout<<dd[j]<<" ";
//            cout<<endl;
            sort(dd,dd+1+n);
            int minn=100;
            for(int j=n;j>0;j--)
            {
                if(dd[j]-dd[j-1]<minn)
                    minn=dd[j]-dd[j-1];
            }
            if(24-dd[n]<minn)
                minn=24-dd[n];
            ans=max(ans,minn);
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
long long func(long long n,long long x){
    if(n>=0)return n/x+1;
    return 0;
}
int main()
{
    long long a,b,x;
    scanf("%lld%lld%lld",&a,&b,&x);
    printf("%lld",func(b,x)-func(a-1,x));
    return 0;
}


Measured memory_bytes: 128