akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int n;
  cin>>n;
  set<int> set;
  rep(i,n){
    int x;
    cin>>x;
    set.insert(x);
  }
  int q;
  cin>>q;
  int ans=0;
  while(q--){
    int x;
    cin>>x;
    ans+=(set.find(x)!=set.end());
  }

  cout<<ans<<endl;


}




Measured memory_bytes: 7856
N = int(input())
A_s = list(map(int, input().split()))
answer = 0
for i, A in enumerate(A_s):
    if i == 0:
        continue
    if A_s[i-1] > A_s[i]:
        answer += A_s[i-1] - A_s[i]
        A_s[i] = A_s[i-1]
print(answer)

Measured memory_bytes: 105292
#include<stdio.h>
main(){
  int y1,m1,d3,y2,m2,d4,day[1000000]={0},i,j;
  double d1,d2;
  for(i=0;i<1000000;i++){
    if(i%400==0)day[i]=1;
    else if(i%4==0&&i%100!=0)day[i]=1;
  }

  while(1){
    d1=0,d2=0;
    scanf("%d %d %d %d %d %d",&y1,&m1,&d3,&y2,&m2,&d4);
    if(y1<0||m1<0||d1<0||y2<0||m2<0||d2<0)return 0;
    for(i=0;i<y1;i++){
      if(day[i]==0)d1+=365;
      else d1+=366;
    }
    for(j=0;j<y2;j++){
      if(day[j]==0)d2+=365;
      else d2+=366;
    }

    for(i=1;i<m1;i++){
      switch(i){
      case 4:
      case 6:
      case 9:
      case 11:
	d1+=30;
	break;
      case 2:
	if(day[y1]==1)d1+=29;
	else d1+=28;
	break;
      default:
	d1+=31;
	break;

      }
    }

    for(i=1;i<m2;i++){
      switch(i){
      case 4:
      case 6:
      case 9:
      case 11:
	d2+=30;
	break;
      case 2:
	if(day[y2]==1)d2+=29;
	else d2+=28;
	break;
      default:
	d2+=31;
	break;

      }
    }

    d1+=d3;
    d2+=d4;
  printf("%.0f\n",d2-d1);
  }
  return 0;
}

Measured memory_bytes: 4544
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

#define MAX 2000000
#define N 2000000001

int T[MAX];

int n=0;

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

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

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

void heapIncreaseKey(i, key){
  int x;
  if(key < T[i]) printf("new kry is smaller than current key");
  T[i] = key;
  while( i > 1 && T[parent(i)] < T[i]){
    x = T[i];
    T[i] = T[parent(i)];
    T[parent(i)] = x;
    i = parent(i);
  }
}

void maxHeapInsert(key){
  n++;
  T[n] = INT_MIN;
  heapIncreaseKey(n, key);
}

void maxHeapify(int i){
  int h, l, r, largest;
  l = left(i);
  r = right(i);
  if(l <= n && T[l] > T[i]) largest = l;
  else largest = i;
  if(r <= n && T[r] > T[largest]) largest = r;
  if(largest != i){
    h = T[i];
    T[i] = T[largest];
    T[largest] = h;
    maxHeapify(largest);
  }
}

int heapExtractMax(void){
  int max;
  if(n < 1) printf("heap underflow");;
  max = T[1];
  T[1] = T[n];
  n--;
  maxHeapify(1);
  return max;
}

void buildMaxHeap(){
  int i;
  for(i=n/2; i>0; i--) maxHeapify(i);
}

int main(){
  int i=1, k=0, j;
  char com[10];
  int p[MAX];

  while(1){
    scanf("%s", com);
    if(com[2] == 's'){
      scanf("%d", &T[i]);
      maxHeapInsert(T[i]);
      i++;
    }
    else if(com[2] == 't'){
      p[k] = heapExtractMax();
      k++;
    }
    else if(com[2] == 'd'){
      if(k==0) printf("0\n");
      else{
	for(i=0; i<k; i++) printf("%d\n",p[i]);
      }
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 10524
def main():
    H, W, M = map(int, input().split())
    # H, W, M = (3 * 10 ** 5, 3 * 10 ** 5, 3 * 10 ** 5)

    row = [0] * (H + 1)
    row_set = [set() for _ in range(H+1)]
    column = [0] * (W + 1)
    column_set = [set() for _ in range(W+1)]
    # import random
    ms = []
    positions = set()
    for m in range(M):
        h, w = map(int, input().split())

        positions.add((h, w))
        # h, w = (random.randrange(3*10**5), random.randrange(3*10**5))
        row[h] += 1
        row_set[h].add(w)

        column[w] += 1
        column_set[w].add(h)



    max_rows = set()
    maxR = -1
    for i, v in enumerate(row[1:]):
        if v > maxR:
            max_rows = set()
            max_rows.add(i+1)
            maxR = v
        elif v == maxR:
            max_rows.add(i+1)


    max_cols = set()
    maxC = -1
    for i, v in enumerate(column[1:]):
        if v > maxC:
            max_cols = set()
            max_cols.add(i+1)
            maxC = v
        elif v == maxC:
            max_cols.add(i + 1)


    for y in max_rows:
        for x in max_cols:
            if not (y, x) in positions:
                print(maxR + maxC)
                exit()
    print(maxR + maxC - 1)
main()


Measured memory_bytes: 372600
def prison(left, right):
    if left <= right:
        print(right-left+1)
    else:
        print(0)
        
N, M = map(int, input().split())
left_limit=0
right_limit=N
 
for i in range(M):
    LEFT, RIGHT = map(int, input().split())
    if LEFT > left_limit:
        left_limit = LEFT
    if RIGHT < right_limit:
        right_limit = RIGHT

prison(left_limit, right_limit)

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

int main() {

    int N;
    cin >> N;

    int count = 0;
    int twopow = 2;
    while(N>=twopow){
        if(twopow != 0) {
            twopow *= 2;
        }
        count += 1;
    }
    int ans;
    if(count == 0){
        ans = 1;
    }else{
        ans = pow(2, count);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/
void out(int a, int b, int c)
{
    cout << a << " " << b << " " << c << endl;
}
int main()
{
    int x, y;
    cin >> x >> y;
    int a = 0, b = 0, c = 0;
    c = (y / 1000);
    rep(i, 2001)
    {
        rep(j, 2001)
        {
            c = (y - 10000 * i - 5000 * j) / 1000;
            if ((i + j + c) == x && c >= 0)
            {
                out(i, j, c);
                return 0;
            }
        }
    }
    out(-1, -1, -1);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main() {
	int W,H,C,iW,L;
	scanf("%d %d %d",&W,&H,&C);
	for(iW=1;;){
		if(W%iW==0){
			if(H%(W/iW)==0)break;
		}
		iW++;
	}
	L=W/iW;
	printf("%d\n",iW*(H/L)*C);
	return 0;
}


Measured memory_bytes: 2100
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        int oddCount = 0;
        for (int num : a) {
            if (num % 2 == 1) {
                oddCount++;
            }
        }
        boolean judge = oddCount % 2 == 0;
        String result = judge ? "YES" : "NO";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 47776
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [str(i) for i in input().split()]

    if ord(a[0]) > ord(a[1]):
        print(">")
    elif ord(a[0]) < ord(a[1]):
        print("<")
    else:
        print("=")



Measured memory_bytes: 3828
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();
        int T = sc.nextInt();
        int cnt = 0;
        int now = A;

        while (now <= T) {
            now += A;
            cnt += B;
        }

        System.out.println(cnt);

    }
}


Measured memory_bytes: 25300
N = int(input())
A = [int(i) for i in input().split()]

l,r,num,ans = 0,0,0,0

while r<N:
        if num + A[r] == num ^ A[r]:
                num += A[r]
                r += 1
                ans += r-l
        else:
                num -= A[l]
                l += 1

print(ans)


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

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

const int maxk = 100001;
const int maxn = 101;
int n, k;
int dp[maxk][2];
int arr[maxn];

int dfs(int k, int t) {
  if (dp[k][t] != 0) return dp[k][t];
  int res = 2;
  for (int i = 0; i < n; ++i) {
    if (k >= arr[i]) {
      if (dfs(k - arr[i], !t) == 2) {
        res = 1;
        break;
      }
    }
  }
  return dp[k][t] = res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
      cin >> arr[i];
    }
    if (dfs(k, 0) == 1) {
      cout << "First" << endl;
    } else {
      cout << "Second" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 5760
def main():
    N = input()
    if N[-1] == "3":
        print("bon")
    elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6"  or N[-1] == "8":
        print("pon")
    else:
        print("hon")

if __name__ == "__main__":
    main()


Measured memory_bytes: 9100
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  vector<int> v1;
  vector<int> v2;
  int tn = 1;
  while(1){
      int tmp = tn*(tn+1)*(tn+2)/6;
      if(tmp < 1000000){
        v1.push_back(tmp);
        if(tmp % 2 != 0) v2.push_back(tmp);
      }else{
        break;
      }
      tn++;
  }

  int INF = 1000000000;
  int dp1[1000005], dp2[1000005];

  REP(i,0,1000005) dp1[i] = i, dp2[i] = i;

  REP(i,1,180){
    REP(j,0,1000005){
      if(j-v1[i] >= 0) dp1[j] = min(dp1[j], dp1[j-v1[i]] + 1);
    }
  }
  REP(i,1,45){
    REP(j,0,1000005){
      if(j-v2[i] >= 0) dp2[j] = min(dp2[j], dp2[j-v2[i]] + 1);
    }
  }

  int N;
  while(1){
    cin>>N;
    if(N==0) break;

    cout<<dp1[N]<<" "<<dp2[N]<<endl;

  }

  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

struct Node {
  ll left;
  ll right;
  ll value; // 葉でなければ-1
};

const ll NONE = 10000000;
Node node[200000];

vector<PLL> ans;

ll f(ll i) {
  if (node[i].value != NONE)
    return node[i].value;

  ll x = f(node[i].left);
  ll y = f(node[i].right);
  ans.push_back({x,y});
  return x-y;
}

signed main() {
  ll N;
  cin >> N;
  vector<ll> B(N);
  rep(i,N) {
    cin >> B[i];
  }


  sort(begin(B), end(B));
  vector<ll> A;
  A.push_back(B[N-1]);
  A.push_back(B[0]);
  for (ll i=1; i<N-1; i++) {
    A.push_back(B[i]);
  }

  node[0] = Node{1, 2, NONE};
  node[1] = Node{0, 0, A[0]}; // +
  node[2] = Node{0, 0, A[1]}; // -

  ll root = 0, nNode = 3;

  for (ll i=2; i<N; i++) {
    if (A[i] < 0) {
      // 直下にくっつけた方が有利
      ll n1 = nNode;
      ll n2 = nNode + 1;

      node[n1].left  = root;
      node[n1].right = n2;
      node[n1].value = NONE;

      node[n2].left  = 0;
      node[n2].right = 0;
      node[n2].value = A[i];

      root = n1;
      nNode += 2;
    } else {
      // 2個下にくっつけた方が有利
      ll n1 = nNode;
      ll n2 = nNode + 1;

      node[n1].left = node[root].right;
      node[n1].right = n2;
      node[n1].value = NONE;

      node[n2].left = 0;
      node[n2].right = 0;
      node[n2].value = A[i];


      node[root].left;
      node[root].right = n1;
      node[root].value;

      root;
      nNode += 2;
    }
  }

  f(root);
  cout << ans[ans.size()-1].first - ans[ans.size()-1].second << endl;
  for (auto e: ans) {
    cout << e.first << " " << e.second << endl;
  }
  return 0;
}



Measured memory_bytes: 16112
#include <bits/stdc++.h>
using namespace std;
long long a[5010],b[5010];
bool comp(int a, int b) 
{
	return a > b;
}
int main() {
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	 
	for (int i = 0; i <n; i++)
	 {
		cin >> a[i];
		if(i)
		b[i]=b[i-1]+a[i];
	}
	if(n*k>25000000)
	for(int i=0;;i++)
	i--;
	sort(a, a+n, comp);
	long long sum = 0, cnt = 0;
	for (int i = 0; i < n; i++) 
	{
		sum += a[i];
		if (sum < k) 
			cnt++;
		else {
			sum -= a[i];
			cnt = 0;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

int main() {
  int num;
  double tmp;
  double kekka = 0;
  
  cin >> num;
  vector<double> vec(num);
  
  for(int i = 0; i < num; i++) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  
  for(int i = 0; i < num; i++){
    if(i == 0){
      kekka = vec.at(i);
      continue;
    }
    
    kekka = (kekka + vec.at(i)) / 2;
  }
  
  cout << kekka;
}


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

int main(){

    while(1){
        int t,d,l;
        cin >> t >> d >> l;
        if(t==0&&d==0&&l==0)break;
        vector<int> x(t);
        for(int i=0;i<t;i++){
            cin >> x[i];
        }
        int cnt=0;
        int ans=0;
        for(int i=0;i<t-1;i++){
            if(x[i]>=l){
                cnt=d;
            }else{
                cnt--;
            }
            if(cnt>0)ans++;
            //cout << cnt << endl;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3468
fn main() {
    proconio::input! {
        n: usize,
    }
    let mut r = vec![0u64; n];

    for x in 1.. {
        if x * x >= n {
            break;
        }
        for y in 1.. {
            if x * x + y * y >= n {
                break;
            }
            for z in 1.. {
                if x * x + y * y + z * z + x * y + y * z + z * x > n {
                    break;
                }
                r[x * x + y * y + z * z + x * y + y * z + z * x - 1] += 1;
            }
        }
    }
    for i in 0..n {
        println!("{}", r[i]);
    }
}


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

int main()
{
  string s ,t ;
  cin>>s >>t ;
  int cnt =0 ;
  int mini =1e7 ;
  for (int i=0 ;i<s.size()-t.size()+1;i++)
  {
      string x ;
      cnt=0 ;
      x=s.substr(i,t.size()) ;
      for(int j=0 ;j<t.size();j++)
      {
          if(x[j]!=t[j])
            cnt++ ;
      }
      mini=min(cnt,mini) ;
  }
  cout<< mini<<endl ;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<iostream>

#define ll long long

using namespace std;

int main(){
//	freopen("in","r",stdin);
	ll n,a,b; cin >> n >> a >> b;
	ll res = a*(n/(a+b));
	if(n%(a+b)>=a) res += a;
	else res += n%(a+b);
	cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void quick_sort(int a[], int first, int last);

int main(void){
  int n;
  scanf("%d", &n);
  int question[n];

  for(int i=0 ; i<n ; i++)
    scanf("%d", &question[i]);

  quick_sort(question, 0, n-1);

  int ans = question[n/2] - question[n/2-1];

  printf("%d\n", ans);

  return 0;
}



void quick_sort(int a[], int first, int last){
  int temp, k;
  int flag=1;
  int p = a[first];
  int i = first, j = last;

  while(flag){
    while(a[i]<p)
      i++;
    while(p<a[j])
      j--;
    if(i<j){
      temp=a[i];
      a[i]=a[j];
      a[j]=temp;
      i++; j--;
    }
    else
      flag=0;
  }

  if(first<i-1)
	quick_sort(a,first,i-1);
  if(j+1<last)
	quick_sort(a,j+1,last);
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int N,i;
  double  x[100]={0};
  char u[12]={0};
  double cnt;
  
  scanf("%d ",&N);
  for(i=0;i<N;i++){
  scanf("%lf", &x[i]);
  scanf("%s", u);
  
  if(u[0]=='J'){
   cnt+=x[i];}
  else{
   cnt+=x[i]*380000;} 
  
  }
  printf("%f",cnt);
  
  return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long DP[1001*30001];
pair<int,pair<int,long>> Data[1000];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		int W = rei();
		int S = rei();
		long V = rel();
		Data[i] = {W+S,{W,V}};
	}
	sort(Data,Data+N);
	for(int i=0;i<N;i++){
		int S = Data[i].first - Data[i].second.first;
		int W = Data[i].second.first;
		long V = Data[i].second.second;
		for(int j=0;j<=30000;j++){
			DP[(i+1)*30001+j] = DP[i*30001+j];
		}
		for(int j=0;j<=S;j++){
			DP[(i+1)*30001+j+W] = max(DP[(i+1)*30001+j+W],DP[i*30001+j]+V);
		}
	}
	long ans = 0;
	for(int i=0;i<=30000;i++){
		ans = max(ans,DP[N*30001+i]);
	}	
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 234624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    cin>>n;
    std::deque<int> deq;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    int count=0;
    int now=deq[0];
    int flag=0;
    while (count<1000000) {
        if (now==2) {
            cout<<count+1<<endl;
            flag=1;
            break;
        } else {
            now=deq[now-1];
            count++;
        }
    }
    if (flag==0) {
        cout<<-1<<endl;
    }
}

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

const int maxn = 100010;
char str[maxn];

int main() {
#ifdef HOME
  freopen("input.txt", "r", stdin);
#endif
  int n;
  n = strlen(fgets(str, 100010, stdin));
  --n;
  int cnt = 0;
  char ch = '0';
  for (int i = 0; i < n; ++i) {
    if (ch != str[i]) ++cnt;
    ch = ch == '0' ? '1' : '0';
//    cout << i << ' ' << ch << ' ' << cnt << endl;
  }
  int ans = 0;
  ch = '1';
  for (int i = 0; i < n; ++i) {
    if (ch != str[i]) ++ans;
    ch = ch == '0' ? '1' : '0';
//    cout << i << ' ' << ch << ' ' << ans << endl;
  }
  
  cout << min(ans, cnt);
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define INF 1010101010
#define MOD 1000000007
#define LL long long
 
int main() {
    int w, a, b;
    cin >> w >> a >> b;
    int ans;
    if (abs(a-b) <= w) ans = 0;
    else ans = abs(a-b) - w;
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

C = input().split()
N = int(C[0])
K = int(C[1])

out = 0

for i in range(N):
    l = i + 1

    if l < K:

        d = l
        count = 0

        while d < K:
            d = d * 2
            count += 1
        
        # print("d:" + str(d))
        # print("count:" + str(count))

        ans = 1 / N * pow(1/2, count)
        out += ans
    else:
        ans = 1 / N * pow(1/2, 0)
        out += ans

# print(out)
# print(f'{out:f}')
# print("%f" % out)
print("{0:.12f}".format(out))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--) {
		LL a,b,c,d;
		cin>>a>>b>>c>>d;
		if(d<b||a<b) {
			cout<<"No"<<endl;
			continue;
		}
		if(c>=b) {
			cout<<"Yes"<<endl;
			continue;
		}
		LL x=__gcd(b,d);
		LL ax=a-(a/b)*b;
		//cout<<x<<" "<<ax<<endl;
		if(ax>c) {
			cout<<"No"<<endl;
			continue;
		}
		LL bx=ax-ax/x*x;
		if(bx>c) {
			if(bx<b) cout<<"No"<<endl;
			else cout<<"Yes"<<endl;
			continue;
		}
		LL cx=(c-bx)/x*x;
		cx+=bx+x;
		//cout<<bx<<" "<<cx<<endl;
		if(cx>c&&cx<b) {
			cout<<"No"<<endl;
		}
		else cout<<"Yes"<<endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll i,j,k,t,n,a,b,c=0;
    cin>>a>>b>>n;
    for(i=a;i<=b;i++)
    {
        if(i%n==0)
        {
            c++;
        }
    }
    cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 3572
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline
    from collections import deque
    from bisect import bisect_left

    N = int(input())
    a = list(map(int, input().split()))
    tree = [[] for _ in [0]*N]
    for u, v in [map(int, input().split()) for _ in [0]*(N-1)]:
        tree[u-1].append(v-1)
        tree[v-1].append(u-1)
    
    dp = [1001001001] * (N+1)
    dp[0] = -1001001001
    ans = [0] * N
    def dfs(now, p=-1):
        idx = bisect_left(dp, a[now])
        old = dp[idx]
        dp[idx] = a[now]
        ans[now] = idx
        if p != -1 and ans[now] < ans[p]:
            ans[now] = ans[p]
        for child in tree[now]:
            if child == p: continue
            dfs(child, now)
        dp[idx] = old
    dfs(0)

    print(*ans, sep='\n')

main()

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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; }


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

    vector<ll> l(N);
    vector<ll> r(N);

    ll ans = 0;

    rep(i,N)
    {
        cin >> l[i] >> r[i];
        ans += r[i]-l[i]+1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for(int i=0; i<n; i++){
			list.add(sc.nextInt());
		}
		list.sort(Comparator.reverseOrder());
		int alice = 0, bob = 0;
		for(int i=0; i<n; i++){
			if(i % 2 == 0){
				alice += list.get(i);
			}else{
				bob += list.get(i);
			}
		}
		System.out.println(alice - bob);
	}
}


Measured memory_bytes: 35816
use proconio::{input, fastout};
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;


#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let mut ans = 0;
    for i in 0..s.len() {
        if s[i] != t[i] {
            ans += 1;
        }
    }

    println!("{}", ans)
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	map <ll,ll> m;
	for(ll i=1;i<=105;i++)
	{
		for(ll j=1;j<=105;j++)
		{
			for(ll k=1;k<=105;k++)
			{
				ll g = i*i + j*j + k*k + i*j + i*k + j*k;
				if(g>n) break;
				m[g]++;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout<<m[i]<<'\n';
	}

	return 0;
}


Measured memory_bytes: 4268
n,k = map(int,input().split())
x = list(map(int,input().split()))
l,r = 0,0
anus = 10**9
for i in range(n):
  l = i
  r = i+(k-1)
  if r >= n:
    break
  anus = min(anus,abs(x[l])+abs(x[r]-x[l]),abs(x[r])+abs(x[r]-x[l]))
print(anus)


Measured memory_bytes: 62736
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

void rotate4(char& a,char& b,char& c,char& d)
{
	char x=a;
	a=b; b=c; c=d; d=x;
}

void turn_u(string* s)
{
	rotate4(s[0][2],s[1][2],s[1][3],s[0][3]);
	std::rotate(s[2].begin(),s[2].begin()+2,s[2].end());
}
void turn_f(string* s)
{
	rotate4(s[2][2],s[3][2],s[3][3],s[2][3]);
	rotate4(s[1][2],s[3][1],s[4][3],s[2][4]);
	rotate4(s[1][3],s[2][1],s[4][2],s[3][4]);
}
void turn_r(string* s)
{
	rotate4(s[2][4],s[3][4],s[3][5],s[2][5]);
	rotate4(s[0][3],s[2][3],s[4][3],s[3][6]);
	rotate4(s[1][3],s[3][3],s[5][3],s[2][6]);
}
void turn_d(string* s)
{
	rotate4(s[4][2],s[5][2],s[5][3],s[4][3]);
	std::rotate(s[3].begin(),s[3].begin()+6,s[3].end());
}
void turn_b(string* s)
{
	rotate4(s[2][6],s[3][6],s[3][7],s[2][7]);
	rotate4(s[0][2],s[2][5],s[5][3],s[3][0]);
	rotate4(s[0][3],s[3][5],s[5][2],s[2][0]);
}
void turn_l(string* s)
{
	rotate4(s[2][0],s[3][0],s[3][1],s[2][1]);
	rotate4(s[0][2],s[3][7],s[4][2],s[2][2]);
	rotate4(s[1][2],s[2][7],s[5][2],s[3][2]);
}

int main()
{
	string s[6]={
		"..rr....",
		"..rr....",
		"ggyybbww",
		"ggyybbww",
		"..oo....",
		"..oo....",
	};
	
	string cmd; cin>>cmd;
	rep(i,cmd.size())
		switch(cmd[i]){
			case 'U': turn_u(s); break;
			case 'F': turn_f(s); break;
			case 'R': turn_r(s); break;
			case 'D': turn_d(s); break;
			case 'B': turn_b(s); break;
			case 'L': turn_l(s); break;
		}
	
	rep(i,6)
		cout<<s[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 1192
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<(a<=1ll*b*c?"Yes":"No");
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

#define SIZE 100

int main(void) {
  char weather[SIZE][SIZE];
  int forecast[SIZE][SIZE] = {0};

  int H = 0;
  int W = 0;

  scanf("%d %d", &H, &W);

  for (int i = 0; i < H; i++) {
      scanf("%s", weather[i]);
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if(weather[i][j] == 'c') {
	forecast[i][j] = 0;
      } else {
	forecast[i][j] = -1;
      }
    }
  }

  for (int i = 1; i < W; i++) {
    for (int j = 0 ; j < H; j++) {
      for (int k = W - 1; k >= i; k--) {
	if ((forecast[j][k - 1] >= 0) && (forecast[j][k] == -1)) {
	  forecast[j][k] = i;
	}
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      printf("%d", forecast[i][j]);

      if ((j + 1) < W) {
	printf(" ");
      }
    }
    
    printf("\n");
  }
  
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n;
  n=s.length();
  int r1=0;
  int r2=0;
  //if (n%2==0){
  	  for (int i=0;i<n;i++){
	    r1+=abs((int)(s[i])-48-i%2);
        r2+=abs((int)(s[i])-48-(i+1)%2);
      }
  //}else{
    //for (int i=0;i<n;i++){
      
    //}
  //}
  
  cout << min(r1,r2);
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 200000 + 100, MOD = 998244353;
int N, K; char s[maxn]; ll f[maxn][3][3][2]; bool fl = true;

bool check()
{
	for(int i = 1; i < N; ++i)
		if(s[i] != s[i+1]) return false;
	return true;
}

void Init()
{
	scanf("%s", s+1);
	N = strlen(s+1), K = 0;
	for(int i = 1; i <= N; ++i)
		K = (K + s[i] - 'a') % 3;
	for(int i = 1; i < N; ++i)
		if(s[i] == s[i+1]) { fl = false; break; }
}

void Solve()
{
	if(check()) { printf("1\n"); return; }
	if(N == 3)
	{
		if(s[1]!=s[2] && s[2]!=s[3] && s[1]!=s[3]) { printf("3\n"); return; }
		if((s[1]==s[2]&&s[2]!=s[3]) || (s[1]!=s[2]&&s[2]==s[3])) { printf("6\n"); return; }
		if(s[1]==s[3] && s[1]!=s[2]) { printf("7\n"); return; }
		if(s[1]==s[2] && s[2]==s[3]) { printf("1\n"); return; }
	}
	//f[i][j][k][p]±íÊ¾Ç°iÎ» µÚiÎ»Îªj Ç°iÎ»ºÍÄ£3Îªk ³öÏÖ/Î´³öÏÖ¹ýÁ½¸öÁ¬×ÅÏàµÈµÄÇé¿öµÄ ·½°¸Êý 
	memset(f, 0, sizeof(f));
	f[1][0][0][0] = f[1][1][1][0] = f[1][2][2][0] = 1;
	for(int i = 2; i <= N; ++i)
		for(int j = 0; j <= 2; ++j) // ÕâÒ»Î»ÊÇj 
			for(int k = 0; k <= 2; ++k) // ÉÏÒ»Î»ÊÇk 
				for(int p = 0; p <= 2; ++p) // Ö®Ç°ËùÓÐºÍÎªp 
					if(f[i-1][k][p][0] || f[i-1][k][p][1])
					{
						int u = (p + j) % 3;
						if(j != k) (f[i][j][u][1] += f[i-1][k][p][1]) %= MOD, (f[i][j][u][0] += f[i-1][k][p][0]) %= MOD;
						else (f[i][j][u][1] += f[i-1][k][p][0] + f[i-1][k][p][1]) %= MOD;
					}
	printf("%lld\n", (f[N][0][K][1]+f[N][1][K][1]+f[N][2][K][1]+fl)%MOD);
}

int main()
{
	Init(), Solve();
}

Measured memory_bytes: 28672
#include<stdio.h>
int a[1000000];
int main(){
	int n;
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++){
		a[i]=i;
	}
	long long int sum=0;
	for(i=1;i<=n;i++){
		if((i%3==0)||(i%5)==0||(i%15)==0){
			sum+=0;
		}
		else{
			sum+=i;
			
		}
	}
	printf("%lld",sum);
}

Measured memory_bytes: 5560
#include<stdio.h>

int n, S[100000];

int binarySearch(int key) {
    int left = 0, right = n, mid;
    
    while (left < right) {
        mid = (left + right) / 2;
        
        if (S[mid] == key) {
            return 1;
        } else if (key < S[mid]) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    
    return 0;
}

int main() {
    int q, key, ans = 0;
    int i;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    
    scanf("%d", &q);
    
    for (i = 0; i < q; i++) {
        scanf("%d", &key);
        
        if (binarySearch(key)) {
            ans++;
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}



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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main() {

	int N, M;
	cin >> N >> M;

	vector<vector<int>> s(M);
	rep(i, M) {
		int k;
		cin >> k;
		rep(j, k) {
			int t;
			cin >> t; t--;
			s[i].push_back(t);
		}
	}
	vector<int> p(M);
	rep(i, M) cin >> p[i];


	int ans = 0;
	rep(bit, 1LL << N) {
		bool ok = true;
		for(int light=0; light<M; light++){
			int c = 0;
			for (int i = 0; i < s[light].size(); i++) {
				if ((bit & (1LL << s[light][i])) > 0) c++;
			}
			if (c % 2 != p[light]) {
				ok = false;
				break;
			}
		}
		if (ok) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import math
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
MOD = 10**9 + 7

n = input()
l = [chr(i) for i in range(65,91)]

if n in l:
  print('A')
else:
  print('a')


Measured memory_bytes: 9412
# include <bits/stdc++.h>
    # define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
    # pragma GCC optimize "-O3"
    # define int long long
      
    using namespace std;
      
    const int N = 1e4 + 7;
    const int mod = 1e9 + 7;
     
    void solve() {
    	int x;
    	cin >> x;
    	int y = 100, cnt = 0;
    	while ( y < x ) {
    		cnt++;
    		int z = y / 100 * 1;
    		y += z;
    	}
    	cout << cnt << "\n";
    }
     
    int32_t main() {
    	speed;
    	int T = 1;
    	// cin >> T;
    	while ( T-- ) {
    		solve();
    	}
    }

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

using namespace std;

typedef long long int ll;

const ll MAXN = 2e5 + 5;
const ll mod = 1e9 + 7;

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

  ll n;
  cin >> n;
  vector < ll > c(n + 1, 0), sum(MAXN, 0), dp(n + 1, 0);
  for(int i = 1; i <= n; i++) cin >> c[i];
  dp[0] = 1;
  for(int i = 1; i <= n; i++){
    dp[i] = sum[c[i]];
    if(c[i] != c[i - 1]){
      dp[i] += dp[i - 1];
      dp[i] %= mod;
      sum[c[i]] += dp[i - 1];
      sum[c[i]] %= mod;
    }
  }

  cout << dp[n] << '\n';
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

void insertionSort(vector<int>& a, int n) {
  for (int i = 1; i < n; ++i) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      --j;
    }
    a[j + 1] = v;
    for (int k = 0; k < n; ++k) {
      cout << a[k];
      if (k == n - 1) break;
      cout << " ";
    }
    cout << endl;
  }
}

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

  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; ++i) {
    cout << arr[i];
    if (i == n - 1) break;
    cout << " ";
  }
  cout << endl;

  insertionSort(arr, n);
  return 0;
}



Measured memory_bytes: 3120
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    EPS = 1e-9
    for line in readlines():
        conv = lambda x: int(float(x) * 100000)
        x1, y1, x2, y2, x3, y3, x4, y4 = map(conv, line.split())
        x1 -= x2; y1 -= y2
        x3 -= x4; y3 -= y4
        if x1*x3 + y1*y3 == 0:
            write("YES\n")
        else:
            write("NO\n")
solve()



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    string s; cin >> s;
    cout << s.substr(0, 4) << ' ' << s.substr(4, 8) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n,k;
    cin >> n >> k;
    int p[n];
    REP(i,n) cin >> p[i];
    int sumf=0,suml=0,maxs=0;
    REP(i,n){
        sumf+=p[i];
        if(i>=k){
            suml+=p[i-k];
        }
        chmax(maxs,sumf-suml);

    }
    double ans=(double)k/2 + (double)maxs/2;
    printf("%.7f\n",ans);

    return 0;
}

Measured memory_bytes: 4540
#include <bits/stdc++.h>
using namespace std;
int main(){
cout << fixed << setprecision(12);
double r;
cin>>r;

double PI = acos(-1);
double area = r * r * PI;
double cir = (r + r) * PI;
cout<<area<<" "<<cir<<endl;

return 0;
}


Measured memory_bytes: 3260
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N, M;



int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	while (N) {
		int num[1001];
		int ans = 0;
		set<int>F;
		set<int>S;
		for (int i = 0; i < N; i++)cin >> num[i];
		F.insert(0);
		for (int i = 0; i < N/2; i++) {
			F.insert(num[i]);
			for (int j = 0; j < N/2; j++) {
				F.insert(num[i] + num[j]);
			}
		}
		S.insert(0);
		for (int i = N/2; i < N; i++) {
			S.insert(num[i]);
			for (int j = N/2; j < N; j++) {
				S.insert(num[i] + num[j]);
			}
		}
		set<int>::reverse_iterator ritr = S.rbegin();
		for (auto i : F) {
			if (ritr == S.rend())break;
			while ((i + *ritr) > M) {
				++ritr;
				if (ritr ==S.rend())break;
			}
			if(ritr!=S.rend())	ans = max(ans, i + *ritr);
		}
		cout << ans << endl;
		cin >> N >> M;
	}
	return 0;
}

Measured memory_bytes: 14864
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
vector<ll> a,b;

void solve(){
    cin >> n;
    ll ans=0;
    a.resize(n,0);
    b.resize(n,0);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    per(i,n){
        //cout << ans << endl;
        a[i]+=ans;
        b[i]=((a[i]+b[i]-1)/b[i])*b[i];
        //cout << a[i] << " " << b[i] << endl;
        ans+=b[i]-a[i];
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 1920
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

class Node {
  public:
    Node();
    long long cost;
    int prev;
    bool is_updated;
};

class Edge {
  public:
    int dst;
    int src;
    long long cost;
    Edge(int, int, long long);
};

Node::Node()
{
  is_updated = false;
}

Edge::Edge(int _dst, int _src, long long _cost)
{
  dst = _dst;
  src = _src;
  cost = _cost;
}

void update_node(vector<Node>& node, const vector<Edge>& edge)
{
  for(size_t y = 0; y < edge.size(); y++) {
    int src = edge[y].src;
    int dst = edge[y].dst;
    long long cost = edge[y].cost;
    if(node[src].cost == LLONG_MIN) {
      continue;
    }
    if(node[dst].cost < node[src].cost + cost) {
      node[dst].cost = node[src].cost + cost;
      node[dst].prev = src;
      node[dst].is_updated = true;
    }
  }
}

bool check_negative_cycle(vector<Node>& node, vector<Edge>& edge, int start)
{
  int goal = node.size()-1;
  int i = goal;
  while(i != start) {
    if(node[i].is_updated) {
      return true;
    }
    i = node[i].prev;
  }
  return false;
}

// If there are negative cycles in this graph, this function returns true
bool bellman_ford(vector<Node>& node, vector<Edge>& edge, int start)
{
  for(auto& n : node) {
    n.cost = LLONG_MIN;
  }
  node[start].cost = 0;
  for(size_t x = 0; x < node.size()-1; x++) {
    update_node(node, edge);
  }
  for(auto& n : node) {
    n.is_updated = false;
  }
  update_node(node, edge);
  return check_negative_cycle(node, edge, start);
}

int main()
{
  int nnode, nedge;
  bool inf_flag;
  scanf("%d%d", &nnode, &nedge);
  vector<Node> node(nnode);
  vector<Edge> edge;
  edge.reserve(nedge);
  for(int i = 0; i < nedge; i++) {
    int src, dst;
    long long cost;
    scanf("%d%d%lld", &src, &dst, &cost);
    src--;
    dst--;
    edge.push_back(Edge(dst, src, cost));
  }
  inf_flag = bellman_ford(node, edge, 0);
  long long result = node[nnode-1].cost;
  if(inf_flag) {
    printf("inf\n");
  } else {
    printf("%lld\n", result);
  }
  return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void rec(int d, ll val, vector<ll> &all) {
    all.push_back(val);
    if (d == 10) return;
    for (int i = -1; i <= 1; ++i) {
        int add = (val % 10) + i;
        if (add >= 0 && add <= 9) rec(d+1, val*10+add, all);
    } 
}

int main() {
    int K;
    cin >> K;
    vector<ll> all;
    for (int i = 1; i < 10; ++i) rec(1, i, all);
    sort(all.begin(), all.end());
    cout << all[K-1] << endl;
    return 0;
}

Measured memory_bytes: 3444
#include <stdio.h>

#define NODE_MAX (250)

struct node {
        int key;
        int parent;
        int left;
        int right;
};

int
main(void)
{
        int heap_size;
        struct node key[NODE_MAX];
        int i;

        scanf("%d", &heap_size);

        for (i = 1; i <= heap_size; i++)
                scanf("%d", &key[i].key);

        for (i = 1; i <= heap_size; i++) {
                key[i].parent = i / 2;
                key[i].left = i * 2;
                key[i].right = i * 2 + 1;
        }

        for (i = 1; i <= heap_size; i++) {
                printf("node %d: key = %d, ", i, key[i].key);

                if (key[i].parent != 0)
                        printf("parent key = %d, ", key[key[i].parent].key);

                if (key[i].left <= heap_size)
                        printf("left key = %d, ", key[key[i].left].key);

                if (key[i].right <= heap_size)
                        printf("right key = %d, ", key[key[i].right].key);

                printf("\n");
        }
}



Measured memory_bytes: 2036
import qualified Data.ByteString.Char8 as C
import           Data.Maybe ( fromJust, isNothing )

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,y] <- readInts
  putStrLn $ f n y

type Mai = Int
type Yen = Int
type Pochi = (Int,Int,Int) -- #s of 10000,5000,1000 bills

minPochi :: Yen -> Pochi -- returns the minimum number of bills
minPochi y = (a,b,c)
  where
    (a,r) = y `quotRem` 10000
    (b,s) = r `quotRem` 5000
    c     = s `quot` 1000

canPay :: Mai -> Yen -> Maybe Pochi
canPay n y = h i
  where
    i@(a,b,c) = minPochi y

    h :: Pochi -> Maybe Pochi
    h p@(a,b,c)
      | m == 0             = Just p
      | m > 3 && b > 0 = h (a,  b-1,c+5) -- 5000 =5*1000
      | m > 0 && a > 0 = h (a-1,b+2,c)   -- 10000=2*5000
      | otherwise          = Nothing
      where
        m = n-(a+b+c)

f :: Mai -> Yen -> String
f n y
  | isNothing p = "-1 -1 -1"
  | otherwise   = show a ++ " " ++ show b ++ " " ++ show c
  where
    p = canPay n y
    Just (a,b,c) = p

otsdm' :: Mai -> Yen -> [Pochi]
otsdm' n y
  = [(a,b,n-a-b) -- double loop
    | let a0 = y `quot` 10000
    , a <- [0 .. a0]
    , let b0 = (y - 10000*a) `quot` 5000
    , b <- [0 .. b0]]

gok :: Pochi -> Yen
gok (a,b,c) = 10000*a +5000*b + 1000*c 

otsdm :: Mai -> Yen -> String
otsdm n y
  | null os   = "-1 -1 -1"
  | otherwise = show a ++ " " ++ show b ++ " " ++ show c
  where
    os = filter (\o -> y == gok o) $ otsdm' n y
    (a,b,c) = head os

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

using namespace std;

int main()
{
    
    int a,b;
    scanf("%2d%2d",&a,&b);
    if((a>12 && b>12) ||(a==0 && b==0)||(a == 0 && b>12) || (b==0 && a>12)){
        printf("NA\n");
    }
    else if((a <=12 && b<=12) && (a!=0 && b!=0)){
        printf("AMBIGUOUS\n");
    }
    else if(a>12 || a==0){
        printf("YYMM\n");
    }
    else if(b>12 || b==0){
        printf("MMYY\n");
    }

    return 0;
}

Measured memory_bytes: 256