akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    double a,ans=0;
    while(cin>>a){
        vector<ld>v(11,0);
        loop(i,1,11){
            if(i==1){v[1]=a;ans=a;}
            else if(i%2){
                v[i]=v[i-1]/3;
                ans+=v[i];
            }else {
                v[i]=v[i-1]*2;
                ans+=v[i];
            }
        }
        printf("%6lf\n",ans);
    }
}

Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		if (n / 100 == n % 10) {
			System.out.print("Yes");

		} else {
			System.out.print("No");
		}
	}
}

Measured memory_bytes: 21844
# include<iostream>
using namespace std;
int main() {
    string str;
    int b = 0;
    while (1) {
        cin >> str;
        if (str=="0") break;
        for (int i=0;i<str.size();i++) {
            int x = str[i] - '0';
            b += x;
        }
        cout << b << endl;
        b = 0;
    }
    return 0;
}


Measured memory_bytes: 3152
from collections import deque
n = int(input())
e = [[] for i in range(n)]
for i in range(n-1):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append((b,c))
    e[b].append((a,c))

Q,k = map(int,input().split())
k -= 1
d = [-1]*n
d[k] = 0
q =deque([])
q.append(k)
while q:
    now = q.popleft()

    for nex,dis in e[now]:
        if d[nex] == -1:
            d[nex] = d[now]+dis
            q.append(nex)

for i in range(Q):
    x,y = map(int,input().split())
    print(d[x-1]+d[y-1])



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

using namespace std;

#define int long long
#define PB push_back
#define MP make_tuple
#define ALL(V) V.begin(), V.end()
#define RALL(V) V.rbegin(), V.rend()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> pipi;

constexpr int INF = 1LL << 60;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 105;
constexpr int MAX_M = 1005;
//constexpr int MAX_H = 1005;
constexpr int dx[] = { 0, 1, 0, -1 };
constexpr int dy[] = { 1, 0, -1, 0 };

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    for (int i = 0; i < tx - sx; ++i) cout << "R";
    for (int i = 0; i < ty - sy; ++i) cout << "U";
    for (int i = 0; i < tx - sx; ++i) cout << "L";
    for (int i = 0; i < ty - sy; ++i) cout << "D";

    cout << "D";
    for (int i = 0; i <= tx - sx; ++i) cout << "R";
    for (int i = 0; i <= ty - sy; ++i) cout << "U";
    cout << "LU";
    for (int i = 0; i <= tx - sx; ++i) cout << "L";
    for (int i = 0; i <= ty - sy; ++i) cout << "D";
    cout << "R" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <deque>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cmath>

using namespace std;
int main(){
    int n;
    int mem;
    int bmem=10000000000;
    vector<int> x;
    cin>>n;
    for(int i=0;i<n;i++){
        cin >> mem;
        x.push_back(mem);
    }
    mem = 10000000;
    for(int i=0;i<100;i++){
        mem=0;
        for(int j=0;j<n;j++){
            int th=x[j];
            mem = mem + pow(th-i,2);
        }
        mem = min(bmem,mem);
        bmem=mem;
    }
    cout << mem << endl;
}

Measured memory_bytes: 256
import sys
k = int(input())
mod_k = [0] * (k+2)
mod_k[1] = 7 % k
if mod_k[1] == 0:
    print(1)
    sys.exit()
for i in range(2,k+2):
    nex = (mod_k[i-1]*10+7) % k
    if nex == 0:
        print(i)
        sys.exit()
    mod_k[i] = nex
print(-1)



Measured memory_bytes: 71492
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 998244353;
const int MAX_N = 200100;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

mint dp[3010][3010];
vi v;
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n, s;
    cin >> n >> s;
    rep(i, n)
    {
        int t;
        cin >> t;
        v.emplace_back(t);
    }
    dp[0][0] = 1;
    rep(i, n)
    {
        int now = v[i];
        rep(j, 3001)
        {
            dp[i + 1][j] += 2 * dp[i][j].x;
            if (j + now < 3010)
                dp[i + 1][j + now] += dp[i][j];
        }
    }
    cout << dp[n][s] << endl;

    return 0;
}

Measured memory_bytes: 74444
#include<cstdio>
using namespace std;
int main()
{
	int n,i,j,k,cnt;
	scanf("%d",&n);
	cnt=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			for(k=1;k<=n;k++){
				cnt++;
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

void funcC() {
  int k, n;
  std::cin >> k >> n;
  std::vector<int> a(n,0);
  for (int i = 0; i < n; i++) std::cin >> a[i];
  int maxsub = a[0] - a[n - 1] + k;
  for (int i; i < n - 1;i++) {
    if (maxsub < a[i + 1] - a[i]) maxsub = a[i + 1] - a[i];
  }
  std::cout << (k - maxsub);
}

int main(void) {
  funcC();
  return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N, D, X;
	cin >>N >>D >>X;
	vector<int> A(N, 0);
	for (int i=0; i<N; i++)
		cin >>A.at(i);
	for (int i=0; i<N; i++)
		X +=(D-1)/A.at(i)+1;
	cout <<X <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector< int > v;
  vector< int > w;

  for(int i = 0 ; i < n ; i++){
    int a;
    cin >> a;
    v.push_back(a);
  }
  for(int i = 0 ; i < n ; i++){
    w.push_back(v[n - i - 1]);
  }

  int ans = 0;
  for(int i = 0; i <= n && i <= k ; i++){
    for(int j = 0; j <= n - i && j <= k - i ; j++){
      vector< int > s;
      int a = 0;
      for(int t = 0; t < i ; t++){
        s.push_back(v[t]);
      }
      for(int t = 0; t < j ; t++){
        s.push_back(w[t]);
      }
      sort(s.begin(), s.end());
      for(int t = 0 ; t < k - i - j && s.size() > 0 ; t++){
        if(s[0] < 0) s.erase(s.begin());
      }
      for(int p = 0; p < s.size() ; p++){
        a += s[p];
      }
      ans = max(ans, a);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
S = input()

ans = len(S)
for i in range(26):
    c = chr(ord('a') + i)
    t1 = S
    cnt = 0
    while any(list(map(lambda x:x!=c, t1))):
        t2 = ''
        for ca,cb in zip(t1,t1[1:]):
            if ca == c or cb == c:
                t2 += c
            else:
                t2 += ca
        t1 = t2
        cnt += 1
    ans = min(ans, cnt)

print(ans)

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

int r = 26;
string name = "";

void next(long long n)
{
  long long k, m;
  char addition;
  m = n % r;
  k = n / r;
  addition = m + 0x61;
  name = addition + name;
  // cout << name << endl;
  if (k >= 1)
  {
    next(k - 1);
  }
  else
  {
    cout << name << endl;
  }
}

int main()
{
  long long a = 1000000000000001, n, i;
  long long m, k;
  char addition;
  cin >> n;
  n = n - 1;
  m = n % r;
  k = n / r;
  addition = m + 0x61;
  name = addition + name;
  // cout << name << endl;

  if (k >= 1)
  {
    next(k - 1);
  }
  else
  {
    cout << name << endl;
  }

  return 0;
}

Measured memory_bytes: 3628
import math
N = int(input())
A = list(map(int, input().split()))

B = [0 for _ in range(N)]
C = [0 for _ in range(N)]

B[0] = A[0]
for i in range(1,N):
  B[i] = math.gcd(B[i-1],A[i])

C[N-1] = A[N-1]
for i in range(N-2,-1,-1):
  C[i] = math.gcd(C[i+1],A[i])
  
ans = max(C[1],B[N-2])
for i in range(1,N-1):
  #print(i, math.gcd(C[i+1],B[i-1]))
  ans = max(math.gcd(C[i+1],B[i-1]), ans)
          
print(ans)
#print(B)
#print(C)

Measured memory_bytes: 97152
import numpy as np

N, K = map(int, input().split())
H = np.array(list(map(int, input().split())) + [0] * K, dtype=np.int64)

table = np.full(N + K, 10 ** 10, dtype=np.int64)
table[0] = 0

for i in range(1, N):
    table[i:i + K] = np.minimum(table[i:i + K], np.abs(H[i:i + K] - H[i - 1]) + table[i - 1])

print(table[N - 1])


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

int S[10000],t;
int n,q;


//線形探索
bool lenearSearch(int key){

  for ( int i = 0; i < n; i++ ) {
    
  if ( key == S[i] ) return true;
  
  }
  
  return false;
  
}

int main() {

  int cnt = 0;
  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> S[i];
  cin >> q;
  for ( int i = 0; i < q; i++ ) {
    cin >> t;
    if ( lenearSearch(t) ) {
      cnt++;
    }
  }

  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++) cin >> a[i];
    
    ll q;
    cin >> q;
    
    for(ll i = 0;i < q;i++){
        ll k;
        cin >> k;
        
        cout << lower_bound(a.begin(), a.end(), k) - a.begin() << endl;
    }
}


Measured memory_bytes: 3588
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	public K()
	{
		// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = ReadLine().Split().Select(int.Parse).ToArray();
		int N = I[0];
		uint A = (uint)I[1], B = (uint)I[2];
		if (BitCount(A ^ B) % 2 == 0) { WriteLine("NO"); return; }
		WriteLine("YES");
		WriteLine(string.Join(" ", Generate(N, A, B)));
	}
	List<uint> Generate(int N, uint A, uint B)
	{
		if (N == 1) return new List<uint> { A, B };
		B ^= A;
		var cnt = BitCount(B);
		// B の bit を左に揃える
		int[] perm = new int[N], iperm = new int[N];
		int on = N - 1, off = 0;
		for (var i = 0; i < N; i++) { perm[i] = (B & (1u << i)) != 0 ? on-- : off++; iperm[perm[i]] = i; }
		B = ((1u << cnt) - 1) << (N - cnt);
		// 作る
		var ans = new List<uint>();
		var lim = 1u << (N - 1);
		for (var i = 0u; i < lim; i++) ans.Add(i ^ (i >> 1));   // 前半は gray code
		foreach (var i in Generate(N - 1, 1u << (N - 2), B ^ lim)) ans.Add(i ^ lim);    // 後半は再帰
																						// 戻す (perm と 最初の B^=A)
		for (var i = 0; i < ans.Count; i++)
		{
			var s = 0u;
			for (var j = 0; j < N; j++) if ((ans[i] & (1u << j)) != 0) s |= 1u << iperm[j];
			ans[i] = s ^ A;
		}
		return ans;
	}
	public static int BitCount(uint n)
	{
		n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
		n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
		n = (n & 0x0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f);
		n = (n & 0x00ff00ff) + ((n >> 8) & 0x00ff00ff);
		return (int)((n & 0x0000ffff) + ((n >> 16) & 0x0000ffff));
	}
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> d(n);
  for(int i=0 ; i<n ; i++){
    cin >> d[i];
  }
  
  sort(d.begin(), d.end());
  /*
  for(int i=0 ; i<d.size() ; i++){
    cout << d[i] << " ";
  }
  cout << endl ;
  */
  
  int ans=1,x=d[0];
  for(int i = 0 ; i <  n-1 ; i++){
    if(x < d[i+1]){
      x = d[i+1];
      ans++;
    }
  }
  cout << ans << endl;
  
  /*
  int ans=0,x=1;
  while(x <= 100){
    for(int i=0 ; i<n ;i++){
      if(d[i] == x){
      ans++;
      break;
      }
    }
    x++;
  }
  cout << ans << endl;
  */
}


Measured memory_bytes: 256
import bisect
N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
ans=0
for i in range(N):
    for j in range(i+1,N):
        k=bisect.bisect_left(L,L[i]+L[j])
        ans+=k-j-1
print(ans)

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

int main(){
	string s;
	int n;
	cin >> s >> n;
	int a,b;
	string str,str2;
	for(int i = 0; i < n; i++){
		cin >> str >> a >> b;
		if(str == "print"){
			cout << s.substr(a,b+1-a) << endl;
		}else if(str == "reverse"){
			str2 = s.substr(a,b+1-a);
			reverse(str2.begin(),str2.end());
			s.replace(a,str2.length(),str2);
		}else{
			cin >> str2;
			s.replace(a,str2.length(),str2);
		}
	}
	return 0;
}		

Measured memory_bytes: 3220
#include<iostream>
#include<algorithm>
#define N 101
using namespace std;

int main(){

  int i, m, a[N] = {};
  while(cin >> i)
    a[i]++;

  for(int j = 1; j < N; j++) 
    m = max(m,a[j]);

  for(int k = 1; k < N; k++)
    if(a[k] == m) 
      cout << k << "\n";
  
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main() {
    int n; cin >> n;
    int n_odd = 0;
    int n_four = 0;
    rep(i, n) {
        ll a; cin >> a;
        if (a % 4 == 0) n_four++;
        if (a % 2 == 1) n_odd++;
    }
    if (n % 2 == 1) n_four++;

    cout << (n_odd <= n_four ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		int total =0;
		int fivehund = x/500;
		total = fivehund * 1000;
		int a = x - (fivehund * 500);
		int fives = a / 5;
		total+= fives*5;
		System.out.println(total);
	}
	
}

Measured memory_bytes: 27048
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:u128 = read();
    let k:u128 = read();
    println!("{}", min(n%k, k-(n%k)));
}


Measured memory_bytes: 2092
n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np
dists = np.ones((n + 1, n + 1)) * float('inf')
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
    dists[i, i] = 0

from itertools import permutations
for i in range(1, 1 + n):
    dists = np.minimum(dists, dists[i: i + 1] + dists[:, i: i + 1])

ans = float('inf')
for path in permutations(rs):
    val = sum(dists[i, j] for i, j in zip(path, path[1:]))
    val = int(val)
    if val < ans:
        ans = val

print(ans)

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

int main() {
    vector<long int> ryuka(100, 0);
    ryuka[0] = 2; ryuka[1] = 1;
    for (int i = 2; i < 100; ++i) {
        ryuka[i] = ryuka[i - 2] + ryuka[i - 1];
    }
    int temp;
    cin >> temp;
    cout << ryuka[temp] << endl;
}


Measured memory_bytes: 256
# 20
# ABC077 C Snuke Festival

import bisect
import itertools

n = int(input())
a_list = [int(x) for x in input().split()]
b_list = [int(x) for x in input().split()]
c_list = [int(x) for x in input().split()]

a_list.sort()
b_list.sort()
c_list.sort()

bc_list = []
for i in range(n):
    _b = b_list[i]
    _idx = bisect.bisect_right(c_list, _b)
    bc_list.append(n-_idx)

ab_list = []
for i in range(n):
    _a = a_list[i]
    _idx = bisect.bisect_right(b_list, _a)
    ab_list.append(n-_idx)

bc_list.sort()
cumsum = list(itertools.accumulate(bc_list))

ans = 0
for i in range(n):
    if ab_list[i] == 0:
        continue
    ans += cumsum[ab_list[i]-1]
print(ans)

Measured memory_bytes: 28532
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,idx = 1;
    while (1)
    {
        cin >> a >> b;
        if(a == 0 && b == 0)
            break;
        
        cout << min(a,b) << " " << max(a,b) << endl;
        idx++;
    }
    
  
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define REP(i,n) for(int i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")

using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;

const int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int dy[8] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  bool ans = true;
  rep(i,h){
    rep(j,w){
      if(s[i][j] == '#'){
        bool ok = false;
        rep(dir,4){
          int nx = j + dx[dir];
          int ny = i + dy[dir];
          if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
          if(s[ny][nx] == '#') ok = true;
        }
        if(!ok) ans = false;
      }
    }
  }
  YesorNo(ans);
}

Measured memory_bytes: 256
n = int(input())
List = [input() for i in range(n)]
x = 0
ans = "Yes"

for i in range(1,n):
    if List[i-1][-1:] != List[i][:1]:
        ans = "No"
        #print(List[i-1][-1:])
        #rint(List[i][:1])
        break
if len(List) != len(set(List)):
    ans = "No"
print(ans)
#print(List[i-1][-1:])
#print(List[i][:1])
#print(len(set(List)))

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

using ll = long long;

constexpr ll inf = 1e18;

int main() {
    ll s, t, d; cin >> s >> t >> d;
    vector<ll> w(d), sum(d + 1);
    for(int i = 0; i < d; ++i) {
        cin >> w[i];
        sum[i + 1] = sum[i] + w[i];
    }

    ll mini = inf;
    for(int i = 0; i <= d; ++i) {
        if(s + sum[i] <= t) {
            cout << i << endl;
            return 0;
        }
        mini = min(mini, sum[i]);
    }

    if(sum[d] >= 0) {
        cout << -1 << endl;
        return 0;
    }

    const ll cnt = (s - t + mini - sum[d] - 1) / (-sum[d]);
    ll ans = cnt * d;
    s += cnt * sum[d];
    for(int i = 0; i <= d; ++i) {
        if(s + sum[i] <= t) {
            ans += i;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4396
def binarySearch(A, key, n):
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if S[mid] == i:
            return True
        elif i < S[mid]:
            right = mid
        else:
            left = mid + 1
    return False

n = int(input())
S = tuple(map(int, input().split(' ')))

q = input()
T = tuple(map(int, input().split(' ')))

cnt = 0

for i in T:
    if binarySearch(S, i, n):
        cnt += 1

print(cnt)

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream& operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T>
inline void printV(vector<T>& a, int n) { for(int i=0; i<n; i++) { cerr<<a[i]<<" "; } cerr<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a) { for(int i=0; i<sz(a); i++) { cerr<<a[i]<<"\n"; } cerr<<"\n"; }
template <typename T>
inline void clearVV(vector<vector<T>>& a) { for(auto &x : a) { x.clear(); } a.clear(); }
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val) { for(int i=0; i<sz(a); i++) { a[i].assign(sz(a[i]), val); } }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n, d;
	cin>>n>>d;
	int cnt = 0;
	int i1=1;
	while(i1<=n) {
		cnt++;
		i1 += 2*d+1;
	}
	cout<<cnt<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=a;i<=b;i++)
const int maxn = 1e5+7;
int n,m,a[maxn];
int main(int argc, char const *argv[])
{
	cin>>n>>m;
	int p = 1;
	_for(i,1,n)
	{
		cin>>a[i];
	}
	int ans = 1e9+7;
	_for(i,1,n-m+1)
	{
		if(a[i]<0&&a[i+m-1]>=0)
		{
			ans = min(ans,min(abs(a[i])*2+a[i+m-1],abs(a[i])+a[i+m-1]*2));
		}
		else if(a[i]<0)ans = min(ans,abs(a[i]));
		else if(a[i]>=0)ans = min(ans,a[i+m-1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int a,b;
    char c;
    double pi=acos(-1.0);
    double x=0,y=0,angle=90;
    for(;;){
       cin>>a>>c>>b;
       if(a==0 && b==0) break;
       x+=a*cos(angle*pi/180);
       y+=a*sin(angle*pi/180);
       angle-=b;      
   }
   cout<<(int)x<<"\n"<<(int)y<<endl;
   return 0;
}

Measured memory_bytes: 1168
n = gets.to_i

num_ary = []

n.times do
  num_ary << gets.to_i
end

min, max_diff = nil, nil

num_ary.each_with_index do |num, index|
  if index.zero?
    min = num
    next
  end

  if index == 1
    max_diff = num - num_ary[0]
    min = num if num < min
    next
  end

  if index > 1
    diff = num - min
    max_diff = diff if max_diff < diff
    min = num if num < min
  end
end

puts max_diff

Measured memory_bytes: 10540
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    set<double> st1,st2;
    rep(ai, 30)
    {
        rep(bi, 30)
        {
            int tmp = ai * a * 100 + bi * b * 100; 
            if (tmp <= f)
            {
                st1.insert(tmp);
            }
        }
    }
    rep(ci,3000){
        rep(di,3000){
            int tmp = ci * c + di * d;
            if (tmp <= f){
                st2.insert(tmp);
            }
        }
    }
    double den = 0;
    int ret[2];
    for(auto p : st1){
        for(auto p2:st2){
            double noudo = p2 / (p + p2) * 100;
            if (p+p2 <= f && noudo >= den && p/100*e >= p2){
                den = noudo;
                ret[0] = p + p2;
                ret[1] = p2;
            }
        }
    }
    rep(i,2){
        cout << ret[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
//#define i_7 (long long)(1e9+7)
#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  vector<long long> a(n);
  REP(i, n) cin>>a[i];
  
  long long ans = INF;
  vector<long long> d(n);
  REP(i, n) d[i] = a[i]; REPP(i, n - 1) d[i] += d[i - 1];
  for(int m = 2; m <= n - 2; m++){// [0, m), [m, n) で分ける。
    //[0, l) [l, m) [m, r) [r, n) で分けたい。
    
    int l = upper_bound(d.begin(), d.begin() + m, d[m - 1] / 2) - d.begin();
    if(l == m) l--;
    if(l == 0) l++;
    if(l > 1) if(abs(d[m - 1] - 2 * d[l - 1]) > abs(d[m - 1] - 2 * d[l - 2])) l--;
    if(l + 1 < m) if(abs(d[m - 1] - 2 * d[l - 1]) > abs(d[m - 1] - 2 * d[l])) l++;
    long long P = d[l - 1];
    long long Q = d[m - 1] - d[l - 1];
    
    int r = upper_bound(d.begin() + m, d.end(), (d[n - 1] + d[m - 1]) / 2) - d.begin();
    if(r == n) r--;
    if(r == m) r++;
    if(r > m + 2) if(abs(d[n - 1] - 2 * d[r - 1] + d[m - 1]) > abs(d[n - 1] - 2 * d[r - 2] + d[m - 1])) r--;
    if(r + 1 < n) if(abs(d[n - 1] - 2 * d[r - 1] + d[m - 1]) > abs(d[n - 1] - 2 * d[r] + d[m - 1])) r++;
    long long R = d[r - 1] - d[m - 1];
    long long S = d[n - 1] - d[r - 1];
    
    long long temp = max(max(P, Q), max(R, S)) - min(min(P, Q), min(R, S));
    ans = min(ans, temp);
    
    /*
    cout << "m: " << m << endl;
    cout << "P: " << P << ", Q: " << Q << ", R: " << R << ", S: " << S << endl;
    cout << "temp: " << temp << endl;
    */
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6464
n,m=map(int,input().split())
h=list(map(int,input().split()))
s=[]
for i in range(n):
    s.append(i)
res=0
a=[]
for i in range(m):
    a.append(list(map(int,input().split())))
    if h[a[i][0]-1]<=h[a[i][1]-1]:
        s[a[i][0]-1]=-1
    if h[a[i][0]-1]>=h[a[i][1]-1]:
        s[a[i][1]-1]=-1
for ss in s:
    if ss!=-1:
        res=res+1
print(res)


Measured memory_bytes: 34380
//                        Bismillahir Rahmanir Rahim
//ALGO:
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=01;

int main() {
    double x;
    cin>>x;
    x/=3;
    cout<<fixed<<setprecision(10)<<x*x*x;
}



Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())

vec = [[] for _ in range(N)]
for _ in range(M) :
    u, v = map(int, input().split())
    vec[u-1].append(v-1)

S, T = map(int, input().split())
S, T = S - 1, T - 1

visited = [[False] * N for _ in range(3)]
visited[0][S] = True
queue = deque([(S, 0)])

while queue :
    q, cost = queue.popleft()
    p = (cost + 1) % 3
    for i in vec[q] :
        if p == 0 and i == T :
            print((cost + 1) // 3)
            exit()
        if not visited[p][i] :
            visited[p][i] = True
            queue.append((i, cost + 1))

print(-1)
    

Measured memory_bytes: 61856
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b){
  if(b > a) swap(a, b);
  ll r = -1;
  while(r!=0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
int main(int argc, char const *argv[]) {
  ll N;
  std::cin >> N;
  std::vector<ll> A(N);
  std::vector<ll> l(N);
  std::vector<ll> r(N);
  range(i, N) std::cin >> A[i];
  ll reg = A[0];
  range(i, N){
    reg = gcd(reg, A[i]);
    l[i] = reg;
  }
  reg = A[N-1];
  for(int i = N-1;i>=0;i--){
    reg = gcd(reg, A[i]);
    r[i] = reg;
  }
  ll ans = 0;
  range(i, N){
    if(i == 0){
      ans = max(ans, r[1]);
    }else if(i == N-1){
      ans = max(ans, l[N-2]);
    }else{
      ans = max(ans, gcd(r[i+1], l[i-1]));
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		long x = sc.nextLong();
		long y = sc.nextLong();
		
		if(x % y == 0) {
			out.println(-1);
		}else{
			out.println(x);
		}
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

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

	public static int lcm(int a, int b) {
		return (a * b) / gcd(a, b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21332
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int gi()
{
	char c;int num=0,flg=1;
	while((c=getchar())<'0'||c>'9')if(c=='-')flg=-1;
	while(c>='0'&&c<='9'){num=num*10+c-48;c=getchar();}
	return num*flg;
}
#define N 200005
#define LL long long
#define lc i<<1
#define rc i<<1|1
const LL INF=0x3f3f3f3f3f3f3f3fll;
int pos[N],A,B,n,Q;
struct node{
	int l,r;
	LL mi1,mi2,la;
}a[N<<2];
void cal(int i,LL k){a[i].mi1+=k;a[i].mi2+=k;a[i].la+=k;}
void pushdown(int i)
{
	if(a[i].la&&a[i].l<a[i].r){
		cal(lc,a[i].la);cal(rc,a[i].la);
		a[i].la=0;
	}
}
void pushup(int i)
{
	a[i].mi1=min(a[lc].mi1,a[rc].mi1);
	a[i].mi2=min(a[lc].mi2,a[rc].mi2);
}
void build(int i,int l,int r)
{
	a[i].l=l;a[i].r=r;
	if(l==r){
		a[i].mi1=INF;a[i].mi2=INF;
		return;
	}
	int mid=(l+r)>>1;
	build(lc,l,mid);build(rc,mid+1,r);
	pushup(i);
}
void insert(int i,int l,int r,LL k)
{
	if(a[i].l>r||a[i].r<l)return;
	pushdown(i);
	if(l<=a[i].l&&a[i].r<=r){cal(i,k);return;}
	insert(lc,l,r,k);insert(rc,l,r,k);
	pushup(i);
}
void modify(int i,int x,LL k)
{
	if(a[i].l>x||a[i].r<x)return;
	pushdown(i);
	if(x==a[i].l&&a[i].r==x){a[i].mi1=min(a[i].mi1,k-x);a[i].mi2=min(a[i].mi2,k+x);return;}
	modify(lc,x,k);modify(rc,x,k);
	pushup(i);
}
LL query1(int i,int l,int r)
{
	if(a[i].l>r||a[i].r<l)return INF;
	pushdown(i);
	if(l<=a[i].l&&a[i].r<=r)return a[i].mi1;
	return min(query1(lc,l,r),query1(rc,l,r));
}
LL query2(int i,int l,int r)
{
	if(a[i].l>r||a[i].r<l)return INF;
	pushdown(i);
	if(l<=a[i].l&&a[i].r<=r)return a[i].mi2;
	return min(query2(lc,l,r),query2(rc,l,r));
}
LL query(int i)
{
	if(a[i].l==a[i].r)return a[i].mi1+a[i].l;
	pushdown(i);
	return min(query(lc),query(rc));
}
int ab(int x){return x<0?-x:x;}
int main()
{
	int i;LL f;
	n=gi();Q=gi();A=gi();B=gi();
	build(1,1,n);
	pos[0]=A;modify(1,B,0);
	for(i=1;i<=Q;i++){
		pos[i]=gi();
		f=min(query1(1,1,pos[i])+pos[i],query2(1,pos[i]+1,n)-pos[i]);
		insert(1,1,n,ab(pos[i]-pos[i-1]));
		modify(1,pos[i-1],f);
	}
	printf("%lld\n",query(1));
}

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

int main(void) {
	int A,B,C;

	cin >> A >> B >> C;

	for (int i = 0; i <= B; i++) {
		if ((A*i) % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

}

Measured memory_bytes: 256
N,M,Q = map(int,input().split())
T = [[0 for _ in range(N+1)] for _ in range(N+1)]
for i in range(M):
  L,R = map(int, input().split())
  T[L][R] += 1
for l in range(1,N+1):
  for r in range(1,N+1):
    T[l][r] += T[l-1][r]+T[l][r-1]-T[l-1][r-1]
ans = []
for i in range(Q):
  p,q = map(int, input().split())
  ans.append(T[p-1][p-1]+T[q][q]-T[p-1][q]-T[q][p-1])
print('\n'.join(map(str,ans)))


Measured memory_bytes: 23896
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
ans = [0] * N

def fn(x, y, z):
    f = x**2 + y**2 + z**2 + x * y + y * z + z * x
    return f

for x in range(1, int(N ** 0.5) + 2):
    if fn(x, 1, 1) > N:
        break
    for y in range(1, int(N ** 0.5) + 2):
        if fn(x, y, 1) > N:
            break
        for z in range(1, int(N ** 0.5) + 2):
            f = fn(x, y, z)
            if f > N:
                break
            if f <= N:
                ans[f - 1] += 1

for a in ans:
    print(a)

Measured memory_bytes: 75084
defmodule Main do
  def main do
      s =
      IO.read(:line)
      |> String.trim
      |> String.to_charlist
	  if Enum.member?(s, ?a) and Enum.member?(s, ?b) and Enum.member?(s, ?c) do
    	IO.puts("Yes")
      else
    	IO.puts("No")
      end
  end
end

Measured memory_bytes: 30644
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

A,B,N=get_i
x=0
if B-1<=N
    x=B-1
else
  x=N  
end
puts (A*x)/B

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


int main(){
  int N;
  cin>>N;
  int ans=1e7;
  vector<int>A(100);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int j=1;j<=100;j++){
    int SUM=0;
    for(int k=0;k<N;k++){
      SUM+=(A[k]-j)*(A[k]-j);
    }
    
    ans=min(ans,SUM);  

  }
  cout<<ans<<endl;

}

Measured memory_bytes: 256
import itertools
import math


n = int(input())
xs = list()
ys = list()
for i in range(n):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)

costs = list()
indices = itertools.permutations(range(n))
for index in indices:
    cost = 0.0
    for i, j in zip(index[:-1], index[1:]):
        d2 = (xs[j] - xs[i]) ** 2 + (ys[j] - ys[i]) ** 2
        cost += math.sqrt(d2)
    costs.append(cost)

print(sum(costs) / len(costs))


Measured memory_bytes: 4528
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = n/4;
		int d = n/7;
		boolean flg = false;
		for(int i = 0;i <=k;i++){
			for(int j = 0;j <= d;j++){
				if(4*i + j*7 == n){
					flg = true;
					break;
				}
			}
		}
		if(flg){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <queue>
#include <set>
#include <iomanip>
using namespace std;

long double CalProb(int i, int N, int K){
    // if(i > K/2){
    //     return (double)1/N;
    // }
    int iter = ceil(log2((long double)K/i));
    long double prob;
    prob = (long double)1/N*pow((long double)1/2, iter);
    return prob;
}

 int main(){
     int N, K;
     std::cin >> N >> K;
     long double prob = 0;
     
     if(N < K){
         for (int i = 1; i < N + 1; ++i)
         {
             prob = prob + CalProb(i, N, K);
             // std::cout<<std::fixed<<std::setprecision(14) << prob << "\n";
             // std::cout << i << "\n";
             // last_i = i;
         }
         // prob = prob + ()*(double)1/N;
         // std::cout << prob << "\n";
         std::cout<<std::fixed<<std::setprecision(14) << prob << "\n";
         // std::cout << (double)1/100000 << "\n";
    }else{
        for (int i = 1; i < K; ++i)
        {
            prob = prob + CalProb(i, N, K);
            // std::cout<<std::fixed<<std::setprecision(14) << prob << "\n";
            // std::cout << i << "\n";
            // last_i = i;
        }
        prob = prob + (long double)(N-K+1)/N;
        std::cout<<std::fixed<<std::setprecision(14) << prob << "\n";
    }
 }

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, X, T = MAP()

print(-(-N // X) * T)

Measured memory_bytes: 10560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int x[5];
    int ans;
    for(int i=0;i<5;i++){
        cin>>x[i];
        if(x[i] == 0){
            ans = i+1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3568
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  int n,rank[100];
  pair<int,int> point[100];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    point[i].first = 0;
    point[i].second = i;
  }
  for(int i=0;i<n*(n-1)/2;i++){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(c<d){
      point[b-1].first += 3;
    }else if(c>d){
      point[a-1].first += 3;
    }else{
      point[a-1].first += 1;
      point[b-1].first += 1;
    }
  }
  sort(point,point+n);
  reverse(point,point+n);
  int r;
  for(int i=0;i<n;i++){
    int team = point[i].second;
    if(i>0&&point[i].first==point[i-1].first){
      rank[team] = r;
    }else{
      r = i+1;
      rank[team] = r;
    }
  }
  for(int i=0;i<n;i++) printf("%d\n",rank[i]);
  return 0;
}

Measured memory_bytes: 2692
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int h,m,s;
	cin>>s;

	h=s/3600;
	s%=3600;
	m=s/60;
	s%=60;

	cout << h << ":" << m << ":" << s << endl; // prints !!!Hello World!!!
	return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a>=1 && b>=1 && c>=1 && a<=100 && b<=100 && c<=100)
   { printf("%d %d %d\n",c,a,b);}
    return 0;
}
    

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int imax = N/4;
  int jmax = N/7;
  string Ans = "No";
  for (int i= 0; i <= imax ; i++){
    for (int j = 0; j <= jmax; j++){
      if (i*4 + j*7 == N) Ans = "Yes";
    }
  }
  cout << Ans << endl;
} 


Measured memory_bytes: 3576
# -*- coding: utf-8 -*-
# 整数の入力
# 1以上N以下の整数のうち、10進法での各桁の和が
# A以上B以下であるものの総和を求めてください。
import math
a, b, c = map(int, input().split())
if a == b and a != c and b != c:
  print('Yes')
elif b == c and a != b and a != c:
  print('Yes')
elif c == a and a != b and c != b:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060