akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int n,k,ans = 0;
    cin >> n >> k;
    REP(i,n) {
        int h;
        cin >> h;
        ans += (h >= k);
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 764
h, w = map(int, input().split())
grid = [input() for _ in range(h)]

def check(i, j, h, w, grid):
    flg = False
    lst = [(i-1, j), (i+1, j), (i, j-1), (i, j+1)]
    if i == 0:
        lst.remove((i-1, j))
    if j == 0:
        lst.remove((i, j-1))
    if i == h-1:
        lst.remove((i+1, j))
    if j == w-1:
        lst.remove((i, j+1))
    for tpl in lst:
        if grid[tpl[0]][tpl[1]] == '#':
            flg = True
    return flg

flg = True
for i in range(h):
    for j in range(w):
        if grid[i][j] == '#':
            if check(i, j, h, w, grid):
                pass
            else:
                flg = False
print('Yes') if flg else print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){

int r, D, x, ans;
  cin >> r >> D >> x;
  ans = x;
  
  for(int i = 0;i < 10;i++){
  ans = ans * r - D;
  cout << ans << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

mod = 998244353
A, B, C, D = map(int, input().split())

dp = [[0] * (D+1) for _ in range(C+1)]
dp[A][B] = 1
for i in range(A, C+1):
    for j in range(B, D+1):
        if i == A and j == B:
            continue
        dp[i][j] = (dp[i][j-1] * i + dp[i-1][j] * j - dp[i-1][j-1] * (i - 1) * (j - 1)) % mod
print(dp[C][D])

Measured memory_bytes: 136916
a,b,c,d = [int(i) for i in input()]

if a + b + c + d == 7:
    print('{}+{}+{}+{}=7'.format(a,b,c,d))
elif a + b + c - d == 7:
    print('{}+{}+{}-{}=7'.format(a,b,c,d))
elif a + b - c + d == 7:
    print('{}+{}-{}+{}=7'.format(a,b,c,d))
elif a - b + c + d == 7:
    print('{}-{}+{}+{}=7'.format(a,b,c,d))
elif a - b + c - d == 7:
    print('{}-{}+{}-{}=7'.format(a,b,c,d))
elif a + b - c - d == 7:
    print('{}+{}-{}-{}=7'.format(a,b,c,d))
elif a - b - c + d == 7:
    print('{}-{}-{}+{}=7'.format(a,b,c,d))
else:
    print('{}-{}-{}-{}=7'.format(a,b,c,d))

Measured memory_bytes: 3064
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 1e18 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';
int32_t main(){
    boost;
    int n;
    cin>>n ;
    vi v;
     for(int i =0 ;  i < n ; i++ ){
         int x;
         cin>>x;
         v.pb(x);
     }
     sort(all(v));
     int num=1;
     for(int i = 0;  i < n ; i++ ){
        if(v[i] == 0){
          //  cout<<"hi1\n";
            cout<<0<<endl;
            return 0;
        }    
            
            if(num  >  limit/v[i] ){
                // cout<<v[i]<<endl;
                // cout<<num
                //   cout<<"hi2\n";
                cout<<-1<<endl;
                return 0;
            }
            
        num = num*v[i];    
            
     }
     cout<<num<<endl;
}

Measured memory_bytes: 4284
N,Q = map(int, input().split())
S = input()
TD = [ input().split() for _ in range(Q)]


N = len(S)
ans = 0

# N-1 falls from right edge ? 
nowpos = N-1
fall_f = False
for i in range(Q):
    t,d = TD[i]
    nowChar = S[nowpos]
    if t == nowChar:
        if d == "L":
            nowpos -= 1
            if nowpos == -1:
                break
        if d == "R":
            nowpos += 1
            if nowpos == N:
                fall_f = True
                break

if fall_f:
    ok = N-1
    ng = -1
    mid = (ok+ng)//2
    while abs(ok - ng) > 1:
        nowpos = mid
        fall_f = False

        for i in range(Q):
            t,d = TD[i]
            nowChar = S[nowpos]
            if t == nowChar:
                if d == "L":
                    nowpos -= 1
                    if nowpos == -1: break
                if d == "R":
                    nowpos += 1
                    if nowpos == N:
                        fall_f = True
                        break
        if fall_f :
            ok = mid
        else:
            ng = mid

        mid = (ok+ng)//2

    ans += N - ok 

    

    
# 0 fallse from left edge  ?
nowpos = 0
fall_f = False
for i in range(Q):
    t,d = TD[i]
    nowChar = S[nowpos]
    if t == nowChar:
        if d == "L":
            nowpos -= 1
            if nowpos == -1:
                fall_f = True
                break
        if d == "R":
            nowpos += 1
            if nowpos == N:
                break
if fall_f:

    ok = 0
    ng = N
    mid = (ok+ng)//2
    while abs(ok - ng) > 1:

        nowpos = mid
        fall_f = False

        for i in range(Q):
            t,d = TD[i]
            nowChar = S[nowpos]
            if t == nowChar:
                if d == "L":
                    nowpos -= 1
                    if nowpos == -1: 
                        fall_f = True
                        break
                if d == "R":
                    nowpos += 1
                    if nowpos == N:
                        break
        if fall_f :
            ok = mid
        else:
            ng = mid

        mid = (ok+ng)//2

    ans= min( ans +  ok + 1,  N)

print(N - ans)



Measured memory_bytes: 93084
n = gets.to_s.to_i

h = Hash.new()
ans = 0
n.times do |s|
  
  s = gets.to_s.chomp.bytes.sort.pack("U*")
  
  if h.has_key?(s)
    h[s] += 1
    ans += h[s]
    p 
  else
    h[s] = 0
  end
end

puts ans

Measured memory_bytes: 18556
N=int(input())
A=list(map(int,input().split()))
#print(A)
L=[A[0]]
for i in range(1,N):
    L.append(L[-1]+A[i])
S=sum(A)
#print(S)
ans=10**15
for i in range(N):
    if abs(S-2*L[i])<ans:
        ans=abs(S-2*L[i])
print(ans)

Measured memory_bytes: 26396
#include <bits/stdc++.h>
using namespace std;
 
const int INF = 1e9;

int main() {
    int n, W;
    cin>>n>>W;
    int w[n];
    long long int v[n];
    for (int i=0; i<n; i++){
        cin>>w[i];
        cin>>v[i];
    }
    long long int dp[W+1] = {0};
    for (int i=0; i<n; i++){
        for (int j=W-w[i]; j>=0; j--){
            dp[j+w[i]] = max(dp[j+w[i]], v[i]+dp[j]);
        }
    }

    cout<<dp[W];
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod = 1e9+7;
 
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};






 
int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 

  
  
  int x,n;
  cin>>x>>n;
  for(int i=0;i<n;i++)
  {
	  int a;
	  cin>>a;
	  x-=a;
  }
  if(x<0)
  cout<<-1;
  else cout<<x;
  

}




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

int main() {
    int n,d,x;
    cin >> n >> d >> x;
    int a[n];
    for (int i=0;i<n;i++){
        cin >> a[i];
    }
    int sum = 0;
    for(int i=0;i<n;i++){
        if(a[i] != 0)
        sum += 1 + (d-1)/a[i];
    }

    sum += x;

    cout << sum << "\n";

}


Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int x = int.Parse(input[0]);
		int y = int.Parse(input[1]);

		Console.WriteLine(GetGCD(x, y));
	}

	static int GetGCD(int x, int y)
	{
		int z = (x > y) ? x % y : y % x;

		return (z == 0) ? y : GetGCD(y, z);
	}
}

Measured memory_bytes: 9220
import heapq
x,y,z,k = map(int,input().split())
a = sorted(list(map(int,input().split())),reverse = 1)
b = sorted(list(map(int,input().split())),reverse = 1)
c = sorted(list(map(int,input().split())),reverse = 1)
q = []
heapq.heapify(q)
for i in range(x):
    if i == 0:
        jlim = y
    else:
        jlim = min(-(-k//i),y)
    for j in range(jlim):
        if i*j == 0:
            llim = z
        else:
            llim = min(-(-k//(i*j)),z)
        for l in range(llim):
            heapq.heappush(q,-(a[i]+b[j]+c[l]))
for i in range(k):
    x = heapq.heappop(q)
    print(-x)



Measured memory_bytes: 130512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
// #define INF I64_MAX
#define MOD 1000000007

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
void warshall_floyd(Matrix< T > &g, T INF) {
  for(int k = 0; k < g.size(); k++) {
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
        if(g[i][k] == INF || g[k][j] == INF) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

void solve(void)
{
  int N,E;
  cin>>N>>E;
  int R;
  cin>>R;
  vector<int> city(R);
  for (int i = 0; i < R; i++)
  {
    int A;
    cin>>A;
    A--;
    city[i] = A;
  }
  
  Matrix<long long> mat(N,vector<int>(N,I64_MAX));

  for (int i = 0; i < N; i++)
  {
    mat[i][i] = 0;
  }
  

  for (int i = 0; i < E; i++)
  {
    int A,B,C;
    cin>>A>>B>>C;
    A--;
    B--;
    mat[A][B] = C;
    mat[B][A] = C;
  }

  warshall_floyd(mat,(long long)(I64_MAX));
  int ANS = 0;
  int num = 1;
  vector<int> perm(R,0);
  for (int i = 0; i < R; i++)
  {
    perm[i] = i;
    num *= i + 1;
  }
  int MIN = I64_MAX;
  for (int k = 0; k < num; k++)
  {
    ANS = 0;
   for (int i = 0; i < R -1; i++)
  {
    // cout<<perm[i]<<" ";
    int from,to;
    from = city[perm[i]];
    to = city[perm[i+1]];
    ANS += mat[from][to];
  }
  MIN =min(ANS,MIN);
  next_permutation(perm.begin(),perm.end());
  
  }
  

  cout<<MIN<<endl;
  

  
  
  

  return;  
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

vector<ll> A;

int main(){
    ll N,B;
    cin >> N;
    rep(i,N){
        cin >> B ;
        A.pb(B);
    }
    ll T = N-1;
    while(T>=0){
        cout << A[T] << " ";
        T-=2;
    }
    T=0;
    if(N%2==1){
        T=1;
    }
    while(T<N-1){
        cout << A[T]  << " ";
        T+=2;
    }
    cout << endl;
}

Measured memory_bytes: 3824
s=list(input())

for i in range(int(input())):
    cmd,a,b,*c=input().split()
    a,b=int(a),int(b)
    
    if cmd=="print":
        print(*s[a:b+1],sep="")
    elif cmd=="reverse":
        s[a:b+1]=s[a:b+1][::-1]
    else:
        s[a:b+1]=c[0]
        



Measured memory_bytes: 5740
m,d = map(int,input().split())
ans = 0
for i in range(1,m+1):
    seki = 0
    for j in range(1,d+1):
        if ((j%10) >= 2) and ((j//10) >= 2):
            seki = (j%10)*(j//10)
            if seki == i:
                ans += 1
                # print(i,j)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, a, i, j, k;
	cin >> n >> a;
	if (n % 500 <= a) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(void) {
    int n;
    cin >> n;
    long long a[n];
    rep(i, n) cin >> a[i];

    rep(i, n) a[i] -= 1 + i;

    // rep(i, n) { cout << a[i] << endl; }

    partial_sort(a, a + (n/2 + 1), a+n);
    int mid = a[n/2];

    long long sum = 0;
    rep(i, n) {
        sum += abs(a[i] - mid);
    }
    long long ma = sum;

    mid = a[n/2 + 1];

    sum = 0;
    rep(i, n) {
        sum += abs(a[i] - mid);
    }
    ma = min(ma, sum);
    cout << ma << endl;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, k; cin >> n >> k;
    vector<int> p(n);
    vector<double> exp(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        exp[i] = double(p[i]+1) / 2.0; 
    }

    double ans = 0;
    double sum = 0;
    for(int i = 0; i < k; i++) ans+=exp[i];
    sum = ans;
    for(int i=1; i+k-1 < n; i++){
        sum = sum - exp[i-1] + exp[i+k-1];
        if(sum > ans) ans = sum;
    }
    printf("%.8f\n", ans);

    return 0;
}


Measured memory_bytes: 2560
import math

def  XYZTriplets():

    num = int(input())
    
    if num >= 400 and num <= 599:
        print(8)
        
    elif num >= 600 and num <= 799:
        print(7)
    
    elif num >= 800 and num <= 999:
        print(6)
    
    elif num >= 1000 and num <= 1199:
        print(5)
    
    elif num >= 1200 and num <= 1399:
        print(4)
    
    elif num >= 1400 and num <= 1599:
        print(3)
    
    elif num >= 1600 and num <= 1799:
        print(2)

    elif num >= 1800 and num <= 1999:
        print(1)        
    
if __name__ == '__main__':
    XYZTriplets()


Measured memory_bytes: 9184
#include <stdio.h>

int solve(int *b, int n, int w, int m)
{
	int v, i, p;

	p = 0;
	for (i = 0; i < m; i++){
		v = 0;
		while (p < n && v + b[p] <= w){
			v += b[p];
			p++;
		}
		if (p == n) return (1);
	}
	return (0);
}

int main(void)
{
	int books[128];
	int n, m;
	int f, l;
	int ans;
	int i;

	while (scanf("%d %d", &m, &n), m){
		for (i = 0; i < n; i++){
			scanf("%d", books + i);
		}

		f = 0;
		l = 1500000;
		while (f != l){
			int v = f + l >> 1;
			if (solve(books, n, v, m)){
				ans = v;
				l = v;
			}
			else f = v + 1;
		}
		printf("%d\n", ans);
	}
	return (0);
}

Measured memory_bytes: 600
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  long long int s;
  long long int a[301];
  for(int i = 0; i<301; i++){
    a[i] = 0;
  }
  long long int ans = 0;
  long long int p=0;
  cin >> s;
  long long int b = s;
  if(s==1){
    cout << 4 <<endl;
    return 0;
  }
  if(s==2){
    cout << 4 << endl;
    return 0;
  }
  if(s==4){
    cout << 4 << endl;
    return 0;
  }
  //debug
  //out << s << endl;
  /*
  long long int b = s;
  a[b]++;
  for(int i=2;i<100001;i++){
    long long int n;
    if(b%2==0){
      n=b/2;
    }else{
      n=3*b+1;
    }
    a[n]++;
    for(int j=1;j<301;j++){
      if(a[j]==2){
        ans = i;
        break;
      }
    }
    if(ans!=0)break;
    b = n;
  }
  */
  for(int i=2;i<100001;i++){
    long long int n;
    if(b%2==0){
      n=b/2;
    }else{
      n=3*b+1;
    }
    if(n==4)p++;
    if(p==2){
      ans=i;
      break;
    }
    b=n;
  }
  cout << ans << endl;
  return 0;
}


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

#define ll long long
#define ar array

template<typename T> struct cp {
	T x, y;
	cp<T> operator+(const cp &o) const {
		return {x+o.x, y+o.y};
	}
	cp<T> operator*(const cp &o) const {
		return {x*o.x-y*o.y, x*o.y+y*o.x};
	}
};
template<typename T> struct fft {
	static const int mxN=1<<19;
	cp<T> rt[mxN];
	void fi(int n) {
		T PI=acos((T)-1);
		for(int i=0; i<n/2; ++i) {
			T an=2*PI*i/n;
			rt[i+n/2]={cos(an), sin(an)};
		}
		for(int i=n/2; --i; )
			rt[i]=rt[2*i];
	}
	void ac(vector<cp<T>> &a) {
		int n=a.size();
		for(int i=0, j=0; i<n; ++i) {
			if(i>j)
				swap(a[i], a[j]);
			for(int k=n/2; (j^=k)<k; k/=2);
		}
		for(int st=1; 2*st<=n; st*=2) {
			for(int i=0; i<n; i+=2*st) {
				for(int j=i; j<i+st; ++j) {
					cp<T> z=rt[j-i+st]*a[j+st];
					a[j+st]=a[j]+cp<T>{-1, 0}*z;
					a[j]=a[j]+z;
				}
			}
		}
	}
	void mul(vector<cp<T>> &g, vector<cp<T>> &h) {
		int n=g.size();
		ac(g);
		for(int i=0; i<n; ++i) {
			int j=(n-i)&(n-1);
			cp<T> g2=g[i]*g[i];
			g2.x=-g2.x;
			h[i]=(g[j]*g[j]+g2)*cp<T>{(T)0, (T)-1/4/n};
		}
		ac(h);
	}
};
fft<long double> f;

const int P=200003;
int n, x[P], y[P];
vector<cp<long double>> c1(1<<19), c2(1<<19);

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

	//*
	//set<int> s;
	int p=1;
	for(int i=0; i<P-1; ++i, p=p*2%P) {
		x[i]=p;
		y[p]=i;
		//s.insert(p);
	}
	//cout << s.size() << endl;
	//*/
	cin >> n;
	ll ans=0;
	for(int i=0; i<n; ++i) {
		int b;
		cin >> b;
		if(b) {
			++c1[y[b]].x;
			++c1[y[b]].y;
			//cout << b << " " << y[b] << endl;
			ans-=(ll)b*b%P;
			//cout << y[b]*2
		}
	}
	f.fi(1<<19);
	f.mul(c1, c2);
	for(int i=0; i<1<<19; ++i) {
		//if((ll)round(c2[i].x))
			//cout << i%P << " " << c2[i].x << endl;
		ans+=(ll)round(c2[i].x)*x[i%(P-1)];
	}
	cout << ans/2;
}

Measured memory_bytes: 54348
#include <iostream>
using namespace std;
int main()
{
  int n, v;
  long t = 0;
  int m = 0;
  int x = 1000000000;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v;
    if (v < 0) {
      v = -v;
      m++;
    }
    t += v;
    if (x > v) {
      x = v;
    }
  }
  if (m & 0x01) {
    t -= x * 2;
  }
  cout << t << endl;
  return 0;
}

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

using namespace std;

int main()
{ios_base::sync_with_stdio(false);
    long long int n;
    cin>>n;
    long long int a[n],i,j=1000000000000000000,c=0,d=0,ans=1;
    for(i=0;i<n;i++)
        cin>>a[i];
        for(i=0;i<n;i++)
        {
            if(a[i]==0)
            {
                d++;
                break;
            }
        }
        if(d!=0)
            cout<<"0";
        else{
        for(i=0;i<n;i++)
        {
            j=j/a[i];
            if(j==0)
            {
                c++;
                break;
            }
        }
         if(c!=0)
            cout<<"-1";
        else
        {
            for(i=0;i<n;i++)
                ans=ans*a[i];
            cout<<ans;
        }
        }


    return 0;
}


Measured memory_bytes: 4384
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    ll p[N];
    REP(i, 0, N) {
        cin >> p[i];
    }
    sort(p, p + N);
    ll ans = 0;
    REP(i, 0, K) {
        ans += p[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
ll n;
ll F(ll x) {
    ll ret = 1;
    for (ll i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            ret += 2;
            if (x / i == i) ret--;
        }
    }
    return ret;
}
ll G(ll x) {
    ll ret = 1, tp;
    for (ll i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            ll tmp = x / i;
            tp = x;
            while (tp % i == 0) {
                tp /= i;
            }
            if (tp > i) tp %= i;
            ret += (tp == 1);
            if (tmp != i) {
                tp = x;
                while (tp % tmp == 0) {
                    tp /= tmp;
                }
                if (tp > tmp) tp %= tmp;
                ret += (tp == 1);
            }
        }
    }
    return ret;
}
int main() {
    cin >> n;
    if (n == 2) {
        cout << 1;
        return 0;
    }
    cout << F(n - 1) + G(n);
    return 0;
}



Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
ans = 0
if n == 1:
  print(0)
  exit()
if n == 2:
  print(0)
  exit()
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if l[i] == l[j]:
        continue
      if l[i] == l[k]:
        continue
      if l[j] == l[k]:
        continue
      if l[i] >= l[j] + l[k]:
        continue
      if l[j] >= l[i] + l[k]:
        continue
      if l[k] >= l[i] + l[j]:
        continue
      ans += 1
print(ans)

Measured memory_bytes: 9220
from collections import Counter

R = lambda: map(int, input().split())
R()
d = Counter(R())
s = sum(d.elements())
q, = R()
for _ in range(q):
  b, c = R()
  s += (c - b) * d[b]
  print(s)
  d[c]+=d[b]
  d[b] = 0


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

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

  int size = (int)s.size(), index=0;
  string ans = "          ";
  for(int i = 0;i < size;i++) {
    if(s[i] == 'B') {
      if(index > 0) {
        index--;
        ans[index] = ' ';
      }
    } else {
      ans[index] = s[i];
      index++;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = Integer.parseInt(stdin.next());
		int A = Integer.parseInt(stdin.next());
		int B = Integer.parseInt(stdin.next());

		if(N+A+B >= 22) {
			out.println("bust");
		}
		else {
			out.println("win");
		}



		out.flush();
	}

}


Measured memory_bytes: 21716
import heapq
X,Y,Z,K=[int(i) for i in input().split()]
A=sorted([int(i) for i in input().split()],reverse=True)
B=sorted([int(i) for i in input().split()],reverse=True)
C=sorted([int(i) for i in input().split()],reverse=True)
#print(A)
#print(B)
#print(C)
Q=[(-A[0]-B[0]-C[0],0,0,0)]
heapq.heapify(Q)
ans=[]
S=set([(0,0,0)])
for _ in range(K):
  q=heapq.heappop(Q)
  ans+=[-q[0]]
  a=q[1]
  b=q[2]
  c=q[3]
  if a!=X-1 and not ((a+1,b,c) in S):
    heapq.heappush(Q,(-A[a+1]-B[b]-C[c],a+1,b,c))
    S.add((a+1,b,c))
  if b!=Y-1 and not ((a,b+1,c) in S):
    heapq.heappush(Q,(-A[a]-B[b+1]-C[c],a,b+1,c))
    S.add((a,b+1,c))
  if c!=Z-1 and not ((a,b,c+1) in S):
    heapq.heappush(Q,(-A[a]-B[b]-C[c+1],a,b,c+1))
    S.add((a,b,c+1))
for i in ans:
  print(i)
    

Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int slen=s.length()-1;
    int ans=1;
    for(int i =0;i<s.length()/2;i++)
    {
        if(s[i]!=s[slen])
        {
            ans=0;
            break;
        }
        slen--;
    }
    if(ans==1)
    {
        slen = (s.length()-1)/2-1;
        for(int i =0;i<s.length()/4;i++)
        {
            if(s[i]!=s[slen])
            {
                ans=0;
                break;
            }
            slen--;
        }
    }
    if(ans==1)
    {
        slen = s.length()-1;
        int slen2 = (s.length()+3)/2-1;
        for(int i =0;i<s.length()/4;i++)
        {
            if(s[slen2]!=s[slen])
            {
                ans=0;
                break;
            }
            slen2++;
            slen--;
        }
    }
    if(ans==1)
        cout<<"Yes";
    else
        cout<<"No";




}



Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        bool isFirst = true;
        int[] coins = new int[] { 10, 50, 100, 500 };
        int bill, ownedMoney, changeMoney;
        int[] ownedCoins = new int[4], changeCoins = new int[4], paymentCoins = new int[4];

        while (true)
        {
            bill = int.Parse(Console.ReadLine());
            if (bill == 0) break;
            if (isFirst) { isFirst = false; } else { Console.WriteLine(); }
            ownedCoins = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            ownedMoney = 0;
            for (int i = 3; i >= 0; i--)
                ownedMoney += coins[i] * ownedCoins[i];

            changeMoney = ownedMoney - bill;

            for (int i = 3; i >= 0; i--)
            {
                changeCoins[i] = changeMoney / coins[i];
                changeMoney = changeMoney % coins[i];
                paymentCoins[i] = ownedCoins[i] - changeCoins[i];
            }
            for (int i = 0; i <= 3; i++)
                if (paymentCoins[i] > 0) Console.WriteLine("{0} {1}", coins[i], paymentCoins[i]);
        }
    }
}


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

int main() {

	//ifstream cin("INPUT.txt");
	//ofstream cout("OUTPUT.txt");

	int n, m, i, j;
	int command[1001] = {0};
	int pos;
	int dice[1001] = {0};

	while(cin >> n >> m, n != 0 || m != 0) {

		for(i = 1; i <= n; i++) {
			cin >> command[i];
		}
		for(i = 1; i <= m; i++) {
			cin >> dice[i];
		}
		pos = 1;
		for(i = 1; i <= m; i++) {
			pos += dice[i];
			if(pos < n)
				pos += command[pos];
			if(pos >= n) {
				cout << i << endl;
				break;
			}
		}

}

	return 0;

}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <vector>

const uint64_t MOD = 1000 * 1000 * 1000 + 7;

template <uint8_t max_value, uint8_t mod_value>
struct index_mod {
  uint8_t mod[max_value];
  constexpr index_mod() : mod() {
    for (size_t i = 0; i < max_value; ++i) {
      mod[i] = i % mod_value;
    }
  }
};

template <uint8_t mod_value>
struct sub_index {
  uint8_t index[mod_value][mod_value - 10];
  constexpr sub_index() : index() {
    auto value = 0;
    uint8_t in[mod_value] = {0};
    for (size_t i = 0; i < mod_value; ++i) {
      value += 10;
      for (size_t j = 0; j < mod_value - 10; ++j) {
        // index[i][j] = (value + j) % mod_value;
        auto v = (value + j) % mod_value;
        index[v][in[v]] = i;
        ++in[v];
      }
    }
  }
};

int main() {
  std::string s;
  std::cin >> s;

  // i番目の文字を見た時に13との剰余がnになる個数を数え上げる
  std::vector<uint64_t> dp(2 * 13);

  constexpr index_mod<13 * 10, 13> imod;
  constexpr sub_index<13> sindex;

  // for (size_t i = 0; i < 13; ++i) {
  // for (size_t j = 0; j < 3; ++j) {
  //   std::cout << (int)sindex.index[i][j] << ",";
  // }
  // std::cout << std::endl;
  // }

  uint64_t row_sum = 0;

  {  // テーブル初期化
    int val = -1;
    if (s[0] != '?') val = s[0] - '0';
    if (val == -1) {
      for (size_t i = 0; i < 10; ++i) {
        dp[i % 13] = 1;
      }
      row_sum = 10;
    } else {
      dp[val % 13] = 1;
      row_sum = 1;
    }
    // % 13は不要だけど定義に帰るため
  }

  for (size_t i = 1, e = s.length(); i < e; ++i) {
    int val = -1;
    if (s[i] != '?') val = s[i] - '0';
    if (val == -1) {
      for (size_t here = 0; here < 13; ++here) {
        auto temp_sum = row_sum + 3 * MOD;
        for (size_t j = 0; j < 3; ++j) {
          temp_sum -= dp[sindex.index[here][j]];
        }
        dp[13 + here] = temp_sum;
      }
    } else {
      for (size_t pre = 0; pre < 13; ++pre) {
        auto &here_dp = dp[13 + imod.mod[pre * 10 + val]];
        const auto &pre_dp = dp[pre];
        here_dp = pre_dp;
      }
    }

    //     for (int i = 0; i < 2; ++i) {
    //     for (int j = 0; j < 13; ++j) {
    //       std::cout << dp[i * 13 + j] << ",";
    //     }
    //     std::cout << std::endl;
    //   }
    //
    row_sum = 0;
    for (size_t i = 0; i < 13; ++i) {
      dp[i] = dp[13 + i] % MOD;
      row_sum += dp[i];
      // dp[i] = dp[13 + i];
      dp[13 + i] = 0;
    }
    row_sum %= MOD;
  }

  std::cout << dp[5] % MOD << std::endl;
  return 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    int x; cin >> x;
    int acc = 0;
    for(int i=1;i<=x;i++){
        acc += i;
        if(acc >= x){
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

//最大公約数
//O(log max(a,b))
template<class T>
T GCD(T a, T b) {
	if (b == 0)return a;
	if (a < b)return GCD(b, a);
	return GCD(b, (T)(a % b));
}

long long A, B;
long long G;

int main() {
	cin >> A >> B;
	G = GCD<long long>(A, B);
	vector<long long> prime;
	for (long long p = 1; p * p <= G; p++) {
		if (G % p == 0) {
			prime.push_back(p);
			if (p * p != G)prime.push_back(G / p);
		}
	}
	sort(prime.begin(), prime.end());
	long long ans = 0;
	for (long long p : prime) {
		bool flag = false;
		for (long long n = 2; n * n <= p; n++) {
			if (p % n == 0) {
				flag = true;
				break;
			}
		}
		if (!flag)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
def maximal_value(b)
  sum = b[0]
  1.upto(b.size - 1) do |i|
    sum += [b[i - 1], b[i]].min
  end
  sum += b[-1]
  sum
end

n = gets.to_i
b = gets.split.map(&:to_i)
puts maximal_value(b)

Measured memory_bytes: 1788
use std::io;
use std::f32::consts::PI;

fn main() {
    let n: f32 = read::<f32>();

    println!("{}", n * 2.0 * PI);
}

fn read<T: std::str::FromStr>() -> T {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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


const string YES = "Yes";
const string NO = "No";

void func(std::string S, std::string T){

    T.pop_back();

    if(S==T)cout<<YES<<endl;
    else cout<<NO<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    func(S, T);
    return 0;
}


Measured memory_bytes: 3628
import math
n = int(input())

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

i = 0

while(True):
    if is_prime(n+i):
        print(n+i)
        exit()
    else:
        i += 1


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

using namespace std; 

int main() {
  int n,l; cin>>n>>l;
  vector<int> v;
  int x=1e9;
  for (int i=1; i<=n; i++) {
    int cur = l+i-1;
    if (abs(cur) < abs(x)) x=cur;
    v.push_back(cur);
  }
  int ans = 0;
  for (auto x: v) ans += x;
  ans -= x;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define tr(a,b) (a)+=(b);(b)=(a)-(b);(a)-=(b);


hsort(int *p,int n){
	int i,j;

	for(i=0;i<n;i++){
		for(j=i;j>0;j=(j-1)/2){
			if(p[j]>p[(j-1)/2]){
				tr(p[j],p[(j-1)/2]);
			}else{
				break;
			}
		}
	}

	for(i=n-1;i>0;i--){
		tr(p[0],p[i]);
		for(j=0;;){
			if(j*2+2<i && p[j*2+2]>p[j*2+1]){
				if(p[j*2+2]>p[j]){
					tr(p[j*2+2],p[j]);
					j=j*2+2;
					continue;
				}else{
					break;
				}
			}else if(j*2+1<i && p[j*2+1]>p[j]){
				tr(p[j*2+1],p[j]);
				j=j*2+1;
				continue;
			}else{
				break;
			}
		}
	}
	return 0;
}

main(){
	int N;
	int i,j;
	int r[9]={0,};
	int c=0;
	scanf("%d",&N);

	int a[N];

	for(i=0;i<N;i++){
		scanf("%d",a+i);
	}

	hsort(a,N);

	/*
	for(i=0;i<N;i++){
		printf("%d ",a[i]);
	}
	*/

	for(j=0,i=0;j<8;j++){
		for(;i<N;i++){
			if(a[i]<(j+1)*400)
				r[j]++;
			else
				break;
		}
	}
	r[8]=N-i;


	for(i=0;i<8;i++)
		if(r[i])
			c++;
	/*
	for(i=0;i<9;i++)
		printf("r[%d]:%d\n",i,r[i]);
	*/
	printf("%d %d\n",c==0?1:c, c+r[8]);

	return 0;
}


Measured memory_bytes: 128
N = int(input())
data = [[] for _ in range(N)]
for i in range(N):
    data[i] = [int(i) for i in input().split()]

#%%
dp = [[0] * 3 for i in range(N + 1)]
for i in range(1, N + 1):
    for j in range(3):
        temp = max(dp[i - 1][j - 1], dp[i - 1][j - 2])
        dp[i][j]= data[i - 1][j] + temp

ans = 0
for i in range(3):
    ans = max(ans, dp[N][i])

print(ans)


Measured memory_bytes: 48572
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i];
  for(int i=0; i<=N-M; i++) {
    for(int j=0; j<=N-M; j++) {
      bool flag=true;
      rep(k, M) {
        rep(l, M) {
          if(B[k][l] != A[i+k][j+l]) {
            flag = false;
            break;
          }
        }
      }
      if(flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int A;
  int B;
  int C;
  cin >>A>>B>>C;
  int x1=10*A+B+C;
    int x2=10*B+A+C;
    int x3=10*C+A+B;
   int y=max(max(x1,x2),x3);
  cout << y<< endl;
}

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

using namespace std;

typedef long long ll;

int main(){
  ll N,i;
  string S;
  ll ans = 0;
  map<string,ll> memo;
  cin >> N;
  for(i=0;i<=N-1;i++){
    cin >> S;
    memo[S] = 1;
  }
  for(auto&& x : memo) ans += memo[S];
  cout << ans << endl;
}



Measured memory_bytes: 19228
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ld Calc_Dist (ld X1, ld Y1, ld X2, ld Y2){
  ld ans = (X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2);
  ans = sqrtl(ans);
  return ans;
}

pair <ld, ld> Calc_P (ld X1, ld Y1, ld R1, ld R2){
  ld A = (X1 * X1 + Y1 * Y1 + R1 * R1 - R2 * R2) / 2;

  ld X = A * X1 + Y1 * sqrtl((X1 * X1 + Y1 * Y1) * R1 * R1 - A * A);
  X /= X1 * X1 + Y1 * Y1;

  ld Y = A * Y1 - X1 * sqrtl((X1 * X1 + Y1 * Y1) * R1 * R1 - A * A);
  Y /= X1 * X1 + Y1 * Y1;

  return make_pair(X, Y);
}

pair <ld, ld> Calc_Q (ld X1, ld Y1, ld R1, ld R2){
  ld A = (X1 * X1 + Y1 * Y1 + R1 * R1 - R2 * R2) / 2;

  ld X = A * X1 - Y1 * sqrtl((X1 * X1 + Y1 * Y1) * R1 * R1 - A * A);
  X /= X1 * X1 + Y1 * Y1;

  ld Y = A * Y1 + X1 * sqrtl((X1 * X1 + Y1 * Y1) * R1 * R1 - A * A);
  Y /= X1 * X1 + Y1 * Y1;

  return make_pair(X, Y);
}

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

  ld X[N], Y[N], C[N];
  for (int i = 0; i < N; i++){
    cin >> X[i] >> Y[i] >> C[i];
  }

  ld L = 0, R = 1e10;
  while (R - L > 1e-8){
    ld now = (L + R) / 2;

    vector <pair<ld, ld>> Cand;


    for (int i = 0; i < N; i++){
      Cand.push_back(make_pair(X[i], Y[i]));
      for (int j = i + 1; j < N; j++){
        ld Ri = now / C[i], Rj = now / C[j];
        ll Dist = Calc_Dist(X[i], Y[i], X[j], Y[j]);

        if (Dist < abs(Ri - Rj) - 1e-8) continue;
        if (Dist > Ri + Rj + 1e-8) continue;

        pair <ld, ld> P = Calc_P(X[j] - X[i], Y[j] - Y[i], Ri, Rj);
        P.first += X[i]; P.second += Y[i];
        pair <ld, ld> Q = Calc_Q(X[j] - X[i], Y[j] - Y[i], Ri, Rj);
        Q.first += X[i]; Q.second += Y[i];
        Cand.push_back(P);
        Cand.push_back(Q);
      }
    }
    
    bool flag = false;
    for (int i = 0; i < Cand.size(); i++){
      int cnt = 0;
      ld X_now = Cand[i].first, Y_now = Cand[i].second;

      for (int j = 0; j < N; j++){
        ld Dist = Calc_Dist(X_now, Y_now, X[j], Y[j]);
        if (Dist <= now / C[j] + 1e-8) cnt++;
      }
      if (cnt >= K) flag = true;
    }
    
    if (flag == true) R = now;
    else L = now;

  }
  cout << setprecision(16) << (L + R) / 2 << endl;

  return 0;
}


Measured memory_bytes: 384
N=int(input())
L=list(map(int,input().split()))

ans=0

for i in range(N):
    for j in range(i,N):
        for k in range(j, N):
            if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
                sum_edge=L[i]+L[j]+L[k]
                max_edge=max(L[i],L[j],L[k])
                if max_edge<(sum_edge-max_edge):
                    ans+=1

print(ans)

Measured memory_bytes: 8944
#include<iostream>

using namespace std;

int main()
{
	int A[3][3];
  	for(int i = 0; i < 3; i++)
      for(int j = 0; j < 3; j++)
      {
      	cin >> A[i][j];
      }
  	int N;
  	cin >> N;
  	int row[3] = {0, 0, 0};
  	int col[3] = {0, 0, 0};
  	int d1 = 0, d2 = 0;
  	while(N--)
    {
      	int b;
    	cin >> b;
      	for(int i = 0; i < 3; i++)
          for(int j = 0; j < 3; j++)
          {
          	if(A[i][j] == b)
            {
            	row[i]++;
              	col[j]++;
              	if(i == j) d1++;
              	if(i + j == 2) d2++;
                break;
            }
          }
    }
  	if(d1 == 3 || d2 == 3 || row[0] == 3 || row[1] == 3 || row[2] == 3 || 
      col[0] == 3 || col[1] == 3 || col[2] == 3)
      	cout << "Yes";
  	else
    	cout << "No";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	
	long long  a, b, k;
	cin >> a >> b >> k;

	if (k <= a) {
		cout << a - k << " " << b << endl;
	}
	else if (k <= a + b) {
		cout << 0 << " " << b - k + a << endl;
	}
	else {
		cout << 0 << " " << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#define MAXSIZE 10000
#define PI 3.141592653589
using namespace std;
int main(){
  int n;
  int a[MAXSIZE];
  std::cin >> n;
  for(int i=0;i<n;i++){
    std::cin >> a[i];
  }
  int max=a[0],min=a[0];
  long long sum=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
    if(a[i]>max){
      max=a[i];
    }
    if(a[i]<min){
      min=a[i];
    }
  }
  std::cout << min<<" "<<max<<" "<<sum << '\n';
}

Measured memory_bytes: 3104
Imports System

Module Program
    Sub Main(args As String())

        Dim NK() As Integer = Console.ReadLine().Split(" ").Select(Function(x) Integer.Parse(x)).ToArray()
        Dim N As Integer = NK(0)
        Dim K As Integer = NK(1)
        Dim A() As Integer = Console.ReadLine().Split(" ").Select(Function(x) Integer.Parse(x)).ToArray()

        For i As Integer = K + 1 To N

            Dim zenhyo As Long = A(i - K - 1)

            Dim hyoka As Long = A(i - 1)

            If zenhyo < hyoka Then
                Console.WriteLine("Yes")
            Else
                Console.WriteLine("No")
            End If

        Next

    End Sub

End Module


Measured memory_bytes: 46188
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        int K = RInt();

        long ans = 1;
        for (int i = 0; i < N; i++)
        {
            if (ans < K) ans *= 2;
            else ans += K;
        }
        WriteLine(ans);
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 27356