akhauriyash/Code-Regression huggingface dataset:
#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
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int x[100],y[100],h[100];
    REP(i,n){
        cin >> x[i] >> y[i] >> h[i];
    }
    REP(i,102){
        REP(j,102){
            int H = -1;
            bool ok = true;
            REP(k,n){
                if(h[k]){
                    H = h[k] + abs(i-x[k]) + abs(j-y[k]);
                    break;
                }
            }
            REP(k,n){
                if(H!=-1 && h[k]!=max(0,H-abs(i-x[k])-abs(j-y[k]))){
                    ok = false;
                    break;
                }
            }
            if(ok){
                cout << i <<" "<< j <<" "<< H << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

cash = 1000
stock = 0

for a, b in zip(A[:-1], A[1:]):
    if a <= b:
        n = int(cash / a)
        cash -= n * a
        stock += n
    else:
        cash += stock * a
        stock = 0

cash += stock * A[-1]
print(cash)


Measured memory_bytes: 9024
#define y1 askjdkasldjlkasd
#include <bits/stdc++.h>
#undef y1

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

int m, d;
int ans;

void solve () {
	fo(1, m) {
	fi(2, 9) {
		fj(2, 9) {
			int day = i * 10 + j;
			if (day < 1 || day > d) {
				continue;
			}
			if (i * j == o) {
				ans++;
			}
		}
	}
	}
	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif

	scanf("%d %d", &m, &d);	
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

int GCD(int A, int B) {
    if (B == 0) return A;
    
    return GCD(B, A % B);
}

int main() {
    int a, b;
    
    while (std::cin >> a && std::cin >> b) {
        int gcd = GCD(a, b);
        printf("%d %d\n", gcd, a/gcd*b);
    }
    
    return 0;
}



Measured memory_bytes: 3072
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include"bits/stdc++.h"
#define int ll
using namespace std;
using ll = long long ;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
//#define endl '\n'
///       Author
///        ::
///    (  NOBODY  )
///   No Copyright .....You can copy and paste it without my permission...................................
/// !!!!!!!!!!!!!!!
#define pb push_back
#define N 1000020
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
typedef pair<int,int> ii;
void scan(vector<int>&v,int siz)
{
    v.resize(siz);
    for(auto &c:v)
        cin>>c;
}
void print(vector<ll>v)
{
    for(auto c:v)
        cout<<c<<' ';
    cout<<endl;
}
void view(deque<int>v)
{
    for(auto c:v)
        cout<<c<<' ';
    cout<<endl;
}
int fenwik[N];
void update(int pos,int val)
{
    while(pos<N)
    {
        fenwik[pos]+=val;
        pos+=(pos&(-pos));
    }
}
int get(int pos)
{
    int ans=0;
    while(pos>0)
    {
        ans+=fenwik[pos];
        pos-=(pos&(-pos));
    }
    return ans;
}
int a[N],mod=1e9+7;
int goy(int base,int pow)
{
    base%=mod;
    if(pow==0)return 1;
    int x=goy(base,pow/2);
    x=(x*x)%mod;
    if(pow%2)x=(base*x)%mod;
    return x;
}
multimap<int,int>mp;
vector<pair<int,int>>Get_all(int key)
{
    vector<pair<int,int>>vv;
    typedef multimap<int, int>::iterator MMAPIterator;
    pair<MMAPIterator, MMAPIterator> result = mp.equal_range(1);
    for (MMAPIterator it = result.first; it != result.second; it++)vv.push_back({it->ff,it->ss});
    return vv;
}
int n,m;
int dp[21][1001];
int go(int pos,int bef)
{
    if(pos==m)return 1;
    if(dp[pos][bef]!=-1)return dp[pos][bef];
    int ans=0;
    for(int i=bef;i<=n;i++)
    {
        ans+=go(pos+1,i);
        ans%=mod;
    }
    return dp[pos][bef]=ans;
}
int32_t main()
{
    FAST_IO;
  int a,b;
  cin>>a>>b;
  if(a>b)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
    return 0;
}


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

int main(){
    ll s;
    
    cin>>s;
   
    ll x=1000000000,y=1;
    
   
    int x1=(x-s%x)%x;
     int y1=(s+x1)/x;
    cout<<0<<" "<<0<<" "<<x<<" "<<y<<" "<<x1<<" "<<y1;
  
}


Measured memory_bytes: 3596
/* 165a.c */
#include <stdio.h>

int main(void){
    int k,a,b,hantei=0;
    scanf("%d %d %d",&k,&a,&b);
    for(int i=a;i<=b;i++){
        if(i%k==0){
            printf("OK");
            hantei=0;
            break;
        }else{
            hantei=1;
        }
    }
    if(hantei==1){
        printf("NG");
    }
    return 0;
}

Measured memory_bytes: 1724
N,K = map(int,input().split())
S = list(input())
i = 1
if N == 1:
    print(0)
    exit()
while K >= 1 and i < N:
    if S[i] != S[0]:
        while i<N and S[i] != S[0]:
            S[i] = S[0]
            i += 1
        K -= 1
    i += 1
ans = 0
for i in range(1,N-1):
    if S[i] == "L" and S[i-1] == "L":
        ans += 1
    elif S[i] == "R" and S[i+1] == "R":
        ans += 1
if S[0] == "R" and S[1] == S[0]:
    ans += 1
if S[-1] == "L" and S[-2] == S[-1]:
    ans += 1
print(ans)

Measured memory_bytes: 4084
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 2010
using namespace std;
int n, m, q, map[N][N], s[N][N], s1[N][N], s2[N][N], ans, l1, r1, l2, r2;
char S[N];
int main(){
	scanf("%d%d%d", &n, &m, &q);
	for(int i=1; i<=n; i++){
		scanf("%s", S+1);
		for(int j=1; j<=m; j++)map[i][j]=S[j]-'0';
	}
	memset(s, 0, sizeof(s)); memset(s1, 0, sizeof(s1)); memset(s2, 0, sizeof(s2));
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+map[i][j];
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m-1; j++)s1[i][j]=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1]+(map[i][j]&map[i][j+1]);
	for(int i=1; i<=n-1; i++)
		for(int j=1; j<=m; j++)s2[i][j]=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1]+(map[i][j]&map[i+1][j]);
	for(int i=1; i<=q; i++){
		scanf("%d%d%d%d", &l1, &l2, &r1, &r2);
		ans=s[r1][r2]-s[l1-1][r2]-s[r1][l2-1]+s[l1-1][l2-1];
		ans-=s1[r1][r2-1]-s1[l1-1][r2-1]-s1[r1][l2-1]+s1[l1-1][l2-1];
		ans-=s2[r1-1][r2]-s2[l1-1][r2]-s2[r1-1][l2-1]+s2[l1-1][l2-1];
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 64768
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using rh_type = unsigned long long;

template <rh_type MOD = 0>
struct rolling_hash {
	int n;
	rh_type base;
	std::vector<rh_type> pow, hash;

	rolling_hash() {}

	template <typename Array>
	rolling_hash(const Array &s, rh_type b_ = 10007) {
		set(s, b_);
	}

	template <typename Array>
	void set(const Array &s, rh_type b_ = 10007) {
		n = s.size();
		base = b_;
		pow.resize(n + 1);
		pow[0] = 1;
		hash.resize(n + 1);
		hash[0] = 0;
		for (int i = 0; i < n; ++i) {
			if (MOD == 0) {
				pow[i + 1] = pow[i] * base;
				hash[i + 1] = s[i] + hash[i] * base;
			}
			else {
				pow[i + 1] = pow[i] * base % MOD;
				hash[i + 1] = (s[i] + hash[i] * base) % MOD;
			}
		}
	}

	rh_type get(int r) const { return hash[r]; }

	rh_type get(int l, int r) const {
		if (MOD == 0) {
			return get(r) - get(l) * pow[r - l];
		}
		else {
			return (get(r) - get(l) * pow[r - l] % MOD + MOD) % MOD;
		}
	}
};

using RH = rolling_hash<1000000007>;

using namespace std;

// 汎用的な二分探索のテンプレ(めぐる式)
int binary_search(function<bool(int)> isOk, int ng, int ok) {

	/* ok と ng のどちらが大きいかわからないことを考慮 */
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;

		if (isOk(mid)) ok = mid;
		else ng = mid;
	}
	return ok;
}

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

	RH hs(S);

	auto isOk = [&](int len) -> bool {
		map<rh_type, vector<int>> ma;

		rep(i, N - len + 1) {
			rh_type	hash = hs.get(i, i + len);
			ma[hash].push_back(i);
		}

		for (auto p : ma) {
			int f = p.second[0];
			int l = p.second.back();

			if (f + len <= l) {
				return true;
			}
		}
		return false;
	};

	cout << binary_search(isOk, N, 0) << "\n";

	return 0;
}


Measured memory_bytes: 896
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n;in(n);
	LL a[n];
	for(int i=0;i<n;i++) inl(a[i]);
	
	LL maxi = -1;
	LL ans = 0;
	for(int i=0;i<n;i++) {
		if(a[i] > maxi) maxi = a[i];
		else ans += (maxi-a[i]);
	}
	cout<<ans<<en;
}

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


Measured memory_bytes: 5220
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		boolean[]s = new boolean[31];
		for(int i=0;i<28;i++){
			s[sc.nextInt()]=true;
		}
		for(int i=1;i<31;i++){
			if(!s[i]){
				System.out.println(i);
			}
		}
	}

}

Measured memory_bytes: 17388
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops"
#include<bits/stdc++.h>
using namespace std;
#define ll int 
#define mod 998244353
#define MOD 998244353
#define inf 1000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double
#define read(a) scanf("%d" , &a)
#define print(a) printf("%d " , a)
const ll maxN=2e5;

ll n , x;
void solve(){
   cin>> n ;
   string s = "ACL";
   for(ll i=0;i<n ;i++)cout<<s;
}

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


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
#H, W=input().split()
S=input()
T=input()
S_list=list(S)
T_list=list(T)

for i in range(len(T)):
  T_list.append(T_list[i])

#print(S_list)
#print(T_list)

#H=int(H)
#W=int(W)
#C=int(C)
#K=int(K)
i=0
ID_list=[]
ID_sublist=[]
pixel_list=[]
H_dummy=0
W_dummy=0
C_dummy=0
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
#for i in range(K):
# ID_list.append(i+1)
#print(ID_list)
#for i in range(H)
#この下の行が二次元リストの読み込
#intを消して記号を読み込めるようにしたしかしこれでは文字列から読み込んでいるのと同じ
#pixel_list =  [list(input())for i in range(H)]
#for i in range(H):
#  ppixel_list=list(input())
#  
#print(pixel_list)
i=0
j=0
#high_pixel_list =[['' for i in range(W)]for j in range(2*H)]
#print(high_pixel_list)
#print(pixel_list[0][1])#行　列の順番にかっこが並んでいる

#整数二次元配列を読み込む時のやり方
#gate_list =  [list(map(int, input().split(" ")))for i in range(M)]
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！

for i in range(len(T)):
    #print(i)
    for j in range(len(T)):
     if S_list[j]!=T_list[i+j]:
         break
     elif j==len(S)-1 :
         print("Yes")
         sys.exit()
print("No")
      


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int intinput() {
	int x;
	cin >> x;
	return x;
}
vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int n,x,t;
	cin >> n >> x >> t;
	if(n%x == 0){
		cout << n/x*t << endl;
	}else{
		cout << (n/x+1) *t << endl;
	}
}

Measured memory_bytes: 3612
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        var scanner = new Scanner(System.in);
        var s = scanner.next();
 
        if ("ABC".equals(s)) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}

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

int main() {
	int n,ans = 0;
	cin >> n;
	long long l,r;
	
	for(int i = 0; i < n; i++) {
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll N;
    cin>>N;
    ll ans=0;
    rep(0,i,N){
        ans+=i;
    }
    cout<<ans<<endl;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s < t){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

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

def main():
    N,C = map(int, input().split())
    X = []
    for _ in range(N):
        X.append(list(map(int, input().split())))
    
    cw = [0] # 時計回りに数えて i 番目までを食べた時に摂取できるカロリー
    ccw = [0] # 反時計回り
    for i in range(N):
        cw.append(cw[i] + X[i][1])
        ccw.append(ccw[i] + X[N-1-i][1])
    for i in range(N):
        cw[i+1] -= X[i][0]
        ccw[i+1] -= C - X[N-1-i][0]

    ma = 0
    ga = []
    for i in range(0, N+1):
        ma = max(ma, cw[i])
        ga.append(ma)
    ma = 0
    gb = []
    for i in range(0, N+1):
        ma = max(ma, ccw[i])
        gb.append(ma)

    ans = 0
    for bi in range(N+1):
        tmp = ccw[bi] + ga[N-bi]
        if bi > 0:
            tmp -= C - X[N-bi][0]
        ans = max(ans, tmp)

    for ai in range(N+1):
        tmp = cw[ai] + gb[N-ai]
        if ai > 0:
            tmp -= X[ai-1][0]
        ans = max(ans, tmp)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
using P =  pair<int, int>;
using T = tuple<int, int ,int>;
const int INF = 1e9;
const int MAX = 10;

// vector<vector<char>> field(MAX, vector<char>(MAX));    
vector<vector<bool>> graph(MAX, vector<bool>(MAX, false));
// vector<bool> visited(MAX, false);

int n,m;

int dfs(int v, int n, vector<bool> &visited){
    bool all_visited = true;
    rep(i,n) if(visited[i] == false) all_visited = false; 
    if(all_visited) return 1;  //全ての点にたどり着いていたらプラス1して返す

    int ret = 0;
    rep(i,n){
        if(graph[v][i] == false) continue;  //行き場がない
        if(visited[i]) continue;    //すでに着いた
        visited[i] = true;
        ret += dfs(i, n, visited); 
        visited[i] = false;     //前回の操作で全ての点にたどり着いたあと、起点を未到達にする
    }
    return ret;
}

int main(){
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = true;
    }
    vector<bool> visited(MAX, false);
    visited[0] = true;
    cout << dfs(0,n , visited) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = str(input())

R = s.count("R")
G = s.count("G")
B = s.count("B")

counter = R * G * B 
#j-i != k-j
# 1 2 3 ,1 3 5

for i in range(n-1):
    for j in range(i+1,(n+i+1)//2):
        if s[i] != s[j] and s[i] != s[2*j-i] and s[2*j -i] != s[j] :
            counter -= 1

print(counter)

Measured memory_bytes: 9196
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
void solve()
{
	int n,w;
	cin>>n>>w;
	vpii g;
	int x,y;
	int dp[n+1][w+1];
	for(int i=0;i<=n;i++)
		dp[i][0]=0;
	for(int i=0;i<=w;i++)
		dp[0][i]=0;
	
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		g.pb(mkp(x,y));
	}
	sort(g.begin(),g.end());

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(g[i-1].first>j)
				dp[i][j]=dp[i-1][j];
			else
			{
				dp[i][j]=max(g[i-1].second+dp[i-1][j-g[i-1].first],dp[i-1][j]);
			}
		}
	}
	cout<<dp[n][w]<<endl;
}





signed main()
{
	fastio;
	solve();
}

Measured memory_bytes: 79232
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int a, b, c, d, n, m, tmp = 0;
	string str, keye = "keyence";
	cin >> str;
	n = str.length();
	for (int i = 0; i <= 7; i++) {
		tmp = 0;
		for (int p = 0; p < 7; p++) {
			
				if (p < i) {
					if (str[p] == keye[p]) { tmp++; }
				}
				else {
					if (str[n + p -7] == keye[p]) { tmp++; }
				}
		}
		if (tmp == 7) {
			cout << "YES"; return 0;
		}
	}
	cout << "NO";
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <malloc.h>
#include <stack>
#include <cstring>
#include <string>
#include <set>
#include <stack>
#include <unordered_map>
#define INT long long int
#define MOD 1000000007
#define oo 2000000007
using namespace std;

INT n, m, ans;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    ans = min( n, m/2 );
    m -= 2*ans;
    if( m > 0 ) ans += m/4;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
mod = 10**9 + 7
cnt = {}
def yakusuu(p,dict):
  while True :
    if p == 1 :
      break  
    for i in range(2,p+1):
      if p % i == 0:
        if i not in dict:
          dict[i] = 1
          return yakusuu(p//i,dict)
        else:
          dict[i] += 1 
          return yakusuu(p//i,dict)

for i in range(2,N+1):
  yakusuu(i,cnt)
ans = 1 
for i, j in cnt.items():
  ans *= (j + 1) 
  ans = ans % mod
print(ans)

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

int main(){
  ll r,c,k;
  cin >> r >> c >> k;
  vector<vector<ll>> v(r,vector<ll>(c,0));
  rep(i,r){
    rep(j,c){
      ll x,y,val;
      cin >> x >> y >> val;
      x--;
      y--;
      v[x][y] = val;
    }
  }
  
  vector<vector<vector<ll>>> dp(r,vector<vector<ll>>(c,vector<ll>(4,0)));
  dp[0][0][0] = 0;
  
  rep(i,r){
    rep(j,c){
      for(k=2;k>=0;k--){
        dp[i][j][k+1] = max(dp[i][j][k+1],dp[i][j][k]+v[i][j]);
      }
      rep(k,4){
        if(i+1 < r){
          dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][k]);
        }
        if(j+1 < c){
          dp[i][j+1][k] = max(dp[i][j+1][k],dp[i][j][k]);
        }
      }
    }
  }
  
  /*
  rep(j,c-1){
    dp[0][j+1][0] = dp[0][j][0];
    rep(k,3){
      if(j == 0 && k == 2){
        dp[0][j+1][k+1] = dp[0][j][k+1];
      }else{
        dp[0][j+1][k+1] = max(dp[0][j][k+1],dp[0][j][k] + v[0][j+1]);
      }
    }
  }
  
  rep(j,c){
    rep(k,4){
      cout << dp[0][j][k] << " ";
    }
    cout << endl;
  }
  */
  
  ll ans=0;
  rep(i,4){
    ans = max(ans,dp[r-1][c-1][i]);
  }
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 706656
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5+1;

int n, p, q, c[N], g[N], h[N], l[N], r[N], ans[N];

bool compare(int i, int j) {
	int u = l[i]/p, v = l[j]/p; return u != v ? (u > v) : (r[i]/p > r[j]/p); }

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cin >> n >> q;
    for (int i = 0; i < n; ++i)
    	cin >> c[i];
    for (int i = 0; i < q; ++i)
        cin >> l[i] >> r[i], --l[i], --r[i];
    for (p = 1; p*p <= n; ++p);
    iota(h,h+q,0), --p, sort(h,h+q,compare), ++g[c[0]];
    for (int i, u, v, w = 0, z = 0, j = 0, k = 1; j < q; ++j, ans[i] = k) {
    	for (i = h[j], u = l[i], v = r[i]; z > v; --z)
        	if (--g[c[z]] == 0)
            	--k;
    	for (; z < v; ++g[c[z]])
        	if (g[c[++z]] == 0)
               ++k;
    	for (; w < u; ++w)
        	if (--g[c[w]] == 0)
            	--k;
    	for (; w > u; ++g[c[w]])
        	if (g[c[--w]] == 0)
            	++k; }
    for (int i = 0; i < q; ++i)
        cout << ans[i] << '\n'; }


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

using namespace std;
#define ll long long int
#define vv vector<int>

int ans = INT_MAX;

void cal(vector< vector<int> > &a, int n, int m, int x, int u, vector<int> t){
  int f = 0;
  for(int i = 1; i<=m; i++){
    if(t[i] < x){
      f = 1;
      break;
    }
  }
  if(f){
    if(u >= n)
      return ;
    for(int i = u; i<n; i++){
      for(int j = 0; j<=m; j++)
        t[j] += a[i][j];

      cal(a, n, m, x, i+1, t);

      for(int j = 0; j<=m; j++)
        t[j] -= a[i][j];
    }
  }
  else{
    ans = min(ans, t[0]);
  }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, x;
    cin >> n >> m >> x;
    vector< vector<int> > a(n, vector<int>(m+1,0));
    for(int i = 0; i<n; i++){
      for(int j = 0; j<=m; j++)
        cin >> a[i][j];
    }
    vector<int> t(m+1, 0);
    for(int i = 0; i<n; i++){
      cal(a, n, m, x, i, t);
    }
    if(ans == INT_MAX)
      cout<< "-1";
    else
      cout<< ans;
    return 0;
}


Measured memory_bytes: 3648
def divisors(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return res

n, m = map(int, input().split())
ans = 0
nums = divisors(m)
nums.sort()
num = nums.pop(0)
while num * n <= m:
    if (m - num * n) % num == 0:
        ans = num
    if nums == []:
        break
    num = nums.pop(0)
print(ans)

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

int main(){

  int N,H,W;
  int ans = 0;

  cin >>N>>H>>W;

  for(int i = 0;i<N;i++){
    int A,B;
    cin >>A>>B;
    if(A >= H && B >= W)ans++;
  }

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


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

int main(){
int N;
cin >> N;

vector<int>count(N);
int num;
for (int i = 1; i < N; i++)
{
    cin >> num;
    count.at(num-1)++;
}

for (int i = 0; i < N; i++)
{
    cout << count.at(i) << endl;
}


}

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

struct node { 
    int key;
    node *left, *right, *parent;
};
node *root, *NIL;

void insert(int k) {
    node *y = NIL;
    node *x = root;
    node *z;

    z = (node *)malloc(sizeof(node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while( x != NIL ) {
        y = x;
        if( z->key < x->key ) x = x->left;
        else x = x->right;
    }
    z->parent = y;
    if( y == NIL ) root = z;
    else {
        if( z->key < y->key ) y->left = z;
        else y ->right = z;
    }
}

void preParse(node* u) {
    if(u == NIL) return;
    printf(" %d", u->key);
    preParse(u->left);
    preParse(u->right);
}

void inParse(node* u) {
    if(u == NIL) return;
    inParse(u->left);
    printf(" %d", u->key);
    inParse(u->right);
}

signed main() {
    ll n; scanf("%lld", &n); 
    string com;
    for( ll i = 0; i < n; i++ ) {
        cin >> com;
        if( com == "insert") {
            int x;
            scanf("%d", &x);
            insert(x);
        } else if ( com == "print" ) {
            inParse(root);
            putchar('\n');
            preParse(root);
            putchar('\n');
        }
    }

    return 0;
}




Measured memory_bytes: 26624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int A,B,C;
	cin>>A>>B>>C;
	int ans = min(C,B/A);
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


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


def main():
    N, M = MI()
    print(int(N*(N-1)/2 + M*(M-1)/2))


main()


Measured memory_bytes: 64928
// Problem Code: abc172_e

#include <iostream>
#include <numeric>
#include <vector>
#include <functional>

using namespace std;

int inverse(long long a, int m) {
	// fermat's little theorem
	int x = 1, n = m - 2;
	while (n) {
		if (n & 1)
			x = (x * a) % m;
		a = (a * a) % m;
		n >>= 1;
	}
	return x;
}

int neq(int N, int M) {
	int mod = 1e9 + 7;
	vector<long long> fact(M + 1), inv_fact(M + 1);

	// preprocess the factorials and inverse factorials
	fact[0] = 1;
	for (int i = 1; i <= M; i++)
		fact[i] = (i * fact[i - 1]) % mod;
	inv_fact[M] = inverse(fact[M], mod);
	for (int i = M - 1; i >= 0; i--)
		inv_fact[i] = ((i + 1) * inv_fact[i + 1]) % mod;
	
	// helper function to compute n choose r
	auto nCr = [&](int n, int r) {
		int den = (inv_fact[r] * inv_fact[n - r]) % mod;
		return (fact[n] * den) % mod;
	};

	long long neg = 1, ways_b = 0, ways_a = (nCr(M, N) * fact[N]) % mod;

	for (int j = 0; j <= N; j++) {
		int ways = (nCr(N, j) * nCr(M - j, N - j)) % mod;
		ways = (neg * ways * fact[N - j] + mod) % mod;
		ways_b = (ways_b + ways) % mod;
		neg *= -1;
	}

	return (ways_a * ways_b) % mod;
}

int main() {
	int N, M;
	cin >> N >> M;
	cout << neq(N, M);
	return 0;
}

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

int n, t, a[3], done;
double dp[301][301][301], ans = 0;

double f(int n1, int n2, int n3) {
	if (n1 < 0 || n2 < 0 || n3 < 0 || (n1+n2+n3) == 0)
		return 0;
	if (dp[n1][n2][n3] == -1) {
		dp[n1][n2][n3] = (n + n1 * f(n1 - 1, n2, n3) + n2 * f(n1 + 1, n2 - 1, n3) + n3 * f(n1, n2 + 1, n3 - 1)) / (n1 + n2 + n3);
	}
	return dp[n1][n2][n3];
}

int main() {
	cin >> n;
	a[0] = a[1] = a[2] = 0;
	for (int i = 1; i <= n; i++)
		cin >> t, a[t - 1]++;

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n; k++) {
				dp[i][j][k] = -1;
			}
		}
	}
	printf("%.15lf", f(a[0], a[1], a[2]));
	return 0;
}


Measured memory_bytes: 213376
q,h,s,d = map(int,input().split())
n = int(input())
q1 = q*4
h1 = h*2
q2 = q*8
h2 = h*4
s2 = s*2
b1 = 0
b2 = 0

if q1 <= h1 and q1 <= s:
    b1 = q1
elif h1 <= q1 and h1 <= s:
    b1 = h1
else:
    b1 = s


if  q2 <= h2 and q2 <= s2 and q2 <= d:
    b2 = q2
elif h2 <= q2 and h2 <= s2 and h2 <= d:
    b2 = h2
elif s2 <= q2 and s2 <= h2 and s2 <= d:
    b2 = s2
else:
    b2 = d

cnt1 = 0
cnt2 = 0

if b1*2 > b2:
    cnt1 = n//2
    cnt2 = n%2
    print((b2*cnt1)+(b1*cnt2))
else:
    print(b1*n)


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

int main(){
    long n, x;
    long min, max, sum;
    min = 1000000;
    max = -1000000;
    sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> x;
        if (x < min) min = x;
        if (x > max) max = x;
        sum += x;
    }
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3108
N = int(input())
S = []
A = {}
for i in range(N):
    sortedstring = ''.join(sorted(input()))
    if sortedstring in A:
        A[sortedstring]+=1
    else:
        A[sortedstring]= 1
# print(N,A)
Nacro = 0
for k, v in A.items():
    Nacro+=int(v*(v-1)/2.)
    # print(k, v)

print(Nacro)

Measured memory_bytes: 17852
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=4e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
#endif
}
int n,m;
int num[N],a[N];
void input()
{
	n=read<int>(),m=read<int>();
	For(i,1,n)
	{
		a[i]=read<int>();
		num[a[i]]++;
	}
}
int ans;
int b[N];
void work()
{
	For(i,1,n)if(num[i])
	{
		b[n+i-num[i]+1]++;
		b[n+i+1]--;;
	}
	For(i,1,n*2)b[i]+=b[i-1];
	For(i,n+1,n*2)if(!b[i])ans++;
	//For(i,1,n*2)cout<<b[i]<<' ';
	//cout<<endl;
	int x,y;
	For(i,1,m)
	{
		x=read<int>(),y=read<int>();
		int pos=n+a[x]-num[a[x]]+1;
		if(!--b[pos]&&pos>=n+1)ans++;			
		num[a[x]]--; 
		//cout<<pos<<endl;	
		a[x]=y;
		++num[a[x]];
		pos=n+a[x]-num[a[x]]+1;
		//cout<<pos<<endl;	
		if(++b[pos]==1&&pos>=n+1)ans--;
	
		write(ans,'\n');
	
		//For(j,1,n*2)cout<<b[j]<<' ';
		//cout<<endl;
	}
}
int main()
{
//	file();
	input();
	work();
	return 0;
}



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

int main() {
    int d;
    cin >> d;
    if(d == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }else if(d == 23){
        cout << "Christmas Eve Eve" << endl;
    }else if(d == 24){
        cout << "Christmas Eve" << endl;
    }else{
        cout << "Christmas" << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
/*Always success does not build on success,success build on failure and hardwork*/
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<long long>
#define map         map<long long,long long>
#define scn(t)      scanf("%d",&t);
#define lscn(t)      scanf("%lld",&t);
#define mod         1000000007
#define rep(i,a,b)  for(long long i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const long long N=1e5+5;
int main()
{
   int n;
   scn(n);

   ll d;
   lscn(d);

   d=d*d;

   int cnt=0;

   while(n--)
   {
      ll x,y;
      lscn(x);
      lscn(y);

      if(x*x+y*y<=d)
      cnt++;
   }

   cout<<cnt;
}

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


int main(){
    int N,M,X;
    scanf("%d %d %d",&N,&M,&X);
    int C[N],A[N][M];
    int S[M];
    int min=1000000000,S_m;
    for (int i=0; i<N; i++) {
        scanf("%d",&C[i]);
        for (int j=0; j<M; j++) {
            scanf("%d",&A[i][j]);
        }
    }
    for (int i=0; i<(1<<N); i++) {
        for (int j=0; j<M; j++) {
            S[j]=0;
        }
        S_m=0;
        for (int k=0; k<N; k++) {
            if(i & (1<<k)){
                for (int l=0; l<M; l++) {
                    S[l]+=A[k][l];
                }
                S_m+=C[k];
            }
        }
        int f=1;
        for (int o=0; o<M; o++) {
            if(S[o]<X){
                f=0;
                break;
            }
        }
        if (f) {
            if (S_m<min) {
                min=S_m;
            }
        }
        
    }
    if (min==1000000000) {
        printf("-1\n");
    }
    else{
        printf("%d\n",min);
        
    }
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    string s;
    cin >> s;
    bool ok = 1;
    rep(i,s.length()/2){
        if (s[2*i] != 'h' || s[2*i+1] != 'i') ok = 0;
    }
    if (ok && s.length()%2 != 1) PRINT("Yes");
    else PRINT("No");
}


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

using namespace std;
using LLONG = long long;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A * B, C * D) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

int f1(int n){
    if(n % 2 == 0) return n /2 ;
    else return 3 * n + 1;
}

int main(){
    map<int,int> m;
    int s;
    cin >> s;
    int ans = 0;
    int pre = s;
    m[s] = 1;
    for(int i = 2; i <= 1000000; i++){
        int temp = f1(pre);
        auto ite = m.find(temp);
        if(ite != m.end()){
            ans = i;
            break;
        }
        else m[temp] = 1;
        pre = temp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define LL long long
char a[3][3];
int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			std::cin >> a[i][j];
		}
	}
	std::cout << a[0][0] << a[1][1] << a[2][2] << std::endl;
	return 0;
}


Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>

#define for0(i,n) for(int i = 0;i < (n);i++)
#define for1(i,n) for(int i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define bit(x,n) (x & (1<<(n)))
#define EPS 1e-8
#define INF 0x3f3f3f3f3
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}

using namespace std;

typedef pair<int,int> ii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<long long, long long> > vll;

ii DR8[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
ii DR4[] = {{-1,0},{0,-1},{0,1},{1,0}};

const ll mod = 998244353;
/*
ll nop = 100;
vi primes(nop+1,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}

void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

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

ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}
*/
ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    ll n,s;
    cin>>n>>s;
    vl a(n);
    inp_arr(a,n);
    vvl dp(n+1,vl(s+1,0)),dp2(n+1,vl(s+1,0));
    dp[0][0] = 1;
    for0(i,n) {
        for0(j,s+1) {
            if(j+a[i] <= s) {
                dp[i+1][j+a[i]] = (dp[i+1][j+a[i]] + dp[i][j])%mod;

            }
            dp[i+1][j] = (dp[i+1][j] + (dp[i][j]*2)%mod)%mod;
        }
    }
    cout<<dp[n][s]<<endl;
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t){
        //cout<<"Case #"<<T<<": ";
        solve();
    }
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif */
    return 0;
}


Measured memory_bytes: 144144
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll T[2],A[2],B[2],N,D,ans;

int main(void){
    cin >> T[0] >> T[1] >> A[0] >> A[1] >> B[0] >> B[1];
    if(A[0]<B[0]){
        swap(A[0],B[0]);
        swap(A[1],B[1]);
    }
    D = (B[0]*T[0] +B[1]*T[1])-(A[0]*T[0] +A[1]*T[1]);
    //cout << D << endl;
    if(D==0){cout << "infinity" << endl;return 0;}
    if(D<0){cout << 0 << endl;return 0;}
    if(D>0){
        N = (T[0]*A[0] - T[0]*B[0])/D;
        ans = N*2+1;
        if((T[0]*A[0] - T[0]*B[0])%D==0)ans--;
        cout << ans << endl;
    }
    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  int N;

  rep(i, 3) {
    rep(j, 3) {
      cin >> A.at(i).at(j);
    }
  }
  cin >> N;
  vector<int> B(N);
  rep(i, N) {
    cin >> B.at(i);
  }

  rep(i, 3) {
    rep(j, 3) {
      rep(k, N) {
        if (A.at(i).at(j) == B.at(k)) {
          A.at(i).at(j) = 0;
        }
      }
    }
  }
  rep(i, 3) {
    if (A.at(i).at(0) + A.at(i).at(1) + A.at(i).at(2) == 0 || A.at(0).at(i) + A.at(1).at(i) + A.at(2).at(i) == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (A.at(0).at(0) + A.at(1).at(1) + A.at(2).at(2) == 0 || A.at(0).at(2) + A.at(1).at(1) + A.at(2).at(0) == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

return 0;
}

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

using namespace std;

#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define vi vector<int >
#define pii pair<int, int>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SQ(a) (a)*(a)
#define ll long long
#define lli long long int
#define ull unsigned long long
#define endl '\n'
#define Pi(a) printf("%d\n",a);
#define debug2(a,b) printf("%d\t%d\n",a,b);
#define debug1(a) printf("%d\n",a);
#define Si(a) scanf("%d",&a);
#define mod 1000000007
#define w(n) while(n--)



int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//code
	int n;
	cin >> n;
	if(n<1200) cout << "ABC" << endl;
	else if(n<2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
#define cases int t;cin>>t;while(t--) 

int main(){
    char c;
    cin>>c;
    if(c == '7'){
        cout<<"Yes\n";
        return 0;
    }
    cin>>c;
    if(c == '7'){
        cout<<"Yes\n";
        return 0;
    }
    cin>>c;
    if(c == '7'){
        cout<<"Yes\n";
        return 0;
    }
    cout<<"No\n";
   
}


Measured memory_bytes: 3572
N, M=map(int,input().split())
AB=[]
for _ in range(N):
    AB.append(list(map(int,input().split())))
AB.sort()

res = M
total = 0
for i in range(N):
  if(res > AB[i][1]):
    newbuy = AB[i][1]
  else:
    newbuy = res
  total += newbuy*AB[i][0]
  res = res - newbuy

print(total)

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

int counter = 0;
rep(i,n-2)
{
    if(str[i]=='A'&&str[i+1]=='B'&&str[i+2]=='C') counter++;
}

cout << counter << endl;

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>  
#define MAX 100
#define inf 2000000
#define WHITE 0
#define GRAY 1
#define BLACK 2


int main(){
  int n,i,j,u,k,v,c,mincost;
  int color[MAX],d[MAX],w[MAX][MAX];
  
  scanf("%d", &n); 
  for( i=0;i<n;i++){
    d[i] = inf;
    color[i]=WHITE;
    for( j=0; j<n; j++){
      w[i][j] = inf;
    }
  }
  
  d[0] = 0;
  color[0]=GRAY;
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      w[u][v] = c;  
    }
  }
  
  while(1){
    mincost = inf;
    
    for( i=0; i<n; i++){
      if( mincost > d[i] && color[i] != BLACK ){
	u = i;
	mincost = d[i];
      }
    }
  
    if( mincost == inf )break;
  
    color[u] = BLACK;
  
    for(i=0;i<n;i++){
      if(color[i] != BLACK && w[u][i] != inf){
	if( d[i] > (d[u] + w[u][i]) ){
	  d[i] = d[u] + w[u][i];
	  color[i]=GRAY;
	}
      }
    }
  }
  
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
  
  return 0;
}

Measured memory_bytes: 636