akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<stack>
#include<queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
    int n,k;
    long long ans;
    cin>>n>>k;
    vector<long long> h(n);
    rep(i,n){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    rep(i,n-k){
        ans += h[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
def main():
	N, K = map(int, input().split(" "))
	
	ans = N - K + 1

	print(ans)

	
	
if __name__ == "__main__":
	main()

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

const int M = 998244353;

int main() {
  static int d[3001][3001];
  memset(d, 0xff, sizeof(d));

  int A, B, C, D;
  cin >> A >> B >> C >> D;

  d[A][B] = 1;
  function<int(int, int)> dp = [&](int n, int m) {
    if (~d[n][m]) return d[n][m];
    if (A < n && B < m) {
      d[n][m] = 0;
      (d[n][m] += (int64_t) (m - 1) * dp(n - 1, m) % M) %= M;
      (d[n][m] += (int64_t) (n - 1) * dp(n, m - 1) % M) %= M;
      (d[n][m] -= (int64_t) (n - 1) * (m - 1) * dp(n - 1, m - 1) % M) %= M;
      (d[n][m] += dp(n - 1, m)) %= M;
      (d[n][m] += dp(n, m - 1)) %= M;
    } else if (A < n) {
      d[n][m] = (int64_t) m * dp(n - 1, m) % M;
    } else if (B < m) {
      d[n][m] = (int64_t) n * dp(n, m - 1) % M;
    }
    return d[n][m];
  };

  int res = dp(C, D);
  if (res < 0) res += M;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 39612
#include<cstdio>
#include<queue>
using namespace std;
const int N=2e5+5;
int n,m,i,he[N],cnt,now,ans;
struct edge{int l,to;}e[N];
priority_queue<int> q;
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
int main(){
	for (n=read(),m=read(),i=1;i<=n;i++){
		int x=read(),y=read();
		e[i].l=he[x];he[x]=i;e[i].to=y;
	}
	for (int x=m;~x;x--){
		for (i=he[x];i;i=e[i].l) q.push(e[i].to);
		if (x&&!q.empty()) q.pop(),cnt++;
	}
	ans=cnt;now=m;
	for (;!q.empty()&&now>cnt;q.pop())
		if (q.top()<=now) ans++,now--;
	printf("%d",n-ans);
}

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

struct Node {
    struct Node* parent;
    struct Node* left;
    struct Node* right;
    int key;
};

static struct Node* Insert(struct Node* tree, struct Node* z) {
    struct Node* ret = NULL;
    struct Node* y = NULL;
    struct Node* x = tree;

    while ( x != NULL ) {
        y = x;
        if ( z->key < x->key ) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;

    if ( y == NULL ) {
        ret = z;
    } else if ( z->key < y->key ) {
        y->left = z;
        ret = tree;
    } else {
        y->right = z;
        ret = tree;
    }

    return ret;
}

static int Find(const struct Node* tree, int key) {

    if ( !tree ) {
        return 0;
    }

    if ( tree->key == key ) {
        return 1;
    }
    if ( key < tree->key ) {
        return Find(tree->left, key);
    } else {
        return Find(tree->right, key);
    }
}

static void PrintInorder(struct Node* tree) {

    if ( tree == NULL ) {
        return;
    }

    PrintInorder(tree->left);
    printf(" %d", tree->key);
    PrintInorder(tree->right);

    return;
}

static void PrintPreorder(struct Node* tree) {
    if ( tree == NULL ) {
        return;
    }

    printf(" %d", tree->key);
    PrintPreorder(tree->left);
    PrintPreorder(tree->right);

    return;
}

static struct Node* CreateNode(int key) {
    struct Node* p_node = malloc(sizeof(struct Node));

    p_node->parent = NULL;
    p_node->left   = NULL;
    p_node->right  = NULL;
    p_node->key    = key;

    return p_node;
}

static void DestroyNode(struct Node* p_node) {
    free(p_node);

    return;
}

static void DestroyTree(struct Node* tree) {
    if ( tree == NULL ) {
        return;
    }

    DestroyTree(tree->left);
    DestroyTree(tree->right);
    DestroyNode(tree);

    return;
}

int main(int argc, char* argv[]) {
    int m;
    int i;
    char order[16];
    struct Node* tree = NULL;

    scanf("%d\n", &m);

    for ( i = 0; i < m; i++ ) {
        int key;        
        scanf("%s %d\n", order, &key);
        if ( order[0] == 'i' ) {
            struct Node* p_node = CreateNode(key);
            tree = Insert(tree, p_node);
        } else if ( order[0] == 'f' ) {
            int f = Find(tree, key);
            printf("%s\n", f ? "yes" : "no");            
        } else if ( order[0] == 'p' ) {
            PrintInorder(tree);
            printf("\n");
            PrintPreorder(tree);
            printf("\n");            
        }
    }

    DestroyTree(tree);

    return 0;
}




Measured memory_bytes: 20416
def main():
    H, W = map(int, input().split())
    s = [list(input()) for _ in range(H)]

    for y in range(H):
        for x in range(W):
            if s[y][x] == '.':
                continue
            else:
                for dx,dy in [-1,0],[0,-1],[1,0],[0,1]:
                    nx = x + dx
                    ny = y + dy
                    if (0 <= nx < W) and (0 <= ny < H) and s[ny][nx] != '.':
                        break
                    elif (0 > nx) or (W <= nx) or (0 > ny) or (H <= ny):
                        continue
                    elif dx == 0 and dy == 1 and s[ny][nx] == '.':
                        return 'No'

    return 'Yes'

print(main())


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	ll n;
	cin>>n;
	
	set<ll> res;
	auto check=[&](ll div) {
		if(div<=1) return ;
		//~ LOG(div);
		ll curr=n;
		while(curr%div==0) curr/=div;
		if(curr%div==1) res.insert(div);
		
	}; 
	
	//~ for(ll i=2;i<=n;++i) check(i);
	
	for(ll i=1;i*i<=n;++i) {
		if(n%i==0) {
			check(i);
			if(i!=n/i) {
				check(n/i);
			}
		}
	}
	
		
	for(ll i=1;i*i<=n-1;++i) {
		if((n-1)%i==0) {
			check(i);
			if(i!=(n-1)/i) {
				check((n-1)/i);
			}
		}
	}

	cout<<sz(res)<<"\n";
	return 0;
}


Measured memory_bytes: 256
N = input()
p = input().split()

cnt = 0
flg = False
for i,ind_str in enumerate(p):
    if flg:
        flg = False
        continue
    i += 1
    ind = int(ind_str)
    if i==1 and ind==1:
        cnt+=1
        flg = True
        continue
    if i==ind and i+1==ind+1:
        cnt+=1
        flg = True
        continue
    if i == ind:
        cnt+=1

print(cnt)

Measured memory_bytes: 10420
#include<bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* dlm="";
  for(const auto& x:v) cout<<exchange(dlm," ")<<x;
  return os;
}
int32_t main(){
  size_t N,W; cin>>N>>W;
  vector<size_t> v(N+1), w(N+1);
  for(size_t i=1; i<N+1; ++i) cin>>v[i]>>w[i];
  vector<vector<size_t>> dp(N+1, vector<size_t>(W+1));
  // i=0
  for(size_t j=0; j<W+1; ++j) dp[0][j]=0;
  for(size_t i=1; i<N+1; ++i){
    for(size_t j=0; j<W+1; ++j){
      dp[i][j]=dp[i-1][j];
      if(j>=w[i]) dp[i][j]=max(dp[i][j], dp[i][j-w[i]]+v[i]);
    }
  }
  cout<<dp[N][W]<<endl;
}


Measured memory_bytes: 10764
// sync

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <map>

typedef long long ll;
const int N = 1e5 + 51;
struct edge {
	int to, next;
} e[N << 1];
int head[N], cnt;
void addedge(int x, int y) {
	e[++cnt] = (edge){y, x[head]}, x[head] = cnt;
	e[++cnt] = (edge){x, y[head]}, y[head] = cnt;
}

ll ans;
void dfs(int x, int p, int d) {
	ans += d;
	for (int i = x[head], nx; i; i = e[i].next)
		if ((nx = e[i].to) != p) dfs(nx, x, d + 1);
}

int p[N];
int f(int x) { return x[p] ? x[p] = f(x[p]) : x; }
void l(int x, int y) {
	if ((x = f(x)) != (y = f(y))) x[p] = y;
}

std::map<ll, int> mp;
int n, sz[N];
ll a[N];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", a + i), i[sz] = 1, mp[a[i]] = i;
	std::sort(a + 1, a + n + 1, std::greater<ll>());
	for (int i = 1; i < n; i++) {
		int x = mp[a[i]], nx;
		ll tmp = a[i] - n + 2 * x[sz];
		if (tmp >= a[i] || !mp.count(tmp)) return puts("-1"), 0;
		nx = mp[tmp];
		nx[sz] += x[sz];
		if (f(x) == f(nx)) return puts("-1"), 0;
		addedge(x, nx);
		l(x, nx);
	}
	dfs(mp[a[1]], 0, 0);
	if (ans != a[1]) return puts("-1"), 0;
	for (int i = 1; i <= cnt; i += 2) printf("%d %d\n", e[i + 1].to, e[i].to);
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define unordered_map umap
typedef long long ll;
typedef long double ld;
ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}
bool isPrime(int n){if(n<2){return false;}for(int i=2;i<sqrt(n)+1;i++){if(n%i==0) return false;}return true;}

int main(){
  char s[4]; scanf("%s",s);
  int a[4]; REP(i,4){a[i] = ctoi(s[i]);}
  bool noans = true;
  REP(i,8){
    int e = a[0];
    REP(j,3){
      if( i & (1<<j) ){e += a[j+1];}
      else{e -= a[j+1];}
    }
    if(e==7){
      printf("%d",a[0]);
      REP(j,3){
        if( i & (1<<j) ){printf("+");}
        else{printf("-");}
        printf("%d",a[j+1]);
      }
      printf("=7");
      noans = false;
      break;
    }
  }
  if(noans){
    printf("no ans\n");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, M; cin >> N >> M;
    vec<lint> num_balls(N, 1);
    vec<bool> red_possible(N, false);
    red_possible.at(0) = true;
    range(_, 0, M) {
        lint x, y; cin >> x >> y;
        x--; y--;
        if (red_possible.at(x)) red_possible.at(y) = true;
        num_balls.at(x) -= 1;
        if (num_balls.at(x) == 0) red_possible.at(x) = false;
        num_balls.at(y) += 1;
    }
    lint ans = 0;
    range(i, 0, N) ans += red_possible.at(i);
    cout << ans << "\n";
}

Measured memory_bytes: 1024
'use strict'

function Main(input) {
	let tmp = input.split(' ')
    let v1 = tmp[0]
    let v2 = tmp[1]
    if((v1 * v2) % 2 == 0){
      console.log("Even")
    } else {
      console.log("Odd")
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf-8"))

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    cout<<n*(n+1)/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <vector>
#include <stack>

using namespace std;

int p,q,r;
void invert(stack<int> &st){
    int x;
    x=st.top();
    st.pop();
    while(!st.empty()){
        if(st.top()!=-1)break;
		st.pop();
        x=(x-1)*(-1)+1;
	//	cout << st.size();
    }
	st.push(x);
    return;
}

void calc(stack<int> &st){
	int x,y;
	while(true){
		invert(st);
		x=st.top();
		st.pop();
		if(st.top()==-4){
			st.pop();
			st.push(x);
			invert(st);
			break;
		}
		else{
			int t=st.top();
			st.pop();
			invert(st);
			if(t==-2){
				y=st.top();
				st.pop();
				st.push(max(x,y));
			}
			else if(t==-3){
				y=st.top();
				st.pop();
				st.push(min(x,y));
			}
		}
	}
	return;
}

int main(){
	while(true){
		string str;
		cin >> str;
		int ans=0;
		stack<int> st;
		if(str[0]=='.')break;
		for(p=0;p<3;p++){
		for(q=0;q<3;q++){
		for(r=0;r<3;r++){
			for(int i=0;i<str.length();i++){
				if(str[i]=='(')st.push(-4);
				else if(str[i]=='-')st.push(-1);
				else if(str[i]=='+')st.push(-2);
				else if(str[i]=='*')st.push(-3);
				else if(str[i]=='P')st.push(p);
				else if(str[i]=='Q')st.push(q);
				else if(str[i]=='R')st.push(r);
				else if(str[i]==')')calc(st);
				else st.push((int)(str[i]-'0'));
			}
			if(st.size()!=1){
				invert(st);
			}
			if(st.top()==2)ans++;
		}
		}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void solve(long long K, long long A, long long B){
    REP(i, 1001){
        if(A<=i*K && i*K<=B){
            cout<<"OK"<<endl;
            return;
        }
    }
    cout<<"NG"<<endl;
}

int main(){
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();

		long m = 100;

		int i = 0;
		while(true){
			m *= 1.01;

			i++;

			if(m >= x){
				break;
			}
		}

		System.out.println(i);
	}

}


Measured memory_bytes: 27092
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    size_t N, C, K;
    std::cin >> N >> C >> K;

    std::vector<int64_t> T;
    for (size_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        T.push_back(t);
    }

    std::sort(std::begin(T), std::end(T));

    int64_t bus_count = 0;
    int64_t next_dep = T[0] + K;
    size_t pas = 1;

    for (size_t i = 1; i < N; ++i) {
        if (T[i] <= next_dep && pas < C) {
            // T[i]まにあう
            pas++;
        }
        else {
            // T[i]まにあわない/乗れないので出発
            bus_count++;
            // 次のバス待機
            next_dep = T[i] + K;
            pas = 1;
        }
    }

    // 最後の人
    if (pas > 0) {
        bus_count++;
    }

    std::cout << bus_count << std::endl;

    return 0;
}


Measured memory_bytes: 1400
#include<iostream>

using namespace std;

int main(void){
    int n;
    cin >> n;
    int b[102];
    for(int a = 0; a < n; a++)cin >> b[a];
    int min = b[0];
    int max = b[0];
    for(int c = 1; c < n; c++){
        if(b[c] > max)max = b[c];
        if(b[c] < min)min = b[c];
    }
    cout << max - min;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstdio>
#define F(i,n) for(int i=0;i<(int)(n);i++)
#define INF 100000000
#define ll long long

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

int main() {
	string a;
	int ans,i,j,p=0;
	stack<int> s;
	while (1) {
		ans = 0;
		i = 0;
		while (s.size()!=0) {
			s.pop();
		}
		getline(cin, a);
		F(j,100) {
			if (i == 0 && a[j] == '.') {
				p = 1;
				break;
			}
			if (a[j] == '.') {
				if (s.size()!=0 ){
					ans = 1;
					break;
				}
				break;
			}
			if (a[j] == '(')s.push(1);
			if (a[j] == '[')s.push(2);
			if (a[j] == ')') {
				if (s.size() == 0) {
					ans = 1;
					break;
				}
				if (s.top() == 1) {
					s.pop();
				}
				else {
					ans = 1;
				}
			}
			if (a[j] == ']') {
				if (s.size() == 0) {
					ans = 1;
					break;
				}
				if (s.top() == 2) {
					s.pop();
				}
				else {
					ans = 1;
					break;
				}
			}
			i = 1;

		}
		if (p == 1)break;
		if (ans == 0)cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#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,a;cin>>n;
  bool isok=true;
  rep(i,n) {
    cin>>a;
    if(a%2==0&&(a%3!=0&&a%5!=0)) isok=false;
  }
  puts(isok?"APPROVED":"DENIED");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,sum=0;
    cin>>n>>m;
    int a[n+1];
    for (i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1);
    for (i=n;i>=n-m+1;i--)
    sum+=a[i];
    cout<<sum<<endl;
    return 0;
}

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

#define INF 1e18
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    ll n,a,b; cin>>n>>a>>b;
    if(n%(a+b)==0) cout<<(n/(a+b))*a<<endl;
    else if(a<=n%(a+b)) cout<<(n/(a+b))*a + a<<endl;
    else cout<<(n/(a+b))*a + n%(a+b)<<endl;


    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
int N, M;
void func()
{
    cin >> N;
    ll ans(0);
    map<ll, ll> A, B;
    ll tmp;
    rep(i, 1, N + 1)
    {
        cin >> tmp;
        if (A.count(i + tmp))
            ++A[i + tmp];
        if (!(A.count(i + tmp)))
            A[i + tmp] = 1;
        if (B.count(i - tmp))
            ++B[i - tmp];
        if (!(B.count(i - tmp)))
            B[i - tmp] = 1;
    }
    for (auto i = A.begin(); i != A.end(); ++i)
    {
        if (B.count(i->first))
            ans += (i->second * B.find(i->first)->second);
    }
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 26692
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    x1 = set(s[:i])
    x2 = set(s[i:])
    ans_cur = 0
    for xx1 in x1:
        if xx1 in x2:
            ans_cur +=1
    ans = max(ans, ans_cur)
print(ans)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(){
    int N;
    string S;

    cin >> N;
    cin >> S;

    string newS = "";
    newS += S[0];
    for(int i=1; i < N; i++){
        if(S[i] != S[i-1]) newS += S[i];
    }

    cout << newS.length();

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#define N 100
using namespace std;

int main(){
  while(1){
    int h, w;
    bool flag;
    cin >> h >> w;
    if(h==0 && w==0) break;
    getchar();

    bool p[N][N];
    char data[N][N];

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> data[i][j];
	p[i][j]=false;
      }
    }

    int x=0, y=0;
    flag=false;
    while(1){
      if(p[y][x]){
	flag=true;
	break;
      }
      p[y][x]=true;
      if(data[y][x]=='>'){
	x++;
      }
      else if(data[y][x]=='<'){
	x--;
      }
      else if(data[y][x]=='^'){
	y--;
      }
      else if(data[y][x]=='v'){
	y++;
      }
      else if(data[y][x]=='.'){
	break;
      }
    }
    if(flag) cout << "LOOP" << endl;
    else cout << x << ' ' << y << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
#include <fstream>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

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

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion

ll dp[3001][3001][5];

int main() {
    int r, c, k;
    cin >> r >> c >> k;
    vector<vector<ll>> v(r, vector<ll>(c));
    rep(i, k) {
        int ri, ci, vi;
        cin >> ri >> ci >> vi;
        ri--; ci--;
        v[ri][ci] = vi;
    }
    
    rep(i, r) rep(j, c) rep(cnt, 4) {
        chmax(dp[i + 1][j + 1][cnt], dp[i][j + 1][cnt]);
        chmax(dp[i + 1][j + 1][cnt], dp[i + 1][j][cnt]);
        
        chmax(dp[i + 1][j + 1][cnt + 1], dp[i + 1][j][cnt] + v[i][j]);
        rep(cnt_, 4) chmax(dp[i + 1][j + 1][1], dp[i][j + 1][cnt_] + v[i][j]);
    }
    
    ll ans = 0;
    rep(cnt, 4) chmax(ans, dp[r][c][cnt]);
    cout << ans << endl;
    
    /*rep(i, r) {
        rep(j,  c) {
            cout << "(";
            rep(cnt, 4) cout << dp[i + 1][j + 1][cnt] << (cnt <= 2 ? ", " : "");
            cout << ") ";
        }
        cout << endl;
    }*/
}

Measured memory_bytes: 424796
#include <stdio.h>

int main(){    

int a, b;    

scanf("%d %d" ,&a ,&b);    

if(a < b){      

printf("a < b\n");     

}    

else if(a > b){      

printf("a > b\n");     

}    

else{      

printf("a == b\n");     

}  

return 0;  

}

Measured memory_bytes: 580
n, m = [int(i) for i in input().split()]

g = [[0 for i in range(n)] for i in range(n)]
for i in range(m):
    a, b = [int(_) for _ in input().split()]
    g[a-1][b-1] = 1
    g[b-1][a-1] = 1

s = [0]
p = 0
cnt = 0
h = -1
while True:
    if 1 in g[p][h+1:]:
        q = g[p].index(1, h+1)
        if q not in s:
            p = q
            h = -1
            s.append(p)
        else:
            h = q
    else:
        if len(s) == n:
            cnt += 1
        elif len(s) == 1:
            break
        h = p
        s.pop()
        p = s[-1]

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

ll modpower(ll x, ll n, ll mod){
    ll res = 1;
    while(n){
        if(n&1)res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll inv(ll n){
    return modpower(n,MOD-2,MOD);
}
void COMinit(vector<ll> &fact, vector<ll> &invfact, ll k){ //空っぽの配列を二つ
   fact.resize(k, 0);
   invfact.resize(k, 0);
   fact[0] = 1;
   repi(i, k, 1)
   {
       fact[i] = fact[i - 1] * i % MOD;
   }
   invfact[k - 1] = inv(fact[k - 1]);
   repd(i, k - 2, -1)
   {
       invfact[i] = invfact[i + 1] * (i + 1) % MOD;
   }
   return;
}
ll nCk(vector<ll> &fact,vector<ll> &invfact,ll n, ll k){ //この関数を使う前にCOMinit
   if (k < 0 || n < k)
       return 0LL;
   return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}

//---------main function----------

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0,k) << "..." << endl;
    }
   return 0;
}

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

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

  cout << "Christmas";
  if (25-d>=1) cout << " " << "Eve";
  if (25-d>=2) cout << " " << "Eve";
  if (25-d==3) cout << " " << "Eve";
  cout << endl;

  return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main() {
    int N, X, m, min_m = 1 << 30, count = 0;
    cin >> N >> X;
    REP(i, N) {
        cin >> m;
        min_m = min(min_m, m);
        X -= m;
        count++;
    }
    cout << count + X / min_m << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

N = gets.chomp.to_i

A = gets.chomp.split.map(&:to_i)

wanttobuy = true

money = 1000
stock = 0

last = A.size - 1

A.reverse.each_cons(2) do |x, y|
  break if x > y
  last -= 1
end

last += 1
A[last] = 0

A[0..last].each_cons(2) do |x, y|
  warn [x, y].inspect
  case
  when stock <= 0
    next if x >= y

    stock = money / x
    money -= stock * x
    wanttobuy != wanttobuy
  when stock > 0
    next if x <= y

    money += stock * x
    stock = 0
    wanttobuy != wanttobuy
  end

  warn({ money: money, stock: stock, wanttobuy: wanttobuy, x: x, y: y }.inspect)
end

puts money


Measured memory_bytes: 14372
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;


int main(){
  ll n;
  cin >> n;
  vector<ll> l(100);
  l[0] = 2;
  l[1] = 1;
  for(int i = 2; i < 100; ++i){
    l[i] = l[i - 1] + l[i - 2];
  }

  cout << l[n] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

int return_cost(vector <int> heights)
{
    int DP_table[heights.size()];
    DP_table[0] = 0;
    DP_table[1] = abs(heights[1] - heights[0]);
    for (int i = 2; i < heights.size(); i++)
    {
        DP_table[i] = min(DP_table[i - 1] + abs(heights[i - 1] - heights[i]), DP_table[i - 2] + abs(heights[i - 2] - heights[i]));
    }
    return DP_table[heights.size() - 1];
}

int main()
{
    int n;
    vector <int> heights;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        
        int height_i;
        cin >> height_i;
        heights.push_back(height_i);
    }
    cout << return_cost(heights);
}
    

Measured memory_bytes: 1528
#include <iostream>
#include <cstdio>

using namespace std;
typedef long long LL;

long long N , X;
LL work(LL x , LL y){
	if(x == 0 || y == 0) return 0;
	if(x % y != 0) return x % y + y + 2 * (x / y) * y + work(y - x % y , x % y);
	return 2 * (x / y) * y;
}
int main(){
	cin >> N >> X;
	cout << X + work(X , N - X) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(a) (int) (a).size()
#define pb push_back
using ll = int64_t;
using ld = long double;
using vint = vector<int>;
using str = string;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k = 2;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    int dp[n];
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        dp[i] = 1000000000000000000;
        for (int j = i - 1; j >= 0 && j + k >= i; --j)
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
    cout << dp[n - 1];
}

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

#define S second
#define F first
#define all(a) a.begin() , a.end()
#define pb push_back 
#define DBG cout<<"debug\n";

typedef long long ll;

const int N = 2 * 1e5 + 10;
const ll inf = 9e18 + 9; 

ll res;
ll a[N];

vector<ll> adj[N];
ll score[N] = {0};

void dfs(ll node , ll prev) {
    score[node] += score[prev];
    for(auto i : adj[node]) {
        if(i == prev) 
            continue;
        else
            dfs(i, node);
    }
}


void solve(){
    ll n , q;
    cin>>n>>q;

    for(int i = 0; i < n-1 ; i++) {
        ll x , y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    for(int i = 0; i < q; i++) {
        ll p , x;
        cin>>p>>x;
        score[p] += x;
    }

    dfs(1 , 0);

    for(int i = 1; i <= n ; i++) {
        cout<<score[i]<<" ";
    }
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 24320
mod = 1000000007

def add(a, b):
    return (a + b) % mod

def sub(a, b):
    return (a + mod - b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
    
a = []
N, M = map(int, input().split())
for i in range(M):
    a.append(int(input()))

def main():
  results = []

  flag = True

  for m in range(1, M):
      if a[m] - a[m - 1] == 1:
          flag = False
          break

  flag_end = True
  if M == 0:
      flag_end = False

  def Fib(n):
      a, b = 0, 1
      if n == 1:
          return a
      elif n == 2:
          return b
      else:
          for i in range(n-2):
              a, b = b, a + b
          return b

  if flag and flag_end:
      for m in range(M):
          if m == 0:
              results.append(Fib(a[m] + 1))
          else:
              results.append(Fib(a[m] - a[m - 1]))
      results.append(Fib(N - a[m] + 1))
      result = 1
      for i in range(len(results)):
          result = mul(result, results[i])
      print(result % mod)
  elif not flag:
      print(0)
  else:
      print(Fib(N + 2) % mod)

if __name__ == "__main__":
  main()


Measured memory_bytes: 7096
#include <stdio.h>

int main()
{
    char N[5];
    int i,yn=0;

    scanf("%s",N);

    if(N[1]==N[2]){
        if((N[0]==N[1])||(N[2]==N[3])){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");

    return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	vi conto1;
	vi contoN;
	makei(N);
	makei(M);
	rep(M) {
		makei(a);
		makei(b);
		if (a == 1)conto1.push_back(b);
		else if (b == 1)conto1.push_back(a);
		else if (a == N)contoN.push_back(b);
		else if (b == N)contoN.push_back(a);
	}
	sort(all(conto1));
	sort(all(contoN));
	auto it1 = conto1.begin();
	auto itN = contoN.begin();
	while (it1 != conto1.end() && itN != contoN.end()) {
		if ((*(it1)) == (*(itN))) { say("POSSIBLE"); re; }
		else if ((*(it1)) < (*(itN)))++it1;
		else ++itN;
	}
	say("IMPOSSIBLE");
}


Measured memory_bytes: 1276
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <climits>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;

#define ten(n) (1e##n)
#define COUT cout <<
#define SPACE_COUT << " "  <<
#define COMMA_COUT << ", " <<
#define ENDL << endl;

const long long denominator = ten(9) + 7;

int
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    vector<int> A;
    cin >> N;
    A.resize(N, 0);
    fill(A.begin(), A.end(), 0);

    int tmp;
    for (int i = 0; i < N; ++i) {
        cin >> tmp;
        A[tmp]++;
    }

    int odd = N % 2;
    if (odd && N == 1) {
        if(A[0] == 1) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
        return 0;
    }
    long long total = 1;;
    for (int i = 1 + odd; i < N; i += 2) {
        if (A[i] == 2) { 
            total = (total * 2) % denominator;
        } else {
            cout << 0 << endl;
            return 0;
        }                        
    }
    cout << total << endl;
    return 0;
}


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

int main()
{
        int N;
        cin >> N;
        vector<int> s(N, 0);
        int sum = 0;
        for (int i = 0; i < N; ++i) {
                cin >> s[i];
                sum += s[i];
        }
        sort(s.begin(), s.end());
        for (int i = 0; i < N; ++i) {

                if (sum % 10 == 0) {
                        if (s[i] % 10 != 0) {
                                cout << sum - s[i] << endl;
                                exit(0);
                        }
                }
                else {
                        cout << sum << endl;
                        exit(0);
                }
        }
        cout << 0 << endl;

}


Measured memory_bytes: 256
#include <iostream>
typedef long long int LLI;
typedef unsigned long long int ULLI;
using namespace std;

int main() {
    int N;
    cin >> N;
    LLI p, q, b, d;
    b = 0;
    LLI P[N], A[N], B[N];
    for (int i = 0; i < N; ++i) {
        cin >> P[i];
        A[i] = i+1;
        B[N-i-1] = i+1;
    }
    for (int i = 0; i < N; ++i) {
        p = P[i]-1;
        q = A[p]+B[p];
        if (q <= b) {
            d = b - q + 1;
            for (int j = p; j < N; ++j) {
                A[j] += d;
            }
            for (int j = 0; j < p+1; ++j) {
                B[j] += d;
            }
        }
        b = A[p]+B[p];
    }
    for (int i = 0; i < N-1; ++i) {
        cout << A[i] << " ";
    }
    cout << A[N-1] << endl;
    for (int i = 0; i < N-1; ++i) {
        cout << B[i] << " ";
    }
    cout << B[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;

int max(int a,int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int n, a[109];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int A = 0, B = 0;
	rep(i, n) {
		if (i % 2 == 0) {
			A += a[i];
		}
		else {
			B += a[i];
		}
	}
	cout << A - B << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
lower = -float('inf')
upper = float('inf')
for i in range(m):
    l,r = map(int,input().split())
    if l > lower:
        lower = l
    if r < upper:
        upper = r
    if upper < lower:
        upper = 0
        lower = 0
        break
if upper == lower == 0:
    print(0)
else:
    print(upper - lower + 1)

Measured memory_bytes: 9020
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    int ans = 0;
    REP(i,n) {
        ans += v[i] - abs(k-v[i]) >= 0 ? abs(k-v[i]) : v[i];
    }

    cout << ans * 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

void solve()
{
	string s;
	cin>>s;
	if(s[3]==s[2] && s[5]==s[4]) cout<<"Yes";
	else cout<<"No";
}

int main() 
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

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

namespace AtCoder_086
{
    class Program
    {
        static void Main(string[] args)
        {
			//// 整数の入力
			//int a = int.Parse(Console.ReadLine());
			// スペース区切りの整数の入力
			string[] input = Console.ReadLine().Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);
			//// 文字列の入力
			//string s = Console.ReadLine();
			//出力
			if (a * b % 2 != 0)
			{
				Console.WriteLine("Odd");
			}
			else
			{
				Console.WriteLine("Even");
			}
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main()
{
	int n,m,a,b,c,d;
	scanf("%d %d",&n,&m);
    a=0;
	b=0;
	c=0;
	d=0;
	a=n+m;
	if(a<=2) printf("0\n");
	else {
		b=n*(n-1)/2;
		c=m*(m-1)/2;
		d=b+c;
		printf("%d",d);
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int count=1;
  for(int i=0;i<N-1;i++){
    if(S.at(i)!=S.at(i+1)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int K=gi();
	    int[] H=new int[N];
	    
	    int c=0;
	    for(int i=0; i<N; i++) {
	    	H[i]=gi();
	    	if(H[i]>=K)c++;
	    }

        System.out.print(c);
//        if (c<=2) {
//        	System.out.println("YES");
//        }else {
//        	System.out.println("NO");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 57660
#include<iostream>
#include<unordered_map>
#include <queue>
 
struct myless {
	bool operator()(int x, int y) const {
		return x<y;
	}
};
 
typedef long int MYINT;
typedef std::priority_queue<MYINT,std::vector<MYINT>,myless> P_Queue;
typedef std::unordered_map<MYINT,unsigned int> SET;
 
 
//////////////////////////////////
int main(void) {
	unsigned int N;
	P_Queue Q;
 
	std::cin >> N;
 
	//inputfase
	//binary insert
	for (int i = 0; i < N; i++) {
		MYINT temp;
		std::cin >> temp;
		Q.push(temp);
	}
	SET set;
	MYINT max1, max2;
 
	int count = 0;
	while (!Q.empty()) {
		MYINT temp=Q.top();
 
		if (set.find(temp) != set.end()) {
			if (count == 0) {
				//max1,max1,...
				max1 = temp;
				set[temp]++;
			}
 
			if (count >= 1) {
				if (max1 != temp) {
					//max1,max1,max2,max2
					max2 = temp;
					break;
				}
				else {
					//max1,max1,max1,...
					set[temp]++;
				}
			}
 
			if (set[max1] == 4) {
				//max1,max1,max1,max1
				max2 = max1;
				break;
			}
			count++;
		}
		else set[temp] = 1;
 
		Q.pop();
	}
 
	std::cout << max1*max2 << std::endl;
 
	return 0;
}


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
typedef vector<int64_t> vi;
typedef vector<vector<int64_t>> vvi;
const double pi = 3.14159265358979;

int main(){
    int a,b,h,m; cin >> a >> b >> h >> m;
    double ax,ay,bx,by,rh,rm,r;
    
    rh = (30.0*h+30.0*m/60.0)*pi/180.0; rm = 6.0*m*pi/180.0;
    r = abs(rh-rm);
    if(r > pi) r=2.0*pi-r;
    ax = a*cos(rh); ay = a*sin(rh);
    bx = b*cos(rm); by = b*sin(rm);
    double dist = sqrt(pow(ax-bx,2)+pow(ay-by,2));
   // double dist = sqrt(a*a + b*b - 2*a*b*cos(r));
    //cout << ax << " " << ay << endl;
    //cout << bx << " " << by << endl;
    cout << fixed << setprecision(10) << dist << endl;
}

Measured memory_bytes: 4100
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, M, Q = map(int, readline().split())
    A = [[0] * N for _ in range(N)]
    for _ in range(M):
        l, r = map(int, readline().split())
        A[l - 1][r - 1] += 1

    B = [[0] * (N + 1) for _ in range(N + 1)]
    for i in range(N):
        for j in range(N):
            B[i + 1][j + 1] = B[i][j + 1] + B[i + 1][j] - B[i][j] + A[i][j]

    ans = [0] * Q
    for i in range(Q):
        p, q = map(int, readline().split())
        p -= 1
        q -= 1
        ans[i] = B[q + 1][q + 1] - B[q + 1][p] - B[p][q + 1] + B[p][p]

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 21076