akhauriyash/Code-Regression huggingface dataset:
"""
Nが奇数のとき、絶対に末尾が0が来ることはない。したがって、答えは0。
Nが偶数の時、
N//10 * 1 + N//10**2 * 1 + ...の数だけ0ができる。
"""
N = int(input())
if N % 2 == 1:
    print(0)
else:
    ans = 0
    ind = 1
    while True:
        m = 5**ind
        if m > N:
            break
        r = N//m
        r //= 2
        ans += r
        ind += 1
    print(ans)

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

#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))

string youbi[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int str2int(string day){
    
    int result = -1;
    
    for(int i = 0; i < GET_ARRAY_SIZE(youbi); i++){
        if(youbi[i] == day)  result = i;
    }
    
    return result;
}


int main(void){
    // Your code here!
    
    string a;
//    cin >> a >> b;
    cin >> a;
    int dayid = str2int(a);
    
    cout << GET_ARRAY_SIZE(youbi) - dayid << endl;
    
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(& mut buf).ok();
    //let n: i32 = buf.trim().parse().ok().unwrap();
    let s: &str = buf.trim();
    let v: Vec<char> = s.chars().collect();
    let mut ans = v[0].to_digit(10).unwrap();
    if v[0] < v[1] {
        ans = v[0].to_digit(10).unwrap() + 1;
    }
    else if v[0] == v[1] {
        if v[1] < v[2] {
            ans = v[1].to_digit(10).unwrap() + 1;
        }
    }
    println!{"{}{}{}", ans, ans, ans};
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    vector<vector<int>> A;
    vector<int> B;
    rep(i, 0, M){
        int temp;
        cin >> temp;
        B.push_back(temp);
    }
    rep(i, 0, N){
        vector<int> tmpV;
        rep(ii, 0, M){
            int tmp;
            cin >> tmp;
            tmpV.push_back(tmp);
        }
        A.push_back(tmpV);
    }
    int cnt = 0;
    rep(i, 0, N){
        int sum = 0;
        rep(ii, 0, M){
            sum += A[i][ii] * B[ii];
        }
        if (sum > (C * -1)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
H=[int(input()) for _ in range(n)]
r=10**10
l=0
while r-l>1:
    k=(l+r)//2
    if sum( max(0,(h-k*b-1)//(a-b)+1) for h in H)>k:
        l=k
    else:
        r=k

print(r)

Measured memory_bytes: 52824
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


N = int(input())
s = list(input())

num_w = 0
for i in range(N):
    if s[i] == 'W':
        num_w += 1
num_r = N - num_w
# print(num_w, num_r)

# [解法]
# 例えば N = 4, s = WWRR を考える
# 条件を見たす並べ方は、
# RRRR, RRRW, RRWW, RWWW, WWWW
# の N+1 通り存在する
# ここで、以下のような N+1 通りの区切り d を考える
# d: 0   1   2   3   4
# i: | 0 | 1 | 2 | 3 |
# s: | W | W | R | R |
# すると、達成したいことは
# d より左側にある W の数 num_w_before_d を 0 にして、
# d より右側にある R の数 num_r_after_d を 0 にすることである
# これを達成するには、少なくとも max(num_w_before_d, num_r_after_d) の手数がかかる
# 従って、N+1 通りの d に対して max(num_w_before_d, num_r_after_d) を計算し、
# それらの最小値を求めれば良い


def count_w_before_d(num_w_before_d, d):
    if d == 0:
        return 0
    if s[d-1] == 'W':
        num_w_before_d += 1
    return num_w_before_d


def count_r_after_d(num_r_after_d, d):
    if d == 0:
        return num_r
    if s[d-1] == 'R':
        num_r_after_d -= 1
    return num_r_after_d

ans = INF
num_w_before_d = 0
num_r_after_d = num_r
for d in range(N+1):
    num_w_before_d = count_w_before_d(num_w_before_d, d)
    num_r_after_d = count_r_after_d(num_r_after_d, d)
    ans = min(ans, max(num_w_before_d, num_r_after_d))

print(ans)


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

using namespace std;

typedef long long ll;

map<pair<int, int>, int> kek;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll h, w;
    int n;
    cin >> h >> w >> n;
    vector<int> k(10);
    vector<int> dir = { 0, -1, 1 };
    set<pair<int, int>> topkek;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        ++kek[{a, b}];
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (a + dir[j] < 2 || a + dir[j] > h - 1 || b + dir[k] < 2 || b + dir[k] > w - 1) {
                    continue;
                }
                topkek.insert({a + dir[j], b + dir[k]});
            }
        }
    }
    ll zero = (h - 2) * (w - 2) - topkek.size();
    for (auto p : topkek) {
        int t = 0;
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                t += kek.count({p.first + dir[j], p.second + dir[k]});
            }
        }
        ++k[t];
    }
    cout << zero << '\n';
    for (int i = 1; i < 10; ++i) {
        cout << k[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 48768
S=input()
N=len(S)+1
l=[0]*N
for i in range(N-1):
    if S[i]=="<":
        l[i+1]=l[i]+1
for i in range(N-2,-1,-1):
    if S[i]==">":
        l[i]=max(l[i+1]+1,l[i])
print(sum(l))

Measured memory_bytes: 23336
#include<bits/stdc++.h>
typedef long long int ll;
typedef long long unsigned int llu;
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define YUGEN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lp(i,start,end) for(int i=start;i<end;i++)
#define MAX 105
#define test() ll t; cin>>t; while(t--)
using namespace std;
ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}
int main()
 {
    YUGEN;
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll m = *max_element(a,a+n);
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<ans;







 }


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

int main() {
  int n;
  cin >> n;
  vector<P> xy(n);
  rep(i, n) cin >> xy[i].first >> xy[i].second;

  auto dist = [&](int i, int j) {
    double dx = xy[i].first - xy[j].first;
    double dy = xy[i].second - xy[j].second;
    return sqrt(dx * dx + dy * dy);
  };

  vector<int> p(n);
  rep(i, n) p[i] = i;
  double len = 0;
  int cnt = 0;
  do {
    rep(i, n - 1) { len += dist(p[i], p[i + 1]); }
    cnt++;
  } while (next_permutation(p.begin(), p.end()));

  printf("%.10f\n", len / cnt);
  return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}
int main() {
	ll N, X;


	cin >> N >> X;

	if (N < X) {

		cout << 0 << endl;
	}
	else {

		cout << 10 << endl;
	}


	return 0;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int cnt = 0;

    int m = max(a,max(b,c));
    int s = a + b + c;

    if(3 * m % 2 == s % 2) cnt = (3 * m - s) / 2;
    if(3 * m % 2 != s % 2) cnt = (3 * m + 3 - s) / 2;
    
    cout << cnt << endl;
}
 


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    int N = in.read<int>();

    std::vector<std::pair<int, int>> A(N);
    for (int i : boost::irange(0, N)) {
        A[i] = std::make_pair(i, in.read<int>());
    }
    std::sort(A.begin(), A.end(), [](auto& l, auto& r) { return l.second < r.second; });

    for (auto x : A) {
        std::cout << x.first + 1 << " ";
    }

    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
template<class T> int gmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class T> int gmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
using namespace std;

const int MAXN = 2e5 + 5;
int a[MAXN];
int b[MAXN];
int main() {
    int n;
    while(~scanf("%d", &n)) {
        // memset(b, 0, sizeof(b))
        for(int i = 1; i <= n; ++i) {
            scanf("%d", &a[i]);
        }

        for(int i = n; i >= 1; --i) {
            int sum = 0;
            for(int j = 2 * i; j <= n; j += i) {
                sum += b[j];
            }
            sum %= 2;
            b[i] = sum ^ a[i];
        }
        
        vector<int> result;

        for(int i = 1; i <= n; ++i) {
            if(b[i]) {
                result.push_back(i);
            }
        }

        printf("%d\n", (int)result.size());
        if(!result.empty()) {
            for(int i = 0, len = result.size(); i < len; ++i) {
                if(i) printf(" ");
                printf("%d", result[i]);
            }
            printf("\n");
        }


    }
    return 0;
}

Measured memory_bytes: 3064
K,N=map(int,input().split())
A=[int(e) for e in input().split()]
dis=[]
for i in range(N):
    if i==N-1:
        dis.append(K-A[i]+A[0])
    else:
        dis.append(A[i+1]-A[i])
dis.sort()
ans=0
for i in range(N-1):
    ans+=dis[i]
print(ans)

Measured memory_bytes: 26420
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  int n;
  cin>>n;
  int arr[n];
  rep(i,n)cin>>arr[i];
  int ans=LLONG_MAX;
  repre(i,1,100)
  {
    int sum=0;
    rep(j,n)
    {
      int diff=i-arr[j];
      sum+=diff*diff;
    }
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

//                                          mdsaqib
signed main(){
    fast;
    string s,t;
    cin >> s >> t;
    int n=s.size();
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]!=t[i])ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3792
acgt = ['A', 'C', 'G', 'T']

def count(s):
	max = 0
	cnt = 0
	for i in range(0, len(s)):
		if s[i] in acgt:
			cnt += 1
		else:
			cnt = 0
		if cnt > max:
			max = cnt
	return max

print count(raw_input())

Measured memory_bytes: 2568
# ALDS1 : Binary Search

def binary_search(S,t,imin,imax):
    if imin>imax:
        return 0
    else:
        imid = imin + (imax - imin)/2
        if S[imid] > t:
            return binary_search(S,t,imin,imid-1)
        elif S[imid]<t:
            return binary_search(S,t,imid+1,imax)
        else:
            return 1

def main():
    n = input()
    S = map(int,raw_input().split())
    q = input()
    T = map(int,raw_input().split())
    ans = 0
    for t in T:
        ans += binary_search(S,t,0,len(S))
    print ans

if __name__ == '__main__':
    main()

Measured memory_bytes: 14884
import java.util.Scanner;

public class Main {

static class QuickUnionUF {

    private int[] id;
    private int[] sz;

    QuickUnionUF(int N) {
        id = new int[N];
        sz = new int[N];
        for (int i = 0; i < N; i++) {
            id[i] = i;
            sz[i] = 0;
        }
    }

    private int root(int i) {
        while (i != id[i]){
            id[i] = id[id[i]]; // Path Compression: node points to grandparent
            i = id[i];
        }
        return i;
    }

    void union(int p, int q) {
        int i = root(p);
        int j = root(q);

        if (i == j) return;
        if (sz[i] < sz[j]){
            id[i] = j;
            sz[j] += sz[i];
        }
        else {
            id[j] = i;
            sz[i] += sz[j];
        }
    }

    boolean connected(int p, int q) {
        return root(p) == root(q);
    }
}



    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();
//        QuickFindUF uf = new QuickFindUF(N);
        QuickUnionUF uf = new QuickUnionUF(N);

        // input
        for (int i = 0; i < M; i++) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            uf.union(p, q);
        }

        // Query
        int Q = scanner.nextInt();
        for (int i = 0; i < Q; i++) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            if (uf.connected(p,q))
                System.out.print("yes\n");
            else
                System.out.print("no\n");
        }
    }
}

Measured memory_bytes: 105536
def gcd(a , b):
    r = a%b
    while r:
        a=b
        b=r
        r=a%b
    return b

N=int(input())
A=list(map(int,input().split()))
L=[0]*100000
R=[0]*100000
L[0]=A[0]
for i in range(N-1):
    L[i+1]=gcd(L[i],A[i+1])
R[N-1]=A[N-1]
for i in reversed(range(N-1)):
    R[i]=gcd(R[i+1],A[i])
Ans=max(L[N-2],R[1])
for i in range(1,N-1):
    Ans=max(Ans,gcd(L[i-1],R[i+1]))
print(Ans)

Measured memory_bytes: 14400
#include<iostream>
#include<set>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
    int A,B,K;set<int> S;
int main(){
    cin>>A>>B>>K;
    REP(i,K){
        if(A+i<=B)S.insert(A+i);
        if(A<=B-i)S.insert(B-i);
    }
    for(auto x:S)cout<<x<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
	fastio();
	int n,c;
	cin>>n>>c;
	int x[n],v[n];
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>v[i];
	}
	int fm[n];
	int bm[n];
	int totc=0;
	int ma=0;
	for(int i=0;i<n;i++)
	{	
		totc+=v[i];
		fm[i]=max(ma,totc-x[i]);
		ma=fm[i];
	}
	totc=0;
	ma=0;
	for(int i=n-1;i>=0;i--)
	{
		totc+=v[i];
		bm[i]=max(ma,totc-(c-x[i]));
		ma=bm[i];
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans=max(ans,fm[i]);
		ans=max(ans,bm[i]);
	}
	for(int i=0;i<n-1;i++)
	{
		ans=max(ans,fm[i]-x[i]+bm[i+1]);
	}
	for(int i=n-1;i>0;i--)
	{
		ans=max(ans,bm[i]-(c-x[i])+fm[i-1]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3456
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
    char[] c = in.next().toCharArray();
    char[] eq = {'0', '1'};
    int o = 0, z = 0;
    for (int i = 0; i < c.length; i++)
    {
      if (c[i] != eq[i%2]) o++;
      else z++;
    }
    int ans = (int)(Math.min(o, z));
    System.out.println(ans);
  }
}

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

#define int long long

signed main(void){
    int n,k; cin >> n >> k;

    vector<double>kitai(n,0);
    for(int i=0;i<n;i++){
        int p; cin >>p;
        kitai[i] = p*(p+1)/double(2*p);
        // cout << kitai[i] << ' ';
    }
    // cout << endl;
    double ans = 0;
    // for(int i=0;i<n-k+1;i++){
    //     double tmp=0;
    //     for(int j=0;j<k;j++){
    //         tmp += kitai[i+j];
    //         // cout << tmp << ' ';
    //     }
    //     // cout << endl;
    //     if( ans < tmp)ans = tmp;
    //     // cout << ans << endl;
    // }
    for(int i=0;i<k;i++){
        ans += kitai[i];
    }
    double tmp = ans;
    for(int i=0;i<n-k;i++){
        tmp = tmp - kitai[i] + kitai[k+i];
        if(ans < tmp )ans = tmp;
    }
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MAXM=2*MAXN-1;

int n,m;
int x[MAXM];

bool ok(int q) {
	int at=(m-1)/2,l=at,r=at;
	while(l-1>=0&&(x[l-1]>=q)!=(x[l]>=q)) --l; int zl=x[l]>=q?1:0;
	while(r+1< m&&(x[r+1]>=q)!=(x[r]>=q)) ++r; int zr=x[r]>=q?1:0;
	// at the bottom, we have an alternating sequence from l..r, and l==0 or z[l-1]==z[l], and r==m-1 or z[r+1]==z[r]
	while(true) {
		if(l==at) return zl==1;
		if(r==at) return zr==1;
		++l,--r;
	}
}

void run() {
	scanf("%d",&n); m=2*n-1; REP(i,m) scanf("%d",&x[i]);
	int l=1,h=m+1;
	while(l+1<h) {
		int mid=l+(h-l)/2;
		if(ok(mid)) l=mid; else h=mid;
	}
	printf("%d\n",l);
}

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


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std ;
#define data_type int
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str[3];
    vector<int> cont(3,0);
    cin>>str[0]>>str[1]>>str[2];
    char ch='a';
    while(str[ch-'a'][cont[ch-'a']])
        ch=str[ch-'a'][cont[ch-'a']++];
    cout<<(char)(ch-32)<<endl;

    return 0;
}



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

int main() {
  int n;
  cin >>n;
  vector<int> v(n);
  for(int i=0; i<n;i++){
    cin >> v.at(i);
  }
  int ans = 1;
  int mymin=v.at(0);
  for(int i=0; i<n-1;i++){
   if (mymin>=v.at(i+1)){
     ans ++ ;
     //cout << i+1<<endl;
   }
     mymin = min(mymin,v.at(i+1));
   // cout <<mymin<<endl;
  }
  cout << ans;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
from collections import defaultdict

def solve(N: int, S: "List[str]"):
    d = defaultdict(int)
    cnt_common = 0
    commons = []

    for s in S:
        d[s] += 1
        if cnt_common < d[s]:
            cnt_common=d[s]
            commons = [s]
        elif cnt_common == d[s]:
            commons.append(s)

    return '\n'.join(sorted(commons))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    print(solve(N, S))

if __name__ == '__main__':
    main()


Measured memory_bytes: 36772
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[2 * N];
		for(int i = 0; i < 2 * N; i++) {
			L[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(L);
		int sum = 0;
		for(int i = 0; i < 2 * N; i += 2) {
			sum += L[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,D;
    cin >> N >> D;
    vector<int64_t> x(N);
    vector<int64_t> y(N);
    int i;
    for(i=0;i<N;i++){
        cin >> x.at(i) >> y.at(i);
    }

    double dis;
    int count = 0;
    for(i=0;i<N;i++){
        int64_t a = x.at(i) * x.at(i) + y.at(i) * y.at(i);
        dis = sqrt(a);
        if(dis <= (double)D){
            count ++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 6424
n = int(input())
aa = list(map(int, input().split()))
dic = {0: 0}
for a in aa:
    dic[a] = dic.get(a, 0) + 1

total = 0
for _, v in dic.items():
    total += (v * (v - 1)) // 2

for i in range(n):
    v = dic[aa[i]]
    x = total - (v * (v - 1)) // 2
    x += ((v - 1) * (v - 2)) // 2
    print(x)


Measured memory_bytes: 26140
//
// tested with : g++ (GCC) 8.3.0
//

#include <iostream>
using namespace std;

//与えられた数字の分割回数を返す。
int devide_count(int num) {
    int count = 0;
    while (true) {
        if ((num % 2) == 0) {
            num /= 2;
            count++;
        }
        else {
            return count;
        }
    }
}
int main() {
    int N;
    cin >> N;

    int count = 0;//今回の分割回数。
    int champcount = 0;//過去最高の分割回数。
    int champnum = 1;//チャンピオンの番号

    //総当たりして一番割り切れた数が多いものを比較保持。
    for (int i = 1; i <= N; i++) {
        count = devide_count(i);//今回の分割回数を受け取る。
        if (count > champcount ) {
            champcount = count;
            champnum = i;
        }
    }

    cout << champnum << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b;
	cin >> a >> b;
	int m;
	m = max(a + b,a - b);
	m = max(m, a * b);
	cout << m << endl;
}

Measured memory_bytes: 3540
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    auto AS = readln.split.to!(int[]);
    auto BS = readln.split.to!(int[]);
    auto CS = new int[](N*M+1);
    foreach (a; AS) {
        if (CS[a] == 1) {
            writeln(0);
            return;
        }
        CS[a] = 1;
    }
    foreach (b; BS) {
        if (CS[b] >= 2) {
            writeln(0);
            return;
        }
        CS[b] += 2;
    }
    auto DS = new long[](N*M+1);
    auto ES = new long[](N*M+1);
    foreach_reverse (i; 1..N*M+1) {
        DS[i-1] += DS[i] + (CS[i]&1 ? 1 : 0);
        ES[i-1] += ES[i] + (CS[i]&2 ? 1 : 0);
    }

    long r = 1;
    foreach_reverse (x; 1..N*M+1) {
        switch (CS[x]) {
            case 2:
                r = r * DS[x] % P;
                break;
            case 1:
                r = r * ES[x] % P;
                break;
            case 0:
                r = r * (DS[x] * ES[x] - (N*M-x)) % P;
                break;
            default:
        }
    }
    writeln(max(0, r));
}

Measured memory_bytes: 23036
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <string>
#include <bitset>
#include <math.h>
#include <vector>
#include <set>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;

using namespace std;

int main(){
    int N, T, A;
    cin >> N >> T >> A;
    vector<double> H(N);

    for(int i = 0; i < N; i++){
        cin >> H[i];
        H[i] = T - H[i] * 0.006;
        H[i] = fabs(H[i] - A);
    }

    vector<double>::iterator iter = min_element(H.begin(), H.end());

    cout << distance(H.begin(), iter) + 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
	int key;
	struct node *parent,*left,*right;
}Node;

Node *root,*NIL;

void insert(int k);
void find(int k);
void inOrder(Node *x);
void preOrder(Node *x);

int main(){
	int i,n,x;	scanf("%d",&n);
	char com[10];

	for(i=0;i<n;i++){
		scanf("%s",com);
		if(com[0]=='i'){
			scanf("%d",&x);
			insert(x);

		}else if(com[0]=='p'){
			inOrder(root);
			printf("\n");
			preOrder(root);
			printf("\n");
		}else{
			scanf("%d",&x);
			find(x);
		}
	}

	return 0;
}

void insert(int k){
	Node *y=NIL, *x=root, *z;

	z=(Node*)malloc(sizeof(Node));

	z->key=k;	z->left=NIL;	z->right=NIL;

	while(x!=NIL){
		y=x;
		if(k < x->key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	z->parent=y;

	if(y==NIL)root=z;
	else{
		if(k < y->key){
			y->left = z;
		}else{
			y->right=z;
		}
	}
}

void find(int k){
	Node* p=root;

	while(p!=NIL){
		if(p->key==k){
			printf("yes\n");
			return;
		}

		if(k < p->key)p=p->left;
		else p=p->right;
	}



	printf("no\n");
	return;
}

void inOrder(Node* x){
	if(x==NIL)return;
	inOrder(x->left);
	printf(" %d",x->key);
	inOrder(x->right);
}
void preOrder(Node* x){
	if(x==NIL)return;
	printf(" %d",x->key);
	preOrder(x->left);
	preOrder(x->right);
}



Measured memory_bytes: 20444
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N, C = map(int, input().split())
sushis = [list(map(int, input().split())) for _ in range(N)]

# Aを時計回り,Bを反時計回りとする
# O->Aと0->A->Oのコストを計算
valA = []
valArev = []
sumV = 0
tmpMax = -float('inf')

for d, v in sushis:
    sumV += v
    valArev.append(sumV-2*d)
    tmpMax = max(tmpMax, sumV-d)
    valA.append(tmpMax)

valB = []
valBrev = []
sumV = 0
tmpMax = -float('inf')
for d, v in reversed(sushis):
    sumV += v
    revD = C-d
    valBrev.append(sumV-2*revD)
    tmpMax = max(tmpMax, sumV-revD)
    valB.append(tmpMax)


# 折り返しなしの場合の値
ans = max(valA+valB+[0])
# O->A->O->B
for i in range(N-1):
    ans = max(ans, valArev[i]+valB[N-i-2])

# O->B->O->A
for i in range(N-1):
    ans = max(ans, valBrev[i]+valA[N-i-2])
print(ans)


Measured memory_bytes: 46716
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long>A(N),B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	long result = 0;
	for (int i = N-1; i > -1; i--) {
		if ((result + A[i]) % B[i] != 0) {
			result += B[i] - (result + A[i]) % B[i];
		}
	}
	cout << result << endl;
}

Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<algorithm>

using namespace std;
using ll = long long;

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

	int A = 0;

	for (int i = 0; i < 3; i++) {
		if (S[i] == 'o') {
			A++;
		}
	}

	cout << 700 + 100 * A << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 200000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;

typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll N;

int main() {
	cin >> N;
	ll tmp = 1000000000000;
	for (ll i = 1; i*i <= N; i++)
	{
		if (N % i == 0) {
			tmp = min(tmp, N / i);
		}
	}
	cout << tmp + N / tmp - 2 << endl;
}

Measured memory_bytes: 3636
N,K = map(int,input().split())
As = list(map(int,input().split()))
towns = [0]*N
route = [0]
pre = 0
i = 0
towns[0] = 1
for _ in range(K):
    i = As[i]-1
    if towns[i]>0:
        pre = route.index(i)
        route = route[pre:]
        break
    route.append(i)
    towns[i] = 1
mod = len(route)
print(route[(K-pre)%mod]+1)


Measured memory_bytes: 32376
n = int(input())
s = [input() for i in range(n)]

ab = 0
ba = 0
c2 = 0
c3 = 0
for x in s:
    if 'AB' in x:
        ab += x.count('AB')    
    if x[-1] == 'A' and x[0] == 'B':
        ba += 1
    if x[-1] == 'A' and x[0] != 'B':
        c2 += 1
    if x[-1] != 'A' and x[0] == 'B':
        c3 += 1
if ba > 0:
    if c2 + c3 > 0:
        ans = ab + ba + min(c2, c3)
    else: # c2 = c3 =0
        ans = ab + ba - 1
else:
    ans = ab + min(c2, c3)
print(ans)

Measured memory_bytes: 9516
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int k = sc.nextInt();

		int count = 0;

		int flag = 0;

		for (int i = 0; i < s.length ;i++) {
			//count =  ((s[i] - 'a') % 26 + 'a');

			if (s[i] == 'a') {
				continue;
			}

			count = 26 - (s[i] - 'a');

			if (count <= k) {
				s[i] = 'a';
				k = k - count;
				flag = 1;
			}

		//	System.out.println(count);
		}


		if (k > 0) {

			if (k >= 26 && flag == 1) {
				k = k%26;
			}

			s[s.length -1] = (char) ((s[s.length -1] - 'a' + k) % 26 + 'a');
		}

		for (int i = 0; i < s.length ;i++) {
			System.out.print(s[i]);
		}



		System.out.println("");

		sc.close();
	}
}


Measured memory_bytes: 23640
from heapq import *
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = [-i for i in a]
heapify(a)
for i in range(m):
    minimum = heappop(a)
    minimum /= 2
    #print(minimum)
    heappush(a,minimum)

ans = 0
for i in a:
    ans += int(i)

print(-ans)

Measured memory_bytes: 93336
#include<stdio.h>

int insertionSort(int A[], int n, int g)
{
	int i,j,v,k,c;
	
	c=0;
	
	for(i=g; i<n; i++)
	{
		v=A[i];
		j=i-g;
		
		while(j>=0 && A[j]>v)
		{
			A[j+g]=A[j];
			
			j=j-g;
			c++;
		}
	
		A[j+g]=v;
	}
	
	return c;
	
}

void shellSort(int A[], int n)
{
	int c,t,k;
	c=0;
	
	int i,j;
	
	int G[100];
	G[0]=1;
	for(j=0; G[j]<=n; j++)
	{
		G[j+1]=3*G[j]+1;
	}
	
	for(i=j-1; i>=0; i--)
	{
		c = c+insertionSort(A, n, G[i]);
	}
	
	printf("%d\n",j);
	
	for(t=j-1; t>=0; t--)
	{
		printf("%d",G[t]);
		
		if(t > 0)
		{
			printf(" ");
		}
	}
		
		printf("\n");
	
	printf("%d\n",c);
	
	for(k=0; k<n; k++)
	{
		printf("%d",A[k]);
		
		if(k<n-1)
		{
			printf("\n");
		}
	}
		
	
}

int main(void)
{
	int n,i;
	
	scanf("%d",&n);
	
	int A[n];
	for(i=0; i<n; i++)
	{
		scanf("%d",&A[i]);
	}
	
	shellSort(A,n);
	
	return 0;
}




Measured memory_bytes: 6660
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy";
  }
  else if(s=="Cloudy"){
    cout<<"Rainy";
  }
  else if(s=="Rainy"){
    cout<<"Sunny";
  }
  else{
    return 0;
  }
  return 0;
}


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

const double eps=1.0e-9;

vector<double> solve(double a,double b,double c){
	double d=b*b-4.0*a*c;
	vector<double> result;
	if(d>eps){
		double dd=sqrt(d);
		double ans1=(-b+dd)/(2.0*a);
		if(ans1>eps) result.pb(ans1);
		double ans2=(-b-dd)/(2.0*a);
		if(ans2>eps) result.pb(ans2);
	}else if(abs(d)<eps){
		double ans=-b/(2.0*a);
		if(ans>eps) result.pb(ans);
	}
	return result;
}

double x[210],y[210],z[210],r[210];
double vx[210],vy[210],vz[210],vr[210];


typedef tuple<double,int,int> state;

int main(void){
	int n;
	while(cin >>n,n){
		vector<state> del;
		rep(i,n){
			cin >> x[i] >> y[i] >> z[i];
			cin >> vx[i] >> vy[i] >> vz[i];
			cin >> r[i] >> vr[i];
		}
		rep(i,n){
			double t=1.0*r[i]/vr[i];
			del.pb(state(t,i,i));
		}
		rep(i,n)rep(j,n){
			if(i>=j) continue;
			double a=0.0,b=0.0,c=0.0;

			// x
			c+=(x[i]-x[j])*(x[i]-x[j]);
			b+=2.0*(x[i]-x[j])*(vx[i]-vx[j]);
			a+=(vx[i]-vx[j])*(vx[i]-vx[j]);

			// y
			c+=(y[i]-y[j])*(y[i]-y[j]);
			b+=2.0*(y[i]-y[j])*(vy[i]-vy[j]);
			a+=(vy[i]-vy[j])*(vy[i]-vy[j]);

			// z
			c+=(z[i]-z[j])*(z[i]-z[j]);
			b+=2.0*(z[i]-z[j])*(vz[i]-vz[j]);
			a+=(vz[i]-vz[j])*(vz[i]-vz[j]);

			// r
			c-=(r[i]+r[j])*(r[i]+r[j]);
			b-=-2.0*(r[i]+r[j])*(vr[i]+vr[j]);
			a-=(vr[i]+vr[j])*(vr[i]+vr[j]);
			vector<double> res=solve(a,b,c);
			rep(k,res.size()){
				del.push_back(state(res[k],i,j));
				del.push_back(state(res[k],i,j));
			}
		}
		sort(del.begin(),del.end());
		double ans[210];
		rep(i,210) ans[i]=-1.0;
		for(auto &record:del){
			double t;int i,j;
			tie(t,i,j)=record;
			if(t<0.0) continue;
			if(ans[i]==-1.0&&ans[j]==-1.0) ans[i]=t,ans[j]=t;
		}
		cout.precision(10);
		rep(i,n) cout << fixed << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3024
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;

using namespace std;


int main(int argc, char* argv[])
{
    int R,G,B,N;
    scanf("%d%d%d%d", &R, &G, &B, &N);

    int cnt=0;
    int i,j;
    for(i=0; i<=3000; i++) {
        int num = N-R*i;
        for(j=0; j<=3000; j++) {
            int tmp = num - (j*G);
            if(tmp%B==0) {
                if(tmp>=0) cnt++;
            }
        }
    }

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

    return 0;
}



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

int main() {

	int n, k; cin >> n >> k;
	string s; cin >> s;
	char tmp = s[k - 1];
	s[k - 1] = (tmp - 'A') + 'a';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 5050;
int N, K;
int a[MAX];
bool dp[MAX][MAX];
int abuf[MAX];

bool check(const int limit) {
    if (limit < 0) {
        return false;
    }
    memset(dp, false, sizeof(dp));
    dp[0][0] = true;
    REP(i, N) {
        REP(j, K) {
            if (abuf[i] + j <= K) {
                dp[i + 1][abuf[i] + j] |= dp[i][j];
            }
            dp[i + 1][j] |= dp[i][j];
        }
    }
    FOR(i, limit, K + (limit == 0)) if (dp[N][i]) {
        return false;
    }
    return true;
}

int main(void) {
    scanf("%d%d", &N, &K);
    a[0] = 0;
    REP(i, N) {
        scanf("%d", a + i + 1);
    }
    sort(a, a + N + 1);
    if (accumulate(a, a + N + 1, 0ll) < K) {
        cout << N << endl;
        return 0;
    }
    int low = 0, high = N;
    while (high - low > 1) {
        const int mid = (high + low) / 2;
        //DEBUG(mid)
        int id = 0;
        REP(i, N + 1) if (i != mid) {
            abuf[id++] = a[i];
        }
        (check(K - a[mid]) ? low : high) = mid;
    }
    cout << low << endl;
}


Measured memory_bytes: 25216
# -*- coding: utf-8 -*-
# @Date    : 2019-06-15 20:02:29
# @Author  : raj lath (oorja.halt@gmail.com)
# @Link    : link
# @Version : 1.0.0

import sys
sys.setrecursionlimit(10**5+1)

inf     =  int(10 ** 20)
max_val =  inf
min_val = -inf

RW  = lambda : sys.stdin.readline().strip()
RI  = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
from collections import defaultdict

nb_points = RI()
points    = [RMI() for _ in range(nb_points)]
if nb_points == 1:
    print(1)
else:
    pq = defaultdict(int)
    for i in range(nb_points):
        for j in range(nb_points):
            if i == j : continue
            p1 = points[i][0] - points[j][0]
            q1 = points[i][1] - points[j][1]
            pq[(p1, q1)]  = pq.get((p1, q1), 0) + 1
    print(nb_points - max(pq.values()))


Measured memory_bytes: 3824
#include<stdio.h>
int main()
{
    int a[13],n,sum=0,s=0,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
        if(a[i]>s)
        s=a[i];
        
    }
    sum=sum-s;
    if(sum>s)
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}



Measured memory_bytes: 1656
#include <stdio.h>          // printf(), getc()
#include <string.h>         // memcpy(), strstr()

#define MAX_L 100
const char NUL = '\0';

int
main(int argc, char** argv)
{
	char s[2 * MAX_L + 1];
	char t[MAX_L + 1];
	int len1, len2;
	int c;

	c = getc(stdin);
	len1 = 0;
	while (c != '\n' && c != EOF)
	{
		s[len1++] = c;
		c = getc(stdin);
	}

	c = getc(stdin);
	len2 = 0;
	while (c != '\n' && c != EOF)
	{
		t[len2++] = c;
		c = getc(stdin);
	}

	t[len2] = NUL;
	memcpy(&s[len1], s, len2);
	s[len1 + len2] = NUL;

	if (strstr(s, t) != NULL)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

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


void solve(long long N, long long L, std::vector<std::string> S){
    sort(S.begin(), S.end());
    for (auto& s : S) {
	cout << s;
    }
    cout << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, L, std::move(S));
    return 0;
}


Measured memory_bytes: 256
/**
 *    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;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int cnt=0;
    while(b<=a) b*=2,cnt++;
    while(c<=b) c*=2,cnt++;
    cout<<(cnt<=k?"Yes":"No");
    return 0;
}


Measured memory_bytes: 3648