akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i, n)      reps (i, 0, n)
#define reps(i, f, n)  for (int i = f; i < int(n); ++i)

struct Node
{
    Node *lch, *rch;
    unsigned pri;
    int val, mini, cnt;
    Node() {
        lch = rch = NULL;
        val = mini = 0;
        cnt = 1;
    }
};

typedef pair<Node*, Node*> PPNode;

int getcnt(Node *t) { return t ? t->cnt : 0; }
int getmin(Node *t) { return t ? t->mini : 1 << 29; }

Node* update(Node *t)
{
    t->cnt = getcnt(t->lch) + getcnt(t->rch) + 1;
    t->mini = min(min(getmin(t->lch), getmin(t->rch)), t->val);
    return t;
}

Node* merge(Node *l, Node *r)
{
    if (!l || !r) return l ? l : r;
    if (l->pri > r->pri) {
        l->rch = merge(l->rch, r);
        return update(l);
    } else {
        r->lch = merge(l, r->lch);
        return update(r);
    }
}

PPNode split(Node *t, int k)
{
    if (!t) return PPNode(NULL, NULL);
    if (k <= getcnt(t->lch)) {
        PPNode p = split(t->lch, k);
        t->lch = p.second;
        return PPNode(p.first, update(t));
    } else {
        PPNode p = split(t->rch, k - getcnt(t->lch) - 1);
        t->rch = p.first;
        return PPNode(update(t), p.second);
    }
}

unsigned rnd()
{
    static unsigned x[] = { 123456789, 362436069, 521288629, 88675123 };
    unsigned t = x[0] ^ (x[0] << 11);
    x[0] = x[1]; x[1] = x[2]; x[2] = x[3];
    return x[3] = (x[3] ^ (x[3] >> 19)) ^ (t ^ (t >> 8));
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n, q, a, x, y, z;
    cin >> n >> q;
    vector<Node> node(n);
    Node *root = NULL;
    rep (i, n) {
        cin >> a;
        node[i].pri = rnd();
        node[i].val = node[i].mini = a;
        root = merge(root, &node[i]);
    }
    rep (i, q) {
        cin >> x >> y >> z;
        if (x == 0) {
            PPNode p1 = split(root, y);
            PPNode p2 = split(p1.second, z - y);
            PPNode p3 = split(p2.second, 1);
            root = merge(p1.first, p3.first);
            root = merge(root, p2.first);
            root = merge(root, p3.second);
        } else if (x == 1) {
            PPNode p1 = split(root, y);
            PPNode p2 = split(p1.second, z - y + 1);
            cout << p2.first->mini << endl;
            root = merge(p1.first, p2.first);
            root = merge(root, p2.second);
        } else {
            PPNode p1 = split(root, y);
            PPNode p2 = split(p1.second, 1);
            p2.first->val = p2.first->mini = z;
            root = merge(p1.first, p2.first);
            root = merge(root, p2.second);
        }
    }
}

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

#define MIN(a,b) ((a)<(b)?(a):(b))

void run(void){
  int n,w;
  scanf("%d%d",&n,&w);
  const int m=1000*n;
  int *dp=(int *)calloc(m+1,sizeof(int));
  int i;
  for(i=1;i<=m;i++) dp[i]=w+1;
  while(n--){
    int a,v;
    scanf("%d%d",&a,&v);
    for(int i=m;i>=v;i--){
      dp[i]=MIN(dp[i],dp[i-v]+a);
    }
  }
  for(i=m;dp[i]>w;i--);
  printf("%d\n",i);
}

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
 
struct SegmentTree{
    vector<int> Seg;
	int n;
 
	void build(vector<int>& v, int m){
		n = m;
        Seg = vector<int> (4*n,1e6);
		build(v, 1, 0, n);
	}
	void build( vector<int>& v, int id,int left, int right){
		if(left + 1 >= right){
			Seg[id] = v[left];
			return;
		}
		int mid = (left + right)/2;
		build(v, id * 2, left, mid);
		build(v, id * 2 + 1, mid, right);
		Seg[id] = min(Seg[id*2],Seg[id*2 + 1]);
	}
 
	int find(int x, int y){
		return find(x, y, 1, 0, n);
	}
	int find(int x, int y, int id, int left, int right){
		if(left >= y or right <= x){
			return 1e6;
		}
		if(left >= x and right <= y){
			return Seg[id];
		}
		int mid = (left + right)/2;
		return min(find(x, y, 2*id, left, mid), find(x, y, 2*id + 1, mid, right));
	}
};
SegmentTree S[2];
 
struct obj {
	int x,y,i;
	bool operator < (const obj& o) const {
		return x > o.x;
	}
};

int pos[200010];
int s = 0;
vector<obj> adj[200010];
priority_queue<obj> pq;
	
void getans(int l, int r, int p, int par) {
	if(l + 1 >= r) return;
	int curNode = s++;
	int x = S[p].find(l,r);
	int px = pos[x];
	int y = S[p^1].find(px + 1, r);
	int py = pos[y];

	if(par != -1) {
		adj[par].push_back({x,y,curNode});
	}
	else {
		pq.push({x,y,curNode});
	}
	
	getans(l, px, p, par);
	getans(px + 1, py, p^1, curNode);
	getans(py + 1, r, p, par);
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> odd(n, 1e6), even(n, 1e6);
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		pos[x] = i;
		if(i&1) even[i] = x;
		else odd[i] = x;
	}
 
	S[0].build(odd, n);
	S[1].build(even, n);
	getans(0,n,0,-1);
 
	int ans[n];

	while(pq.size()) {
		auto x = pq.top();
		pq.pop();
		cout << x.x << ' ' << x.y << ' ';
		for(auto i : adj[x.i]) pq.push(i);
	}

}


Measured memory_bytes: 36736
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n,l;
	cin>>n>>l;

	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	REP(i,0,n-1){
		if(a[i]+a[i+1]>=l){
			cout<<"Possible"<<endl;
			lli target = i+1;
			REP(j,1,target){
				cout<<j<<endl;
			}

			for(lli j=n-1;j>i;j--){
				cout<<j<<endl;
			}
			return 0;
		}
	}

	cout<<"Impossible"<<endl;

	return 0;
}

Measured memory_bytes: 1664
input = STDIN.read.split("\n").map{|l| l.split(" ")}

first = input.shift
H = first[1].to_i
W = first[2].to_i

cnt = 0
input.each do |r|
  if r[0].to_i >= H && r[1].to_i >= W 
    cnt = cnt + 1
  end
end

puts cnt

Measured memory_bytes: 1788
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
#define int long long
int a[1000010],f[1000010],s[1000010];
int max(int a,int b){
    return a>b?a:b;
}
main(){
    int i,j,k,n,m;
    scanf("%lld%lld",&m,&n);swap(n,m);
    for(i=1;i<=n;i++)
        scanf("%lld%lld",&a[i],&s[i]);
    for(i=1;i<=n;i++)
        for(j=m;j>=a[i];j--)
            f[j]=max(f[j-a[i]]+s[i],f[j]);
    printf("%lld\n",f[m]);
    return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

int H, W;
vector<string> s(60);
int dy[4] = {1, -1, 0, 0};
int dx[4] = {0, 0, 1, -1};
int map[60][60];
int dots = 0;
queue<pair<int ,int>> q;

void bfs(int y, int x) {
    for (int ib=0; ib<4; ++ib) {
        int Y, X;
        Y = y + dy[ib];
        X = x + dx[ib];
        if (Y>=0 && Y<H && X>=0 && X<W && s[Y][X]=='.' && map[Y][X]==-1) {
            map[Y][X] = map[y][x] + 1;
            q.push(make_pair(Y, X));
        }
    }
    s[y][x] = '#';
}

int main() {
    cin >> H >> W;

    for (int i=0; i<H; ++i) cin >> s[i];
    for (int i=0; i<H; ++i) for (int j=0; j<W; ++j) map[i][j] = -1;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (s[i][j] == '.') ++dots;
        }
    }

    q.push(make_pair(0, 0));
    while (!q.empty()) {
        auto p = q.front();
        int y = p.first;
        int x = p.second;
        q.pop();
        
        if (y==H-1 && x==W-1) break;

        bfs(y, x);
    }

    if (map[H-1][W-1] == -1) cout << "-1" << endl;
    else cout << dots - (map[H-1][W-1]+2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

class STlazy{
private:
    int n;
    vector<ll> node, lazy;

public:
    STlazy(vector<ll> v){
        int siz = v.size();
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, 0);
        lazy.resize(2*n-1, 0);
        
        for(int i = 0; i < siz; i++)    node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = node[2*i+1] + node[2*i+2];
    }

    void eval(int k, int l, int r){
        if(lazy[k] == 0)    return;
        node[k] += lazy[k];
        if(r-l > 1){
            lazy[2*k+1] += lazy[k]/2;
            lazy[2*k+2] += lazy[k]/2;
        }
        lazy[k] = 0;
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        eval(k, l, r);
        if(r <= a || b <= l)    return;
        if(a <= l && r <= b){
            lazy[k] += (r-l)*x;
            eval(k, l, r);
            return;
        }
        add(a, b, x, 2*k+1, l, (l+r)/2);
        add(a, b, x, 2*k+2, (l+r)/2, r);
        node[k] = node[2*k+1] + node[2*k+2]; // 自分の全ての子孫の値伝播が終わったら自分を更新する
    }

    ll query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        if(r <= a || b <= l)    return 0;
        eval(k, l, r); // 最初の呼び出しが必ずeval(0,0,n)となるので漏れなく上から値の伝播がなされている
        if(a <= l && r <= b)    return node[k];
        ll lx = query(a, b, 2*k+1, l, (l+r)/2);
        ll rx = query(a, b, 2*k+2, (l+r)/2, r);
        return lx+rx;
    }
};

int main(){
    int n, d, a;
    cin >> n >> d >> a;
    vector<pii> vp;
    for(int i = 0; i < n; i++){
        int x, h;
        cin >> x >> h;
        vp.push_back({x, h});
    }
    sort(vp.begin(), vp.end());
    
    vector<ll> za;
    for(int i = 0; i < n; i++)  za.push_back(vp[i].first);

    vector<ll> emp(n, 0);
    STlazy seg(emp);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll hist = seg.query(i, i+1);
        ll hp = vp[i].second;
        if(hist*a >= hp)  continue;
        ll attack = (hp-hist*a+a-1)/a;
        ans += attack;
        ll from = vp[i].first;
        ll to = from+2*d;
        int x = --upper_bound(za.begin(),za.end(),to)-za.begin();
        seg.add(i, x+1, attack);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14832
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int n, q;
    cin >> n;
    map<int, int> cnt;
    int64 ans = 0;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        cnt[a]++;
        ans += a;
    }
    cin >> q;
    for (int i=0; i<q; i++) {
        int b, c;
        cin >> b >> c;
        ans -= b * cnt[b];
        ans += c * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << ans << endl;
    }
}


Measured memory_bytes: 7460
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
#a,b= (int(i) for i in input().split())      #入力整数横2つ
#k,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

n = ip()                      #入力セット(整数改行あり)
a=[ip() for i in range(n)]    #入力セット(整数改行あり)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意

print(len(set(a)))

Measured memory_bytes: 13648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];

	ll sum = 0;
	rep(i, n) {
		sum += a[i] - 1;
	}

	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}


int main() {
    unsigned int k;
    string s;
    cin >> k >> s;
    string plus = "...";

    if (s.size() <= k) {
        cout << s << endl;
    } else {
        string temp = s.substr(0,k);
        cout << temp + plus << endl;
    }


    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void){
int n;

scanf("%d",&n);
if(n>=28||n==4||n==7||n==8||n==11||n==12||n==14||n==15||n==16||n==20||n==21||n==22||n==18||n==19||n==24||n==23||n==26)
printf("Yes\n");
else
printf("No\n");
		
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int a, b; scanf("%d%d", &a, &b);
	
	printf("%d\n", a * b);
	return 0;
}



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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

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

    int N;
    cin >> N;

    vvi adj(N);
    for (int i = 0, u, v; i < N - 1; i++) {
        cin >> u >> v;
        adj[u-1].push_back(v-1);
        adj[v-1].push_back(u-1);
    }

    vi c(N);
    for (int i = 0; i < N; i++) {
        cin >> c[i];
    }
    sort(all(c));

    vi deg(N);
    queue<int> leaf;
    for (int i = 0; i < N; i++) {
        deg[i] = adj[i].size();
        if (deg[i] == 1)
            leaf.push(i);
    }

    vi res(N);
    for (int t = 0; !leaf.empty(); leaf.pop()) {
        int node = leaf.front();
        res[node] = c[t++];
        for (int nbr : adj[node]) {
            if (--deg[nbr] == 1) {
                leaf.push(nbr);
            }
        }
    }

    ll score = 0;
    for (int i = 0; i < N; i++) {
        for (int j : adj[i]) {
            score += min(res[i], res[j]);
        }
    }

    cout << score / 2 << "\n";
    for (int v : res)
        cout << v << " ";
    cout << endl;

    return 0;
}



Measured memory_bytes: 1024
h,n = map(int,input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])

dp = [[100000000 for i in range(h+1)] for j in range(n+1)]

for i in range(n):
    for j in range(h+1):
        if j <= ab[i][0]:
            dp[i+1][j] = min(ab[i][1],dp[i][j])
        else:
            dp[i+1][j] = min(ab[i][1]+dp[i+1][j-ab[i][0]],dp[i][j])

print(dp[-1][-1])
        

Measured memory_bytes: 125276
#include <iostream>

using namespace std;

void printa(int A[], int len) {
	cout << A[0];
	for (int i = 1; i < len; i++)
		cout << " " << A[i];
	cout << endl;
}

int ssort(int A[], int len) {
	int t = 0;
	for (int i = 0; i < len; i++) {
		int mini = i;
		for (int j = i; j < len; j++) {
			if (A[j] < A[mini]) {
				mini = j;
			}
		}
		if (mini != i) {
			swap(A[i], A[mini]);
			t++;
		}
	}
	return t;
}

int main() {
	int n, *a, t;
	cin >> n;
	a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	t = ssort(a, n);
	printa(a, n);
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
using namespace std;
typedef pair<int, int> P;
typedef pair<P, string> Pi;
#define fi first
#define sec second
int main()
{
    int n, q;
    while (cin >> n >> q)
    {
        if (n == 0 && q == 0)
            break;
        string str;
        vector<Pi> vec(n + 1);
        int era[n + 1];
        int westerm[n + 1];
        rep(i, n)
        {
            cin >> str >> era[i] >> westerm[i];
            vec[i].fi.fi = westerm[i] - era[i] + 1;
            vec[i].fi.sec = westerm[i];
            vec[i].sec = str;
        }
        vector<int> year(q + 1);
        rep(i, q) cin >> year[i];
        rep(i, q)
        {
            bool flag = false;
            rep(j, n)
            {
                if (year[i] >= vec[j].fi.fi && year[i] <= vec[j].fi.sec)
                {
                    flag = true;
                    cout << vec[j].sec << " " << year[i] - westerm[j] + era[j] << endl;
                    break;
                }
            }
            if (!flag)
                cout << "Unknown" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3292
import java.util.Scanner;
     
    class Main {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if ((a * b) % 2 == 1) {
    			System.out.println("Yes");
    		} else {
    			System.out.println("No");
    		}
    		
    	}
    }

Measured memory_bytes: 21588
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
 
int main() {
    int N,K;
    cin >> K >> N;
    vector<int>A(N);
    rep(i, 0, N){
        cin >> A[i];
    }
    int maxD = (K+A[0])-A[N-1];
    rep(i, 0, N-1){
        int D = A[i+1]-A[i];
        maxD = max(D,maxD);
    }
    
    
    cout << K-maxD << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	s=s.substr(0,s.size()-8);
	cout<<s<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=1;
	while(n--){
		if (ans+k>ans*2)
			ans*=2;
		else
			ans+=k;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
ave = lambda a: sum(a) / len(a)
a = []
INF = int(1e9)

def C(n, m):
    ret = 1
    for i in range(m):
        ret *= n - i
    for i in range(2, m+1):
        ret //= i
    return ret

for i in range(A, B+1):
    a.append((ave(v[:i]), i))
ans1, i = max(a)
ans2 = 0
for b, j in a:
    if b != ans1:
        continue
    c1 = v[:j].count(v[j-1])
    c2 = v.count(v[j-1])
    ans2 += C(c2, c1)
print(ans1)
print(ans2)

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

using namespace std;
typedef long long ll;

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    ll ans = 0;

    ans = A + B + C;

    if (ans >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

import numpy as np

N = int(input())
A = np.array(input().split(), dtype=np.int8)
B = np.array(input().split(), dtype=np.int8)

def test(li):
    # xをyにできる
    can_make = np.eye(51,dtype=np.bool)
    for k in li:
        can_make |= can_make[np.arange(51)[:,None]%k,np.arange(51)[None,:]]
    return can_make[A,B].all()

if not test(list(range(1,51))):
    print(-1)
    exit()

use = []
x = 50
while x:
    if test(use):
        break
    for y in range(1,x+1):
        if test(list(range(1,y+1)) + use):
            use = [y] + use
            x = y-1
            break

answer = sum(1<<x for x in use)
print(answer)

Measured memory_bytes: 12512
def s(x): print('', x, end = '')

def p(u):
    if u + 1: s(u); p(T[u]); p(T[u+N])
    
def i(u):
    if u + 1: i(T[u]); s(u); i(T[u+N])
    
def o(u):
    if u + 1: o(T[u]); o(T[u + N]); s(u)

N = int(input())

T = [0, 0] * N

for _ in[0] * N:
    a, b, c = map(int, input().split())
    T[a], T[a + N] = b, c

r = (set(range(N)) - set(T)).pop()

print('Preorder'); p(r)
print('\nInorder'); i(r)
print('\nPostorder'); o(r)
print()


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

const ll INF = 1LL << 60;

ll N;
vector<ll> A;

int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    // 山1に流す量を求める
    vector<ll> ans(N);

    ll tmp = 0;
    rep(i, N) {
        // 奇数個目は足す
        if (i % 2 == 0) {
            tmp += A[i];
        } else {
        // 偶数個目は減らす
            tmp -= A[i];
        }
    }
    ans[0] = tmp;

    // A[i] - (1個前の流量 / 2) 
    for (int i = 0; i <= N - 2; i++) {
        ans[i + 1] = 2 * (A[i] - (ans[i] / 2));
    }


    rep(i, N) {
        cout << ans[i] << " ";
    }
    cout << endl;
}

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

int FindSomeOfDigits(int n){
  int sum = 0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}

int main() {
  int N,A,B;
  std::cin >>N>> A>>B;
  int count=0;
  for (int i = 0; i < N+1; i++) {
    /* code */
    int sum=FindSomeOfDigits(i);
    if(sum>=A && sum<=B){
      count+=i;
    }
  }
  cout << count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n;
ll a[110];
ll t;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
	{
		cin >>a[i];
		if (!i) t=a[i];
		else
		{
			ll g=__gcd(t,a[i]);
			a[i]/=g;
			t*=a[i];
		}
	}
	cout <<t;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.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 INF 2147483647
using namespace std;



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

	string s;
	cin >> s;

	if (s.size() % 2) {
		s.pop_back();
	}
	else
	{
		s.pop_back();
		s.pop_back();
	}
	
	REPR(i, s.size() / 2)
		if (s.substr(0, i) == s.substr(i, i)) {
			cout << i*2 << endl;
			break;
		}
		s.pop_back();
		s.pop_back();		
	}


	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
int a[222222],b[222222];
int main()
{
	int n=io::F();
	for(register int i=1;i<=n;++i)
		a[i]=io::F(),b[i]=io::F();
	int fl=1,min=0x3f3f3f3f;
	for(register int i=1;i<=n;++i)
	{
		if(a[i]!=b[i])fl=0;
		if(a[i]>b[i])cmin(min,b[i]);
	}
	if(fl==1)puts("0"),exit(0);
	long long sum=0;
	for(register int i=1;i<=n;++i)sum+=a[i];
	printf("%lld\n",sum-min);
	return 0;
}

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

int main() {  
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }  
  int ans=-N; 
  for (int i = 0; i < N; i++) {
    ans+=A.at(i);      
  } 
  cout<<ans<<endl;
}

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

#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define forn(i,n) forr(i,0,n)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
#define dforn(i,n) for(int i=n-1; i>=0; i--)
#define dprint(v) cout << #v"=" << v << endl //;)
#define dpr(v) cout << #v"=" << v << endl //;)
#define dpra(a,n) { forn(i,(n)) cout << (a)[i] << (i==(n)-1?'\n':' '); }
#define dprv(vec) dpra(vec,sz(vec))

int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	
	string s;
	cin>>s;                   
	long long i=0,cntb=0,cntw=0,acb=0,ans=0;
	while(i<(int)s.length()){
		while(s[i]=='B') cntb++,i++;
		while(s[i]=='W') cntw++,i++;
		ans += ((acb+cntb)*cntw);
		acb+=cntb;
		cntb=0,cntw=0;
	}
	cout<<ans<<"\n";
 	
	return 0;
}



Measured memory_bytes: 720
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    l=int(input())
    vol=l*l*l
    print(vol/27)




if __name__ == "__main__":

    main()

Measured memory_bytes: 38256
function Main(input){
  // 文字列を格納
  input = input.trim().split('\n');
  let x = parseFloat(input);
  let i = parseFloat(100);
  let count = 0;

  while (i < x) {
    i *= 1.01;
    i = Math.floor(i);
    count++;
  }

  console.log(count);
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29688
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N;
	cin >> N;
	vector<vector<ll>> vlist(N, vector<ll>());
	vector<vector<ll>> elist(N, vector<ll>());
	for (int ii = 0; ii < N - 1; ++ii){
		ll u, v, w;
		cin >> u >> v >> w;
		u--;
		v--;
		vlist[u].push_back(v);
		elist[u].push_back(w);
		vlist[v].push_back(u);
		elist[v].push_back(w);
	}

	vector<ll> isBlack(N, -1);
	queue<ll> q;
	ll initVertex = 0;
	q.push(initVertex);
	isBlack[0] = 1;
	while (!q.empty()) {
		ll vertex = q.front();
		q.pop();
		for (int ii = 0; ii < vlist[vertex].size(); ++ii){
			ll adVertex = vlist[vertex][ii];
			ll edgeLen = elist[vertex][ii];
			if (isBlack[adVertex] == -1){
				isBlack[adVertex] = (isBlack[vertex] + edgeLen) % 2;
				q.push(adVertex);
			}
		}
	}

	for (int ii = 0; ii < N; ++ii){
		cout << isBlack[ii] << endl;
	}

	return 0;
}


Measured memory_bytes: 13184
#include <cstdio>
int n, l, r, p[222];
int main() {
	while (scanf("%d%d%d", &n, &l, &r), n | l | r) {
		for (int i = 0; i < n; i++) scanf("%d", &p[i]);
		int ret = 0, gap = -1;
		for (int i = l; i <= r; i++) {
			if (p[i - 1] - p[i] >= gap) ret = i, gap = p[i - 1] - p[i];
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2576
n = int(input())
a = [int(i) for i in input().split()]
print(" ".join([str(i) for i in a]))

for i in range(1, n):
    j = i
    while a[j - 1] > a[j] and j > 0:
        a[j], a[j - 1] = a[j - 1], a[j]
        j -= 1
    print(" ".join([str(i) for i in a]))



Measured memory_bytes: 5608
fun main(args: Array<String>){
	Sum_of_Numbers()
}
fun Sum_of_Numbers(){
	var i=0
	while(i<10000){
		var sum = 0
		val n = readLine()!!
		if(n=="0")break
		for(j in 0..n.length-1){
			sum += n.substring(j,j+1).toInt()
		}
		println(sum)
		i++
	}
}


Measured memory_bytes: 26660
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;

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

int main(){
	int a,b,k;
	cin >> a >> b >> k;
	int gcd = GCD(a,b);
	int i;
	vector<int> nums;
	int n = (int)sqrt(gcd);
	for(i=1;i<n+1;i++){
		if(gcd%i==0){
			nums.push_back(i);
			int sub = gcd/i; 
			if(i != sub){
				nums.push_back(sub);
			}
		}
	}
	sort(nums.begin(),nums.end(),greater<int>());
	cout << nums[k-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#                               #
    # author : samars_diary #
    # 16-09-2020 │ 18:28:11 #
#                               #

import sys, os.path, math

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=ii()
    print(((10**a)-2*(9**a)+(8**a))%mod())
for _ in range(1):
    solve()

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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a.at(i);

    long long sum = 0;
    int tmp;
    for (int i = 1; i < n; i++) {
        if (a.at(i) < a.at(i-1)) {
            tmp = a.at(i-1) - a.at(i);
            a.at(i) += tmp;
            sum += tmp;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4044
import java.util.Scanner;

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

		if (y > x * 4 || y % 2 == 1 || x > 50 || x >= y || y < x * 2) {
			System.out.println("No");
		} else if (x > 0 && y == 0) {
			System.out.println("No");
		} else if (x > 25 && y > 100) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

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

public class Coder
{

    public static int[] ReadArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));
    }

    public static int ReadInt()
    {
        return Convert.ToInt32(Console.ReadLine());
    }

    public static string ReadStr()
    {
        return Console.ReadLine();
    }

    public static long ReadLong()
    {
        return Convert.ToInt64(Console.ReadLine());
    }

    public static long[] ReadLongArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt64(m));

    }

    public static void Main()
    {

        long[] A = ReadLongArray();

        long N = A[0];
        long K = A[1];

        long n = N % K;
        Console.WriteLine(Math.Min(n,Math.Abs(n-K)));

        
    

    }

}

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

public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[][]dp;
	static long[]arr;
	static long solve(int i,int j)
	{
		if(i>j)
			return 0;
		if(dp[i][j]!=-1)
			return dp[i][j];
		long res=0;
		res=Math.max(arr[i]-solve(i+1,j),arr[j]-solve(i,j-1));
		dp[i][j]=res;
		return res;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		int n=cin();
		arr=splitL();
		dp=new long[n+1][n+1];
		for(int i=0;i<=n;i++)
		{
			Arrays.fill(dp[i], -1);
		}
		System.out.println(solve(0,n-1));
	}
}


Measured memory_bytes: 105308
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	public static void main(String args[]) {
		MyInput in = new MyInput();

    int N = in.nextInt();
    boolean flg = false;

    while(N != 0) {
        if(N % 10 == 9) {
            flg = true;
            break;
        }
        N = N / 10;
    }
    if(flg) {
        System.out.println("Yes");
    } else {
        System.out.println("No");
    }
	}
}

class MyInput {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr= 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		}else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch(IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	public int readByte() { 
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <=126;
	}

	private void skipUnprintable() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if(!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if(!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if(b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true) {
			if('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			}else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

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



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

int main() {
  long long N;
  cin >> N;

  long long ans =0;
  for(long long i=1; i<=N; i++){
    if (i%3!=0 && i%5!=0) {
      ans +=i;
    }
  }
  cout << ans << endl;

}


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

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    ll sum = 0;
    REP(i, n+1) {
        if(i%3==0 || i%5==0) continue;
        sum += i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    if(n%10 == 3) cout << "bon" << endl;
    else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

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

int N, Q;

int main() {
  while (cin >> N >> Q) {
    if (N == 0) break;
    map<int,int> ma;
    for (int i = 0; i < N; ++i) {
      int M; cin >> M;
      for (int j = 0; j < M; ++j) {
	int a; cin >> a;
	ma[a]++;
      }
    }
    int Max = -1, pMax = -1;
    for (map<int,int>::iterator it = ma.begin(); it != ma.end(); ++it) {
      if (it->second > Max && it->second >= Q) {
	Max = it->second;
	pMax = it->first;
      }
    }
    cout << (pMax != -1 ? pMax : 0)  << endl;
  }
}


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

int main()
{
    int n,submissions;
    scanf("%d %d",&n,&submissions);
    int ar[n+1],WA[n+1];
    memset(ar,0,sizeof(ar));
    memset(WA,0,sizeof(WA));
    int penalty=0,correct=0;
    while(submissions--){
        int sl;
        string verdict;
        cin>>sl>>verdict;
        if(verdict=="AC"){
            if(ar[sl]==0){
                ar[sl]=1;
                correct++;
                penalty+=WA[sl];
            }
        }
        else{
            if(ar[sl]==0) WA[sl]++;
        }
    }
    printf("%d %d",correct,penalty);
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
#print(N)
card = list(map(int, input().split()))
#print(card)

for i in range(N):
    v = card[i]
    j = i - 1
    while j >= 0 and card[j] > v:
        card[j+1] = card[j]
        j = j -1
    card[j+1] = v
    #print(card)
    card_str = ""
    
    for k in range(N):
        card_str += str(card[k])
        card_str += " "
    
    print(card_str[:-1])

    

Measured memory_bytes: 7668
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int main()
{
    int n = 0, b;
    long c = 0;
    cin >> n;
    vector<int> mp(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        cin >> b;
        if (i - b >= 0)
        {
            c += mp[i - b];
        }
        if (i + b < n + 1)
        {
            mp[i + b]++;
        }
    }
    cout << c;
    return 0;
}

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

int main(void){
	int n;
	cin >> n;
	vector<int> s(30, 0);
	for(int i = 0; i < n; ++i){
		char tmp;
		cin >> tmp;
		s[tmp - 'A'] = 1;
	}
	int ans = 0;
	for(auto x : s){
		if(x == 1) ans++;
	}
	cout << (ans == 3 ? "Three" : "Four") << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'

using namespace std;
typedef vector<ll>   vll;
typedef vector<int>   vi;
typedef set<ll>      sll;
typedef set<int>      si;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

ll i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}

// #define cerr if(0)cerr
void solve()
{
  ll x,a; cin>>x>>a;
  if(x<a) cout<<0;
  else cout<<10;
  cout<<'\n';
}

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

#define max 50

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int digit(int a){int i=0;while (a!=0) {a=a/10;i++;}return i;}

int main()
{
    int n, dig;
    
    scanf("%d", &n);
    
    dig=digit(n);
    
    switch (dig) {
        case 1:
            printf("%d", n);
            break;
        case 2:
            printf("%d", 9);
            break;
        case 3:
            printf("%d", n-90);
            break;
        case 4:
            printf("%d", 909);
            break;
        case 5:
            printf("%d", n-9090);
            break;
        case 6:
            printf("%d", 90909);
            break;
            
        default:
            break;
    }

    return 0;
}



Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);
        
        try {
            st = new StringTokenizer(br.readLine());
            int x = Integer.parseInt(st.nextToken());
            int n = Integer.parseInt(st.nextToken());
            st = new StringTokenizer(br.readLine());
            HashSet<Integer> hs = new HashSet<>();
            for(int i=0 ; i<n ; i++) {
                int u = Integer.parseInt(st.nextToken());
                hs.add(u);
            }

            int l = x;
            int r = x;
            while(hs.contains(l)) l--;
            while(hs.contains(r)) r++;
            if(x-l <= r-x) {
                pw.print(l);
            }
            else {
                pw.print(r);
            }
        }
        finally {
            pw.flush();
            pw.close();
        }
    }
}


Measured memory_bytes: 32704
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 1e18;

signed main() {
  int a, b, q;
  cin >> a >> b >> q;
  vector<int> s(a + 2), t(b + 2), x(q);

  for (int i = 1; i <= a; i++) {
    cin >> s[i];
  }

  for (int i = 1; i <= b; i++) {
    cin >> t[i];
  }
  s[0] = t[0] = -1 * inf;
  s[a + 1] = t[b + 1] = inf;
  for (auto &&w : x) {
    cin >> w;
  }
  //   sort(s.begin(), s.end());
  //   sort(t.begin(), t.end());

  for (auto &&w : x) {
    int res = inf;
    int ls = lower_bound(s.begin(), s.end(), w) - s.begin();
    int lt = lower_bound(t.begin(), t.end(), w) - t.begin();
    for (int is : {ls - 1, ls})
      for (int it : {lt - 1, lt}) {
        res = min(res, abs(w - s[is]) + abs(s[is] - t[it]));
        res = min(res, abs(w - t[it]) + abs(s[is] - t[it]));
      }
    cout << res << endl;
  }
}


Measured memory_bytes: 3712