akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


bool check(string s) {
  int dig = 0;
  for(auto itr : s) {
	dig += (itr - '0');
	dig %= 9;
	//	cout << dig << endl;
  }
  return dig % 9 == 0;
}


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

  
  return 0;
}



Measured memory_bytes: 3464
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    string S;
    cin >> S;
    int len = (int)S.size();
    int cnt_1 = 0;
    int cnt_0 = 0;
    rep(i, len){
        if(S.at(i) == '1') cnt_1++;
        if(S.at(i) == '0') cnt_0++;
    }
    //ブロックを取り除く操作を行えなくなるのは、積んであるブロックが0か1のどちらかの種類しかない
    //状況になるときなので、取り除けるブロックの総数は、min(cnt_0, cnt_1) * 2 と表せる。
    cout << min(cnt_0, cnt_1) * 2 <<endl;
    return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    const int U = 4;

    int dp[n+1][U+1];
    rep(i, n+1) {
        rep(j, U+1) {
            dp[i][j] = -1;
        }
    }
    
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, U+1) {
            if(dp[i][j] == -1) {
                continue;
            }
            for(int k = 1; k <= U && i + k <= n; k++) {
                if( j != k || s.substr(i - j, j) != s.substr(i, k) ) {
                    dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
                }
            }
        }
    }

    int ans = 0;
    rep(j, U+1) {
        ans = max(ans, dp[n][j]);
    }

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

Measured memory_bytes: 4484
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,A[100001]={0};
  cin>>N;
  for (int i(0);i<N;i++) {
    int a;
    cin>>a;
    A[a]++;
  }
  
  int cnt(0),tmp(0);
  for (int i(0);i<=100000;i++){
    if (A[i] != 0 && A[i] %2==0) tmp++;
    if (A[i] != 0) cnt++;
  }

  if (tmp % 2 == 1) cout << cnt - 1 << endl;
  else cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
void pre(){}
void solve(){
    long long int n;cin>>n;
    cout<<1000*(n/500)+((n-500*(n/500))/5)*5<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
    string s;
    cin >> s;
    int l = s.size();
    ll ans = 0;
    rep(bit, 1<<(l-1)) {
      long a = s[0]-'0', b = 0;
      rep(i,l-1) {
        if (bit>>i & 1) {
          b += a;
          a = s[i+1] - '0';
        }
        else {
          a = a * 10 + int(s[i+1]-'0');
        }
      }
      b += a;
      ans += b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
//
//  main.cpp
//  test130
//
//  Created by  on 2019/06/16.
//  Copyright © 2 All rights reserved.
//
//
//  main.cpp
//  new
//
//  Created on 2019/06/09.
//  Copyright  All rights reserved.
//

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


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

#define int long long
using namespace std;

int n,ans;
signed main(){
    cin>>n;
    
    cout<<n*n<<endl;
}













Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;
const ll inv2 = 500000004;

template <typename T> inline void getint(T &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline ll fastpow(ll bas, ll ex){
	register ll res = 1; bas %= MOD;
	for(; ex; ex >>= 1, bas = bas * bas % MOD) if(ex & 1) res = res * bas % MOD;
	return res;
}

int N, A[200005], B[200005];
ll f[4005][4005], fac[16005] = {1}, ifac[16005], ans = 0;

inline void Init(){
	for(register int i = 1; i <= 16000; i++) fac[i] = fac[i - 1] * i % MOD;
	ifac[16000] = fastpow(fac[16000], MOD - 2);
	for(register int i = 16000; i >= 1; i--) ifac[i - 1] = ifac[i] * i % MOD;
}

inline ll C(int n, int m) {return fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;}

int main(){
	getint(N), Init();
	for(register int i = 1; i <= N; i++){
		getint(A[i]), getint(B[i]);
		f[2001 - A[i]][2001 - B[i]]++;
	}
	for(register int i = 1; i <= 4001; i++)
		for(register int j = 1; j <= 4001; j++)
			(f[i][j] += f[i - 1][j] + f[i][j - 1]) %= MOD;
	for(register int i = 1; i <= N; i++) (ans += f[2001 + A[i]][2001 + B[i]]) %= MOD;
	for(register int i = 1; i <= N; i++) (ans += MOD - C(A[i] + B[i] << 1, A[i] << 1)) %= MOD;
	return printf("%lld\n", ans * inv2 % MOD), 0;
}

Measured memory_bytes: 127360
#include <cstdio>

#define gc getchar
#define pc putchar
#define sp pc(' ')
#define ln pc('\n')

template <class t>
inline void read(t &num) {
    register char c = gc();
    register bool flag = 0;
    num = 0;
    while ((c < '0' || c > '9') && c != '-') c = gc();
    if (c == '-') flag = 1, c = gc();
    while (c >= '0' && c <= '9') num = (num << 1) + (num << 3) + c -'0', c = gc();
    flag && (num = ~(num - 1));
}
template <class t>
inline void print(t num) {
    if (num < 0) pc('-'), num = ~(num - 1);
    if (num >= 10) print(num / 10);
    pc(num % 10 + '0');
}

#include <algorithm>

int n;
int a[51];

int main() {
    read(n);
    for (int i = 1; i <= n; i++) {
        read(a[i]);
    }
    std::sort(a + 1, a + n + 1);
    double ans = a[1];
    for (int i = 2; i <= n; i++) {
        ans = (ans + a[i]) / 2.0;
    }
    printf("%lf\n", ans);
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main()
{
 long long int a,b,c,s=0;
cin>>a>>b;
  for(int i=0;i<b;i++)
  {
    cin>>c;
   s=s+c; 
  }
  if(s<=a)
  {
    long long int k=a-s;
  cout<<k;
  }else
  {
  cout<<-1;
  }
  
  
}

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskC {
        static long modpow(long a , int b){
            a%=1000000007;
            long ans = 1;
            while (b>0){
                if ((b&1)>0) ans=ans*a%1000000007;
                b>>=1;
                a=a*a%1000000007;
            }
            return ans;
        }
        static long sol(long a){
            if (a==1) return 1;
            long ans = sol(a/2);
            return ans+ans+1;
        }
        public void solve(int testNumber, InputReader in, PrintWriter out){
            int h = in.nextInt();
            int a = in.nextInt();
            System.out.println((int)Math.ceil(((double)h)/a));

        }




    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  int a = 0;
  int b = 0;
  vector<int> P(N),Q(N);
  rep(i,N)
  {
    cin >> P[i];
  }
  rep(i,N)
  {
    cin >> Q[i];
  }
  vector<int> vec(N);
  rep(i,N) vec[i] = i+1;
  int count = 0;
  while(next_permutation(ALL(vec)))
  {
    count ++;
    if(P==vec)
    {
      a = count;
    }
    if(Q==vec)
    {
      b = count;
    }
  }
  cout << abs(b-a) << endl;
  return 0;
}


Measured memory_bytes: 3564
str_in = list(input())
q = int(input())
for i in range(q):
    command = input().split()
    start_num = int(command[1])
    end_num   = int(command[2])+1
    if command[0] == 'replace':
        rep = list(command[3])
        cnt = 0
        for j in range(start_num, end_num):
            str_in[j] = rep[cnt]
            cnt += 1
    elif command[0] == 'reverse':
        end_num -= 1
        while end_num > start_num:
            str_tmp = str_in[end_num]
            str_in[end_num] = str_in[start_num]
            str_in[start_num] = str_tmp
            end_num -= 1
            start_num += 1
    elif command[0] == 'print':
        for l in range(start_num, end_num):
            print(str_in[l], end="")
        print()
    else:
        pass


Measured memory_bytes: 5740
let () =
  Scanf.scanf "%d %d %d" @@ fun n a b ->
  let h = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in

  let rec loop l r =
    if l+1 >= r then r
    else
      let m = (l+r) / 2 in
      let c = Array.fold_left (fun s e -> s + max 0 ((e - m * b + a - b - 1) / (a-b))) 0 h in
      if c <= m then loop l m else loop m r
  in
  loop 0 1010101010 |> Printf.printf "%d\n"

Measured memory_bytes: 5120
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(N, K, AB):
    M = Mod(10**9+7)
    def P(n, k):
        ret = 1
        for i in range(n, n-k, -1):
            ret = M.mul(ret, i)
        return ret
    
    g = defaultdict(list)
    for a, b in AB:
        g[a].append(b)
        g[b].append(a)
    
    s = 1
    q = g[s][:]
    done = set([s]) | set(q)
    ans = K
    ans = M.mul(ans, P(K-1, len(g[s])))
    while q:
        u = q.pop()
        for v in g[u]:
            if v not in done:
                done.add(v)
                q.append(v)
        c = len(g[u])-1
        ans = M.mul(ans, P(K-2, c))
    return ans


def main():
    N, K = read_int_n()
    AB = [read_int_n() for _ in range(N-1)]
    print(slv(N, K, AB))


if __name__ == '__main__':
    main()


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

using namespace std;

const int NMAX = 400 + 5;
const int MMAX = 100000 + 5;

int N, M;
int edgesA[MMAX];
int edgesB[MMAX];

int lastEdgeContainingNode[MMAX][NMAX];
bool active[NMAX];

priority_queue <int> pq;

bool check(int a, int b) {
    while (!pq.empty())
        pq.pop();

    for (int i = 1; i <= N; ++ i)
        active[i] = false;
    active[a] = active[b] = true;

    if (lastEdgeContainingNode[M][a])
        pq.push(lastEdgeContainingNode[M][a]);
    if (lastEdgeContainingNode[M][b] && lastEdgeContainingNode[M][a] != lastEdgeContainingNode[M][b])
        pq.push(lastEdgeContainingNode[M][b]);

    int last = M + 1;
    while (!pq.empty()) {
        int edge = pq.top();
        pq.pop();

        if (edge >= last)
            continue;

        last = edge;
        if (active[edgesA[edge]] && active[edgesB[edge]])
            return false;

        if (!active[edgesA[edge]])
            active[edgesA[edge]] = true;
        if (!active[edgesB[edge]])
            active[edgesB[edge]] = true;

        if (lastEdgeContainingNode[edge - 1][edgesA[edge]])
            pq.push(lastEdgeContainingNode[edge - 1][edgesA[edge]]);
        if (lastEdgeContainingNode[edge - 1][edgesB[edge]] && lastEdgeContainingNode[edge - 1][edgesA[edge]] != lastEdgeContainingNode[edge - 1][edgesB[edge]])
            pq.push(lastEdgeContainingNode[edge - 1][edgesB[edge]]);
    }

    return true;
}

int main()
{
    ios_base :: sync_with_stdio(false);

    cin >> N >> M;
    for (int i = 1; i <= M; ++ i) {
        int x, y;
        cin >> x >> y;
        edgesA[i] = x;
        edgesB[i] = y;

        for (int node = 1; node <= N; ++ node)
            lastEdgeContainingNode[i][node] = lastEdgeContainingNode[i - 1][node];
        lastEdgeContainingNode[i][x] = lastEdgeContainingNode[i][y] = i;
    }

    int ans = 0;
    for (int a = 1; a <= N; ++ a)
        for (int b = a + 1; b <= N; ++ b)
            if (check(a, b))
                ++ ans;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 159232
#include <iostream>

using namespace std;

int matrix[9][9] = {};
bool visited[9] = {};
int n,m;

int dfs(int current){
    bool all_visited = true;
    for(int i = 1; i <= n; i++){
        if(!visited[i])all_visited=false;
    }
    if(all_visited)return 1;
    int res = 0;
    for(int i = 1; i <= n; i++){
        if(matrix[current][i]==0)continue;
        if(visited[i])continue;
        visited[i] = true;
        res += dfs(i);
        visited[i] = false;
    }
    return res;
}
int main(){
    
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        matrix[a][b] = matrix[b][a] = 1;
    }
    visited[1]=true;
    cout << dfs(1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt()-1;
		}
		
		boolean[] use = new boolean[N];
		int id = 0;
		int count = 0;
		while(true) {
			if(use[id]) {
				count = -1;
				break;
			}
			if(id == 1) {
				break;
			}
			use[id] = true;
			count++;
			id = a[id];
		}
		System.out.println(count);
		
	}
}

Measured memory_bytes: 50960
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0281

"""
import sys
from sys import stdin
input = stdin.readline


def solve(c, a, n):
    CCA, CCC, CAN = 0, 0, 0
    CAN = min(c, a, n)                     #  CAN??????????????°
    c -= CAN
    a -= CAN

    if a > 0 and c > 0:
        CCA = min(a, c//2)        #  CCA??????????????°
        c -= (CCA * 2)
    if c > 2:
        CCC = c // 3         # CCC??????????????°
    return CAN + CCA + CCC


def main(args):
    Q = int(input())
    for _ in range(Q):
        c, a, n = map(int, input().split())
        ans = solve(c, a, n)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 5624
#include <cstdio>
#include <algorithm>
int H, W, left[2005][2005], right[2005][2005], up[2005][2005], down[2005][2005];
char S[2005][2005];
int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 1; i <= H; ++i) scanf("%s", S[i] + 1);
	for (int i = 1; i <= H; ++i)
		for (int j = 1; j <= W; ++j)
		{
			if (S[i][j] == '#')
				left[i][j] = j, up[i][j] = i;
			else
				left[i][j] = left[i][j - 1], up[i][j] = up[i - 1][j];
		}
	for (int i = 1; i <= W; ++i)
		down[H + 1][i] = H + 1;
	int ans = 0;
	for (int i = H; i; --i)
	{
		right[i][W + 1] = W + 1;
		for (int j = W; j; --j)
		{
			if (S[i][j] == '#')
				right[i][j] = j, down[i][j] = i;
			else
			{
				right[i][j] = right[i][j + 1], down[i][j] = down[i + 1][j];
				ans = std::max(ans, right[i][j] - left[i][j] - 1 + down[i][j] - up[i][j] - 1 - 1);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 66816
#include <iostream>
#include <bitset>
using namespace std;
int main(){
	int i;
	int N;
	int A;
	int S = 0;
	bitset<2000 * 2000> bs;
	bs[0] = 1;
	for (scanf("%d", &N); N--;){
		scanf("%d",&A);
		bs |= (bs << A);
		//bs |= A;
		S += A;
	}
	S = (S >> 1) + (S & 1);
	while (!bs[S]) S++;
	cout << S;

	return 0;
}

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

int main()
{
    int S[10000], T[500];
    int n, m;
    cin >> n;
    for(int i=0;i<n;++i)
    {
        cin >> S[i];
    }
    cin >> m;
    for(int i=0;i<m;++i)
    {
        cin >> T[i];
    }
    int ans = 0;
    for(int i=0;i<m;++i)
    {
        for(int j=0;j<n;++j)
        {
            if(T[i] == S[j]){
                ans += 1;
                break;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3160
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float(10 ** 5)
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n, m = LI()
G = [[] for _ in range(n)]
for _ in range(m):
    a, b = LI()
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]

par = [-2] * n
par[0] = -1
used = set()
cnt = [0] * n

def dfs(u):
    for v in G[u]:
        if v in used or par[u] == v:
            continue
        if par[v] != -2:
            print(u + 1, v + 1)
            cnt[u] ^= 1
        else:
            par[v] = u
            if dfs(v):
                print(v + 1, u + 1)
                cnt[v] ^= 1
            else:
                print(u + 1, v + 1)
                cnt[u] ^= 1
    used.add(u)
    if cnt[u]:
        return 1

if m % 2:
    print(-1)
else:
    dfs(0)

Measured memory_bytes: 118856
#!/bin/bash
':' /*
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro node:5.2-slim \
  /bin/bash -c "node /vo/$(basename $0) < /vo/g.inp"; exit $?
exit 0
*/

"use strict";

let main = (input) => {
  let eqn=input.split("\n")[0].replace(/ /g, "+");
  let ans = "win";
  if (eval(eqn) >= 22) ans= "bust"
  return ans;
};
console.log(main(require("fs").readFileSync("/dev/stdin", "utf-8")));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    string s;
    ll k;
    cin >> s >> k;
    bool flag = true;
    int n = s.size();
    for(int i = 1; i < n; i++)
    {
        if(s[i] != s[i-1]) flag = false;
    }
    if(flag)
    {
        cout << n * k / 2 << endl;
    }
    else
    {
        ll cnt = 0;
        for(int i = 1; i < n; i++)
        {
            if(s[i] == s[i-1])
            {
                cnt++;
                i++;
            }
        }
        if(s[0] != s[n-1])
        {
            cout << k * cnt << endl;
        }
        else
        {
            ll pos = 0;
            while(true)
            {
                if(s[pos] == s[pos+1])
                {
                    pos++;
                }
                else break;
            }
            ll x = pos + 1;
            pos = n-1;
            while(true)
            {
                if(s[pos] == s[pos-1])
                {
                    pos--;
                }
                else break;
            }
            ll y = n-1 - pos + 1;
            if((x + y) % 2 == 1)
            {
                cout << k * cnt << endl;
            }
            else
            {
                cout << (k-1) * (cnt+1) + cnt << endl;
            }
        }
    }
}


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

int main()
{
    string s;
    cin >> s;
    int f=0;
    for(int i=0;i<s.length();i++)
    {
        if(!((s[i]=='U')||(s[i]=='D')))
        {
            if(i%2==0 && s[i]=='L') 
            {
                f=1;
                break;
            }
            if(i%2==1 && s[i]=='R')
            {
                f=1;
                break;
            }
        }
    }
    if(f==1)    cout << "No";
    else    cout << "Yes";
    return 0;
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<ll> v(N);

  int ans = 0;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp; 
    if((i+1)%2 == 1 && tmp%2==1) ans++;
  }
  cout << ans << endl;

}


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

int main(void) {
	
	int x, a, b;

	cin >> x >> a >> b;
	x -= a;
	while (1) {
		if (x - b >= 0)
			x -= b;
		else
			break;
	}
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = Array.new(20)
x = Array.new(20).map {Array.new(20)}
y = Array.new(20).map {Array.new(20)}

1.upto(N) do |i|
  A[i] = gets.to_i
  1.upto(A[i]) do |j|
    x[i][j], y[i][j] = gets.strip.split.map(&:to_i)
  end
end

ans = 0

[0, 1].repeated_permutation(N) do |persons|
  not_exist = false
  persons.each.with_index(1) do |witness ,i|
    break if not_exist == true
    next if witness == 0
    1.upto(A[i]) do |j|
       match = y[i][j] == persons[x[i][j]-1]
       break not_exist = true if !match
    end
  end
  next if not_exist == true
  ans = [ans, persons.count(1)].max
end

print ans.to_i

Measured memory_bytes: 14436
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <bitset>

#define Z class
#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

using namespace std;
using pll = pair<long long, long long>;

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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;


int main(){
    //1/N必ず行うから定数としてもっておく
    //それぞれのNについて、Kを超えるまで2をかけ続ける
    //計算した確率を足し続ける
    double N, K; cin >> N >> K;
    double res = 0.0;
    double constdiv = 1.0 / N; 
    for (int i = 1; i <= N; i++) {
        double p = 1.0;
        int mul_N_2 = i;
        while(mul_N_2 < K) {
            mul_N_2 *= 2;
            p = p / 2;
        }
        res += constdiv * p;
    }
    printf("%.12f\n",res);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
ll a[100005],sum[100005];
int main(){
    ll n,x,m;cin>>n>>x>>m;
    ll now=x,num=1;
    while(!a[now]){
        a[now]=num;sum[num]=sum[num-1]+now;
        num++;now=now*now%m;
    }
    ll l=a[now],r=num-1;
    if(n<=r){
        cout<<sum[n]<<endl;return 0;
    }
    n-=r;ll ans=sum[r],v=n%(r-l+1);
    cout<<ans+(n/(r-l+1))*(sum[r]-sum[l-1])+(sum[l+v-1]-sum[l-1])<<endl;
}

Measured memory_bytes: 4704
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int a,b;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b;
	if (a<b) cout<<0;
	else cout<<10;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <cmath>
#include <algorithm>
using namespace std;

int h[100000];
long long d[100000];

int main() {

	int n, k;
	cin >> n >> k;

	for(int i = 0; i < n; i++)
		cin >> h[i];

	memset(d, 0, 100000);

	for(int i = 1; i < n; i++){
		long long w = d[i - 1] + abs(h[i] - h[i - 1]);
		for(int j = 1; j <= min(k, i); j++)
			w = min(d[i - j] + abs(h[i] - h[i - j]), w);

		d[i] = w;
	}

	cout << d[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1408
def main():
    INF = float("inf")

    N, M, *ABC = map(int, open(0).read().split())

    D = [INF, 0] + [INF] * (N - 1)
    E = tuple(zip(*[iter(ABC)] * 3))

    for a, b, c in E:
        D[b] = min(D[b], D[a] - c)

    ans = D[-1]

    for a, b, c in E:
        D[b] = min(D[b], D[a] - c)

    print("inf" if ans != D[-1] else -ans)

main()


Measured memory_bytes: 3572
/** https://atcoder.jp/contests/dp/tasks/dp_e */
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
vector< vector<long long> > f;
int n, W;
int w[103], v[103];

int main()
{
    cin >> n >> W;
    f.assign(n+1, vector<long long> (100003, INT_MAX));

    for(int i = 1; i<=n; i++) cin >> w[i] >> v[i];

    f[0][0] = 0;
    for(int i = 0; i< n; i++)
    for(int j = 0; j<= 100000; j++)
        if (f[i][j] != INT_MAX)
        {
            f[i+1][j] = min(f[i+1][j] , f[i][j]); //pass
            if (f[i][j] + w[i+1] <= W) f[i+1][j+v[i+1]] = min(f[i+1][j+v[i+1] ], f[i][j] + w[i+1] );
        }

    for(int i = 100000; i >= 0; i--)
    if (f[n][i] <= W) {cout << i; break; }

    return 0;
}



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

int main()
{
int n;
cin >> n;
int a[n];
int b[n];
int Aans = -1;
 int Bans = -1;
vector <int>index(n);
for(int i = 0;i<n;i++){
    cin >> a[i];
}

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

for(int i=0;i<n;i++){
    index[i] = i+1;
}
int cnt =0;
int clear = 0;
while(clear != 2){
int Aflag = 0, Bflag = 0;
for(int i=0;i<n;i++){
    if(a[i] != index[i]){
        Aflag = 1;
        continue;
    }
}
    for(int i=0;i<n;i++){
    if(b[i] != index[i]){
        Bflag = 1;
        continue;
    }
}
if(Aflag == 0){
    Aans = cnt;
    clear++;
}
if(Bflag == 0){
    Bans = cnt;
    clear++;
}
cnt++;
next_permutation(index.begin(), index.end());
}
   cout << abs(Aans - Bans) << endl;
   return 0;
}

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

bool isOK(string s)
{
  auto n = s.length();

  for (int i = 0; i < n / 2; i++)
  {
    if (s[i] != s[n - i - 1])
    {
      return false;
    }
  }
  return true;
}

int main()
{
  string s;
  cin >> s;
  auto n = s.length();

  if (!isOK(s))
  {
    cout << "No" << endl;
    return 0;
  }

  if (!isOK(s.substr(0, (n - 1) / 2)))
  {
    cout << "No" << endl;
    return 0;
  }

  if (!isOK(s.substr((n + 3) / 2 - 1, n)))
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int x[5] = {0,0,0,0,0};

    for (int i = 1; i <= 5; i++) {
        cin >> x[i];
    }
    int idx;
    for (int i = 1; i <= 5; i++) {
        if (x[i] == 0) {
            idx = i;
        }
    }
    cout << idx;
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 8005;

bool dp[MAX_N][MAX_N * 2];

std::string s;
int x, y;

int main(int argc, char **argv) {
    std::cin >> s;
    std::cin >> x >> y;

    int start_pos = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'T') {
            break;
        } else {
            start_pos++;
        }
    }

    int goal[2];
    goal[0] = x - start_pos;
    goal[1] = y;

    std::vector<int> vec[2];
    int is_y = 1;
    int tmp_length = 0;

    for (int i = start_pos + 1; i < s.size(); i++) {
        if (s[i] == 'F') {
            tmp_length++;
        } else {
            if (0 < tmp_length) {
                vec[is_y].push_back(tmp_length);
            }
            is_y = 1 - is_y;
            tmp_length = 0;
        }
    }

    if (0 < tmp_length) {
        vec[is_y].push_back(tmp_length);
    }

    for (int i = 0; i < 2; i++) {
        int sum = 0;
        for (int j = 0; j < vec[i].size(); j++) {
            sum += vec[i][j];
        }
        //std::cout << "check_sum:" << sum << " " << vec[i].size() << " " << goal[i] << std::endl;
        if (goal[i] < -sum || sum < goal[i]) {
            std::cout << "No" << std::endl;
            return 0;
        }
        for (int k = 0; k <= vec[i].size(); k++) {
            for (int j = MAX_N - sum; j <= MAX_N + sum; j++) {
                dp[k][j] = false;
            }
        }
        dp[0][MAX_N] = true;
        for (int k = 0; k < vec[i].size(); k++) {
            for (int j = MAX_N - sum; j <= MAX_N + sum; j++) {
                if (dp[k][j]) {
                    dp[k+1][j + vec[i][k]] = true;
                    dp[k+1][j - vec[i][k]] = true;
                }
            }
        }
        if (!dp[vec[i].size()][MAX_N + goal[i]]) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    std::cout << "Yes" << std::endl;
    return 0;

}

Measured memory_bytes: 42368
gets
h = gets.split(" ").map(&:to_i)

ans = 0
i = 0

while i < h.size do
  _h = h[i]
  j = i + 1
  a = 0
  while j < h.size && h[j] <= _h do
    a += 1
    _h = h[j]
    j += 1
  end

  i = j
  ans = a if a > ans
end

puts ans


Measured memory_bytes: 8580
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a;
  string s;
  cin >> a >> s;
  if (3200 <= a)
    cout << s << endl;
  else
    cout << "red" << endl;
  return 0;
}

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

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    long long ans, rem;
    ans = (n / (a + b)) * a;
    rem = n % (a + b);
    ans += min(rem, a);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;
using namespace std;

int main(){
  ll N;
  scanf("%lld", &N);

  ll sum=0;
  REP(ll, i, 1, N+1){
    if(i%3!=0 && i%5!=0) sum += i;
  }

  printf("%lld",sum);
}


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

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 5000000000000000;
constexpr auto MOD = 1000000007;

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

	cout << n * (n - 1)/2 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int m=-2;
void p(int n){
int k=n%m;n=n/m;
if (k<0) k-=m,n++;
if (n!=0) p(n);
putchar(k>9?k+55:k+48);
}
 
int main(){
int n=read();
p(n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;

ll a;

int main(){
  cin >> a;
  int ans = 0;
  ll k = 100;

  while(k < a){
    ans++;
    k = k * 1.01;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3592
N = int(input())
A = str(input())
B = str(input())
C = str(input())

count = 0
for i in range(0, N):
    if A[i] != B[i] and A[i] != C[i] and B[i] != C[i]:
        count += 2
    elif A[i] != B[i] or A[i] != C[i] or C[i] != B[i]:
        count += 1

print(count)

Measured memory_bytes: 3064
n = int(input())
s = []
t = []
for i in range(n):
  input_line = input().split()
  s.append(str(input_line[0]))
  t.append(int(input_line[1]))
  #print(i,s[i],t[i])
x = input()

sum_bool = False
sum_song = 0
for j in range(n):
  if sum_bool == True:
    sum_song = sum_song + t[j]
  if x == s[j]:
    sum_bool = True
print(sum_song)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
using LL = long long int;
int main(){
    LL x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    if(x/d < k){
        k = k - x/d;
        x = x % d;
    }else{
        cout << x-(d * k);
        return 0;
    }
    if(k % 2){
        cout << abs(x-d);
    }else{
        cout << x;
    }
    return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	double a = ri(), b = ri(), c = ri();
	double height = (double) c / a / a;
	double clearance = b - height;
	if (clearance > height) {
		printf("%.11f", atan2(b, (double) c / a * 2 / b) / acos(-1) * 180);
	} else {
		// (a / 2, clearance)
		std::cerr << (double) a / 2 << " " << clearance << std::endl;
		printf("%.11f", atan2(clearance, (double) a / 2) / acos(-1) * 180);
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int N = 0, D = 0,a=0;
	cin >> N >> D;
	a = N / (2 * D + 1);
	if (N % (2 * D + 1) != 0)
	{
		a += 1;
	}
	cout << a;
	return 0;
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  int K;
  cin >> K;
  int even, odd;
  even = K / 2;
  odd = K - even;
  cout << even * odd << endl;
  return 0;
}

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

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

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

const int INF = 9876854321;
int n, m, x;
int c[13];
int a[13][13];

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

	cin >> n >> m >> x;
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
		for (int j = 0; j < m; j++) cin >> a[i][j];
	}

	int ans = INF;
	for (int i = 0; i < (1 << n); i++)
	{
		int res = 0;
		int lv[13] = { 0, };
		for (int j = 0; j < n; j++)
		{
			if (!(i & (1 << j))) continue;
			res += c[j];
			for (int k = 0; k < m; k++) lv[k] += a[j][k];
		}

		bool isValid = true;
		for (int j = 0; j < m; j++)
		{
			if (lv[j] < x) isValid = false;
		}

		if (isValid) ans = min(ans, res);
	}

	if (ans == INF) ans = -1;
	cout << ans;
}

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

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

	int n, m, l;
	long long csum = 0;
	cin >> n >> m >> l;
	vector<vector<int>> a(n, vector<int>(m));
	vector<vector<int>> b(m, vector<int>(l));
	vector<vector<int>> c(n, vector<int>(l));
	rep(i, n){
		rep(j, m){
			cin >> a[i][j];
		}
	}
	rep(i, m){
		rep(j, l){
			cin >> b[i][j];
		}
	}
	rep(i, n){
		rep(j, l){
			rep(k, m){
				csum += a[i][k] * b[k][j];
			}
			cout << csum;
			csum = 0;
			if (j != l - 1)
				cout << ' ';
		}
		cout << '\n';
	}

	return 0;
}


Measured memory_bytes: 3292
n = int(input())
h = []

for i in range(n):
    h.append(int(input()))
    
left = [0] * n
left[0] = h[0]
for i in range(1, n):
    left[i] = max(left[i - 1], h[i])

right = [0] * n
right[-1] = h[-1]
for i in reversed(range(n - 1)):
    right[i] = max(right[i + 1], h[i])

print(right[1])
for i in range(1, n - 1):
    print(max(left[i - 1], right[i + 1]))
print(left[n - 2])

Measured memory_bytes: 15652
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef vector<long long> vll;
#define fo(i, a) for (ll i = 0; i < a; i++)
#define Fo(i, a, b) for (ll i = a; i < b; i++)
#define deb(x) cout << #x << " = " << x << "\n"
#define MAX 100
void prllString(ll n)
{
    char str[MAX];
    ll i = 0;

    while (n > 0)
    {
        ll rem = n % 26;
        if (rem == 0)
        {
            str[i++] = 'z';
            n = (n / 26) - 1;
        }
        else
        {
            str[i++] = (rem - 1) + 'a';
            n = n / 26;
        }
    }
    str[i] = '\0';
    reverse(str, str + strlen(str));
    cout << str << endl;

    return;
}
void solve()
{
    ll n;
    cin>>n;
    prllString(n);
}

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

    ll t = 1;
    //	cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> xx(n), yy(n);
    vector<pair<double,ll>> arg(n);
    REP(i, n) {
        cin >> xx[i] >> yy[i];
        arg[i] = {atan2(yy[i], xx[i]), i};
    }
    sort(ALL(arg));
    vector<ll> x(n), y(n);
    REP(i, n) x[i] = xx[arg[i].second], y[i] = yy[arg[i].second];

    ll ret = 0;
    REP(i, n) {
        ll a = 0, b = 0;
        REP(j, n) {
            a += x[(i+j)%n];
            b += y[(i+j)%n];
            chmax(ret, a*a + b*b);
        }
    }
    cout << fixed << setprecision(15) << sqrt(ret) << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

int main() {
    string s, ans="";
    cin>>s;

    REP(i, 0, s.size()){
        if(s[i]=='0'){
            ans+="0";
        }
        else if(s[i]=='1'){
            ans+="1";
        }
        else{
            if(ans.size()>0){
                ans.erase(ans.begin()+ans.size()-1);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256