akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 30;
const int N = (int)3e5 + 7;
const int MAXN = (int)3e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

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

void solve() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int x = min(a, k), ans = 0;
	a -= x, k -= x, ans += x;
	x = min(b, k);
	b -= x, k -= x;
	x = min(c, k);
	ans -= x;
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n;
	cin >> n;
	map<string,int> mp;
	rep(i,n){
		string s;
		cin >> s;
		mp[s] ++ ;
	}
	int mx = 0 ;
	for(auto p: mp) mx= max(mx,p.second);
	for(auto p: mp) {
		if(p.second != mx) continue;
		cout << p.first << endl;
	}
	return 0 ;
}


Measured memory_bytes: 25216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int num1 = scan.nextInt();
		int[] array1 = new int[num1+1];
		 //配列1個目
		for(int i = 0; i < num1; i++) {
			array1[i] = scan.nextInt();
		}
		//配列2個目
		int num2 = scan.nextInt();
		int[] array2 = new int[num2];
		for(int i = 0; i < num2; i++) {
			array2[i] = scan.nextInt();
		}
		
		int count = 0; //2つの配列の共通の個数
		
		for(int i = 0; i < num2; i++) {
		count += binarySearch(num1, array1, array2[i]);
		}
		
		System.out.println(count);
}
	
	public static int binarySearch(int n, int[] A, int key) {
		int left = 0;
		int right = n;
		int mid;
		while(left < right) {
			mid = (left + right) / 2;
			if(A[mid] == key) {
				return 1;
			} else if(key < A[mid]) {
					right = mid;
				} else {
					left = mid + 1;
			}
		}
		return 0;
	}
}


Measured memory_bytes: 68224
//
//  main.cpp
//  Atcoder1
//
//  Created by Hamske on 2020/09/17.
//  Copyright © 2020 Author. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

//#define pb push_back
//#define mp make_pair
//
//#define F first
//#define S second

typedef long long ll;

#define rept(_i,iv,n,type) for(type _i=(type)(iv);_i<(type)(n);++_i)
//#define repi(_i,iv,n) rept(_i,iv,n,int)
//#define repl(_i,iv,n) rept(_i,iv,n,ll)

#define rept0(_i,n,type) rept(_i,0,n,type)
#define repi0(_i,n) rept(_i,0,n,int)
#define repl0(_i,n) rept(_i,0,n,ll)

//#define repst(_i,iv,n,type) for(type _i=iv;_i<=(type)(n);++_i)
//#define repsi1(_i,n) repst(_i,1,n,int)

#define REPT(_i,iv,_l,n,type) for(type _i=(type)(iv),_l=(type)(n);_i<_l;++_i)
//#define REPI(_i,iv,_l,n) REPT(_i,iv,_l,n,int)
//#define REPL(_i,iv,_l,n) REPT(_i,iv,_l,n,ll)
//
#define REPT0(_i,_l,n,type) REPT(_i,0,_l,n,type)
#define REPI0(_i,_l,n) REPT(_i,0,_l,n,int)
#define REPL0(_i,_l,n) REPT(_i,0,_l,n,ll)


//#define rrept(_i,x,e,type) for(type _i=((type)(x)-1);_i>=e;--_i)
//
//#define rrept0(_i,x,type) rrept(_i,x,0,type)
//
//#define RREPT(_i,x,_e,e,type) for(type _i=((type)(x)-1),_e=(type)(e);_i>=_e;--_i)
//
//#define RREPT0(_i,x,_e,type) RREPT(_i,x,_e,0,type)
//
//#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//#define all(x) (x).begin(),(x).end()
#define REPV(v,_itr,_end) for(auto _itr=(v).begin(),_end=(v).end();_itr!=_end;++_itr)
#define REPVC(v,_itr,_end) for(auto _itr=(v).cbegin(),_end=(v).cend();_itr!=_end;++_itr)

#define td typedef
//#define tds(stl,type,name) typedef stl<type > name;
#define tdv(type,name) typedef vector<type > name;


//typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb > vvb;
typedef vector<int> vi;
typedef vector<vi > vvi;
//typedef vector<ll> vll;
//typedef vector<vll > vvll;

#define MOD7 1'000'000'007
#define MOD9 1'000'000'009

int main(int argc, const char * argv[]) {
    int N,X,T;
    cin>>N>>X>>T;
    int mod=N%X,num=(N-mod)/X+((mod==0)?0:1);
    cout<<(num*T)<<endl;
    return 0;
}


Measured memory_bytes: 3136
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
        int N = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int[] H = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToArray();
        int T = a[0];
        int A = a[1];
        int ans = 1;
        double difMin = 1000000;
        
        for(int i = 0; i < N; i++)
        {
            //標高H[i]における平均気温tを求める
            double t = (double)T - (double)(H[i] * 0.006);
            //tとAの差difを求める
            double dif = (double)Math.Abs(t - A);
            
            if(dif < difMin)//もしdifが最小値より小さいならば
            {
                //最小値を更新
                difMin = dif;
                //その時の場所の番号を記録
                ans = i + 1;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13332
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String k = sc.nextLine();
    int kInt = Integer.parseInt(k);
    String s = sc.nextLine();
    if (s.length() > kInt) {
      s = s.substring(0, kInt);
      s += "...";
    }
    System.out.println(s);
  }
}


Measured memory_bytes: 38584
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int n,k;
int a[200005];
int Max[200005];
int Min[200005];
pair<int,int> que[200005];
bool chance[200005];
int sum[200005];

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>k;
	k++;
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
	}
	int st=0,ed=0;
	que[ed++]=mp(a[0],0);
	for(int i=1;i<k;i++)
	{
		while(ed>st && a[i]<=que[ed-1].first)
		{
			ed--;
		}
		que[ed++]=mp(a[i],i);
	}
	Min[0]=que[st].first;
	for(int i=k;i<n;i++)
	{
		if(que[st].second==i-k) st++;
		while(ed>st && a[i]<=que[ed-1].first)
		{
			ed--;
		}
		que[ed++]=mp(a[i],i);
		Min[i-k+1]=que[st].first;
	}
	
	st=ed=0;
	que[ed++]=mp(a[0],0);
	for(int i=1;i<k;i++)
	{
		while(ed>st && a[i]>=que[ed-1].first)
		{
			ed--;
		}
		que[ed++]=mp(a[i],i);
	}
	Max[0]=que[st].first;
	for(int i=k;i<n;i++)
	{
		if(que[st].second==i-k) st++;
		while(ed>st && a[i]>=que[ed-1].first)
		{
			ed--;
		}
		que[ed++]=mp(a[i],i);
		Max[i-k+1]=que[st].first;
	}
	chance[0]=true;
	for(int i=0;i<n-k+1;i++)
	{
		if(a[i]==Min[i] && a[i+k-1]==Max[i])
		{
			chance[i+1]=false;
		}
		else
		{
			chance[i+1]=true;
		}
	}
	k--;
	
	sum[0]=0;
	for(int i=1;i<n;i++)
	{
		sum[i]=sum[i-1]+(a[i-1]>a[i]);
	}
	bool flag=true;
	int res=0;
	for(int i=0;i<n-k+1;i++)
	{
		if(!chance[i]) continue;
//		cout<<sum[i+k-1]<<' '<<sum[i]<<endl;
		if(sum[i+k-1]-sum[i]==0)
		{
			res+=flag;
			flag=false;
		}
		else
		{
			res++;
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>

int main(void) {
	double max = 0, min = 0;
	double x;
	while (scanf("%lf", &x) != EOF) {
		max = max < x ? x : max;
		min = min > x || min == 0 ? x : min;
	}
	printf("%.1lf\n", max - min);
	return 0;
}

Measured memory_bytes: 652
#include<iostream>
using namespace std;
int main()
{
    int n,na,e;
    long long sum[4010];
    long long p,q;
    while(cin >> n,n!=0){
        na = 0;
        for(int i=0;i<=4000;i++) sum[i] = 0;
        for(int i=0;i<n;i++){
            cin >> e >> p >> q;
            if(sum[e] >= 1000000) continue;
            sum[e] += p*q;
            if(sum[e] >= 1000000){
                na = 1;
                cout << e << endl;
            }
        }
        if(na == 0) cout << "NA" << endl;
    }
    return 0;
}



Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N,X;
  cin>>N>>X;

 
vector<ll> L(N);
  for(ll i=0;i<N;i++) {
    cin>>L[i];
  }
  
ll ans=1;
  ll z=0;
  for(ll i=0;i<N;i++) {
if(z+L[i]>X) {
break;
}
    z+=L[i];
    ans++;
  }
  
  cout<<ans<<endl;
}
 
    

  
  
  
  
  


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    if(a + b + c >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n;
  vi diff;
  int p[100005];
  cin>>n;
  rep(i,n){
    cin>>p[i];
    diff.pb(abs((i+1)-p[i]));
  }
  int ans=0;
  rep(i,diff.size()){
    if(i!=diff.size()-1&&diff[i]==0&&diff[i+1]==0){
      i++;
      ans++;
    }else if(diff[i]==0){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1148
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string.h>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int main()
{
	int a[10];
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	sort(a, a + 5, greater<int>());

	for (int i = 0; i < 4; i++) {
		cout << a[i] << " ";
	}
	cout << a[4] << endl;
	
	return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

struct mission{int l,r,x;};

int main(void){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	vector<bool> solt;
	solt.push_back(true);
	reps(i,3000){
		if((i-c)>=0 && solt[i-c]){
			solt.push_back(true);
			continue;
		}
		if((i-d)>=0 && solt[i-d]){
			solt.push_back(true);
			continue;
		}
		solt.push_back(false);
	}
	rep(i,f/100*e+1){
		//cerr<<solt[i]<<" ";
	}
	//cerr<<endl;

	ll ans_w = 100*a, ans_s = 0;
	double ans = 0;
	rep(i,31){
		rep(j,31){
			ll water = 100*a*i + 100*b*j;
			if(water > f) break;
			//cerr<<water<<endl;
			ll limit = min(water/100*e, f-water);
			rep(k, limit + 1){
				if(solt[k]){
					double nodo = 100.0 * k / (water + k);
					if(nodo > ans){
						ans = nodo;
						ans_w = water;
						ans_s = k;
					}
				}
			}
		}
	}
	cout<<ans_w+ans_s<<" "<<ans_s<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
H_list = list(map(int, input().split()))
m_ans = 0
m = 0

for i in range(N-1):
    if H_list[i] >= H_list[i+1]:
        m += 1
    else:
        m = 0
    m_ans = max(m, m_ans)
    
print(m_ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << ((sizeof...(tail)!=0)?" ":""); print(forward<Tail>(tail)...); }
template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a << ((&a!=&vec.back())?" ":""); } cout << endl; }
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } }

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

    // 二次元累積和？
    int n, m, q; cin >> n >> m >> q;
    vector<vector<int>> a(n, vector<int>(n, 0));
    rep(i, m) {
        int x, y; cin >> x >> y;
        x--; y--;
        a[y][x]++;
    }

    vector<vector<int>> s(n+1, vector<int>(n+1, 0));
    rep(i, n) rep(j, n) {
        s[i+1][j+1] = s[i+1][j]+s[i][j+1]-s[i][j]+a[i][j];
    }

    // print();
    // print(s);

    // s[i][j] = iまでに終わる列車のうち、j以降から出発する列車の本数

    rep(i, q) {
        int x, y; cin >> x >> y;
        print(s[y][y]-s[y][x-1]);
    }
}

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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		String[] tmpArray = br.readLine().split(" ");
		int[] input = new int[n];
		
		for(int i = 0 ; i < n ; i++){
			input[i] = Integer.parseInt(tmpArray[i]);
		}
		
		int result = lcm(input);
		
		System.out.println(result);

	}

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

	static int lcm(int a, int b) {
	    return a * b / gcd(a, b);
	}
	
	static int lcm(int[] array){
		int result = array[array.length - 1];
		
		for(int i = array.length - 2 ; i >= 0 ; i--){
			result = lcm(result, array[i]);
		}
		
		return result;
	}

}

Measured memory_bytes: 24364
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    double ans =0;
    rep(i,n){
        int m;
        cin>>m;
        ans+= (double) 1/m;
    }
    ans = 1/ans;
    cout << ans;


    return 0;
}

Measured memory_bytes: 3800
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
p.reverse()
q.sort()
q.reverse()
P = p[:x]
Q = q[:y]
R = P+Q+r
R.sort()
R.reverse()
T = R[:x+y]
ans = sum(T)
print(ans)

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

int N; long long A[100];
int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> A[i];
  sort(A, A + N);
  cout << A[N - 1] - A[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int a[12][12];
const int INF = 1001001001;

int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> c(n);
  rep(i,n){
   cin>>c[i];
    rep(j,m) cin >> a[i][j];
  }
  int ans = INF;
  rep(s,1<<n){
    int cost = 0;
    vector<int> d(m);
   	rep(i,n){
      if(s>>i&1){
      	cost+=c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if(d[j] < x) ok = false;
    if(ok) ans = min(ans, cost);
  }  
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main(){
	
	int n, m;
	
	cin >> n >> m;
	
	int a[10000], b[10000];
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}
	
	int ans_max = 0;
	
	for(int j = 0; j < m; j++){
		for(int i = 0; i < n; i++){
			if(a[i] == b[j]){
				int index1 = i + 1;
				int index2 = j + 1;
				int ans = 1;
				while(true){
					
					if(index1 >= n || index2 >= m){
						break;
					}
					
					if(a[index1] == b[index2]){
						index1++;
						index2++;
						ans++;
					}else{
						index1++;
					}
				}
				if(ans_max < ans){
					ans_max = ans;
				}
				//cout << ans << " ";
				break;
			}
		}
		//cout << endl;
	}
	
	cout << ans_max << endl;
	
	return 0;
}

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

typedef long long ll;

#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()

int main()
{
 
  int n;
  cin >> n;
  int a,b,c;
  int dp[3] = {0};
  cin >> dp[0] >> dp[1] >> dp[2];
  for (int i = 1;i < n;i++)
  {
    cin >> a >> b >> c;
    int t1,t2,t3;
    t1 = a + max(dp[1], dp[2]);
    t2 = b + max(dp[0], dp[2]);
    t3 = c + max(dp[0], dp[1]);
    dp[0] = t1;
    dp[1] = t2;
    dp[2] = t3;
  }
  cout << max(dp[0], max(dp[1], dp[2])) << "\n";


  return 0;
}


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

ans = 0
for i in range(1, n - 1):
    if min(a[i - 1], a[i], a[i + 1]) != a[i] and max(a[i - 1], a[i], a[i + 1]) != a[i]:
        ans += 1
print(ans)


Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<char>> c(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c.at(i).at(j);
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<c.at(i).at(j);
      if(j==w-1)
        cout<<endl;
      
    }
    for(int j=0;j<w;j++){
      cout<<c.at(i).at(j);
      if(j==w-1)
        cout<<endl;
      
    }
  }
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110
#define MAX_C 10010

int N;
int A[MAX_N] = {};
int dp[MAX_N][MAX_C];

// i 番目を見ていて、一つ前のスライムの色が prev のときの最小回数
int dfs(int i = 0, int prev = 10007) {
    if(i >= N) { return 0; }

    int& res = dp[i][prev];
    if(~res) {
        return res;
    }
    res = LLINF;

    res = min(res, dfs(i+1, 10007) + 1);
    if(prev != A[i]) {
        res = min(res, dfs(i+1, A[i]));
    }
    return res;
}

signed main()
{
    cin >> N;
    REP(i, N) { cin >> A[i]; }

    MINUS(dp);
    int ans = dfs();
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int d, l; scanf("%d%d", &d, &l);
	
	printf("%d\n", d / l + d % l);
	return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;
int main() {
 int N;
 cin>>N;
 vector<int>A(N);
 vector<int>B(N);
 vector<int>C(N-1);
 for(int i=0;i<N;i++){
     cin>>A[i];
 }
 for(int i=0;i<N;i++){
     cin>>B[i];
 }
 for(int i=0;i<N-1;i++){
     cin>>C[i];
 } 
 int sum=0;
 for(int i=0;i<N;i++){
  sum+=B[A[i]-1];
  if(i<N-1&&A[i+1]-A[i]==1){sum+=C[A[i]-1];}
 }
cout<<sum<<endl;
 return 0;}

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


using namespace std;

int main()
{
long n;
cin>>n;
long long a[100100];
for(int i=0;i<n;i++)
    cin>>a[i];
sort(a,a+n);
long long  f=0,s=0;
for(int i=n-1;i>0;i--){
    if(a[i]==a[i-1]&&a[i]>f){
        f=a[i];
        i--;
    }
    else if(a[i]==a[i-1]&&a[i]>s){
        s=a[i];
 
 
    }
}

cout<<f*s<<endl;
return 0;

}


Measured memory_bytes: 1024
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N, A, B;
  ci(N, A, B);
  co(min(A * N, B));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define dump(x) cerr << #x << " : " << x << '\n'

bool f(int n) {
    string s = to_string(n);
    int a = s.size();
    return a % 2;
}

int main() {
    int N; cin >> N;
    int ans = 0;
    rep(i, 1, N + 1) {
        ans += f(i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
ll h[100005];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int ans = 0;
	int active = 0;
	for (int i = 0; i < n; i++) {
		if (active >= h[i]) {
			active = h[i];
		}
		else {
			ans += h[i] - active;
			active = h[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//import java.util.Scanner;
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.PrintWriter;
//import java.io.BufferedReader;
//import java.io.InputStreamReader;
//import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args)
	{
		StringBuilder sb = new StringBuilder();
		
//		Scanner sc = new Scanner(System.in);
		FastScanner sc = new FastScanner();
//		int n = sc.nextInt();
//		String s = sc.next();
//		int a[] = new int[3];
//		for (int ii = 0; ii < 3; ii++) a[ii] = sc.nextInt();
		
		
		
		int a = 1;
		for (int ii = 0; ii < 2; ii++) a *= sc.nextInt();

		if (a % 2 == 0) sb.append("Even");
		else sb.append("Odd");
		
		
		
//		System.out.println(sb.toString());
		PrintWriter out = new PrintWriter(System.out);
		out.println(sb.toString());
		out.flush();
	}
}

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


Measured memory_bytes: 20692
#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 all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   while (true) {
      int w, h;
      cin >> w >> h;
      if (w == 0 && h == 0) break;
      vector<vector<int>> c(h, vector<int>(w)), a(h, vector<int>(w));

      rep(i, 0, h) rep(j, 0, w) cin >> c[i][j];
      int ans = 0;
      function<void(int, int)> dfs = [&](int u, int v) {
         if (a[v][u] != 0) return;
         c[v][u] = ans;
         a[v][u] = 1;
         rep(i, -1, 2) rep(j, -1, 2) {
            int x_i = u + i;
            int y_j = v + j;
            if (x_i >= 0 && x_i < w && y_j >= 0 && y_j < h && c[y_j][x_i] == 1)
               dfs(x_i, y_j);
         }
         return;
      };
      rep(i, 0, h) {
         rep(j, 0, w) {
            if (a[i][j] == 0 && c[i][j] == 1) {
               ans++;
               dfs(j, i);
            }
         }
      }
      cout << ans << endl;
   }
   return 0;
}


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

#define vi vector<int>
#define pb push_back

int main(){
        int a,b,h;
        cin >> a >> b >> h;
        cout << (a+b)*h/2 << endl;
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                          
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<string> u(N);
  vector<double> x(N);
  double sum=0;
  for(int i=0; i<N; i++){
    cin >> x.at(i) >> u.at(i);
    if(u.at(i)=="JPY"){
      sum+=x.at(i);
    }
    else if(u.at(i)=="BTC"){
      sum+=380000*x.at(i);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
typedef double db;
#define inf 0x3f3f3f3f

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main() {
	int n;
	cin >> n;
	int i;
	for (i = 0; i < 12; ++i) {
		if (1000 * i >= n)break;
	}
	cout << 1000 * i - n << endl;
	return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
map<int, int> gogo;
int main(){
	int n;
	cin >> n;
	vector<int> geko;
	REP(i, n) {
		int a;
		cin >> a;
		geko.push_back(a);
		gogo[a]++;
	}
	int ans = 0;
	sort(geko.begin(), geko.end(), greater<int>());
	REP(i, geko.size()) {
		if (gogo[geko[i]] != 0) {
			for (int q = 30; q >= 0; --q) {
				int hoge = (1 << q) - geko[i];
				if (hoge <= 0) break;
				if (hoge == geko[i]) {
					if (gogo[hoge] >= 2) {
						gogo[geko[i]] -= 2;
						ans++;
						break;
					}
				}else
				if (gogo[hoge] != 0) {
					gogo[geko[i]]--;
					gogo[hoge]--;
					ans++;
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 30572
n = int(input())
alist = list(map(int,input().split()))
length = 0
temp = 0
keypoint = 0

for a in alist:
    length += a

halflength = length/2
    
for i in range(len(alist)):
    temp += alist[i]
    if temp > halflength:
        keypoint = i
        break
        
beforeamari = abs(halflength-temp+alist[i])
afteramari = abs(halflength-temp)

if beforeamari>=afteramari:
    print(int(afteramari*2))
else:
    print(int(beforeamari*2))

Measured memory_bytes: 26220
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>
#include <unordered_set>

using namespace std;
using ll = long long;
const int BIG = 1000000007;


int main() {
    vector<ll> divis(1000001,1);
    for(ll i = 2;i < divis.size();++i){
        for(ll j = i;j < divis.size();j += i){
            ++divis[j];
        }
    }

    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1;i <= n - 1;++i){
       // cout << "i = " << i << ",d = " << divis[i] << endl;
        ans += divis[i];
    }

    cout << ans << endl;
}





Measured memory_bytes: 10684
i, j = map(int, input().split())

if (i + j) % 3 != 0 or (max(i, j) / min(i, j) > 2):
  print(0)
else:
  TW = (i + j) // 3
  W = (TW - (i-j)) // 2

  def mod_cmb(n, r, mod=10**9+7):
      r = min(r, n-r)
      res = 1
      for i in range(r):
          res = res * (n - i) % mod * pow(i+1, mod-2, mod) % mod
      return res

  print(mod_cmb(TW, W))

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

int main() {
    int n;
    cin >> n;
    vector<P> p(n);

    rep(i, n) {
        int a;
        cin >> a;
        p[i] = make_pair(a, i+1);
    }
    sort(p.begin(), p.end());
    rep(i, n) {
        cout << p[i].second << ' ';
    }
    cout << endl;

	return 0;
}

Measured memory_bytes: 4052
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int N,A[1005];
int main()
{
	for(;scanf("%d",&N),N;)
	{
		int r=1000001;
		for(int i=0;i<N;i++)
		{
			scanf("%d",&A[i]);
			for(int j=0;j<i;j++)
				r=min(r,abs(A[i]-A[j]));
		}
		printf("%d\n",r);
	}
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd_ll(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int main(){
  int n;
  cin>>n;
  vl a(n);
  rep(i,n) cin>>a[i];
  ll ans = a[0];
  rep(i,n-1) ans =gcd_ll(ans, a[i+1]);
  cout<< ans<<endl;
}





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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  cin >> n;
  vector<int> a(n);
  range(i, 0, n) cin >> a[i];
  const int N = 4000010;
  bitset<N> st;
  st[0] = 1;
  range(i, 0, n) {
    st |= st << a[i];
  }
  int sum = 0;
  range(i, 0, n) sum += a[i];
  range(i, (sum + 1) / 2, sum + 1) {
    if(st[i]) {
      cout << i;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1664
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 S              PIC X(3).
01 cnt            PIC 9(10).

PROCEDURE DIVISION.
  ACCEPT S.
  INSPECT S TALLYING cnt FOR ALL "A".
  IF cnt = 1 OR 2
      DISPLAY "Yes"
  ELSE
      DISPLAY "No"
  END-IF.
  STOP RUN.


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll A,B,K;
    cin >> A >> B >> K;
    if(A >= K){
        pr(A - K, B);
    }else{
        pr(0, max(0LL, B-(K-A)));
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
    string s;
    cin >> s;
    int x=0;
    for(int i=0;i<s.length();i++){
    if(s.substr(i,1)=="+"){
        x++;
    }else{
        x--;
    }
    }
    cout << x << endl;
}

Measured memory_bytes: 256
a_coins = int(input())
b_coins = int(input())
c_coins = int(input())
x_num = int(input())

def money_match(a, b, c):
    money = 500 * a + 100 * b + 50 * c
    if money == x_num:
        return 1
    else:
        return 0
        
cnt = 0
for a in range(a_coins+1):
    for b in range(b_coins+1):
        for c in range(c_coins+1):
            if money_match(a, b, c) == 1:
                cnt += 1
                
print(cnt)

Measured memory_bytes: 9144
#include<stdio.h>

int main(){
		int n,m,k,i,j;
		scanf("%d%d%d",&n,&m,&k);
		int dp[1001][1001]={0};
		for(i=1;i<=n;i++){
				dp[i][0]=dp[i-1][0]+m;
				for(j=1;j<=m;j++){
						dp[i][j]=dp[i][j-1]+n-i*2;
				}
		}
		int ansf=0;
		for(i=0;i<=n;i++){
				for(j=0;j<=m;j++){
						if(dp[i][j]==k)ansf=1;
				}
		}
		if(ansf==1)puts("Yes");
		else puts("No");
		return 0;
}


Measured memory_bytes: 4096
import sys
# from math import sqrt, gcd, ceil, log
from bisect import bisect_left
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n = int(input())
	print(n + n*n + n*n*n)

		

if __name__ == "__main__":
	solve()

Measured memory_bytes: 9396
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define debug(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

const int MAX_N = 7 + 100;
///----------------------------------------------
char str[MAX_N];
int pow2[MAX_N];
ll val(int l,int r) {
	ll ret=0;
	rep(i,l,r+1) ret=ret*10+str[i]-'0';
	return ret;
}
int main() {

	///init
	pow2[0]=1; rep(i,1,15) pow2[i]=(pow2[i-1]<<1);

	///read
	scanf(" %s",str); int len=strlen(str);

	///work
	ll ans=0;
	rep(l,0,len) rep(r,l,len) {
		ll tmp = pow2[l-(l>0)+len-1-r-(len-1-r>0)];
		ans += tmp*val(l,r); 
	}
	cout << ans;
	

}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
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);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N, X; cin >> N >> X;
    vector<int> L(N+1);
    for(int i=0; i<N; i++) {
        cin >> L[i];
    }

    int d = 0, ans = 0;
    for(int i=0; i<N+1; i++) {
        if(d <= X) ans++;
        d = d + L[i];
    }
    cout << ans << endl;
    return 0;
}


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

const ll mod = 1000000007 ;

bool isInteger(double n)
{
	if(floor(n)==ceil(n))
		return true ;
	return false ;
}

using namespace std ;

int main()
{
	int k;
	cin>>k;
	int A[k];
	A[0]=7%k;
	int flag = 0 ;
	for(int i=1 ; i<k ; i++)
	{
		A[i] = (A[i-1]*10+7)%k ;
	}
	for(int i=0 ; i<k ; i++)
	{
		if(A[i]==0)
		{
			cout<<(i+1);
			flag =1;
			break ;
		}
	}
	if(flag==0)
		cout<<-1;

}


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

typedef long long ll;

int A,B,C;
int X[3];
int main() {
  cin >>X[0]  >> X[1] >> X[2];
  int cnt = 0;
  while(1){
    if ( X[0] == X[1] && X[1] == X[2] ) break;
    sort(X,X+3);
    if ( X[2] - X[0] >= 2 ){
      int tmp = (X[2] - X[0])/2;
      X[0]+=2*tmp;
      cnt+= tmp;
    }else if( X[2]-X[0] == 1 && X[2]-X[0] == 1 ) {
      X[0]++;
      X[1]++;
      cnt++;
    } else if ( X[2] -X[1] == 1 && X[1] - X[0] == 1 ) {
      X[0]++;
      X[1]++;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, const char *argv[]) {
  int N, sum;
  cin >> N;
  vector<int> L(N);

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

  vector<int>::iterator iter = max_element(L.begin(), L.end());
  size_t index = distance(L.begin(), iter);
  sum = accumulate(L.begin(), L.end(), 0);
  if (L[index] < sum - L[index]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int a, b, c;
    cin >> a >> b >> c;
    if(a > b) swap(a, b);
    if(a < c && c < b)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n, q int
	var s string
	fmt.Scan(&n, &q, &s)

	a := make([]int, n+1)
	for i := 1; i < n; i++ {
		x := 0
		if s[i-1] == 'A' && s[i] == 'C' {
			x = 1
		}
		a[i+1] = a[i] + x
	}

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < q; i++ {
		sc.Scan()
		l, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		r, _ := strconv.Atoi(sc.Text())
		fmt.Println(a[r] - a[l])
	}
}


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

int yu(int a, int b) {
  while(1) {
    int temp=a%b;
    if(temp==0) {
      return b;
    }
    else {
      a=b;
      b=temp;
    }
  }
}

int main () {
  int a,b,c;
  cin >> a >> b >> c;
  if (c%yu(a,b)==0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256