akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
using namespace std;
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdio>

int main()
{
    long long int x,y,a=-1;
    cin>>x>>y;
    if(x%y==0)
        cout<<a;
    else
    {int i;
        for(i=3,a=2*x;a%y==0;i++)
            a=x*i;
        cout<<a;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
const ll mod = (ll)(1000000007);
const ll maxn = 20;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
void solve()
{
    int n;
    cin>>n;
    ll arr[n];
    rep0(i,n) cin>>arr[i];
    sort(arr,arr+n);
    ll sum = 0; 
    ll xx=1LL;
    for (ll i = 0; i <= 64; i++)  
    { 
        ll zc = 0, oc = 0;  
        ll idsum = 0;  
        for (int j = 0; j < n; j++) 
        { 
            if (arr[j] % 2 == 0) 
                zc++; 
            else
                oc++; 
            arr[j] /= 2LL; 
        } 
        idsum = ((((oc * zc)%mod) * xx)%mod)%mod;  
        sum =(sum+idsum)%mod;  
        xx=(xx*2LL)%mod;
    } 
    pr(sum%mod);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  sort(vec.rbegin(),vec.rend());
  int64_t ans = 0;
  priority_queue<int64_t> PQ;
  PQ.push(vec[0]);
  for(int i=1; i<N; i++){
    ans += PQ.top();
    PQ.pop();
    PQ.push(vec[i]);
    PQ.push(vec[i]);
  }
  cout << ans << endl; 
}



Measured memory_bytes: 6916
/*
  "I knew I shouldn't have gotten out of bed today."
   - Squidward Tentacles
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;

#define pb           push_back
#define pf           push_front
#define mp           make_pair
#define ff           first
#define ss           second
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define brep(i,s,e)  for(int i=s;i>=e;i--)
#define mem(x,y)     memset(x,y,sizeof(x))
#define DANGER       std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
   DANGER 
   int a,b,c;
   cin>>a>>b;
   int x[4]={0};
   x[a]=1;
   x[b]=1;
   int res;
   for (int i = 1; i < 4; i++)
   {
      if(x[i]==0)
      res=i;
   }

   cout<<res<<"\n";
   
}

Measured memory_bytes: 256
//Suplex
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int n,m;
char st[10000];
char a[1000][1000];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",st+1);
		for(int j=1;j<=m;j++) a[i][j]=st[j];
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(a[i][j]=='#'){
				if(a[i-1][j]=='.' && a[i+1][j]=='.' && a[i][j-1]=='.' && a[i][j+1]=='.') {puts("No");return 0;}
			}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c;cin>>a>>b>>c;
  if(a-b==b-c)cout<<"YES";
  else cout<<"NO";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

int32_t main(){
	int n,m;
	cin>>n>>m;
	if(n==m){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
}


Measured memory_bytes: 256
#include <stdio.h>


// ?¨????#?????????????????????????????¬?????????
void showFrame(int width){
	int w;
	for(w = 0; w < width; w++){
		putchar('#');
	}
}

// ?¨????#??¨.???????????????????????????
void showContents(int width){
	int w;
	for(w = 0; w < width; w++){
		if((w == 0) || (w == width - 1)){
			putchar('#');
		}else{
			putchar('.');
		}
	}
}

// ???????????????????????????
void showHeight(int height, int width){
	int h;
	for(h = 0; h < height; h++){
		if((h == 0) || (h == height - 1)){
			showFrame(width);
		}else{
			showContents(width);
		}
		putchar('\n');
	}
	putchar('\n');
}

// ????????¢????????¨?¨??????\?????????
int main(void){
	int height, width, h, w;
	
	scanf("%d %d", &height, &width);
	
	
	while(!(height == 0 && width == 0)){
		showHeight(height, width);
		scanf("%d %d", &height, &width);
	}
	return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int a;
	cin >> a;
	string s;
	cin >> s;

	if (a >= 3200){
		cout << s  << "\n";
	} else {
		cout << "red" << "\n";		
	}





	return 0;
}


Measured memory_bytes: 256
import itertools

A, B, C = map(int, input().split())
k = int(input())
l = ['a', 'b', 'c']
for v in itertools.combinations_with_replacement(l, k):
  new_A = A * (2**(v.count('a')))
  new_B = B * (2**(v.count('b')))
  new_C = C * (2**(v.count('c')))
  if new_A < new_B < new_C:
    print('Yes')
    exit()
    
print('No')

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;



int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n,temp;
    cin >> n;
    vector<int> a(n);
    set<int> s;
    rep(i,n) cin >> a[i];
    sort(all(a));

    ll ans=0,i=0;
    vector<bool> dp(a[n-1]+1,false);
    while(2*a[i]<=a[n-1]){
        if(dp[a[i]]){
            i++;
            continue;
        }
        rep(j,(int)a[n-1]/a[i]) dp[(j+1)*a[i]] = true;
        if(a[i]!=a[i+1]) ans++;
        i++;
    }
    repk(j,n,i){
        if(a[j]==a[j+1]) while(a[j]==a[j+1]) j++;
        else if(dp[a[j]] == false) ans++;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 4292
//https://beta.atcoder.jp/contests/abc095/tasks/abc095_a
#include<iostream>
#include<string>

using namespace std;

int main(){
    int cnt = 0;
    string s;
    
    cin >> s;
    
    if(s[0] == 'o') cnt++;
    if(s[1] == 'o') cnt++;
    if(s[2] == 'o') cnt++;

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

Measured memory_bytes: 256
from collections import Counter
N = int(input())
a = list(map(int, input().split()))

c = Counter(a)
keys = sorted(list(c.keys()))
values = sorted(list(c.values()))
if len(c) == 1 and c[0] == N:
    print("Yes")
    exit()
if N % 3 != 0:
    print("No")
elif len(c) == 2 and 0 in keys and c[0] == N//3:
    print("Yes")
elif len(c) == 3 and values[0] == values[1] == values[2] == N//3 and keys[0] ^ keys[1] ^ keys[2] == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
typedef long long int ll;
typedef vector<int> vint;
const ll LINF = 9000000000000000000ll;
const int INF = 2000000000;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint h(n);
    rep(i, n) cin >> h[i];
    int ans = 0;
    int cnt = 0;
    int mx = *max_element(all(h));
    rep(i, mx) {
        cnt = 0;
        if (h[0] > 0) cnt++;
        rep(i, n-1) if (h[i] == 0 && h[i+1] > 0) cnt++;
        ans += cnt;
        rep(i, n) h[i] = max(h[i] - 1, 0);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long calcPattern(int a) {
  long long res = 0;
  for (int i = 0; i <= (a + 1) / 2; i++) {
    res += COM(a - i, i) % MOD;
    res %= MOD;
  }
  return res % MOD;
}

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

  int N, M;
  cin >> N >> M;
  vector<int> broken(M);
  COMinit();
  for (int i = 0; i < M; i++) {
    cin >> broken.at(i);
  }
  for (int i = 0; i < M - 1; i++) {
    if (broken.at(i) + 1 == broken.at(i + 1)) {
      cout << 0 << endl;
      return 0;
    }
  }
  vector<int> stairs;
  if (M > 0) {
    stairs.push_back(broken.at(0) - 0 - 1);
    for (int i = 0; i < M - 1; i++) {
      stairs.push_back(broken.at(i + 1) - broken.at(i) - 2);
    }
    stairs.push_back(N - broken.at(M - 1) - 1);
    long long ans = 1;
    for (int i = 0; i < stairs.size(); i++) {
      ans *= calcPattern(stairs.at(i)) % MOD;
      ans %= MOD;
    }
    cout << ans << endl;
  } else{
    cout << calcPattern(N) % MOD <<endl;
  }
}


Measured memory_bytes: 12800
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

d = [(1,0),(-1,0),(0,1),(0,-1)]
def solve():
    def rotate(dice,d):
        d1,d2,d3,d4,d5,d6 = dice
        if d == (0,1):
            return (d4,d2,d1,d6,d5,d3)
        elif d == (0,-1):
            return (d3,d2,d6,d1,d5,d4)
        elif d == (1,0):
            return (d5,d1,d3,d4,d6,d2)
        else:
            return (d2,d6,d3,d4,d1,d5)
    h,w = LI()
    s = [input() for i in range(h)]
    bfs = [[0 for i in range(w)] for j in range(h)]
    bfs[0][0] = 1
    q = deque([(0,0,(1,2,3,4,5,6))])
    while q:
        y,x,dice = q.popleft()
        if y == h-1 and x == w-1:
            print("YES")
            return
        for dy,dx in d:
            ny,nx = y+dy,x+dx
            if 0 <= ny < h and 0 <= nx < w:
                nd = rotate(dice,(dy,dx))
                if not bfs[ny][nx] and str(nd[-1]) == s[ny][nx]:
                    bfs[ny][nx] = 1
                    q.append((ny,nx,nd))
    print("NO")
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 6184
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <limits>
#include <math.h>
#include <string>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  map<long long, long long> m;
  m[0]++;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += a[i];
    m[sum]++;
  }

  long long ans = 0;
  for (auto e: m) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

ll COM2(ll r)
{
    // com(r, 2);
    ll ans;
    ans = r * (r - 1) / 2;
    return ans;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++)cin >> a[i];
    
    vector<ll> counttable(n + 1);
    ll tot = 0;
    // cout << 100 << endl;
    for(ll i = 1; i <= n; i++) counttable[i] = 0;
    for(ll i = 0; i < n; i++){
        counttable[a[i]]++;
    }
    // cout << 2 << endl;
    for(ll i = 1; i <= n; i++) tot += COM2(counttable[i]);
    
    for(ll i = 0; i < n; i++){
        ll ans = tot;
        ans -= COM2(counttable[a[i]]);
        ans += COM2(counttable[a[i]] - 1);
        cout << ans << endl;

    }


}

Measured memory_bytes: 5760
n,m=map(int,input().split())
a1=0
ans=1
for i in range(m+1):
    if i==m:
        a2=n+1
    else:
        a2=int(input())
    l=a2-a1
    if l==0:
        print(0)
        exit()
    if l>2:
        fst=1
        snd=1
        for _ in range(l-2):
            nfst=snd
            snd=fst+nfst
            fst=nfst
        ans*=snd
    a1=a2+1
print(ans%(10**9+7))

Measured memory_bytes: 9124
from itertools import accumulate
import bisect
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
b = list(map(int, input().split()))
A.insert(0, 0)
b.insert(0, 0)

A = list(accumulate(A))
b = list(accumulate(b))

ans = 0
for i, a in enumerate(A):
    if a > k:
        break
    index = bisect.bisect_right(b, k-a)
    ans = max(ans, i + index-1)

print(ans)

Measured memory_bytes: 131644
#include<stdio.h>

int main(){
    int TIME;
    int x;
    scanf("%d",&TIME);
    int hour,min,sec;
    hour=TIME/3600;
    x=TIME-(hour*3600);
    min=x/60;
    sec=x-(min*60);
    printf("%d:%d:%d\n",hour,min,sec);
    return 0;
}


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

int gcd(int m,int n){
    if(n==0)    return m;
    return      gcd(n,m%n);
}
int main(){
    unsigned short W,H,C;
    cin>>W>>H>>C;
    unsigned short g=gcd(W,H);
    cout<<(W/g)*(H/g)*C<<endl;
    return 0;	
}


Measured memory_bytes: 3084
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  int la = abs(x-a), lb = abs(x-b);
  string ans;
  if(la < lb) ans = "A";
  else ans = "B";
  cout << ans;
  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] mountain = new int[10];
            for (int i = 0; i < 10; i++) {
                mountain[i] = sc.nextInt();
            }
        Arrays.sort(mountain);
            for(int i = 0; i < 3; i++){
                System.out.println(mountain[9-i]);
            }
    }
}

Measured memory_bytes: 17304
#include<stdio.h>
int main()
{
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    if(A<=B && C<=D)
    printf("%d\n",A+C);
    else if(B<=A && C<=D)
    printf("%d",B+C);
    else if(A<=B && D<=C)
    printf("%d",A+D);
    else
    printf("%d",B+D);
    return 0;
}

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

int main() {
  long long d, n;
  cin >> d >> n;
  long long ans = 1;

  if (n == 100) {
    n++;
  }

  for (int i = 0; i < d; i++) {
    ans *= 100;
  }

  cout << ans * n << endl;

  return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, M, X;
    cin >> N >> M >> X;
    vec A(M);
    REP(i,0,M) cin >> A[i];

    ll c = upper_bound(ALL(A), X) - A.begin();
    PR(MIN(c,M-c));

    return 0;
}

/*



*/

Measured memory_bytes: 3632
a = input()

def int2019(s):
    s = [int(i) for i in s]
    modTable = [0] * 2019
    total = 0
    for i in range(len(s)):
        nextTable = [0] * 2019
        for j in range(2019):
            nextTable[(j * 10 + (s[i])) % 2019] = modTable[j]

        nextTable[(s[i]) % 2019] += 1
        total += nextTable[0]
        modTable = nextTable

    return total


print(int2019(a))


Measured memory_bytes: 78884
#include<stdio.h>

static const int N = 100;

int main(){
  
  int M[N][N];
  int n, u, k, v;
  
  
  scanf("%d",&n);
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)M[i][j] = 0;
  }
  
  
  for(int i=0;i<n;i++){
    scanf("%d %d", &u, &k);
    u--;
    for(int j=0;j<k;j++){
      scanf(" %d",&v);
      v--;
      M[u][v]=1;
    }
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2060
using System;


namespace atCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int kyori = int.Parse(s[0]);
            int time = int.Parse(s[1]);
            int speed = int.Parse(s[2]);


            Console.WriteLine(((time * speed) >= kyori) ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 27460
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

int n;

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

    ll ans=n;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ans=min(ans,i+n/i-2);
        }
    }

    cout<<ans<<endl;
}


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

int main(){
	ll x,k,d;
	cin >> x >> k >> d;
	if(x>0){
		ll butuh=ceil((double)x/(double)d);
		ll kecil=x-(d*butuh);
		ll besar=kecil+d;
		ll sisa=k-butuh;
		if(sisa<0) cout << abs(x-(d*k)) << '\n';
		else if(sisa%2==0) cout << abs(kecil) << '\n';
		else cout << abs(besar) << '\n';
	}
	else{
		ll butuh=ceil((double)abs(x)/(double)d);
		ll besar=x+(d*butuh);
		// cout << besar << ' ' << x << ' ' << d*butuh << '\n'; 
		ll kecil=besar-d;
		// cout << kecil << ' ' << besar << '\n';
		ll sisa=k-butuh;
		if(sisa<0) cout << abs(x+(d*k)) << '\n';
		else if(sisa%2==0) cout << abs(besar) << '\n';
		else cout << abs(kecil) << '\n';
	}
}

Measured memory_bytes: 3720
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
r,d,x = n1()

for _ in range(10):
    x = r * x - d
    print(x)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 998244353
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

ll Pow(ll n, ll k) {
	ll ans = 1, a = n % MOD;
	while (k > 0) {
		if (k & 1) {
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		k >>= 1;
	}
	return ans;
}

ll Inverse(ll a) {
	return Pow(a, MOD - 2);
}

//nCaを計算、a < 0 の時 0
ll Combi(ll n, ll a, vector<ll> & k) {
	a = min(a, n - a);
	if (a < 0)
		return 0;
	if (a == 0)
		return 1ll;
	ll ans = k[n] * Inverse(k[a]) % MOD;
	return ans * Inverse(k[n - a]) % MOD;
}

// d[n] = n! の配列初期化
void Ini_fact(vector<ll> & d) {
	d[1] = 1;
	for (ll i = 2; i < d.size(); i++)
		d[i] = d[i - 1] * i % MOD;
	return;
}

int main(void) {
	ll num, m, k, i, ans = 0, sum = 0;
	cin >> num >> m >> k;
	vector<ll> kai(num + 5);
	Ini_fact(kai);
	rep(i, k + 1) {
		sum = m * Combi(num - 1, i, kai) % MOD;
		sum *= Pow(m - 1, num - 1 - i);
		sum %= MOD;
		ans += sum;
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4836
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N,M;
   cin >> N >> M;
   vector<pair<int,int>> edge[N];
   for(int i=0;i<M;i++){
      int l,r,c;
      cin >> l >> r >> c;
      edge[l-1].emplace_back(make_pair(r-1,c));
   }
   long long dist[N];
   for(int i=0;i<N;i++) dist[i]=LLONG_MAX/2;
   priority_queue<pair<long long,int>> pq;
   pq.push(make_pair(0,0));
   while(!pq.empty()){
      pair<long long, int> p = pq.top();
      pq.pop();
      long long d = -p.first;
      int cur = p.second;
      if( d > dist[cur] ) continue;
      if( cur == N-1 ){
         cout << d << endl;
         return 0;
      }
      for(int i=0;i<(int)edge[cur].size();i++){
         pair<int,int> e = edge[cur][i];
         long long cost = e.second;
         int next = e.first;
         if( dist[next] > d+cost ){
            dist[next]=d+cost;
            pq.push(make_pair(-d-cost, next));
         }
      }
      if( cur!=0 && dist[cur-1] > d ){
         dist[cur-1]=d;
         pq.push(make_pair(-d, cur-1));
      }
   }
   cout << -1 << endl;
   return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

vector<string> ANS {
  "pairwise coprime",
  "setwise coprime",
  "not coprime",
};

#include <map>
class Spf {
public:
  Spf(ll n): n(n) {
    init();
  }

  map<ll,ll> get(ll x) {
    map<ll,ll> m;
    while (x != 1) {
      m[dat[x]]++;
      x /= dat[x];
    }
    return m;
  }
private:
  ll n;
  vector<ll> dat;
  void init() {
    dat.assign(n+1, 0);
    for (ll i=0; i<=n; i++) dat[i] = i;
    for (ll i=2; i*i<=n; i++) {
      if (dat[i] == i) {
        for (ll j=i*i; j<=n; j += i) {
          if (dat[j] == j) dat[j] = i;
        }
      }
    }
  }
};


int main() {
  int n; cin >> n;
  vector<ll> A(n);
  loop(i,0,n) cin >> A[i];
  Spf spf(1000001);
  ll gc = A[0];
  loop(i,0,n) gc = __gcd(gc, A[i]);
  if (gc != 1) {
    cout << ANS[2] << endl;
    return 0;
  }

  set<int> S;
  loop(i,0,n) {
    auto M = spf.get(A[i]);
    for (auto m: M) {
      int a = m.first;
      if (S.count(a)) {
        cout << ANS[1] << endl;
        return 0;
      }
      S.insert(a);
    }
  }

  cout << ANS[0] << endl;
  return 0;
}


Measured memory_bytes: 18764
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){

    double a,b,x; cin >> a >> b >> x;

    double hight = x / (a * a);

    //cout << hight << endl;
    //cout << 2 * hight * a / (b * b) << endl;

    double ans1 = 0;
    if(hight <= b / 2){
        ans1 = 90 - atan(2 * hight * a / (b * b)) * (180 / M_PI);
    }else{
        ans1 = 90 - atan(a /( 2 * (b - hight))) * (180 / M_PI);
    }
    

    cout << fixed << setprecision(10) << ans1 << endl;
}

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

int main()
{
    int n; string sh;
    cin >> n >> sh;
    int ans = 0;
    for(int i = 0; i < n - 2; i++)
    {
        if(sh[i] == 'A' && sh[i + 1] == 'B' && sh[i + 2] == 'C') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;
    vector<ll> A(X),B(Y),C(Z);
    rep(i,X)cin>>A.at(i);
    rep(i,Y)cin>>B.at(i);
    rep(i,Z)cin>>C.at(i);
    sort(A.begin(),A.end());
    vector<ll> BC(Y*Z);
    rep(i,Y*Z){
        BC.at(i)=B.at(i/Z)+C.at(i%Z);
    }
    sort(BC.begin(),BC.end());
    ll r=-1,l=A.back()+BC.back()+1;
    while(l-r>1){
        ll m=(r+l)/2;
        ll count=0;
        rep(i,X){
            count+=BC.end()-lower_bound(BC.begin(),BC.end(),m-A.at(i));
        }
        if(count<=K){l=m;}
        else{r=m;}
    }
    vector<ll> ans(0);
    reverse(A.begin(),A.end());
    reverse(BC.begin(),BC.end());
    rep(i,X){
        rep(j,Y*Z){
            if(A.at(i)+BC.at(j)>=l){ans.pb(A.at(i)+BC.at(j));}
            else{break;}
        }
    }
    sort(ans.rbegin(),ans.rend());
    rep(i,sz(ans)){
        cout<<ans.at(i)<<endl;
    }
    rep(i,K-sz(ans)){
        cout<<r<<endl;
    }
}

Measured memory_bytes: 11312
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
h, w = map(int, input().split())
c = [ list(map(int, input().split())) for _ in range(10) ]
csr = csr_matrix(c)
A = dijkstra(csr)
Q = [0]*10
for i in range(10):
  Q[i] = int(A[i][1])
ans = 0
for _ in range(h):
  for i in map(int, input().split()):
    if not i==-1:
      ans += Q[i]
print(ans)

Measured memory_bytes: 13708
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        aa1: [usize; n],
        aa2: [usize; n],
    };
    let mut max = 0;
    for i in 0..n {
        let sum: usize = aa1[0..=i].iter().sum::<usize>() + aa2[i..n].iter().sum::<usize>();
        max = std::cmp::max(max, sum);
    }
    println!("{}", max);
}


Measured memory_bytes: 2184
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long

class UnionFind
{
private:
	vec<int> p;
	vec<int> Rank;

public:
	UnionFind(int n) : p(n), Rank(n, 0) {
		rep(i, n) p[i] = i;
	}

	void init(int n)
	{
		p.resize(n);
		rep(i, n) p[i] = i;
		Rank.resize(n);
		rep(i, n) Rank[i] = 0;
	}

	int root(int a)
	{
		if (p[a] == a) return a;
		p[a] = root(p[a]);
		return p[a];
	}

	void unite(int a, int b)
	{
		int ra = root(a);
		int rb = root(b);
		if (Rank[ra] > Rank[rb]) p[rb] = ra;
		else p[ra] = rb;
		if (Rank[ra] == Rank[rb]) Rank[rb]++;
	}

	int is_same_group(int a, int b)
	{
		return (root(a) == root(b));
	}
};

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

	UnionFind road(n), train(n);
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		road.unite(a, b);
	}
	rep(i, l) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		train.unite(a, b);
	}

	vec<pair<pair<int, int>, int>> set(n);
	rep(i, n) {
		set[i].first.first = road.root(i);
		set[i].first.second = train.root(i);
		set[i].second = i;
	}

	sort(set.begin(), set.end());
	vec<int> ans(n);
	int cur = 0;
	while(cur < n) {
		int prev = cur;

		for (; cur <= n; cur++) {
			if (cur < n && set[prev].first == set[cur].first) continue;
			break;
		}
		for (int i = prev; i < cur; i++) ans[set[i].second] = cur - prev;
	}

	rep(i, n - 1) cout << ans[i] << " ";
	cout << ans[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for(int i=0;i<(int)(n);++i)
#define FOR(i, b, n)  for(int i=b;i<(n);++i)
#define ALL(c) (c).begin(),(c).end()
#define SS size()
#define PB push_back
#define ST first
#define ND second

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


template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

template<typename T> void print(vector<T> d){for(T a : d) cout << a << " "; cout << endl;}
 
vi primes(int mx) {
	vi vis(mx); 
	vi res; 
	FOR(i,2,mx) {
		if (vis[i]) continue; 
		vis[i]=1;
		res.PB(i);
		for(int j=i; j<mx; j+=i) vis[j]=1;
	}
	return res; 
}

int main() {
	// freopen("./aaa.txt", "w", stdout);
	int n; cin >> n; 
	vi pps = primes(5555);
	int cnt = 0; 
	for(int i : pps) {
		if (i%5==1) {
			cout << i << " "; 
			if (++cnt==n) return 0;
		}
	}

}

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

#define MOD 1000000007

int main(){

    long long int s;

    cin >> s;

    int arr[2001];

    for (int i = 0; i < 2001; i++)
    {
        arr[i] = 0;
    }

    arr[3] = 1;

    for (int j = 4; j <= s; j++)
    {
        for (int i = 0; i <= j-3; i++)
        {
            arr[j] = (arr[j] + arr[i])%MOD;
        }
        arr[j] += 1;
        
    }
    
    cout << arr[s]%MOD << endl;


    return 0;
}

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

using namespace std;

int ret[100000];

bool check(int seat) {
  cout << seat << endl;
  string v;
  cin >> v;
  if (v == "Vacant") {
    exit(0);
  }
  if (ret[seat] != -1) {
    return ret[seat];
  }
  if (v == "Male") {
    ret[seat] = true;
    return true;
  } else {
    ret[seat] = false;
    return false;
  }
}

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

  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    ret[i] = -1;
  }

  int l = 0, r = n;
  check(l);
  while (l < r) {
    int m = (l + r) / 2;
    check(m);
    if ((m - l) % 2 ^ (ret[m] == ret[l]))
      l = m;
    else
      r = m;
  }
}


Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll n,k;
  cin>>n>>k;
  vi p(n);
  rep(i,n) cin>>p[i];
  REP(i,1,n) p[i]+=p[i-1]; //累積和
  ll foo=p[k-1];
  REP(i,1,n-k+1) chmax(foo,p[i+k-1]-p[i-1]);
  double d=(double(foo)+double(k))/2;
  decimal(10);
  out(d);
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat 
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int INF=1<<30;
const int SIZE=3*1e5;
const int BITSIZE=1<<17;
const int TIMES=40;
const LL p=7+1e9;
LL N,M,K,H,W,C;
bool poss[SIZE];
int nums[SIZE];
int x[SIZE];
int main(){
	int N,M,tied=-1;
	cin >> N >> M;
	FOR(i,1,N+1){
		cin >> x[i];
		if(i && x[i]+x[i-1]>=M) tied=i-1;
	}
	if(tied==-1){
		cout <<"Impossible" << endl;
		return 0;
	}
	cout <<"Possible" << endl;
	FOR(i,1,tied)
		cout << i << endl;
	for(int i=N-1;i>=tied;i--){
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
// 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

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main(void){
    ll a;
    cin >> a;
    ll b;
    cin >> b;
    ll c;
    cin >> c;
    ll x;
    cin >> x;
    ll y;
    cin >> y;

    ll ans =INF;
    ll maxnum =0;
    CHMAX(maxnum, x);
    CHMAX(maxnum, y);
    REP(i, maxnum*2+1){
        ll tmpx = (x*2) -i;
        ll tmpy = (y*2) -i;
        ll tmpans =0;
        //abピザ料金加算
        tmpans += i*c;

        if(tmpx >0){
            if( tmpx % 2){
                tmpx++;
            }
            tmpans += (tmpx /2) *a;
        }
        if(tmpy > 0){
            if( tmpy % 2){
                tmpy++;
            }
            tmpans += (tmpy /2) *b;
        }
        
        CHMIN(ans, tmpans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  
  vector<int> a;
  int temp;
  
  for(int i = 0; i < n; i++){
    cin >> temp;
    a.push_back(temp);
  }
  
  sort(a.begin(), a.end(), greater<int>());
  
  for(int i = 0; i < n - 1; i++){
    if(a.at(i) == a.at(i + 1)){
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cout << "YES" << endl;
  
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int n, k;
double x[65], y[65], c[65], r[65];
double eps = 1e-6;

double dist(pair<double, double> p, pair<double, double> q) {
	double xx = (p.first - q.first)*(p.first - q.first);
	double yy = (p.second - q.second)*(p.second - q.second);

	return sqrt(xx + yy);
}

vector<pair<double, double>> circle_circle_intersection(double x1, double y1, double r1, double x2, double y2, double r2) {
	vector<pair<double, double>> ans;
	double d = dist(make_pair(x1, y1), make_pair(x2, y2));
	if (d > r1 + r2) {
		return ans;
	}
	if (x1 == x2 && y1 == y2) {
		ans.push_back(make_pair(x1, y1)); return ans;
	}
	if (d < abs(r1 - r2)) {
		ans.push_back(make_pair(x1, y1)); return ans;
	}

	double a = (r1*r1 - r2*r2 + d*d)/(2*d);
	double h = sqrt(r1*r1 - a*a);


	double x3 = (x2 - x1)*(a/d) + x1;
	double y3 = (y2 - y1)*(a/d) + y1;

	ans.emplace_back(x3 + h*(y2 - y1)/d, y3 - h*(x2 - x1)/d);
	ans.emplace_back(x3 - h*(y2 - y1)/d, y3 + h*(x2 - x1)/d);

	return ans;
}

int check(double t) {
	int ans = 0;
	for (int i = 0; i < n; i++) {
		r[i] = t/c[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			vector<pair<double, double> > pts = circle_circle_intersection(x[i], y[i], r[i], x[j], y[j], r[j]);
			for (auto p: pts) {
				int cnt = 0;
				for (int k = 0; k < n; k++) {
					if (dist(p, make_pair(x[k], y[k])) <= r[k] +eps) cnt++;
				}
				ans = max(ans, cnt);
			}
		}
	}
	

	return ans;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	if (k == 1) {
		cout << "0\n"; exit(0);
	}
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> c[i];
	}

	double l = 0, r = 100000000;
	while(r-l>=1e-7)
	{
		double mid = (l + r)/2;

		if (check(mid) >= k) {
			r = mid;
		} else {
			l = mid;
		}
	}
	cout << fixed << setprecision(9) << r << '\n'; 

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    bool b = true;
    vector<int> wrong;
    rep(i, N) {
        if (P[i] != i + 1) {
            b = false;
            wrong.push_back(i);
        }
    }

    if (b || wrong.size() == 2) {
        write("YES");
    }
    else {
        write("NO");
    }
}

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

using namespace std;

int main(){
  map<string, int> ma, mb;
  array<string, 100> strs;
  int n,m;
  cin>>n;
  for(int i=0;i<n;i++){
    string str;
    cin>>str;
    ma[str]++;
    strs[i]=str;
  }

  cin>>m;
  for(int i=0;i<m;i++){
    string str;
    cin>>str;
    ma[str]--;
  }

  int result = 0;
  for(auto it=ma.begin();it!=ma.end();it++){
    if(result < it->second){
      result = it->second;
    }
  }
  cout<<result;

  return 0;
}


Measured memory_bytes: 256
D=int(input())
c=list(map(int, input().split()))
s=[list(map(int, input().split()))  for i in range(D)]

d=[-1]*(26)
v=[0]*(D+1)


for i in range(D):
    t=s[i].index(max(s[i]))
    v[i]=s[i][t]
    d[t]=-1
    sb=0      
    for j in range(26):
        d[j]+=1 
        sb+=d[j]*c[j]
                            
        v[i]+=v[i-1]-sb
    print(t+1)

Measured memory_bytes: 9356
#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)

//i個目までみてj個選んだ時総和がkになる組み合わせ数
ll dp[60][60][3000] = {};

int main(){
	int n, x;
	scanf("%d %d", &n, &x);
	int a[n];
	REP(i, 0, n) scanf("%d", &a[i]);
	dp[0][0][0] = 1;

	REP(i, 0, n) REP(j, 0, 1+n) REP(k, 0, 2500) {
	    dp[i+1][j][k] += dp[i][j][k];
	    if(j<n) dp[i+1][j+1][k+a[i]] += dp[i][j][k];
	}
	
	ll ans = 0;
	REP(j, 1, n+1) {
	    ans += dp[n][j][x*j];
	}
	printf("%ld\n", ans);
	return 0;
}



Measured memory_bytes: 63556
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long

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

	int N, K;
	cin >> N >> K;

	int X = N / 2;
	if (N % 2 == 1) {
		X++;
	}
	if (X >= K) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  map<int, long long> m;
  for(int i=0; i < n; i++) {
    cin >> v[i];
    if(m.count(v[i]) == 0) {
      m[v[i]] = 1;
    } else {
      m[v[i]]++;
    }
  }
  map<int, long long> ans;
  for(int i=0; i < n; i++) {
    if(ans.count(m[v[i]]) == 0) {
    m[v[i]]--;
    
    long long sum = 0;
    for(std::map<int,long long>::iterator it=m.begin(); it!=m.end(); ++it) {
      long long v = it->second;
      sum += v*(v-1)/2;
    }
    cout << sum << endl;
    m[v[i]]++;
    ans[m[v[i]]] = sum;
    } else {
      cout << ans[m[v[i]]] << endl;
    }
  }
}


Measured memory_bytes: 10240
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int n,saidai,saisho;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    saisho=v[0];
    saidai=v[1]-v[0];
    for(int i=1;i<n;i++){
        if(saidai<v[i]-saisho){saidai=v[i]-saisho;}
        if(saisho>v[i]){saisho=v[i];}
    }
    cout << saidai << endl;
}


Measured memory_bytes: 3624
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
M=1
for a in A:
    M=((M * a) // gcd(M, a))
M%=mod

print(sum([M*pow(a,mod-2,mod)%mod for a in A])%mod)


Measured memory_bytes: 68440
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[2001],ans,p[2001],mod=1000000007;
int main(){
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i<=n;i++)cin>>a[i];
	for(ll i=1;i<=n;i++){
		for(ll j=i+1;j<=n;j++){
			if(a[j]<a[i]){
				ans=ans+k;
				ans%=mod;
			}
		}
		for(ll j=1;j<=n;j++){
			if(a[j]<a[i]){
				ans=ans+k*(k-1)/2;
				ans%=mod;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second > b.second; }

signed main() {
    string s[3];
    cin>>s[0]>>s[1]>>s[2];
    int turn=0;
    for(;;){
        if(s[0].size()<1&&turn==0||s[1].size()<1&&turn==1||s[2].size()<1&&turn==2)break;
        int temp=turn;
        turn=s[turn].front()-'a';
        s[temp].erase(s[temp].begin());
    }
    cout<<(char)(turn+65)<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long h = Integer.parseInt(scan.next());
    long w = Integer.parseInt(scan.next());
    long max = (h + 2) / 3 * w;
    long min = h / 3 * w;
    long diff = max - min;
    max = (w + 2) / 3 * h;
    min = w / 3 *  h;
    diff = Math.min(diff, max - min);
    for (int i = 1; i < h; i++) {
      max = Math.max(i * w, (w + 1) / 2 * (h - i));
      min = Math.min(i * w, w / 2 * (h - i));
      diff = Math.min(diff, max - min);
    }
    for (int i = 1; i < w; i++) {
      max = Math.max(i * h, (h + 1) / 2 * (w - i));
      min = Math.min(i * h, h / 2 * (w - i));
      diff = Math.min(diff, max - min);
    }
    System.out.println(diff);
  }
}

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

// ---------------------------template starts here-------------------------- 

#define int long long int
#define pb push_back
#define MAX INT_MAX
#define F first
#define S second 
#define mp make_pair
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

set <int> s;
bool ar[100001];
void seive() {
    ar[0] = ar[1] = true;

    for(int p=2; p*p<=100001; p++) {
        if(ar[p] == false) {
            for(int i=p*p;i<=100001;i+=p)
                ar[i] = true ;
        }
    }

    for(int p=2;p<=100001;p++) {
        if(ar[p] == false)
            s.insert(p);
    }
}

bool is_palindrome(string str) {
    int len = str.length();
    for(int i=0;i<=len/2;i++) {
        if(str[i] != str[len-1-i])
            return false;
    }
    return true;
}

// --------------------------template ends here------------------------------

void solve() {
    int n, m;
    cin >> n >> m;

    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}

Measured memory_bytes: 256