akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n;
	cin >> n;
	VI a(n);
	REP(i, n) { cin >> a[i]; }

	int result = 0;
	REP(i, n) {
		if((i + 1) % 2 == 0) {
			continue;
		}

		if(a[i] % 2 == 0) {
			continue;
		}
		result++;
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
 
ll dp[22][(1<<22)];
vector<vector<int> >v(22,vector<int>(22));
int n;
ll solve(int i,int womenset)
{
   if(i==n+1)
   {
       if(womenset==0)
        return 1;
       return 0;
   }
   if(dp[i][womenset]!=-1)
   return dp[i][womenset];
   ll ans=0;
   for(int woman=0;woman<n;woman++)
   {
       bool available=(1<<woman)&(womenset);
       if(available==1 && v[i][woman+1]==1)
       {
           ans=(ans+solve(i+1,((1<<woman)^womenset)))%mod;
       }
   }
   dp[i][womenset]=ans;
   return dp[i][womenset];
}
int main() {
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	    for(int j=1;j<=n;j++)
	    {
	        cin>>v[i][j];
	    }
	}
	memset(dp,-1,sizeof(dp));
	cout<<solve(1,((1<<n)-1))<<"\n";
	return 0;
}

Measured memory_bytes: 721280
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {



    int a,b;
    char c;

    while(1){
        cin >> a>> c >> b;
        
        if(c=='+')
            cout << a+b << endl;
        else if(c == '-')
            cout << a-b << endl;
        else if(c == '*')
            cout << a*b << endl;
        else if(c == '/')
            cout << a/b << endl;
        else if(c == '?')
            break;

    }
    
    return 0;
    
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 main() {
    ll n;
    cin >> n;
    vector<ll> a(n,0);
    rep(i,n)cin >> a[i];
    ll res = 0;
    rep(i,n){
        if(i%2 == 0 && a[i]%2 == 1)res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;

ld sqrt_(ld d) {
	assert(d >= 0.0);
	ld l = 0.0, r = 1000000.0;
	rep(q, 40) {
		ld m = (l + r) / 2.0;
		if (m * m >= d)
			r = m;
		else
			l = m;
	}
	return l;
}

int main() {
	int N, K;
	vd x, y, c;
	cin >> N >> K;
	x.resize(N);
	y.resize(N);
	c.resize(N);
	rep(i, N)
		cin >> x[i] >> y[i] >> c[i];
	ld L = 0.0, R = 150000.0;
	rep(q, 37) {
		ld t = (L + R) / 2.0;
		bool can = false;
		rep(i, N) {
			rep(j, N) {
				vector<ld> X(2), Y(2);
				if (i == j) {
					// 円の中心
					X[0] = x[i];
					Y[0] = y[i];
					X[1] = x[i];
					Y[1] = y[i];
				}
				else if (i > j) {
					// 円の交点
					ld A = (t / c[i]) * (t / c[i]);
					ld B = (t / c[j]) * (t / c[j]);
					ld C = (x[i] * x[i] - x[j] * x[j]) + (y[i] * y[i] - y[j] * y[j]) - (A - B);
					ld D = 2.0 * (x[i] - x[j]);
					ld E = 2.0 * (y[i] - y[j]);
					if (D == 0.0) {
						Y[0] = C / E;
						Y[1] = C / E;
						ld AY = A - (Y[0] - y[i]) * (Y[0] - y[i]);
						if (AY < 0.0)
							continue;
						ld sAY = sqrt_(AY);
						X[0] = sAY + x[i];
						X[1] = -sAY + x[i];
					}
					else {
						ld F = C / D;
						ld G = E / D;
						ld H = F - x[i];
						ld a_ = G * G + 1;
						ld b_ = -1.0 * (G * H + y[i]);
						ld c_ = H * H + y[i] * y[i] - A;
						if (b_ * b_ - a_ * c_ < 0.0)
							continue;
						ld sbbac = sqrt_(b_ * b_ - a_ * c_);
						Y[0] = (-b_ + sbbac) / a_;
						Y[1] = (-b_ + -sbbac) / a_;
						X[0] = F - G * Y[0];
						X[1] = F - G * Y[1];
					}
				}
				else continue;

				ld t2 = t * t + 0.0000000001;

				rep(p, 2) {
					int k = 0;
					rep(n, N) {
						ld ttmp2 = c[n] * c[n] * ((X[p] - x[n]) * (X[p] - x[n]) + (Y[p] - y[n]) * (Y[p] - y[n]));
						if (ttmp2 <= t2)
							k++;
						if ((N - n) <= (K - k))
							break;
					}
					if (k >= K) {
						can = true;
						break;
					}
				}
				if (can)
					break;
			}
			if (can)
				break;
		}
		if (can)
			R = t;
		else
			L = t;
	}
	db ans = L;
	printf("%.12f\n", ans);
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> ans(2);

  if(n%2 == 1){
    for(int l = 1, r = n-1; l < r; l++, r--){
        ans.at(0).push_back(l);
        ans.at(1).push_back(r);
    }
  }
  else{
    bool flag = false;
    for(int l = 1, r = n-1; l < r; l++, r--){
        if(!flag && r-l <= n/2){
          --r;
          flag = true;
        }
        ans.at(0).push_back(l);
        ans.at(1).push_back(r);
    }
  }
  
  for(int i = 0; i < m; i++){
    cout << ans.at(0).at(i) << " " << ans.at(1).at(i) << endl;
  }
}

Measured memory_bytes: 4056
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cstdio>
#include<cfloat>

using namespace std;

double EPS = 1e-10;

struct point{
  double x, y;
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double norm(point a){
  return sqrt(a.x*a.x+a.y*a.y);
}

int main(void){
  double D;
  point p,v;
 
  while(cin >> D,D){
  
    cin >> p.x >> p.y >> v.x >> v.y;
     
    double d=D+1;
    double a=dot(p,v)/norm(p)/norm(v);

    if(abs(1.0 + a) < EPS )d=norm(p);
    else if(abs(1.0 - a) < EPS)d=2.0-norm(p);

    if(d<D || abs(d-D)<EPS)printf("%.8f\n",d);
    else cout << "impossible" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <string>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
    double a,b,x;cin >> a >> b >> x;
    double ans;
    if(2*x<=a*a*b) cout << fixed<<setprecision(6) << double(90) - atan(2*x/a/b/b)/M_PI*180 << endl;
    else cout << fixed<<setprecision(6) << atan(2*(a*a*b-x)/a/a/a)/M_PI*180 << endl;
}

Measured memory_bytes: 3812
S = input()[::-1]
digits = 1
Sum, ans = 0, 0
l = [0] * 2019
l[0] = 1

for c in S:
  Sum += int(c) * digits % 2019
  Sum %= 2019
  l[Sum] += 1
  digits = digits * 10 % 2019

for i in range(len(l)):
  ans += l[i] * (l[i] - 1) // 2
  
print(ans)

Measured memory_bytes: 9380
{-#LANGUAGE FlexibleContexts#-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V

getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]

type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)

mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
ti = toInteger
fi = fromInteger
fig = fromIntegral
rf = realToFrac

(.<.) :: Integer -> Integer -> Integer
(.<.) f g -- combination
    | g < 1 || f < 1 || f < g = 1
    | True = foldr1 (*) (take (fi g) [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)

unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)

mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a

countIf f = length . filter f

enumDivisor :: Int -> [Int]
enumDivisor n = do
    let sqrted = floor $ sqrt (fromIntegral n)
        smaller = filter (\x -> mod n x == 0) [1..sqrted]
        bigger = reverse $ map (div n) smaller
    if head bigger == sqrted then smaller ++ (init bigger)
    else smaller ++ bigger

safeHead [] = Nothing
safeHead (x:_) = Just x

-- 
--
--

main = do
    num <- getI
    humans <- getIs
    let counted = evalState (cnt humans) M.empty
        checks = if even num then [1,3..(num - 1)] else [0,2..(num - 1)]
        able = all (valid counted) checks
    putStrLn . show $ bool 0 (foldr (\x y -> mod (x * y) mmm) 1 $ take (div num 2) [2,2..]) able
    where
        valid mp 0 = M.lookup 0 mp == Just 1
        valid mp n = M.lookup n mp == Just 2


cnt [] = get
cnt (x:xs) = do
    nowMap <- get
    put $ M.alter mapIncr x nowMap
    cnt xs
    


Measured memory_bytes: 47484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define PI 3.141592653589793

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double m_degree = m * 6;
    double h_degree = h * 30 + 0.5 * m;
    //printf("%.10lf\n", h_degree);
    //printf("%.10lf\n", m_degree);
    double mid_degree = min(abs(h_degree - m_degree), (double)360 - abs(h_degree - m_degree));
    //printf("%.10lf\n", mid_degree);
    double ans_pow = a*a + b*b - 2*a*b*cos(mid_degree * PI / 180);
    //printf("%.10lf\n", ans_pow);
    double ans = sqrt(ans_pow);
    printf("%.10lf\n", ans);    
}

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

int main() {
	int n,m;
	cin>>n>>m;

	vector<int>p(m);
	vector<vector<int>>s(m);
	for (int i = 0; i < m; i++)
	{
		int k;cin>>k;
		s[i].resize(k);
		for(int j=0;j<k;j++)
		{
			cin>>s[i][j];
			s[i][j]--;
		}
	}
	for (int i = 0; i < m; i++)
	{
		cin>>p[i];
	}

	int ans = 0;
	for (int x = 0; x < (1 << n); x++)
	{
		bool flag = true;
		for (int i = 0; i < m; i++)
		{
			int cnt = 0;
			for (int j = 0; j < s[i].size(); j++)
			{
				int ss = s[i][j];
				if(x & (1<<ss))cnt++;
			}
			if(cnt%2 != p[i])flag = false;
		}

		if(flag)ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	const A = args[1].map(arg => parseInt(arg, 10))
	let ans = 0

	for (let i = 0; i < N; i++) {
		ans += 1 / A[i]
	}

	console.log(1 / ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

using namespace std;

typedef long long int ll;

ll n;
vector<char> v;

vector<string> ans;
void fun()
{
    if(v.size() == n)
    {
        string temp="";
        for(int i=0 ; i<n ; i++)
            temp+=v[i];

        ans.push_back(temp);
        return;
    }
    else
    {
       char t='a';
       for(int i=0;  i<v.size() ; i++)
        t = max(t,v[i]);

       for(char i='a' ; i<=char(t+1) ; i++)
       {
           v.push_back(i);
           fun();
           v.pop_back();
       }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    v.push_back('a');
    fun();

    sort(ans.begin(),ans.end());

    vector<string> a2;

    for(int i=0 ; i<ans.size() ; i++)
    {
        if(i==0)
            a2.push_back(ans[i]);
        else
        {
            if(a2[a2.size()-1] != ans[i])
                a2.push_back(ans[i]);
        }
    }
    for(int i=0 ; i<a2.size() ; i++)
        cout << a2[i] << "\n";

    return 0;
}


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

using namespace std;
#define taskname "TEST"
#define pb	push_back
#define mp 	make_pair
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 55;

ll dp[2][maxn][maxn * maxn];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    int bit = 0;
    int n , a;cin  >> n >> a;
    dp[0][0][0] = 1;
    for(int i = 1 ; i <= n ; ++i)
    {
        int x;
        cin >> x;
        for(int j = 0 ; j <= i ; ++j)
            for(int t = 0 ; t <= (i - 1) * 50 ; ++t)
                dp[bit ^ 1][j][t] = dp[bit][j][t];
        for(int j = 0 ; j <= i ; ++j)
            for(int t = 0 ; t <= (i - 1) * 50 ; ++t)
                dp[bit ^ 1][j + 1][t + x] += dp[bit][j][t];
        bit ^= 1;
    }
    ll res = 0;
    for(int i = 1 ; i <= n ; ++i)
        for(int j = 0 ; j <= 2500 ; ++j)
    {
        if(i * a == j){
            res += dp[bit][i][j];
        }
    }
    cout << res;
}


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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+1,1);
  rep(i,2,n+1){
    for(int j=i; j<n+1; j+=i){
      a[j]++;
    }
  }
  ll ans=1;
  rep(i,2,n+1){
    ans= ans + a[i]*i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81332
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }

    int ans = 0;
    for (auto & a : A) {
        if (a % 2 == 0) {
            for (int i = 0; i < ans; i++) {
                a *= 3;
            }

            while(a % 2 == 0) {
                a /= 2;
                ans++;
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    double l;
    cin >> l;
    cout << fixed << setprecision(12) << pow(l / 3, 3) << endl;
}


Measured memory_bytes: 512
import sys
readline = sys.stdin.readline

# 0-indexでやる

D = int(readline())

C = list(map(int,readline().split())) # 満足度の下がりやすさ

for i in range(D):
  S = list(map(int,readline().split()))
  for j in range(len(S)):
    S[j] = (S[j],j)
  S = sorted(S, key = lambda x:x[0], reverse = True)
  print(S[0][1] + 1)


Measured memory_bytes: 9200
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    uint64_t n;
    cin >> n;

    vector<pair<long, long>> tasks(n);
    for(pair<long, long>& t :tasks){
        cin >> t.second >> t.first;
    }

    sort(tasks.begin(), tasks.end());

    string result("Yes");
    long time = 0;
    for(pair<long, long>& t :tasks){
        time += t.second;
        if(time > t.first){
            result = "No";
            break;
        }
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  long long HPs[N];
  for( int i=0; i < N ;i++ ) cin >> HPs[i];

  sort(HPs,HPs+N,greater<long long>());

  for(int j=0; j<min(K,N); j++) HPs[j]=0;

  long long attack_num = 0;
  for (int i=0; i<N;++i) attack_num+=HPs[i];

  cout << attack_num << endl;  
  int dum;
  cin >> dum;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <stdio.h>
#include <math.h>

#define EPS 1e-3
#define INF (1<<29)
#define equals(a, b) (fabs(a - b) < EPS)

struct Country {
    int f, a, x, y, i;
    Country(){}
    Country(int f, int a, int x, int y, int i) :
        f(f), a(a), x(x), y(y), i(i) {}
};

double get_distance(double x1, double y1, double x2, double y2)
{
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}

int main()
{
    int N, f, a, t, x, y;    
    std::cin >> N;
    std::vector<Country> country[2];
    for (int i = 0; i < N; i++) {
        std::cin >> f >> a >> t >> x >> y;
        country[t].push_back(Country(f, a, x, y, i));
    }
    
    double max_dist[2], min_time[2];
    for (int i = 0; i < 2; i++) {
        size_t size = country[i].size();
        max_dist[i] = -1;
        min_time[i] = INF;
        if (size > 1) {         
            for (size_t j = 0; j < size-1; j++) {            
                Country c1 = country[i][j], c2 = country[i][j+1];
                if (c1.a == c2.a || c2.i - c1.i != 1) {
                    continue;
                }                
                double ndist = get_distance(c1.x, c1.y, c2.x, c2.y);
                double ntime = (c2.f - c1.f) / 60.0;
                if (ndist > max_dist[i]) {
                    max_dist[i] = ndist;                    
                    min_time[i] = ntime;
                } else if (equals(ndist, max_dist[i])) {
                    if (ntime < min_time[i]) {
                        min_time[i] = ntime;
                    }
                }
            }
        }
        if (max_dist[i] == -1) {
            std::cout << -1 << " " << -1 << std::endl;
        } else {
            printf("%.10f %.10f\n", max_dist[i], min_time[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
map< ll , ll > mp;
int main()
{
	int a , b;
	cin >> a >> b;
	if(a <= b)
      cout << a << endl;
  	else
      cout << a-1 << endl;
	return 0;
} 



Measured memory_bytes: 256
while True:
    list_ = list(map(str, input().split()))
    a = int(list_[0])
    op = list_[1]
    b = int(list_[2])
    
    if op == '?':
        break
    
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(int(a / b))


Measured memory_bytes: 5596
h,w=list(map(int,input().split()))

anses=[]
for x,y in (h,w),(w,h):
  if x%3==0:
    anses.append(0)
  else:
    anses.append(y)

  for i in range(x):
    ss = (i * y, (x - i) * (y // 2), (x - i) * (y - y // 2))
    anses.append(max(ss)-min(ss))


print(min(anses))



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

int main()
{
    int n;
    cin >> n;
    vector<int> L(n);
    for (int i = 0; i < n; i++)
        cin >> L[i];
    sort(L.begin(), L.end());
    int sum = 0;
    for (int i = 0; i < n - 1; i++)
        sum += L[i];
    if (L[n - 1] < sum)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF 1LL<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll n,k; cin >> n >> k;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(rall(a));
    ll sum = 0;
    rep(i,k) sum += a[i];
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
// #include <string>
// #include <vector>
// #include <algorithm>
// #include <numeric>
// #include <set>
// #include <map>
// #include <iomanip>

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
// typedef long long ll;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

ull fact_mod(int n) {
    ull ret = 1;
    for (int i = 2; i <= n; i++) {
        ret = (ret * i) % MOD;
    }
    return ret;
}

int main(int argc, char const *argv[]) {
    int N, M;
    cin >> N >> M;
    if (abs(N - M) >= 2) {
        cout << 0 << endl;
    } else {
        ull ans = (fact_mod(N) * fact_mod(M)) % MOD;
        if (N == M) {
            ans = (ans * 2) % MOD;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int arr[n][3];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin >> arr[i][j];
		}
	}
	int ans=0;
	int dp[n][3];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<3;i++)
	{
		dp[0][i]=arr[0][i];
	}
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(j==0)
			{
				dp[i][j]+=arr[i][j]+max(dp[i-1][1],dp[i-1][2]);
			}
			else if(j==1)
			{
				dp[i][j]+=arr[i][j]+max(dp[i-1][0],dp[i-1][2]);
			}
			else
			{
				dp[i][j]+=arr[i][j]+max(dp[i-1][0],dp[i-1][1]);
			}
		}
	}
	// for(int i=0;i<n;i++)
	// {
	// 	for(int j=0;j<3;j++)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }
	cout << max(dp[n-1][0],(max(dp[n-1][1],dp[n-1][2])));
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
 
using namespace std;
 
#define MAX 2001
 
int dp[MAX][MAX];
int arr[MAX][MAX];
 
void init(int N){
    for(int i = 0 ; i < N ; i++){
	for(int j = 0 ; j < N ; j++){
	    dp[i][j] = 0;
	    arr[i][j] = MAX;
	}
    }
}
 
int main(){
    string s;
 
    while(cin >> s){
	string t = s;
	reverse(t.begin(), t.end());
  
	int len = s.size();  init(len+1);
	for(int i = 0 ; i < len ; i++){
	    for(int j = 0 ; j < len ; j++){
		if(s[i] == t[j]){
		    dp[i+1][j+1] = dp[i][j] + 1;
		    arr[i+1][j+1] = 0;
		}else{
		    if(dp[i][j+1] < dp[i+1][j]){
			dp[i+1][j+1] = dp[i+1][j];
			arr[i+1][j+1] = -1;
		    }else{
			dp[i+1][j+1] = dp[i][j+1];
			arr[i+1][j+1] = 1;
		    }
		}
	    }
	}
	string str;
	for(int i = len, j = len ; i > 0 && j > 0 ;){
	    if(!arr[i][j]){
		str += s[i-1];
		i--, j--;
	    }else if(arr[i][j] == 1){
		i--;
	    }else{
		j--;
	    }
	}
	cout << str << endl;
    }
 
    return 0;
}

Measured memory_bytes: 34432
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int x,n;
	cin >> x >> n;
	map<int,bool> used;
	for(int i = 0;i < n;i++){
		int p;
		cin >> p;
		used[p] = true;
	}

	int d = INF;
	int ans = 200;
	for(int i = -1;i <= 101;i++){
		if(abs(x-i) < d && used[i] == false){
			d = abs(x-i);
			ans = i;
		}
	}

	cout << ans << endl;
}


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

typedef long long ll;
int n;
ll k,a[202020];
ll st=-2e18,en=2e18;

int main() {
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	while(st+1!=en) {
		ll mid=(st+en)/2,cnt=0;
		for(int i=0;i<n;i++) {
			int l=i,r=n;
			while(l+1!=r) {
				int m=(l+r)/2;
				if(a[i]*a[m]<=mid) 
					(a[i]<0)?r=m:l=m;
				else (a[i]<0)?l=m:r=m;
			}
			if(a[i]<0) cnt+=n-r;
			else cnt+=l-i;
		}
		if(cnt<k) st=mid;
		else en=mid;
	}
	cout<<en<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
struct node {
	int key;
	node* parent, * left, * right;
};
node* nil, * root;
void insert(int key) {
	node* y = nil;//親
	node* x = root;
	node* z;
	z = (node*)malloc(sizeof(node));
	z->key = key;
	z->left = nil;
	z->right = nil;
	while (x!=nil) {
		y = x;
		if (z->key<x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y==nil) {
		root = z;
	}
	else {
		if (z->key<y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
};
void ino(node* u) {
	if (u == nil) {
		return;
	}
	ino(u->left);
	cout << " " << u->key;
	ino(u->right);
};
void pre(node* u) {
	if (u == nil) {
		return;
	}
	cout << " " << u->key;
	pre(u->left);
	pre(u->right);
}

node* find(int key,node* root) {
	node* x = root;
	while (x!=nil) {
		if (key==x->key) {
			break;
		}
		if (key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	return x;
}
node* getMin(node* x) {
	while (x->left!=nil) {
		x = x->left;
	}
	return x;
}
node* getNextNode(node *x) {
	if (x->right!=nil) return getMin(x->right);
};

void del(int key,node *root) {
	node* z = find(key,root);
	node* y;
	if (z->left==nil||z->right==nil) {
		y = z;
	}
	else {
		y = getNextNode(z);
	}
	node* x;
	if (y->left!=nil) {
		x = y->left;
	}
	else if (y->right!=nil) {
		x = y->right;
	}
	else {
		x = nil;
	}
	if (x!=nil) {
		x->parent = y->parent;
	}
	if (y->parent==nil) {
		root = x;
	}
	else if (y->parent->left==y) {
		y->parent->left = x;
	}
	else {
		y->parent->right = x;
	}
	if (z!=y) {
		z->key = y->key;
	}
};
void print(node* root) {
	ino(root);
	cout << endl;
	pre(root);
	cout << endl;
};
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		string order;
		cin >> order;
		if (order == "insert") {
			int key;
			cin >> key;
			insert(key);
		}
		else if (order=="find"){
			int key;
			cin >> key;
			cout<<((find(key,root)==nil)?"no":"yes")<<endl;
		}
		else if (order=="delete") {
			int key;
			cin >> key;
			del(key,root);
		}else
		{
			print(root);
		}
	}
};




Measured memory_bytes: 21900
n=int(input())
b=list(map(int,input().split()))
a=[0]*n
a[0]=b[0]
a[n-1]=b[n-2]

mae=b[0]
for i in range(n-2):
    a[i+1]=min(mae,b[i+1])
    mae=b[i+1]
ans=0
for i in range(n):
    ans+=a[i]
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u)
{
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for(v=0 ; v<n ; v++)
    {
      if(M[u][v] == 0) continue;
      if(color[v] == WHITE)
	{
	  dfs_visit(v);
	}
    }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs()
{
  int u;
  for(u=0 ; u<n ; u++) color[u] = WHITE;
  tt=0;

  for(u=0 ; u<n ; u++)
    {
      if(color[u] == WHITE) dfs_visit(u);
    }

  for(u=0 ; u<n ; u++)
    {
      printf("%d %d %d\n",u+1,d[u],f[u]);
    }
}

int main(){
  int u,v,k,i,j;
  
  scanf("%d",&n);
  for(i=0 ; i<n ; i++)
    {
      for(j=0 ; j<n ; j++)
	{
	  M[i][j] = 0;
	}
    }

  for(i=0 ; i<n ; i++)
    {
      scanf("%d %d",&u,&k);
      u--;
      for(j=0 ; j<k ; j++)
	{
	  scanf("%d",&v);
	  v--;
	  M[u][v] = 1;
	}
    }

   dfs();
   
  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
const int mod = 1000000007;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
mint choose(int n,int a){
    mint x=1,y=1;
    rep(i,a){
        x*=n-i;
        y*=i+1;
    }
    return x/y;
}
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    mint ans=2;
    ans=ans.pow(n)-1;
    cout<<ans-choose(n,a)-choose(n,b)<<endl;
}


Measured memory_bytes: 3608
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑



int a, b, path[100005];
int main() {
	cin >> a >> b;

	for (int i = 0; i < b; ++i) {
		int n, m;
		cin >> n >> m;
		++path[n]; ++path[m];
	}

	for (int i = 0; i < a; ++i) {
		if (path[i] % 2) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

const int N = 1e5 + 5;

int a[N];

int main(){

	int n, l;
	scanf("%d %d", &n, &l);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}

	for(int i = 1; i < n; i++){
		if(a[i] + a[i - 1] >= l){
			cout<<"Possible\n";
			for(int j = 1; j < i; j++)	cout<<j<<'\n';
			for(int j = n - 1; j >= i; j--)	cout<<j<<'\n';
			exit(0);
		}
	}

	cout<<"Impossible\n";

	return 0;
}

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



int main() {
  int x, y;
  cin >> x >> y;
  string ans = "No";
  rep(i, x+1) {
    if((2*i+2*x)==y){
      ans = "Yes";
    }
  }
  cout << ans << endl;
  
  return 0;
}

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

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

  int n;
  string s, t;
  cin >> n >> s >> t;
  int max_check = s.size() + t.size() - n;
  if (max_check <= 0) {
    cout << n << "\n";
  }
  for (size_t i = n - t.size(); i < max_check; ++i) {
    bool match = true;
    for (int j = 0; j < n - i; ++j) {
      if (s[i + j] != t[j]) {
        match = false;
        break;
      }
    }
    if (match) {
      cout << n + i << "\n";
      return 0;
    }
  }
  cout << n + max_check << "\n";
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
int gcd(int a, int b)
{
    if (b == 0)
    {
        return a;
    }
    else if (a < b)
    {
        return gcd(b, a);
    }
    else
    {
        return gcd(b, a % b);
    }
}

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    printf("%d\n", gcd(m, n));
}


Measured memory_bytes: 2132
#include <stdio.h>

int main() {
	long long N, T, a, prev;
	long long ans = 0;
	scanf("%lld %lld %lld", &N, &T, &prev);

	while (scanf("%lld", &a) != -1) {
		if (a - prev >= T) {
			ans += T;
		} else {
			ans += a - prev;
		}
		prev = a;
	}
	printf("%lld\n", ans + T);
}


Measured memory_bytes: 128
// #include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define print(x) (cout << x << endl)

using namespace std;

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

ll val(int i, int remW, vector<int>& w, vector<int>& v, vector<vector<ll> >& memo, int n, int W) {
  // cout << i << " " << remW << endl;
  if (i == n || remW == 0) return 0;
  // for (auto a : memo) {
  //   for (auto b : a) {
  //     cout << b << " ";
  //   }
  //   cout << endl;
  // }
  // cout << memo[i][remW] << endl;
  if (memo[i][remW] != -1) return memo[i][remW];
  if (w[i] > remW) return memo[i][remW] = val(i + 1, remW, w, v, memo, n, W);
  return memo[i][remW] = max(val(i + 1, remW, w, v, memo, n, W), v[i] + val(i + 1, remW - w[i], w, v, memo, n, W));
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  // const int M = 1e9 + 7;

  int n, W;
  cin >> n >> W;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }

  vector<vector<ll> > memo(n, vector<ll> (W + 1, -1)); // here fuck

  cout << val(0, W, w, v, memo, n, W) << endl;
  
    
  
  


}
    // cout << "Case #" << C++ << ": " << cur_max << endl;  



Measured memory_bytes: 79488
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  if(S[S.size()-1]=='s'){
    cout<<S<<"es"<<endl;
  }else{
    cout<<S<<"s"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n,k; cin>>n>>k;
	ll a[n]; ll s[n+1]; s[0]=0LL;
	rep(i,n) cin>>a[i],s[i+1]=s[i]+a[i];
	vector<ll> b;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<=n; j++){
			b.PB(s[j]-s[i]);
		}
	}
	sort(ALL(b));
	ll x=0LL;
	for(ll i=40; i>=0; i--){
		int cnt=0;
		ll msk=1LL<<i;
		rep(j,b.size()){
			if(((x|msk)&b[j])==(x|msk)) cnt++;
		}
		if(cnt>=k) x|=msk;
	}
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 6384
s = sorted(str(input()))
t = sorted(str(input()))[::-1]
a = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(min(len(s),len(t))):
    if t[i] > s[i]:
        print("Yes")
        break
    elif len(set(s)) == len(set(t)):
        if len(s) < len(t):
            print("Yes")
            break
else:
    print("No")

Measured memory_bytes: 3064
[n, m] = [int(i) for i in input().split()]
lists = [[int(j) for j in input().split()] for i in range(0, n)]
price = {}
bottle = {}

for (idx, [a, b]) in enumerate(lists):
    price[idx] = a
    bottle[idx] = b

total = 0
bought = 0
for k, v in sorted(price.items(), key=lambda x: x[1]):
    if m > bottle[k]:
        bought = bought + bottle[k]
        total = total + price[k] * bottle[k]
        m = m - bottle[k]
    else:
        total = total + price[k] * m
        break

print(total)


Measured memory_bytes: 45320
from itertools import product


A, B, C = map(int, input().split())
K = int(input())

for D in product([0, 1, 2], repeat=K):
    ans = [A, B, C]
    for d in D:
        ans[d] *= 2
    if ans[0] < ans[1] < ans[2]:
        print("Yes")
        break
else:
    print("No")


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

int H, W, dist[59][59], sum;
string S[59];

int main()
{

    cin >> H >> W;
    for (int i = 0; i < H; i++)// nyuuryoku
    {
        cin >> S[i];
        for (int j = 0; j < W; j++)
        {
            if (S[i][j] == '.')
                sum++; // . no kazu
        }
    }

    for (int i = 0; i < 59; i++)
    {
        for (int j = 0; j < 59; j++)
            dist[i][j] = (1 << 30); // INF de syokika
    }

    queue<pair<int, int>> Q;
    Q.push(make_pair(0, 0)); // junnbi
    dist[0][0] = 1;

    while (!Q.empty())
    {
        int a1 = Q.front().first, a2 = Q.front().second;
        Q.pop();
        int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
        for (int i = 0; i < 4; i++)
        {
            int cx = a1 + dx[i], cy = a2 + dy[i];
            if (cx < 0 || cy < 0 || cx >= H || cy >= W || dist[cx][cy] <= dist[a1][a2] + 1 || S[cx][cy] == '#')
                continue;
            Q.push(make_pair(cx, cy));
            dist[cx][cy] = dist[a1][a2] + 1;
        }
    }

    if (dist[H - 1][W - 1] == (1 << 30)) // muri
        cout << "-1" << endl;
    else // sum - saitann kyori
        cout << sum - dist[H - 1][W - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  string odd, even;
  cin >> odd >> even;
  int a = odd.size() + even.size();
  string pass = "";
  for(int i = 0; i < a; i++){
    if(i % 2 == 0){
      pass += odd.at(i/2);
    }
    if(i % 2 == 1 && i / 2 <= even.size() - 1){
      pass += even.at(i/2);
    }
  }
  cout << pass << endl;
}

Measured memory_bytes: 256
// ABC154
// d.cs

using System;

class D
{
    public static void Main()
    {
        string[] str0 = Console.ReadLine().Split(' ');
        int N = int.Parse(str0[0]);
        int K = int.Parse(str0[1]);
        string[] str1 = Console.ReadLine().Split(' ');
        int[] P = new int[N];

        for (int i = 0; i < N; i++)
        {
            P[i] = int.Parse(str1[i]);
        }

        int[] sum_n = new int[N];
        int[] sum_k = new int[N];
        int sum_k_max = 0;
        int index = 0;

        sum_n[0] = P[0];
        for (int i = 1; i < N; i++)
        {
            sum_n[i] = P[i] + sum_n[i-1];
        }

        for (int i = 0; i + K - 1 < N; i++)
        {
            if (i == 0)
            {
                sum_k[i] = sum_n[i + K - 1];
                sum_k_max = 0;
            }
            else
            {
                sum_k[i] = sum_n[i + K - 1] - sum_n[i - 1];
            }
            if (sum_k_max < sum_k[i])
            {
                sum_k_max = sum_k[i];
                index = i;
            }
        }

        double answer = 0;
        // 期待値の計算
        for(int i = index; i < index + K; i++)
        {
            answer += func01(P[i]);
        }
        Console.WriteLine(answer);
    }

    public static double func01(double P)
    {
        double sum = (P + 1) / 2.0;
        return sum;
    }
}

Measured memory_bytes: 29020
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    long x;
    long y;
}data;

int main(void){
    int N,K;
    scanf("%d%d",&N,&K);

    //A[0]~A[N-1]に格納する
    data* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%ld%ld",&A[i].x,&A[i].y);
    }

    long ans=1e18*4;
    for(int a=0;a<N;a++){
        for(int b=0;b<N;b++){
            for(int c=0;c<N;c++){
                for(int d=0;d<N;d++){
                    long x0=MIN(A[a].x, A[b].x);
                    long x1=MAX(A[a].x, A[b].x);

                    long y0=MIN(A[c].y, A[d].y);
                    long y1=MAX(A[c].y, A[d].y);

                    int tmp=0;
                    for(int i=0;i<N;i++){
                        if(x0<=A[i].x && A[i].x<=x1 && y0<=A[i].y && A[i].y<=y1) tmp++;
                    }
                    if(tmp>=K) ans=MIN(ans,(x1-x0)*(y1-y0));
                }
            }
        }
    }
    printf("%ld\n",ans);

    return 0;
}

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

int a[3][3], x[3], y[3];

int main() {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    x[0] = 0;
    for (int j = 0; j < 3; j++) y[j] = a[0][j] - x[0];
    for (int i = 0; i < 3; i++) x[i] = a[i][0] - y[0];
    bool good = true;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (x[i] + y[j] != a[i][j]) {
                good = false;
            }
        }
    }
    if (good) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int A,B;
int main(){
	cin>>A>>B;
	if(A==B) {
		cout<<"Draw"<<endl;
	} else if(A==1) {
		cout<<"Alice"<<endl;
	} else if(B==1) {
		cout<<"Bob"<<endl;
	} else if(A>B) {
		cout<<"Alice"<<endl;
	} else if(A<B) {
		cout<<"Bob"<<endl;
	}
}


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

#define N 2020

bitset<N> l[N], r[N], a[N];
int n;

int main() {
	scanf("%d", &n);
	char s[N];
	for (int i = 2; i <= n; i ++) {
		scanf("%s", s + 1);
		for (int j = 1; j < i; j ++) {
			a[i][j] = s[j] - '0';
			a[j][i] = !a[i][j];
		}
	}
	for (int i = 1; i <= n; i ++) {
		l[i][i] = r[i][i] = a[i][i] = 1;
	}
	for (int len = 1; len < n; len ++) {
		for (int y = 1; y + len <= n; y ++) {
			int x = len + y;
			if ((a[x]&l[y]&r[x-1]).any()) l[y][x] = 1;
			if ((a[y]&l[y+1]&r[x]).any()) r[x][y] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i ++) {
		if (l[1][i] && r[n][i]) ans ++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
s = input()
t = 0
if s == 'SUN':
    t = 0
elif s == 'MON':
    t = 1
elif s == 'TUE':
    t = 2
elif s == 'WED':
    t = 3
elif s == 'THU':
    t = 4
elif s == 'FRI':
    t = 5
elif s == 'SAT':
    t = 6
print(7-t)

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

n = int(input())
a = [int(x) for x in input().split()]

max_a = [0]*(n + 1)

if n == 0 and a[0] == 0:
    print(-1)
    sys.exit()

for i in range(n + 1):
    if i == 0:
        max_a[i] = 1
    else:
        max_a[i] = (max_a[i - 1] - a[i - 1])*2
        if max_a[i] < 0:
            print(-1)
            sys.exit()
# print(max_a)
for i in range(n, -1, -1):
    if i == n:
        if max_a[i] < a[i]:
            print(-1)
            sys.exit()
        max_a[i] = a[i]
    else:
        min_p = max_a[i + 1] // 2 + int(max_a[i + 1] % 2 == 1)
        max_p = max_a[i + 1]
        if max_a[i] < min_p:
            print(-1)
            sys.exit()
        max_a[i] = min(max_p + a[i], max_a[i])
print(sum(max_a))
# print(max_a)




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

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

	int n = s.size();
	int n1 = 0;
	int n2 = 0;

	for (int i = 0; i < n; ++i)
	{
		if (i%2 == 0)
		{
			if (s[i] == '0')
				++n1;
			else
				++n2;
		}
		else
		{
			if (s[i] == '1')
				++n1;
			else
				++n2;
		}
	}

	if (n1 < n2)
		cout << n1;
	else
		cout << n2;

	return 0;
}

Measured memory_bytes: 512