akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const ll INF = 1e18;
const int mod = 1e9+7;
const int MAX = 1e6;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問の有無

int gcd(int a, int b) { // aとbの最大公約数（ユークリッドの互除法）
    if (b == 0) return a;
    return gcd(b, a % b);
}

int seive[MAX+1]; // 整数の素因数で最小のもの

void erat() { // エラトステネスのふるい
    rep(i, MAX+1) seive[i] = i;
    for (int i = 2; i <= MAX; i++) {
        if (seive[i] == i) {
            for (int j = i + i; j <= MAX; j += i) {
                seive[j] = i;
            }
        }
    }
}

void prime_fact(int x, set<int> &fact) { // 素因数分解
    if (x < 2) return;
    while (x > 1 && x % seive[x] == 0) {
        fact.insert(seive[x]);
        x /= seive[x];
    }
}

int n;
int a[MAX];
set<int> s;
bool flag = true;

int main() {
// input
    erat();
    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }
// solve
    rep(i, n) {
        if (a[i] == 1) continue;
        if (flag) {
            set<int> fact;
            prime_fact(a[i], fact);
            for (int x : fact) {
                if (not s.count(x)) {
                    s.insert(x);
                } else {
                    flag = false;
                    break;
                }
            }
        }
        if (i > 0) a[i] = gcd(a[i], a[i-1]);
    }
// output
    if (flag) cout << "pairwise coprime" << "\n";
    else if (a[n-1] == 1) cout << "setwise coprime" << "\n";
    else cout << "not coprime" << "\n";
}

Measured memory_bytes: 11500
# -*- coding: utf-8 -*-

if __name__ == '__main__':

	l = input()
	S1, S2 = [], []
	
	sum = 0
	n = len(l)
	for i in range(n):
		if l[i] == "\\":
			S1.append(i)
		elif l[i] == "/" and S1:
			j = S1.pop()
			a = i - j
			sum += a
	
			while S2 and S2[-1][0] > j:
				a += S2.pop()[1]
			S2.append([j, a])
	
	print(sum)
	print(len(S2), *(a for j, a in S2))

Measured memory_bytes: 8244
def main():
    S = input()
    K = int(input())

    lst = list(S)
    apnd = lst.append
    l = len(S)
    for n in range(2, 6):
        for i in range(l - n + 1):
            apnd(S[i:i+n])

    lst = sorted(set(lst))
    print(lst[K-1])

main()


Measured memory_bytes: 5068
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
int main() {
	int n;
	cin >> n;
	vector<vector<int>> da(n);
	for (int i = 0;i < n - 1;i++) {
		int x, y;
		cin >> x >> y;
		da[x - 1].push_back(y - 1);
		da[y - 1].push_back(x - 1);
	}
	queue<int> q;
	vector<long long> dp(n, 1), dpp(n, 1), gg(n);
	vector<bool> ju(n, false);
	for (int i = 0;i < n;i++) {
		gg[i] = da[i].size();
		if (gg[i] == 1) {
			gg[i]--;
			q.push(i);
			ju[i] = true;
		}
	}
	int co = n-1, ans = 2;
	while (co > 0) {
		int x = q.front();
		q.pop();
		ju[x] = true;
		long long b = 1, w = 1;
		for (int i = 0;i < da[x].size();i++) {
			gg[da[x][i]]--;
			if (ju[da[x][i]]) {
				w = (w*(dp[da[x][i]] + dpp[da[x][i]])) % 1000000007;
				b = (b*dp[da[x][i]]) % 1000000007;
			}
			if (gg[da[x][i]] == 1) {
				q.push(da[x][i]);
			}
		}
		dp[x] = w;
		dpp[x] = b;
		if (q.empty()) {
			ans = (dp[x] + dpp[x])%1000000007;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 9088
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N,x = II()
a = III()

dp = [[float('inf')]*N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if j==0:
            dp[i][j] = a[i]
        else:
            dp[i][j] = min(dp[i][j-1], a[(i-j)%N])

ans = float('inf')
for j in range(N):
    now = j*x
    for i in range(N):
        now += dp[i][j]
    if now<ans:
        ans = now

print(ans)

Measured memory_bytes: 141404
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    vector<int> A( N );
    for( auto &x : A )
    {
        cin >> x;
    }
    sort( ALL( A ) );
    int res{};
    REP( i, N )
    {
        i % 2 == 0 ? res -= A[ i ] : res += A[ i ];
    }
    cout << abs( res ) << endl;
    return 0;
}

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

int main(){
    int K,T;
    cin >> K >> T;
    priority_queue<pair<int,int>> que;
    rep(i,T){
        int a;
        cin >> a;
        que.push(make_pair(a,i));
    }
    int before = -1;
    rep(i,K){
        auto a = que.top();
        que.pop();
        if(a.second == before){
            if(!que.empty()){
                auto b = que.top();
                que.pop();
                before = b.second;
                b.first--;
                if(b.first != 0) que.push(b);
                que.push(a);
            }else{
                cout << a.first << endl;
                return 0;
            }
        }else{
            before = a.second;
            a.first--;
            if(a.first != 0) que.push(a);
        }
    }
    cout << 0 << endl;
    
    return 0;
}

Measured memory_bytes: 256
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

ans = 3000
for bits in range(4**n):
    xa = xb = xc = 0
    tmp_ans = 0
    for i in range(n):
        f = (bits//(4**i)) % 4
        if f == 1:
            if xa != 0:
                tmp_ans += 10
            xa += l[i]
        elif f == 2:
            if xb != 0:
                tmp_ans += 10
            xb += l[i]
        elif f == 3:
            if xc != 0:
                tmp_ans += 10
            xc += l[i]

    if xa == 0 or xb == 0 or xc == 0:
        continue
    
    tmp_ans += abs(a - xa) + abs(b - xb) + abs(c - xc)
    ans = min(ans, tmp_ans)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n % 2 == 0)
        printf("0.5000000\n");
    else{
        int p = n / 2;
        p++;
        double ans = (double) p / n;
        printf("%.7f\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3704
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,k,ans;

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    cin>>n>>k;
    while(n!=0)
    {
        ans++;
        n/=k;
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 10000000
#define ll long long
using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    ll p=s.size();
    ll q=t.size();
    ll ans=10000000;
    for(ll i=0; i<=p-q; i++){
        ll count=0;
        for(ll j=0; j<q; j++){
            if(s[i+j]!=t[j]) count++;
        }
        if(ans>count) ans=count;
    }
    
    cout<<ans<<endl;
}

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

int main() {
    long long int n;
    long long int k;
    cin >> n >> k;
    
    int counter = 0;
    while(n) {
        n /= k;
        counter++;
    }

    cout << setprecision(15) << counter << endl;


    return 0;
}

Measured memory_bytes: 256
//0039
//include-------------------------------------
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<stack>

using namespace std;

//typedef--------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define MP make_pair

//repetition-----------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

//constant-------------------------------------
const double PI = acos(-1.0);

//cout,cin-------------------------------------
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)

int f(char c){
	if (c == 'I') return 1;
	else if (c == 'V') return 5;
	else if (c == 'X') return 10;
	else if (c == 'L') return 50;
	else if (c == 'C') return 100;
	else if (c == 'D') return 500;
	else if (c == 'M') return 1000;
}

int main(){
	int ans = 0;
	string st;
	while (CIN(st)){
		 int now = f(st[0]);
		 if (st.size() == 1) ans = now;
		 ans = now;
		 REP(i, st.size() - 1){
			 now >= f(st[i + 1]) ? ans += f(st[i + 1]) : ans += f(st[i + 1]) - now - now;
			 now = f(st[i + 1]);
		 }
		 COUT(ans);
	}



	return 0;

}

Measured memory_bytes: 1180
#include<iostream>
#include<algorithm>
#include<math.h>
#define _USE_MATH_DEFINES

using namespace std;

int a, b, c, d;

int main(){
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    long long d, n;
    cin >> d >> n;

    if(n == 100) cout << setprecision(15) << pow(100, d) * 101 << endl;
    if(n != 100) cout << setprecision(15) << pow(100, d) * n << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int[] nums = sc.nextIntArray(3);
    Arrays.sort(nums);
    System.out.println(nums[2] * 10 + nums[0] + nums[1]);
  }
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    vector<vector<ll>> c(3,vector<ll>(3));
    rep(i,3)rep(j,3)cin >> c[i][j];
    bool ok = true;
    rep(i,2){
        bool temp = true;
        ll sub = c[i+1][0] - c[i][0];
        rep(j,2)temp &= ((c[i+1][j+1] - c[i][j+1]) == sub);
        ok &= temp;
    }
    rep(i,2){
        bool temp = true;
        ll sub = c[0][i+1] - c[0][i];
        rep(j,2)temp &= ((c[j+1][i+1] - c[j+1][i]) == sub);
        ok &= temp;
    }

    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
a =  list(map(int, input().split()))
d = {}
c = 0
for x in a:
    d[x] = d.get(x, 0) + 1
for y,z in d.items():
    if y < z:
        c += z-y
    if y > z:
        c += z
print(c)


Measured memory_bytes: 17780
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

M, D = map(int, input().split())

ans = 0

for d in range(20, D + 1):
    for m in range(1, M+1):
        a, b = map(int, str(d))
        if m == a*b and b >= 2:
            ans += 1


print(ans)


Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		long n = sc.nextLong();
		long x = sc.nextLong();

		long a = Math.max(x, n - x);
		long b = Math.min(x, n - x);

		long total = 0;

		while (b != 0) {

			total += b * 3 * (a / b);

			long tmp = a;
			a = b;
			b = tmp % b;
		}

		out.println(total);
		out.flush();
	}

}

class FastScanner {
	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;
	}

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

	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}

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

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

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		byte 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();
		}
	}
}

Measured memory_bytes: 8020
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = n / b * b - 1;
    x -= b * 100;

    ll ans = -INF;
    while (x + b <= n) {
        x += b;
        if (x < 0) continue;
        chmax(ans, a * x / b - a * (x / b));
    }
    chmax(ans, a * n / b - a * (n / b));
    cout << ans << endl;


}

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

using namespace std;

const int maxn = 100010;

struct Edge {
	int v, x;
} E[maxn << 1];

int l[maxn], n, dep[maxn], fa[maxn], vis[maxn], ok = 1, e;

struct CMP {
	bool operator()(const int &a, const int &b) const {
		if (dep[a] == dep[b]) return a < b;
		return dep[a] > dep[b];
	}
};

set<int, CMP> st;

inline void addEdge(int u, int v) {
	E[e].v = v; E[e].x = l[u]; l[u] = e++;
}

void dfs(int u, int f) {
	fa[u] = f;
	for (int p = l[u]; p >= 0; p = E[p].x) {
		int v = E[p].v;
		if (v != f) {
			dep[v] = dep[u] + 1;
			dfs(v, u);
		}
	}
}

int main() {
	memset(l, -1, sizeof(l));
	scanf("%d", &n);
	if (n & 1) {
		puts("First");
		return 0;
	}
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		addEdge(u, v);
		addEdge(v, u);
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++) st.insert(i);
	while (!st.empty()) {
		int u = *(st.begin());
		if (vis[fa[u]]) {
			ok = 0;
			break;
		}
		vis[fa[u]] = vis[u] = 1;
		st.erase(fa[u]);
		st.erase(u);
	}
	if (!ok) puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 8064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int div_round_down(int a, int b) {
  if (b < 0) return div_round_down(-a, -b);
  if (a >= 0) return a / b;
  return -(((-a) + b - 1) / b);
}

int main() {
  int h, w, d;
  scanf("%d %d %d", &h, &w, &d);
  const char colors[] = "RYGB";
  for (int y = 0; y < h; ++y) {
    for (int x = 0; x < w; ++x) {
      int color;
      if (d % 2 == 1) color = (x + y) % 2;
      else {
        int a = ((x + y) / d) % 2;
        int b = (div_round_down(x - y, d) % 2 + 2) % 2;
        color = 2 * a + b;
      }
      printf("%c", colors[color]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B - A - B + 1 << "\n";

    return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++)cin>>x[i];
  
  sort(x.begin(), x.end());
  
  long long ans=INT_MAX;
  for(int i=x[0];i<=x[n-1];i++){
    long long cnt=0;
    
    for(int j=0;j<n;j++){
      cnt+=(x[j]-i)*(x[j]-i);
    }
    
    ans=min(ans, cnt);
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt(),D=sc.nextInt();
	 int count=0;
	 int index=0;
	 
	 while(true) {
		 if(index+(2*D+1)>=N) {
			 count++;
			 break;
		 }
		 else {
			 index+=(2*D+1);
			 count++;
		 }
	 }
	 System.out.println(count);
	 
 }
	


}




Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<pii> ab(n);
  rep(i,n) cin >> ab[i].first >> ab[i].second;
  sort(ab.begin(), ab.end());
  ll ans = 0;
  ll count = 0;
  rep(i, n) {
    if (count >= m) break;
    int a = ab[i].first;
    int b = ab[i].second;
    ll temp = min(m - count,(ll) b);
    ans += (temp * a);
    count += temp;
  }
  cout << ans << endl;

}

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

Measured memory_bytes: 1024
from itertools import product
from collections import deque

class ZeroOneBFS:
    def __init__(self, N):
        self.N = N # #vertices
        self.E = [[] for _ in range(N)]
        
    def add_edge(self, init, end, weight, undirected=False):
        assert weight in [0, 1]
        self.E[init].append((end, weight))
        if undirected: self.E[end].append((init, weight))
        
    def distance(self, s):
        INF = float('inf')
        self.dist = [INF] * self.N # the distance of each vertex from s
        self.prev = [-1] * self.N # the previous vertex of each vertex on a shortest path from s
        visited = [False] * self.N
        dq = deque([(0, -1, s)]) # (dist, prev, vertex)
        n_visited = 0 # #(visited vertices)
        while dq:
            d, p, v = dq.popleft()
            if visited[v]: continue # (s,v)-shortest path is already calculated
            self.dist[v] = d; self.prev[v] = p; visited[v] = True
            n_visited += 1
            if n_visited == self.N: break
            for u, c in self.E[v]:
                if visited[u]: continue
                if c == 0: dq.appendleft((d, v, u))
                else: dq.append((d + 1, v, u))
        return self.dist
    
    def shortest_path(self, t):
        P = []
        prev = self.prev
        while True:
            P.append(t)
            t = prev[t]
            if t == -1: break
        return P[::-1]

H, W = map(int, input().split())
zobfs = ZeroOneBFS(H * W)
 
def vtx(i, j): return i*W + j
def coord(n): return divmod(n, W)
 
grid = [input() for _ in range(H)] # |string| = W
E = [[] for _ in range(H * W)]
ans = 0 if grid[0][0] == '.' else 1
for i, j in product(range(H), range(W)):
    v = vtx(i, j)
    check = [vtx(i+dx, j+dy) for dx, dy in [(1, 0), (0, 1)] if i+dx <= H-1 and j+dy <= W-1]
    for u in check:
        x, y = coord(u)
        if grid[i][j] == '.' and grid[x][y] == '#':
            zobfs.add_edge(v, u, 1)
        else:
            zobfs.add_edge(v, u, 0)
dist = zobfs.distance(0)
ans += dist[vtx(H-1, W-1)]
print(ans)

Measured memory_bytes: 7412
package main

import "fmt"

var N, X int
var l int
var L []int

func main() {
	fmt.Scan(&N, &X)
	L = make([]int, N)
	total := 0
	i := 0
	for i = 0; i < N; i++ {
		fmt.Scan(&l)
		L[i] = l
	}
	for i = 0; i < N; i++ {
		total += L[i]
		if total > X {
			break
		}
	}
	fmt.Println(i + 1)
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

const ll mod=924844033;

ll dp[4002][2002][2]={0};
ll fact[2001];

int main()
{
    fact[0]=1;
    for(ll i=1; i<=2000; ++i) fact[i]=(i*fact[i-1])%mod;

    int n,k;
    cin >>n >>k;

    vector<bool> vis(2*n,false);
    vector<pi> edge;
    vector<bool> conneced_prev;
    rep(i,n)
    {
        if(vis[i]) continue;

        int ii=i;
        int jj=i-k;
        if(jj<0) jj+=2*k;

        if(jj>=n) continue;

        edge.pb(pi(ii,jj));
        conneced_prev.pb(false);
        while(1)
        {
            if(ii<jj) ii+=2*k;
            else jj+=2*k;

            if(ii>=n || jj>=n) break;

            edge.pb(pi(ii,jj));
            conneced_prev.pb(true);
            vis[ii]=vis[jj+n]=true;
        }
    }

    int E=edge.size();
    // rep(i,E) printf(" edge %d = (%d,%d) , prev=%d\n", i,edge[i].fi,edge[i].se+n, (int)conneced_prev[i]);

    dp[0][0][0]=1;
    rep(i,E)
    {
        rep(j,min(2001,i+1))
        {
            // i番目の辺を使う
            (dp[i+1][j+1][1] += dp[i][j][0]) %= mod;
            if(!conneced_prev[i]) (dp[i+1][j+1][1] += dp[i][j][1]) %= mod;

            // i番目の辺を使わない
            (dp[i+1][j][0] += dp[i][j][0]+dp[i][j][1]) %= mod;
        }
    }

    vector<ll> M(E+1);
    rep(i,E+1) M[i] = (dp[E][i][0]+dp[E][i][1])%mod;

    ll sub=0;
    for(int i=1; i<=min(E,n); ++i)
    {
        if(i%2==0) sub = (sub - (M[i]*fact[n-i])%mod + mod)%mod;
        else sub = (sub + (M[i]*fact[n-i])%mod)%mod;
    }

    ll ans=(fact[n]-sub+mod)%mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 101632
n=int(input())
from collections import defaultdict
d=defaultdict(int)

for i in range(1,n+1):
  d[str(i)[0]+str(i)[-1]]+=1

sm=0
for i in range(1,10):
  for j in range(1,10):
    sm+=d[str(i)+str(j)]*d[str(j)+str(i)]
print(sm)

Measured memory_bytes: 9356
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200;
int nxt[maxn][26], tmp[26];
int main(){
	string s, t;
	cin >> s >> t;
	int lens = s.size(), lent = t.size();
	for(int i = 0; i < 26; i++) tmp[i] = -1, nxt[lens][i] = -1;
	for(int i = lens - 1; i >= 0; i--){
		tmp[s[i] - 'a'] = i;
		for(int j = 0; j < 26; j++) nxt[i][j] = tmp[j];
	}
	long long ans = 0;
	int pos = 0;
	for(int i = 0; i < lent;){
		int wt = t[i] - 'a';
		if(nxt[pos][wt] == -1 && pos == 0){
			cout << -1 << endl;
			return 0;
		}
		if(nxt[pos][wt] == -1){
			ans += lens - pos;
			pos = 0;
			continue;
		}
		ans += nxt[pos][wt] - pos + 1;
		pos = nxt[pos][wt] + 1;
		i++;
		if(pos == lens) pos = 0;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    int a = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 2 == 1) a++;
    }

    printf("%lf\n", (double)a / (double)N);
}

Measured memory_bytes: 256
INF = 10 **9 
v , e = map(int,input().split())
route = [[] for i in range(v)]
for i in range(e):
    s , t , d = map(int,input().split())
    route[s].append((t,d))

dp = [[INF for i in range(v)] for j in range(2**v)]

dp[0][0] = 0

for i in range(2**v):
    for j in range(v):
        for k , d in route[j]:
            if (i>>k) & 1 == 1:
                continue
            dp[i | (1<<k)][k] = min(dp[i | (1<<k)][k],dp[i][j] + d) 

print(dp[-1][0] if dp[-1][0] != INF else -1)


Measured memory_bytes: 20060
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

long long extgcd(long long a, long long b, long long &x, long long &y) {
    long long ret = a;
    if (b != 0) {
        ret = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return ret;
}

int main() {
    
    ll a,b,x,y;
    cin >> a >> b;
    extgcd(a,b,x,y);

    cout << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 3092
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, C;
pair<pair<int,int>, int> pro[100000];

signed main(){
	cin >> N >> C;
	rep(i, N){
		cin >> pro[i].first.first >> pro[i].first.second >> pro[i].second;
	}
	sort(pro, pro+N);

	rep(c, C){
		int rec[30];
		bool flg = true;
		rep(i, c+1) rec[i] = -1;
		rep(i, N){
			rep(j, c+1){
				if(rec[j] == -1 || pro[rec[j]].first.second < pro[i].first.first){
					rec[j] = i;
					break;
				}
				else if(pro[rec[j]].second == pro[i].second && pro[rec[j]].first.second <= pro[i].first.first){
					rec[j] = i;
					break;
				}
				if(j == c) flg = false;
			}
		}
		if(flg){
			cout << c+1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1408
N, M , K = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
t = 0
R = 0
tmp = 0
for i in range(M):
    if tmp + Y[i] > K:
        break
    R += 1
    tmp += Y[i]

sY = sum(Y)
j = M
for i in range(N):
    t += X[i]
    if t > K:
        break
    while j:
        if sY + t <= K:
            break
        j-=1
        sY -= Y[j]
    R = max(R, j+i+1)
print(R)


Measured memory_bytes: 111028
#include<iostream>

using namespace std;

int main(void){

    int n, m, l, i, j, k;

    cin >> n >> m >> l;

     long int a[n][m], b[m][l], c[100][100] = {0};

    for(i = 0;i < n;i++){
        for(j = 0;j < m;j++){
            cin >> a[i][j];
        }
    }//?????´??????????????\???

    for(i = 0;i < m;i++){
        for(j = 0;j < l;j++){
            cin >> b[i][j];
        }
    }//?????´??????????????\???

    for(i = 0;i < n;i++){
        for(j = 0;j < l;j++){
            for(k = 0;k < m;k++){
                c[i][j] = c[i][j] + a[i][k] * b[k][j];
            }
        }
    }//???????????????????????¨????´??????????

    for(i = 0;i < n;i++){
        for(j = 0;j < l;j++){
        if(j != l - 1){cout << c[i][j] << ' ';
        }
        else{cout << c[i][j];
        }
        }
        cout << endl;   
     }

return 0;
}

Measured memory_bytes: 1400
/*
    Take me to church
    I'll worship like a dog at the shrine of your lies
    I'll tell you my sins and you can sharpen your knife
    Offer me that deathless death
    Good God, let me give you my life
*/
#include<bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, A[N], P[N];
long long dp[N], dp2[N];
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++)
        scanf("%d", &A[i]), P[i] = P[i - 1] + (A[i] + 1 & 1);
    long long SM = 0;
    for (int i = 1; i <= n; i ++)
    {
        SM += A[i];
        dp[i] = SM;
        int w = 0;
        if (!A[i]) w = 2;
        if (A[i] & 1) w = 1;
        dp[i] = min(dp[i], dp[i - 1] + w);
    }
    SM = 0;
    for (int i = n; i; i --)
    {
        SM += A[i];
        dp2[i - 1] = SM;
        int w = 0;
        if (!A[i]) w = 2;
        if (A[i] & 1) w = 1;
        dp2[i - 1] = min(dp2[i - 1], dp2[i] + w);
    }
    long long Mn = LLONG_MAX, Mx = 0;
    for (int i = 1; i <= n; i ++)
        Mx = max(Mx, P[i] - dp[i]), Mn = min(Mn, dp2[i] + P[i] - Mx);
    return !printf("%lld\n", Mn);
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define   FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define   vi vector<long long>
#define   vvi vector<vector<long long>>
#define   all(a) (a).begin(), (a).end()
#define   rep(i,a,b)  for(int  i=a;i<b;i++)
#define   tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define   pb push_back
#define   endl "\n"
#define   dbg(x,y) cout<<(x)<<" -->  "<<(y)<<endl
#define   dbg2(k)   cout<<(k)<<" * "<<endl;
#define   F first
#define   S second
#define   int long long
#define   ll long long

const int  inf=1e6+2;
const int  ninf=-1e9 ;
const int  mod=1e9+7;
int cost[200005],h[200005];
int BIT[200005];
int n;
void update(int idx,int val)
{
	while(idx<n)
	{
	   BIT[idx]=max(BIT[idx],val);
	   idx+=((idx)&(-idx));
	}
}

int fun(int idx)
{
	int ans=0;
	
	while(idx>0)
	{
	  ans=max(ans,BIT[idx]);
	  idx-=(idx&(-idx));	
	}
	return ans;
}


void solve()
{
  	int m,i,j,x,d,bt,y,p,g,k,low,high,res,mid,q;
  	cin>>n;
  	for(i=0;i<n;i++)
  	{
  		cin>>h[i];
	}
	for(i=0;i<n;i++)
  	{
  		cin>>cost[i];
	}
	int ans=0;
	for(i=0;i<n;i++)
  	{
  	  mid=fun(h[i]-1);
  	  res=mid+cost[i];
//  	  cout<<i<<" "<<mid<<" "<<res<<" "<<h[i]<<endl;
  	  ans=max(ans,res);
  	  update(h[i],res);
  	}
	   
	cout<<ans<<endl;	
}
signed main()
{
//   FASTIO;
   int T;
   T=1;
//   cin>>T;
   while(T--)
   {
    solve();
   }
   return 0;
}


Measured memory_bytes: 8300
#include<vector>
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()

const int N = 1000001;
const int M = 30;

bool table[M][N];
bool isprime[N];

void generate(){
  for(int i=0;i<N;i+=2)isprime[i]=false;
  for(int i=1;i<N;i+=2)isprime[i]=true;
  isprime[2]=true;
  for(int i=3;i*i <= N ;i+=2){
    if (isprime[i]){
      for(int j=2*i;j<N;j+=i)isprime[j]=false;
    }
  }
}

void solve(int n,int lim,vector<int> & price){
  rep(i,n)rep(j,lim+1)table[i][j]=false;
  
  for(int i=0;i<lim+1;i+=price[0]){
    table[0][i]=true;
  }

  REP(i,1,price.size()){
    rep(j,lim+1){
      table[i][j]=table[i-1][j];
      if (j-price[i] < 0)continue;
      table[i][j]|=(table[i][j-price[i]]);
    }
  }

  for(int i=lim;i>0;i--){
    if (isprime[i] && table[n-1][i]){
      cout << i << endl;
      return;
    }
  }
  cout << "NA" << endl;
}


main(){
  int n;
  int lim;
  generate();
  while(cin>>n>>lim && n){
    vector<int> a;
    int tmp;
    rep(i,n){
      cin>>tmp;
      a.push_back(tmp);
    }
    solve(n,lim,a);
  }
  return false;
}

Measured memory_bytes: 30000
#include<iostream>
#include<cstdio>
using namespace std;
int Tsukasa[1000];  //Oya
int Hizikata[1000]; //Ko-Hidari
int Yuuma[1000];    //Ko-Migi  May Be Yuma
bool used[1000];
int counter=0,n,Pos;
bool finfin=false;

void Init(int n){
  for(int i=0;i<n;i++){
    Tsukasa[i]=-1;
    Hizikata[i]=-1;
    Yuuma[i]=-1;
    used[i]=false;
  }
  
}

int SRoot(int n){
  for(int i=0;i<n;i++)if(Tsukasa[i] == -1)return i;
  return -2;
}

void Print(int s){
  printf("%d",s);
  counter++;
  if(counter != n)printf(" ");
  used[s]=true;
}

int MLS(void){
  for(int i=0;i<n;i++){
    if(!used[i] && Hizikata[i] != -1)return i;
  }
  return -3;
}
// MLS(Mottomo Left_wo Search)

int MMS(){
  for(int i=0;i<n;i++)if(!used[i] && Yuuma[i] == -1)return i;
  return -3;
}
// MMS(Mottomo Migi_wo Siraberu)

void BInit(int n){
  for(int i=0;i<n;i++){
    used[i] = false;
  }
}
int Pre(int s){
  /*
  if(Hizikata[s] == -1 && Yuuma[s] == -1){
    printf("%d",s);
    counter++;
    if(counter != n)printf(" ");
    return 0;
  }
  printf("%d",s);
  counter++;
  if(counter != n)printf(" ");
  if(Hizikata[s] != -1){
    Pre(Hizikata[s]);
  }
  if(Yuuma[s] != -1){
    Pre(Yuuma[s]);
  }
  */
  if(s!= -1){
  Print(s);
  Pre(Hizikata[s]);
  Pre(Yuuma[s]);
  }
}



int Rget(){
  for(int i=0;i<n;i++)if(Tsukasa[i] == -1)return i;

}

int In(int s){
  if(s != -1){
    In(Hizikata[s]);
    Print(s);
    In(Yuuma[s]);
  }


}



int Po(int s){
  /*
  if(used[s])return 0;
    if(!used[s] && (Hizikata[s] == -1 || used[Hizikata[s]]) && (Yuuma[s] == -1 || used[Yuuma[s]])){
      Print(s);
      if(!used[Yuuma[Tsukasa[s]]] && Yuuma[Tsukasa[s]] != -1)Print(Yuuma[Tsukasa[s]]);
      if(!used[Tsukasa[s]] && Tsukasa[s] != -1)Print(Tsukasa[s]);
    }
    else{
    Po(Hizikata[s]);
    Po(Yuuma[s]);
    }
  */

  if(s != -1){
    Po(Hizikata[s]);
    Po(Yuuma[s]);
    Print(s);
  }

}

int main(){
  int id,lef,rig,rn;
 
  scanf("%d\n",&n);
 
  Init(n);
  rn = n;
  while(rn-- > 0){
    scanf("%d %d %d\n",&id,&lef,&rig);
    Tsukasa[lef] = Tsukasa[rig] = id;
    Hizikata[id] = lef;
    Yuuma[id] = rig;
  }
  
  /*
    for(int i=0;i<n;i++){
    cout << "tukasa = " << Tsukasa[i] << endl;
    }
    
    for(int i=0;i<n;i++){
    cout << "hiji = " << Hizikata[i] << endl;
    }
    for(int i=0;i<n;i++){
    cout << "Yuuma = " << Yuuma[i] << endl;
    }
  */
  printf("Preorder\n");
  counter=0;
  printf(" ");
  Pre(SRoot(n));
  printf("\n");

  BInit(n);
  counter=0;
  printf("Inorder\n");
  printf(" ");
  In(SRoot(n));
  printf("\n");

  BInit(n);
  counter=0;
  printf("Postorder\n");
  finfin=false;
  BInit(n);
  printf(" ");
  Po(SRoot(n));
  printf("\n");
  return 0;
}

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

using namespace std;

int main(){
    long long N, M;
    cin >> N >> M;
    long long arr[N];
    multiset <long long, greater <long long> > s;
    multiset <long long, greater <long long> > :: iterator itr; 
    for(long long i = 0; i < N; i++){
        cin >> arr[i];
        s.insert(arr[i]);
    }
    itr = s.begin();
    while(M > 0){
        itr = s.begin();
        long long x = *itr;
        s.erase(itr);
        s.insert(x / 2);
        M--;
    }
    long long sum = 0;
    for(itr = s.begin(); itr != s.end(); itr++){
        sum += *itr;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  
  vector<vector<int>> a(n, vector<int>(2));
  for(int i=0; i<n; i++){
    cin >> a[i][0];
    a[i][1] = i+1;
  }

  sort(&a[0], &a[n], [](auto& x, auto& y){return x[0]<y[0];});
  
  for(int i=0; i<n; i++){
    cout << a[i][1] << " ";
  }
  cout << endl;
 
  return 0;
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
const ll MOD = 1e9+7;
const vi dx = {1, 0, -1, 0, 1, -1, -1, 1};
const vi dy = {0, 1, 0, -1, 1, 1, -1, -1};


int main() {
    int a,b; cin>>a>>b;
    string ab = "";
    string ba = "";
    rep(i,b) ab += '0' + a;
    rep(i,a) ba += '0' + b;

    cout<<(ab >= ba ? ba : ab)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n, k, s;
    cin >> n >> k >> s;

    int sother = s<=2 ? s+1 : s-1;

    rep(i, n){
        if (i < k){
            cout << s << " ";
        } else {
            cout << sother << " ";
        }
    }


}



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

int main() {
  int a;
  cin>>a;
  vector<int> b(a);
  for(int i=0;i<a;i++)
    cin>>b[i];
  int c=b[0],d=0;
  for(int i=0;i<a;i++){
    c=max(c,b[i]);
    if(b[i]>=c)
      d++;
  }
  cout<<d;
}

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

using namespace std;

int main(){
    char x,y;
    cin >> x >> y;
    
    if(x > y){
        cout << ">" << endl;
    }else if(x < y){
        cout << "<" << endl;
    }else {
        cout << "=" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(x,y) (x+y-1)/y

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

int main() {
	FAST;

	int a, b, c;
	int k;

	cin >> a >> b >> c;
	cin >> k;
	
	int m = max({a,b,c});
	m *= (pow(2,k)-1);

	int res = a+b+c+m;
	cout << res;

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
int main() {
	int N;
	cin>>N;
	vint A;
	int minus=0;
	vint P,M;
	ll sum=0;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
		if(a<0){
			minus++;
			M.pb(a);
		}
		else{
			P.pb(a);
		}
		sum+=llabs(a);
	}
	sort(P.begin(),P.end(),greater<int>());	//絶対値が小さいほうが後
	sort(M.begin(),M.end());	//絶対値が小さいほうが後
	if(N==2){
		if(P.size()==M.size()){
			cout<<sum<<endl;
			cout<<P[0]<<" "<<M[0]<<endl;
		}
		else if(P.size()){
			cout<<P[0]-P.back()<<endl;
			cout<<P[0]<<" "<<P.back()<<endl;
		}
		else{
			cout<<-M[0]+M.back()<<endl;
			cout<<M.back()<<" "<<M[0]<<endl;
		}
		return 0;
	}



	vpint Op;
	if(minus==N){
		Op.pb(mp(M.back(), M[M.size()-2]));
		P.pb(M.back()-M[M.size()-2]);
		M.pop_back();
		M.pop_back();
	}
	if(minus==0){
		Op.pb(mp(P[P.size()-2], P.back()));
		M.pb(-P[P.size()-2]+P.back());
		P.pop_back();
		P.pop_back();
	}
	
	for(int i=0;i<P.size()-1;i++){
		Op.pb(mp(M[0], P[i]));
		M[0]-=P[i];
	}
	for(int i=0;i<M.size();i++){
		Op.pb(mp(P.back(), M[i]));
		P.back()-=M[i];
	}
	cout<<P.back()<<endl;
	for(auto P:Op){
		cout<<P.first<<" "<<P.second<<endl;
	}

	return 0;
}

Measured memory_bytes: 3824
//C
#include<bits/stdc++.h>
 
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
 
int main(){
	LL A;
	double B;
	scanf("%lld%lf", &A, &B);
	B += 0.001;
	B *= 100;
	printf("%lld\n", A * (LL)B / 100);
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF = (1LL << 62);
const double inf = pow(10, 10);
double pi = 3.141592653589793;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1};
const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0};

ll gcd(ll a, ll b)
{
  if (a < b)
    swap(a, b);
  if(a%b==0)
    return b;

  return gcd(a % b, b);
}

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

int main()
{
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
}

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

int main(){
    int N, L, sum = 0;
    cin >> N >> L;
    vector<int> A(N, L);
    for (int i = 0; i < N; i++) {
        A[i] += i;
        sum += A[i];
    }
    sort(A.begin(), A.end());
    int mn = 1e3;
    for (int i = 0; i < N; i++) {
        int dis = abs(A[i]);
        if (dis < abs(mn)) {
            mn = A[i];
        }
    }
    
    sum -= mn;
    cout << sum << endl;
    return 0;
}

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

// mint
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// combination mod prime（mintが必要）
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
// nCkを求めて結果をansに格納したい場合、
// combination c(n);
// mint ans = c(n, k);
// cout << ans.x << endl;
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

// 整数の累乗x^n O(log2n)
ll power(ll k, ll n) {
	mint ret = 1LL;
	mint x = k;
	while(0 < n){
		if((n % 2) == 0){
			x *= x;
			n >>= 1;
		}else{
			ret *= x;
			--n;
		}
	}
	return ret.x;
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	mint ans = power(2, n) - 1;
	
	// combination c(n);
	// mint nCa = c(n, a);
	// mint nCb = c(n, b);

	mint nCa = 1;
	for(int i = n; i >= n-a+1; i--){
		nCa *= i;
	}
	for(int i = a; i >= 1; i--){
		nCa /= i;
	}
	mint nCb = 1;
	for(int i = n; i >= n-b+1; i--){
		nCb *= i;
	}
	for(int i = b; i >= 1; i--){
		nCb /= i;
	}
	
	ans -= nCa + nCb;
	cout << ans.x << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vi l(n);
  rep(i,n) cin >> l.at(i);
  sort(l.begin(), l.end());
  int ans = 0;
  REP(i,0,n-2)REP(j,i+1,n-1)REP(k,j+1,n){
    if (l.at(i) + l.at(j) <= l.at(k)){
      break;
    }
    ans++;
    //printf("%d %d %d\n", l.at(i), l.at(j), l.at(k));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200010;
map<string,int> Cnt;
vector<string> S;
int N;char ss[MAXN];string s[MAXN];
int main()
{
	cin>>N;
	int Max=0;
	for (int i=1;i<=N;++i)
	{
		scanf("%s",ss+1);
		int len=strlen(ss+1);
		for (int j=1;j<=len;++j) s[i].push_back(ss[j]);
		++Cnt[s[i]];
		Max=max(Max,Cnt[s[i]]);
	}
	for (int i=1;i<=N;++i)
		if (Cnt[s[i]]==Max)
		{
			S.push_back(s[i]);
			Cnt[s[i]]=0;
		}
	sort(S.begin(),S.end());
	for (int i=0;i<S.size();++i,printf("\n"))
		for (int j=0;j<S[i].size();++j)
			printf("%c",S[i][j]);
	return 0;
}

Measured memory_bytes: 37748