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

int n;
std::vector<long> a;
	
long calc(long b) {
	long ret = 0;
	for(int i = 0; i < n; i++) {
		ret += llabs(a[i] - (b + (long)i + 1));
	}
	
	return ret;
}

long binary() {
	long ok = -1e9, ng = 1e9;
	
	for(int i = 0; i < 100; i++) {
		long A = (ok + ok + ng) / 3;
		long B = (ok + ng + ng) / 3;
		
		if(calc(A) < calc(B)) {
			ng = B;
		} else {
			ok = A;
		}
	}
	
	long mi = 1e18;
	for(int i = -1e2; i < 1e2; i++) {
		mi = std::min(mi, calc(ok + i));
	}
	
	return mi;
}

int main(){
	cin >> n; a.resize(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	cout << binary() << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;

const int N = 20005;
const long long INF = 0x3f3f3f3f3f3f3f3f;

int n, idx;
long long ans, x, k, d, p[N], c[N], s[N];
long long q[N];
bool st[N];

int main()
{
	scanf("%d %lld", &n, &k);
	for(int i = 1; i <= n; ++i) scanf("%lld", &p[i]);
	for(int i = 1; i <= n; ++i) scanf("%lld", &c[i]);
	ans = -INF;
	for(int i = 1; i <= n; ++i)
	{
		if(!st[i])
		{
			int r = 0;
			long long maxv = -INF;
			idx = 1;
			s[0] = 0;
			while(!st[i])
			{
				s[idx] = s[idx-1] + c[i];
				++idx;
				st[i] = true;
				i = p[i];
			}
			if(s[--idx] > 0)
			{
				r = k % idx;
				if(!r) r = idx;
			}
			else r = min(idx, int(k));
			for(int i = 1; i <= idx; ++i) s[i + idx] = s[i] + s[idx];
			int hh = 0, tt = -1;
			for(int i = 0; i < idx << 1; ++i)
			{
				while(hh <= tt && s[q[tt]] >= s[i]) --tt;
				q[++tt] = i;
				if(q[hh] <= i - r) ++hh;
				maxv = max(maxv, s[i + 1] - s[q[hh]]);
			}
			if(s[idx] > 0) maxv += s[idx] * ((k - 1) / idx);
			ans = max(ans, maxv);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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



int main(){
  int N;
  cin>>N;
  
  int64_t m=0;
  int64_t a=0;
  int64_t r=0;
  int64_t c=0;
  int64_t h=0;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    if(S.at(0)=='M') m++;
    if(S.at(0)=='A') a++;
    if(S.at(0)=='R') r++;
    if(S.at(0)=='C') c++;
    if(S.at(0)=='H') h++;
  }
  int64_t T=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h;
  int64_t Q=a*r*c+a*r*h+a*c*h+r*c*h;
  cout<<T+Q<<endl;
    
    
    
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x,t;
    cin>>x>>t;
    cout<<max(x-t,0)<<endl;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());

    vector<array<int64_t, 2>> B(n);
    for (int i = 0; i < n; i++)
        B[i] = {A[i], i};
    sort(B.begin(), B.end(), greater<array<int64_t, 2>>());
    vector<vector<int64_t>> DP(n + 1, vector<int64_t>(n + 1));

    int64_t ans = 0;
    for (int i = 0; i < n; i++){
        for (int l = 0; l <= i; l++){
            int r = n + l - i - 1;
            DP[l + 1][r] = max(DP[l + 1][r], DP[l][r] + B[i][0] * abs(B[i][1] - l));
            if (r - 1 >= 0)
                DP[l][r - 1] = max(DP[l][r - 1], DP[l][r] + B[i][0] * abs(B[i][1] - r));
            else
                ans = max(ans, DP[l][r] + B[i][0] * abs(B[i][1] - r));
        }
    }

    
    for (int l = 1; l <= n; l++){
        ans = max(ans, DP[l][l - 1]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 34680
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>

int main(int argc, char* argv[])
{
  int n, a;
  std::cin >> n >> a;

  if (n % 500 <= a) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
def type(id)
  if @parents[id] == -1
    return 'root'
  end

  if @nodes[id].empty?
    'leaf'
  else
    'internal node'
  end
end

def set_depth(id, depth)
  @depths[id] = depth

  @nodes[id].each do |node|
    set_depth(node, depth + 1)
  end
end

def find_root_id
  @nodes.keys.each do |key|
    return key if @parents[key] == -1
  end

  raise
end

def set_height(id)
  if @nodes[id].empty?
    @heights[id] = 0
    return
  end

  max_height = 0
  @nodes[id].each do |_id|
    set_height(_id)
    max_height = [max_height, @heights[_id]].max
  end

  @heights[id] = max_height + 1
end

@n = gets.chomp.to_i
@nodes = Hash.new{|k, v| k[v] = []}
@parents = Hash.new(-1)
siblings = Hash.new(-1)
@heights = Hash.new(0)
@depths = {}

@n.times do
  id, left, right = gets.chomp.split.map(&:to_i)
  @nodes[id] = []

  if left != -1
    @nodes[id] << left
    @parents[left] = id
    siblings[left] = right
  end

  if right != -1
    @nodes[id] << right
    @parents[right] = id
    siblings[right] = left
  end
end

set_depth(find_root_id, 0)

# p @nodes
# p @parents

# puts "find_root_id = #{find_root_id}"

set_height(find_root_id)

# p @nodes

@nodes.keys.sort.each do |id|
  puts "node #{id}: parent = #{@parents[id]}, sibling = #{siblings[id]}, degree = #{@nodes[id].size}, depth = #{@depths[id]}, height = #{@heights[id]}, #{type(id)}"
end


Measured memory_bytes: 6880
def bfs(n, node, prev, visited, graph):
    visited.append(node)
    if len(visited) == n:
        return 1

    res = 0
    for edge in graph[node]:
        if edge == prev:
            continue
        if edge in visited:
            continue
        res += bfs(n, edge, node, visited[:], graph)
    # print(visited)
    return res


def main():
    n, m = map(int, input().split())
    graph = [[] for _ in range(n+1)]
    for _ in range(m):
        i, j = map(int, input().split())
        graph[i].append(j)
        graph[j].append(i)

    ans = bfs(n, 1, 0, [], graph)
    print(ans)


if __name__ == "__main__":
    main()


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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  double a, b, x;

  void init() {
    scanf("%lf %lf %lf", &a, &b, &x);
  }

  double deg(double rad) {
    return rad/2/M_PI*360;
  }

  void solve() {
    if(x/a<=a*b/2) {
      double denominator = sqrt(pow(2*x/a/b, 2) + pow(b, 2));
      printf("%.10lf\n", deg(asin(b/denominator)));
    } else {
      double denominator = sqrt(4*pow(b-x/a/a, 2) + pow(a, 2));
      double numerator = 2*b-2*x/a/a;
      printf("%.10lf\n", deg(asin(numerator/denominator)));
    }
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define LL long long
int t;
LL a,b,c,d;
LL gcd(LL a,LL b)
{
	if(!b) return a;
	return gcd(b,a%b);
}
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if(a<b) printf("No\n");
		else if(d<b) printf("No\n");
		else if(c>=b) printf("Yes\n");
		else if(b-gcd(b,d)+a%gcd(b,d)>c) printf("No\n");
		else printf("Yes\n");
		//printf(" %lld %lld %lld\n",b,gcd(b,d),(c-a%b+b)%b);
	}
}


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


Measured memory_bytes: 128
Scanf.scanf "%d %d" @@ fun n m ->
  let sss = Array.init m @@ fun _ ->
    let k = Scanf.scanf " %d" @@ (+) 0 in
    Array.init k @@ fun _ -> Scanf.scanf " %d" @@ fun s -> s - 1 in
  let ps = Array.init m @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  let array_count f = Array.fold_left (fun n x -> if f x then n + 1 else n) 0 in
  let array_for_all f xs = Array.length xs = array_count f xs in
  let flags = Array.make n false in
  let is_on i =
    let ss = sss.(i) in
    let c = ref 0 in
    for j = 0 to Array.length ss - 1 do
      if flags.(ss.(j)) then incr c
    done;
    !c mod 2 = ps.(i) in
    (* let c = array_count ((=) true) flags in c mod 2 = ps.(i) in *)
  let judge () = array_for_all is_on @@ Array.init m @@ (+) 0 in
  let ans = ref 0 in
  let rec find i =
    (* Array.iter (fun x -> print_string @@ if x then "true " else "false ") flags;
    print_newline (); *)
    (* Printf.printf "%d %d\n" i n; *)
    if i >= n then
      (if judge () then incr ans)
    else
      (flags.(i) <- true;
      find (i + 1);
      flags.(i) <- false;
      find (i + 1)) in
  find 0;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 640
N, M = map(int, input().split())
list = [list(map(int, input().split())) for x in range(N)]
list.sort(key=lambda x: x[0])
remain = M
cost = 0
for i in range(N):
    store = list[i][1]
    if remain>=store:
        remain -= store
        cost += list[i][0]*store
    elif remain<store:
        cost += list[i][0]*(remain)
        remain = 0
    if remain==0: break
print(cost)


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC111_A();
        }

        static void ABC111_A()
        {
            var N = Console.ReadLine();
            var l = new List<string>();
            for (var i = 0; i < N.Length; i++)
            {
                if (N[i] == '1')
                    l.Add("9");
                else if (N[i] == '9')
                    l.Add("1");
                else
                    l.Add(N[i].ToString());
            }
            Console.WriteLine(string.Join("", l));
        }
    }
}

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

int main()
{
	int n,m,q; cin>>n>>m>>q;
	int a[900][900] = {0};
	for(int i=0;i<m;i++){
		int x,y; cin>>x>>y;
		a[x][y]++;
	}

	for(int i=n;i>=1;i--){
		for(int j=1;j<=n;j++){
			a[i][j] += a[i+1][j] + a[i][j-1] - a[i+1][j-1];
		}
	}

	for(int i=0;i<q;i++){
		int x,y; cin>>x>>y;

		cout<<a[x][y]<<endl;
	}

    
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int n,i;
    string str1,str2,ans="";
    cin>>n>>str1>>str2;
    for(i=0; i<n; i++)
    {
        ans+=str1[i];
        ans+=str2[i];
    }
    cout<<ans<<endl;



    return 0;
}



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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String[] line = bufferedReader.readLine().split(" ");
        int A = Integer.parseInt(line[0]);
        int B = Integer.parseInt(line[1]);
        int H = Integer.parseInt(line[2]);
        int M = Integer.parseInt(line[3]);
        double radA = Math.PI * (60 * H + M) / (60 * 12) * 2;
        double radB = Math.PI * M / 60 * 2;
        double C = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.abs(radA - radB)));
        System.out.println(C);
    }
}


Measured memory_bytes: 33072
package main

import "fmt"

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

func main() {
	var k int
	fmt.Scan(&k)

	ans := 0
	for a := 1; a <= k; a++ {
		for b := 1; b <= k; b++ {
			for c := 1; c <= k; c++ {
				g := gcd(a, b)
				ans += gcd(g, c)
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  const ll N = 202, S = 1, T = 102, LabelX = -1, LabelY = -2;

  ll A, B;
  cin >> A >> B;
  vector< vector<ll> > D(A + 1, vector<ll>(B + 1));
  REP(i, 1, A + 1) REP(j, 1, B + 1) cin >> D[i][j];

  struct edge { ll u, v, c; };
  vector<edge> edges;
  vector< vector<bool> > ok(A + 1, vector<bool>(B + 1, false));

  ll maxp = 0, maxq = 0;
  REP(p, 0, 101) REP(q, 0, 101) REP(r, 0, 100 + 1) {
    bool f = true;
    REP(x, 1, A + 1) REP(y, 1, B + 1) f = f && D[x][y] <= p * x + q * y + r;
    if(!f) continue;
    ll cnt = 0;
    REP(x, 1, A + 1) REP(y, 1, B + 1) {
      if(!ok[x][y] && D[x][y] == p * x + q * y + r) {
        ok[x][y] = true;
        cnt++;
      }
    }
    if(cnt > 0) {
      edges.push_back((edge) { S + p, T + q, r });
      maxp = max(maxp, p);
      maxq = max(maxq, q);
    }
  }

  REP(i, S, S + maxp) edges.push_back((edge) { i, i + 1, LabelX });
  REP(i, T, T + maxq) edges.push_back((edge) { i + 1, i, LabelY });

  bool possible = true;
  REP(a, 1, A + 1) REP(b, 1, B + 1) possible = possible && ok[a][b];
  if(!possible) {
    cout << "Impossible" << endl;
  } else {
    cout << "Possible" << endl;
    cout << N << " " << edges.size() << endl;
    for(edge e : edges) {
      if(e.c >= 0) cout << e.u << " " << e.v << " " << e.c << endl;
      else cout << e.u << " " << e.v << " " << (e.c == LabelX ? "X" : "Y") << endl;
    }
    cout << S << " " << T << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <utility>
using namespace std;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx, dy = ty - sy;
	cout << string(dy, 'U') << string(dx, 'R');
	cout << string(dy, 'D') << string(dx, 'L');
	cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
	cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s,a,b,c;
  cin >> s;
  
  a = s / 100;
  s = s % 100;
  b = s / 10;
  s = s % 10;
  c = s;
  
  cout << a + b + c  << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a, b, c, d;
long long m1, m2;
long long out;
int main()
{
	cin >> a >> b >> c >> d;
	if (a >= 0 && c >= 0){
		m1 = b;m2 = d;
		out = m1 * m2;
	}
	else if (a >= 0 && c <= 0) {
		if (d >= 0) {
			m1 = b;
			m2 = d;
			out = m1 * m2;
		}
		else {
			m1 = a;
			m2 = d;
			out = m1 * m2;
		}
	}
	else if (a <= 0 && c >= 0) {
		if (b >= 0) {
			m1 = b;
			m2 = d;
			out = m1 * m2;
		}
		else {
			m1 = b;
			m2 = c;
			out = m1 * m2;
		}

	}
	else if(a <= 0&&c <= 0){
		out = a * c;
		if (b >= 0 && d >= 0) {
			if (b * d > out) out = b * d;
		}
		else out = a * c;
	}
	cout << out << endl;
	return 0;
}

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

int main(){
  float d,t,s;  
  cin>>d>>t>>s;
  
  if(d/s<=t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  

   return 0;
}

Measured memory_bytes: 3720
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
M = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, M + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = MAP()

for i in range(1, K+1):
	print(cmb(N-K+1, i, mod)*cmb(K-1,i-1,mod)%mod)

Measured memory_bytes: 46448
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (const pair<db,ll>  p1, const pair<db,ll> p2){
        return (p1.first ==  p2.first) ? p1.ss < p2.ss : p1.first > p2.first;
    }
};
#define MAXN 1005


int main(){
    FIO;
    ll l,r,d; cin >> l >> r >>d;
    ll ans = 0;
    ll temp = 0;
    for(ll i = 0;d*i <= r;i++){
        if(temp >=l && temp <= r){
            ans++;
        }
        temp += d;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		String[] strArray = str.split("", 0);

		for(int i = strArray.length - 1; i > -1; i--) {
			if(i == 0) {
				System.out.println(strArray[0]);
			} else {
				System.out.print(strArray[i]);
			}
		}

	}
}

Measured memory_bytes: 24224
#include <iostream>
#include<algorithm>
#include <stdio.h>
#define N 200005
using namespace std;
int  a[N];
int k,n;
int main()
{
       int  i,sum=0;
      scanf("%d%d",&n,&k);
      for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
     sort(a+1,a+n+1);
     int mins=1000000001;
    for(i=k;i<=n;i++)
    {
       sum=a[i]-a[i-k+1];
       if(sum<mins)
        mins=sum;
    }
     printf("%d\n",mins);
    return 0;
}




Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int h,w,i,j,a;
	char s[100];
	scanf("%d %d", &h, &w);
	for(i=0; i<h; i++)
	{
		scanf("%s", s);
		a=-1;
		for(j=0; j<w; j++)
		{
			if(a>=0)
			a++;
			if(s[j]=='c')
			a=0;
			printf("%d", a);
			if(j<w-1)
			printf(" ");
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 2100
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

#1400

def main():
	x,y=MI()
	mod=10**9+7

	a=2*y-x
	b=2*x-y

	if a%3!=0 or b%3!=0 or a<0 or b<0:
		print(0)
		exit(0)

	a//=3
	b//=3

	f=[1]
	for i in range(1,10**6):
		f.append(f[-1]*i%mod)

	ans=f[a+b]*pow(f[a],mod-2,mod)*pow(f[b],mod-2,mod)
	print(ans%mod)


if __name__ == "__main__":
	main()

Measured memory_bytes: 115568
n = gets.to_i
a = n / 4
b = n / 7
f = false
(a+1).times do |e|
    (b+1).times do |i|
        if 4 * e + 7 * i == n
            f = true
        end
    end
end

if f == true
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=pow(10,9)+7;
bool cmp(pair<long double ,int > x, pair<long double , int> y){ return x.F<y.F && x.S<y.S; }
const ll maxn=1e4+10;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
ll solve(ll n){
	if (n==1) return 1;
	else return 1+2*solve(n/2);
}
int main(){ 
    
//    #ifndef ONLINE_JUDGE
//  		freopen("input.txt", "r", stdin);
//    #endif
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    
	ll h,a;
	cin>>h>>a;
	ll ans=h/a;
	if (h%a) ans++;
	cout<<ans<<endl;
    
	return 0;
}


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

using namespace std;

set<string>q;

int main()
{
    int n;
    string s;
    scanf("%d", &n);
    while(n--)
    {
        cin>>s;
        q.insert(s);
    }
    if(q.size()==3)
        cout<<"Three"<<endl;
    else
        cout<<"Four"<<endl;
    return 0;
}


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

using namespace std;

void dfs(set<int> &g, int init, vector<vector<int>> &neigh, vector<bool> &chk) {
	g.insert(init);
	chk[init] = true;
	for (int i = 0; i < neigh[init].size(); i++) {
		if (!chk[neigh[init][i]]) {
			dfs(g, neigh[init][i], neigh, chk);
		}
	}
}

int main(void) {
	int N, M;
	cin >> N >> M;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		p[i]--;
	}
	vector<vector<int>> neigh(N);
	vector<bool> chk(N, false);
	for (int i = 0; i < M; i++){
		int x, y;
		cin >> x >> y;
		neigh[x - 1].push_back(y - 1);
		neigh[y - 1].push_back(x - 1);
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (!chk[i]) {
			set<int> g;
			dfs(g, i, neigh, chk);
			for (auto itr = g.begin(); itr != g.end(); itr++) {
				auto jtr = g.find(p[*itr]);
				if (jtr != g.end()) ans++;
			}
		}
	}
	cout << ans << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 15096
#include <bits/stdc++.h>
#define ll long long
#define ALL(A) (A).begin(),(A).end()
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	ll ans = 0;
	cin >> N;
	vector<ll> A(N);
	vector<ll> bit(65);//bit[j] := jbit目が1になる回数
	rep(i,N){
		cin >> A[i];
		for(int j=0;j<61;j++){
			if((A[i]>>j)&1){
				bit[j]++;
			}
		}
	}
	for(int i=0;i<65;i++){
		ll X=1;
		rep(j,i)X*=2;
		X%=mod;
		if(bit[i]){
			ll Y = bit[i]*(N-bit[i]);
			Y%=mod;
			ans += X*Y;
			ans %= mod;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        for (int i = 1; i <= 5; i++) {
            int curr = in.nextInt();
            if (curr == 0) {
                System.out.println(i);
                break;
            }
        }
    }
}


Measured memory_bytes: 35716
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
s = sum(B)
for i in range(N-1):
    if (A[i] + 1) == A[i+1] :
        s = s + C[A[i]-1]
print(s)

        



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

#define int long long

int e[111][111],d[111];
int used[111];

signed main(){
  int n;
  cin >> n;
  int INF=1LL<<55LL;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      e[i][j] = INF;
  for(int i=0;i<n;i++){
    int u, k;
    cin >> u >> k;
    for(int j=0;j<k;j++){
      int v,c;
      cin>>v>>c;
      e[u][v]=min(e[u][v],c);
    }
  }
  memset(used,0,sizeof(used));
  for(int i=0;i<n;i++) d[i]=INF;
  d[0]=0;
  while(1){
    int u=-1;
    for(int i=0;i<n;i++){
      if(used[i]) continue;
      if(d[i]==INF) continue;
      if(u<0||d[i]<d[u]) u=i;
    }
    if(u<0) break;
    used[u]=1;
    for(int i=0;i<n;i++)
      d[i]=min(d[i],d[u]+e[u][i]);
    
  }
  for(int i=0;i<n;i++) cout<<i<<" "<< d[i] << endl;
  return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1000000;
int a[maxn];

int main(){
    int n;
    scanf("%d",&n);
    int sum = 0;
    for(int i = 0;i<n-1;++i)scanf("%d",&a[i]);
    sum+=a[n-2];
    for(int i = n-2;i>=1;--i){
        sum += min(a[i],a[i-1]);
       // cout<<i<<endl;
    }
    sum+=a[0];
    cout<<sum<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;
typedef long long int lli;
typedef long int li;
const int inf = numeric_limits<int>::max();



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

}



Measured memory_bytes: 3604
# 088 B
n = int(input())
aa = list(map(int, input().split()))
alice = 0
bob=0
aa = sorted(aa, reverse = True)
for i,a in enumerate(aa):
    if i % 2 == 0:
        alice += a
    else:
        bob += a
# print(alice, bob)
print(abs(alice-bob))

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  long int n,a,b,ans=0;
  scanf("%ld %ld %ld",&n,&a,&b);

  ans=(n/(a+b))*a; //必ず含まれている青いボールの数
  if(n%(a+b)<=a)
    ans=ans+n%(a+b);
  else
    ans=ans+a;
  
  printf("%ld",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N; cin>>N;
	vector<int> buka(N,0);
	rep(i,N-1){
		int t; cin>>t;
		buka[--t]++;
	}
	rep(i,N){
		cout<<buka[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n)
  {
    cin >> a[i];
    b[i] = c[i] = a[i];
  }
  if (prev_permutation(all(b)))
  {
    rep(i, n) cout << b[i] << (i == n - 1 ? "\n" : " ");
  }
  rep(i, n) cout << a[i] << (i == n - 1 ? "\n" : " ");
  if (NP(c))
  {
    rep(i, n) cout << c[i] << (i == n - 1 ? "\n" : " ");
  }
  return 0;
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

LL a[87];

int main() {
    a[0] = 2;
    a[1] = 1;
    for (int i = 2; i <= 86; ++i) {
        a[i] = a[i - 1] + a[i - 2];
    }
    int n;
    cin >> n;
    cout << a[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[111111];
int  main()
{
    int n,m,p=0;
    double d;
    string s;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        p+=a[i];
    }
    if(p>n)
        cout<<"-1";
    else
        cout<<n-p;


}


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

int main() {
	string S;
	cin >> S;

	rep(i,7)
		if(S.substr(0,i)+S.substr(S.size()-7+i,7-i) == "keyence") {
			cout << "YES" << endl;
			return 0;
		}
	
	cout << "NO" << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll MOD = 1000000007;
ll INF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

//-----------------------------------------

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({a * c, a* d, b * c, b * d}) << endl;
    
    
  return 0;
}



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

int main(){
    int X , Y , Z , M;
    string XEON;
    cin >> X;
    XEON = to_string(X);
    Y = XEON.size();
    if(Y < 3){
        cout << "0" <<endl;
    }else if(Y == 3){
        Z = X / 100;
        M = X - Z*100;
        if(M <= Z*5){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }else if(Y == 4){
        Z = X / 100;
        M = X - Z*100;
        if(M <= Z*5){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }else if(Y == 5){
            cout << 1 << endl;
    }else if(Y == 6){
        cout << 1 <<endl;
    }

    

    
}

Measured memory_bytes: 256
N, K = map(int, input().split())
*A, = map(int, input().split())

ans = N+1
t = 0; u = [0]*K; c = 0
for s in range(N):
    while t < N and c < K:
        v = A[t]
        if v <= K:
            u[v-1] += 1
            if u[v-1] == 1:
                c += 1
        t += 1
    if c == K:
        ans = min(ans, t-s)
    v = A[s]
    if v <= K:
        u[v-1] -= 1
        if u[v-1] == 0:
            c -= 1
print(ans if ans < N+1 else 0)



Measured memory_bytes: 16380
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;

long long gcd(long long a, long long b){
    if(b==0){
        return a;
    }
    return gcd(b,a%b);
}

long long lcm(long long a, long long b){
    long long g = gcd(a,b);
    return (a/g) * b;
}

int main(){
    int N;
    cin >> N;
    long long T[N];

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

    sort(T,T+N,greater<long long>());

    long long result = T[0];

    for(int i = 0; i < N; i++){
        result = lcm(result, T[i]);
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//MIN

bool p_judge(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

	ll N;
	vector<int> X, Y;

	cin >> N;
	for (int i = 0; i < N; i++) {

		int tmp;
		cin >> tmp;
		X.push_back(tmp);

	}
	Y = X;
	sort(Y.begin(), Y.end());
	
	for (int i = 0; i < N; i++) {

		if (X[i] < Y[N / 2]) {

			cout << Y[N / 2] << endl;

		}
		else {

			cout << Y[N / 2 - 1] << endl;

		}

	}

	return 0;
}

Measured memory_bytes: 3828
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int m = sc.nextInt();
        long a = 0;
        for (int i = 0; i < m; i++) {
            a += sc.nextLong();
        } 
        sc.close();

        if (n >= a) {
            System.out.println(n - a);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 37872
#include <stdio.h>
#include <math.h>

int round0(double x)
{
  if (x < 0.0) {
    return ceil(x);
  }
  return floor(x);
}

int main(void)
{
  double x = 0, y = 0;
  int dir = 90;
  int dist, deg;

  while (scanf("%d,%d", &dist, &deg), dist || deg) {
    y += dist * sin(dir / 180. * M_PI);
    x += dist * cos(dir / 180. * M_PI);
    dir = ((dir - deg) % 360 + 360) % 360;
  }
  printf("%d\n%d\n", round0(x), round0(y));
  return (0);
}

Measured memory_bytes: 604
import java.util.Scanner;
class Main{
    public static void main(String[] a){
    	Scanner scan = new Scanner(System.in);
    	while (scan.hasNext()){ 
    	int n = 0;
    	n = scan.nextInt();
    	int bigkekka = -1;
    	int bigsen = -1;
    	for(int i = 0; i < n; i++){
    		int num = scan.nextInt();
    		int result = scan.nextInt();

    		if(result > bigkekka){
    			bigkekka = result;
    			bigsen = num;
    		}else if (bigkekka == result){
    			bigsen = Math.min(bigsen, num);
    		}
    	}
    	System.out.println(bigsen + " " + bigkekka);
    	}
 }
}

Measured memory_bytes: 26300
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vi L(2*N);
    rep(i,2*N) cin>>L[i];
    sort(all(L));
    int counter=0;
    for(int i=0; i<2*N; i+=2) counter+=L[i];
    cout<<counter<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const MOD=1000000007;

ll X;

int main(){
    cin>>X;

    ll val=0,ans;
    repn(i,100000){
        val+=i;
        if(X<=val){
            ans=i;
            break;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3648
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();
    let split: Vec<&str> = input.split(' ').collect();

    let a: i32 = split[0].trim().parse().unwrap();
    let b: i32 = split[1].trim().parse().unwrap();
    let c: i32 = split[2].trim().parse().unwrap();

    if 1 <= a && a <= 10000 && 1 <= b && b <= 10000 && 1 <= c && c <= 10000 {
        let mut arr: [i32; 3] = [a, b, c];
        arr.sort();
        println!("{} {} {}", arr[0], arr[1], arr[2]);
    }
}



Measured memory_bytes: 5036
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
#include<utility>
#include<string>
#include<iomanip>
#include<queue> 
#include<cmath>
#include<utility>
#include<set>
using namespace std;
int main()
{
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i++)
    cout << 'x';
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	vector<int> t(n), max_departure(n);
	for (int i = 0; i < n; ++i) {
		cin >> t[i];
		max_departure[i] = t[i] + k;
	}

	sort(t.begin(), t.end());
	sort(max_departure.begin(), max_departure.end());

	int min_buses = 0;
	int curr_passengers = 0;
	int	curr_departure = 0;
	int i = 0;
	while (i < n) {
		curr_passengers = 1;
		curr_departure = max_departure[i];
		++i;
		while (i < n && curr_passengers < c && t[i] <= curr_departure) {
			++curr_passengers;
			++i;
		}

		++min_buses;
		curr_passengers = 0;
	}

	if (curr_passengers) {
		++min_buses;
	}

	cout << min_buses << "\n";

	return 0;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

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

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, vector<long long> A) {
  ll ans = 1;
  ll ans2 = 1;
  REP(i, N) { ans *= 3; }
  REP(i, N) {
    if (A[i] % 2 == 0) {
      ans2 *= 2;
    } else {
      ans2 *= 1;
    }
  }

  cout << (ans - ans2) << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> A[i];
  }
  solve(N, A);
  return 0;
}


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

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b;
  cin>>a>>b;
  if(a*b%2==0)cout<<"Even"<<endl;
  else cout<<"Odd"<<endl;
}

Measured memory_bytes: 256
//2020-06-03 
#include <bits/stdc++.h>
using namespace std;
#define loop(v, st, en) for (int v = st; v < en; v++)
#define loopdesc(v, st, en) for (int v = st; v >= en; v--)
#define INF 1E9
#define clr(v, d) memset(v, d, sizeof(v))
#define pb push_back
#define MP make_pair
#define P(x) cout << #x  <<" = { "<< x<<" }\n"
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const int M=2e5+5;



int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    int n ;string s; 
    cin>>n>>s;
    if(s.size()>n)cout <<s.substr(0,n)<<"...\n";
    else cout <<s<<endl;
    return 0;
}

Measured memory_bytes: 3628
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A+1):
	for b in range(B+1):
		for c in range(C+1):
			y = 500*a + 100*b + 50*c
			if (y == X):
				count += 1

print(count)
	

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

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] + a[1] == a[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}




Measured memory_bytes: 256
N = [int(e) for e in input().split()]
if(N[3] - N[0] > 0):
    N[3] -= N[0]
    if(N[3] - N[1] > 0):
        N[3] -= N[1]
        ans = N[0] - N[3]
    else:
        ans = N[0]
else:
    ans = N[3]
print(ans)

Measured memory_bytes: 61688
import sys
x, n = map(int, input().split())
p = list(map(int, input().split()))
if not p or x not in p:
  print(x)
  sys.exit()
dp = [i-x for i in p]
dp_dic = {}
for i in range(len(p)):
  if abs(dp[i]) in dp_dic:
    dp_dic[abs(dp[i])].append(p[i])
  else:
    dp_dic[abs(dp[i])] = [p[i]]
i = 1
while True:
  if i in dp_dic and len(dp_dic[i]) == 1:
    if x + i == dp_dic[i][0]:
      print(x - i)
    else:
      print(x + i)
    break
  elif i not in dp_dic:
    print(x - i)
    break
  i += 1

Measured memory_bytes: 9144
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    writeln("2018" ~ sread()[4 .. $]);
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 100000

int parent(int i){
  return i/2;
}
int left(int j){
  return 2*j;
}
int right(int k){
  return 2*k+1;
}

int main(){
  int N,i,st[M+1];

  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&st[i]);
  }
  for(i=1;i<=N;i++){
    printf("node %d: key = %d,",i,st[i]);
    if(parent(i)>=1)printf(" parent key = %d,",st[parent(i)]);
    if(left(i)<=N)printf(" left key = %d,",st[left(i)]);
    if(right(i)<=N)printf(" right key = %d,",st[right(i)]);
    printf(" \n");
  }
		     
  return 0;
}


Measured memory_bytes: 2104