akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
ll x, y, ans = linf;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x >> y;
  if(x <= y) mins(ans, y - x);
  if(-x <= y) mins(ans, y + x + 1);
  if(x <= -y) mins(ans, -y - x + 1);
  if(-x <= -y) mins(ans, -y + x + 2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=9;i++)
		if(n%i==0&&n/i<=9&&n/i>=1)
		{
			printf("Yes");
			return 0;
		}
	printf("No");
}

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

int main(int argc, char const *argv[]) {
	int a, b; cin >> a >> b;
	if ((a * b) % 2 == 0) printf("Even\n");
	else printf("Odd\n");
	return 0;
}


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

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


Measured memory_bytes: 3680
#include <stdio.h>

int main(void) {
  int n, i, j, x[4], y[4];
  scanf("%d", &n);
  for(j = 0; j < n; ++j) {
    for(i = 0; i < 4; ++i) scanf("%d%d", &x[i], &y[i]);
    if((y[1] - y[0]) * (x[3] - x[2]) == (y[3] - y[2]) * (x[1] - x[0])) printf("2\n");
    else if((y[1] - y[0]) * (y[3] - y[2]) == -(x[3] - x[2]) * (x[1] - x[0])) printf("1\n");
    else printf("0\n");
  }
  return 0;
}


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

int main() {
    int a;
    deque<int> some;
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (i % 2 == n % 2) {
            some.push_back(a);
        } else {
            some.push_front(a);
        }
    }
    for (int x:some) {
        cout << x << endl;
    }
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<queue>
#include<set>

using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v1(n+1);
    vector<int>v2(n+1);
    vector<int>v3(n+1);
    for(int i=0;i<n;i++){
        cin>>v1[i]>>v2[i]>>v3[i];
    }
    const int types = 3;
    vector<vector<int>>dp(n+1,vector<int>(types,0));
    const int swim = 0;
    const int bugs = 1;
    const int hw = 2;
    dp[0][hw] = v2[0];
    dp[0][swim] = v1[0];
    dp[0][bugs] = v3[0];
    for(int i=1;i<=n;i++){
        dp[i][swim] = v1[i] + max(dp[i-1][hw],dp[i-1][bugs]);
        dp[i][hw] = v2[i] + max(dp[i-1][swim],dp[i-1][bugs]);
        dp[i][bugs] = v3[i] + max(dp[i-1][swim],dp[i-1][hw]);
    }
    cout<<max(dp[n][swim],max(dp[n][hw],dp[n][bugs]))<<endl;
    return 0;
}

Measured memory_bytes: 6912
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

int memo[301][301][301];
int visited[301][301][301];
char S[301];
int K, len;

int max(int i, int j) { if (i > j) { return i; } else { return j; } }
int dp(int i, int j, int k) {
	int M;
	if (visited[i][j][k] == 1) { return memo[i][j][k]; }

	if (i == j) {
		memo[i][j][k] = 0;
		visited[i][j][k] = 1;
	}
	else if (i + 1 == j) {
		memo[i][j][k] = 1;
		visited[i][j][k] = 1;
	}
	else {
		M = max(dp(i+1,j,k), dp(i,j-1,k));
		if (S[i] == S[j - 1]) { M = max(M, dp(i + 1,j - 1,k) + 2); }
		else if (k >= 1) { M = max(M, dp(i + 1,j - 1,k - 1) + 2); }
		memo[i][j][k] = M;
		visited[i][j][k] = 1;
	}
	return memo[i][j][k];
}

int main() {
	scanf("%s", S);
	scanf("%d", &K);
	len = strlen(S);

	for (int i = 0; i < 301; i++) {
		for (int j = 0; j < 301; j++) {
			for (int k = 0; k < 301; k++) {
				visited[i][j][k] = 0;
			}
		}
	}

	printf("%d\n", dp(0, len, K));
}

Measured memory_bytes: 213120
#include <stdio.h>

int main(void)
{
	int x, y, z, num;
	scanf("%d %d %d",&x, &y, &z);
	if(x==y){
		if(x==z)
			num=1;
		else
			num=2;
	}
	else{
		if(x==z||y==z)
			num=2;
		else
			num=3;
	}
	printf("%d\n", num);

	return(0);
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<cstdint>
#include<algorithm>
#include<boost/variant.hpp>
#include<boost/range/irange.hpp>
struct update
{
	std::int64_t a, b;
};
struct output
{

};
typedef boost::variant<update, output> query;
template<class T>class binary_indexed_tree
{
	typedef T type;
	std::vector<type> ar;
	std::size_t size;
public:
	binary_indexed_tree(std::size_t size_) :ar(size_), size(size_)
	{

	}
	void add(type val, int index)
	{
		++index;
		while (index <= size)
		{
			ar[index - 1] += val;
			index += index & -index;
		}
	}
	auto get(int index)const
	{
		++index;
		type ret{};
		while (index != 0)
		{
			ret += ar[index - 1];
			index -= index & -index;
		}
		return ret;
	}
};
struct operation
{
	binary_indexed_tree<int> count;
	binary_indexed_tree<std::int64_t> sum;
	std::map<std::int64_t, int> indexes;
	std::vector<std::int64_t> values;
	std::size_t size;
	std::int64_t update_count;
	std::int64_t constant;

	operation(
		std::map<std::int64_t, int>&& _indexes,
		std::vector<std::int64_t>&& _values,
		std::size_t _size) :
		count(_size),
		sum(_size),
		indexes(std::move(_indexes)),
		values(std::move(_values)),
		size(_size),
		update_count(),
		constant()
	{

	}
	
	void operator()(update const& q)
	{
		auto a = q.a;
		auto b = q.b;
		auto i = indexes[a];
		count.add(1, i);
		sum.add(a, i);
		constant += b;
		++update_count;
	}
	void operator()(output const&)
	{
		auto j = (update_count + 1) / 2;
		auto rng = boost::irange<std::size_t>(0, size);
		auto i = *std::partition_point(rng.begin(), rng.end(), [&](std::size_t k)
			{
				auto c = count.get(k);
				return c < j;
			});
		auto v = (2 * count.get(i) - update_count) * values[i] + sum.get(size - 1) - 2 * sum.get(i) + constant;
		std::cout << values[i] << " " << v << std::endl;
	}
};

void Main()
{
	int Q;
	std::cin >> Q;
	std::vector<query> queries;
	std::set<std::int64_t> as;
	for (int i : boost::irange(0, Q))
	{
		int q;
		std::cin >> q;
		if (q == 1)
		{
			std::int64_t a, b;
			std::cin >> a >> b;
			as.emplace(a);
			queries.emplace_back(update{ a,b });
		}
		else
		{
			queries.emplace_back(output{});
		}
	}
	std::map<std::int64_t, int> indexes;
	std::vector<std::int64_t> values;
	std::size_t index = 1;
	const std::int64_t min = -1000000000;
	indexes.emplace(min - 1, 0);
	values.emplace_back(min - 1);
	for (auto a : as)
	{
		indexes[a] = index;
		values.emplace_back(a);
		++index;
	}
	operation op(std::move(indexes), std::move(values), index);
	for (auto const& q : queries)
	{
		boost::apply_visitor(op, q);
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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


int main() {
	long long int a, b, n, k, m, sum=0;
	string str;
	cin >> a >> b >> n;


	cout << a * b*n / max(a, max(b, n)) / 2;
}

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 ll;
const ll mod = 1e9+7;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,L;
    cin >> N >> L;
    ll ans = 0;
    ll minimum = LLONG_MAX;
    REP(i,N){
        ans += L + i;
        minimum = min(minimum,abs(L+i));
    }
    if(minimum!=0&&L<0){
        cout <<ans + minimum<< "\n";
    }else{
        cout <<ans - minimum<< "\n";
    }
}

Measured memory_bytes: 256
p = [raw_input() for i in xrange(8)]
pr = ["".join([p[y][x] for y in xrange(7,-1,-1)]) for x in xrange(8)]
print "90"
for i in xrange(8):
    print pr[i]
print "180"
for i in xrange(7,-1,-1):
    print p[i][::-1]
print "270"
for i in xrange(7,-1,-1):
    print pr[i][::-1]

Measured memory_bytes: 4220
#include <iostream>
using namespace std;
int main(void){
    int a,b ;
    cin >> a;
    cin >> b;
    if(a < b){
        cout << "a < b" <<endl;
    }
        else if(b < a){
            cout << "a > b"   << endl;
        }
            else{
                cout <<   "a == b" <<endl;
            }
}   


Measured memory_bytes: 3076
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
const int MAX_N = 100010;

int par[MAX_N];
int Rank[MAX_N];
int SIZE;

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        Rank[i] = 0;
    }
    SIZE = n;
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    SIZE--;
    if (Rank[x] < Rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (Rank[x] == Rank[y]) {
            Rank[x]++;
        }
    }
}
bool same(int x, int y) {
    return find(x) == find(y);
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    
    cin >> N >> M;
    init(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        unite(a, b);
    }
    cout << SIZE - 1 << endl;

    return 0;
}


Measured memory_bytes: 4444
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}*/ 
int main()
{
	int n,m;
	cin>>n>>m;
	priority_queue<int> a;
	for(int i=0;i<n;i++)
	{
		int a1;
		cin>>a1;
		a.push(a1);
	}
	for(int i=0;i<m;i++)
	{
		int r=a.top();
		a.pop();
		a.push(r/2);
	}
	ll ans=0;
	while(a.size()>0)
	{
		ans+=a.top();
		a.pop();
	}
	cout<<ans;
	return 0;
	
}







Measured memory_bytes: 892
'use strict'

const Main = (input) => {
  const tmp = input.trim().split('\n')
  const N = parseInt(tmp[0].split(' ')[0])
  const A = parseInt(tmp[0].split(' ')[1])
  const B = parseInt(tmp[0].split(' ')[2])
  const S = tmp[1].split('')
  //a 国内
  //b 海外
  //c どちらでもない

  let result = []
  let count = 0
  let overseas = 0

  for (let i = 0; i < N; i++) {
    const participant = S[i]
    if (participant === 'a') {
      if (count < (A + B)) {
        result.push('Yes')
        count += 1
      } else {
        result.push('No')
      }
    } else if (participant === 'b') {
      if (count < (A + B) && overseas < B) {
        result.push('Yes')
        count += 1
        overseas += 1
      } else {
        result.push('No')
      }
    } else {
      result.push('No')
    }
  }
  result = result.join('\n')

  console.log(result)
  return result
}

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

Measured memory_bytes: 38304
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
ll c;
vector<pair<ll, ll>> nums;
int main() {
    cin >> n >> c;
    nums.resize(n+1);
    vector<ll> g(n+1);
    nums[0] = {0, 0};
    g[0] = 0;
    ll cur = 0;
    for (int i = 1; i <= n; i++) {
        cin >> nums[i].first >> nums[i].second;
        cur += nums[i].second;
        g[i] = max(g[i-1], cur - nums[i].first);
    }
    vector<ll> rg(n+1);
    rg[0] = 0;
    cur = 0;
    for (int i = 1; i <= n; i++) {
        cur += nums[n+1-i].second;
        rg[i] = max(rg[i-1], cur - c + nums[n+1-i].first);
    }
    ll ans = max(rg[n], g[n]);
    for (int i = 1; i <= n; i++) {
        ans = max(ans, rg[n-i] + g[i]-nums[i].first);
    }
    for (int i = 1; i <= n; i++) {
        ans = max(ans, g[n-i] + rg[i]- c + nums[n+1-i].first);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;

long long gcd(long long a, long long b){
	if(a%b==0)return b;
	else return gcd(b,a%b);
}
int main()
{ 
	int cnt=1;
	long long n,m;
	cin>>n>>m;
	long long arr [100000];
	for(int i=0;i<100000;i++)arr[i]=-1;
	for(int i=0;i<n;i++)cin>>arr[i];
	
	for(int i=0;i<40;i++){
		if(arr[0]%2!=0)break;
		arr[0]=arr[0]/2;
		cnt=cnt*2;
	}
	for(int i=1;i<n;i++){
		int cmd=1;
		for(int j=0;j<40;j++){
			if(arr[i]%2!=0)break;
			arr[i]=arr[i]/2;
			cmd=cmd*2;
		}
		if(cmd!=cnt){cout<<"0"<<endl;return 0;}
	}
	long long gt=1;
	for(int i=0;i<n;i++){
		gt=gt*arr[i]/gcd(gt,arr[i]);
	}
	gt=gt*cnt/2;
	if(gt>m){
		cout<<"0"<<endl;
		return 0;
	}
	cout<<((m/gt)+1)/2<<endl;
	return 0;
}


	


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define MP make_pair
#define VI vector<int>
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

int main(){
    IOS();
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<char> stk;
    REP (i,n) {
        if (!SZ(stk) || stk.back() != s[i]) stk.eb(s[i]);
    }
    cout << SZ(stk) << endl;
}


Measured memory_bytes: 592
#include <iostream>

const long long INF = 1LL << 60;

int main() {
    long long X;
    std::cin >> X;

    auto pow = [](long long a, long long n) {
        long long res = 1;
        for (; n; n >>= 1) {
            if (n & 1) res *= a;
            a *= a;
        }
        return res;
    };

    for (int a = 0; pow(a, 5) <= INF; a++) {
        for (int b = 0; pow(b, 5) <= INF; b++) {
            long long p = pow(a, 5) - pow(b, 5);
            long long q = pow(a, 5) + pow(b, 5);
            if (p == X) {
                std::cout << a << " " << b << "\n";
                return 0;
            }
            if (q == X) {
                std::cout << a << " " << -b << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

using namespace std;

int main()
{
	int d;
	unsigned int ans;

	while(cin>>d){
		ans=0;
		for(int i=d;i<600;i+=d) ans+=i*i*d;

		cout<<ans<<endl;
	}


	return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int main()
{
    int n, t;
    cin >> n >> t;

    int tt, c, ans = INT_MAX;
    for(int i = 0; i < n; i++){

        cin >> c >> tt;

        if(tt <= t)
            ans = min(ans, c);
    }

    if(ans == INT_MAX)
        cout << "TLE\n";
    else
        cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n,h[21],i=0,can=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&h[i]);
	}
	for(i=1;i<n;i++)
	{
		if(h[i]>=h[i-1])
		{
			can++;
		}
		else
		{
			h[i]=h[i-1];
		}
	}
	printf("%d",can);
	return 0;
}


Measured memory_bytes: 256
// C - Welcome to AtCoder
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,m,p,ac=0,wa=0;
	string s;
	cin>>n>>m;
	int wa_count[n]; while(n--) wa_count[n] = 0;
	while(m--){
		cin>>p>>s; --p;
		if(wa_count[p] < 0) continue;// ac
		else{//not ac
			if(s[0] == 'W') wa_count[p]++;
			else{
				wa += wa_count[p];
				wa_count[p] = -1;// ac flag on
				ac++;
			}
		}
	}
	cout<< ac <<" "<< wa <<endl;
}

Measured memory_bytes: 640
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

struct S {
    int ly, lx;
    int ry, rx;
}
 
bool used[50][50][50][50];
void main() {
    int W, H;
    while (readf("%d %d\n", &W, &H), W || H) {
        auto L = new char[][H],
             R = new char[][H];
        foreach (i; 0 .. H) {
            string[] I = readln.chomp.split(" ");
            L[i] = cast(char[])I[0];
            R[i] = cast(char[])I[1];
        }
        int lx, ly, rx, ry;
        foreach (i; 0 .. H) {
            foreach (j; 0 .. W) {
                if (L[i][j] == 'L') {
                    ly = i;
                    lx = j;
                    //L[i][j] = '.';
                }
                if (R[i][j] == 'R') {
                    ry = i;
                    rx = j;
                    //R[i][j] = '.';
                }
            }
        }

        bool bfs() {
            memset(cast(void*)used, 0, used.sizeof);
            DList!S Q; Q.insert(S(ly, lx, ry, rx)); used[ly][lx][ry][rx] = true;
            while (!Q.empty) {
                static const dy = [0, 1, 0, -1],
                             dx = [1, 0, -1, 0];
                S c = Q.front; Q.removeFront;
                foreach (i; 0 .. 4) {
                    S n;
                    n.ly = c.ly + dy[i];
                    n.lx = c.lx + dx[i];
                    n.ry = c.ry + dy[i];
                    n.rx = c.rx - dx[i];
                    if (n.ly < 0 || n.ly >= H) n.ly = c.ly;
                    if (n.lx < 0 || n.lx >= W) n.lx = c.lx;
                    if (L[n.ly][n.lx] == '#') n.ly = c.ly;
                    if (L[n.ly][n.lx] == '#') n.lx = c.lx;
                    if (n.ry < 0 || n.ry >= H) n.ry = c.ry;
                    if (n.rx < 0 || n.rx >= W) n.rx = c.rx;
                    if (R[n.ry][n.rx] == '#') n.ry = c.ry;
                    if (R[n.ry][n.rx] == '#') n.rx = c.rx;
                    if (used[n.ly][n.lx][n.ry][n.rx]) continue;
                    used[n.ly][n.lx][n.ry][n.rx] = true;
                    //[n.ly, n.lx, n.ry, n.rx].writeln;
                    if (L[n.ly][n.lx] == '%' || R[n.ry][n.rx] == '%') {
                        if (L[n.ly][n.lx] == '%' && R[n.ry][n.rx] == '%') {
                            return true;
                        } else {
                            continue;
                        }
                    }
                    Q.insert(n);
                }
            }
            return false;
        }
        
        writeln(bfs ? "Yes" : "No");
    }
}

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

int main(){
  int n;
  cin >> n;
  ll ans = 0;
  vector<ll> march(5,0);
  string m = "MARCH";
  rep(i, n){
    string s;
    cin >> s;
    rep(j, 5){
      if(s.at(0)==m.at(j)) march.at(j)++;
    }
  }
  rep(i, 3){
    for(int j = i+1; j<4;j++){
      for(int k=j+1; k<5;k++){
        ans += march.at(i) * march.at(j) * march.at(k);
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 3636
S = input()
S = list(S)
N = [1 for i in range(len(S))]


pre = ""
tmp_r = 0
tmp_l = 0
Ri = 0
Li = 0

for i in range(len(S)):
    if pre == "":
        pre = S[i]
    elif i == len(S)-1:
        if pre == "L":
            tmp_l += 1
            N[i] = 0
            N[Ri] += (tmp_r // 2) + (tmp_l // 2 + tmp_l % 2)
            N[Li] += (tmp_r // 2 + tmp_r % 2) + (tmp_l // 2)
        elif pre == "R":
            Ri = i - 1
            Li = i
            N[Ri] += (tmp_r // 2) + (tmp_l // 2 + tmp_l % 2)
            N[Li] += (tmp_r // 2 + tmp_r % 2) + (tmp_l // 2)
    elif pre == "R":
        if S[i] == "R":
            tmp_r += 1
            N[i-1] = 0
        elif S[i] == "L":
            Ri = i - 1
            Li = i
            pre = S[i]
    elif pre == "L":
        if S[i] == "L":
            tmp_l += 1
            N[i] = 0
        elif S[i] == "R":
            pre = S[i]
            N[Ri] += (tmp_r // 2) + (tmp_l // 2 + tmp_l % 2)
            N[Li] += (tmp_r // 2 + tmp_r % 2) + (tmp_l // 2)
            tmp_l = 0
            tmp_r = 0
            Ri = 0
            Li = 0

for i in range(len(N)):
    if i == len(N)-1:
        print(N[i])
    else:
        print(N[i], end=" ")


Measured memory_bytes: 5584
import scala.io.{StdIn => in}
import annotation.tailrec

object Main extends App {
  val n = in.readInt
  val a = 0 +: in.readLine.split(" ").map(_.toInt).sorted
  val b = in.readLine.split(" ").map(_.toInt).sorted
  val c = 0 +: in.readLine.split(" ").map(_.toInt).sorted

  val ans = b./:(0L) { (acc, i) =>
    val ia = binarySearch(a, i, false)
    val ic = n - binarySearch(c, i, true)
    // println(ia, ic)
    acc + ia.toLong * ic.toLong
  }
  
  println(ans)

  def binarySearch(arr: Array[Int], key: Int, isUpper: Boolean): Int = {
    var left = 0
    var right = arr.size

    val evalute = (idx: Int, key: Int) => {
      if(isUpper) arr(idx) <= key else arr(idx) < key
    }

    @tailrec
    def loop(left:Int, right:Int):Int = {
      if(right - left < 2) left
      else {
        val mid = (left + right) / 2
        if( evalute(mid, key) ) loop(mid,right)
        else loop(left, mid)
      }
    }
    loop(left, right)
  }
}

Measured memory_bytes: 81596
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <bitset>

using namespace std;

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

int main() {
  ios::sync_with_stdio(false);
  string s, t;
  cin >>s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) ans += (s[i] != t[i]);
  cout << ans << endl;
}

Measured memory_bytes: 3872
#include<iostream>

using namespace std;

int main(){
  int a,b,k,tmp,K[100],count=0,i;
  cin >> a >> b >> k;

  for(i=1;i<=a;i++){
    if(a%i==0 && b%i==0){
      K[count]=i;
      count++;
    }
    //if(count==k) break;
  }
  cout << K[count-k] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int dsum(int a);

int main()
{
	int sum,i,kari,ans=100;
	scanf("%d",&sum);
	for(i=1;i<=sum/2;i++)
	{
		kari=dsum(i)+dsum(sum-i);
		if(ans>kari)ans=kari;
	}
	printf("%d",ans);
}

int dsum(int a)
{
	int b=0;
	while(a!=0)
	{
		b+=a%10;
		a/=10;
	}
	return b;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
using ll = long long;
int main(){ 
    ll a,b;
    cin>>a>>b;
    ll c;
    c=max(a+b,max(a-b,a*b));
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
	Scanner scn = new Scanner(System.in);
      int check = 0;
      int[] a = new int[9];
      for(int i=0; i<a.length; ++i){
        a[i] = scn.nextInt();
      }
      int x1 = 0;
      int x2 = 0;
      int y1 = 0;
      int y2 = 0;
      x1 = a[3] - a[0];
      x2 = a[6] - a[3];
      
      if(a[4] != a[1]+x1){
        check=1;
      } if(a[5] != a[2]+x1){
        check=1;
      } if(a[7] != a[4]+x2){
        check=1;
      } if(a[8] != a[5]+x2){
        check=1;
      }
      
      if(check==0){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
	}
}


Measured memory_bytes: 35600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a;
  cin >> a;
  int b;
  if(a % 1000 == 0){
    cout << "0\n";
    return 0;
  }
  b = a / 1000 + 1;
  b = b * 1000;
  cout << b - a << "\n";
}
  
  
  
  
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

int N, K;
int a[109];
int dp[100009];

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

    cin >> N >> K;
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }

    for (int i = 1; i <= K; i++)
    {
        for (int j = 1; j <= N; j++)
        {
            if (i - a[j] >= 0 && dp[i - a[j]] == 0)
            {
                dp[i] = 1;
                break;
            }
        }
    }

    if (dp[K])
        cout << "First\n";
    else
        cout << "Second\n";
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
using namespace std;
int main()
{
    IOS;
    int n, x, t;
    cin >> n >> x >> t;
    int a = ceil((double)n / x);
    cout << 1ll * t * a;
}

Measured memory_bytes: 3608
#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() {
  ll X, K, D;
  cin >> X >> K >> D;
  X = abs(X);

  ll ans = 0;
  if (X / D >= K) {
    ans = X - D * K;
  } else {
    ll r = X % D;
    if ((K - X / D) % 2 == 0) {
      ans = r;
    } else {
      ans = D - r;
    }
  }

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


Measured memory_bytes: 3628
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;
use std::vec::Vec;
use std::collections::VecDeque;

fn main() {
    let stdin = stdin();
    let mut scan = InputScanner::new(stdin.lock(),256);

    let h:usize = scan.next();
    let w:usize = scan.next();

    let mut a:Vec<Vec<char>> = (0..h).map(|_| scan.next::<String>().chars().collect()).collect::<Vec<Vec<char>>>();

    let mut queue = VecDeque::new();

    for y in 0..h {
        for x in 0..w {
            if a[y][x] == '#' {
                queue.push_back((x,y));
            }
        }
    }

    let mut white_count = h * w - queue.len();
    let mut count = 0;

    let mut onmoved = OnMoved::new(w,h);

    'outer: while queue.len() > 0 {
        let mut current = queue.drain(0..).collect::<VecDeque<_>>();

        if white_count == 0 {
            break 'outer;
        }

        while let Some((x,y)) = current.pop_front() {
            onmoved.vh_move(x,y,|x,y| {
                if a[y][x] == '.' {
                    white_count -= 1;
                    a[y][x] = '#';
                    queue.push_back((x,y));
                }
            })
        }

        count += 1;
    }

    println!("{}",count);
}
struct OnMoved {
    w:usize,
    h:usize
}
impl OnMoved {
    pub fn new(w:usize,h:usize) -> OnMoved {
        OnMoved {
            w:w,
            h:h
        }
    }

    pub fn vh_move<F: FnMut(usize,usize)>(&mut self,x:usize,y:usize,mut f:F) {
        let x = x as i64;
        let y = y as i64;

        for &(dx,dy) in &[(-1,0),(1,0),(0,-1),(0,1)] {
            let x = x + dx;
            let y = y + dy;

            if x >= 0 && x < self.w as i64 && y >= 0 && y < self.h as i64 {
                let x = x as usize;
                let y = y as usize;

                f(x,y);
            }
        }
    }
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}



Measured memory_bytes: 40184
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	string S;

	cin >> N >> S;

	if((int)S.size()%2==0 && S.substr(0,N/2)==S.substr(N/2,(int)S.size()-1))
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
	return 0;
}



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

#define endl '\n'
#define ll long long
#define int long long
#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

#define db  long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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



	ll t, i, x, j, y, 	z, k, n;
	cin >> n  ;
	set<string> s;
	while (n--)
	{
		string st;
		cin >> st;
		s.insert(st);
	}

	return cout << s.size(), 0;

	// ce(t)
	// rep(i, 0, t, 1) {
	// 	cout << v[i].size() << " ";
	// 	for (auto zx : v[i])	cout << zx << " ";
	// 	ce("")
	// }

}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()

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

  int a, b, c;
  cin >> a >> b >> c;

  int count = 0;

  if(a != b) count++;
  if(a != c) count++;
  if(b != c) count++;
  if(count == 0) count = 1;

  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
char buf[11];
int N;
void fn(const char last, const int n) {
  if (n == N) {
    cout << buf << '\n';
    return;
  }
  for (char c = 'a'; c <= last + 1; c++) {
    buf[n] = c;
    fn(max<char>(last, c), n + 1);
  }
}
int main() {
  cin >> N;
  buf[N] = '\0';
  buf[0] = 'a';
  fn('a', 1);
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi; 
typedef vector<pi> vpi;

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rsz resize
#define bk back()
#define pb push_back
#define ins insert
#define del erase
#define inf INT_MAX

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7;
const ld PI = acos((ld)-1);
mt19937 rng; // or mt19937_64
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a = 1 ;
	while(a--)
	{
		string s ;
		cin >> s ;
		string t ;
		cin >> t ;
		string arr[sz(s)];
		arr[0]=s[0];
		int ans1=INT_MAX;
		F0R(i,sz(s)-sz(t)+1)
		{
			int ans=0;
			FOR(j,i,i+sz(t))
			{
				if(s[j]!=t[j-i])
				{
					ans++;
				}
			}
			ans1=min(ans,ans1);
		}
		cout << ans1;
		
			
		
	}	
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ll long long int
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define mp make_pair
#define pb push_back
#define pi pair <int, int > 
#define pl pair <ll, int >
#define infl (1ll << 60)
#define inf (1 << 30)
#define nax  100010
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int arr[nax];
int sum[nax];
int gcf[nax];
int gcb[nax];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    sd(n);
    int run = 0;
    for(int i = 1; i <= n; i++)
    {
        sd(arr[i]);
        gcf[i] = __gcd(run, arr[i]);
        run = gcf[i];
    }

    run = 0;
    for(int i = n; i >= 1; i--)
    {
        gcb[i] = __gcd(run, arr[i]);
        run = gcb[i];
    }

    int ans = 0;
    for(int i = 1; i <= n; i++)
        ans =  max(ans, __gcd(gcf[i - 1], gcb[i + 1]));

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

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

    vector<LL> A(N);
    vector<LL> B(N);
    rep(i, N) {
        cin >> A[i];
        B[i] = A[i];
    }

    //プラススタート
    LL sum = A[0] > 0 ? A[0] : 1;
    LL count = sum - A[0];
    for(int i = 1; i < N; i++) {
        LL tmp = A[i] + sum;
        if(i % 2 == 1 and tmp >= 0) {
            A[i] += (-1 - tmp);
            count += abs(-1 - tmp);
        } else if(i % 2 == 0 and tmp <= 0) {
            A[i] += (1 - tmp);
            count += (1 - tmp);
        }
        sum += A[i];
    }

    LL ans = count;

    //マイナススタート
    sum = B[0] < 0 ? B[0] : -1;
    count = abs(sum - B[0]);
    for(int i = 1; i < N; i++) {
        LL tmp = B[i] + sum;
        if(i % 2 == 0 and tmp >= 0) {
            B[i] += (-1 - tmp);
            count += abs(-1 - tmp);
        } else if(i % 2 == 1 and tmp <= 0) {
            B[i] += (1 - tmp);
            count += (1 - tmp);
        }
        sum += B[i];
    }
    chmin(ans, count);

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
bool isgood(long long int mid,vector<int> &arr,long long int k)
{
    int count=0;
    if(mid==0)
        return false;
    for(long long int i=0;i<arr.size();i++)
    {
        if(arr[i]<=mid)
            continue;
        else
        {
            long long int x=arr[i]/mid;
            long long int rem=arr[i]%mid;
            if(rem==0)
            {
                count+=x-1;
            }
            else
            {
                count+=x;
            }
        }
    }
    if(count<=k)
    {
        return true;
    }
    else
        return false;
}
int main()
{
    long long int n,k;
    cin>>n>>k;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    long long int start=0,end=1000000020;
    while(start<end)
    {
        long long int mid=start+ (end-start)/2;
        if(isgood(mid,arr,k))
        {
            end=mid;
        }
        else
        {
            start=mid+1;
        }
    }
    cout<<start<<endl;

}


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


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

  bool flg_c=false,flg_f=false;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='C')
      flg_c=true;
    else if(s.at(i)=='F' && flg_c==true)
      flg_f=true;
  }

  if(flg_f)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

	return 0;
}



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

typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll INFLL = (ll)1e18+1;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int H,W;
template<class T> class Dijkstra {
public:
    int N;
    T inf;
    vector<T> cost;
    vector<vector<pair<T, int>>> edge;
    Dijkstra(const int _N, T _inf) : N(_N), inf(_inf),cost(_N), edge(_N) {
    }
 
    void make_edge(int from, int to, T w) {
        edge[from].push_back({ w,to });
    }
 
    void solve(int start) {
        for(int i = 0; i < N; ++i) cost[i] = inf;
 
        priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
        cost[start] = 0;
        pq.push({ 0,start });
 
        while (!pq.empty()) {
            T v = pq.top().first;
            int from = pq.top().second;
            pq.pop();
            for (auto u : edge[from]) {
                T w = v + u.first;
                int to = u.second;
                if (w < cost[to]) {
                    cost[to] = w;
                    pq.push({ w,to });
                }
            }
        }
        return;
    }
};


vector<string> A;
bool IsIn(int x,int y){
    return 0<=x&&x<H&&0<=y&&y<W;
}
int f(int i, int j){
    return i * W + j;
}

int main() {

    cin >> H >> W;
    A.resize(H);
    rep(i,H){
        cin >> A[i];
    }
    Dijkstra<ll> d(H*W, INFLL);
    rep(i,H)rep(j,W){
        rep(k,2){
            int e = f(i, j);
            int nx = i + dx[k];
            int ny = j + dy[k];
            int ne = f(nx, ny);
            int cost = 0;
            if(!IsIn(nx, ny))continue;
            if(A[i][j] == '.' && A[nx][ny] == '#')cost = 1;
            d.make_edge(e, ne, cost);
        }
    }
    d.solve(f(0, 0));

    ll ans = d.cost[f(H-1, W-1)];
    if(A[0][0] ==  '#')ans++;
    cout << ans <<  endl;
}

Measured memory_bytes: 1024
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
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;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

//main.cpp----------------------------


void solve();

ll n;
ll a[100100];

int main() {
  cin >> n;
  rep(i, n) cin >> a[i];

  solve();

  return 0;
}

void solve() {
  ll odd = 0;
  ll even = 0;

  rep(i, n) {
    if(a[i]%2==0) even += 1;
    else odd += 1;
  }

  if(odd%2==1) cout << "NO" << endl;
  else cout << "YES" << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

/**
 * Created by Harry on 4/2/20.
 */
//https://atcoder.jp/contests/dp/tasks/dp_i
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        double[] p = new double[N];
        for(int i=0; i<N; i++){
            p[i] = scanner.nextDouble();
        }
        double[] dp = new double[N+1];
        dp[0] = 1;
        for(int i=0; i<N; i++){
            for(int j=i+1; j>=0; j--){
                dp[j] = dp[j]*(1-p[i])+(j-1>=0 ? dp[j-1]*p[i] : 0);
            }
        }
        double res = 0.0;
        for(int i=(N+1)/2; i<=N; i++){
            res += dp[i];
        }
        System.out.print(res);
    }
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N;
	
	ll L[100];
	
	cin >> N;
	
	L[0] = 2;
	L[1] = 1;
	
	for(int i=2; i<=N; i++)
		L[i] = L[i-1] + L[i-2];
	
	cout << L[N];
	
	return 0;
}

Measured memory_bytes: 256
N=int(input())
Pn=tuple(map(int, input().split()))
Qn=tuple(map(int, input().split()))
a,b=0,0

from itertools import permutations
seq = [i for i in range(1, N+1)]
for i, l in enumerate(list(permutations(seq))):
    if l == Pn:
        a = i
    if l == Qn:
        b = i

print(abs(a-b))

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

using namespace std;

#define ff(i, a, b) for(int i = (a); (i <= (b)); ++i)
#define FF(i, a, b) for(int i = (a); (i >= (b)); --i)
#define ll long long

const int M = 1000000000 + 7;

struct re {
    int x, y;
    const bool operator < (const re &a) const {
        if (x != a.x) return x < a.x;
        return y < a.y;
    }
};

int n;
re a[100010];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("", "r" , stdin);
    //freopen("", "w", stdout);
    cin >> n;
    ff(i, 1, n) {
        cin >> a[i].x;
        a[i].y = i;
    }
    sort(a + 1, a + 1 + n);

    ff(i, 1, n) cout << a[i].y << " ";
}
//This code belongs to s34vv1nd


Measured memory_bytes: 1664