akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
using pii = pair<int, int>;

bool comp(pii a, pii b) { return a.second < b.second; }
signed main() {
  int n;
  cin >> n;
  vector<int> x(n), l(n);
  vector<pair<int, int>> robot(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> l[i];
    robot[i] = make_pair(x[i] - l[i], x[i] + l[i]);
  }

  sort(robot.begin(), robot.end(), comp);

  int res = 0;
  int cur = -99999999;
  for (int i = 0; i < n; ++i) {
    if (cur > robot[i].first) continue;
    ++res;
    cur = robot[i].second;
  }
  cout << res << endl;
}

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

int main() {
  for (int i = 0; i < 3; i++) {
    string str;
    cin >> str;
    int a = str.at(0) - 'a';
    char b = a + 'A';
    cout << b;
  }
  cout << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            List<char> cA = Console.ReadLine().Trim().ToCharArray().ToList();
            List<char> cB = Console.ReadLine().Trim().ToCharArray().ToList();
            List<char> cC = Console.ReadLine().Trim().ToCharArray().ToList();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "";
            char cNow = 'a';
            while (true)
            {
                switch (cNow)
                {
                    case 'a':
                        if (cA.Count <= 0) { sOut = "A"; break; }
                        cNow = cA[0];
                        cA.RemoveAt(0);
                        break;
                    case 'b':
                        if (cB.Count <= 0) { sOut = "B"; break; }
                        cNow = cB[0];
                        cB.RemoveAt(0);
                        break;
                    case 'c':
                        if (cC.Count <= 0) { sOut = "C"; break; }
                        cNow = cC[0];
                        cC.RemoveAt(0);
                        break;
                }
                if (sOut != "") { break; }
            }

            // 出力
            Console.WriteLine("{0}", sOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

int x, b, a;
 
int main()
{
	ios::sync_with_stdio(false);
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b)) cout << "A" << endl;
	else cout << 'B' << endl;
	   
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <math.h>
    using namespace std;
    int main(void){
        int N;
        cin>>N;
        long long int A[N+1];
        long long int count=0;
        for(int i=0;i<N+1;i++){
            cin>>A[i];
            count+=A[i];
        }
        long long int ans=0;
        long long int node=1;
        for(int i=0;i<N+1;i++){
            ans+=node;
            node=(node-A[i])*2;
            count-=A[i];
            node=min(node,count);
            if(node<0){
                cout<<"-1"<<endl;
                return 0;
            }
        }
        cout<<ans<<endl;
    }

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

using namespace std;

#define INF (1<<29)

double dist(double x, double y)
{
    return sqrt(x * x + y * y);
}

int main()
{
    int D, E;
    while (cin >> D >> E, D) {
        double res = INF;
        for (int x = 0; x <= 100; x++) {
            for (int y = 0; y <= 100; y++) {
                if (x + y != D) continue;
                res = min(res, abs(dist(x, y) - E));
            }
        }
        printf("%.10f\n", res);
    }
    return 0;
}

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  long m,a[100000],sum[100010];
  long n,ans=0,num[100000][2],max=0,r;
  scanf("%ld %ld",&n,&m);
  sum[0]=0;
  for(long i=0;i<n;i++){
    scanf("%ld",&a[i]);
    sum[i+1]=(sum[i]+a[i])%m;
  }
  sort(sum,sum+n+1);
  num[0][0]=0;
  num[0][1]=1;
  for(long i=1;i<=n;i++){
    if(num[max][0]==sum[i])
      num[max][1]++;
    else{
      max++;
      num[max][0]=sum[i];
      num[max][1]=1;
    }
    //printf("%ld %ld\n",num[max][0],num[max][1]);
  }
  for(long i=0;i<=max;i++){
    //printf("%ld %ld\n",num[i][0],num[i][1]);
    ans+=num[i][1]*(num[i][1]-1)/2;}
  printf("%ld\n",ans);
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <algorithm>

using namespace std;

int table[2001][2001];

int main(){
  for(int i=0; i < 2001; i++){
    for(int j=0; j < 2001; j++){
      table[i][j] = 0;      
    }
  }

  int N, K;
  scanf("%d %d\n", &N, &K);
  int stars = 0;
  for(int i=0; i < N; i++){
    int x, y;
    char b;
    scanf("%d %d %c\n", &x, &y, &b);
    if(b == 'W'){
      x += K; /* 白は等価な黒に */
    }
    x = x % (2*K);
    y = y % (2*K);
    //    printf("%d %d\n", x, y);
    for(int yoko=y+1; yoko <= 2*K; yoko++){
      table[x][yoko] += 1;
    }
    /* tate[x][yoko]でx列で，yoko番目に横の線を入れたときにそこから上の希望の数を数える */

    // if((0 <= x && x < K && 0 <= y && y < K) || (K <= x && x < 2*K && K <= y && y < 2*K)){
    //   stars++;
    // }
  }

  int max_now = stars;
  for(int yoko=0; yoko < K; yoko++){
    stars = 0;
    for(int x=0; x < K; x++){
      stars += table[(x+K)%(2*K)][yoko] + (table[x][yoko+K] - table[x][yoko]) + (table[(x+K)%(2*K)][2*K] - table[(x+K)%(2*K)][yoko+K]);
    }
    for(int tate=1; tate <= 2*K; tate++){
      /* tateとyokoの交点から左下が黒だとする */
      int top_incr = table[(tate-1) % (2*K)][yoko];
      int top_decr = table[(tate-1+K) % (2*K)][yoko];
      int mid_incr = table[(tate-1+K) % (2*K)][yoko+K] - table[(tate-1+K) % (2*K)][yoko];
      int mid_decr = table[(tate-1) % (2*K)][yoko+K] - table[(tate-1) % (2*K)][yoko];
      int bot_incr = table[(tate-1) % (2*K)][2*K] - table[(tate-1) % (2*K)][yoko+K];
      int bot_decr = table[(tate-1+K) % (2*K)][2*K] - table[(tate-1+K) % (2*K)][yoko+K];

      stars = stars + top_incr + mid_incr + bot_incr - top_decr - mid_decr - bot_decr;
      max_now = max(stars, max_now);
    }
  }
  printf("%d\n", max_now);

  return 0;
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

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

const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
const int MAXN = 1123456;
const double pi = 3.14159265359;
const double eps = 0.00000001;

li arr[MAXN];

int32_t main() {

    
    int x, y;

    scanf("%2d%2d", &x, &y);

    bool yymm = 0;
    bool mmyy = 0;

    yymm = y <= 12 && y > 0;
    mmyy = x <= 12 && x > 0;

    if (yymm && mmyy) {
        printf ("AMBIGUOUS\n");
    } else if (yymm) {
        printf ("YYMM\n");
    } else if (mmyy) {
        printf ("MMYY\n");
    } else {
        printf ("NA\n");
    }


    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int k;
	cin >> k;
	cout << (k / 2)*(k % 2 == 0 ? k / 2 : k / 2 + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int parent(int);
int left(int);
int right(int);
int main(){
  int n,i,T[250];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&T[i+1]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d,",i,T[i]);
    if(i != 1) printf(" parent key = %d,",T[parent(i)]);
    if(left(i) <= n) printf(" left key = %d,",T[left(i)]);
    if(right(i) <= n) printf(" right key = %d,",T[right(i)]);
    printf(" \n");
  }
  return 0;
}

int parent(int key){
  return key/2;
}

int left(int key){
  return 2*key;
}

int right(int key){
  return 2*key+1;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

void no(){
    cout<<-1<<endl;
    exit(0);
}

int main() {
    cin>>N>>A>>B;
    ll comp = 0;
    rep(i, N - 2){
        cin>>K;
        comp = comp ^ K;
    }
    ll d = A + B - comp;
    if(d < 0 || (d&1) || comp < B - A) no();
    d /= 2;
    if(comp&d) no();
    if(d >= B){
        cout<<(d - B == A ? -1 : d - B)<<endl;
        return 0;
    }
    ll res = d, last = 50, last_stack = 0;
    Rrep(i, 40){
        if((B>>i)&1){
            if((comp>>i)&1) {
                res += (1LL<<i);
                last_stack += (1LL<<i);
            }else if(!((d>>i)&1)){
                res += (1LL<<last) - last_stack;
                break;
            }
        }else{
            if((d>>i)&1) break;
            if((comp>>i)&1) {
                last = i;
                last_stack = 0;
            }
        }
    }
    cout<<(res - B == A ? -1 : res - B)<<endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
LL ans,x,pr[100005],sf[100005],co[100005],mul[100005];
int n;
int main()
{
    scanf("%d",&n);
    pr[0]=1,sf[n+1]=1,sf[n+2]=1;
    for(int i=1;i<=n;i++)pr[i]=pr[i-1]*i,pr[i]%=MOD;
    for(int i=n;i>0;i--)sf[i]=sf[i+1]*i,sf[i]%=MOD;
    for(int i=1;i<=n;i++)co[i]=co[i-1]+(pr[i]*sf[i+2]),co[i]%=MOD;
    for(int i=1;i<=(n+1)/2;i++)
    {
        mul[i]+=co[n-i];
        mul[i]+=co[i-1];
        mul[i]%=MOD;
    }
    for(int i=n;i>n/2;i--)mul[i]=mul[n-i+1];
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        ans+=x*pr[n];
        ans%=MOD;
        ans+=x*mul[i];
        ans%=MOD;
    }
    printf("%lld",(ans+MOD*50)%MOD);
}


Measured memory_bytes: 6944
use std::collections::{
    HashMap, HashSet
};

#[derive(Debug)]
struct UnionFind {
    parent: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> Self {
        let mut p = vec![0; n];
        for i in 0..n {
            p[i] = i;
        }
        UnionFind {
            parent: p,
            rank: vec![0; n],
            size: vec![1; n],
        }
    }

    fn root(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let p = self.parent[x];
            self.parent[x] = self.root(p);
            self.parent[x]
        }
    }

    fn unite(&mut self, a: usize, b:usize) {
        let ra = self.root(a);
        let rb = self.root(b);
        if self.rank[ra] > self.rank[rb] {
            self.parent[rb] = ra;
            self.size[ra] += self.size[rb];
        } else if self.rank[ra] < self.rank[rb] {
            self.parent[ra] = rb;
            self.size[rb] += self.size[ra];
        } else if ra != rb {
            self.parent[rb] = ra;
            self.size[ra] += self.size[rb];
            self.rank[ra] += 1;
        }
    }

    fn size (&mut self, x: usize) -> usize {
        let rx = self.root(x);
        self.size[rx]
    }

    fn same(&mut self, a: usize, b: usize) -> bool {
        self.root(a) == self.root(b)
    }

}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|i| i.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let n = input[0];
    let m = input[1];
    let k = input[2];

    let mut uf = UnionFind::new(n);
    let mut friends: HashMap<usize, HashSet<usize>> = HashMap::new();
    let mut blocks: HashMap<usize, HashSet<usize>> = HashMap::new();

    for i in 0..n {
        friends.insert(i, HashSet::new());
        blocks.insert(i, HashSet::new());
    }

    for _ in 0..m {
        let input = read_vec::<usize>();
        uf.unite(input[0]-1, input[1]-1);
        friends.get_mut(&(input[0]-1)).unwrap().insert(input[1]-1);
        friends.get_mut(&(input[1]-1)).unwrap().insert(input[0]-1);
        
    }

    for _ in 0..k {
        let input = read_vec::<usize>();
        blocks.get_mut(&(input[0]-1)).unwrap().insert(input[1]-1);
        blocks.get_mut(&(input[1]-1)).unwrap().insert(input[0]-1);
        

    }

    let mut ans: Vec<usize> = vec![];

    for i in 0..n {
        let s = uf.size(i);
        let f = &friends[&i];
        let b = &blocks[&i];
        let mut c = 0;
        for j in b {
            if uf.same(i, *j) {
                c += 1;
            }
        }
        ans.push(s-f.len()-c-1);
    }

    let s = ans.iter().map(|e| e.to_string()).collect::<Vec<_>>().join(" ");

    println!("{}", s);
}


Measured memory_bytes: 127796
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n, i, x;
    
    scanf("%d",&n);
    
    for (i=1; i<=n; i++) {
        x=i;
        if (x % 3 == 0) {
            printf(" %d", x);
        }else {
            while (x) {
                if(x % 10 == 3){
                    printf(" %d", i);
                    break;
                }
                x = x/10;
            }
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2100
a = gets.to_i
b = gets.split.map(&:to_i)
c = []
e = []
for num in 0..a-1 do
  if b[num].even?
    c << b[num]
  end
end
d = c.length
for num in 0..d-1 do
  if c[num] % 3 == 0 || c[num] % 5 == 0
    e << c[num]
  end
end
if d == e.length
  puts "APPROVED"
else
  puts "DENIED"
end

Measured memory_bytes: 1788
#include <iostream>
#include <numeric>

using namespace std;

int main()
{
    int P, Q, R;

    cin >> P >> Q >> R;

    int a = P + Q;
    int b = Q + R;
    int c = R + P;

    int result = min(a, min(b, c));

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {

		// ?????????
		int debt = 100000;

		// n??±???
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		int n = Integer.parseInt(br.readLine());

		for (int i = 0; i < n; ++i) {

			debt *= 1.05;

			if (debt % 1000 != 0) {
				StringBuilder sb = new StringBuilder(String.valueOf(debt));

				int count = sb.length();
				sb.delete(count-3, count);
				sb.append("000");
				debt = Integer.parseInt(sb.toString());
				debt += 1000;
			}

		}
		System.out.println(debt);

	}
}

Measured memory_bytes: 16884
var
 i,j,t:longint;
 a:array[1..3] of longint;
begin
 read(a[1],a[2],a[3]);
 for i:=1 to 2 do
  for j:=i+1 to 3 do
   if a[i]>a[j] then begin t:=a[i];a[i]:=a[j];a[j]:=t;end;
   writeln(a[1]+a[2]);
end.

Measured memory_bytes: 128
// hackerearth incom
        #include <bits/stdc++.h>

        using namespace std;

        typedef long long ll;
        const ll N = 5e5+5;
        const ll MOD = 1000000007;
        #define all(x) x.begin(),x.end()
        #define pii pair<ll,ll>
        #define pis pair<ll,string>
        #define F first
        #define S second
        #define LCM(a,b) ((a*b)/__gcd(a,b))
        #define inf 1e15
        #define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
        #define PI 3.14159265
        #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
        const double EPS = 1E-9;
        typedef vector<vector<double>> matrix;
        typedef vector<int> vi;


int main(){

    fast;
    string S, T;

    cin >> S;
    cin >> T;

    int ar[26][1005];
    int A[26];
    memset(ar, 0, sizeof ar);
    memset(A, 0, sizeof A);

    // for(int i = 0; i < T.size(); i++) A[ T[i] - 'a' ]++;
    // for(int i = 0; i < S.size(); i++) {
    //     ar[ S[i] - 'a' ][i + 1] += 1;

    //     for(int j = 0; j < 26; j++) ar[j][i + 1] += ar[j][i];
    // }

    int ans = INT_MAX;
    // for(int i = T.size(); i <= S.size(); i++) {

    //     int change = 0;
    //     for(int j = 0; j < 26; j++) {
    //         int charCount = ar[j][i] - ar[j][i - T.size()];
    //         if(A[j] > charCount) {
    //             change += A[j] - charCount;
    //         }


    //         if(charCount > 0) cout << (char)('a' + j) << ":" << charCount << " ";
    //     }
    //     cout << change << "\n";

    //     ans = min(ans, change);
    // }
    for(int i = 0; i + T.size() - 1 < S.size(); i++) {

        int cnt = 0;
        for(int j = i; j < (i + T.size()); j++) {
            // cout << S[j];
            if(T[j - i] != S[j])
                cnt++;
        }
        // cout << "\n";
        // string s = S.substr(i, T.size()); cout << s << "\n";
        ans = min(cnt, ans);
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3760
//23;17

#include<stdio.h>

int len(char S[101]){
  int i = 0;
  while(S[i] != '\0'){
    i++;
  }
  return i;
}

int cmp(char S[101], char T[101]){
  int flag; 
  for(int i=0; i==0||i<len(S); i++){
    if(S[i]!=T[i]){
      flag = 0;
      break;
    }
    else{
      flag = 1;
    }
  }
  return flag;
}

void copy(char S[101], char tmp[101]){
  for(int i=0; i<=len(S); i++){
    tmp[i] = S[i];
  }
}

int main(){
  char S[101], T[101];

  scanf("%s", S);
  scanf("%s", T);

  int flag = 0;
  for(int i=0; i<len(S); i++){
    if(cmp(S,T)==1){
      flag = 1;
      break;
    }
    else{
      flag = 0;
    }

    char tmp[101];
    copy(S, tmp);

    for(int j=0; j<len(S); j++){
      if(j==0){
	S[j] = tmp[len(S)-1];
      }
      else{
	S[j] = tmp[j-1];
      }
    }
  }

  if(flag) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){

	int i, n, min, max, A[10000];
	long int sum;

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

	for( i = 0; i < n ; i++)
		scanf("%d", &A[i]);
	sum = A[0];
        min = A[0];
        max = A[0];
	for( i = 1; i < n ;i++){

	sum = sum + A[i];

	if( min > A[i]) {
	min = A[i];
}

	if( max < A[i]) {
	max = A[i];
	}
}
	printf("%d %d %ld\n", min, max, sum);

	return 0;
}
		
			

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<map>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 110000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)


int main(){
    ll N;
    cin>>N;
    ll now=-2;
    vector<int> ans;
    if(N==0){
        cout<<0<<endl;
        return 0;
    }
    while(N!=0){
        if(abs(N)%abs(now)!=0){
            N-=(now)/(-2);
            ans.push_back(1);
        }else{
            ans.push_back(0);
        }
        now*=(-2);
    }
    for(int i=(int)ans.size()-1;i>=0;i--){
        cout<<ans[i];
    }
    cout<<endl;
}



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

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, D;

  cin >> N >> D;

  D = D * 2 + 1;

  cout << (N + D - 1) / D << endl;

  return 0;
}


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

int main(){
	long long N,E;
	vector<long long> a(5);
	cin >> N;
	for(int i=0;i<5;i++)cin >> a[i];
	
	sort(a.begin(),a.end());
	
	cout << 4+(N+a[0]-1)/a[0] << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.lang.String.format

fun main(args: Array<String>) {
    val line = readLine()!!.split(' ').map { it.toInt() }
    val rank = IntArray(line[0] + 1) { 1 }
    val cities = (1..line[1]).map {
        val l = readLine()!!.split(' ').map { it.toInt() }
        Triple(it, l[0], l[1])
    }.sortedBy { it.third }
    val sb = StringBuilder()
    cities.map { Pair(it, rank[it.second]++) }
            .sortedBy { it.first.first }
            .forEach {
                sb.append(format("%06d%06d\n", it.first.second, it.second))
            }
    println(sb)
}

Measured memory_bytes: 140800
#include <bits/stdc++.h>
#include<cstring>
using namespace std;
int main()
{
    int i,k;
    string s,c="";
    cin>>k>>s;

     if(s.size()>k)
    {
        for(i=0;i<k;i++){
            c=c+s[i];
        }
        cout<<c;
            cout<<"...";


    }
    else
    {

        cout<<s;
        return 0;
    }
   return 0;
}


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

using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;

int main() {
  ll a, b, h, m;
  cin >> a >> b >> h >> m;

  double angle, angle_h, angle_m, ret;

  angle_h = 30.0 * h + 30.0 * m / 60.0;
  angle_m = 6.0 * m;

  angle = angle_h - angle_m;
  angle = abs(angle);
  if (angle < 1e-8) {
    ret = abs(a - b);
    cout << std::setprecision(20) << ret << endl;
    return 0;
  }

  ret = sqrt(a * a + b * b - 2.0 * a * b * cos(M_PI / 180.0 * angle));
  cout << std::setprecision(20) << ret << endl;

  return 0;
}


Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 99999999999999999
#define MOD 1000000007

void func()
{
    ll a;
    cin>>a;
    ll ans=a+(a*a)+(a*a*a);
    cout<<ans<<"\n";
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 3688
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
vint v;
int m,n;
bool check(int t){
	// cout<<t<<endl;
	int tmp=0;
	int cnt=1;
	rep(i,n){
		if(v[i]+tmp>t){
			// cout<<tmp<<" ";
			tmp=0;
			cnt++;
			i--;
		}
		else{
			tmp+=v[i];
		}
		if(cnt>m){
			// cout<<"false "<<endl;
			return false;
		}
	}
	// cout<<endl;
	return true;
}


int bs(int l,int r){
	if(l==r) return l;
	int t=(l+r)/2;
	bool f=check(t);
	if(f) return bs(l,t);
	else return bs(t+1,r);
}

void mainmain(){
	while(cin>>m>>n,m||n){
		vint tmp(n);
		rep(i,n){
			cin>>tmp[i];
		}
		v=tmp;
		int ans=bs(1,1500000);
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1216
def sum_list(l1, l2):
  return [i+j for i, j in zip(l1, l2)]

def judge(l):
  for i in l[1:]:
    if i < X:
      return False
  return True

N, M, X = map(int, input().split())
array = []
zeros = [0]*(M+1)
for i in range(N):
  row = [j for j in map(int, input().split())]
  array.append(row)
  zeros = sum_list(zeros, row)

if not judge(zeros):
  print(-1)
  exit()

ret = float('inf')
for i in range(2**N):
  arr = [0]*(M+1)
  cost = 0
  for j in range(N):
    if i >> j & 1:
      arr = sum_list(arr, array[j])
  if judge(arr):
    ret = min(ret, arr[0])
    
print(ret)

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

typedef long long ll;

const int maxn = 1e5 + 5;

int n, T, ans, mn = 2e9, mx;
int a[maxn];

int main()
{
    scanf("%d%d", &n, &T);
    for(int i = 1; i <= n; i++)
	scanf("%d", &a[i]);
    for(int i = 1; i <= n; i++)
    {
	if(a[i] - mn > mx)
	{
	    mx = a[i] - mn;
	    ans = 1;
	}
	else if(a[i] - mn == mx)
	    ans++;
	mn = min(mn, a[i]);
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
    string S, T;
    cin >> S >> T;
    int N = S.size();
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (S[i]!=T[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3916
#!/bin/ruby
def dist(x1,y1,x2,y2)
  (x1-x2).abs+(y1-y2).abs
end
n=gets.to_i
a,b=gets.split.map{|e|e.to_i-1}
c,d=gets.split.map{|e|e.to_i-1}
puts (1..100).map{|w|
  dist(a/w,a%w,b/w,b%w)+dist(c/w,c%w,d/w,d%w)
}.min
  

Measured memory_bytes: 6112
def read_data():
    X, Y, E = map(int, input().split())
    Ss = list(range(X))
    Ts = list(range(X, X + Y))
    Es = []
    for i in range(E):
        x, y = map(int, input().split())
        Es.append((x, y + X))
    return Ss, Ts, Es
    

def bp_match(Ss, Ts, Es):
    '''2??¨??°???????????????????????°???????????¨??????
    '''
    super_source = len(Ss) + len(Ts)
    super_target = super_source + 1
    Cs = [dict() for i in range(super_target + 1)]
    for si, ti in Es:
        Cs[si][ti] = 1
        Cs[ti][si] = 0
    for si in Ss:
        Cs[super_source][si] = 1
        Cs[si][super_source] = 0
    for ti in Ts:
        Cs[super_target][ti] = 0
        Cs[ti][super_target] = 1
    return dinic(Cs, super_target + 1, super_source, super_target)

def dinic(cf, nV, s, t):
    dist = get_distance(cf, s, t)
    while dist[t] > 0:
        df = dfs(dist, cf, s, t, float('inf'))
        while df:
            df = dfs(dist, cf, s, t, float('inf'))
        dist = get_distance(cf, s, t)
    return sum(cf[t].values())

def get_distance(cf, s, t):
    dist = [-1] * len(cf)
    dist[s] = 0
    frontiers = [s]
    while frontiers:
        new_frontiers = []
        for u in frontiers:
            for v, capacity in cf[u].items():
                if dist[v] == -1 and capacity > 0:
                    dist[v] = dist[u] + 1
                    new_frontiers.append(v)
        frontiers = new_frontiers
    return dist

def dfs(dist, cf, u, t, df):
    if u == t:
        return df
    for v, capacity in cf[u].items():
        if dist[v] > dist[u] and capacity > 0:
            new_df = dfs(dist, cf, v, t, min(df, capacity))
            if new_df > 0:
                cf[u][v] -= new_df
                cf[v][u] += new_df
                return new_df
    return 0

if __name__ == '__main__':
#    Ss = [0, 1, 2, 3, 4]
#    Ts = [5, 6, 7, 8]
#    Es = [(0, 5), (1, 5), (1, 7), (2, 6), (2, 7), (2, 8), (3, 7), (4, 7)]
    Ss, Ts, Es = read_data()
    print(bp_match(Ss, Ts, Es))

Measured memory_bytes: 9724
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
l=[]
for i in range(n-1):
  l.append(list(map(int,input().split())))
l2=[]
for i in range(q):
  l2.append(list(map(int,input().split())))
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
 
L4=[]
for i in range(n):
  L4.append(0)
for i in range(q):
  L4[l2[i][0]-1]+=l2[i][1]
distance=[0 for i in range(n)]
distance[0]=L4[0]
ans=[0 for i in range(n)]
ans[0]=L4[0]
L=[0]
L2=[]
L3=[]
while len(L2)!=n and len(L)!=0:
  for j in range(len(L)):
    for k in range(len(connection[L[j]])):
      distance[connection[L[j]][k]]=distance[L[j]]+L4[connection[L[j]][k]]
      L3.append(connection[L[j]][k])
    L2.append(L[j])
  L=L3
  L3=[]
for i in range(len(distance)):
  distance[i]=str(distance[i])
print(' '.join(distance))

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

using namespace std;
using ll = long long;

vector <int> primes;
void sieve(){
  const int n = 101001;
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2 ; p * p <= n; ++p) {
    if (prime[p] == true) {
      for (int i = p * 2 ; i <= n ; i += p)
          prime[i] = false;
    }
  }
  for (int p = 2 ; p <= n ; p++)
   if (prime[p])
    primes.push_back(p);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  sieve();
  sort(primes.begin(), primes.end());
  int x; cin >> x;
  cout << *lower_bound(primes.begin(), primes.end(), x) << '\n';
  return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

double calc(int target,vector<vector<int>> &g){
	int n=g.size();
	vector<double> dp(n,0);
	dp[n-1]=0;
	repr(i,n-2,0){
		double sum=0;
		double max_=0;

		for(auto x:g[i]){
			sum+=dp[x];
			max_=max(max_,dp[x]);
		}

		double size=g[i].size();
		if(i==target){
			sum-=max_;
			size--;
		}

		dp[i]=sum/size+1;
	}

	return dp[0];
}

int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int>> g(n,vector<int>());

	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
	}

	double ans=INF;


	rep(i,n){
		ans=min(ans,calc(i,g));
	}
	cout<<setprecision(10)<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
    
using namespace std;
    
int main(){
    int n, r;
    scanf("%d%d", &n, &r);
    if(n>=10){
        printf("%d\n", r);
        return 0;
    }
    printf("%d\n", r+100*(10-n));
    return 0;
}

Measured memory_bytes: 256
/* ITP1_7_D: Matrix Multiplication */

#include <iostream>

int main() {
    std::ios_base::sync_with_stdio(false);

    int row, col;
    int n_a_row, n_a_col, n_b_col;
    std::cin >> n_a_row >> n_a_col >> n_b_col;

    long long A[n_a_row][n_a_col];
    long long B[n_a_col][n_b_col];
    long long C[n_a_row][n_b_col];

    for (int row = 0; row < n_a_row; row++)
        for (int col = 0; col < n_a_col; col++)
            std::cin >> A[row][col];

    for (int row = 0; row < n_a_col; row++)
        for (int col = 0; col < n_b_col; col++)
            std::cin >> B[row][col];

    // Multiply two matrixes.
    for (int b_col = 0; b_col < n_b_col; b_col++) {
        for (int a_row = 0; a_row < n_a_row; a_row++) {
            C[a_row][b_col] = 0;
            for (int a_col = 0; a_col < n_a_col; a_col++) {
                C[a_row][b_col] += A[a_row][a_col] * B[a_col][b_col];
            }
        }
    }

    // Output result.
    for (int row = 0; row < n_a_row; row++) {
        std::cout << C[row][0];
        for (int col = 1; col < n_b_col; col++)
            std::cout << " " << C[row][col];
        std::cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 1440
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,A[MAXN],pa[MAXN];
int64 ans = 0;
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
	read(A[i]);
	ans += A[i] / 2;
	pa[i] = A[i] / 2;
	A[i] %= 2;
    }
    int pre = -1;
    for(int i = 1 ; i <= N ; ++i) {
	if(A[i]) {
	    if(pre == -1) pre = i;
	    else {pre = -1;++ans;}
	}
	else {
	    if(!pa[i]) pre = -1;
	}
    }
    out(ans);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}
template <typename T>
T gcd(const T x, const T y) {
  if (x == 0) {
    return y;
  } else if (y == 0) {
    return x;
  } else if (x < y) {
    return gcd(x, y % x);
  } else if (y < x) {
    return gcd(y, x % y);
  } else {
    return x;
  }
}

template <typename T>
T lcm(const T x, const T y) {
  if (x == 0 || y == 0) {
    return 0;
  } else {
    return x / gcd(x, y) * y;
  }
}
int main() {
  int64_t a, b;
  std::cin >> a >> b;

  std::cout << lcm(a, b) << std::endl;
  return 0;
}

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

using namespace std;
using  ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}



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


  std::vector<int> a(n,0);
  rep(i,n-1){
    int temp;
    std::cin >> temp;
    a[temp-1]++;
  }

  rep(i,n)std::cout << a[i] << '\n';

  return 0;


}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;

int n;
int a[200002], b[200002];
set<int> s;
int cali(int i)
{
    if(i < 0) i += n;
    if(i >= n) i -= n;
    return i;
}
int f(int i)
{
    return b[cali(i)];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<n;i++)
    {
        cin >> b[i];
        if(a[i] > b[i])
        {
            cout << -1;
            return 0;
        }
    }
    for(int i=0;i<n;i++)
    {
        int x = f(i-1) + f(i+1);
        if(x < f(i))
        {
            s.insert(i);
        }
    }
    ll ans = 0;
    while(!s.empty())
    {
        int i = *s.begin();
        s.erase(s.begin());
        int x = f(i+1) + f(i-1);
        int r = (b[i] - a[i]) / x;
        b[i] -= r * x;
        //cout << i << ' ' << b[i] << '\n';
        ans += r;
        if(f(i) < f(i+1) && f(i+1) > f(i+2)) s.insert(cali(i+1));
        if(f(i) < f(i-1) && f(i-1) > f(i-2)) s.insert(cali(i-1));
    }
    for(int i=0;i<n;i++)
    {
        if(a[i] != b[i])
        {
            cout << -1;
            return 0;
        }
    }
    cout << ans;
}

Measured memory_bytes: 6528
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

A.sort()
for i in range(N-1):
    if A[i] == A[i+1]:
        A[i] = 0
        A[i+1] = 0


for i in range(N):
    if A[i] > 0:
        A[i] = 1

# print(A)
print(sum(A))


Measured memory_bytes: 51160
/**
*    created: 15.07.2020 18:09:19
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    int k, x, y; cin >> k >> x >> y;
    if (n <= k) cout << n * x << endl;
    else cout << k * x + (n-k) * y << endl;
    return 0;
}

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

int main(){
   
   int n;
   cin >> n ;
   int a[n];
   int mx = 0;
   ll ans = 0;
   for(int i = 0; i < n; i++){
       cin >> a[i];
       mx = max(mx, a[i]);
       if(i)
         ans += (mx - a[i]);
     
   }
   
  
   cout << ans;
   return 0;
}

Measured memory_bytes: 4360
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,a,b,c,d;
    string s;
    cin >> a >> b;
    int ans = a*(a-1)/2;
    ans += b*(b-1)/2;
    cout << ans << endl;
}


Measured memory_bytes: 256
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin >> n;

    int count = 0;

    for (int a = 1; a <= n; a++) {
        for (int b = 1; b <= n; b++) {
            const int c = n - a * b;
            if (c <= 0) break;
            count++;
        }
    }

    cout << count << "\n";
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
#include <iomanip>
using namespace std;
const long long mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for(int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k; 
ll INF = 10000000000000000;

int main(){
    string  T;
    cin >>T;
    int N =T.size();
    rep(i,N) {
        if (T[i]=='?') T[i]='D';
    }
    cout <<T<<endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a = 0;
  int b = 0;
  int ans = 0;
  REP(i,n-1){
      if (i%2==0){
          cin >> a;
          if (i==n-2){
              ans+=a;
          }
      }else{
          cin >> b;
          if (i==n-2){
              ans+=b;
          }
      }
      ans += min(a,b);
      if (i==0){
          ans+=a;
      }
  }
  cout << ans << endl;
}


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

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

    for (int i = 0; i < n - 1; i++)
    {
        if (h.at(i) < h.at(i + 1))
            h.at(i + 1)--;
        else if (h.at(i) > h.at(i + 1))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

long long attack(long long h);
int main(void){
    long long h, count = 0;
    scanf("%lld", &h);
    count = attack(h);
    printf("%.0lld", count);
    return 0;
}
long long attack(long long h){
    if (h == 1){
        return 1;
    }
    else{
        return 2*(attack(h/2))+1;
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,s;
ll f( ll b,ll n)
{
  return n<b?n:f(b,n/b)+n%b;
}
int main()
{
  scanf("%lld%lld",&n,&s);
  if(s>n)return puts("-1"),0;
  if(s==n)return printf("%lld\n",n+1),0;
  ll m=sqrt(n)+1;
  for(ll i=2; i<=m; ++i)
    if(f(i,n)==s)return printf( "%lld",i),0;
  ll ans=1e11;
  n-=s;
  for( ll i=1; i*i<=n; ++i)
    if(n%i==0)
    {
      ll b=n/i+1;
      if(f(b,n+s)==s)ans=min(ans,b);
    }
  return printf("%lld\n",ans!=1e11?ans:-1),0;
}

Measured memory_bytes: 256
def main():
    lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
           1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    k = int(input())

    print(lst[k - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 61736
N, M = map(int, input().split())
 
left, right = 1, N
 
for _ in range(M):
  L, R = map(int, input().split())
  
  left = max(L, left)
  right = min(R, right)

ans = right - left + 1 if left <= right else 0 
print(ans)

Measured memory_bytes: 3060
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

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

    int ta, tb, i = 1;
    do {
        if (c == a)
            ta = i;
        if (c == b)
            tb = i;
        i++;
    } while (next_permutation(c.begin(), c.end()));

    cout << abs(ta - tb) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n, a, sum = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a);
		sum += a - 1;
	}
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n , mi = 1000001 , ma = -1000001;
    long long wa = 0;
    cin >> n;
    vector <int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        if(mi > a.at(i)){
            mi = a.at(i);
        }
        if(ma < a.at(i)){
            ma = a.at(i);
        }
        wa+=a.at(i);
    }
    cout << mi << ' ' << ma << ' ' << wa << endl;
}


Measured memory_bytes: 3132
fun main(args: Array<String>) {
    var ans = ""
    for (c in readLine()!!.toCharArray()) {
        when (c) {
            '0' -> ans += '0'
            '1' -> ans += '1'
            'B' -> if (ans.isNotEmpty()) ans = ans.dropLast(1)
        }
    }
    println(ans)
}

Measured memory_bytes: 31860
import math as m

def is_prime(x):
    if x < 2:
        return False
    if x == 2 or x == 3 or x == 5:
        return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
        return False
    prime_number = 7
    difference = 4
    while prime_number <= m.sqrt(x):
        if x % prime_number == 0:
            return False
        prime_number += difference
        difference = 6 - difference
    return True
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
for i in a:
    ans += 1 if is_prime(i) else 0
print(ans)


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

using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef map<string, int> msi;
typedef pair<int, int> PII;

vector<int> Addition(vector<int> A, vector<int> B, int N){
    vector<int> temp(N);
    for(int i = 0 ; i < N ; i++){
        temp[i] = A[i] + B[i];
    }
    return temp;
}

int main() {
    int n, m, x; cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> A(n, vector<int>(m));
    rep(i, n) {
        cin >> c.at(i);
        rep(j, m) {
            cin >> A.at(i).at(j);
        }
    }
    int ans = 10000000;
    for(int bit = 0; bit < (1 << n); bit++){
        vector<int> temp(m, 0);
        int cost = 0;
        bool flag = true;
        for(int j = 0; j < n; j++){
            if(bit >> j & 1){
                temp = Addition(A.at(j), temp, m);
                cost += c.at(j);
            }
        }
        for(auto v : temp) if(v < x) flag = false;
        if(flag) ans = min(ans, cost);
    }
    cout << (ans == 10000000 ? -1 : ans) << endl;

    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

class Main
{
	public static void main(String args[]) {

		try {

			Scanner sc = new Scanner(System.in);

			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());



			System.out.println((a*b) +" "+ (a+a+b+b));
		}
		catch (Exception e) {
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 17124