akhauriyash/Code-Regression huggingface dataset:
from heapq import heappop, heappush, heapify
from collections import deque

class Graph():  #directed
    def __init__(self, n, edge):
        self.n = n
        self.graph = [[] for _ in range(n)]
        self.deg = [0 for _ in range(n)]
        for e in edge:
            self.graph[e[0]].append((e[1], e[2]))
            self.deg[e[1]] += 1

    def dijkstra(self, s, INF=10**18):
        dist = [INF for _ in range(self.n)]
        dist[s] = 0
        heap = [(0, s)]
        while heap:
            cost, node = heappop(heap)
            if dist[node] < cost:
                continue
            for adj, adjcost in self.graph[node]:
                if dist[node] + adjcost < dist[adj]:
                    dist[adj] = dist[node] + adjcost
                    heappush(heap, (dist[adj], adj))
        return dist

N, M, S = map(int, input().split())
T = [tuple(map(int, input().split())) for _ in range(M)]
C = [tuple(map(int, input().split())) for _ in range(N)]

node = [[0 for j in range(2500)] for i in range(N)]
E = []

for i in range(M):
    u, v, a, b = T[i]
    u -= 1
    v -= 1
    for c in range(2500):
        if c - a >= 0:
            E.append((2500 * u + c, 2500 * v + c - a, b))
            E.append((2500 * v + c, 2500 * u + c - a, b))

for i in range(N):
    a, b = C[i]
    for c in range(2500):
        if c + a < 2500:
            E.append((2500 * i + c, 2500 * i + c + a, b))
        else:
            E.append((2500 * i + c, 2500 * i + 2499, b))

G = Graph(2500 * N, E)
D = G.dijkstra(min(2499, S))

for i in range(N):
    if i == 0:
        continue
    res = 10**18
    for j in range(2500):
        res = min(res, D[i * 2500 + j])
    print(res)

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

#ifdef local
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	string s; cin >> s;
	cout << ((s.size()%2)^(s[0]==s.back())?"First":"Second");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3

n = int(input())
b = list(map(int, input().split()))
a = list(map(int, input().split()))

ans = 0
for i in range(len(a)):
    power = a[i]
    if b[i] <= power:
        power = power - b[i]
        ans += b[i]
        b[i] = 0
        if b[i+1] <= power:
            power = power - b[i+1]
            ans += b[i+1]
            b[i+1] = 0
        else:
            ans += power
            b[i+1] -= power
            power = 0
    else:
        ans += power
        b[i] -= power
        power = 0
print(ans)


Measured memory_bytes: 18624
#include<cstdio>
using namespace std;
const int N=1e5+10;
int n,a[N];
int gcd(int x,int y)
{
	if (!y) return x;
	return gcd(y,x%y);
}
int dg()
{
	int cnt1=0,cnt2=0,p=0;
	for (int i=1;i<=n;i++) 
	{
		if (a[i]&1) cnt1++;else cnt2++;
		if (a[i]==1) p=1;
	}	
	if (cnt2&1) return 1;
	if (cnt1>1||p) return 0;
	int g;
	for (int i=1;i<=n;i++) if (a[i]&1) 
	{
		g=i;
		break;
	} 
	if (a[g]==1) return 0;
	a[g]--;
	int num=a[1];
	for (int i=2;i<=n;i++) num=gcd(num,a[i]);
	for (int i=1;i<=n;i++) a[i]=a[i]/num;
	return 1-dg();
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	if (dg()) puts("First"); else puts("Second");
}
 

Measured memory_bytes: 512
//In the name of He
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long long maxn = 3e5 + 5 + 1;
const long long INF = 4e18 ;
const long long M = 1e9 + 7;
const int lg = 21;

int x,a,b;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> x >> a >> b;
	x -= a;
	a = x/b;
	cout << (x - (b*a));
	return 0;
}


Measured memory_bytes: 256
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


n = I()

dp = [0] * 2001
dp[3] = 1

for i in range(4, 2001):
    dp[i] = (dp[i - 1] + dp[i - 3]) % mod

print(dp[n])


Measured memory_bytes: 68172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    string s;cin>>s;
    ll sum=0;
    rep(i,s.size()){
        sum+=(ll)(s[i]-'0');
    }
    if(sum%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3716
'use strict';
(function(stdin) {
    var inputs = stdin.toString().trim().split('\n')[0];
    var params = inputs.split('\n')[0].split(' ').map(Number);

 (function(W,H,x,y,r) {
    // var check = [x - r < 0 , y - r < 0 , x + y > W , y + r > H];
    // console.log(check);
    if(x - r < 0 || y - r < 0 || x + r > W || y + r > H){
        console.log('No');
    }else{
        console.log('Yes');
    }
    //????????????????????????

    }(params[0],params[1],params[2],params[3],params[4])); 

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

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

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

using ll = long long;
const int limit = 100010;
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

/*long C(long n, long r){
    if(n < r) return 0;
    long p[n+1][n+1];
    p[0][0] = 1;
    for(int i = 1; i <= n; i++){
        p[i][0] = 1;
        p[i][i] = 1;
        for(int j = 1; j <= i-1; j++){
            p[i][j] = p[i-1][j] + p[i-1][j-1];
        }
    }
    return p[n][r];
}*/

long long gcd(long long a, long long b){
    if(a < b) swap(a, b);
    if(a % b == 0) {
        return b;
    }
    else{
        return gcd(b, a % b);
    }
}

long long lcm(long long a, long long b){
    return (max(a, b) / gcd(a, b)) * min(a, b);
}
 
void dfs(int v, int p, ll d){
    depth[v] = d;
    for(auto &e : tree[v]){
        if (e.to == p) continue;
        dfs(e.to, v, d + e.cost);
    }
}

void solve() {
    int N;
    cin >> N;
    
    REP(i, N-1){
        int a, b, c;
        cin >> a >> b >> c;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }

    int Q, K;
    cin >> Q >> K;
    int x[Q], y[Q];
    dfs(K, -1, 0);
    REP(i, Q) {
        cin >> x[i] >> y[i];
    }
    REP(i, Q){
        cout << depth[x[i]] + depth[y[i]] << endl;
    }
}
 
int main() {
    solve();
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n / 10 == 9 || n % 10 == 9) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#define INF (__INT32_MAX__ / 2)

using namespace std;

int main(int argc, char **argv) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    printf("%d\n", a * c <= b ? c : b / a);
}

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


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

	bool ok = false;

	if (s[0] == s[1] && s[2] == s[3] &&s[0]!=s[2]) {
		ok = true;
	}
	else if (s[0] == s[2] && s[1] == s[3] && s[0]!=s[1]) {
		ok = true;
	}
	else if (s[0] == s[3] && s[1] == s[2] && s[0]!=s[1]) {
		ok = true;
	}
	else {
		ok = false;
	}

	if (ok) {
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
}
	return  0;
}

Measured memory_bytes: 3592
import math

N = int(input())
List = []
Length = 0
for i in range(N):
    x, y = map(int, input().split())
    List.append((x,y))
    
for i in range(N):
    for j in range(i):
        Length += math.sqrt((List[i][0]-List[j][0])**2+(List[i][1]-List[j][1])**2)
        
print(Length*2/N)

Measured memory_bytes: 9204
s=input()
objectlist=s.split("RL")

numlist=[0 for i in range(len(s))]
Rindex=0


for i in range(len(objectlist)-1):
    leftpart=objectlist[i]
    rightpart=objectlist[i+1]
    Rindex+=len(leftpart)
    Lindex=Rindex+1
    rcount=leftpart.count("R")
    lcount=rightpart.count("L")
    if (rcount+lcount)%2==0:
        numlist[Rindex]=int((rcount+lcount)/2)+1
        numlist[Lindex]=int((rcount+lcount)/2)+1
    elif rcount>lcount:
        if lcount%2==0:
            if (rcount-lcount)%2==0:
                numlist[Rindex]=int((rcount+lcount-1)/2)+2
                numlist[Lindex]=int((rcount+lcount-1)/2)+1
            else:
                numlist[Rindex]=int((rcount+lcount-1)/2)+1
                numlist[Lindex]=int((rcount+lcount-1)/2)+2
        else:
            if (rcount-lcount)%2==0:
                numlist[Rindex]=int((rcount+lcount-1)/2)+1
                numlist[Lindex]=int((rcount+lcount-1)/2)+2
            else:
                numlist[Rindex]=int((rcount+lcount-1)/2)+2
                numlist[Lindex]=int((rcount+lcount-1)/2)+1
    else:
        if rcount%2==0:
            if (lcount-rcount)%2==0:
                numlist[Rindex]=int((rcount+lcount-1)/2)+1
                numlist[Lindex]=int((rcount+lcount-1)/2)+2
            else:
                numlist[Rindex]=int((rcount+lcount-1)/2)+2
                numlist[Lindex]=int((rcount+lcount-1)/2)+1
        else:
            if (lcount-rcount)%2==0:
                numlist[Rindex]=int((rcount+lcount-1)/2)+2
                numlist[Lindex]=int((rcount+lcount-1)/2)+1
            else:
                numlist[Rindex]=int((rcount+lcount-1)/2)+1
                numlist[Lindex]=int((rcount+lcount-1)/2)+2
    Rindex+=2
        
a=[str(i) for i in numlist]
print(" ".join(a))
    

Measured memory_bytes: 51192
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int A, B;
    cin >> A >> B;
    if (A + B < 10) {
        cout << A + B << endl;
    } else {
        cout << "error" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    int n; cin >> n;
    vector<ll> a(n),b(n),d(n);
    vector<pair<ll,ll>> p(n);
    ll suma = 0, sumb = 0, cnt = 0, m = 0;
    rep(i,n) {
        cin >> a[i];
        suma += a[i];
    }
    rep(i,n) {
        cin >> b[i];
        sumb += b[i];
    }
    if(suma < sumb){
        cout << -1 << endl;
    }else{
        rep(i,n) {
            d[i] = a[i] - b[i];
            if(d[i] < 0) {
                m += d[i];
                cnt++;
            }
            p[i].first = d[i];
            p[i].second = i;
        }
        m *= -1;
        sort(p.rbegin(),p.rend());
        int j = 0;
        while(m>0){
            m -= p[j].first;
            j++;
        }
        cout << j + cnt << endl;
    }

}

Measured memory_bytes: 7220
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector <int> a(n),b;
  for(int i=0;i<n;i++) cin>>a[i];

  b=a;
  if(prev_permutation(b.begin(),b.end())){
    for(int i=0;i<n;i++){
      if(i) cout<<" ";
      cout<<b[i];
    }
    cout<<endl;
  }

  b=a;
  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<b[i];
  }
  cout<<endl;

  b=a;
  if(next_permutation(b.begin(),b.end())){
    for(int i=0;i<n;i++){
      if(i) cout<<" ";
      cout<<b[i];
    }
    cout<<endl;
  }

  return 0;

}



Measured memory_bytes: 3136
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if b > a {
		a, b = b, a
	}
	if c > a {
		a, c = c, a
	}
	kotae := a*10 + b + c
	fmt.Println(kotae)

}


Measured memory_bytes: 512
#include <stdio.h>

#define YES 1
#define NO -1

void s_p(int num){
    int i = 0;
    int n, flag;
    for(i = 3; i <= num; i++){
        n = i;
        flag = NO;
        if(n % 3 == 0)
            flag = YES;
    
        while(n > 0){
            if(n % 10 == 3)
                flag = YES;
            n /= 10;
        }
        if(flag == YES)
            printf(" %d", i);
    }
    printf("\n");
}

int main(void){
    int n;
    scanf("%d", &n);
    s_p(n);

    return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include <algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

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

int f(ll a) {
  ll ad = a;
  int ans = 0;
  while(ad % 2 == 0) {
    ad /= 2;
    ans++;
  }
  return ans;
}

int main() {
  int N;
  ll M;
  cin >> N >> M;
  ll a[N];
  rep(i,N) cin >> a[i];

  int fn = f(a[0]);
  rep1(i,N) {
    if (fn != f(a[i])) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll lcmv = 1;
  rep(i,N) {
    lcmv = lcm(lcmv, a[i]/2);
    if (lcmv > M) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 0;
  ll k = 1;
  while(lcmv*k <= M) {
    k += 2;
    ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
l=list(input())
l1=['U','D']
c=0
for i in range(len(l)):
    if l[i] not in l1:
        if (i+1)%2==0 and l[i]!='L':
            c=1
            break
        if (i+1)%2!=0 and l[i]!='R':
            c=1
            break
if(c==0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
from itertools import *
n,c,*u=map(int,open(0).read().split());x,a=u[::2]+[c],[0]+list(accumulate(u[1::2]));ans=l=r=0
for b in range(n+1):t,d,l,r=a[n]-a[b],c-x[b],max(l,a[b]-x[b-1]),max(r,a[b]-2*x[b-1]);ans=max(ans,l+t-2*d,r+t-d)
print(ans)

Measured memory_bytes: 25588
#include <cstdio>

#define abs(a) (a >= 0 ? a : -a)
int N,s,d;

int pow2(int n){
		if(n == 0){
				return (1<<30);
		}
		for(int i = 1; ; i++){
				if(abs(n) % (1<<i) != 0){
					return (1<<(i-1));
				}
		}
}
int main(){
		scanf("%d",&N);
		for(int I = 0; I < N; I++){
			scanf("%d%d",&s,&d);
			int now = s;
			for(int j = 1; ; j++){
				int t = pow2(now);
				for(int k = 0; ; k++){
						if(now + (t>>k) <= d){
								now += (t>>k);
								break;
						}
				}
				if(now == d){
						printf("%d\n",j);
						break;
				}
			}
		}
		return 0;
}



Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int N;cin>>N;
    
    vector<pair<ll,int>> A(N);
    
    for(int i=0;i<N;i++){
        cin>>A[i].first;
        A[i].second=i;
    }
    
    sort(all(A));
    reverse(all(A));
    
    A.push_back(make_pair(0,-1));
    
    vector<ll> cnt(N);
    
    int mini=INF;
    
    for(int i=0;i<N;i++){
        if(A[i].first!=A[i+1].first){
            int j=A[i].second;
            mini=min(mini,j);
            cnt[mini]+=(A[i].first-A[i+1].first)*(i+1);
        }else mini=min(mini,A[i].second);
        //cout<<cnt[mini]<<endl;
    }
    
    for(int i=0;i<N;i++){
        cout<<cnt[i]<<endl;
    }
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
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);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int N,M;
    cin >> N >> M;
    VLL a(N);
    set<ll> out;
    rep(i,M){
        cin >> a[i];
        out.insert(a[i]);
    }
    VLL DP(N+1);
    DP[0]=1;
    DP[1]=1;
    rept(i,1,N+1){
        if(out.find(i-1)==out.end()){
            DP[i]=DP[i-1];
        }
        if(i>1){
            if(out.find(i-2)==out.end()){
                DP[i]+=DP[i-2];
                DP[i]%=MOD;
            }
        }
    } 
    cout << DP[N]%MOD << endl;  
}

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

int main()
{
    int H, N;
    std::cin >> H >> N;
    std::vector<int> A(N);
    std::vector<int> B(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> A[i] >> B[i];
    }

    std::vector<int> dp(H + 1, std::numeric_limits<int>::max());
    dp[0] = 0;
    for (int i = 1; i <= H; i++)
    {
        for (int j = 0; j < N; j++)
        {
            int p = (i - A[j] < 0 ? B[j] : dp[i - A[j]] + B[j]);
            dp[i] = std::min(dp[i], p);
        }
    }

    std::cout << dp[H] << std::endl;

    return 0;
}

Measured memory_bytes: 256
let get_wday m d =
  let days_of_month = [|31;29;31;30;31;30;31;31;30;31;30;31|] in
  let days_of_month_total = Array.fold_left (+) 0 (Array.sub days_of_month 0 m) in
  let days_of_year = days_of_month_total + d in
  (days_of_year+3) mod 7;;

let () =
  let print_wday w =
    let wday =
      match w with
        0 -> "Sunday"
      | 1 -> "Monday"
      | 2 -> "Tuesday"
      | 3 -> "Wednesday"
      | 4 -> "Thursday"
      | 5 -> "Friday"
      | 6 -> "Saturday"
      | _ -> "Whatever"
    in print_endline wday
  in
  let rec read () =
    let a = read_line () |> Str.split (Str.regexp " ")
            |> List.map int_of_string |> Array.of_list
    in
    if (a.(0),a.(1)) = (0,0) then ()
    else begin
        print_wday (get_wday (a.(0)-1) a.(1));read ()
      end
  in read ()
;;

Measured memory_bytes: 2064
#include <stdio.h>
#include <stdlib.h>
#define MAX_H 100000
#define MAX_W 100000
#define MAX_C 1000000007

long long H, W, A, B;
long long fact[MAX_H+MAX_W];
long long i_fact[MAX_H+MAX_W];

long long bin_pow(long long x){
    long long n=MAX_C-2, p=x, y=1;
    while (n>0) {
        if (n%2==0){
            p = ((long long)p*p) % MAX_C;
            n = n/2;
        } else {
            y = ((long long)y*p) % MAX_C;
            n--;
        }
    }
    return y;
}

void set(){
    long long i;
    fact[0] = 1; i_fact[0] = 1;
    for (i=1; i<=H+W-2; i++){
        fact[i] = ((long long)fact[i-1] * i) % MAX_C;
        i_fact[i] = bin_pow(fact[i]);
    }
}

long long combi(long long n, long long r){
    long long y;
    y = (fact[n] * i_fact[r]) % MAX_C;
    y = (y * i_fact[n-r]) % MAX_C;
    return y;
}

int main(){
    long long x, y, ans=0, i;
    scanf("%lld%lld%lld%lld", &H, &W, &A, &B);
    set();
    x = B; y = H-A-1;
    for (i=B; i<W; i++) {
        ans += combi(H-A+i-1, i) * combi(W+A-i-2, A-1);
        ans = ans % MAX_C;
    }
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 3328
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
 
using namespace std;
typedef long long ll;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())


int main() {

	std::cin.tie(0);

    ll n,k;
    cin >> n >>k;

    ll tmp,ttmp;
    bool flag=true;

    tmp = n;
    if (n == 0){
        cout << 0 << endl;
        return 0;
    }

    if (n % k == 0){
        cout << 0 << endl;
        return 0;
    }

    if(n % k != 0){
        tmp = n % k;
        ttmp = abs(tmp - k) ; 
        if(tmp < ttmp && tmp < k ){
            cout << tmp << endl;
        }else if(ttmp < tmp && ttmp < k){
            cout << ttmp << endl;
        }else if(tmp==ttmp){
            cout << tmp << endl;
        }else{
            cout << k << endl;
        }
    
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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


int main(){

	int a,b; int S=0; int T=0;
	rep(i,4){
		cin >> a;
		S+=a;
	}

	rep(i,4){
		cin >> b;
		T+=b;
	}

	if(S>=T) cout << S << endl;
	else cout << T << endl;


	return 0;
}

Measured memory_bytes: 1160
//AGC 003-B
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	int N, A[100001];
	long pair = 0;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	A[N] = 0;

	for (int i = 0; i < N; i++) {
		pair += A[i] / 2;
		if (A[i + 1] > 0) {
			pair += A[i] % 2;
			A[i + 1] -= A[i] % 2;
		}
	}
	cout << pair << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    string s;
    cin >> s;

    int k;
    cin >> k;

    set<string> v;
    for (int i = 0; i < s.size(); i++)
        for (int j = i; j >= 0 and i - j + 1 <= k; j--)
            v.insert(s.substr(j, i - j + 1));
    for (int i = 0; i < k - 1; i++)
        v.erase(v.begin());
    cout << *v.begin() << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b ? gcd(b,a%b) : a;}

//head
const int nax = 305;
double dp[nax][nax][nax]; // dp[a][b][c] = expected # of operations so far to get to a b c
// probability of getting to getting to this state at all
// probability that we eventually get to the state 0 0 0
double ev[nax][nax][nax];
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << setprecision(15);
	int n;
	cin >> n;

	vi cnt(4);
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		cnt[x]++;
	}

	dp[cnt[1]][cnt[2]][cnt[3]] = 1;

	for(int c = n; c >= 0; --c) {
		for (int b = n; b >= 0; b--) { // a can be greater than cnt[1]
			for (int a = n; a >= 0; a--) { // will move to a state that will be considered later!
				// dp[a][b][c]
				if(a == 0 && b == 0 && c == 0 || a + b + c > n) continue;
				double pWaste = (double)(n - (a + b + c)) / n;
				// pWaste + pWaste^2 +... is geometric progression
				double evWaste = pWaste / (1 - pWaste) + 1; 
				ev[a][b][c] += evWaste * dp[a][b][c]; // probability of existing
				// remove 1 -> a-1
				// we will eventually choose one of a + b + c 
				if(a != 0) {
					double pGo = (double)a / (a + b + c);
					dp[a-1][b][c] += dp[a][b][c] * pGo;
					ev[a-1][b][c] += ev[a][b][c] * pGo;
				}
				// remove 2 -> dp[a+1][b-1][c] 
				if(b != 0) {
					double pGo = (double)b/(a+b+c);
					dp[a+1][b-1][c] += dp[a][b][c] * pGo;
					ev[a+1][b-1][c] += ev[a][b][c] * pGo;
				}
				// remove 3
				if(c != 0) {
					double pGo = (double)c/(a+b+c);
					dp[a][b+1][c-1] += dp[a][b][c] * pGo;
					ev[a][b+1][c-1] += ev[a][b][c] * pGo;
				}
			}
		}
	}
	// ev is the number of wasted operations ! where the cnt[1] + ... is the minimum number
	cout << ev[0][0][0] << endl;
	
	return 0;
}


Measured memory_bytes: 438528
import java.util.*;

public class Main{
	public static void main(String args[]){
     	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	long d = sc.nextLong();
        int count = 0;
        while(n-->0){
        	long a = sc.nextLong();
            long b = sc.nextLong();
            double ans = Math.sqrt(a*a + b*b);
            if(ans<=d)
                count++;
        }
        System.out.println(count);
    }
}


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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define dump(x)  cout << #x << " = " << (x) << endl
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

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

    vector<ll> l(n);
    for(ll i = 0; i < n; i++) {
        cin >> l[i];
    }
    asort(l);

    ll cnt = 0;
    for(ll i = 0; i < n; i++) {
        for(ll j = i + 1; j < n; j++) {
            for (ll k = j + 1; k < n; k++) {
                if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] 
                && l[k] + l[i] > l[j] && l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3576
/*||>>>> Praveen Ojha <<<<>>>> 22 June 2019 <<<<>>>> 05:07:45 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=100005;
inline int powermod(int a,int n){
	int result=1;
	a=a%mod;
	while(n>0){
		if(n & 1)
			result=(a*result)%mod;
		a=(a*a)%mod;
		n/=2;
	}
	return result;
}
int cnt[N];
int32_t main(){__
	int n;
	cin>>n;
	vi a(n);
	int f=1,si=n&1;
	for(int i=0;i<n;i++)
		{
			cin>>a[i];
			if((si+a[i]&1)!=1){
				f=0;
			}
			cnt[a[i]]++;
		}
	if(cnt[0]>1)
		f=0;
	if(n&1){
		for(int i=2;i<n;i+=2){
			if(cnt[i]!=2)
			{
				f=0;
				break;
			}
		}
	}
	else{
		for(int i=1;i<n;i+=2){
			if(cnt[i]!=2)
			{
				f=0;
				break;
			}
		}
	}
	if(!f){
		return cout<<0<<"\n",0;
	}
	cout<<powermod(2,n/2)<<"\n";
return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
from itertools import chain


def solve(
    N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"
):
    ok = [1 for _ in range(N)]
    for a, b in zip(A, B):
        if H[a - 1] <= H[b - 1]:
            ok[a - 1] = 0
        if H[b - 1] <= H[a - 1]:
            ok[b - 1] = 0

    return sum(ok)


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    answer = solve(N, M, H, A, B)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 58716
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, Q;
ll M;
ll A[MAXN];
ll psum[MAXN];

int main() {
	int i, j;
	scanf("%d%lld", &N, &M);
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &A[i]);
	}
	sort(A + 1, A + 1 + N);

	for (i = N; i >= 1; --i) {
		psum[N - i + 1] = psum[N - i] + A[i];
	}
	ll l = 2ll * A[1];
	ll h = 2ll * A[N];
	ll ansCnt = -1ll;
	ll ansSum = -1ll;
	ll ansX = -1ll;
	while (l <= h) {
		ll x = (l + h) >> 1;
		ll cnt = 0;
		ll sum = 0;
		for (i = 1; i <= N; ++i) {
			ll num = (A + 1 + N) - lower_bound(A + 1, A + 1 + N, x - A[i]);
			sum += num * A[i] + psum[num];
			cnt += num;
		}
		if (cnt > M) l = x + 1ll;
		else {
			h = x - 1ll;
			ansCnt = cnt;
			ansSum = sum;
			ansX = x;
		}
	}
	if (ansX == -1ll) {
		printf("%lld\n", M * 2ll * A[1]);
		return 0;
	}
	ansSum += (M - ansCnt) * (ansX - 1ll);
	printf("%lld", ansSum);
	return 0;
}

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

int main() {
    
    int D;
    int N;
    
    cin >> D >> N;
    
    int a = 1;
    for(int i=0; i<D; i++) {
        a = a * 100;
    }
    
    int b = a * 100;
    
    int ans = a * N;
    
    if(b == ans) {
        ans += a;
    }
    
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc142_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var k = CIn.ReadInt();
      var h = CIn.ReadIntArray(n);

      Console.WriteLine(h.Count(e => e >= k));
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 19424
divide = ["dream", "dreamer", "erase", "eraser"]
S = input()[::-1]
for i in range(4): divide[i] = divide[i][::-1]

can = True
i = 0
while i < len(S):
  can2 = False
  for d in divide:
    if S[i:i+len(d)] == d:
      can2 = True
      break
  i += len(d)*(can2)
  if not can2:
    can = False
    break
print("YNEOS"[~can%2::2])

Measured memory_bytes: 3188
n = int(input())
s = [input() for i in range(n)]
t = {}
cnt = 0
for i in s:
    tmp = "".join(sorted(list(i)))
    if tmp in t:
        t[tmp] += 1
        cnt += t[tmp]
    else:
        t[tmp] = 0
    
print(cnt)

Measured memory_bytes: 24980
package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	var s string
	var k uint64
	fmt.Fscan(in, &s)
	fmt.Fscan(in, &k)

	var c1 uint64
	var n1 = "1"
	for i := 0; i < len(s); i++ {
		if s[i] != '1' {
			c1 = uint64(i)
			n1 = string(s[i])
			break
		}
	}

	if k <= c1 {
		fmt.Fprintln(out, "1")
	} else {
		fmt.Fprintln(out, n1)
	}
}


Measured memory_bytes: 512
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500 + j*100 + k*50 == X:
                ans += 1
print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        char[] cardArray={'S','H','C','D'};
        int[][] card=new int[4][13];
        int num = sc.nextInt();
        for(int i=0;i<num;i++){
            char cards=sc.next().charAt(0);
            int number = sc.nextInt();
            if(cards=='S'){
                card[0][number-1]=1;
            }
            if(cards=='H'){
                card[1][number-1]=1;
            }
            if(cards=='C'){
                card[2][number-1]=1;
            }
            if(cards=='D'){
                card[3][number-1]=1;
            }
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<13;j++){
                if(card[i][j]==0)
                System.out.printf("%c %d\n",cardArray[i],(j+1));
            }
        }
    }
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

clock_t time_p = clock();

void rtime() {
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float) 1000 * (time_p) / CLOCKS_PER_SEC << "\n";
}

#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF=1e15;
const int MOD=1e9+7;
const int N=2e5+10;

signed main() {
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    IOS;
    int t = 1;
//    cin >> t;
    while (t--) {
        int n,m,x;
        cin>>n>>m>>x;
        int mat[n][m],cost[n];
        for(int i=0;i<n;i++) {
            cin>>cost[i];
            for(int j=0;j<m;j++) {
                cin>>mat[i][j];
            }
        }
        int lt=pow(2,n)-1;
        int ans=INF;
        for(int i=0;i<=lt;i++) {
            vector<int> have(m,0);
            int c=0;
            for(int j=0;j<n;j++) {
                if(i&(1LL<<j)) {
                    c+=cost[j];
                    for(int k=0;k<m;k++) {
                        have[k]+=mat[j][k];
                    }
                }
            }
            bool ok=true;
            for(int j=0;j<m;j++) {
                if(have[j]<x) {
                    ok=false;
                }
            }
            if(ok) {
                ans=min(ans,c);
            }
        }
        if(ans==INF) {
            ans=-1;
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 4120
#include <stdio.h>
using namespace std;

int main(){
        int a,b;
        char op;
    for(int i=1;i<=20000;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?')break;
        switch(op){
        case '+':
        printf("%d\n",a+b);break;
        case '-':
        printf("%d\n",a-b);break;
        case '*':
        printf("%d\n",a*b);break;
        case '/':
        printf("%d\n",a/b);break;
        case '%':
        printf("%d\n",a%b);break;
        }
        
    }
}


Measured memory_bytes: 2728
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	string s;
	vector<string> v;
	int x,y;

	cin>>x>>y;

	for(int i=0;i<x;i++) {
		cin>>s;
		v.push_back(s);
	}

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

	for(int i=0;i<x;i++) {
		cout<<v[i];
	}

	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>

using namespace std;

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

  if (S[0] == 'R' && S[1] ==  'R' && S[2] == 'R'){
    cout << 3 << endl;
  }
  else if ( (S[0] == 'R' && S[1] ==  'R') ||  (S[1] ==  'R'&& S[2] == 'R') ){
    cout << 2 << endl;
  }
  else if (S[0] == 'R' || S[1] ==  'R' || S[2] == 'R'){
    cout << 1 << endl;
  }else {
    cout << 0 << endl;
  }

  return 0;
}




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

int solve(vector<int> &h, int k) {
	vector<int> dp(h.size(), 0);
	for (int i = 1; i < h.size(); ++i)
	{
		if (i<=k) {
			dp[i] = abs(h[i]-h[0]);
			for (int j = 0; j < i; ++j)
			{
				dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
			}
		} else {
			dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
			for (int j = i-k; j < i; ++j)
			{
				dp[i] = min(dp[i], dp[j] + abs(h[i]- h[j]));
			}
		}
	}
	return dp[h.size()-1];
}

int main(int argc, char const *argv[])
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}
	cout << solve(h, k) << "\n" ;
	return 0;
}

Measured memory_bytes: 4056
#include<cstdio>
using namespace std;
char s[105][105];
int vis[105],cnt[105];
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i)
        scanf("%s",s[i]);
    for(int i=0;i<n;++i)
    {
        int f=0;
        for(int j=0;j<m;++j)
            f+=s[i][j]=='#';
        if(!f)vis[i]=1;
    }
    for(int j=0;j<m;++j)
    {
        int f=0;
        for(int i=0;i<n;++i)
            f+=s[i][j]=='#';
        if(!f)cnt[j]=1;
    }
    for(int i=0;i<n;++i)
        if(!vis[i])
        {
            for(int j=0;j<m;++j)
                if(!cnt[j])
                    putchar(s[i][j]);
            puts("");
        }
    return 0;
}

Measured memory_bytes: 128