akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    char C[N];
    for(int i=0;i<N;i++){
        scanf("%c",&C[i]);
    }
    int y=0;
    for(int j=0;j<N;j++){
        if(C[j]=='Y')y++;
        else;
    }
    
    if(y>0)printf("Four\n");
    else printf("Three\n");
    return 0;
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){

  string s; cin >> s;
  ll ans = 0;
  char p = '2';
  rep(i,s.length()){
    if(s[i]==p){
      ans ++;
      if(p=='0') p = '1';
      else p = '0';
    }else{
      p = s[i];
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;

int main()
{
    ll n, m,ac=0,wa=0;
    cin>>n>>m;
    vector<bool> b(100001,false);
    vector<ll> wav(100001);
    
    for (ll i = 0; i < m;i++){
        ll p;
        string s;
        cin >> p >> s;
        if(!b[p]&&s=="WA"){
            wav[p]++;
        }
        else if(!b[p]&&s=="AC"){
            ac++;
            b[p] = true;
        }
    }
    for (ll i = 1; i <= n;i++){
        if(b[i]){
            wa += wav[i];
        }
    }
    cout << ac << " " << wa << endl;

}


Measured memory_bytes: 1024
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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 end

ll calc(ll g, ll b, ll r){
    return max(g, max(b, r)) - min(g, min(b, r));
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h, w, gh, gw, bh, bw, rh, rw, score = INF;
    in >> h >> w;
    REP(i, h-1){
        gh = i + 1;
        gw = w;

        bw = w;
        rw = w;
        bh = int((h - gh) / 2.0);
        rh = h - gh - bh;
        chmin(score, calc(gh*gw, bh*bw, rh*rw));

        bw = int(w / 2.0);
        rw = w - bw;
        bh = h - gh;
        rh = h - gh;
        chmin(score, calc(gh*gw, bh*bw, rh*rw));
    }
    REP(i, w-1){
        gw = i + 1;
        gh = h;
    
        bw = int((w - gw) / 2.0);
        rw = w - gw - bw;
        bh = h;
        rh = h;
        chmin(score, calc(gh*gw, bh*bw, rh*rw));

        bw = w - gw;
        rw = w - gw;
        bh = int(h / 2.0);
        rh = h - bh;
        chmin(score, calc(gh*gw, bh*bw, rh*rw));
    }

    out << score << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int result = 0, rest_min = 10, food_time;
    for (int i=0; i<5; i++) {
        cin >> food_time; 
        result += (int)ceil((float)food_time/10)*10;
        if (food_time%10 != 0) rest_min = min(rest_min, food_time%10);
    }
    result -= 10;
    result += rest_min;

    cout << result << endl;
}

Measured memory_bytes: 256
#define ll long long
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
//#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
ll pi = acos(-1) ;
ll z =  1000000007 ;
ll inf = 100000000000000000 ;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll fact[100] ;
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
ll min(ll a , ll b){if(a < b) return a ; return b ;}
ll left(ll i){return ((2*i)+1) ;}
ll right(ll i){return ((2*i) + 2) ;}
ll ncr(ll n , ll r){if(n < r) return 0 ; return ((((fact[n] * inverse(fact[r] , z)) % z) * inverse(fact[n-r] , z)) % z);}
void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
//__builtin_popcount(n) -> returns number of set bits in n


void solve()
{
    
    ll n ;
    string str ;
    cin >> n >> str ;
    vector<ll> a , b , c ;
    fo(i , n)
    {
        if(str[i] == 'R')
            a.pub(i) ;
        if(str[i] == 'B')
            b.pub(i) ;
        if(str[i] == 'G')
            c.pub(i) ;
    }
    ll ans = (a.size() * b.size() * c.size()) ;
    //cout << ans << endl ;
    for(ll diff = 1 ; diff < n ; diff++)
    {
        for(ll i = 0 ; i < n ; i++)
        {
            ll j = i + diff ;
            ll k = j + diff ;
            if(k >= n)
                break ;
            if(!(str[i] == str[j] || str[j] == str[k] || str[k] == str[i]))
                ans-- ;
        }
    }
    cout << ans << endl ;
    return ;
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif*/
   
    ll t ;
    //cin >> t ;
    t = 1 ;
    while(t--)
    {
        solve() ;
    }
    //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
    return 0;
}

Measured memory_bytes: 3756
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    queue<int> ready;
    vector<vector<int>> A(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            cin >> A[i][j];
            A[i][j]--;
        }
        ready.push(i);
    }

    vector<int> ptr(n);
    vector<vector<bool>> state(n, vector<bool>(n));
    int ans = 0;
    while (!ready.empty()) {
        ans++;
        queue<int> next_ready;
        while (!ready.empty()) {
            int q = ready.front();
            ready.pop();
            int peer = A[q][ptr[q]];
            state[q][peer] = true;
            if (state[peer][q]) {
                ptr[q]++;
                ptr[peer]++;
                if (ptr[q] < n - 1) next_ready.push(q);
                if (ptr[peer] < n - 1) next_ready.push(peer);
            }
        }

        while (!next_ready.empty()) {
            ready.push(next_ready.front());
            next_ready.pop();
        }
    }

    bool ok = true;
    for (int i = 0; i < n; i++) {
        if (ptr[i] != n-1) {
            ok = false;
            break;
        }
    }

    cout << (ok ? ans : -1) << '\n';
    return 0;
}

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

int main(){
	int n;
  	map<string,int> mp;
  	cin>>n;
  	for(int i=0;i<n;i++){
    	string s;
      	cin>>s;
      	if(mp.find(s)==mp.end()){
        	mp[s]=0;
        }
      	mp[s]++;
    }
  	cin>>n;
  	for(int i=0;i<n;i++){
    	string s;
      	cin>>s;
      	if(mp.find(s)==mp.end()){
        	mp[s]=0;
        }
      	mp[s]--;
    }
  	int ans=0;
  	for(auto p:mp){
    	ans=max(ans,p.second);
    }
  	cout<<ans<<endl;
}

Measured memory_bytes: 256
line = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())

print(line[k-1])

Measured memory_bytes: 3060
s = gets.chomp.reverse
strings = ["dream","dreamer","erase","eraser"].map(&:reverse)
while s != ""
	flag = false
	strings.each do |t|
		if s.slice(0,t.size) == t
			s.slice!(0,t.size)
			flag = true
		end
	end
	break if !flag
end

puts s == "" ? "YES" : "NO"

Measured memory_bytes: 106716
#include <stdio.h>

int main(void)
{
	long long int t,a,k;
	scanf("%lld%lld%lld",&t,&a,&k);
	if(t >= k){
		printf("%lld %lld\n",t-k,a);
	}
	else if(t+a >= k){
		printf("0 %lld\n",t+a-k);
	}
	else{
		printf("0 0\n");
	}
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int n;
string s,t;
int main(){
	cin>>n;
	cin>>s>>t;
	REP(i,n){
		cout<<s[i]<<t[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}	

int main() {

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

	int n;
	cin >> n;

	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	int fm = 0;
	for (int i = 0; i < n; ++i) {
		fm += (a[i] - 1);
	}

	cout << fm << "\n";

	return 0;

}

Measured memory_bytes: 256
import java.util.*;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] R = new int[N];
		for(int i = 0; i < N; i++){
			R[i] = sc.nextInt();
		}
		double[] pos = new double[N];
		double max = 0;
		for(int i = 0; i < N; i++){
			double pp = R[i];
			for(int j = 0; j < i; j++){
				double c = R[j] + R[i];
				double a = Math.abs(R[j] - R[i]);
				double b = Math.sqrt(c * c - a * a);
				pp = Math.max(pp, b + pos[j]);
			}
			pos[i] = pp;
			max = Math.max(pos[i] + R[i], max);
		}
		System.out.printf("%.8f\n", max);
	
	}

}

Measured memory_bytes: 29512
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  string s; cin >> s;
  int len = s.length();
  int l = 0, r = 0;
  bool O = false;
  int ans = 0;
  FOR(i,0,len) {
    if(s[i] == 'O') {
      if(!O) {
        O = true;
        l = i;
      }
    } else {
      if(O) {
        r = i - 1;
        O = false;
        int k = r - l + 1;
        bool ok = true;
        FOR(j,0,k) {
          r++;
          l--;
          if(r >= len || l < 0) ok = false;
          if(s[r] != 'I') ok = false;
          if(s[l] != 'J') ok = false;
          if(!ok) break;
        }
        if(ok) ans = max(ans, k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

template< class T >
struct CumulativeSum2D {
  vector< vector< T > > data;

  CumulativeSum2D(int W, int H) : data(W + 1, vector< int >(H + 1, 0)) {}

  void add(int x, int y, T z) {
    ++x, ++y;
    if(x >= data.size() || y >= data[0].size()) return;
    data[x][y] += z;
  }

  void build() {
    for(int i = 1; i < data.size(); i++) {
      for(int j = 1; j < data[i].size(); j++) {
        data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
      }
    }
  }

  T query(int sx, int sy, int gx, int gy) {
    return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
  }
};

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

  int n,m,q;
  cin >> n >> m >> q;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  CumulativeSum2D<int> points(m,n),yoko(m,n),tate(m,n);

  rep(i,n)rep(j,m){
    if(s[i][j]=='1'){
      points.add(j,i,1);
    }
  }
  rep(i,n)rep(j,m-1){
    if(s[i][j]=='1' && s[i][j+1]=='1'){
      yoko.add(j+1,i,1);
    }
  }
  rep(i,n-1)rep(j,m){
    if(s[i][j]=='1' && s[i+1][j]=='1'){
      tate.add(j,i+1,1);
    }
  }
  points.build();
  yoko.build();
  tate.build();

  rep(i,q){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    swap(x1,y1);
    swap(x2,y2);
    --x1;--y1;

    // cout << points.query(x1,y1,x2,y2) << " " << yoko.query(x1+1,y1,x2,y2) << " " <<  tate.query(x1,y1+1,x2,y2) << endl;
    cout << points.query(x1,y1,x2,y2) -(yoko.query(x1+1,y1,x2,y2) + tate.query(x1,y1+1,x2,y2)) << endl;
  }
  
  return 0;
    

}


Measured memory_bytes: 53248
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
    string s;cin>>s;
    int ans=1000;
    for(int i=0;i<=s.size()-3;i++){
        int sub=atoi(s.substr(i,3).c_str());
        ans=min(ans,abs(753-sub));
    }
    cout<<ans<<endl;
}


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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    if ((a%k == 0) || (b%k == 0)) {cout << "OK" << endl; return 0;}
    if (a/k < b/k) {cout << "OK" << endl; return 0;}
    else cout << "NG" << endl;
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    long double sum=0;
    sum=(long double) v[0];
    for(int i=1;i<n;i++) sum=(sum+v[i])/(long double)2;
    cout<<fixed<<setprecision(7)<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
# B - Christmas Eve Eve

#  N
N = int(input())
my_list = []

for i in range(0, N):
    my_list.append(int(input()))

my_list = sorted(my_list, reverse=True)
my_list[0] = int(my_list[0] / 2)
answer = sum(my_list)

print(answer)


Measured memory_bytes: 9180
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>

struct Queue {
	char name[128];
	int time;
};

int head = 0, tail = 0, n;
struct Queue Q[100000];

void enqueue(struct Queue);
struct Queue dequeue();

int main() {
	struct Queue a;
	int q, i, t = 0, cnt = 0;
	scanf("%d%d", &n, &q);
	for (i = 0; i < n; i++) scanf("%s %d", Q[i].name, &Q[i].time);
	while (cnt != n) {
		a = dequeue();
		if (a.time <= q) {
			t += a.time;
			printf("%s %d\n", a.name, t);
			++cnt;
		}
		else {
			t += q;
			a.time -= q;
			enqueue(a);
		}
	}
	return 0;
}

void enqueue(struct Queue a) {
	Q[tail] = a;
	if (tail + 1 == n) tail = 0;
	else ++tail;
}

struct Queue dequeue() {
	struct Queue a;
	a = Q[head];
	if (head + 1 == n) head = 0;
	else ++head;
	return a;
}

Measured memory_bytes: 8784
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int mod = 1000000007;
const int INF = 1001001001;

vector<long long> fct(0),invfct(0);

long long modpow(long long a,long long n, long long mod){
    long long res = 1;
    while(n>0){
        if ( n & 1 ) res = (res * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

void fct_input(long long maximum,long long mod){
    fct.resize(maximum+1,-1);
    fct.at(0) = 1;
    fct.at(1) = 1;
    long long x = 1;
    for(long long i=2;i<=maximum;i++){
        x = x * i % mod;
        fct.at(i) = x;
    }
 }

void invfct_input(long long maximum,long long mod){
    invfct.resize(maximum+1,-1);
    invfct.at(0) = 1;
    invfct.at(1) = 1;
    long long x = 1;
    for(long long i=2;i<=maximum;i++){
        x = x * i % mod;
        invfct.at(i) = modpow(x,mod - 2,mod);
    }
}

ll nck(int n,int k){
  if(n<k) return 0;
  return ((invfct.at(k) * invfct.at(n-k) % mod) * fct.at(n) ) % mod; 
}

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

  fct_input(n,mod);
  invfct_input(n,mod);

  vector<ll> a(n);
  rep(i,n) cin >> a.at(i), a.at(i)+=1e9;
  sort(a.begin(),a.end());
  ll minus = 0, plus = 0;
  
  rep(i,n) plus = (plus + (((a.at(i)) * nck(i,k-1))%mod))%mod;
  rep(i,n) minus = (minus + (((a.at(i) * nck(n-1-i,k-1))%mod)))%mod;
  ll ans = (plus-minus)%mod;
  if(ans<0) ans+=mod;
  cout << ans << endl;


  /*
  rep(i,n-k+1) minus = (minus+((n-k+1-i)%mod)*(a.at(i)%mod))%mod;
  rep(i,n-k+1) plus  = (plus+((n-k+1-i)%mod)*(a.at(n-1-i)%mod))%mod;
  cout << plus-minus << endl;
  */
}


Measured memory_bytes: 2560
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            if(ret != null) Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = long.Parse(spl[0]);
        var b = long.Parse(spl[1]);
        var c = long.Parse(spl[2]);
        var d = long.Parse(spl[3]);

        long x1 = a*c;
        long x2 = a*d;
        long x3 = b*c;
        long x4 = b*d;

        return Math.Max(x1, Math.Max(x2, Math.Max(x3, x4)));
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 27436
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n ;
int main ( ){
  int a , b , c;

  cin >> a >> b >> c ;
  cout << min ( b/a , c);
return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char grid1[4], grid2[4];

    scanf("%s", grid1);
    scanf("%s", grid2);

    if(grid1[0] == grid2[2] && grid1[1] == grid2[1] && grid1[2] == grid2[0])
        printf("YES");
    else
        printf("NO");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

typedef pair<int, int> pii;

int fi(int f[], int x) {
    return f[x] == x ? x : (f[x] = fi(f, f[x]));
}

int main() {
    int n, m;
    cin >> n >> m;
    pii ba[n];
    for (int i = 0; i < n; i++) {
        cin >> ba[i].second >> ba[i].first;
    }
    sort(ba, ba+n);
    reverse(ba, ba+n);

    int f[m+1];
    for (int i = 0; i <= m; i++) {
        f[i] = i;
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (ba[i].second <= m && fi(f, m + 1 - ba[i].second)) {
            int t = fi(f, m + 1 - ba[i].second);
            ans += ba[i].first;
            f[t] = fi(f, t - 1);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

using namespace std;

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

int main() {
	
	int N, M;
	cin >> N >> M;
	vector<int>root(M*2);
	vector<int>cnt(N, 0);


	rep(i, 0, M*2) {
		cin >> root[i];
	}

	for (int i = 0; i < root.size();i++) {
		cnt[root[i] - 1]++;
	}


	for (int i = 0; i < cnt.size(); i++) {
		cout << cnt[i] << endl;
	}
	
	return 0;
}

 

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

int main() {
  string S, T;
  cin >> S >> T;
  int times = S.size() - T.size() + 1;
  vector<int> C(times);
  
  for (int i = 0; i < times; i++) {
    int Ct = 0;
    for (int j = 0; j < T.size(); j++) {
      if (S.at(j + i) != T.at(j)) {
        Ct = Ct + 1;
      }
    C.at(i) = Ct;
    }
  }
  
  sort(C.begin(), C.end());
  
  cout << C.at(0); 
 
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

const char bd='b'^'d';
const char pq='p'^'q';


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

	string t=s;
	reverse(begin(t),end(t));
	for(auto &c:t){
		if(c=='b' or c=='d') c^=bd;
		if(c=='p' or c=='q') c^=pq;
	}

	cout << ((s==t)?"Yes":"No") << endl;

	return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

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

	cin >> a >> b >> c;

	if (a == b)cout << c << endl;
	else if (a == c)cout << b << endl;
	else cout << a << endl;

	return 0;
}

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

string S;

void solve(){
    map<string, int> t;
    t["SUN"] = 0;
    t["MON"] = 1;
    t["TUE"] = 2;
    t["WED"] = 3;
    t["THU"] = 4;
    t["FRI"] = 5;
    t["SAT"] = 6;
    cout << 7 - t[S];
}
int main(){
    cin >> S;
    solve();
    return 0;
}

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

#define INF_LL (int64)1e18
//#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

class UnionFind{
private:
    ::std::vector<int_fast32_t> par, edge;
    size_t n;

public:
    UnionFind(){}
    UnionFind(size_t n):n(n){
        par.resize(n, -1);
        edge.resize(n, 0);
    }

    uint_fast32_t find(uint_fast32_t x){
        return par[x] < 0 ? x : par[x] = find(par[x]);
    }

    size_t size(uint_fast32_t x){
        return -par[find(x)];
    }

    bool unite(uint_fast32_t x, uint_fast32_t y){
        x = find(x);
        y = find(y);
        edge[x] += 1;
        if(x == y) return false;
        if(size(x) < size(y)) std::swap(x, y);
        par[x] += par[y];
        edge[x] += edge[y];
        par[y] = x;
        return true;
    }

    bool same(uint_fast32_t x, uint_fast32_t y){
        return find(x) == find(y);
    }

    size_t esize(uint_fast32_t x) {
        return edge[find(x)];
    }
};

int64 N;
vector<int64> c;
vector<PLL> G[112345];

void build(int v, int col, int p) {
    c[v] = col;
    REP(i, G[v].size()) {
        if (G[v][i].sc == p) continue;
        build(G[v][i].sc, col^(G[v][i].fs%2), v);
    }
}

int main(void) {
    cin >> N;
    c = vector<int64>(N, -1);
    REP(i, N-1) {
        int64 u, v, w;
        cin >> u >> v >> w; u--; v--;
        G[u].emplace_back(w, v);
        G[v].emplace_back(w, u);
    }
    build(0, 0, -1);
    REP(i, N) {
        cout << c[i] << endl;
    }
}


Measured memory_bytes: 11264
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  3005;
const ll   mod   =  1e9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   LEVEL =  log2(N)+1;

ll test = 1, n, m, k, a[N][N], dp[N][N][4];

ll mem(int i, int j, int no){
	if(i == n and j == m){
		if(no == 3) return 0;
		return a[i][j];
	}
	if(dp[i][j][no] != -1) return dp[i][j][no];
	ll ans = 0;
	if(i != n){
		ans = max(ans,mem(i+1,j,0));
		if(no != 3) ans = max(ans,mem(i+1,j,0)+a[i][j]);
	}
	if(j != m){
		ans = max(ans,mem(i,j+1,no));
		if(no != 3) ans = max(ans,mem(i,j+1,no+1)+a[i][j]);
	}
	return dp[i][j][no] = ans;
}

void solve(){
	mset(dp,-1);
	cin >> n >> m >> k;
	for(int i = 1; i <= k; i++){
		ll r, c, v; cin >> r >> c >> v;
		a[r][c] = v;
	}
	deb1(mem(1,1,0))
}

int main(){
	GODSPEED;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

Measured memory_bytes: 356668
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,m;
  cin>>n>>m;
  std::vector<int> a(n);
  int sum=0;
  for(auto&& e: a) 
  {
    cin>>e;
    sum+=e;
  }
  sort(a.begin(), a.end(),greater<int>());
  if((double)a[m-1]>=sum/4.0/m) cout<<"Yes";
  else cout<<"No";
}

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

def main():
    n,k=map(int,readline().split())
    ab=[list(map(int,l.split())) for l in read().splitlines()]
    
    ek=0
    while k>>ek:
        ek+=1
    ans=0
    for i in range(ek):
        if k>>i&1:
            m=(k>>(i+1))<<(i+1)|((1<<i)-1)
            ans=max(ans,sum([e[1] for e in ab if e[0]|m==m]))
    ans=max(ans,sum([e[1] for e in ab if e[0]|k==k]))
    print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 35824
# -*- coding: utf-8 -*-

import math

def main():

	n = input()
	l = map(int,raw_input().split())
	minimum = l[0]
	maximum = l[0]
	summation = 0
	for i in l:
		if i < minimum:
			minimum = i
		if i > maximum:
			maximum = i
		summation += i
	print('%d %d %d' % (minimum,maximum,summation))

if __name__ == "__main__":

	main()


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

int main()
{
   string s;
   cin>>s;
   if(s=="SUN"){
    cout<<'7';
   }
   else if (s=="MON"){
    cout<<'6';
   }
   else if (s=="TUE"){
    cout<<'5';
   }
   else if (s=="WED"){
    cout<<'4';
   }
   else if (s=="THU"){
    cout<<'3';
   }
   else if (s=="FRI"){
    cout<<'2';
   }
   else if (s=="SAT"){
    cout<<'1';
   }
    return 0;
}


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

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		if(A-2*B<0) {
			System.out.println("0");
		} else {
			System.out.println(A-2*B);
		}
		sc.close();
	}
}


Measured memory_bytes: 23764
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<String> s = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			s.add(sc.next());
		}
		int innerAB = 0;
		int leftCount = 0;
		int rightCount = 0;
		int bothCount = 0;
		for (String str : s) {
			for (int i = 0; i < str.length() - 1; i++) {
				if (str.charAt(i) == 'A' && str.charAt(i + 1) == 'B') {
					++innerAB;
				}
			}
			if (str.charAt(0) == 'B' && str.charAt(str.length() - 1) == 'A') {
				++bothCount;
			} else {
				if (str.charAt(0) == 'B') {
					++leftCount;
				}
				if (str.charAt(str.length() - 1) == 'A') {
					++rightCount;
				}
			}
		}
		int result = innerAB;
		while (true) {
			if (bothCount > 0 && (leftCount > 0 || rightCount > 0)) {
				--bothCount;
				++result;
			} else if (bothCount > 1) {
				--bothCount;
				++result;
			} else if (rightCount > 0 && leftCount > 0) {
				--rightCount;
				--leftCount;
				++result;
			} else if (bothCount > 0 && (rightCount > 0 || leftCount > 0)) {
				--bothCount;
				if (rightCount > 0) {
					++leftCount;
				} else {
					++rightCount;
				}
				++result;
			} else {
				break;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 32128
#include <stdio.h>
#define TRUE 1
#define FAULSE 0
#define N 20
#define M 2000

int solve( int [], int, int );
int n;

int main (){
    int q, A[N], Q[M], i;

    //input area
    scanf("%d", &n);
    for (i = 0; i<n; i++)
	scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i<q; i++)
	scanf("%d", &Q[i]);

    //check whether we can synthesize the A-number frome the Q-number
    for (i = 0; i<q; i++){
	if (solve(A, 0, Q[i]) == TRUE )
	    printf("yes\n");
	else 
	    printf("no\n");
    }
    return 0;
}

int solve(int A[], int x, int m ){

    if (m == 0)
	return TRUE;
    
    if (x >= n)
	return FAULSE;

    if (solve( A, x+1, m-A[x] ) == TRUE) return TRUE; //choice version
    if (solve( A, x+1, m) == TRUE) return TRUE;//non-choice version
    else 
	return FAULSE;
}



Measured memory_bytes: 2104
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int w,h;
  int d[5]={0,1,0,-1,0};
  while(1){
    cin>>w>>h;
    if(w+h==0)break;
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    queue<pii> q;
    int white[50][50]={},black[50][50]={};

    rep(i,h)rep(j,w)if(s[i][j]=='W')q.push(pii(i,j));
    while(q.size()){
      int x=q.front().first;
      int y=q.front().second;
      q.pop();
      rep(i,4){
	int nx=x+d[i];
	int ny=y+d[i+1];
	if(nx>=0 && nx<h && ny>=0 && ny<w &&
	   s[nx][ny]=='.' && white[nx][ny]==0){
	  white[nx][ny]++;
	  q.push(pii(nx,ny));
	}
      }
    }

    rep(i,h)rep(j,w)if(s[i][j]=='B')q.push(pii(i,j));
    while(q.size()){
      int x=q.front().first;
      int y=q.front().second;
      q.pop();
      rep(i,4){
        int nx=x+d[i];
        int ny=y+d[i+1];
        if(nx>=0 && nx<h && ny>=0 && ny<w &&
           s[nx][ny]=='.' && black[nx][ny]==0){
          black[nx][ny]++;
          q.push(pii(nx,ny));
	}
      }
    }

    int a=0,b=0;
    rep(i,h)rep(j,w)
      if(black[i][j]&&white[i][j]==0)a++;
      else if(black[i][j]==0&&white[i][j])b++;
    cout<<a<<" "<<b<<endl;
  }
}

Measured memory_bytes: 3132
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
Manzoku=sum(B)
for i in range(N-1):
  if A[i]+1==A[i+1]:
    Manzoku += C[A[i]-1]
print(Manzoku)

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

  int A1,A2,A3;

  cin >> A1 >> A2 >> A3 ;

  if(A1+A2+A3 <22){
  
  cout << "win" << endl;

  }else{
    cout << "bust" << endl;
  }

}

Measured memory_bytes: 256
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
print(l[a-1])


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
static const int INFTY=2000000000;
static const int N=100;
int main(){
    int n,p[N+1],m[N+1][N+1];
    cin>>n;
    for(int i=1;i<=n;i++) cin>>p[i-1]>>p[i];
    for(int i=1;i<=n;i++) m[i][i]=0;
    for(int l=2;l<=n;l++){
        for(int i=1;i<=n-l+1;i++){
            int j=i+l-1;
            m[i][j]=INFTY;
            for(int k=i;k<j;k++)
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
        }
    }
    cout<<m[1][n]<<"\n";
    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Pt = complex<double>;
vector<Pt> circleCircle(Pt o1, double r1, Pt o2, double r2) {
    Pt d = o2 - o1;
    double d2 = norm(d);
    if (d2 == 0) return {};
    double pd = (d2 + r1*r1 - r2*r2) / 2;
    double h2 = r1*r1 - pd*pd/d2;
    if (h2 >= 0) {
        Pt p = o1 + d*pd/d2;
        Pt h = d * Pt(0, 1) * sqrt(h2/d2);
        return {p-h, p+h};
    }
    return {};
}
int main() {
    int N, K; cin >> N >> K;
    vector<int> X(N), Y(N), C(N);
    for (int i = 0; i < N; i++) cin >> X[i] >> Y[i] >> C[i];
    auto f = [&](double t) {
        for (int i = 0; i < N; i++) {
            int cnt = 0;
            Pt p = Pt(X[i], Y[i]);
            for (int k = 0; k < N; k++) {
                Pt c = Pt(X[k], Y[k]);
                if (abs(c - p) <= t / C[k]) cnt++;
            }
            if (cnt >= K) return true;
        }
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                Pt a = Pt(X[i], Y[i]);
                Pt b = Pt(X[j], Y[j]);
                vector<Pt> pts = circleCircle(a, t / C[i], b, t / C[j]);
                for (auto p : pts) {
                    int cnt = 0;
                    for (int k = 0; k < N; k++) {
                        if (k == i || k == j) cnt++;
                        else {
                            Pt c = Pt(X[k], Y[k]);
                            if (abs(c - p) <= t / C[k]) cnt++;
                        }
                    }
                    if (cnt >= K) return true;
                }
            }
        }
        return false;
    };
    double ok = 1e9, ng = 0;
    for (int i = 0; i < 100; i++) {
        double mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);

template<typename T>
class UnionFind {
public:
//以下公開

	//親の番号を格納する。親である場合は-(その集合のサイズ)
	vector<T> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(T N) {
		Parent = vector<T>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	T root(T A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}//代入しておくことで参照を速くする
 
	//自分のいるグループの頂点数を調べる
	T size(T A) {
		return -Parent[root(A)];
	}//親である場合は-(その集合のサイズ)なので、Ａの親の
 
	//AとBをくっ付ける
	bool connect(T A, T B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}

    bool same(T A,T B){
        return root(A)==root(B);
    }
};

signed main(){
    ll n,m;cin>>n>>m;
    vector<vector<ll>> hlist(m,vector<ll>(0));

    rep(i,n){
        ll k;cin>>k;

        for(int j=0;j < k;j++)
        {
            ll l;cin>>l;
            l--;
            hlist.at(l).pb(i);
        }
    }

    UnionFind<ll> uf(n);

    for(int i=0;i < m;i++)
    {
        for(int j=1;j < siz(hlist[i]);j++)
        {
            uf.connect(hlist[i][j],hlist[i][0]);
        }
    }

    if(uf.size(1)==n){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 4736
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n), b(n), c(n - 1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i];
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += b[i];
		if (i) {
			if (a[i] - a[i - 1] == 1) {
				ans += c[a[i - 1]];
			}
		}
	}
	dump(ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>


using namespace std;

int main(){


//Q2
string str, str2;
	string tmp;
	vector<string> buf;
	long num[2];
	long roop = 0;


	//str = "314159265 358979323 84";
	//stringstream ss(str);

	//std::getline(ss, tmp, ' ');
	cin	 >> num[0];// = atoi(tmp.c_str());
	//std::getline(ss, tmp, ' ');
	cin >> num[1];// = atoi(tmp.c_str());
	//std::getline(ss, tmp, ' ');
	cin >> roop;// = atoi(tmp.c_str());


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

		int turn = i % 2;//どっちのターンか

		//奇数なら一枚食べる
		if (num[turn] % 2 == 1){
			num[turn]--;
		}
		else{
			//偶数は何もしない
		}

		//半分譲渡
		num[1 - turn] += num[turn] * 0.5;
		num[turn] *= 0.5;

	}

	cout << num[0] << " " << num[1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b;
  while(1){
    scanf("%d %d",&a,&b);
    if(a == 0 && b == 0 ) break;  

    if(a>b)printf("%d %d\n",b,a);
    if(b>=a)printf("%d %d\n",a,b);
  }

  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

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

    int L = scanner.nextInt();
    int N = scanner.nextInt();
    int[] x = new int[N];
    int[] y = new int[N];
    for (int i = 0; i < N; i++) {
      x[i] = scanner.nextInt();
      y[N - i - 1] = L - x[i];
    }
    long[] x2 = new long[N + 1];
    long[] y2 = new long[N + 1];
    for (int i = 1; i <= N; i++) x2[i] = x2[i - 1] + x[i - 1] * 2L;
    for (int i = 1; i <= N; i++) y2[i] = y2[i - 1] + y[i - 1] * 2L;

    long max = x[N - 1];
    for (int n = N - 1; n > 0; n--) {
      int m = N - n;
      if (n > m) {
        max = Math.max(max, Math.max(
            x2[n - 1] - x2[n - m - 1] + y2[m] - y2[0] + x[n - 1],
            x2[n] - x2[n - m] + y2[m - 1] - y2[0] + y[m - 1]
        ));
      } else {
        max = Math.max(max, Math.max(
            x2[n - 1] - x2[0] + y2[m] - y2[m - n] + x[n - 1],
            x2[n] - x2[0] + y2[m - 1] - y2[Math.max(m - n - 1, 0)] + y[m - 1]
        ));
      }
    }
    max = Math.max(max, y[N - 1]);
    System.out.println(max);
  }
}


Measured memory_bytes: 93552
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const ll mod = 1000000000+7;

struct Matrix{
    vector<vector<ll>>data;
    ll row, col;
    Matrix(){}
    Matrix(ll row, ll col){
        this->row = row;
        this->col = col;
        data.resize(row);
        rep(i, row) data[i].resize(col);
    }
    const vector<ll> operator[](ll row)const{
        return this->data[row];
    }
    vector<ll>& operator[](ll row){
        return this->data[row];
    }
    /*
     * rowとcolが計算できる状態
     */
    Matrix operator+(const Matrix& a) const{
        Matrix tmp(this->row, this->col);
        if(this->row != a.row && this->col != a.col)    return tmp;
        rep(i, this->row)   rep(j, this->col)   (tmp[i][j] = (*this)[i][j] + a[i][j]) %= mod;
        return tmp;
    }
    Matrix operator-(const Matrix& a) const{
        Matrix tmp(this->row, this->col);
        if(this->row != a.row && this->col != a.col)    return tmp;
        rep(i, this->row)   rep(j, this->col)   (tmp[i][j] = (mod + (*this)[i][j] - a[i][j])) %= mod;;
        return tmp;
    }
    Matrix operator*(const Matrix& a) const{
        Matrix tmp(this->row, a.col);
        if(this->col != a.row)  return tmp;
        rep(i, this->row)   rep(j, a.row){
            rep(k, this->col)   (tmp[i][j] += (*this)[i][k]*a[k][j]) %= mod;
        }
        return tmp;
    }
    Matrix operator+=(const Matrix& a){
        return (*this)+a;
    }
    Matrix operator-=(const Matrix& a){
        return (*this)-a;
    }
    Matrix operator*=(const Matrix& a){
        return (*this)*a;
    }
    Matrix pow(ll n){
        if(n == 1){
            return *this;
        }
        if(n%2 == 0){
            Matrix tmp = this->pow(n/2);
            return tmp*tmp;
        }else{
            return (*this)*(this->pow(n-1));
        }
    }
    void print(){
        rep(i, row){
            rep(j, col){
                printf("%3ld ", data[i][j]);
            }
            putchar('\n');
        }
    }
    ll ans(){
        ll tmp = 0;
        rep(i, this->row)   rep(j, this->col)   (tmp += (*this)[i][j]) %= mod;
        return tmp;
    }
};

int main(){
    ll n,k; cin >> n >> k;
    Matrix a(n, n);
    rep(i, n)   rep(j, n)   cin >> a[i][j];
    Matrix ans = a.pow(k);
    cout << ans.ans() << endl;
}


Measured memory_bytes: 3704