akhauriyash/Code-Regression huggingface dataset:
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""

N,M=map(int,input().split())
LRD=[list(map(int,input().split())) for i in range(M)]

data=[[] for i in range(N+1)]
for m,(l,r,d) in enumerate(LRD):
    data[l].append([r,d,m])
    data[r].append([l,-d,m])
data2=[set([m[1] for m in data[i]]) for i in range(N+1)]
Nlst=set([i for i in range(1,N)])
Mlst=set([i for i in range(M)])
visited=set()
X=[0 for i in range(N+1)]
while Mlst:
    stack=[Nlst.pop()]
    while stack:
        l=stack.pop()
        visited.add(l)
        for r,d,m in data[l]:
            if m in Mlst:
                Mlst.remove(m)
                if not r in visited:
                    visited.add(r)
                    X[r]=X[l]+d
                    stack.append(r)

                else:
                    if X[r]!=X[l]+d:
                        print("No")
                        exit()

print("Yes")


Measured memory_bytes: 155212
n=int(input())
lst=list(map(int,input().split()))
dp=[0 for i in range(n)]
dp[1]=abs(lst[0]-lst[1])
for i in range(2,len(lst)):
  dp[i]=min(dp[i-1]+abs(lst[i]-lst[i-1]),dp[i-2]+abs(lst[i]-lst[i-2]))
print(dp[n-1])


Measured memory_bytes: 20448
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep1(i,n) for(int i=1;i<(int)(n)+1;i++)
#define vec vector
typedef int64_t intl;
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
vec<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};



int main(){
 intl N,K;
  cin >> N>>K;
  if ( N%K >= K - N%K ) {cout << K-N%K;}
  else{cout <<N%K;}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int ID;
struct file{
  string name;
  bool dir;
  int id;
  map<string, file> sub;
  file* parent;
  file() {}
  file(string name, bool dir, file* par) : dir(dir), parent(par), name(name) {
    if(dir) id = -8;
    else id = ID++;
  }
  file* make(string name, bool d){
    //printf("%s make %s\n", this->name.c_str(), name.c_str());
    sub[name] = file(name, d, (d) ? this : NULL);
    return &(sub[name]);
  }
};

vector<string> make_path(string s){
  bool f = (s[s.size() - 1] == '/');
  REP(i, s.size()) if(s[i] == '/') s[i] = ' ';
  stringstream ss(s);
  vector<string> path;
  while(ss>>s) path.push_back(s);
  if(f) path.push_back(".");
  return path;
}

int get_file(vector<string> path, file* cur){
  //cout<<"get_file"<<endl;
  REP(i, path.size()){
    if(path[i] == "."){
      if(!cur->dir) return -1;
    }else if(path[i] == ".."){
      if(!cur->dir) return -1;
      cur = cur->parent;
      if(!cur) return -3;
    }else if(!cur->sub.count(path[i])){
      //cout<<"not found "<<path[i]<<endl;
      return -1;
    }else{
      cur = &(cur->sub[path[i]]);
    }
    //cout<<cur->name<<endl;
  }
  if(cur->dir){
    if(cur->sub.count("index.html")){
      cur = &(cur->sub["index.html"]);
    }else{
      //cout<<"not found "<<"index.html"<<endl;
      return -2;
    }
  }
  return cur->id;
}

int main(){
  int N, M;
  while(cin>>N>>M && N){
    ID = 0;
    file root("root", true, NULL);
    REP(i, N){
      string s; cin>>s;
      vector<string> path = make_path(s);
      file* cur = &root;
      REP(i, path.size()){
        if(cur->sub.count(path[i])){
          cur = &(cur->sub[path[i]]);
        }else{
          cur = cur->make(path[i], (i != path.size() - 1));
        }
      }
    }
    REP(i, M){
      string s1; cin>>s1;
      string s2; cin>>s2;
      vector<string> path1 = make_path(s1);
      vector<string> path2 = make_path(s2);
      int id1 = get_file(path1, &root);
      int id2 = get_file(path2, &root);
      //debug(path1.begin(), path1.end());
      //debug(path2.begin(), path2.end());
      //printf("id1 = %d id2 = %d\n", id1, id2);
      if(id1 < 0 || id2 < 0){
        cout<<"not found"<<endl;
      }else if(id1 == id2){
        cout<<"yes"<<endl;
      }else{
        cout<<"no"<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ESP 1e-5

int main(void){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while(a >= b){
	b *= 2;
	k--;
    }
    while(b >= c){
	c *= 2;
	k--;
    }
    if(k >= 0){
	cout << "Yes" << endl;
    }else{
	cout << "No" << endl;
    }
    return 0;
    
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define endl "\n"
#define ing long long
using namespace std;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e6;
#define debug(x) cout << #x << ": " << x << endl
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, P;
    vector<int> prime(MAX_N, 1);
    prime[0] = prime[1] = 0;
    for(int i = 2; i * i < MAX_N; i++)
    {
        for(int j = 2 * i; j < MAX_N; j += i) prime[j] = 0;
    }
    while(cin >> N >> P)
    {
        if(N == -1 and P == -1) break;
        vector<int> num;
        for(int i = N + 1; i < MAX_N; i++) if(prime[i]) num.push_back(i);
        vector<int> L;
        for(int i = 0; i < 100; i++)
        {
            for(int j = i; j < 100; j++) L.push_back(num[i] + num[j]);
        }
        sort(L.begin(), L.end());
        cout << L[P - 1] << endl;
    }
    return 0;
}



Measured memory_bytes: 7568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B,C,K;
    cin >>A>>B>>C>>K;
    ll ans = 0;

    if(K>A){
        ans +=A;
    }else{
        ans=K;
        cout<<ans<<endl;
        return 0;
    }

    if(K>=A+B){
        ans -= K-A-B;
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3532
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long LL;
const int LEN = 2e5 + 10;
LL n, k, nums[LEN], L, R;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }
    sort(nums, nums + n);
    L = -1e18, R = 1e18;
    while (L + 1 != R) {
        LL Mid = (L + R) / 2;
        LL cnt = 0;
        for (int i = 0; i < n; i++) {
            if (nums[i] < 0) {
                int l = i, r = n;
                while (l + 1 != r) {
                    int mid = (l + r) / 2;
                    if (nums[i] * nums[mid] <= Mid) {
                        r = mid;
                    } else {
                        l = mid;
                    }
                }
                cnt += n - r;
            } else {
                int l = i, r = n;
                while (l + 1 != r) {
                    int mid = (l + r) / 2;
                    if (nums[i] * nums[mid] <= Mid) {
                        l = mid;
                    } else {
                        r = mid;
                    }
                }
                cnt += l - i;
            }
        }
        if (cnt < k) {
            L = Mid;
        } else {
            R = Mid;
        }
    }
    cout << R << endl;
    return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

// A - We Love Golf
func main() {
	var k, a, b int
	fmt.Scanf("%d", &k)
	fmt.Scanf("%d %d", &a, &b)

	ans := "NG"
	for i := a; i <= b; i++ {
		if i%k == 0 {
			ans = "OK"
			break
		}
	}
	fmt.Println(ans)
}


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

int main(){
  int m,d;
  int M[]={0,31,29,31,30,31,30,31,31,30,31,30,31};

  while(cin>>m>>d){
    if(m==0)break;
    int day=2;
    for(int i=m-1;i>0;i--){
      day+=M[i];
    }
    day+=d;
    if(day%7==0)cout<<"Monday"<<endl;
    if(day%7==1)cout<<"Tuesday"<<endl;
    if(day%7==2)cout<<"Wednesday"<<endl;
    if(day%7==3)cout<<"Thursday"<<endl;
    if(day%7==4)cout<<"Friday"<<endl;
    if(day%7==5)cout<<"Saturday"<<endl;
    if(day%7==6)cout<<"Sunday"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
vector<int> ve[5];
bool vis[5];
int dfs(int x,int y)
{
//	printf("%d %d\n",x,y);
	if(y==4)
	{
		return 1;
	}
	int i,an=0;
	for(i=0;i<ve[x].size();i++)
	{
		if(!vis[ve[x][i]])
		{
			vis[ve[x][i]]=1;
			an|=dfs(ve[x][i],y+1);
		}
	}
	return an;
}
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&x,&y);
	ve[x].push_back(y);
	ve[y].push_back(x);
	scanf("%d%d",&x,&y);
	ve[x].push_back(y);
	ve[y].push_back(x);
	scanf("%d%d",&x,&y);
	ve[x].push_back(y);
	ve[y].push_back(x);
	vis[1]=1;
	if(dfs(1,1))
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

def main():
    A, B, C, D = map(int, readline().split())
    while True:
        C -= B
        if C <= 0:
            ans = 'Yes'
            break
        A -= D
        if A <= 0:
            ans = 'No'
            break

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
n,m=map(int,input().split())
s=input().split()
t=input().split()
dp=[[1]*(m+1)]+[[1]+[0]*m for _ in range(n)]
for i in range(n):
	for j in range(m):
		dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1]-dp[i][j]*(s[i]!=t[j]))%(10**9+7)
print(dp[-1][-1])

Measured memory_bytes: 76508
#include<stdio.h>

int main(void){

int a,b,c;

int count=0;

int i;

scanf("%d %d %d",&a,&b,&c);

for(i=a;i<=b;i++){

if(c%i==0){

count++;
}


}

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

return 0;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

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

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	ll n, m;
	cin >> n >> m;

	vector<ll> dp(n + 1, -1);

	dp.at(0) = 1;

	for (int i = 0; i < m; i++)
	{
		int a;
		cin >> a;
		dp.at(a) = 0;
	}


	for (int i = 1; i <= n; i++)
	{
		if (dp.at(i) == -1)
		{
			dp.at(i) = dp.at(i - 1);
			if (i - 2 >= 0)
			{
				dp.at(i) = (dp.at(i) + dp.at(i - 2)) % mod;
			}
		}
	}

	cout << dp.at(n) % mod << endl;
}

Measured memory_bytes: 1024
import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object Main extends App {

  val max = 20000000
  val a: Array[Int] = Array.ofDim[Int](max+1)
  var h: Int = 0

  def insert(key: Int): Unit = {
    h += 1
    a(h) = Int.MinValue
    heapIncreaseKey(a, h, key)
    //println("ins :" + a.slice(0,h+1).toList.mkString(" "))

  }
  
  private def heapIncreaseKey(heap: Array[Int], i: Int, key: Int): Unit = {
    heap(i) = key
    var idx = i
    while(idx > 1 && heap(idx/2) < heap(idx)){
      swap(heap, idx, idx/2)
      idx = idx/2
    }
  }
  
  def parent(i: Int): Int = i/2
  def left(i: Int): Int   = 2*i
  def right(i: Int): Int  = 2*i+1
  
  def swap(target: Array[Int], from: Int, to: Int): Unit = {
    val temp = target(to)
    
    target(to) = target(from)
    target(from) = temp
  }

  def maxHeapify(heap: Array[Int], i: Int): Unit = {
    //val n = heap.length
    val p = parent(i)
    val l = left(i)
    val r = right(i)

    var largest = if(l <= h && heap(l) > heap(i)) l else i
    largest = if(r <= h && heap(r) > heap(largest)) r else largest

    if(i != largest){
      swap(heap, i, largest)
      maxHeapify(heap, largest)
    }
  }

  def heapExtractMax(heap: Array[Int]): Int = {
    // println("ext :" + heap.slice(0,h+1).toList.mkString(" "))
    val max = heap(1)
    heap(1) = heap(h)
    h -= 1
    maxHeapify(heap, 1)
    max
  }

  val buff = ListBuffer.empty[Int]
  
  var cmd = ""
  while(cmd != "end"){
    cmd = StdIn.readLine()
    cmd.split(' ') match {
      case Array("insert", key) => insert(key.toInt)
      case Array("extract") => 
        buff += heapExtractMax(a)
      case _ =>
    }
  }

  buff.foreach(println)
}


Measured memory_bytes: 544424
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a > b){
		printf("a > b\n");
	}else if(a == b){
		printf("a == b\n");
	}else{
		printf("a < b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int n;
map<ll,ll>mp;
ll ans;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    rep(i,n){
        ll ai;
        cin>>ai;
        mp[ai]++;
        if(mp[ai]>ai)ans++;
    }
    for(auto& it:mp){
        if(it.second<it.first)ans+=it.second;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
	ll a, b, c, d;

	cin >> a >> b >> c >> d;

	ll s1 = max(a * c, a * d);
	ll s2 = max(b * c, b * d);

	cout <<max(s1,s2);
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

int n, ans = 0;

int get(int x) {
    return (x * (x + 1)) / 2;
}

void analyze(int a, int b) {
    if (b > a) {
        ans += get(n - a);
    } else {
        ans += b * a - get(b);
    }
}

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

    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        analyze(a, b);
        analyze(b, a);
    }
    for (int i = n; i >= 1; i--) {
        ans += (i * (2 - i));
    }
    cout << ans << '\n';

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>

int main() {

    int N;
    std::cin >> N;

    int ans = 0;
    int mi = N + 1;

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

        int p; std::cin >> p;
        mi = std::min(mi, p);
        if (mi == p) ++ans;
    
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
s = int(input())
li = [s]
i = 1
while  True:
    if li[i-1]%2==0:
        li.append(int(li[i-1]/2))
    else:
        li.append(3*li[i-1]+1)

    if li[i] in li[:i]:
        break
    else:
        i += 1
print(len(li))

Measured memory_bytes: 3060
N = int(input())

'''
def mcd(a, b) :
    if (a, b) in memo.keys() :
        return memo[(a, b)]
    else :
        if max(a, b) % min(a, b) == 0 :
            return min(a, b)
        else :
            memo[(a, b)] = mcd(min(a, b), max(a, b) % min(a, b))
            return memo[(a, b)]

def lcm(a, b) :
    return int((a * b) / mcd(a, b))
'''

def gcd(x, y) :
    if y == 0 : return x
    else : return gcd(y, x % y)

h = 1

for i in range(N) :
    n = int(input())
    
    h = n * h // gcd(n, h)
    
print(h)
    

Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int x, y; std::cin >> x >> y;
	if ((y & 1) == 0 && x * 2 <= y && y <= x * 4) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}
}

Measured memory_bytes: 3604
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    float n,i;
    cin>>n;
    for(float i=1;i<=n;i++)
    {
    	float aa = floor(i * 1.08);
    	if(aa==n)
    	{
    		cout<<i;
    		return 0;
    	}
    }
    cout<<":(";
}

Measured memory_bytes: 384
// ARC 98 C

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

typedef long long ll;

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; }
const long long INF = 1LL<<60;


int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> w(n, 0); // ある地点より左にいる，西を向いている人の数
  vector<int> e(n, 0); // ある地点より右にいる，東を向いている人の数

  for (int i = 0; i < n; i++) {
    if (i > 0) {
      w[i] = w[i-1];
    }
    if (s[i] == 'W') {
      w[i] += 1;
    }
  }

  for (int i = n - 1; i >= 0; i--) {
    if (i < n - 1) {
      e[i] = e[i+1];
    }
    if (s[i] == 'E') {
      e[i] += 1;
    }
  }

  int ans = n;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      chmin(ans, e[i+1]);
    } else if (i == n - 1) {
      chmin(ans, w[i-1]);
    } else {
      chmin(ans, w[i-1] + e[i+1]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

int main() {
  ll K;
  cin >> K;

  vector<ll> ans(50, 49);
  ll Q = K / 50;
  rep(i, 50) {
    ans[i] += Q;
  }

  ll R = K % 50;
  rep(i, R) {
    rep(j, 50) {
      if (j == i)
        ans[j] += 50;
      else
        ans[j]--;
    }
  }

  cout << 50 << endl;
  rep(i, 50) {
    cout << ans[i] << ' ';
  }
  cout << endl;
}

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

string solve() {
    ll N;
    cin >> N;
    ll a = N % 10;
    if ( a == 3) return "bon";
    if ( a == 0 || a == 1 || a == 6 || a == 8 ) return "pon";
    else return "hon";
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

char a[60],b[60];
int al,bl,cnta,cntb;
bool ok=true;

int main(){
	cin>>a>>b; al=strlen(a),bl=strlen(b);
	for(int i=0;i<al+bl;i++)
		if(ok) { cout<<a[cnta]; ok=false,cnta++; }
		else { cout<<b[cntb]; ok=true,cntb++; }
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void A() {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		if(n == 0) {
			System.out.println(0);
			return;
		}
		int[] height = new int[n];
		for(int i = 0; i < n; i++) {
			height[i] = s.nextInt();
		}
		int[] dp = new int[n];
		dp[dp.length - 1] = 0;
		for(int i = dp.length - 2; i >= 0; i--) {
			dp[i] = Integer.MAX_VALUE;
			for(int j = 1; j <= 2; j++) {
				if(j + i < n) {
					dp[i] = Math.min(dp[i + j] + Math.abs(height[i] - height[i + j]), dp[i]);
				}
			}
		}
		System.out.println(dp[0]);
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		A();
	}

}


Measured memory_bytes: 49324
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int p[n];
  for (int i=0;i<n;i++){
    cin >> p[i];
  }
  int ans=0;
  for (int i=1;i<n-1;i++){
    if ((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i+1]<p[i]&&p[i]<p[i-1])){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val tl = Seq.fill(n)((sc.nextInt, sc.nextInt))

  val res = tl.foldLeft(0L){case (sum, (left, right)) =>
      sum + (right - left + 1)
  }

  println(res)
}

Measured memory_bytes: 29872
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 1e18L+5
#define mod 1000000007
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll n;
   cin>>n;
   vector<long double> dp(n+1);//prob that there are i heads so far;
   dp[0]=1;
  // for(int i=1;i<=n;i++)dp[0]=0;
   for(int i=0;i<n;i++){
       long double head;
       cin>>head;
       for(int j=i+1;j>=0;j--){
           dp[j]= (j==0 ? 0: dp[j-1]*head)+dp[j]*(1-head);
       }
   }
  long  double ans=0;
   for(int i=0;i<=n;i++){
       int t=n-i;
       if(i>t) ans+=dp[i];
   }
   cout<<setprecision(10)<<ans;
}




Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
	int N;
	int A[200];
	int res = 0;
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> A[i];
//
    while (true) {
	bool odd_flag = false;
	for (int i = 0; i < N; ++i) {
		if (A[i]%2 != 0) odd_flag = true;
		// 偶数のときはfalseのまま
	}
		if (odd_flag) break;	
	
	++res;
	for (int i = 0; i < N; ++i) A[i] /= 2 ;
}
	cout << res << endl;
}

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

int main()
{   
	long long x;
	cin >> x;
	int ans = 0;
	bool f = true;
	long long yen = 100;
	while (f) {
		ans++;
		yen += 0.01 * yen;
		if (yen >= x) {
			f = false;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3596
#include<stdio.h>
int main(void){
    while(1){
        int n;
        scanf("%d",&n);
        if(n==0) break;
        getchar();
        int left=0,right=0;
        int state=0;
        int ans=0;
        for(int i=0;i<n;i++){
            char f,s;
            scanf("%c%c",&f,&s); getchar();
            if(f=='l'&&s=='u') left=1;
            if(f=='l'&&s=='d') left=0;
            if(f=='r'&&s=='u') right=1;
            if(f=='r'&&s=='d') right=0;
            
            if(state==0&&left==1&&right==1){
                ans++; state=1;
            }
            if(state==1&&left==0&&right==0){
                ans++; state=0;
            }
        }
        printf("%d\n",ans);
    }
}



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

using namespace std;

int main(){
    int n;
    string s;
    cin>>n>>s;
    long long ans=0;
    
    vector<long long> ruisekiR(n+1,0);
    vector<long long> ruisekiG=ruisekiR;
    vector<long long> ruisekiB=ruisekiR;
    
    for(int i=1;i<=n;i++){
        ruisekiR.at(i)=ruisekiR.at(i-1);
        ruisekiG.at(i)=ruisekiG.at(i-1);
        ruisekiB.at(i)=ruisekiB.at(i-1);
        
        if(s.at(i-1)=='R') ruisekiR.at(i)++;
        if(s.at(i-1)=='G') ruisekiG.at(i)++;
        if(s.at(i-1)=='B') ruisekiB.at(i)++;
    }
    
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            if((s.at(i)=='R' && s.at(j)=='G') || (s.at(i)=='G' && s.at(j)=='R')){//B
                ans+=ruisekiB.at(n)-ruisekiB.at(j+1);
                if(j+j-i<n && s.at(j+j-i)=='B') ans--;
            }else if((s.at(i)=='R' && s.at(j)=='B') || (s.at(i)=='B' && s.at(j)=='R')){//G
                ans+=ruisekiG.at(n)-ruisekiG.at(j+1);
                if(j+j-i<n && s.at(j+j-i)=='G') ans--;
            }else if((s.at(i)=='G' && s.at(j)=='B') || (s.at(i)=='B' && s.at(j)=='G')){//R
                ans+=ruisekiR.at(n)-ruisekiR.at(j+1);
                if(j+j-i<n && s.at(j+j-i)=='R') ans--;
            }
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <utility>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	ll n, len;
	cin >> n >> len;
	vector<ll> t(n);
	for (int i = 0; i < n; i++) cin >> t[i];
	ll ans = 0;
	ll last = 0;
	for (int i = 0; i < n; i++) {
		ans += len;
		ans -= max(0LL, last - t[i]);
		last = t[i] + len;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
n=int(input())
for l in range(n):
    gx,gy=map(int,input().split())
    Count= [[0 for j in range(16)] for i in range(16)] 
    Grid= [[0 for j in range(16)] for i in range(16)] 
    
    for i in range(int(input())):
        x1,y1,x2,y2=map(int,input().split())
        if x1==x2:
            Grid[x1][max(y1,y2)]=Grid[x1][max(y1,y2)]+1
        else:
            Grid[max(x1,x2)][y1]=Grid[max(x1,x2)][y1]+2
            
                    
    for i in range (16):
        if(Grid[0][i]!=0):
            break
        Count[0][i]=1
    for i in range (16):
        if(Grid[i][0]!=0):
            break
        Count[i][0]=1
        
    for i in range(1,16):
        for j in range(1,16):
            k=Grid[i][j]
            if k==0:
                Count[i][j]=Count[i-1][j]+Count[i][j-1]
            elif k==1:
                Count[i][j]=Count[i-1][j]
            elif k==2:
                Count[i][j]=Count[i][j-1]
    

    ans=Count[gx][gy]
    if ans==0:
        print("Miserable Hokusai!" )
    else:
        print(ans)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  int n;
  cin >> n;
  ll v = 0, e = 0;
  for (int i = 1; i <= n; i++) v += ll(i) * (n - i + 1);
  rep(i,n - 1) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    e += ll(a) * (n - b + 1);    
  }
  ll res = v - e;
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
int main()
{
  int a, b, c; cin >> a >> b >> c;
  int a2, b2, c2;
  int ans = 0;
  while(a%2 == 0 && b%2 == 0 && c%2 == 0){
    if(a == b&&b == c){
      cout << -1 << endl;
      return 0;
    }
    a2 = b/2 + c/2;
    b2 = c/2 + a/2;
    c2 = a/2 + b/2;
    a = a2;
    b = b2;
    c = c2;
    ans ++;
  }
  cout << ans << endl;
}


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

int main(){
  int N, M;
  cin >> N;
  map<string,int> mp;
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    // cout << s << endl;
    // sort(s.begin(), s.end());
    mp[s]++;
  }
  cin >> M;
  for(int i=0;i<M;i++){
    string s;
    cin >> s;
    // sort(s.begin(), s.end());
    mp[s] --;
  }
  int res=-10000;
  for(auto ele : mp){
    auto k = ele.first;
    auto v = ele.second;
    if(v>res)res=v;
  }
  if(res < 0)res = 0;
  cout << res << endl;
}

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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#ifdef DEBUG
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
#else
#define DEBUG_PRINT(...)
#endif

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

int N, X[200000], x[200000];

int main(){
  scanf("%d", &N);
  REP(N){
    scanf("%d", &X[i]);
    x[i] = X[i];
  }
  sort(X, X+N);
  int meda = X[N/2-1], medb = X[N/2];
  REP(N){
    if(meda<x[i])printf("%d\n", meda);
    else printf("%d\n", medb);
  }
  return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0;i < n;i++) {
        cin >> a.at(i);
    }
    if((n - 1) % (k - 1) == 0) {
        cout << (n - 1) / (k - 1) << endl;
    }else {
        cout << (n - 1) / (k - 1) + 1 << endl;
    }
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

class Main{
    int sum = 0;
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
	
	//荷物の数
        int n = sc.nextInt();
	//トラックの数
        int k = sc.nextInt();
	//トラックに現在積んである荷物の重さ
        int[] truck = new int[k];
	//荷物の重さ
        int[] weight = new int[n];
	
	
	for(int i = 0;i < n;i++){
	    weight[i] =  sc.nextInt();
	}
	System.out.println(dicision(n,k,weight,truck));
    }
    public static int dicision(int n,int k,int[] weight,int[] truck){
	int P;
	int left = 0;
	int right = n * 10000;
	int mid;
	while(right - left > 1){
	    mid = (left + right) / 2;
	    int v = check(n,k,weight,truck,mid);
	    if(v >= n) right = mid;
	    else left = mid;
	    Arrays.fill(truck,0);
	}
	
	return right;
    }
    public static int check(int n,int k,int[] weight,int[] truck,int P){
	//トラックの総積載量がPを超えてはならない
	int j = 0;

	for(int i = 0;i < k;i++){
	    
	    while((weight[j] + truck[i]) <= P){
		
		truck[i] += weight[j];
		// System.out.println(truck[i]);
		++j;
		//System.out.println(j);
		
		//全て積むことができた場合nを返す
		if(j == n) {
		    return n;
		}
     	    }
	}
	return 0;
    }

}






Measured memory_bytes: 71396
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

typedef long long ll;
typedef std::vector<int> vi;

void output() { std::cout << std::endl; }
void input() {}

template <class Head, class... Tail> void input(Head &&head, Tail &&... tail) {
  std::cin >> head;

  input(std::forward<Tail>(tail)...);
}

template <class Head, class... Tail> void output(Head &&head, Tail &&... tail) {
  std::cout << head;
  if (sizeof...(tail))
    std::cout << " ";

  output(std::forward<Tail>(tail)...);
}

int main() {
  do {

    ll n;
    input(n);
    if (!n)
      break;

    vi s(n);
    for (int &elem : s) {
      input(elem);
    }

    sort(s.begin(), s.end());
    output(std::accumulate(s.begin() + 1, s.end() - 1, 0) / (s.size() - 2));

  } while (true);
  return 0;
}


Measured memory_bytes: 3056
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
#n = ip()                                     #入力整数1つ
a,b,c= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(3)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
if a<=c and c <= b or b<=c and c <=a: j(1)
else: j(0)

Measured memory_bytes: 23612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    int a,b,c;
    char token[1000]={};
    fgets(token, sizeof(token), stdin);
    a=atoi(strtok(token, " "));b=atoi(strtok(NULL, " "));c=atoi(strtok(NULL, " "));
    if (a!=b) {
        if (a!=c){
            if (b==c) printf("Yes");
            else printf("No");
            }
        else printf("Yes");
    }else{
        if (a!=c) printf("Yes");
        else printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
a=list(map(int,input().split()))
s=0
for x in a:
    s^=x
for x in a:
    print(s^x)

Measured memory_bytes: 94140
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int cnt=0;
    int a,b,c;
    cin >> a >> b >> c;
    if(a<b){
        swap(a,b);
    }
    if(b<c){
        swap(b,c);
    }
    if(a<b){
        swap(a,b);
    }

    if(b%2!=c%2){
        cnt+=1;
        a+=1;
        c+=1;
    }
    cnt+=(b-c)/2;
    cnt+=a-b;
    cout << cnt;


    return 0;
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
using namespace std;

int solve()
{
	int n,m;
	cin>>n>>m;
	int a[n];
	priority_queue<int> q;
	for(int i=0;i<n;i++){
		cin>>a[i];
		q.push(a[i]);
	}
	for(int i=0;i<m;i++){
		int x=q.top();
		q.pop();
		x/=2;
		q.push(x);
	}
	int ans=0;
	while(!q.empty()){
		int x=q.top();
		ans+=x;
		q.pop();
	}
	cout<<ans<<endl;
	
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}

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

int main()
{
    int n;
    cin >> n;
    int a;
    map<int,int> t1, t2;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (i%2) t1[a]++;
        else t2[a]++;
    }
    int mx = 0;
    a = 0;
    for (auto x : t1) {
        if (mx < x.second) {
            mx = x.second;
            a = x.first;
        }
    }
    for (auto x : t2) {
        if (mx < x.second) {
            mx = x.second;
            a = x.first;
        }
    }
    n -= mx;
    mx = 0;
    for (auto x : t1) {
        if (x.first != a) mx = max(x.second, mx);
    }
    for (auto x : t2) {
        if (x.first != a) mx = max(x.second, mx);
    }
    cout << n - mx << "\n";
}


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

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;
}
struct Unionfind {
    vector<int> par;

    Unionfind(int n) : par(n) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] =ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

double exp_v(int n) {
    double ans = ((n*(n+1)) / 2.0) / double(n);
    return ans;
}

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

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

    vector<int> p(n);
    vector<double> p_d(n);

    double total = 0.0;
    double ans = -1.0;

    rep(i, n) {
        cin >> p[i];
        p_d[i] = exp_v(p[i]);
        total += p_d[i];
    }

    int sa = n - k;

    vector<double> mae(sa+1);
    vector<double> usiro(sa+1);

    for(int i = 0; i <= sa; ++i) {
        if(i == 0) mae[i] = 0;
        else mae[i] += p_d[i-1] + mae[i-1];
    }
    vector<double> cop(n);
    rep(i, n) cop[i] = p_d[i];

    reverse(cop.begin(), cop.end());

    for(int i = 0; i <= sa; ++i) {
        if(i == 0) usiro[i] = 0;
        else usiro[i] += cop[i-1] + usiro[i-1];
    }

    reverse(usiro.begin(), usiro.end());

    for(int i = 0; i <= sa; ++i) {
        ans = max(ans, total - (mae[i]+usiro[i]));
    }

    cout << fixed << setprecision(12);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10208
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#ifdef LOCAL
#define TIMER cerr<<clock()<<"ms\n"
#else
#define TIMER
#endif
#define SZ 666666
int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	if(c%2==0||a%2==0||b%2==0)
	{
		cout<<0<<"\n";
		return 0;
	}
	cout<<min(a*b,min(a*c,b*c))<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;


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

	int A, B;

	cin >> A >> B;

	if (A >= 13)
	{
		cout << B;
	}
	else if(A >= 6)
	{
		cout << B / 2;
	}
	else
	{
		cout << 0;
	}

	cout << endl;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n, ans=0;
	vector<int> v;

	cin>> n;
	v.resize(n);

	rep(i, n) cin >> v[i];

	sort(v.begin(), v.end());

	cout<< v[n-1]-v[0] << endl;
 
	return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



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

    int limit = (n-1)*(n-2)/2;
    if(k > limit){
        cout << -1 << endl;
        return 0;
    }

    int m = n - 1 + (limit - k);
    cout << m << endl;
    
    int v1 = 1, v2 = 2;
    REP(i, m){
        cout << v1 << " " << v2 << endl;
        if(v2 < n) v2++;
        else{
            v1++;
            v2 = v1 + 1;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();int cnt=0;boolean f=false;
		while(n--!=0) {
			int d1=sc.nextInt(),d2=sc.nextInt();
			if(d1==d2)cnt++;
			else if(d1!=d2)cnt=0;
			if(cnt>=3)f=true;
		}
		if(f)System.out.println("Yes");
		else System.out.println("No");
	}

}


Measured memory_bytes: 35996
N = int(input())

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

ans = 0
for i in range(1, N + 1):
    for j in range(1, N + 1):
        for k in range(1, N + 1):
            ans += gcd(i, gcd(j, k))
print(ans)


Measured memory_bytes: 75416
// AtCoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <math.h>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n-1; i++){
        int k;
        cin >> k;
        k--;
        vec[k]++;
    }
    for(int i = 0; i < n; i++){
        cout << vec[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4048
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;

int main() {
	ll n;
	cin >> n;
	ll res = 1;
	for (int i = 1; i <= n; i++) {
		res *= i % 1000000007;
		res %= 1000000007;
	}
	cout << res << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
S = str(input())
N = len(S)

s0 = ''
s1 = ''

def count_diff(s):
    count = 0
    for i in range(N):
        if s[i] != S[i]:
            count += 1
    return(count)

for i in range(N):
    if i % 2 == 0:
        s0 = s0 + '0'
        s1 = s1 + '1'
    else:
        s0 = s0 + '1'
        s1 = s1 + '0'

print(min(count_diff(s0), count_diff(s1)))


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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  vector<int> D(3);
  
  D.at(0) = abs(A - B);
  D.at(1) = abs(B - C);
  D.at(2) = abs(C - A);
  sort(D.begin(), D.end());
  
  cout << D.at(0) + D.at(1) << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
const int N=2e6;
int f[N],pre[N];
int main()
{
	const int mod=1e9+7;
	int n=gi(),i,ans;
	f[0]=pre[0]=1;ans=(n+1LL*(n-1)*(n-1))%mod;
	for (i=1;i<n;i++) {
		f[i]=i>=3?(f[i-1]+pre[i-3])%mod:f[i-1];
		if (i<n-1)
			ans=(ans+1LL*f[i]*(n-1)%mod*(n-1))%mod;
		ans=(ans+1LL*f[i]*(n-1))%mod;
		pre[i]=(f[i]+pre[i-1])%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 10496
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		double s,n,k[]=new double[11];
		int i;
		while(sc.hasNext()){
			n=sc.nextDouble();
			s=0;
			k[0]=0;
			k[1]=n;//
			for(i=2;i<11;i++){
				if(i%2==0){
					k[i]=k[i-1]*2;
				}
				else{
					k[i]=k[i-1]/3.0;
				}
			}//for
			for(i=1;i<11;i++){
				s+=k[i];
			}
			System.out.printf("%.8f\n",s);
		}
	}
}

Measured memory_bytes: 12000