akhauriyash/Code-Regression huggingface dataset:
/* 
    Author - linpaws07 
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inf (int)1e9
#define f first
#define s second
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define scd(t) scanf("%d",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define memst(a, b) memset(a, (b), sizeof(a))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rp(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define fre(i,a,b) for(int i=(a);i<=(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
inline bool eq(double a, double b) { return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
auto start = high_resolution_clock::now();
inline void measure();

int a[102];
int dp[100002];
int main(){
    FAST
    //Do awesome things here
    int n, k;
    cin >> n >> k;
    rp(i, n){
        cin >> a[i];
    }
    //What to do?
    rp(i, k + 1){
        rp(j, n){
            if(i >= a[j] && !dp[i - a[j]]){
                dp[i] = 1;
            }
        }
    }
    if(dp[k])   cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}


inline void measure(){
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << duration.count() << endl;
}

Measured memory_bytes: 640
#!/usr/bin/perl

my ($N,$K) = map { $_ - 0 } split(/\s+/,<STDIN>);

if( $N == $K ){
  print "0\n";
  exit(0);
}

my $oN = $N;

if( $N > $K ){
  my $d = $N - $K;
  my $d2 = $d % $K;
  if( $d2 == 0 ){
    print "0\n"; exit(0);
  }
  my $d3 = $d - $d2;
  $N -= $d3;
}

my $mn = $N;

for(my $i=0;$i<15;$i++){
  $N = abs($K - $N);
  $mn = $N if $N < $mn;
}

$mn = $oN if $oN < $mn;

print "$mn\n";



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back


int main(){
   ll n;cin>>n;
   string S;cin>>S;
   map<int,int>m;
   rep(i,n){
      m[S[i]-'a']++;
   }
   ll ans=1;
   for(auto v:m){
      ans=((v.se+1)*ans)%MOD;
   }
   ans=(ans-1+MOD)%MOD;
   cout<<ans<<endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n;cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;cin>>s;
        mp[s]++;
    }
    out(mp.size());
}


Measured memory_bytes: 19256
if __name__ == '__main__':
    S = str(input())
    
    AA = int(S[:2])
    BB = int(S[2:4])
    
    month = [i for i in range(1, 13)]
    
    if AA in month:
        if BB in month:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    
    elif BB in month:
            print('YYMM')
    
    else:
        print('NA')
        
        

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
  ll a;
  cin >> a;
  ll ans=0, cnt=1; 
  while(a!=0){
    a/=2;
    ans += cnt;
    cnt*=2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#1042
import re
while True:
    l = []
    x = str(input())
    if x =='END OF INPUT':
        break
    y = re.split('[ ]',x)
    for i in range(len(y)):
        l.append(len(y[i]))
    for j in range(len(l)-1):
        print(l[j],end='')
    print(l[-1])


Measured memory_bytes: 6480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

// int MAX_N = 200000 + 1;
int N;
// vector<bool> v(MAX_N);

bool sub(int x, vector<bool> &v) { // xより大きなN以下のxの倍数kxにつき，v[kx]のXORを返す
	bool res = false;	
	for (int k = 2; k * x <= N; k++) {
		res = !(res == v.at(k * x));
	}
	return res;
}

int main () {
	cin >> N;
	vector<bool> v(N + 1);
	vi a(N + 1); rep(i, N) cin >> a.at(i + 1);
	dbv(a);
	int ans = 0;
	for (int i = N; i > 0; i--) {
		db(i); dbl(sub(i, v));
		v.at(i) = !(sub(i, v) == a.at(i));
		if (v.at(i)) ans++;
	}
	// dbv(v);
	// rep2(i, 1, N + 1) db(v.at(i));
	cout << ans << endl;
	rep2(i, 1, N + 1) {
		if (v.at(i)) {
			cout << i << " ";
		}
	}
}

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

int main(int argc, const char * argv[]) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool flag = false;
    if (abs(a - c) <= d) {
        flag = true;
    }else if (abs(a - b) <= d && abs(b - c) <= d) {
        flag = true;
    }
    if (flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String obj;
        String str;
        int counter=0;
        
        obj=scan.nextLine();
        
        scan.useDelimiter("\\s");
        
        while(!((str=scan.next()).equals("END_OF_TEXT"))){
            str=str.toLowerCase();
            if(str.equals(obj)){
                counter++;
            }
        }
        
        System.out.println(counter);
    }
        
}

Measured memory_bytes: 26176
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    int a[N]; REP(i,N){cin >> a[i]; a[i]--;}
    int ans=1, nxt=a[0];
    bool done[N]; REP(i,N) done[i] = false;
    done[0] = true;
    while(nxt!=1 && nxt!=0){
        if(done[nxt]){
            nxt = 0; break;
        }
        done[nxt] = true;
        ans++; nxt=a[nxt];
    }
    if(nxt) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)

int main()
{
    int N;
    cin >> N;
    long long A[200100];
    long long res = 1LL << 60;
    rep(i, 0, N)
    {
        cin >> A[i];
    }

    long long sum[200100];
    sum[0] = A[0];
    rep(i, 1, N)
    {
        sum[i] = sum[i - 1] + A[i];
    }

    int le = 1;
    int ri = 3;
    rep(i, 2, N)
    {
        // cout << "start:" << i << endl;
        bool pqflg = true;
        while (pqflg)
        {
            // cout << "in,le:" << le << endl;
            if (le == i - 1)
            {
                pqflg = false;
            }
            else
            {

                long long p1 = sum[le - 1];
                long long q1 = sum[i - 1] - p1;
                long long p2 = sum[le];
                long long q2 = sum[i - 1] - p2;
                long long di1 = max({p1, q1}) - min({p1, q1});
                long long di2 = max({p2, q2}) - min({p2, q2});
                if (di2 < di1)
                {
                    le++;
                    // cout << "++" << endl;
                }
                else
                {
                    pqflg = false;
                    // cout << "di1:" << di1 << ",di2:" << di2 << endl;
                    // cout << p1 << "," << q1 << "," << p2 << "," << q2 << endl;
                }
            }
        }
        bool rsflg = true;
        while (rsflg)
        {
            if (ri == N - 1)
            {
                rsflg = false;
                continue;
            }

            long long r1 = sum[ri - 1] - sum[i - 1];
            long long s1 = sum[N - 1] - sum[i - 1] - r1;
            long long r2 = sum[ri] - sum[i - 1];
            long long s2 = sum[N - 1] - sum[i - 1] - r2;
            long long di1 = max({r1, s1}) - min({r1, s1});
            long long di2 = max({r2, s2}) - min({r2, s2});
            if (di2 < di1)
            {
                ri++;
                // cout << "i:" << i << "ri:" << ri << endl;
                // cout << r1 << "," << s1 << "," << r2 << "," << s2 << endl;
            }
            else
            {
                rsflg = false;
            }
        }
        long long p = sum[le - 1];
        long long q = sum[i - 1] - p;
        long long r = sum[ri - 1] - p - q;
        long long s = sum[N - 1] - p - q - r;
        long long di = max({p, q, r, s}) - min({p, q, r, s});
        if (di < res)
        {
            // cout << "i:" << i << endl;
            // cout << p << "," << q << "," << r << "," << s << endl;
            res = di;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3328
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

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

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type fill_v(T &t,
                                                                   const V &v) {
  t = v;
}
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t)
    fill_v(e, v);
}

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

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  usize N, max1, max2;
  std::cin >> N;
  max1 = max2 = 0;

  std::vector<usize> A(N);
  for (usize i = 0; i < N; i++) {
    std::cin >> A[i];
    if (A[i] > max1) {
      max1 = A[i];
    } else if (A[i] > max2) {
      max2 = A[i];
    }
  }

  for (usize i = 0; i < N; i++) {
    if (A[i] == max1) {
      std::cout << max2 << std::endl;
    } else {
      std::cout << max1 << std::endl;
    }
  }
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int[][] dist = new int[n][d];
        for(int i=0;i<n;i++){
            for(int j=0;j<d;j++){
                dist[i][j] = Integer.parseInt(sc.next());
            }
        }
        sc.close();

        double sum = 0;
        int count = 0;
        for(int i=0;i<n;i++){
            
            for(int j=i+1;j<n;j++){
                sum = 0;
                for(int k=0;k<d;k++){
                    sum+=(dist[i][k]-dist[j][k])*(dist[i][k]-dist[j][k]);
                }
                sum = Math.sqrt(sum);
                if(sum == (int)sum){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
def solve():
    n, m = map(int, input().split())
    if m == 0:
        if n == 1:
            return 0
        else:
            return 10 ** (n-1)

    nums = [-1] * n
    for _ in range(m):
        s, c = map(int, input().split())
        if nums[s-1] != -1 and nums[s-1] != c:
            return -1
        else :
            nums[s-1] = c
    
    if nums[0] == 0 and n != 1:
        return -1
    
    start, end = 0, 10 ** (n)-1
    if n != 1:
        start = 10 ** (n-1)
        
    for v in range(start, end + 1):
        chk = True
        s = str(v)
        for i in range(n):
            if nums[i] == -1 or nums[i] == int(s[i]):
                continue
            chk = False
        if chk:
            return v
    return -1

print(solve())

Measured memory_bytes: 3192
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
    static long solve(long arr[],int k,int n){
        
        
        long t[]=new long[arr.length+1];
      
        for(int i=2;i<n;i++){
        long min=Long.MAX_VALUE;
             if(i-k<=0){
            for(int j=1;j<i;j++){
                
               
                    min=Math.min(min,Math.abs(arr[i]-arr[j])+t[j]);
                    
                }
             }
                else{
              
              for(int m=i-k;m<i;m++){
                      min=Math.min(min,Math.abs(arr[i]-arr[m])+t[m]);
              }
              
                    
                }
                t[i]=min;
            }
            
            
  return t[arr.length-1];          
        }
        
  
    
    
    
	public static void main (String[] args) throws java.lang.Exception
	{
	
	Scanner s=new Scanner(System.in);
	int n=s.nextInt();
	int k=s.nextInt();
	long arr[]=new long[n+1];
	
	for(int i=1;i<=n;i++){
	    arr[i]=s.nextLong();
	}

System.out.println(	solve(arr,k,n+1));
	
	
	}
}


Measured memory_bytes: 56576
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n[4],m[4]={0},p=1,i;
	char s[4][100];
	for(i=1; i<4; i++)
	{
		scanf("%s", &s[i]);
		n[i]=strlen(s[i]);
	}
	while(m[p]<n[p])
	{
		m[p]++;
		if(s[p][m[p]-1]=='a')
		p=1;
		else if(s[p][m[p]-1]=='b')
		p=2;
		else
		p=3;
	}
	if(p==1)
	printf("A\n");
	else if(p==2)
	printf("B\n");
	else
	printf("C\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	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>
using namespace std;
string n;   
int ans=0;
int a=0;
int main()
{
    cin>>n;
    for(int i=0;i<n.size();i++)
    {
        if(n[i]=='g')
        {
            if(a>0)
            {
                ans++;
                a--;
            }
            else
            {
                a++;
            }
        }
        else
        {
            if(a>0)
            {
                a--;
            }
            else
            {
                a++;
                ans--;
            }

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

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
  static int A,B,Q;
  static Long[] S,T,X;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    A = sc.nextInt();
    B = sc.nextInt();
    Q = sc.nextInt();
    S = new Long[A+2];
    T = new Long[B+2];
    X = new Long[Q];
    for(int i=1;i<=A;i++){
      S[i]=sc.nextLong();
    }
    S[0]=-100000000000000000L;
    S[A + 1]=100000000000000000L;
    for(int i=1;i<=B;i++){
      T[i]=sc.nextLong();
    }
    T[0]=-100000000000000000L;
    T[B + 1]=100000000000000000L;
    for(int i=0;i<Q;i++){
      X[i]=sc.nextLong();
    }
    for(int i=0;i<Q;i++){
      System.out.println(Qanswer(i));
    }
  }

  static int binary_search(Long[] a, Long x, int lb, int ub) {
    if (ub  - lb <= 1) {
      return lb;
    } else {
      int mid = (lb + ub) / 2;
      if (a[mid] <= x) return binary_search(a, x, mid, ub);
      else return binary_search(a, x, lb, mid);
    }
  }

  static Long Qanswer(int i){
    int Snear = binary_search(S,X[i],0,S.length-1);
    int Tnear = binary_search(T,X[i],0,T.length-1);

    /* ======== DEBUG ======== */
    //System.out.println("[" + S[Snear] + ", " + X[i] + ", " + S[Snear + 1] + "]");
    //System.out.println("[" + T[Tnear] + ", " + X[i] + ", " + T[Tnear + 1] + "]");
    /* ======== /DEBUG ======== */

    return minimum(caliculate(i,Snear,Tnear),caliculate(i,Snear,Tnear+1),caliculate(i,Snear+1,Tnear),caliculate(i,Snear+1,Tnear+1));
    /*if((Snear<=X[i] && Tnear<=X[i]) || (Snear>=X[i] && Tnear>=X[i])){
      return Math.max(Math.abs(X[i]-Snear),Math.abs(X[i]-Tnear));
    }
    else{
    return Math.max(Math.abs(X[i]-Snear),Math.abs(X[i]-Tnear))+2*Math.min(Math.abs(X[i]-Snear),Math.abs(X[i]-Tnear));
    }
    */
  }

  static Long caliculate(int i,int r,int l){
    if((S[r]<=X[i] && T[l]<=X[i]) || (S[r]>=X[i] && T[l]>=X[i])){
      /* ======== DEBUG ======== */
      //System.out.println("1: " + Math.abs(X[i] - S[r]) + ", " + Math.abs(X[i] - T[l]));
      /* ======== /DEBUG ======== */
      return Math.max(Math.abs(X[i]-S[r]),Math.abs(X[i]-T[l]));
    }
    else{
      /* ======== DEBUG ======== */
      //Long t = Math.max(Math.abs(X[i]-S[r]),Math.abs(X[i]-T[l])) + 2*Math.min(Math.abs(X[i]-S[r]),Math.abs(X[i]-T[l]));
      //System.out.println("2: " + t);
      /* ======== /DEBUG ======== */
      return Math.max(Math.abs(X[i]-S[r]),Math.abs(X[i]-T[l]))+2*Math.min(Math.abs(X[i]-S[r]),Math.abs(X[i]-T[l]));
    }
  }

  static Long minimum(Long a,Long b,Long c,Long d){
    Long ans = 100000000000000000L;
    Long[] Arra= new Long[4];
    Arra[0] = a;
    Arra[1] = b;
    Arra[2] = c;
    Arra[3] = d;
    for(int i=0;i<4;i++){
      if(ans>=Arra[i]){
        ans = Arra[i];
      }
    }
    return ans;
  }

}

Measured memory_bytes: 103512
//#define _GLIBCXX_DEBUG //(compiler options)
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define sz(x) ((int)(x).size())
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
using namespace std;
using ll = long long; using ull = unsigned ll; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> T mind(T &x, const T &y) {if (y < x) {T d = y-x; x = y; return d;} else return 0;} //RETURNS A NON-POSITIVE VALUE
template<typename T> T maxd(T &x, const T &y) {if (y > x) {T d = y-x; x = y; return d;} else return 0;}
template<typename C> int uniq(C &a) {a.erase(unique(all(a)), end(a)); return sz(a);}
template<typename C, typename F> int uniq(C &a, F cmp) {a.erase(unique(all(a), cmp), end(a)); return sz(a);}
const int mod = 1e9+7, infi = 1e9; const ll infl = 1e18; const ld infd = INFINITY;

#define x(a) real(a)
#define y(a) imag(a)
using G = ll; using point = complex<G>;
istream& operator>>(istream &is, point &p){G x, y; is >> x >> y; p = {x, y}; return is;}
ostream& operator<<(ostream &os, const point &p){os << p.x() << ' ' << p.y(); return os;}
G dot(const point &a, const point &b) {return (conj(a)*b).x();}
G crs(const point &a, const point &b) {return (conj(a)*b).y();}
G ori(const point &a, const point &b, const point &c) {return crs(b-a, c-b);};
bool cmpyx(const point &a, const point &b) {return a.y()<b.y() || (a.y()==b.y()&&a.x()<b.x());};

int main()
{
    #ifndef LOCAL
    //ifstream cin("hull.in"); ofstream cout("hull.out");
    #endif // LOCAL
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout << setprecision(15);
    ll l = 2, c = 1, n; cin >> n;
    while(n--) {
        tie(l, c) = make_pair(c, l+c);
    }
    cout << l;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int array[100];
	int a,n;
	
	scanf("%d",&a);
	
	for(n=0;n<a;n++){
		scanf("%d",&array[n]);
	}
	for(n=a-1;n>=0;n--){
		printf("%d",array[n]);
		if(n==0){
			printf("\n");
		}else{
			printf(" ");
	}
	}
    return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		char[] str = sc.next().toCharArray();
		Stack<Integer> s1 = new Stack<>();
		Stack<int[]> s2 = new Stack<>();

		int sum = 0;

		for (int i = 0; i < str.length; i++) {
			char now = str[i];
			if ('\\' == now) {
				s1.push(i);
			} else if ('/' == now && !s1.isEmpty()) {
				int from = s1.pop();
				int s = (i - from);
				sum += s;
				while (!s2.isEmpty() && from < s2.peek()[0]) {
					s += s2.pop()[1];
				}
				int[] data = {from, s};
				s2.push(data);
			}

		}

		System.out.println(sum);
		System.out.print(s2.size());
		StringBuffer sb = new StringBuffer();
		while (!s2.isEmpty()) {
			sb.append(" ").append(s2.get(0)[1]);
			s2.remove(0);
		}
		System.out.println(sb.toString());
	}
}



Measured memory_bytes: 28180
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Z = sc.nextInt();
        int W = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        System.out.println( solve(N, Z, W, A) );
    }

    private static int solve(int N, int Z, int W, int[] A) {
        if( N == 1 ) {
            return Math.abs(A[N-1] - W);

        } else {
            // 全部取っていきなり終了のケース
            int case_1 = Math.abs(A[N-1] - W);

            // 相手に残ったものを取らせるケース
            int case_2 = Math.abs(A[N-1] - A[N-2]);

            return Math.max(case_1, case_2);
        }
    }
}

Measured memory_bytes: 24404
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::*;

fn main() {
    input! {
        s: chars,
        t: chars,
    }

    let mut dp = vec![vec![0; 3001]; 3001];
    let mut path: Vec<Vec<Option<(usize, usize)>>> = vec![vec![None; 3001]; 3001];

    for i in 1..s.len() + 1 {
        for j in 1..t.len() + 1 {
            if dp[i - 1][j] > dp[i][j] {
                dp[i][j] = dp[i - 1][j];
                path[i][j] = Some((i - 1, j));
            }

            if dp[i][j - 1] > dp[i][j] {
                dp[i][j] = dp[i][j - 1];
                path[i][j] = Some((i, j - 1));
            }

            if s[i - 1] == t[j - 1] && dp[i - 1][j - 1] + 1 > dp[i][j] {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                path[i][j] = Some((i - 1, j - 1));
            }
        }
    }
    let mut ans: Vec<char> = vec![];
    let mut p = path[s.len()][t.len()];

    while p.is_some() {
        match p {
            Some(x) => {
                if x.0 < s.len() && x.1 < t.len() && s[x.0] == t[x.1] {
                    ans.push(s[x.0]);
                }
                p = path[x.0][x.1];
            }
            _ => {}
        }
    }
    println!("{}", ans.into_iter().rev().collect::<String>());
}


Measured memory_bytes: 307452
import java.io.InputStreamReader
import java.io.BufferedReader

fun _Do(){
    //
    val N = scanEx.nextInt()
    val K = scanEx.nextInt()
    val ia : Array<Int> = scanEx.intArray()
    
    //
    ia.sort()
    ia.reverse()
    
    var x = 0
    for(i in 0 until K){
        x += ia[i]
    }

    println(x)
    
}

val scanEx = ScannerEx()
//
fun main( argv : Array<String> ) {

    _Do()
}
//
class ScannerEx {
    
    //
    fun nextInt():Int{
        
        if( index <= -1 ||
            ls.count() == index)
        {
            index = 0
            ls = br.readLine().split(' ')
        }

        //
        var v = ls[index]!!.toInt()
        index += 1
        return v
    }
    
    var index:Int = -1 //
    var ls:List<String?> = emptyList()   //
    
    
    //
    fun intArray(): Array<Int> {
        
        val ss = br.readLine().split(' ')
        
        val type = Array<Int>(
                ss.size,
                { ss[it].toInt() }
        )
        
        return type
    }
    
    private var br = BufferedReader(InputStreamReader(System.`in`))
}




Measured memory_bytes: 36004
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

total=0
N=int(input())

for i in range(1,N+1):
    for j in range(i,N+1):
        if i==j:
            for k in range(j,N+1):
                if j==k:
                    total += gcd(i,j,k)
                else:
                    total += 3*gcd(i,j,k)
        else:
            for k in range(j,N+1):
                if j==k:
                    total += 3*gcd(i,j,k)
                else:
                    total += 6*gcd(i,j,k)
            
print(total)


Measured memory_bytes: 9624
a, b, x = gets.split.map(&:to_f)
h = x / (a ** 2)
air_h = b - h
water_s = h * a
air_s = air_h * a
top = 90.0
bottom = 0.0

while top - bottom > 0.00000005
    angle = (top + bottom) / 2.0
    height = a * Math.tan(Math::PI * angle / 180)
    if height <= b  # 液面が壁に触れる 
        if air_s > a * height / 2  # 溢れない
            bottom = angle
        else
            top = angle
        end
    else  # 液面が底に触れる
        water_angle = 90.0 - angle
        if water_s < b * b * Math.tan(Math::PI * water_angle / 180) / 2  # 溢れない
            bottom = angle
        else
            top = angle
        end
    end
end
puts bottom


Measured memory_bytes: 1788
TTYPE = 0
X = 1
Y = 2

def main():
    buf = input()
    buflist = buf.split()
    H = int(buflist[0])
    W = int(buflist[1])
    S = []
    for i in range(H):
        buf = input()
        S.append(buf)
    searched = []
    for i in range(H):
        searched.append([])
        for j in range(W):
            searched[i].append(False)
    group_white = []
    group_black = []
    for i in range(H):
        for j in range(W):
            if searched[i][j]:
                continue
            else:
                search_stack = [[S[i][j], i, j]]
                group_white.append(0)
                group_black.append(0)
                while len(search_stack) > 0:
                    target = search_stack.pop()
                    if searched[target[X]][target[Y]]:
                        continue
                    if target[TTYPE] == '.':
                        group_white[-1] += 1
                    else:
                        group_black[-1] += 1
                    searched[target[X]][target[Y]] = True
                    if target[X] > 0:
                        if not searched[target[X]-1][target[Y]] and ((target[TTYPE] == '.' and S[target[X]-1][target[Y]] == "#") or (target[TTYPE] == '#' and S[target[X]-1][target[Y]] == ".")):
                            search_stack.append([S[target[X]-1][target[Y]], target[X]-1, target[Y]])
                    if target[Y] > 0:
                        if not searched[target[X]][target[Y]-1] and ((target[TTYPE] == '.' and S[target[X]][target[Y]-1] == "#") or (target[TTYPE] == '#' and S[target[X]][target[Y]-1] == ".")):
                            search_stack.append([S[target[X]][target[Y]-1], target[X], target[Y]-1])
                    if target[X] < H-1:
                        if not searched[target[X]+1][target[Y]] and ((target[TTYPE] == '.' and S[target[X]+1][target[Y]] == "#") or (target[TTYPE] == '#' and S[target[X]+1][target[Y]] == ".")):
                            search_stack.append([S[target[X]+1][target[Y]], target[X]+1, target[Y]])
                    if target[Y] < W-1:
                        if not searched[target[X]][target[Y]+1] and ((target[TTYPE] == '.' and S[target[X]][target[Y]+1] == "#") or (target[TTYPE] == '#' and S[target[X]][target[Y]+1] == ".")):
                            search_stack.append([S[target[X]][target[Y]+1], target[X], target[Y]+1])
    total = 0
    for i in range(len(group_black)):
        total += group_black[i] * group_white[i]
    print(total)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24436
N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))

is_good_place = [True] * (N + 1)

for _ in range(M):
    A, B = map(int, input().split())
    if H[A] == H[B]:
        is_good_place[A] = is_good_place[B] = False
    elif H[A] > H[B]:
        is_good_place[B] = False
    else:
        is_good_place[A] = False

ans = -1

for place in is_good_place:
    if place:
        ans += 1

print(ans)


Measured memory_bytes: 20144
#include <bits/stdc++.h>
using namespace std;
int a[105], b[105];
int main(){
	int n, x;
	scanf("%d%d", &n, &x);
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
	}
	sort(a+1, a+1+n);
	for(int i=1;i<=n;i++){
		if(i == n){
			b[i] = x;
		}
		else{
			b[i] = min(a[i], x);
			x -= min(a[i], x);
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(a[i] == b[i]) ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int h, w;
int s[2002][2002][5];

int main(void){
    scanf("%d %d", &h, &w);
    

    char c[2002];

    for(int i = 1; i <= h; i++){
        scanf("%s", c + 1);
        for(int j = 1; j <= w; j++){
            s[j][i][0] = c[j] == '#' ? -1 : 0;
        }
    }

    for(int j = 0; j <= w + 1; j++){
        s[j][0][0] = -1;
        s[j][h + 1][0] = -1;
    }

    for(int i = 1 ; i <= h; i++){
        s[0][i][0] = -1;
        s[w + 1][i][0] = -1;
    }

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(s[j][i][0] == -1){
                continue;
            }

            s[j][i][1] = s[j - 1][i][1] + 1;
            s[j][i][2] = s[j][i - 1][2] + 1;
        }
    }

    for(int i = h; i > 0; i--){
        for(int j = w; j > 0; j--){
            if(s[j][i][0] == -1){
                continue;
            }

            s[j][i][3] = s[j + 1][i][3] + 1;
            s[j][i][4] = s[j][i + 1][4] + 1;
        }
    }

    int result = 0;

    for(int i = h; i > 0; i--){
        for(int j = w; j > 0; j--){
            if(s[j][i][0] == -1){
                continue;
            }

            result = max(s[j][i][1] + s[j][i][2] + s[j][i][3] + s[j][i][4] - 3, result);
        }
    }

    printf("%d\n", result);

    return 0;
}

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

using namespace std;

typedef long long int lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
lli k;
vll a;
vll b, b_;
lli ans = 0;

int main(){
  cin >> n >> k;
  a = vll(n+1);
  for(lli i = 1;i <= n;i++) cin >> a[i];
  for(lli i = 1;i <= n;i++) a[i] += a[i-1];
  for(lli i = 1;i <= n;i++){
    for(lli j = i;j <= n;j++){
      b.push_back(a[j]-a[i-1]);
    }
  }
  for(lli bit = 1ll << 60;bit > 0;bit >>= 1){
    for(lli x : b){
      if((x&bit) != 0){
        b_.push_back(x);
      }
    }
    if(b_.size() >= k){
      ans = ans|bit;
      b = b_;
      b_ = vll();
    }else{
      b_ = vll();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll a, b, c;
    cin >> a >> b >> c;
    if ((a != b && b != c && a != c)||(a==b&&b==c&&a==c)) cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

Measured memory_bytes: 256
using System;
public class A009{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        
        int ans = 0;
        
        if(10<=n) ans += 9;
        else{
            Console.WriteLine(n);
            return;
        }
        
        if(1000<=n) ans += 900;
        else{
            if(99<=n) ans += n-99;
            Console.WriteLine(ans);
            return;
        }
        
        if(100000<=n) ans += 90000;
        else if(9999<=n) ans += n-9999;
        
        Console.WriteLine(ans);
    }
}

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

int d[1000][1000],dy[4]={0,0,-1,1},dx[4]={1,-1,0,0};
struct R2{int y,x;};
#define REP(i,s,n) for(int i=s;i<n;i++)
const int INF=1e9;

signed main(){
  int h,w;cin>>h>>w;
  int sy,sx,gy,gx;cin>>sy>>sx>>gy>>gx;sy--;sx--;gy--;gx--;
  vector<string> s(h);
  REP(i,0,h)cin>>s[i];
  REP(i,0,h)REP(j,0,w)d[i][j]=INF;
  deque<R2> que;
  que.push_front({sy,sx});
  d[sy][sx]=0;
  while(que.size()){
    R2 p=que.front();que.pop_front();
    REP(i,0,4){
      int Y=p.y+dy[i],X=p.x+dx[i];
      if(Y<0||Y>=h||X<0||X>=w)continue;
      if(d[Y][X]<=d[p.y][p.x]||s[Y][X]=='#')continue;
      d[Y][X]=d[p.y][p.x];
      que.push_front({Y,X});
    }
    REP(Y,max(p.y-2,0),min(h,p.y+3)){
      REP(X,max(p.x-2,0),min(w,p.x+3)){
        if(d[Y][X]<=d[p.y][p.x]+1||s[Y][X]=='#')continue;
        d[Y][X]=d[p.y][p.x]+1;
        que.push_back({Y,X});
      }
    }
  }
  if(d[gy][gx]==INF)cout<<-1<<endl;
  else cout<<d[gy][gx]<<endl;
}


Measured memory_bytes: 9476
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 998244353;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  
  vector<bool> dp(k+10,false);
  rep(i,k+1) {
    rep(j,n) {
      if(i-a[j]<0) continue;
      if(!dp[i-a[j]]) dp[i]=true;
    }
  }
      
  cout<<(!dp[k] ? "Second" : "First")<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,t=0;
vi b;

int main(){
	cin>>n;
	b=vi(n+1,inf);
	for(int i=1;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++) t+=min(b[i],b[i+1]);
	cout<<t<<endl;
}

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

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

  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
    for (int j = 0; j < M; j++) {
        cin >> A.at(i).at(j);
    }
  }
  
  int64_t res2=-1;
  
  for (int bit = 0; bit < (1<<N) ; ++bit) {
       int64_t res=0;
       vector<int64_t> Mon(M);
       for (int j = 0; j < M; j++) {
           Mon.at(j)=0;
       } 
       for (int i = 0; i < N; ++i) {
           if (bit & (1<<i)) {
              res+=C.at(i);
              for (int j = 0; j < M; j++) {
                  Mon.at(j)+=A.at(i).at(j);
              } 
           }
       }
       
       bool ans = true;
       for (int j = 0; j < M; j++) {
         if (Mon.at(j)< X){
            ans=false;
            break;
         }
       }
       if (ans==true && res>0) {
          if (res2<=0) res2=res;
          else res2=min(res2,res);
       }
   }

   cout << res2 << endl;
}

Measured memory_bytes: 3636
var log = console.log;
if (typeof process != "undefined") {
	var input = "";
	process.stdin.resume();
	process.stdin.setEncoding('utf8');
	process.stdin.on('data', function (chunk) {
		input += chunk;
	});
	process.stdin.on('end', function () {
		var lines = input.split("\n");
		main(lines);
	});
}

//-----

function main(lines) {
	lines.shift();
	while (lines.length > 0) {
		var dataset = lines.slice(0, 2);
		dataset = dataset.map(function (row) {
			return row.split("").filter(function (e) {
				var code = e.charCodeAt(0);
				return (97 <= code && code <= 122)||(65 <= code && code <= 90);
			}).join("");
		});
		processDataset(dataset);
		lines = lines.slice(2);
	}
}

function processDataset(dataset) {
	var A = [];
	var f = dataset[0];
	var s = dataset[1];
	for (var i = 0; i < f.length; i++) {
		A[i] = [];
		for (var j = 0; j < s.length; j++) {
			if (f.charAt(i) == s.charAt(j)) {
				A[i][j] = 1;
			} else {
				A[i][j] = 0;
			}
			if (i == 0 && j == 0) {
				A[i][j] += 0;
			} else if (i == 0) {
				A[i][j] = Math.max(A[i][j - 1], A[i][j]);
			} else if (j == 0) {
				A[i][j] = Math.max(A[i - 1][j], A[i][j]);
			} else {
				A[i][j] = Math.min(Math.max(A[i - 1][j], A[i][j - 1]), Math.min(i, j) + 1);
				if(A[i - 1][j] == A[i][j - 1] && A[i][j-1] == A[i-1][j-1] && f.charAt(i) == s.charAt(j) ){
					A[i][j]++;
				}
			}
			1;
			if(i == f.length - 1 && j == s.length - 1){
				log(A[i][j]);
			}
		}
	}
}

Measured memory_bytes: 98252
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;

int n;

struct node{
	int l,r;
	int key;
	void init(int a){
		l=r=-1;
		key=a;
	}
};
struct bst{
	int size;
	node t[600001];
	void init(){
		size=0;
	}
	void insert(int v){
		int i=0;
		while(i<size){
			int& child=(v<t[i].key?t[i].l:t[i].r);
			if(child==-1)child=size;
			i=child;
		}
		t[size++].init(v);
	}
	bool find(int v){
		int i=0;
		while(i<size){
			if(t[i].key==v)return true;
			int child=(v<t[i].key?t[i].l:t[i].r);
			if(child==-1)child=size;
			i=child;
		}
		return false;
	}

	void preorder(int pos){
		if(pos==-1|| pos==size)return;
		printf(" %d",t[pos].key);
		preorder(t[pos].l);
		preorder(t[pos].r);
	}

	void inorder(int pos){
		if(pos==-1|| pos==size)return;
		inorder(t[pos].l);
		printf(" %d",t[pos].key);
		inorder(t[pos].r);
	}

	void postorder(int pos){
		if(pos==-1|| pos==size)return;
		postorder(t[pos].l);
		postorder(t[pos].r);
		printf(" %d",t[pos].key);
	}
};

bst T;

int main(void){
	scanf("%d",&n);
	char str[100];
	for(int i=0;i<n;i++){
		scanf("%s",str);
		if(str[0]=='i'){
			int a;
			scanf("%d",&a);
			T.insert(a);
		}else if(str[0]=='f'){
			int a;
			scanf("%d",&a);
			printf("%s\n",T.find(a)?"yes":"no");
		}else{
			T.inorder(0);
			printf("\n");
			T.preorder(0);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 7272
import Control.Applicative
import Data.List
main =
    zipWith id [h,m,s] . repeat <$> readLn
    >>= putStrLn . (intercalate ":") . map show
    where
    h x = x `div` 3600
    m x = x `mod` 3600 `div` 60
    s x = x `mod` 3600 `mod` 60 


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    int x=n/100;
    if(n<=x*111){
        cout<<x*111<<endl;
    }else{
        cout<<(x+1)*111<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
program abc147e
  implicit none
  integer h,w
  integer a(80,80),b(80,80)
  logical ::d(80,80,0:159*80)=.false.
  integer i,j,k,l,n,m
  read(*,*) h,w
  n=(h+w-1)*80
  do i=1,h
     read(*,*) a(i,1:w)
  end do
  do i=1,h
     read(*,*) b(i,1:w)
     a(i,1:w)=abs(a(i,1:w)-b(i,1:w))
  end do
  
  d(1,1,a(1,1))=.true.
  do i=1,h
     do j=1,w
        if(i>1) then
           do k=0,n
              if(d(i-1,j,k)) then
                 d(i,j,k+a(i,j))=.true.
                 d(i,j,abs(k-a(i,j)))=.true.
              end if
           end do
        end if
        if(j>1) then
           do k=0,n
              if(d(i,j-1,k)) then
                 d(i,j,k+a(i,j))=.true.
                 d(i,j,abs(k-a(i,j)))=.true.
              end if
           end do
        end if
     end do
  end do
  do i=0,n
     if(d(h,w,i)) then
        print*,i
        stop
     end if
  end do
end program abc147e




Measured memory_bytes: 317824