akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
    vector<vector<int>> v(3, vector<int>(3));
    rep(i, 3) {
        rep(j, 3) {
            cin >> v.at(i).at(j);
        }
    }

    int n;
    cin >> n;

    rep(i, n) {
        int b;
        cin >> b;

        rep(j, 3) {
            rep(k, 3) {
                if (v.at(j).at(k) == b)
                    v.at(j).at(k) = 0;
            }
        }
    }

    rep(i, 3) {
        int s = 0;

        rep(j, 3)
            s += v.at(i).at(j);

        if (s == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(i, 3) {
        int s = 0;

        rep(j, 3)
            s += v.at(j).at(i);

        if (s == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    int s;

    s = 0;
    rep(i, 3)
        s += v.at(i).at(i);

    if (s == 0) {
        cout << "Yes" << endl;
        return 0;
    }

    s = 0;
    rep(i, 3)
        s += v.at(i).at(2 - i);

    if (s == 0) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}


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

int main() {
	int n,a[110];
	double ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		ans += 1 / double(a[i]);
	}
	cout << 1 / ans;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	final long M=(long)1e9+7;
	
	long pow(long a,long n) {
		return n!=0?pow(a*a%M,n/2)*(n%2==1?a:1)%M:1;
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		long N=sc.nextLong();
		long ans=pow(10,N)-2*pow(9,N)+pow(8,N);
		ans=(ans%M+M)%M;
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

Measured memory_bytes: 32584
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

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

  vec dp(N), tmp(N);
  dp[0] = 1;

  for (int i = 0; i + 1 < N; i++) {

    if (s[i] == '<') {
      tmp[0] = 0;
      for (int j = 1; j <= i + 1; j++) {
        tmp[j] = (tmp[j - 1] + dp[j - 1]) % MOD;
      }

    } else {
      tmp[i + 1] = dp[i + 1];
      for (int j = i; j >= 0; j--) {
        tmp[j] = (tmp[j + 1] + dp[j]) % MOD;
      }
    }

    swap(dp, tmp);
  }

  int ans = 0;
  for (int x : dp) {
    ans = (ans + x) % MOD;
  }

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


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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		while (true) {
			if (list.indexOf(s) != -1) {
				System.out.println(list.size() + 1);
				System.exit(0);
			}
			list.add(s);
			if (s % 2 == 0) {
				s /= 2;
			} else {
				s = 3 * s + 1;
			}
		}
	}
}


Measured memory_bytes: 35660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int INF = 1e9+7;

int main(){
    int h,a,cnt=0; cin>>h>>a;
    
    while(h > 0){
        h -= a;
        cnt++;
    }

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
		int i,j,n,d,x,a,ans;
		scanf("%d",&n);
		ans = n;
		scanf("%d %d",&d,&x);
		for(i = 0;i < n; i++)
		{
			scanf("%d",&a);
			for(j = 1;; j++)
			{
				if((j * a + 1) <= d)
					ans++;
				else
					break;
			}
		}
		printf("%d\n",ans + x);
		return 0;
}

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

map<int,int> ans;
ll mod = 1000000007;

void fac(int n){
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            ans[i]++;
            n/=i;
        }
    }
    if(n!=1) ans[n]++;
}

signed main(){
    int n;
    cin >> n;
    for(int i=2;i<=n;i++){
        fac(i);
    }
    ll res = 1;
    for(auto x=ans.begin();x!=ans.end();x++){
        ll u = (x->second+1)%mod;
        res*=u;
        res%=mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
s = list(input())
t = list(input())
l = len(s)
cnt=0
for x in range(l):
    if s == t:
        print('Yes')
        break
    else:
        cnt+=1
        s.insert(0, s[-1])
        s=s[:len(s)-1]
if cnt == l:
    print('No')


Measured memory_bytes: 2940
n, h = map(int, input().split())
amax = 0
bl = []
for i in range(n):
    a, b = map(int, input().split())
    amax = max(amax, a)
    bl.append(b)
bl.sort()
bl.reverse()

ans = 0
for i in range(n):
    if h <= 0:
        break
    if bl[i] <= amax:
        break
    ans += 1
    h -= bl[i]
if h > 0:
    ans += h // amax
    h -= (h // amax) * amax
if h > 0:
    ans += 1

print(ans)


Measured memory_bytes: 7392
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr long long INF = 1LL << 62;
constexpr double EPS = 1e-9;

struct custom_tf : std::numpunct<char> {
  std::string do_truename() const { return "Yes"; }
  std::string do_falsename() const { return "No"; }
};

struct Initializer {
  Initializer() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(0);
    std::cout << std::fixed << std::setprecision(15) << std::boolalpha;
    std::cout.imbue(std::locale(std::cout.getloc(), new custom_tf));
  }
} initializer;

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename T>
std::ostream &operator<<(std::ostream &os, const std::set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
std::ostream &operator<<(std::ostream &os, const std::map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { std::cout<<'\n'; }
template<class T> inline void print(const T &x) { std::cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { std::cout<<x<<", "; print(y...); }
#define dump(...) std::cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);std::cout<<'\n';

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


int main() {
  int n; cin>>n;
  vector<int> a(n); cin>>a;
  sort(a.begin(), a.end());
  long long ans = 1;
  if (n%2 == 0) {
    int t = 1;
    rep(i, n/2) {
      if (a[i*2]==a[i*2+1] and a[i*2]==t) {
        t += 2;
        ans = (ans * 2) % MOD;
      } else {
        print(0);
        return 0;
      }
    }
  } else {
    int t = 2;
    if (a[0] != 0) {
      print(0);
      return 0;
    }
    rep(i, n/2) {
      if (a[i*2+1]==a[i*2+2] and a[i*2+1]==t) {
        t += 2;
        ans = (ans * 2) % MOD;
      } else {
        print(0);
        return 0;
      }
    }
  }
  print(ans);

  return 0;
}


Measured memory_bytes: 640
use std::io;


fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str
}

fn main(){


    const MAX_N : usize = 501;

    let ln1 = read_line();
    let n : usize = (ln1.trim().parse::<i32>().unwrap() - 1) as usize;

    let mut cs : [i32 ; MAX_N] = [0 ; MAX_N];
    let mut ss : [i32 ; MAX_N] = [0 ; MAX_N];
    let mut fs : [i32 ; MAX_N] = [0 ; MAX_N];

    for i in 0..n {
        let ln2 = read_line();
        let v : Vec<i32> = ln2.split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect::<Vec<i32>>();
        cs[i] = v[0];
        ss[i] = v[1];
        fs[i] = v[2];
    }    


    for j in 0..n {
        let mut elappsed : i32 = 0;
        for i in j..n {
            if ss[i] >= elappsed {
                elappsed = ss[i] + cs[i];
            }
            else{
                elappsed = (elappsed + fs[i] - 1) / fs[i] * fs[i] + cs[i];
            }
        }
        println!("{}", elappsed);
    }
    println!("{}", 0);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void){
    int n,a=0,b=0,c=0,d=0,e=0,f=0;
    double x;
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%lf",&x);
        if(x<165.0)a++; 
        else if(165.0<=x&&x<170.0)b++;
        else if(170.0<=x&&x<175.0)c++;
        else if(175.0<=x&&x<180.0)d++;
        else if(180.0<=x&&x<185.0)e++;
        else f++;
    }
    printf("1:"); 
    for(int i=0;i<a;i++) {
        printf("*");
        if(i==a-1) printf("\n");
    }
    printf("2:"); 
    for(int i=0;i<b;i++) {
        printf("*");
        if(i==b-1) printf("\n");
    }
    printf("3:"); 
    for(int i=0;i<c;i++) {
        printf("*");
        if(i==c-1) printf("\n");
    }
    printf("4:"); 
    for(int i=0;i<d;i++) {
        printf("*");
        if(i==d-1) printf("\n");
    }
    printf("5:"); 
    for(int i=0;i<e;i++) {
        printf("*");
        if(i==e-1) printf("\n");
    }
    printf("6:"); 
    for(int i=0;i<f;i++) {
        printf("*");
        if(i==f-1) printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
int vis1[200005],vis2[200005];
vector<int>g[200005],e[200005];
map<pair<int,int>,int>mp;
void dfs1(int x,int xx)
{
	vis1[x]=xx;
	for(int i=0;i<g[x].size();i++)if(!vis1[g[x][i]])dfs1(g[x][i],xx);
}
void dfs2(int x,int xx)
{
	vis2[x]=xx;
	for(int i=0;i<e[x].size();i++)if(!vis2[e[x][i]])dfs2(e[x][i],xx);
}
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=1;i<=k;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	int cnt=1;
	memset(vis1,0,sizeof(vis1));
	memset(vis2,0,sizeof(vis2));
	for(int i=1;i<=n;i++)if(!vis1[i])dfs1(i,cnt++);
	for(int i=1;i<=n;i++)if(!vis2[i])dfs2(i,cnt++);
	for(int i=1;i<=n;i++)mp[make_pair(vis1[i],vis2[i])]++;
	for(int i=1;i<=n;i++)printf("%d ",mp[make_pair(vis1[i],vis2[i])]);
	puts("");
	return 0;
}

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

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll N;

cin >> N;

vector<ll> cnt(N,0);

ll limit = (sqrt(N)+0.5);

for(ll x = 1;x < limit;++x){
  for(ll y = 1;y < limit;++y){
    for(ll z = 1;z < limit;++z){

      ll index = (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);

      if(index > cnt.size()) continue;
      cnt[index]++;

    }
  }
}

for(ll i = 1;i <= N;++i) cout << cnt[i] << endl;

return 0;

}   


Measured memory_bytes: 3620
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('');
   xs.sort(); 
   if(xs[1] == xs[2]){
     console.log('No');
   }else if(xs[0] == xs[1] && xs[2] == xs[3]){
     console.log('Yes');
   }else{
     console.log('No');
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
    ll a,b,x; cin >>a>>b>>x;

	if (a+b>=x&&x>=a) cout <<"YES"<<endl;
	else cout <<"NO"<<endl;
	
    return 0;
}

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

int main(){
  int f[45];

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

  int n; cin >> n;
  cout << f[n] << endl;
}



Measured memory_bytes: 3104
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

int main(){
    while(1){
        string r,a;
        cin >> r >> a;
        if(r=="0")break;

        int hit = 0, blow = 0;
        for(int i=0;i<4;i++){
            if(r[i]==a[i]){
                r[i] = '-';
                a[i] = '-';
                hit += 1;
            }
        }
        for(int i=0;i<4;i++){
            if(r[i]=='-')continue;
            for(int j=0;j<4;j++){
                if(r[i]==a[j]){
                    blow += 1;
                    break;
                }
            }
        }
        cout << hit << " " << blow << endl;
    }

    return 0;
}

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

int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a.at(i);
    }

    int mx = -1;
    rep(i, n - 1)
    {
        mx = max(mx, a.at(i + 1) - a.at(i));
    }
    mx=max(mx, a.at(0)+k-a.at(n-1)) ;

    cout << k-mx << endl ;
}

Measured memory_bytes: 4048
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (n, k) = listOfInt()
    println((1 until n).fold(k, {acc, index -> acc * (k - 1)}))
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

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

using namespace std;

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

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int a,b;
    cin >> a >> b;
    cout << abs(a-b) << endl;
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>
#include <math.h>

#define SQ(x) ((x) * (x))
#define INF (100000000)
#define EPS (1e-5)

double len;
double cake[12];
double dp[1 << 12][12];
int n;

double min(double a, double b)
{
    return (b > a ? a : b);
}

double tsp(int bit, int now)
{
    int i;
    double res;
    
    if (dp[bit][now] >= 0 && now >= 0){
        return (dp[bit][now]);
    }
    
    if (bit == (1 << n) - 1){
        return (cake[now]);
    }
    
    res = INF;
    for (i = 0; i < n; i++){
        if (!((bit >> i) & 1)){
            if (now >= 0){
                res = min(res, tsp(bit | (1 << i), i) + sqrt(SQ(cake[i] + cake[now]) - SQ(cake[i] - cake[now])));
            }
            else {
                res = min(res, tsp(bit | (1 << i), i) + cake[i]);
            }
        }
    }
    
    if (now >= 0){
        return (dp[bit][now] = res);
    }
    else {
        return (res);
    }
}

int main(void)
{
    int i, j;
    
    while (scanf("%lf", &len) != EOF){
        getchar();
        n = 0;
        while (1){
            scanf("%lf", &cake[n++]);
            
            if (getchar() == '\n'){
                break;
            }
        }
        
        for (i = 0; i < (1 << n); i++){
            for (j = 0; j < n; j++){
                dp[i][j] = -1 * INF;
            }
        }
        
        if (tsp(0, -1) < len + EPS){
            printf("OK\n");
        }
        else {
            printf("NA\n");
        }
    }
    
    return (0);
}

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

int main(){
  int n, a[50], i;
  cin >> n;
  if(!n) cout << 0;
  for(i = 0; n; i++){ 
    a[i] = (n & 1);
    n = -(n>>1);
  }
  for(i--; i >= 0; i--){
    cout << a[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 44;
const int X[] = {1,0,-1,0,1,-1,1,-1};
const int Y[] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1e9 + 9;
const long long INF = 1e18;
const int inf = 1e9;

int main () {
	boost;
	int n, p;
	cin >> n >> p;
	int o = -1, z = n;
	while (n--) {int a; cin >> a; a &= 1; o += a; z -= a;}
	long long a = 1, a_ = 1;
	while (z--) a *= 2;
	if (!~o) {
		return cout << (p ? 0 : a), 0;
	}
	while (o--) a_ *= 2;
	cout << (a * a_);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int k = Integer.parseInt(str[0]);
    int x = Integer.parseInt(str[1]);
    
    int left = x-k+1;
    int right = x+k-1;
    
    for (;left <= right;){
      System.out.print(left + " ");
      left += 1;
    }
  }
}

Measured memory_bytes: 23252
a,b,m = map(int,input().split(' '))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
cost = min(A) + min(B)
i = 0
while i < m:
    x,y,c = map(int,input().split(' '))
    cost0 = A[x-1]+B[y-1]-c
    if cost0 < cost:
        cost = cost0
    i += 1
print(cost)

Measured memory_bytes: 18736
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, o = 1000000007;
  long long int result;
  cin >> n;
  result = 1;
  for (int i = 1; i <= n; i++) {
    result = result * i % o;
  }
  cout << result << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

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


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> v(N);
    ll ans = 0;
    for(auto &i : v){
        cin >> i;
        ans ^= i;
    }
    string sol = "";
    for(int i = 0 ; i < N ; i++){
        ans ^= v[i];
        sol += (to_string(ans) + " ");
        ans ^= v[i];
    }
     
    cout << sol;
}


Measured memory_bytes: 8712
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnLngs();
        var N = _[0];
        var K = _[1];
        var result = 0;
        while (Pow(K, result) <= N)
        {
            result++;
        }
        print(result);
    }

    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
public static List<T[]> AllPermutation<T>(params T[] array) where T : IComparable{var a = new List<T>(array).ToArray();var res = new List<T[]>();res.Add(new List<T>(a).ToArray());var n = a.Length;var next = true;while (next){next = false;int i;for (i = n - 2; i >= 0; i--){if (a[i].CompareTo(a[i + 1]) < 0) break;}if (i < 0) break;var j = n;do{j--;} while (a[i].CompareTo(a[j]) > 0);if (a[i].CompareTo(a[j]) < 0){var tmp = a[i];a[i] = a[j];a[j] = tmp;Array.Reverse(a, i + 1, n - i - 1);res.Add(new List<T>(a).ToArray());next = true;}}return res;}}



Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <algorithm>

using namespace std;

#define dirmax 8
int l[2];
int dir[8][2] = { {0,1}, {1,0}, {-1,0}, {0,-1}, {1,1}, {-1,1}, {1,-1}, {-1,-1} };
string ans;

void search( set<string> *v, int pos[2] , char ch[10][20]){

	for(int i = 0; i < dirmax; i++) {
		string str;
		int cpos[] = { pos[0], pos[1] };

		str += ch[pos[0]][pos[1]];

		while( true ) {
			for(int j = 0; j < 2; j++) {
				cpos[j] += dir[i][j];
				if( cpos[j] < 0 ) cpos[j] = l[j] - 1;
				if( cpos[j] >= l[j] ) cpos[j] = 0;
			}
			if( cpos[0] == pos[0] && cpos[1] == pos[1] ) break;
			str += ch[cpos[0]][cpos[1]];
			
			if( v->find(str) != v->end() ) {
				if( ( str.length() > ans.length() ) || ( str.length() == ans.length() && str < ans ) ) {
					ans = str;
				}
			}
			v->insert(str);
		}
		

	}
}

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);
	while(1){
		cin >> l[0] >> l[1];
		if( l[0] == 0 && l[1] == 0 ) break;
		char donut[10][20];
		ans = "";

		set< string > strs;

		//入力を取得する
		for(int i = 0; i < l[0]; i++) {
			string str;
			cin >> str;
			for(int j = 0; j < l[1]; j++){
				donut[i][j] = str[j];
			}
		}

		for(int i = 0; i < l[0]; i++) {
			for(int j = 0; j < l[1]; j++) {
				int pos[2];
				pos[0] = i;
				pos[1] = j;
				search( &strs, pos, donut );
			}
		}

		if(ans == "") 
			cout << 0 << endl;
		else 
			cout << ans << endl;

	}
	//while(1){}
	return 0;
}

Measured memory_bytes: 33764
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
    int n,ans=0;
    cin >> n;
    int x,m=0;
    for(int i=1;i<=n;i++){
        cin >> x;
        if(m<=x)    ans++;
        m = max(m,x);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d,vector<int>(26));
  int i,j;
  for(i=0;i<26;i++){
    cin >> c.at(i);
  }
  
  vector<int> last(26,-1);
  for(j=0;j<d;j++){
    for(i=0;i<26;i++){
      cin >> s.at(j).at(i);
    }
    vector<int> v(26);
    for(i=0;i<26;i++){
      v.at(i)=s.at(j).at(i);
      int k;
      for(k=0;k<26;k++){
        if(k!=i){
          v.at(i) -= c.at(i)*(j-last.at(i));
        }
      }
    }
    int max=v.at(0),type=0;
    for(i=0;i<26;i++){
      if(max<=v.at(i)){
        max=v.at(i);
        type=i;
      }
    }
    cout << type+1 << endl;
  }
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> vec(100010);
  for(int i=0; i<N; i++){
    int x, y;
    cin >> x >> y;
    vec.at(x-1).push_back(y);
  }
  priority_queue<int> pq;
  int ans = 0;
  
  for(int i=0; i<M; i++){
    for(int j=0; j<vec.at(i).size(); j++){
      pq.push(vec.at(i).at(j));
    }
    if(pq.size()){
      int y = pq.top();
      pq.pop();
      ans += y;
    }
  }
  cout << ans << endl;  
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
#define double long double
#define PI 3.141592653589793
typedef long long ll;
const int MOD = 1000000007;
const int INF = 11000000000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 1;i*i <= n;i++){
    if(n%i == 0){
      ret.push_back(i);
      if(i*i != n)ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

int n,k;int a[210000], f[210000];

bool isOK(int d){
  int m[210000];
  rep(i,n)m[i] = d/f[i];
  int sum = 0;
  rep(i,n)sum += max((int)0, a[i] - m[i]);
  return (sum <= k);
}

int s(){
  int ng = -1;
  int ok = INF;
  while(abs(ok-ng) > 1){
    int mid = (ok+ng) / 2;
    if(isOK(mid))ok = mid;
    else ng = mid;
  }
  return ok;
}

signed main() {
  cin>>n>>k;rep(i,n)cin>>a[i];rep(i,n)cin>>f[i];
  sort(a,a+n);sort(f,f+n, greater<int>());
  cout << s() << endl;
}




Measured memory_bytes: 4992
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int P = sc.nextInt();

		ArrayList<Integer>[] s2e = new ArrayList[N];
		ArrayList<Integer>[] e2s = new ArrayList[N];
		int[][] edge = new int[M][];
		for (int i = 0; i < M; i++) {
			int A = sc.nextInt() - 1;
			int B = sc.nextInt() - 1;
			int C = sc.nextInt() - P;

			add(s2e, A, B);
			add(e2s, B, A);
			edge[i] = new int[]{A, B, C};
		}
		boolean[] ok1 = new boolean[N];
		dfs(ok1, s2e, 0);
		boolean[] ok2 = new boolean[N];
		dfs(ok2, e2s, N-1);

		int[] sum = new int[N];
		for (int i = 1; i < N; i++) {
			sum[i] = - 5000 * 2500 * 2;
		}
		int cnt = 0;
		while (true) {
			cnt++;
			boolean updated = false;
			for (int i = 0; i < edge.length; i++) {
				int src = edge[i][0];
				int dst = edge[i][1];
				int coin = edge[i][2];
				if (sum[src] == Integer.MIN_VALUE) continue;

				if (ok1[src] && ok2[src] && ok1[dst] && ok2[dst]) {
					int next = sum[src] + coin;
					if (sum[dst] < next) {
						sum[dst] = next;
						updated = true;
					}
				}
			}
			if (!updated) {
				break;
			}
			if (cnt > N) {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(Math.max(sum[N-1], 0));
	}

	static void add(ArrayList<Integer>[] target, int a, int b) {
		if (target[a] == null) {
			target[a] = new ArrayList<>();
		}
		target[a].add(b);
	}

	static void dfs(boolean[] nodes, ArrayList<Integer>[] edges, int pos) {
		if (nodes[pos]) return;
		nodes[pos] = true;
		if (edges[pos] != null){
			for (int next : edges[pos]) {
				dfs(nodes, edges, next);
			}
		}
	}
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
string s;


int main(){
	cin >> s;
	s += "R";
	vector<int>ans(s.size());
	bool flag = true;
	int count;
	for(int i = 0; i < s.size(); i++){

		if(flag and s[i] == 'L'){
			ans[i-1] += (count + 1)/2;
			ans[i] += count / 2;
			// cout << i << " " <<count << endl;
			count = 0;
			flag = false;
			
			// for(int i=0; i < s.size(); i++)cout << ans[i] << " ";
			// cout << endl;
			
		}
		else if (!flag and s[i] == 'R'){
			ans[i-count] += (count + 1)/2;
			ans[i-count-1] += count / 2;
			count = 0;
			flag = true;
			// for(int i=0; i < s.size(); i++)cout << ans[i] << " ";
			// cout << endl;
		}
		count++;
	}
	for(int i=0; i < s.size()-1; i++)cout << ans[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int main(int argc, char **argv) {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int res = A * X + B * Y;
    res = min(res, 2 * max(X, Y) * C);
    if(X > Y)
        res = min(res, 2 * Y * C + (X - Y) * A);
    else
        res = min(res, 2 * X * C + (Y - X) * B);
    
    cout << res << endl;
}

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

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

  int N;
  cin >> N;
  for(int i=1;i<=9;i++){
    if(N % i == 0){
      int M = N/i;
      if(M >= 1 && M <= 9){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
lis = list(map(int, input().split()))

minus = 0
for i in range(n):
    if lis[i] < 0:
        minus += 1
        lis[i] = lis[i]*-1

if 0 in lis or minus % 2 == 0:
    print(sum(lis))
else:
    print(sum(lis) - 2*min(lis))

Measured memory_bytes: 20144
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

int main(){
	long long n;
	std::vector<long long> aList(5);

	std::cin>>n;

	for(int i=0; i<5; i++)
		std::cin>>aList[i];

	std::sort(aList.begin(), aList.end());

	long long ans= n/aList[0] + 5;

	if(n%aList[0]==0)
		ans--;

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

	return 0;
}

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

constexpr int D = 365;
constexpr int T = 26;
int c[D];
int s[D][T];
vector<int> ans;

void Input() {
    int tmp; cin >> tmp;
    REP(i, T) cin >> c[i];
    REP(i, D) REP(j, T) cin >> s[i][j];
    return;
}

void Commit(int day, int contest, int& score, vector<int>& last) {
    last[contest] = day;
    score += s[day - 1][contest];
    REP(type, T) score -= c[type] * (day - last[type]);
    return;
}

void Output() {
    for(auto contest: ans) cout << contest + 1 << endl;
    return;
}

double lambda = 5.0; // 5.0 is better
int FindMaxProfitContest(int day, vector<int>& last) {
    double max_profit = -1e18;
    int argmax = -1;
    REP(type, T) {
        double profit = 0;
        profit += s[day - 1][type];
        profit += lambda * c[type] * (day - last[type]);
        if(profit > max_profit) {
            max_profit = profit;
            argmax = type;
        }
    }
    return argmax;
}

int Greedy(int start_day, vector<int>& last) {
    int score = 0;
    vector<int> last_copy = last;
    for(int day = start_day; day <= D; day++) {
        int contest = FindMaxProfitContest(day, last_copy);
        Commit(day, contest, score, last_copy);
    }
    return score;
}

int FindMaxProfitContestWithPredict(int day, vector<int>& last) {
    double max_profit = -1e18;
    int argmax = -1;
    REP(type, T) {
        double profit = 0;

        profit += s[day - 1][type];
        profit += lambda * c[type] * (day - last[type]);

        int tmp = last[type];
        last[type] = day;
        profit += Greedy(day + 1, last);
        last[type] = tmp;

        if(profit > max_profit) {
            max_profit = profit;
            argmax = type;
        }
    }
    return argmax;
}

int GetRand() {
    static mt19937 mt;
    return abs((int)mt());
}

int scoring() {
    vector<int> last(T, 0);
    int score = 0;
    REP(i, D) {
        score += s[i][ans[i]];
        last[ans[i]] = i + 1;
        REP(type, T) score -= c[type] * (i + 1 - last[type]);
    }
    return score;
}

void Climbing() {
    int Q = 10000;
    REP(climb, Q) {
        int day = GetRand() % D;
        int changed = GetRand() % T;
        int tmp = ans[day];
        int crt_score = scoring();
        ans[day] = changed;
        int cgd_score = scoring();
        if(cgd_score < crt_score) ans[day] = tmp;
    }
    return;
}

int main() {
    Input();
    int score = 0;
    vector<int> last(T, 0);
    for(int day = 1; day <= D; day++) {
        int contest = FindMaxProfitContestWithPredict(day, last);
        ans.push_back(contest);
        Commit(day, contest, score, last);
    }
    Climbing();
    Output();
    // cerr << scoring() << endl;
    return 0;
}


Measured memory_bytes: 3668
while
  a = gets
  if ! a then
    exit
  end
  a.chomp!

  c=0

  while true
    if (! (a =~ /^S*(R+)(S|$)/)) then
      puts c
      break
    end
    x=$1
    y=$2
        
    if c < x.size then
      c = x.size
    end
    a = y
  end
end



Measured memory_bytes: 14196
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>

using namespace std;


int main()
{
  int n;
  double m, sum = 0;
  int p[1000] = {0};
  while(true)
  {
    sum = 0;
    cin >> n;
    if(!n)
      break;
    for(int i = 0; i < n; i++)
    {
      cin >> p[i];
      sum += p[i];
    }
    m = sum / n;
    sum	= 0;
    for(int i = 0; i < n; i++)
    {
      sum += pow(p[i] - m, 2);
    }
    printf("%lf\n", sqrt(sum / n));
  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s;
  cin >> s;
  
  rep(i,s.size()){
    if(i%2 == 0){
      cout << s[i];
    }
  }
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    ll H;
    cin >> N >> H;
    vector<ll> a(N), b(N);
    rep(i, 0, N) cin >> a[i] >> b[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    int ans = 0;
    ll damage = 0;
    rep(i, 0, N)
    {
        if (b[i] < a[0]) break;

        damage += b[i];
        ++ans;

        if (damage >= H) break;
    }

    if (damage < H)
    {
        ans += (H - damage + a[0] - 1) / a[0];
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <tuple>
#define INF 100000000
#define MOD 1000000007
using namespace std;
int main(void){
  char str[5];
  cin>>str;
  if(str[0]=='A'){cout<<'T';}
  if(str[0]=='T'){cout<<'A';}
  if(str[0]=='G'){cout<<'C';}
  if(str[0]=='C'){cout<<'G';}
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdio>
using namespace std;
int n, k, x, y;
int main() {
	cin >> n >> k >> x >> y;
	if (k >= n)k = n;
	cout << k*x + (n - k)*y << endl;
	return 0;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int r[n]={0};
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    r[a-1]++;
    r[b-1]++;
  }
  for(int i=0;i<n;i++){
    cout << r[i] << endl;
  }
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, x = na()
li = []
ct = n
for i in range(n):
    li.append(ni())
rest = x - sum(li)
ct += rest // min(li)
print(ct)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int N;
int F[100][20];
int P[100][20];
int mi[20];
long long int admi = -1000000000000;
long long int culu(){
    long long int ans = 0;
    long long int kabu[N] = {0};
    bool result = true;
    for(int a = 0;a < 10;a++){
        if(mi[a] == 1)result = false;
    }
    if(result)return -10000000000000;
    for(int a = 0;a < 10;a++){
        if(mi[a] == 1){
            for(int b = 0;b < N;b++){
                if(F[b][a] == 1){
                    kabu[b]++;
                }
            }
        }
    }
    for(int a = 0;a < N;a++){
        ans += P[a][kabu[a]];
    }
    return ans;
}
long long int func(int i){
    if(i == 10){
        admi = max(admi,culu());
        return admi;
    }
    mi[i] = 0;func(i+1);
    mi[i] = 1;func(i+1);
}
int main()
{
    cin >> N;
    for(int a = 0;a < N;a++){
        for(int b = 0;b < 10;b++){
            cin >> F[a][b];
        }
    }
    for(int a = 0;a < N;a++){
        for(int b = 0;b < 11;b++){
            cin >> P[a][b];
        }
    }
    cout<<func(0)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll dp[3001][3001];
struct{
    ll p1, p2;
} path[3001][3001];
string s, t;
deque<char> res;
ll recurse(ll pos1,ll pos2,ll sz1,ll sz2){
    if(pos1>=sz1||pos2>=sz2){
        return dp[pos1][pos2] = 0;
    }
    if(dp[pos1][pos2]!=-1){
        return dp[pos1][pos2];
    }
    char ch;
    ll prevmaxi = -20;
    ll maxi = recurse(pos1 , pos2 + 1, sz1, sz2);
    if(maxi!=prevmaxi){
        prevmaxi = maxi;
        path[pos1][pos2].p1 = pos1;
        path[pos1][pos2].p2 = pos2+1;
    }
    maxi = max(maxi, recurse(pos1 + 1, pos2, sz1, sz2));
    if(maxi!=prevmaxi){
        prevmaxi = maxi;
        path[pos1][pos2].p1 = pos1+1;
        path[pos1][pos2].p2 = pos2;
    }
    if(s[pos1]==t[pos2]){
        maxi = max(maxi, 1 + recurse(pos1 + 1, pos2 + 1, sz1, sz2));
        if(maxi!=prevmaxi){
             prevmaxi = maxi;
            path[pos1][pos2].p1 = pos1+1;
            path[pos1][pos2].p2 = pos2+1;
        }
    }
    return dp[pos1][pos2] = maxi;
}
void print(ll pos1,ll pos2,ll sz1,ll sz2){
    if(pos1>=sz1||pos2>=sz2){
        return ;
    }
    ll kola = abs(path[pos1][pos2].p1 - pos1) + abs(path[pos1][pos2].p2 - pos2);
    if(kola==2){
        cout << s[pos1];
    }
    print(path[pos1][pos2].p1, path[pos1][pos2].p2, sz1, sz2);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l;
    cin >> s >> t;
    memset(dp, -1, sizeof(dp));
    ll sz1 = s.size();
    ll sz2 = t.size();
    recurse(0, 0,sz1,sz2);
    print(0, 0, sz1, sz2);
    return 0;
}

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

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll dp[100005];

int main() {
    ll N, K;
    cin >> N >> K;
    vl A(N);
    rep(i, N) cin >> A[i];

    rep(i, K + 1){
        rep(j, N){
            if (i >= A[j] and dp[i - A[j]] == 0) dp[i] = 1;
        }
    }

    cout << (dp[K] ? "First" : "Second") << '\n';
}

Measured memory_bytes: 4428