akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

int main(void) {

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

  vector< vector<int> > t(k+5);

  for (int s = 2; s <= k; s++) {
    for (int i = 1; s * i <= k; i++) {
      t[s*i].push_back(s);
    }
  }

  ll m[100100] = {};
  m[1] = 1;
  ll p[100100];
  p[1] = 1;

  for (int i = 2; i <= k; i++) {
    m[i] = (m[i-1]+(MOD-p[i-1]))%MOD;
    p[i] = powMod(ll(i), n, MOD);
    m[i] = (m[i]+p[i])%MOD;
    for (int j = 0; j < t[i].size(); j++) {
      m[i] = (m[i]+(MOD-m[i/t[i][j]]))%MOD;
      m[i] = (m[i]+m[i/t[i][j]-1])%MOD;
    }
  }

  //for (int i = 1; i <= k; i++) cout << m[i] << endl;

  ll ans = 0;
  for (ll i = 1; i <= k; i++) {
    ans += (m[k/(int)i]*i)%MOD;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 14820
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var ks = ReadIntArray();
            var k = ks[0];
            var s = ks[1];
            var count = 0;
            for (int x = 0; x <= k && x <= s; x++)
            {
                count += Math.Max(k + 1 - Math.Abs(k - s + x), 0);
            }

            Console.WriteLine(count);
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 11476
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	min := Max((100*A+7)/8, (100*B+9)/10)
	max := Min((100*A+100+7)/8, (100*B+100+9)/10) - 1
	if min <= max {
		fmt.Println(min)
	} else {
		fmt.Println(-1)
	}
}

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

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


Measured memory_bytes: 1768
import scala.io.StdIn._
object Main extends App {

  val Array(x, y) = readLine().split(" ").map(_.toInt)

  def solve(): String = {
    for {
      i <- 0 to x
    } yield {
      if(2 * i + 4 * (x-i)  == y) return "Yes"
    }
    "No"
  }

  println(solve())

}


Measured memory_bytes: 54712
N, X = map(int, input().split())
l = [1]
for i in range(N):
  l.append(2*l[-1]+1)

def main(n, x, ans):
  global X
  global l
  if n == 0:
    return ans+1
  elif x==1:
    return ans
  elif x==2*l[n]-1:
    return ans+2*l[n-1]+1
  elif x == l[n]:
    return main(n-1, x-2, ans+1)
  elif x < l[n]:
    return main(n-1, x-1, ans)
  else:
    return main(n-1, x-2*l[n-1]-1, ans+l[n-1]+1)
  
a = main(N, X, 0)
print(a)

Measured memory_bytes: 8884
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  ll N;
  cin >> N;

  for(ll h = 1;h <= 3500;h++){
    for(ll n = 1;n <= 3500;n++){
      ll den = 4*n*h - N*(h + n);
      ll num = N * h * n;

      if(den > 0 && num % den == 0){
        ll w = num / den;
        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
import sys

for line in sys.stdin:
    y, m, d = map(int, line.rstrip().split())
    if (1989 == y and 1 == m and 8 <= d) or (1989 == y and 2 <= m) or 1990 <= y:
        print 'heisei %s %s %s' % (y-1989+1, m, d)
    elif (1926 == y and 12 == m and 25 <= d) or (1927 <= y <= 1989):
        print 'showa %s %s %s' % (y-1926+1, m, d)
    elif (1912 == y and 7 == m and 30 <= d) or (1912 == y and 8 <= m) or (1913 <= y <= 1926):
        print 'taisho %s %s %s' % (y-1912+1, m, d)
    elif (1868 == y and 9 == m and 8 <= d) or (1868 == y and 10 <= m) or (1869 <= y <= 1912):
        print 'meiji %s %s %s' % (y-1868+1, m, d)
    else:
        print 'pre-meiji'

Measured memory_bytes: 4252
N, M = map(int, input().split())


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r))
                         for r in self.roots())


uf = UnionFind(N)

for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a - 1, b - 1)

maxSize = 0
for x in range(N):
    maxSize = max(maxSize, uf.size(x))
print(maxSize)


Measured memory_bytes: 76032
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main(){
	string s;
	cin >> s;
	int n = s.length();


	for (int i = 0; i < n; i+=2) {
		if (s[i]=='L') {
			cout << "No";
			return 0;
		}
	}
	for (int i = 1; i < n; i+=2) {
		if (s[i]=='R') {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	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 < (int)(n); i++)

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<int>a(n+1);
  vector<int>b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n){
    if(b[i] <= a[i]) ans += b[i];
    else if(b[i] < a[i]+a[i+1]){
      ans += b[i];
      a[i+1] -= b[i]-a[i];
    }
    else{
      ans += a[i]+a[i+1];
      a[i+1] = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)

ll dp[54][2505][54];
vi arr;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z,a;
    cin>>n>>a;
    in(arr,n);
    for(int i=0;i<2505;i++){
        for(int j=1;j<52;j++){
            if((i%j==0)&&(i/j==a)){
                dp[n][i][j] = 1;
            }
        }
    }
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<2505;j++){
            for(int k=0;k<52;k++){
                dp[i][j][k] = dp[i+1][j][k] + dp[i+1][j+arr[i]][k+1];
            }
        }
    }
    cout<<dp[0][0][0];
    

    return 0;
}

Measured memory_bytes: 55552
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238

typedef pair<int, int> P;
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;cin>>a>>b>>c;
    map<int,int> ma;
    ma[a]++;
    ma[b]++;
    ma[c]++;
    if(ma.size()==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll ans = (x / 500) * 1000;
	x %= 500;
	ans += (x / 5) * 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

public class SevenSpotter
    {
        public static void Main(string[] args)
        {
            var number = int.Parse(Console.ReadLine());
            var result = IsThereA7(number);

            Console.WriteLine(result);
        }

        public static string IsThereA7(int number)
        {
            for (int i = 0; i < 3; i++)
            {
                var divisor = Math.Pow(10, i);
                var divided = number / divisor;
                var roundedColumn = Math.Floor(divided);
                if (roundedColumn % 10 == 7)
                {
                    return "Yes";
                }
            }
            return "No";
        }
    }

Measured memory_bytes: 27616
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(ll i2=s;i2<n;i2++){cout <<  V[i2] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  500005LL
#define tmod            998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   if(a.first!=a.second)return (a.first < b.first);
    else return a.second > b.second;}

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
bool P[N+1];
ll LPF[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll t,q=1;
//cin >> q;
t = q;

while(q--)
{
    ll i,n,m,k,j,l,r,c=0,b,a,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> n ;
    vector<ll> V(n);
    CIN(V,0,n);
    for(i=1;i<n;i++) V[i] += V[i-1];
    ll sum = 0;
    ll ans = 0;
    i=0;
    while((V[i]) <= V[n-1]/2)
    {
        sum = V[i];
        i++;
    }
   // cout << sum << " " << V[n-1] << " " ;
    ans  = (V[n-1] - 2*sum);
    sum = V[i];
   // cout << sum << " ";
    ans = min(ans , abs(V[n-1]- 2*sum));
    cout << ans << endl;

}
return 0;
}


ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

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

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(int i=1;i<=n;i++)
        LPF[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i+i;j<=n;j+=i)
            {
                P[j]=false;
                LPF[j] = i;
            }
        }
    }

}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
void coin(long long s)
{
    long long n,p,t,k,l;
    p = s/500;
    l = p*500;
    t = s-l;
    k = t/5;
    n = (p*1000)+(k*5);
    cout << n <<endl;
}
int main()
{
    long long x;
    cin >> x;
    coin(x);
    return 0;
}


Measured memory_bytes: 256
L,R=map(int,input().split())

if L//2019 != R//2019:
  print(0)
else:
  L%=2019
  R%=2019
  
  answer=10**10
  for i in range(L,R):
    for j in range(i+1,R+1):
      answer=min(answer,(i*j)%2019)
      
  print(answer)

Measured memory_bytes: 3064
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] s = new String[n];
    for (int i = 0; i < n; i++) {
      s[i] = sc.next();
    }
    int m = sc.nextInt();
    String[] t = new String[m];
    for (int i = 0; i < m; i++) {
      t[i] = sc.next();
    }
    int max = 0;
    for (int i = 0; i < n; i++) {
      String st = s[i];
      int count = 0;
      for (int j = 0; j < n; j++) {
        if (s[j].equals(st)) count++;
      }
      for (int k = 0; k < m; k++) {
        if (t[k].equals(st)) count--;
      }
      if (count > max) max = count;
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 35776
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//n
		int n = sc.nextInt();
		//m
		int m = sc.nextInt();
		//A=n*mの要素
		int A[][] = new int[n][m];
		//B
		int B[] = new int [m];
		//C
		int C[] = new int[n];
		//A読み込む
		for(int i = 0;i<n;i++){
			for(int j = 0;j<m;j++){
			int a = sc.nextInt();
			A[i][j] = a;
			}
		}
		//B読み込む
		for(int k = 0;k<m;k++){
			int b = sc.nextInt();
			B[k] = b;
		}
		//Cに代入
		for(int l = 0;l<n;l++){
			for(int g = 0;g<m;g++){
				C[l] = C[l] + A[l][g] * B[g];
			}
			System.out.println(C[l]);
		}



	}

}



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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll A, B, C, D, E, F;

int main() {
    cin >> A >> B >> C >> D >> E >> F;
    ll ans1 = 0, ans2 = 0;
    double tmp = 0;
    REP(i, 31) REP(j, 31) REP(k, 101) REP(l, 101) {
        ll sum = A * i * 100 + B * j * 100 + C * k + D * l;
        if(sum > F) continue;
        if(C * k + D * l > (A * i + B * j) * E) continue;
        double den = (double)(C * k + D * l) / (double)sum;
        if(den >= tmp) {
            tmp = den;
            ans1 = sum;
            ans2 = C * k + D * l;
        }
    }
    cout << ans1 << " " << ans2 << "\n";
}

Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, X = list(map(int,_in[0].split(' ')))  # type:list(int)
    m_arr = []
    for i in range(N):
        _ = int(_in[i+1])  # type:int
        m_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = N+(X-sum(m_arr))//min(m_arr)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 38384
N = gets.to_i
S = gets.split("")
index = 0
ans = 0

(N-1).times do
    if S[index] != S[index+1]
        ans += 1
        index += 1
    else
        index += 1
    end
end

if ans == 0
    puts 1
else
    puts ans + 1
end


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

using namespace std;

int total_sum(int n, int sum = 0)
{
    if (n < 0)
        return 0;
    if (n == 0)
        return sum;
    else
        return total_sum(n - 1, sum + n);
}

int main()
{
    int N, M;
    int ans, sum = 0;
    cin >> N >> M;

    ans = total_sum(N - 1, sum);
    ans += total_sum(M - 1, sum);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void hantei(int s);
int main(){
    while (1) {
        int n;
        scanf("%d",&n);
        if(n==0)break;
        hantei(n);
    }
    return 0;
}
void hantei(int s){
    int i,max=5,cnt=0,t;
    int sosuu[1000001];
    sosuu[0]=2;
    cnt++;
    for(i=3;i<=s;i+=2){
        int sw=1;
        for(t=0;t<cnt&&sosuu[t]*sosuu[t]<=i;t++){
            if(i%sosuu[t]==0){
                sw=0;
                break;
            }
        }
        if(sw==1){
            sosuu[cnt]=i;
            if(sosuu[cnt]-sosuu[cnt-1]==2&&sosuu[cnt]>max)max=sosuu[cnt];
            cnt++;
        }
    }
    
    printf("%d %d\n",max-2,max);
    return;
}

Measured memory_bytes: 612
/**
  * @file pa.cpp
  * @brief atcoder

  *

  * @author yao
  * @date 2018-10-27
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#define N 131072
#define ft first
#define sd second
#define INF ((int)1e9)
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#endif //DBG

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int a[N];

lli count(int n)
{
    int l=0, r=n-1;
    lli res = 0;
    int pre = a[(n-1)/2];
    while(l!=r)
    {
        res += abs(a[r]-pre), pre = a[r], --r;
        if( l==r ) break;
        res += abs(a[l]-pre), pre = a[l], ++l;
    }
    return res;
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",a+i);
    std::sort(a,a+n);
    lli ans = count(n);
    std::reverse(a,a+n);
    ans = std::max(ans, count(n));
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 512
from sys import stdin
from collections import defaultdict
N,M = [int(x) for x in stdin.readline().rstrip().split()]
H = [int(x) for x in stdin.readline().rstrip().split()]
d = defaultdict(set)
for i in range(M):
    A,B = [int(x) for x in stdin.readline().rstrip().split()]
    d[A].add(B)
    d[B].add(A)
    
ans = 0
for h in range(1,N+1):
    f = True
    for i in d[h]:
        if H[i-1] >= H[h-1]:
            f = False
    if f:
        ans += 1
print(ans)

Measured memory_bytes: 51552
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vi L(n); for(auto& e : L) cin >> e;
    sort(_all(L));

    int res = 0;
    rep(i, n){
        rep(j, i+1, n){
            int a = L[i], b = L[j];
            int l = j+1, u = n;

            // a - b < c
            auto itr1 = upper_bound(_all(L), a - b);
            chmax(l, (int)(itr1 - begin(L)));

            // b - a < c
            auto itr2 = upper_bound(_all(L), b - a);
            chmax(l, (int)(itr2 - begin(L)));

            // c < a + b
            auto itr3 = lower_bound(_all(L), a + b);
            chmin(u, (int)(itr3 - begin(L)));

            res += max(0, u - l);
        }
    }

    cout << res << endl;

    return 0;
}


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

int main()
{
    int K,S;
    cin >> K >> S;

    int count = 0;

    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if (z < 0) break;
            if(z <= K) count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    
    ll n; cin>>n;
    ll sm=0;
    vll a(n); REP(i,n) {cin>>a[i]; sm+=a[i];}
    ll s=0;
    ll ans=inf;
    REP(i,n-1){
        s += a[i];
        ans = min(abs(2*s-sm), ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4740
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
#include <atcoder/all>
using namespace std; using namespace atcoder;
using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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 ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vector<vpll> path; vs S;
int main() {
	int N;
	cin >> N >> Q;
	dsu D(N);
	for (i = 0; i < Q; i++) {
		int t, u, v;
		cin >> t >> u >> v;
		if (t == 0) D.merge(u, v);
		else cout << (D.same(u, v) ? 1 : 0) << endl;
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  
  vector<int> y=x;
  sort(y.begin(),y.end());
  int a=1000000007;
  for(int i=*y.begin();i<=*y.rbegin();++i){
    int v=0;
    rep(j,n){
      v+=(y[j]-i)*(y[j]-i);
    }
    a = min(a,v);
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int N;
    cin >> N;

    int ans = 10000;
    int tempA = 0;
    for(int i = 1; i < N; ++i) {
        tempA = 0;
        int A = i, B = N - i;
        while (A > 0){
            tempA += A % 10;
            A = A / 10;
        }
        while (B > 0){
            tempA += B % 10;
            B = B / 10;
        }
        ans = min(ans, tempA);
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int i=s.nextInt();
		int n=1;
		while(i!=0){
			System.out.println("Case "+n+": "+i);
			n++;
			i=s.nextInt();
			continue;
		}
	}
}

Measured memory_bytes: 33024
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<map>
#include<stack>
using namespace std;
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
/*
int main()
{
	int r, c;
	cin >> r >> c;
	int sy, sx, gy, gx;
	vector<vector<char>>field(r,vector<char>(c));
	sy--, sx--, gy--, gx--;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> field[i][j];
		}
	}
	queue<pair<int,int>>q;
	q.push({ sx,sy });
	vector<vector<int>>d(c, vector<int> (r, -1));
	d[sx][sy] = 0;

	while (!q.empty())
	{
		pair<int, int>p = q.front;
		q.pop();
		for (int i = 0; i < 4; i++)
		{
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue;
			q.push({ nx,ny });
			d[nx][ny] = d[p.first][p.second] + 1;
		}
	}

	cout << d[gx][gy] << endl;
}*/


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

	int ans = 0;

	if ((n + l - 1)<= 0)
	{
		for (int i = 0; i < (n-1); i++)
		{
			ans += apple[i];
		}
	}
	else if (n > 0 && l > 0)
	{
		for (int i = 0; i < n; i++)
		{
			ans += apple[i];
		}
		ans = ans - apple[0];
	}
	else
	{
		for (int i = 0; i < n; i++)
		{
			ans += apple[i];
		}
	}

	cout << ans << endl;
	
}



Measured memory_bytes: 3204
// D.

#include <sstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
  int n;
  LL w, w0;
  cin >> n >> w;
  vector<int> v[4];
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    int index = 0;
    if (i == 0) {
      w0 = a;
    } else {
      index = a - w0;
    }
    v[index].push_back(b);
  }
  for (int i = 0; i < 4; ++i) {
    sort(v[i].rbegin(), v[i].rend());
  }
  int ans = 0;
  for (int a = 0; a <= v[0].size(); ++a) {
    LL aw = a * w0;
    for (int b = 0; b <= v[1].size(); ++b) {
      LL bw = b * (w0 + 1);
      for (int c = 0; c <= v[2].size(); ++c) {
        LL cw = c * (w0 + 2);
        for (int d = 0; d <= v[3].size(); ++d) {
          LL dw = d * (w0 + 3);
          if (aw + bw + cw + dw > w) break;
          int sum = accumulate(v[0].begin(), v[0].begin() + a, 0)
                  + accumulate(v[1].begin(), v[1].begin() + b, 0)
                  + accumulate(v[2].begin(), v[2].begin() + c, 0)
                  + accumulate(v[3].begin(), v[3].begin() + d, 0);
          ans = max(ans, sum);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int n;
	aa: cin >> n;
	if (n == 0) {
		goto aaa;
	}
	char a[n], b[n], c;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	int m;
	cin >> m;
	char d[m];
	for (int i = 0; i < m; i++) {
		cin >> d[i];
		for (int j = 0; j < n; j++) {
			if (d[i] == a[j]) {
				d[i] = b[j];
				break;
			}
		}
	}
	for (int i = 0; i < m; i++) {
		cout << d[i];
	}
	cout<<endl;
	goto aa;
	aaa: return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <functional>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <array>
#include <memory>

using namespace std;

#define Get(ty,...) ty __VA_ARGS__;cins(__VA_ARGS__);
#define GetArray(ty,v,n) vector<ty> v(n);cin_arr(v,n);
#define ci cin
#define co cout
#define en endl;
#define Arr(f, arr,pred) f(arr.begin(),arr.end(),pred)
#define Arr2(f, arr) f(arr.begin(),arr.end())
#define ArrExpr(f, arr,expr) f(arr.begin(),arr.end(),[](auto x){return expr;})
#define Acc(init,arr,pred) accumulate(arr.begin(),arr.end(),init,pred)

void cins(){}

template<class Head,class... Tail>
void cins(Head& head,Tail&... tail) {
	cin >> head;
	cins(tail...);
}

template<class Arr>
void cin_arr(Arr& v,int n) {
	for (int i = 0; i < n; i++)
		cin >> v[i];
}

int main() {
	Get(int, n);
	GetArray(int, v, n);
	Arr2(sort, v);
	auto itr=Arr2(unique, v);
	v.erase(itr,v.end());
	co << max({ v.size() ,(size_t)1}) << en
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

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

	for(i=0; i<n; i++) {
		if(i==k) {
			if(s==1000000000LL) s--;
          else s++;
		}
		cout<<s;
		if(i!=n-1) cout<<" ";
	}
	cout<<endl;

}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;

typedef long long ll;

// dp[i][j][k]
// i ????¬?????????¶?\?
// j ????????£????????°?????¶?\?
// k ???????¨??????????
// ???????????????????????° mod 1e9+7
ll dp[2][2][310 * 310];

const ll M = 1e9+7;

int main() {
	int d;
	vector<int> l;
	int s;
	cin >> d;
	l.resize(d);
	for(int i = 0; i < l.size(); i++)
		cin >> l[i];
	cin >> s;

	dp[1][0][0] = 1;
	for(int i = 0; i < l.size(); i++) {
		for(int j = 0; j < 310*310; j++) dp[i&1][0][j] = dp[i&1][1][j] = 0;
		for(int j = 0; j < l[i]; j++) {
			dp[i&1][0][j] += dp[i+1&1][0][j];
			dp[i&1][1][j] += dp[i+1&1][1][j];
		}
		for(int j = 0; j+l[i] < 310*310; j++) {
			dp[i&1][0][j+l[i]] += dp[i+1&1][0][j+l[i]] + dp[i+1&1][1][j];
			dp[i&1][1][j+l[i]] += dp[i+1&1][1][j+l[i]] + dp[i+1&1][0][j];

			dp[i&1][0][j+l[i]] %= M;
			dp[i&1][1][j+l[i]] %= M;
		}
	}
	ll res = 0;
	for(int i = 0; i <= s; i++) {
		ll x = 1;
		for(int j = 0; j < d; j++) x = x * (s-i) % M;
		res = (res + (dp[d-1&1][0][i] - dp[d-1&1][1][i] + M) * x) % M;
	}
	cout << res << endl;
}

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

int main(){
    long long n, a, b; cin >> n >> a >> b;
    if((b - a) % 2 == 0){
        cout << (a + b) / 2 - a << endl;
    }else{
        
        cout << min(a - 1, n - b) + (b - a + 1) / 2  << endl;
    }
}

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

using namespace std;

bool cmp1(pair<long, long> a, pair<long, long> b){
    return a.first < b.first;
}
bool cmp2(pair<long, long> a, pair<long, long> b){
    return a.second < b.second;
}

int main(int argc, char const *argv[])
{
    long n, m;
    scanf("%ld %ld\n", &n, &m);
    vector<pair<long, long>> r;
    for(int i=0; i<m; i++){
        long a, b;
        scanf("%ld %ld\n", &a, &b);
        r.push_back(make_pair(a, b));
    }

    sort(r.begin(), r.end(), cmp2);
    long e = r[0].second;
    long cnt = 1;
    for(int i=1; i<m; i++){
        if(r[i].first >= e){
            e = r[i].second;
            cnt++;
        }
    }

    printf("%ld\n", cnt);

    return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

vector<pair<int, int>> edge[100010];
int ans[100010];

void dfs(int from, int pre, int prec) {
	int color = 1;
	for(auto too : edge[from]) {
		int to, id;
		tie(to, id) = too;
		if(to == pre) continue;
		if(color == prec) color++;
		ans[id] = color;
		dfs(to, from, color);
		color++;
	}
}

int main() {
	int n; cin >> n;
	rep(i,n-1){
		int a, b; cin >> a >> b;
		--a, --b;
		edge[a].emplace_back(b, i);
		edge[b].emplace_back(a, i);
	}
	rep(i,n-1) ans[i] = -1;
	dfs(0, -1, -1);

	int anss = 0;
	rep(i,n-1) {
		anss = max(anss, ans[i]);
	}
	cout << anss << '\n';
	rep(i,n-1) {
		cout << ans[i] << '\n';
	}
	return 0;
}

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


Measured memory_bytes: 22868
def solve
  while true
    total = 0

    n, m = gets.split.map(&:to_i)
    break if n <= 0

    pn = gets.split.map(&:to_i).sort {|a, b| b <=> a }

    while pn.count > 0
      t = []
      m.times do
        t.push pn.shift
        break if pn.count <= 0
      end
      t.pop if t.count == m
      t.each { |price| total += price }
    end
    p total
  end
end

solve

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N,D;
    cin >> N >> D;
    ll ans = N/(D*2+1);
    if(N%(D*2+1) != 0){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		
		// 計算
		String result = "No";
		if(c >= a && c <= b) result = "Yes";
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<cstdlib>

typedef struct bittree{
    int data;
    //char kind[14];
    struct bittree *left;
    struct bittree *right;
    struct bittree *parent;
}BIT_TREE;

int SearchRootNode(BIT_TREE *);
void PreoederWalk(BIT_TREE *);
void InorderWalk(BIT_TREE *);
void PostorderWalk(BIT_TREE *);

void PrintData(BIT_TREE *);
void P();

BIT_TREE Nil;
int n;

int main(){
    int i, d, l, r;
    BIT_TREE *T;
    
    scanf("%d", &n);
    T = (BIT_TREE *)malloc(sizeof(BIT_TREE) * n);
    //strcpy(Nil.kind, "leaf");
    Nil.data = -1;
    
    // initialize
    for(i = 0; i < n; i++){
        // make all parent nodes Nil node
        T[i].parent = &Nil;
        T[i].left = &Nil;
        T[i].right = &Nil;
        //strcpy(T[i].kind, "leaf");
    }
    
    
    for(i = 0; i < n; i++){
        scanf(" %d %d %d", &d, &l, &r);
        T[d].data = d;
        if(l != -1){
            T[d].left = &T[l];
            T[l].parent = &T[d];
            //strcpy(T[d].kind, "internal node");
        }else{
            T[d].left = &Nil;
        }
        if(r != -1){
            T[d].right = &T[r];
            T[r].parent = &T[d];
            //strcpy(T[d].kind, "internal node");
        }else{
            T[d].right = &Nil;
        }
    }
    
    r = SearchRootNode(T);
    
    printf("Preorder\n ");
    PreoederWalk(&T[r]);
    printf("Inorder\n ");
    InorderWalk(&T[r]);
    printf("Postorder\n ");
    PostorderWalk(&T[r]);
    
    free(T);
    
    return 0;
}

// put value 0 into root.depth and return root node matrix
int SearchRootNode(BIT_TREE *T){
    int i;
    for(i = 0; i < n; i++){
        if(T[i].parent->data == -1){
            //T[i].depth = 0;
            //strcpy(T[i].kind, "root");
            return i;
        }
    }
}

int count = 0;

void PreoederWalk(BIT_TREE *T){
    //P();
    if (T == &Nil) {
        return;
    }
    printf("%d", T->data);
    //P();
    if (count < n-1) {
        count++;
        printf(" ");
    }else{
        count = 0;
        printf("\n");
    }
    PreoederWalk(T->left);
    PreoederWalk(T->right);
}


void InorderWalk(BIT_TREE *T){
    if (T == &Nil) {
        return;
    }
    InorderWalk(T->left);
    printf("%d", T->data);
    if (count < n-1) {
        count++;
        printf(" ");
    }else{
        count = 0;
        printf("\n");
    }
    InorderWalk(T->right);
}


void PostorderWalk(BIT_TREE *T){
    if (T == &Nil) {
        return;
    }
    PostorderWalk(T->left);
    PostorderWalk(T->right);
    printf("%d", T->data);
    if (count < n-1) {
        count++;
        printf(" ");
    }else{
        count = 0;
        printf("\n");
    }
}


void PrintData(BIT_TREE *T){
    printf("%d ",T->data);
}

void P(){
    printf("\ntest\n");
}















Measured memory_bytes: 2708
#include<stdio.h>
int main(void)
{
	int n,k,l[50],i,j,sum,box;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(l[i]<l[j]){
				box=l[i];
				l[i]=l[j];
				l[j]=box;
			}
		}
	}
	sum=0;
	for(i=0;i<k;i++){
		sum=sum+l[i];
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		long[] A=new long[N];

		long sum=0;
		for (int i = 0; i < N; i++) {

			long buf=sc.nextLong();

			A[i]=buf;

			sum+=buf;

		}

		long sunuke=0;
		long arai=0;


		long min=Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {

			sunuke+=A[i];

			if(i+1<N) {
				arai=sum-sunuke;

				long diff=Math.abs(sunuke-arai);

				min=Math.min(min,diff);
			}

		}

		System.out.println(min);
	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

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

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 65376