akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define endl '\n'

const ll MOD = 1000000007;

int main() {
   int n; scanf("%d", &n);
   vector<int> a(n);
   for (int &i : a)
      scanf("%d", &i);
   int m = *max_element(all(a));
   vector<int> check(m + 1);
   for (int i : a)
      check[i]++;
   int ans = 0;
   for (int i = 1; i <= m; i++) {
      if (check[i] >= 1) {
         if (check[i] == 1) ans++;
         for (int j = 2 * i; j <= m; j += i)
            check[j] = 0;
      }
   }
   printf("%d", ans);
   return 0;
}

Measured memory_bytes: 7888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll n,x;cin>>n>>x;
    ll e,ans;
    ans=0;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n-1;i++){
        e=max((ll)0,(a[i]+a[i+1])-x);
        ans+=e;
        a[i+1]=max((ll)0,a[i+1]-e);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int a, b;
    cin >> a >> b;

    if (a * b & 1) {
        print("Odd");
    } else {
        print("Even");
    }
    
}


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

int main() {

  int N, K;
  cin >> N >> K;
  
  int A = 1;
  int B = 1;
  int C = 1;
  
  for (int i = 0; i < N; i++) {
    B *= 2;
    C += K;
    
    if (B < C) {
      A *= 2;
    }
    else {
      A += K;
    }

    B = A;
    C = A;
  }
  cout << A << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int main(){
    ll N;
    ll ans=0,a;
    cin >> N;
    vector<ll> Sum(N+10,0);
    vector<ll> A(N+10,0);
    for (int i = 0; i < N; i++){
        cin >> a;
        A[i] = a;
        Sum[a-1]++;
    }
    for (ll i = 0; i < N; i++){
        if(Sum[i]>0){
            // cout << Sum[i] << endl;
            ans += Sum[i]*(Sum[i]-1)/2;
        }
    }
    // cout << ans << endl;
    for (ll i = 0; i < N; i++){
        ll tmp = ans;
        ll b = A[i];
        if(Sum[b-1]>1){
            tmp -= Sum[b-1]*(Sum[b-1]-1)/2;
            tmp += (Sum[b-1]-2)*(Sum[b-1]-1)/2;
        }
        cout << tmp << endl;
    }
    
}

Measured memory_bytes: 5760
import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
edges = [[] for _ in range(N+1)] #1-indexed
for i in range(N-1):
    a, b, c = lr()
    edges[a].append((b, c))
    edges[b].append((a, c))

INF = 10 ** 15
dist = [INF] * (N+1)
def set_dist(x, d):
    dist[x] = d
    for next, dd in edges[x]:
        if dist[next] != INF:
            continue
        set_dist(next, d + dd)


Q, K = lr()
set_dist(K, 0)
for i in range(Q):
    x, y = lr()
    print(dist[x] + dist[y])


Measured memory_bytes: 137224
#include <iostream>
#include <vector>
#include <set>

using namespace std;

typedef pair<int,int> P;

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

    vector<set<P> > kugi(N+1);

    for(int i=0; i<=N; ++i) {
        kugi[i].insert(P(0,i+1)); // [0,i+1)
    }

    int ans=0;
    for(int i=0; i<M; ++i) {
        int A,B,X;
        cin >> A >> B >> X;

        for(int j=0; j<=X; ++j) {
            int l=B-1, r=B+j; // [B-1,B+j) is rubber band area
            set<P>::iterator itr=kugi[A+j-1].begin();
            while(!kugi[A+j-1].empty() && itr!=kugi[A+j-1].end()) {
                if(r <= itr->first) break;
                if(itr->second <= l) {
                    ++itr;
                    continue;
                }
                if(l<=itr->first && itr->second<=r) {
                    ans+=itr->second-itr->first;
                    itr=kugi[A+j-1].erase(itr);
                    if(kugi[A+j-1].empty()) {
                        break;
                    }
                } else if(itr->first>=l && itr->second>r) {
                    int temp=itr->second;
                    ans+=r-itr->first;
                    kugi[A+j-1].erase(itr);
                    kugi[A+j-1].insert(P(r,temp));
                    break;
                } else if(itr->first<l && itr->second<=r) {
                    int temp=itr->first;
                    ans+=itr->second-l;
                    itr=kugi[A+j-1].erase(itr);
                    kugi[A+j-1].insert(P(temp,l));
                } else if(itr->first<l && itr->second>r) {
                    int templ=itr->first, tempr=itr->second;
                    ans+=r-l;
                    kugi[A+j-1].erase(itr);
                    kugi[A+j-1].insert(P(templ,l));
                    kugi[A+j-1].insert(P(r,tempr));
                    break;
                }
            }
        }
    }

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


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

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

    int n;cin>>n;
    vector<ll> v(n);
    map<ll,ll> even,odd;    
    for(int i=0;i<n;i++){
      cin>>v[i];
      if(i%2) odd[v[i]]++;
      else even[v[i]]++;
    }
    vector<P> a,b;
    for(auto itr=even.begin();itr!=even.end();itr++){
      P p=*itr;
      a.push_back(P(p.second,p.first));
    }
    for(auto itr=odd.begin();itr!=odd.end();itr++){
      P p=*itr;
      b.push_back(P(p.second,p.first));
    }
    // 個数, 値
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    int cnt=0;
    if(a.size()==1 && b.size()==1){
      if(a[0].second==b[0].second){
        cnt =n/2;
      }
      else{
        cnt = n;
      }
    }
    else if(a.size()==1){
      if(a[0].second==b[0].second){
        cnt = n/2;
        cnt += b[1].first;
      }
      else{
        cnt = n/2;
        cnt += b[0].first;
      }
    }
    else if(b.size()==1){
      if(a[0].second==b[0].second){
        cnt = n/2;
        cnt += a[1].first;
      }
      else{
        cnt = n/2;
        cnt += a[0].first;
      }
    }
    else{
      if(a[0].second!=b[0].second){
        cnt = a[0].first + b[0].first;
      }
      else{
        cnt = max(a[0].first + b[1].first, a[1].first + b[0].first);
      }
    }
    cout<<n-cnt<<endl;
}


Measured memory_bytes: 9592
import itertools as it
def erat():
    D = {9:3, 25:5}
    yield from [2, 3, 5]
    MASK = [1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0]
    MODULOS = (1, 7, 11, 13, 17, 19, 23, 29) 

    for q in it.compress(
            it.islice(it.count(7), 0, None, 2),
            it.cycle(MASK)):
        p = D.pop(q, None)
        if p is None:
            D[q*q] = q
            yield q
        else:
            x = q + 2*p
            while x in D or (x%30) not in MODULOS:
                x += 2*p
            D[x] = p


n = int(input())
l = 0
ans = []
for p in erat():
    if p % 5 == 1:
        ans.append(p)
        l += 1
        if l >= n:
            break
print(*ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	long long ans = 0;
	for (int a = 1; a <= n; a++) {
		if (n % a == 0 and n / a == 1) continue;
		ans += n / a - (n % a == 0);
	}
	cout << ans << "\n";
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    if (N == 1) {
        cout << "Yes\n2\n1 1\n1 1\n";
        return 0;
    }
    if (N == 2) {
        cout << "No\n";
        return 0;
    }
    int t = 2;
    while (t*(t-1)/2 < N) t++;
    if (t*(t-1)/2 > N) {
        cout << "No\n";
    }
    else {
        cout << "Yes\n" << t << endl;
        vector<vector<int>> ans(t, vector<int>());
        int cnt = 1;
        for (int i = 0; i < t-1; i++) {
            for (int j = i+1; j < t; j++) {
                ans[i].push_back(cnt);
                ans[j].push_back(cnt);
                cnt++;
            }
        }
        for (int i = 0; i < t; i++) {
            cout << t-1;
            for (int n : ans[i]) cout << " " << n;
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2304
N, M = map(int, input().split())
xs = [list(map(int, input().split())) for _ in range(N)]
xs = sorted(xs)

ans = 0
m = M
for x in xs:
    c = min(m, x[1])
    ans += x[0] * c
    m -= c
    if c == 0:
        break

print(ans)


Measured memory_bytes: 28648
#include <stdio.h>

int main(void)
{
    int X, Y;
    char c;
    int sum = 0;
    
    
    scanf("%d%c", &X, &c);
    scanf("%d", &Y);
    
    
    switch(X)
    {
        case 1:
            sum += 300000;
            break;
        case 2:
            sum += 200000;
            break;
        case 3:
            sum += 100000;
    }
    
    
    switch(Y)
    {
        case 1:
            sum += 300000;
            break;
        case 2:
            sum += 200000;
            break;
        case 3:
            sum += 100000;
    }
    
    
    if(X == 1 && Y == 1)
        sum += 400000;
    
    
    printf("%d\n", sum);
    
    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>


typedef long long ll;
#define fi first
#define se second
const ll mod = 1000000007;
//              123456789

using namespace std;

///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int a;
int n;
int sml=1000;
int big=0;


int main(){
  
  int i;
  
  cin>>n;
  
  for( i = 0; i < n; i++ ){
    cin>>a;
    sml = min( a, sml );
    big = max( a, big );
  }
  
  cout<<big-sml<<endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long n, ma, mb;
  std::vector<std::array<long, 3>> xs;
  Solver() {
    S002 reader;
    reader >= n >= ma >= mb >n>= xs;
  }
  void solve() {
    long dp[256][256];
    for(long i = 0; i < 256; ++i) for(long j = 0; j < 256; ++j) dp[i][j] = (1 << 29);
    dp[0][0] = 0;
    for(long i = 0; i < n; ++i) {
      for(long j = 255; j >= 0; --j) {
        for(long k = 255; k >= 0; --k) {
          long j2 = j - xs[i][0];
          long k2 = k - xs[i][1];
          if( j2 < 0 or k2 < 0 ) continue;
          dp[j][k] = std::min(dp[j][k], dp[j2][k2] + xs[i][2]);
        }
      }
    }
    long res = (1 << 29);
    for(long i = 1; ; ++i) {
      long x = ma * i, y = mb * i;
      if( x >= 256 or y >= 256 ) break;
      res = std::min(res, dp[x][y]);
    }
    printf("%ld\n", res == (1 << 29) ? -1 : res);
  }
  ~Solver() { fprintf(stderr, "--end--\n"); }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 768
/******************
*  Author: BD747  *
******************/
//dreamoon
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

#define SZ(X) ((int)(X).size())
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define RI(X) scanf("%d", &(X))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define PB push_back
#define MS1(X) memset((X), -1, sizeof((X)))
typedef long long LL;

const int MOD=1e9+7;
const int SIZE=1e6+10;
int input[SIZE][3],ma[SIZE],an[SIZE],bfs[SIZE];
vector<int> e[SIZE];

void go(int in[]){
	int x=in[0]-1,dd=in[1],v=in[2];
	if(dd<=ma[x])return;
	ma[x]=dd;
	bfs[0]=x;
	int rr=1;
	REP(i,rr){
		int x=bfs[i];
		if(!an[x])an[x]=v;
		if(!ma[x])continue;
		REP(j,SZ(e[x])){
			int y=e[x][j];
			int nd=ma[x]-1;
			if(nd>ma[y]){
				ma[y]=nd;
				bfs[rr++]=y;
			}
		}
	}
}

int main(){
	DRII(N,M);
	REP(i,M){
		DRII(x,y);x--;y--;
		e[x].PB(y);
		e[y].PB(x);
	}
	DRI(Q);
	REP(i,Q)REP(j,3)RI(input[i][j]);
	MS1(ma);
	for(int i=Q-1;i>=0;i--){
		go(input[i]);
	}
	REP(i,N)printf("%d\n",an[i]);
	return 0;
}

Measured memory_bytes: 36856
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace

solve :: String -> Int
solve s = sub 0 0 s

sub !num_b !val [] = val
sub !num_b !val ('B':s) = sub (num_b + 1) val s
sub !num_b !val ('W':s) = sub num_b (val + num_b) s

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_s]:remLines1 = remLines0
      s = B.unpack bs_s
  in solve s

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


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

void print_path(int k, char d)
{
    for (int i = 0; i < k; i++)
    {
        cout << d;
    }
}

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int lx = tx - sx, ly = ty - sy;
    print_path(ly, 'U');
    print_path(lx + 1, 'R');
    print_path(ly + 1, 'D');
    print_path(lx + 1, 'L');
    print_path(1, 'U');
    print_path(1, 'L');
    print_path(ly + 1, 'U');
    print_path(lx + 1, 'R');
    print_path(ly + 1, 'D');
    print_path(lx, 'L');
    cout << endl;
}

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

using namespace std;


int main(){

    string S; string T;
    cin >> S;
    cin >> T;

    int count = 0;
    for(int i=0 ; i< 3 ; i++){
        if(S[i] == T[i]){
            count ++ ;
        }
    }

    cout << count;



    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	static Scanner in = new Scanner(System.in);
 
	public static void main(String[] args) {
		String s = in.next();
		int S = 0, E = 0;
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) == 'A'){
				S = i;
				break;
			}
		}
		for(int i = s.length() - 1; i > -1; i--){
			if(s.charAt(i) == 'Z'){
				E = i;
				break;
			}
		}
		System.out.println(E - S + 1);
	}
}

Measured memory_bytes: 28324
n = int(input())
c = 0
c1=0
for x in range(n):
  a,b = map(int,input().split())
  if a==b:
    c+=1
    if c==3:
        c1 = 1
        print('Yes')
        break
  else:
    c=0
if c1==0:
    print('No')


Measured memory_bytes: 9104
#include <iostream>
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define reverse(s) reverse(s.begin(), s.end());
#define p pair<int,int>
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

ll f(int n) {
	switch(n){
	case 0:
		return 1;
	case 1:
		return 1;
	case 2:
		return 2;
	case 3:
		return 3;
	case 4:
		return 5;
	case 5:
		return 8;
	case 6:
		return 13;
	case 7:
		return 21;
	case 8:
		return 34;
	}
	return 1;
}

int main() {
	ll h, w, k;
	cin >> h >> w >> k;
	if (w == 1) {
		cout << 1 << endl;
		return 0;
	}
	vector<vector<ll>> a(h+1);
	rep(i, h+1) {
		a[i].resize(w);
	}
	a[0][k-1] = 1;
	FOR(i,1,h+1) {
		rep(j, w) {
			if (j == 0) {
				a[i][j] = (f(w - 1)*a[i - 1][0] + f(w - 2)*a[i - 1][1]) % mod;
			}
			else if (j == w - 1) {
				a[i][j] = (f(w - 1)*a[i - 1][w-1] + f(w - 2)*a[i - 1][w-2]) % mod;
			}
			else {
				a[i][j] =( f(j - 1) * f(w - j-1) * a[i - 1][j - 1] +
					f(j) * f(w - j-1)* a[i - 1][j] +
					f(j) * f(w - j - 2) * a[i - 1][j + 1])%mod;
			}
			
		}
	}
	cout << a[h][0] << endl;


}
	

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

using namespace std;

typedef long double cod;
using ld = cod;
double eps = 1e-7;
bool eq(cod a, cod b){ return abs(a - b) <= eps; }

struct vec{
	cod x, y; int id;
	vec(cod a = 0, cod b = 0) : x(a), y(b) {}
	vec operator+(const vec &o) const{
		return {x + o.x, y + o.y};
	}
	vec operator-(const vec &o) const{
		return {x - o.x, y - o.y};
	}
	vec operator*(const ld r) const {
		return {x * r, y * r};
	}
	cod operator*(const vec &o) const{ // cos
		return x * o.x + y * o.y;
	}
	cod len() const{
		return sqrtl(x * x + y * y); // <
	}
	cod len2() const{
		return (x * x + y * y); // <
	}
};

ld EPS = 1e-6;
// intersection of line a * x + b * y + c = 0
// and circle centered at the origin with radius r
vector<vec> f(ld r, ld a, ld b, ld c) {
	vector<vec> ans;

	ld x0 = -a*c/(a*a+b*b), y0 = -b*c/(a*a+b*b);
	if(c*c > r*r*(a*a+b*b)+EPS) {

	}
	else if(abs(c*c - r*r*(a*a+b*b)) < EPS){
		ans.push_back(vec(x0, y0));
	}
	else {
		ld d = r*r - c*c/(a*a+b*b);
		ld mult = sqrt (d / (a*a+b*b));
		ld ax, ay, bx, by;
		ax = x0 + b * mult;
		bx = x0 - b * mult;
		ay = y0 - a * mult;
		by = y0 + a * mult;
		ans.push_back(vec(ax, ay));
		ans.push_back(vec(bx, by));
	}
	return ans;
}

struct circle {
	vec c; cod r;
	circle() : c(0, 0), r(0) {}
	circle(const vec o, cod val = 0) : c(o), r(val) {}
	bool inside(const vec &a) const {
		return (a - c).len2() <= r * r + EPS;
	}
	vector<vec> inter(const circle &o) const {
		ld d2 = (c - o.c).len2();
		if(d2 > (r + o.r) * (r + o.r) + EPS) return vector<vec>();
		if(d2 + EPS < (r - o.r) * (r - o.r)) return vector<vec>();

		auto c2 = o.c - c;

		auto ans = f(r, -2 * c2.x, -2 * c2.y, (c2 * c2) + r * r - o.r * o.r);
		for(vec &p : ans) p = p + c;
		return ans;
	}
};

const int N = 66;
int n, k;
int x[N], y[N], c[N];

circle h[N];

int f(ld t) {
	for(int i = 0; i < n; i++) {
		h[i] = circle(vec(x[i], y[i]), t / c[i]);
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			for(vec p : h[i].inter(h[j])) {
				int tmp = 0;
				for(int w = 0; w < n; w++) {
					tmp += h[w].inside(p);
				}
				ans = max(ans, tmp);
			}
		}
	}
	for(int i = 0; i < n; i++) {
		int tmp = 0;
		for(int j = 0; j < n; j++) {
			tmp += h[j].inside(h[i].c);
		}
		ans = max(ans, tmp);
	}
	return ans;
}

int main() {

	/*auto aa = circle(vec(1, 0), 2);
	auto bb = circle(vec(3, 0), 2);

	for(vec p : aa.inter(bb)) {
		cout << p.x << " " << p.y << endl;
	}*/

	scanf("%d %d", &n, &k);
	if(k == 1) return printf("0\n"), 0;

	for(int i = 0; i < n; i++) scanf("%d %d %d", x + i, y + i, c + i);

	ld lo = 0, hi = 1e9;

	for(int it = 0; it < 200; it++) {
		auto mid = (lo + hi) / 2;
		// int val = f(mid);
		// printf("%Lf -> %d\n", mid, val);
		if(f(mid) >= k) hi = mid;
		else lo = mid;
	}
	printf("%.20Lf\n", lo);

}


Measured memory_bytes: 512
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue>
#define ll long long
using namespace std;
int a[200005];
int book[200005];
int main()
{
   int n,k;
   scanf("%d %d",&n,&k);
   for(int i=0;i<n;i++)
   scanf("%d",&a[i]);
   sort(a,a+n);
   //memset(book,0,sizeof(book));
   int t=1;
   book[t]=1;
   for(int i=1;i<n;i++)
   {
   	  if(a[i]==a[i-1])
   	  book[t]++;
   	  else
   	  {
   	  	t++;
   	  	book[t]++;
		 }
   	  
   	  //printf("%d\n",book[t]);
   }
   //printf("%d\n",t);
   if(t<=k)
   printf("0\n");
   else
   {
   	 sort(book+1,book+t+1);
   int sum=0;
   for(int j=1;j<=t-k;j++)	
   {
   	  sum+=book[j];
   	  //printf("%d\n",sum);
   }
  printf("%d\n",sum);
   }
  
	
	return 0;
	
}

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

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

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    int k, x; cin >> k >> x;
    if (k * 500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define rep(i, n) for(long long i=0;i<n;i++)
using ll = long long;
const ll INF = (1LL<<60);

int main(){

    ll n; cin >> n;
    string s; cin >> s;

    ll cnt = 0;
    rep(i, n-2){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
    }

    cout << cnt << endl;

    return 0;
}

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

using namespace std;

int mp[1000];
int res;
int n;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		char ch = 0;
		while(ch > 'Z' || ch < 'A') ch = getchar();
		if(!mp[ch]) mp[ch]++;
	}
	res += mp['P'] + mp['W'] + mp['Y'] + mp['G'];
	printf(res == 4 ? "Four\n" : "Three\n");
	return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] times = ScannerUtils.readIntArray(in, n);
            int sum = 0;
            for (int time : times) {
                sum += time;
            }

            int drinksCount = in.nextInt();
            while (drinksCount-- > 0) {
                int probMod = in.nextInt() - 1;
                int newTime = in.nextInt();

                int newSum = sum - times[probMod] + newTime;
                out.println(newSum);
            }
        }

    }

    static class ScannerUtils {
        public static int[] readIntArray(Scanner in, int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 23764
#include <stdio.h>

int main(void)
{
    int sn;
    double w, h;
    double bmi;
    
    while (scanf("%d,%lf,%lf", &sn, &w, &h)!= EOF){
        bmi = w / (h * h);
        if (bmi >= 25.0){
            printf("%d\n", sn);
        }
    }
    
    return (0);
}

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

int main() {
  int a,b,c,ans = 0;
  cin >> a >> b >> c;
  for(int i = a; i <= b; i++) {
    if(c%i == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3112
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

#ifdef LOCAL
#include<prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int P, Q, R;
    cin >> P >> Q >> R;

    cout << min(P+Q, min(Q+R, R+P)) << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int a[3], i, j;
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	for (i = 0; i < 3; i++) {
		for (j = 2; j > i; j--) {
			if (a[j] > a[j - 1]) {
				int tmp;
				tmp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = tmp;
			}
		}
	}
	printf("%d\n", a[2] + a[1]);
	return 0;
}

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

int main(){
  int n, d, x; cin >> n >> d >> x;
  
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    x += (d-1)/a + 1;
  }
  
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define NMAX (200000)
using namespace std;

int main(void) {
	
	int X[NMAX];
	int Y[NMAX];
	int N;
	cin >> N;

	
	for(int i=0; i<N; i++) {
		cin >> X[i];
		Y[i] = X[i];
	}
	sort(X, X+N);
	int Bunder = X[(N/2)-1];
	int Bupper = X[(N/2)];

	for(int i=0; i<N; i++) {
		if(Y[i] <= Bunder)
			cout << Bupper << endl;
		else 
			cout << Bunder << endl;
	}
	

	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  co(n*n*3)
}

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

int main() {
    int n,k,q;cin>>n>>k>>q;
    int a[n];
    fill(a,a+n,k-q);
    for (int i=0;i<q;i++) {
        int t;cin>>t;
        t--;
        a[t]++;
    }
    for (int i=0;i<n;i++)
        cout<<(a[i]>0?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 1024
import itertools
import math

distance = lambda p,q: ((p[0]-q[0])**2+(p[1]-q[1])**2)**(0.5)

def solve():
    N = int(input())
    xy = [list(map(int, input().split())) for _ in range(N)]
    distances = [[0 for _ in range(N)] for _ in range(N)]
    for p1,p2 in itertools.combinations(range(N), 2):
        distances[p1][p2] = distance(xy[p1],xy[p2])
        
    ret = 0
    total = math.factorial(N)
    for ps in itertools.permutations(range(N), N):
        s = ps[0]
        for p in ps[1:]:
            s_ = s; p_ = p
            if s > p: s_,p_ = p_,s_
            ret += distances[s_][p_]
            s = p
            
    print(ret / total)
    
solve()

Measured memory_bytes: 3064
k=int(input())
a=[]
judge=0
a.append("")
a.append(7%k)
for i in range(2,k+1):
    a.append((a[i-1]*10+7)%k)
for i in range(1,k+1):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)



Measured memory_bytes: 48472
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

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

bool judge(int *a, int n, int k){
    rep(i, n){
        if (a[i+1] != k) return false;
    }
    return true;
}

int main(){
    int n, k; cin >> n >> k;
    int a[n+2], b[n+2];
    rep(i, n) cin >> a[i+1];
    rep(t, k){
        rep(i, n+1) b[i] = 0;
        for (int i = 1; i < n+1; ++i){
            b[max(0, i-a[i])] ++;
            b[min(n+1, i+a[i]+1)] --;
        }
        for (int i = 1; i < n+2; ++i){
            b[i] += b[i-1];
        }
        if (judge(b, n, n)) break;
        rep(i, n) a[i+1] = b[i+1];
    }
  	cout << b[1];
  	for (int i = 2; i < n+1; ++i){
      	cout << ' ' << b[i];
    }
  	cout << "\n";
}


Measured memory_bytes: 5152
import java.util.*;

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

        int num = sc.nextInt();
        int count = 0;
        int high = 0;
        int[] mt = new int[num];

        for(int i = 0;i < num;i++){
            mt[i] = sc.nextInt();
        }

        high = mt[0];
        for(int i = 0;i < num;i++){
            if(high <= mt[i]){
                count++;
            }
            if(high < mt[i]){
                high = mt[i];
            }
            
        }
        System.out.println(count);
    }
}

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

using namespace std;

void Main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ac = a * c;
    long long ad = a * d;
    long long bc = b * c;
    long long bd = b * d;
    long long ans = max(ac, ad);
    ans = max(ans, bc);
    ans = max(ans, bd);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli t,i,j,n,x;
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC";
    }
    else{
        cout<<"ABC";
    }
}

Measured memory_bytes: 3652
fn main() {
    proconio::input! {
        n: usize,
        m: usize,
    }
    let mut inv=vec![1;m+2];
    for i in 2..=m {
        inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    }
    let mut t=0;
    let mut a=1;
    let mut b=1;
    let mut c=1;
    for i in 0..n {
        c=c*(m-i)%MOD;
    }
    for i in 0..=n {
        let v=a*b%MOD*c%MOD*c%MOD;
        let v=if i&1==0 {v} else {MOD-v};
        t=(t+v)%MOD;
        a=a*(n-i)%MOD*inv[i+1]%MOD;
        b=b*(m-i)%MOD;
        c=c*inv[m-i]%MOD;
    }
    println!("{}",t);
}
const MOD: usize=1000000007;

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

int main()
{
    int k;
    cin >> k;

    if (k % 2 == 0 || k % 5 == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    int n, ans;
    for (ans = 1, n = 7; ans <= 1000000; ans++)
    {
        n = n % k;
        if (n == 0)
            break;
        n = n * 10 + 7;
    }

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


Measured memory_bytes: 3648
n, m = map(int, input().split())
br = [False] * (n+1)
for _ in range(m):
    x = int(input())
    br[x] = True

mod = 1000000007
dp = [0] * (n+1)
dp[0] = 1
if not br[1]:
    dp[1] = 1
for i in range(2, n+1):
    if not br[i]:
        dp[i] = (dp[i-1] + dp[i-2]) % mod
print(dp[n])

Measured memory_bytes: 7796
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=1;
  cin >> n;
  vi a(n),b(n);
  REP(i,n) cin>>a[i];


  double af=0;

  REP(i,n)
  {
    af+=log(a[i]);
    ans*=a[i];
  }
  


  if (af>41.45){
    ans=-1;
  }else{
    if (ans>1000000000000000000)ans=-1;
  }

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

Measured memory_bytes: 4848
#include<stdio.h>
#include<ctype.h>
int main(void){
  char c;
  int count[26]={0};
  int i=0;


  while(scanf("%c", &c)!= EOF){
    c = tolower(c);
    count[c - 'a']++;
   }

  for(i=0;i<26;i++){
    printf("%c : %d\n",'a'+i, count[i]);

  }
  return 0;
}

Measured memory_bytes: 1808
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
long long a,b,aa,bb;
long long c,d,tmp;
while(cin>>a>>b){
        if(a < b)swap(a,b);
        aa=a;
        bb=b;
        while(b!=0){
                tmp = a%b;
                a = b;
                b = tmp;
        }
        c=aa*bb/a;
        cout<<a<<' '<<c<<endl;
}
        return 0;
}
 

Measured memory_bytes: 1156
def calc(lhs, op, rhs)
  # opが0なら加算
  if op == 0
    lhs + rhs
  else
    lhs - rhs
  end
end

def to_op(bit)
  if bit == 0
    '+'
  else
    '-'
  end
end

BIT_NUM = 3

def main
  nums = ARGF.gets.chars.map(&:to_i)

  # bit mask の生成
  0.upto((1 << BIT_NUM) - 1) do |mask|

    a = nums[0]
    # 各bitを下から舐める
    0.upto(BIT_NUM - 1)  do |i|
      # 加算 or 減算
      a = calc(a, mask[i], nums[i+1])
    end

    if a == 7
      puts "#{nums[0]}#{to_op(mask[0])}#{nums[1]}#{to_op(mask[1])}#{nums[2]}#{to_op(mask[2])}#{nums[3]}=7"
      return
    end
  end

  puts 'error'  # 問題の前提上、ありえない
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, b, e) for (ll i = (ll)b; i < (ll)e; i++)
#define rep0(i, n) REP(i, 0ll, n)
#define rep1(i, n) REP(i, 1ll, n + 1)
const ll longinf = 1ll << 60;
const int inf = (1 << 30) - 1;

int main() {
  ll n;
  cin >> n;
  ll s[n];
  rep0(i, n) {
    cin >> s[i];
  }
  ll ans = 0;
  rep1(d, n - 1) {
    if ((n - 1) % d == 0) {
      ll p = (n - 1) / d;
      ll pos = 0;
      rep0(i, p + 1) {
        if (d * i != n - 1 - d * i && d * (i - 1) != n - 1 - d * i) {
          pos += (s[d * i] + s[n - 1 - d * i]);
          ans = max(pos, ans);
        } else {
          break;
        }
      }
    } else {
      long long sum = 0;
      int L = 0, R = n - 1;
      while (L + d < n - 1) {
        sum += s[L] + s[R];
        L += d;
        R -= d;
        ans = max(ans, sum);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int flgs = 0;
string s;

bool solve(int & indx) {
	bool inv = false;
	bool res;
	if(s[indx] == '-') {
		indx++;
		res = !solve(indx);
	}
	else if(s[indx] == '(') {
		bool a, b;
		int type;
		indx++;
		a = solve(indx);
		if(s[indx] == '*') type = 0;
		else if(s[indx] == '+') type = 1;
		else {type = 2; indx++;}
		indx++;
		b = solve(indx);
		indx++;
		if(type == 0)
			res = a && b;
		else if(type == 1)
			res = a || b;
		else
			res = !a || b;
	}
	else if(s[indx] == 'T') {
		res = true;
		indx++;
	}
	else if(s[indx] == 'F') {
		res = false;
		indx++;
	}
	else {
		res = flgs & (1 << (s[indx] - 'a'));
		indx++;
	}

	return res;
}

int main() {
	while(1) {
		cin >> s;
		if(s == "#")
			break;
		bool f = true;
		for(flgs = 0; flgs < (1 << 11); flgs++) {
			bool a, b;
			int indx = 0;
			a = solve(indx);
			indx++;
			b = solve(indx);
			if(a != b)
				f = false;
		}
		if(f)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 1208
# coding: utf-8
# Your code here!

try:
   l = []
   for i in range(28):
      l.append(int(input()))

   for i in range(1, 31):
      if i not in l:
         print(i)

except EOFError:
   pass

#for i in range(1, 31):
   #if l[i] == 0:
      #print(i)


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] d = new int[n];
		for ( int i = 0; i < n; i++ ) {
			d[i] = in.nextInt();
		}

		int ans = 0;
		for ( int p = 0; p < n; p++ ) {
			for ( int c = p + 1; c < n; c++ ) {
				ans += d[p] * d[c];
			}
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 21844
void main() {
    import std.stdio, std.string, std.conv, std.algorithm, std.range, std.array, std.math;
    int N, H;
    readf("%d %d\n", &N, &H);
    int[] as, bs;
    foreach (i; 0..N) {
        int a, b;
        readf("%d %d\n", &a, &b);
        as ~= a;
        bs ~= b;
    }
    as = sort(as).array;
    bs = sort(bs).array;
    int cnt = 0;
    while (H > 0) {
        if (!bs.empty && as.back < bs.back) {
            H -= bs.back;
            bs.popBack();
            cnt++;
        } else {
            cnt += H / as.back + ((H % as.back) ? 1 : 0);
            H = 0;
        }
    }
    writeln(cnt);
}


Measured memory_bytes: 4348
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=100000;
int p = 1000000007;
int log2_p_MAX = 32;
// 1/a (mod p) = a^(p-2) (mod p)
long long felmer(long long a)
{
  // a^(2^i) mod p
  long long rem[log2_p_MAX];
  rem[0] = a%p;
  for(int i=1;i<log2_p_MAX;i++)
    rem[i] = (rem[i-1]*rem[i-1])%p;
  long long res = 1;
  long long expo = p-2;
  for(int i=0;i<log2_p_MAX;i++){
	if(expo%2==1){
      res *= rem[i];
      res = res%p;
    }
  	expo /= 2;
  }
  return res;
}
int main()
{
  int n,k,i;
  long long t,res=0;
  long long a[N_MAX],b[N_MAX],f[N_MAX];
  cin >> n >> k;
  for(i=0;i<n;i++)
    cin >> a[i];
  sort(a,a+n);
  b[0]=1;
  f[0]=1;
  b[1]=1;
  f[1]=1;
  for(i=2;i<n;i++){
    b[i]=(b[i-1]*i)%p;
    f[i]=(f[i-1]*felmer(i))%p;
  }
  for(i=0;i<=n-k;i++){
    t=(a[i+k-1]*b[i+k-1])%p;
    t*=f[k-1];
    t%=p;
    t*=f[i];
    t%=p;
    res=(res+t)%p;
    t=(a[i]*b[n-i-1])%p;
    t*=f[k-1];
    t%=p;
    t*=f[n-k-i];
    t%=p;
    res=(res-t)%p;
  }
  if(res<0) res+=p;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {

  static Scanner scan = new Scanner(System.in);

  public static void main(String[] args) {
    String s = scan.next();

    Map<Integer, Integer> modToCount = new HashMap<>();
    int curMod = 0;
    int tenthMod = 0;
    int m = 2019;

    long count = 0;

    for (int i = s.length() - 1; i >= 0; i--) {
      int digit = s.charAt(i) - '0';

      if (i == s.length() - 1) {
        tenthMod = 1;
      }
      else {
        tenthMod = (tenthMod * 10) % m;
      }
      curMod = (curMod + digit * tenthMod) % m;

      if (curMod == 0) {
        count++;
      }

      if (modToCount.containsKey(curMod)) {
        count += modToCount.get(curMod);
      }

      // System.out.println(digit +" " + count);

      if (modToCount.containsKey(curMod)) {
        modToCount.put(curMod, modToCount.get(curMod) + 1);
      }
      else {
        modToCount.put(curMod, 1);
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 47536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
struct union_find{
    vector<int> par;
    vector<int> rank;
    vector<int> siz;
    union_find(int sz){
        par.resize(sz);
        rank.assign(sz,0);
        siz.assign(sz,1);
        for(int i=0;i<sz;i++) par[i]=i;
    }
    int find(int a){
        if(par[a]==a) return a;
        else return par[a] = find(par[a]);
    }
    void unite(int a,int b){
        if(find(a)==find(b)) return;
        int root_a,root_b;
        root_a=find(a),root_b=find(b);
        if(rank[root_a]>rank[root_b]){
            par[root_b]=root_a;
            siz[root_a]+=siz[root_b];
        }else if(rank[root_a]<rank[root_b]){
            par[root_a]=root_b;
            siz[root_b]+=siz[root_a];
        }else{
            rank[root_a]++;
            par[root_b]=root_a;
            siz[root_a]+=siz[root_b];
        }
    }
    bool same(int a,int b){return find(a)==find(b);}
    int size(int a){
        return siz[find(a)];
    }
};
 
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> v(m);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        v[i].first=a;
        v[i].second=b;
    }
    union_find uf(n);
    vector<ll> ans(m+1);
    ans[m]=n*(n-1ll)/2ll;
    for(int i=m-1;i>=0;i--){
        if(uf.find(v[i].first-1)==uf.find(v[i].second-1)){
            ans[i]=ans[i+1];
        }else{
            ans[i]=ans[i+1]-uf.size(v[i].first-1)*uf.size(v[i].second-1);
        }
        uf.unite(v[i].first-1,v[i].second-1);
    }
    for(int i=1;i<m+1;i++){
        cout<<ans[i]<<endl;
    }
}
 

Measured memory_bytes: 4096
N = int(input())
S = input()
result = 0
for i in range(1,N-1):
    a, b = ("G","B") if S[i] == "R" else ("R","B") if S[i] == "G" else ("R","G")
    mae = S[:i]
    ushiro = S[i+1:]
    result += mae.count(a) * ushiro.count(b)
    result += mae.count(b) * ushiro.count(a)
    result -= sum([(a == mae[-1-j] and b == ushiro[j]) or (b == mae[-1-j] and a == ushiro[j]) for j in range(min(len(mae),len(ushiro)))])
print(result)

Measured memory_bytes: 9272
fun main(args: Array<String>){
  val n = readLine()!!.toInt()
  val lStr = readLine()!!.split(" ")
  val l = IntArray(n){ lStr[it].toInt() }
  l.sort()

  var result = 0
  for( i in 0 until n-2 ) for( j in i+1 until n-1 ) for( k in j+1 until n ){
    if( l[i] + l[j] <= l[k] )
      break
    result++
  }

  println(result)
}


Measured memory_bytes: 53352
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

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

int dp[100005][5];
int main() {
   int n;
   cin >> n;
   vector<int> a(n), b(n), c(n);
   rep(i, 0, n) cin >> a[i] >> b[i] >> c[i];
   dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];

   rep(i, 0, n - 1) {
      chmax(dp[i + 1][0], dp[i][1] + a[i + 1]);
      chmax(dp[i + 1][0], dp[i][2] + a[i + 1]);
      chmax(dp[i + 1][1], dp[i][0] + b[i + 1]);
      chmax(dp[i + 1][1], dp[i][2] + b[i + 1]);
      chmax(dp[i + 1][2], dp[i][0] + c[i + 1]);
      chmax(dp[i + 1][2], dp[i][1] + c[i + 1]);
   }
   cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;
   return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
	int n, i, *A, k;
	cin >> n;
	A = new int(n);
	r(i, n)
		cin >> A[i];

	int  j, v;
	for (i = 1; i < n; i++)
	{
		r(k, n)
		{
			if (k)cout << " ";
			cout << A[k];
		}
		cout << endl;
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v)
		{
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
	}

	r(k, n)
	{
		if (k)cout << " ";
		cout << A[k];
	}
        cout<<endl;
	return 0;
}



Measured memory_bytes: 3000