akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,sum=0;
    cin>>N;
    vector<int> a(N);
    REP(i,N){
        cin>>a[i];
        sum += a[i];
    }
    
    ll M = N * (N+1) / 2;
    if(sum % M > 0){
        cout<<"NO"<<endl;
        return 0;
    }
    
    M = sum / M;
    REP(i,N){
        ll d = a[(i+1) % N] - a[i];
        if(M < d || (M-d) % N > 0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;

struct item
{
	int w, v;
};

ll knapsack_weight(vector <item> &v, int n, int w)
{
	int MAXV = 100005, INF=2000000000;
	vector <ll> dp(MAXV+1,INF), aux(MAXV+1,INF);
	vector <bool> visto(MAXV,false);
	visto[0]=true; dp[0]=0;
	forn(i,n)
	{
		forn(j,MAXV)
		{
			aux[j]=dp[j];
			if(j-v[i].v < 0) continue;
			if(visto[j-v[i].v]==true)
			{
				aux[j]=min(aux[j],dp[j-v[i].v]+v[i].w);
				visto[j]=true;
			}
		}
		forn(j,MAXV) dp[j]=aux[j];
	}
	ll ans = 0;
	forn(i,MAXV+1) if(dp[i] <= w && visto[i]==true) ans=i;
	return ans;
}
 
int main()
{ 	
	FIN;
	#ifdef input
		freopen("test1.txt", "r", stdin);
	#endif

	int n, w;
	cin >> n >> w;
	vector <item> v(n);
	forn(i,n) cin >> v[i].w >> v[i].v;
	cout << knapsack_weight(v,n,w) << endl;
    return 0;
}


Measured memory_bytes: 4768
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int F(ll A, ll B) {
    return max(to_string(A).length(), to_string(B).length());
}
int main() {
    ll N;
    vector<ll> divisor;
    cin >> N;
    for (int i = 1; i <= sqrt(N); i++) {
        if (N % i == 0) divisor.push_back(i);
    }
    ll& A = divisor.back();
    cout << F(A, N / A) << endl;
}

Measured memory_bytes: 256
/*In the name of Allah*/
#include<bits/stdc++.h>

#include<cstdio>
#include<vector>
#include<utility>
#include<string>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <string>

#include <set>
#include <map>
#include <sstream>
#include <queue>
#include <string.h>

#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

using namespace __gnu_cxx;
using namespace std;
typedef long long ll;
typedef long double ld;

#define pi acos(-1)
#define s(a) scanf("%d",&a)
#define p(a) printf("%d",a)

#define csp(a) cout<<a<<' '
#define cnl(a) cout<<a<<'\n'
#define nl cout<<'\n';
#define sp cout<<' ';


#define REP(i, a, b) for (int i = (a); i < (b); ++i)

#define rep(i, n) REP(i, 0, (n))


#define REPE(i,a,b) for (int i = (a); i <= (b) ; ++i)
#define repe(i,n) REPE(i, 1, (n))


#define optimize() ios_base::sync_with_stdio(0)
int main(){ optimize();

int a,b,c; cin>>a>>b>>c;
cout<< c<<' '<<a<<' '<<b;


return 0;}

Measured memory_bytes: 256
from collections import defaultdict
n,k=map(int,input().split())
ab=[input() for i in range(n)]
d = defaultdict(list)
[d[int(i.split()[0])].append(int(i.split()[1])) for i in ab]
sd=sorted(d.items(), key=lambda x:x[0])
c=0
for i,l in sd:
  c+=sum(l)
  if c>=k:
    print(i)
    exit()

Measured memory_bytes: 30740
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
#define ld long double

using namespace std;	

const int N = 1e5 + 101;

int n, matching, dead[N];
vector <int> g[N];

void dfs(int v, int p) {
	for (auto u : g[v])
		if (u != p)
			dfs(u, v);
	if (p != 0 && !dead[p] && !dead[v]) {
		matching += 2;
		dead[p] = 1;
		dead[v] = 1;
	}
}

int main() {
	scanf ("%d", &n);
	rep(i, 2, n) {
		int u, v;
		scanf ("%d%d", &u, &v);
		g[u].pb(v);
		g[v].pb(u);
	}
	dfs(1, 0);
	printf (matching == n ? "Second\n" : "First\n");
	
	return 0;
}


Measured memory_bytes: 9804
#include <cstdio>
#include <vector>

using namespace std;

vector<int> hand;

int main(){
	int self;
	while(1){
		hand.clear();
		scanf("%d",&self);
		if(self == 0){break;}
		hand.push_back(self);
		for(int i = 1;i < 5;i++){
			scanf("%d",&self);
			hand.push_back(self);
		
		}
		bool flag[4];
		flag[0] = false;
		flag[1] = false;
		flag[2] = false;
		flag[3] = false;
		vector<int>::iterator it;
		for(it = hand.begin();it < hand.end(); it++){
			flag[*it] = true;
		}
		int re[4];
		if( (flag[1] && flag[2] && flag[3]) || (flag[1] && !flag[2] && !flag[3]) || (!flag[1] && flag[2] && !flag[3]) || (!flag[1] && !flag[2] && flag[3]) ){
			re[1] = 3; // O[
			re[2] = 3; // `L
			re[3] = 3; // p[
		}
		if(flag[1] && flag[2] && !flag[3]){
			re[1] = 1; // O[
			re[2] = 2; // `L
			re[3] = 0; // p[
		}
		if(flag[1] && !flag[2] && flag[3]){
			re[1] = 2; // O[
			re[2] = 0; // `L
			re[3] = 1; // p[
		}
		if(!flag[1] && flag[2] && flag[3]){
			re[1] = 0; // O[
			re[2] = 1; // `L
			re[3] = 2; // p[
		}
		for(it = hand.begin();it < hand.end(); it++){
			printf("%d\n",re[*it]);
		}
	}
	return 0;
}

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

bool is_prime(int x){ 
  if(x<=1) return false;
  	for(int i=2;i*i<=x;i++)
  		if(x%i==0) return true;
  				   return false;
}

signed main(){
int x;
cin>>x;

int p=x;
while(is_prime(p)) p++; //is_primeがtrueを返す間はp++(素数でない) 
  // is_primeがfalseを返したら進む
cout<<p<<endl;
  
return 0;
 }

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll ans = 1;
    cin >> N;
    rep(i, N) {
        ll temp;
        cin >> temp;
        ans = ans / __gcd(ans, temp) * temp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int K; cin >> K;
	REP(i, K)cout << "ACL";
	cout << endl;
	return 0;
}



Measured memory_bytes: 3648
package main

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

func main() {
	read := bufio.NewReader(os.Stdin)
	write := bufio.NewWriter(os.Stdout)
	defer write.Flush()
	var n int
	sum := 0
	fmt.Fscan(read, &n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(read, &a)
		if i%2 == 0 && a%2 == 1 {
			sum++
		}
	}
	fmt.Fprintln(write, sum)
}


Measured memory_bytes: 1844
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    x, a, b = map(int, readline().split())

    if abs(x - a) < abs(x - b):
        print('A')
    else:
        print('B')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
N=int(input())
ans=0
if N<10**1:
  ans=N
elif N<10**2:
  ans=9
elif N<10**3:
  ans=N-90
elif N<10**4:
  ans=909
elif N<10**5:
  ans=N-9000-90
else:
  ans=90909
print(ans)

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

typedef long long lint;
const int maxn = 200005;

int n, f[maxn], fa[maxn], cnt[maxn][2];
lint ans;

struct node
{
	int cnt_0, cnt_1, id;
	
	friend bool operator < (const node &a, const node &b) {
		return (lint)a.cnt_1 * b.cnt_0 > (lint)a.cnt_0 * b.cnt_1;
	}
};
priority_queue<node> q;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline int find(int x)
{
	if (f[x] == x) return x;
	return f[x] = find(f[x]);
}

int main()
{
	n = gi();
	for (int i = 2; i <= n; ++i) fa[i] = gi();
	for (int i = 1; i <= n; ++i) cnt[i][gi()] = 1;
	for (int i = 1; i <= n; ++i) f[i] = i;
	for (int i = 2; i <= n; ++i) q.push((node) {cnt[i][0], cnt[i][1], i});

	int u, v;
	node tmp;
	while (!q.empty()) {
		tmp = q.top();
		u = find(tmp.id); q.pop();
		if (cnt[u][0] == tmp.cnt_0 && cnt[u][1] == tmp.cnt_1) {
			v = find(fa[u]);
			ans += (lint)cnt[v][1] * cnt[u][0];
			cnt[v][0] += cnt[u][0];
			cnt[v][1] += cnt[u][1];
			f[u] = f[v];
			if (v != 1) q.push((node) {cnt[v][0], cnt[v][1], v});
		}
	}

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


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 
#define pb push_back
#define sz(a) (int)a.size()

void solve(){
	int n;
	cin >> n;
	vi dp(3,0);
	for(int i=0;i<n;++i){
		vi a(3);
		vi new_dp(3,0);
		for(int j=0;j<3;++j){
			cin >> a[j];
		}
		for(int j=0;j<3;++j){
			for(int k=0;k<3;++k){
				if(j!=k) new_dp[k]=max(new_dp[k],dp[j]+a[k]);
			}
		}
		dp=new_dp;
	}
	int ans=0;
	for(int i=0;i<3;++i){
		ans=max(ans,dp[i]);
	}
	cout << ans << nl;
}

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

	solve();
	
	return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
int a[maxn];
int n;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        ll cot=0;
        int l=0;
        int r=n-1;
        while(1)
        {
            l+=i,r-=i;
            if(l==r||r<=i||l-i==r) break;
            cot+=a[l]+a[r];
            ans=max(ans,cot);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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


  cin >> n;
  ll pre = -inf;
  rep(i, n) {
    ll h;
    cin >> h;
    if (pre >= h) ans++;
    else {
      ma = max(ma, ans);
      ans = 0;
    }
    pre = h;
  }
  ma = max(ma, ans);
  cout << ma << endl;




  return 0;
}


Measured memory_bytes: 256
///FUCKOUT
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
#include <ext/rope> //header with rope
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
//#define endl '\n'

using namespace __gnu_cxx; //namespace with rope and some additional stuff

using ll = long long;
using db = long double;
using row = vector<int>;
using ii = pair<ll, ll>;

const int N = 3e5+5, M = 1e6 + 5, LG = 17, MOD = 1e9 + 7;
const int BLOCK = 55;
const int BLOCKN = N / BLOCK + 1;
const long double EPS = 1e-7;
using ull = unsigned long long;
int n;
int32_t main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#endif // ONLINE_JUDGE

  cin >> n;

  vector<ii> vp(n);

  f(i,0,n){
    cin >> vp[i].F;
  }
  vector<int> v;
  ll sum = 0, ans = 0;
  f(i,0,n){
    cin >> vp[i].S;
    v.pb(vp[i].F - vp[i].S);
    if(vp[i].F < vp[i].S){
      ans++;
      sum += vp[i].S - vp[i].F;
    }
  }

  sort(v.rbegin(),v.rend());

  f(i,0,n){
    if(sum <= 0)break;
    if(v[i] <= 0){
      cout << -1 << '\n';
      return 0;
    }
    sum -= v[i];
    ans++;
  }

  cout<<ans<<'\n';





  return 0;
}


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define double long double
#define M_PI 3.14159265358979323846 
const int mod = 1e9 + 7;

int32_t main()
{
    fastio;

    int x, n; cin >> x >> n;
    //int ans = INT_MAX;
    unordered_map<int,int> mp;
    for(int i=0; i<n; i++){
        int a; cin >> a;
        mp[a]++;
    }

    for(int i=0; i<=1000; i++){
        if(mp[x-i] == 0){
            cout << x-i << endl;
            break;
        }
        if(mp[x+i] == 0){
            cout << x+i << endl;
            break;
        }
    }
    return 0;
}

/*
2x + 4y= legs
x + y = total

*/

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

bool dp[8001][16001];
int a[8001];

int main(){
	string s;
	int x,y;
	cin>>s>>x>>y;
	int k=0, w=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='T'){
			a[++k]=w;
			w=0;
		}
		else{
			w++;
		}
	}
	a[++k]=w;
	dp[1][a[1]+8000]=1;
	for(int i=3;i<=k;i+=2){
		for(int j=0;j<=16000;j++){
			if(j+a[i]<=16000)
				dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	
	dp[0][8000]=1;
	for(int i=2;i<=k;i+=2){
		for(int j=0;j<=16000;j++){
			if(j+a[i]<=16000) 
			dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
			dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	
	int ans;
	if(k%2==0){ 
		ans=dp[k][y+8000]&&dp[k-1][x+8000];
	}
	else{
		ans=dp[k][x+8000]&&dp[k-1][y+8000];
	}
	
	cout<<((ans==1)?"Yes":"No");
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

const double PI = acos(-1);
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	sort(all(a));
	int ans = 0;
	rep(i, n) rep2(j, i+1, n){
		int sm = a[i] + a[j];
		int ps = lower_bound(all(a), sm) - a.begin();
		ans += max(0, ps -1 - j);
	}
	cout << ans <<"\n";
	return 0;
}


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


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

    long long a[n+1],h[n+1];
    for(long long i=1;i<=n;i++){
        cin>>h[i];
    }
    for(long long i=1;i<=n;i++){
        cin>>a[i];
    }
    long long dp[n+1]={0};
    long long z;
    long long m;
    long long ans=0;
    for(long long i=1;i<n+1;i++){
        z=h[i];
        m=0;
        for(;z;z-=z&-z){
            m=max(m,dp[z]);
        }
        z=h[i];
        dp[z]=m+a[i];
        ans=max(ans,dp[z]);
        m=dp[z];
        for(;z<n+1;z+=z&-z){
            dp[z]=max(m,dp[z]);
        }
    }cout<<ans;
}




Measured memory_bytes: 4992
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Vector.Unboxed (Vector, (!), (//))
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed.Mutable (IOVector, STVector)
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = do
  [h, w] <- f
  unless (h == 0 && w == 0) $ do
    solve h w <$> replicateM h getLine >>= print
    main
  where
    f = map read <$> words <$> getLine

solve :: Int -> Int -> [String] -> Int
solve h w ss = runST $ do
  cv <- V.thaw $ V.fromList $ concat ss
  cnt <- VM.replicate ((h+1) * w) 0 :: ST s (STVector s Int)
  forM_ [0 .. h-1] $ \i -> do
    c <- VM.read cv (idx (i, 0))
    VM.write cnt (idx (i, 0)) (if c == '.' then 1 else 0)
    forM_ [1 .. w-1] $ \j -> do
      x <- VM.read cnt (idx (i, j-1))
      c <- VM.read cv (idx (i, j))
      VM.write cnt (idx (i, j)) (if c == '.' then x + 1 else 0)
  (mx, _) <- foldM (f cnt) (0, []) [(i, j) | j <- [0 .. w-1], i <- [0 .. h]]
  return mx
  where
    idx (i, j) = i * w + j
    f :: (STVector s Int) -> (Int, [(Int, Int)]) -> (Int, Int) -> ST s (Int, [(Int, Int)])
    f cnt (mx, st) (i, j) = do
      x <- VM.read cnt (idx (i, j))
      case st of
       [] -> return (mx, (x, i):st)
       ((rh, ri):rst) -> do
         if rh < x
           then return (mx, (x, i):st)
           else if rh > x
                then g (mx, st) (x, i, i)
                else return (mx, st)
    g :: (Int, [(Int, Int)]) -> (Int, Int, Int) -> ST s (Int, [(Int, Int)])
    g (mx, st) (x, i, pi) = do
      case st of
       [] -> return (mx, [(x, pi)])
       ((rh, ri):rst) -> do
         if rh < x
           then return (mx, (x, pi):st)
           else g ((max mx (rh * (i-ri))), rst) (x, i, ri)



Measured memory_bytes: 51708
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
        String w = sc.next();
        String ans = "Good";

        if (w.substring(0, 1).equals(w.substring(1, 2))
            || w.substring(1, 2).equals(w.substring(2, 3))
            || w.substring(2, 3).equals(w.substring(3, 4))) {
            ans = "Bad";
        }

        System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21844
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Scanner scanner;
	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		// scanner.nextLine();
		String line = scanner.nextLine();

		int H = Integer.parseInt(line.split("\\s+")[0]);
		int A = Integer.parseInt(line.split("\\s+")[1]);

		int res = (int)Math.ceil(1.0 * H / A);
		System.out.println(res);
	}


}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
    int n, m;

    cin >> n >> m;

    cout << (1900 * m + 100 * (n - m)) * pow(2, m) << endl;
}

Measured memory_bytes: 256
n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = float("inf")
for l in range(n-k+1):
    r = l+k-1
    ansl = abs(x[l]) + abs(x[r]-x[l])
    ansr = abs(x[r]) + abs(x[r]-x[l])
    ans = min(ans,ansl,ansr)
print(ans)

Measured memory_bytes: 14532
#!/usr/bin/env python3
import sys


def solve(X: int, N: int, p: "List[int]"):
    for i in range(N):
        if X - i not in p:
            print(X-i)
            return
        elif X + i not in p:
            print(X+i)
            return
    if N == 0:
        print(X)
    else:
        print(X-1)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(X, N, p)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61972
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

const mod = 10^^9+7;
alias mint = FactorRing!mod;

void main()
{
  string s; readV(s);
  int d; readV(d);

  auto t = s.map!(si => cast(int)(si-'0'));
  auto dp = new mint[][][](s.length+1, 2, d);
  dp[0][0][0] = 1;

  foreach (i, ti; t.enumerate)
    foreach (j; 0..2)
      foreach (k; 0..d) {
        auto lm = j ? 9 : ti;
        foreach (l; 0..lm+1)
          dp[i+1][j || l < lm][(k+l)%d] += dp[i][j][k];
      }

  writeln(dp[$-1][0][0] + dp[$-1][1][0] - 1);
}

struct FactorRing(int m, bool pos = false)
{
  version(BigEndian) union { long vl; struct { int vi2; int vi; } } else union { long vl; int vi; }
  alias FR = FactorRing!(m, pos);
  @property static init() { return FR(0); }
  @property int value() { return vi; }
  @property void value(int v) { vi = mod(v); }
  alias value this;

  this(int v) { vi = v; }
  this(int v, bool runMod) { vi = runMod ? mod(v) : v; }
  this(long v) { vi = mod(v); }

  ref auto opAssign(int v) { vi = v; return this; }

  pure auto mod(int v) const { static if (pos) return v%m; else return (v%m+m)%m; }
  pure auto mod(long v) const { static if (pos) return cast(int)(v%m); else return cast(int)((v%m+m)%m); }

  static if (!pos) pure ref auto opUnary(string op: "-")() { return FR(mod(-vi)); }

  static if (m < int.max / 2) {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vi"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vi"~op~"r")); return this; }
  } else {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vl"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vl"~op~"r")); return this; }
  }
  pure ref auto opBinary(string op: "*")(int r) { return FR(mod(vl*r)); }
  ref auto opOpAssign(string op: "*")(int r) { vi = mod(vl*r); return this; }

  pure ref auto opBinary(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opBinary!op(r.vi); }
  ref auto opOpAssign(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(r.vi); }
}


Measured memory_bytes: 24060
k = int(input())
a,b = map(int, input().split())

ka = a//k
kb = b//k

if a % k ==0:
    print("OK")
    exit()
elif b % k ==0:
    print("OK")
    exit()
elif kb -ka >0:
    print("OK")
    exit()
else:
    print("NG")

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
int main(){
  map<char,int>m;
  m['I']=1;
   m['V']=5;
    m['X']=10;
     m['L']=50;
      m['C']=100;
       m['D']=500;
        m['M']=1000;
  string s;
  while(cin>>s){
    reverse(s.begin(),s.end());
    int p=0;
    p+=m[s[0]];
    for(int i=1;i<s.size();i++)
      if(m[s[i]]<m[s[i-1]])p-=m[s[i]];
        else p+=m[s[i]];
    cout<<p<<endl;
  }
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    ll ans=0;
    rep(i,1,N+1){
        ll sum=0;
        string s=to_string(i);
        rep(j,0,s.size()){
            sum+=s[j]-'0';
        }
        if(A<=sum&&sum<=B)ans+=i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>
#include <algorithm>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(to); x++) // for簡略表記
#define DUMP(ar) for(int i=0; i<ar.size(); i++) cout << "[" << i << "]:" << ar[i] << endl // 配列一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// goto ANSWER; で最後へ飛ぶ
// getline(cin, [変数]); で空白など(ホワイトスペース)を含む入力
// cin >> ws; でそこまでに入力ストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b >> c;

    int day = 0;
    int count = 0;
    while(count < c){
        count += a;
        day++;
        if(day % 7 == 0) count += b;
    }

    cout << day << endl;

    return 0;
}

/*
17D8101004B 日高 琉斗 Nishi3311 C++14

*/


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<1088;i++)
	{
		if((a*i)%b==c)
		{
			cout<<"YES"<<'\n';
			return 0;
		}
	}
	cout<<"NO"<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int Ai[N];
	int Bi[N];
	int Ci[N-1];
	int i,sum = 0;

	for(i = 0 ;i < N; i++){
		scanf("%d",&Ai[i]);
	}
	for(i = 0 ;i < N; i++){
		scanf("%d",&Bi[i]);
	}
	for(i = 0 ;i < N-1; i++){
		scanf("%d",&Ci[i]);
	}
	for(i = 0; i < N; i++){
		if(Ai[i+1] != Ai[i] + 1){
			sum += Bi[Ai[i]-1];
		}
		else if(Ai[i+1] == Ai[i] + 1){
			sum += (Bi[Ai[i]-1] + Ci[Ai[i]-1]);
		}
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = sc.nextInt();
            String[] s = new String[N];
            for(int i=0; i<N; i++) {
                s[i] = sc.next();
            }

            HashMap<String,Integer> map = new HashMap<>();

            int i = 0;

            for(String shouhin : s) {
               map.put(shouhin,i);
               i++;
            }
            System.out.println(map.size());
       } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 76132
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n,d;
    cin>>n>>d;
    ll c=0;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        if(d>=sqrt(pow(a,2)+pow(b,2))){
            c++;
        }
    }
    cout<<c;
}

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

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  	int c = 0;
  	string s, t;
  	cin >> s;
  	cin >> t;
  	for (int i = 0; i < 3; i++) {
      if (s[i] == t[i]) c++;
    }
  	cout << c << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(n=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## const ##
MOD=10**9+7
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    x = IS()
    stack = []
    for xi in x:
        if xi == 'S':
            stack.append(xi)
        elif xi == 'T':
            if not stack:
                stack.append(xi)
            elif stack[-1] == 'T':
                stack.append(xi)
            elif stack[-1] == 'S':
                stack.pop()
    print(len(stack))

if __name__ == '__main__':
    main()

Measured memory_bytes: 5732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1000000+5;
const ll mo=(ll)1e9+7;
ll dp[maxn];
ll h,w,a,b;
ll fac[maxn],inv[maxn];
ll extgcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1,y=0;
        return a;
    }else{
        ll tmp=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
        return tmp;
    }
}
ll rev(ll a){
    ll x,y;
    extgcd(a,mo,x,y);
    return (x+mo)%mo;
}
void pre()
{
    fac[0]=1;inv[0]=1;
    inv[1]=1;
    for(ll i=1;i<maxn;i++){
        fac[i]=((ll)fac[i-1]*(ll)i)%mo;
    }
    //printf("%lld\n",fac[maxn-1]);
    inv[maxn-1]=rev(fac[maxn-1]);
    /*for(int i=1;i<maxn;i++){
        printf("fac[%d]=%lld\n",i,fac[i]);
    }puts("");*/
    //printf("%lld\n",inv[maxn-1]);
    for(ll i=maxn-2;i>=1;i--) inv[i]=((ll)((ll)inv[i+1]*(i+1)))%mo;
    /*for(int i=1;i<maxn;i++){
        printf("inv[%d]=%lld\n",i,inv[i]);
    }puts("");*/
}
ll getnum(ll I,ll J)//C(I-1,I-1+J-1)
{
    ll n=I-1+J-1,m=I-1;
    //printf("n=%lld m=%lld\n",n,m);
    if(m==0) return 1ll;
    ll res=1;
    res=res*fac[n];
    res=((ll)((ll)res*(ll)inv[m]))%mo;
    res=((ll)((ll)res*(ll)inv[n-m]))%mo;
    return res;
}
int main()
{
    #ifdef nnnt
    freopen("1.out","w",stdout);
    #endif
    scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
    ll ans=0;
    pre();
    for(ll i=1;i<=h-a;i++)
        ans=(ans+(ll)((getnum(i,b)%mo)*(getnum(h-i+1,w-b)%mo))%mo)%mo;
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
int a,b,c;
cin >> a >> b >> c;
cout << max({a,b,c})*9 + a+b+c;
}
  


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 24 21:02:49 2019

@author: kato yugo
"""

m, d = map(int,input().split())

ans = 0

if d >= 22:
    for i in range(m):
        month = i+1
        for j in range(d):
            day = j+1
            day10 = int(day/10)
            day1 = day%10
            
            if day1 >= 2 and day10 >=2:
                if day10*day1 == month:
                    ans += 1
                    
                    
print(ans)
        
        

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in= new Scanner(System.in);
		int a=0,b=0,temp1,temp2,j;
		while((j=in.nextInt())!=0){
			a=0;b=0;
			for(int i=0;i<j;i++){
				temp1=in.nextInt();
				temp2=in.nextInt();
				if(temp1>temp2){
					a+=temp1+temp2;
				}
				else if(temp1==temp2){
					a+=temp1;b+=temp2;
				}
				else{
					b+=temp1+temp2;
				}
			}
			System.out.printf("%d %d\n",a,b);
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb std::ios::sync_with_stdio(false)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
/*** TEMPLATE CODE STARTS HERE ***/
int n;
int a[100500];
int main()
{
    scanf("%d",&n);
    repd(i,1,n)
    {
        scanf("%d",&a[i]);
    } 
    sort(a+1,a+1+n);
    int ans=0;
    repd(i,1,n)
    {
        if(a[i]&1)
        {
            ans^=(n-i+1);
        }else
        {

        }
    }
    if(ans==0)
    {
        printf("second\n" );
    }else
    {
        printf("first\n");
    }
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define Accepted return 0;
int a[310][310],b[310][310];
bool vis[310][310];
int main()
{
    int n,i,j,k;
    long long ans;
    bool gg;
    cin>>n;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
        {
            scanf("%d",&a[i][j]);
            b[i][j]=a[i][j];
        }
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            for(k=1;k<=n;k++)
                b[j][k]=min(b[j][k],b[j][i]+b[i][k]);
    gg=false;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if (a[i][j]!=b[i][j]) gg=true;
    if (gg)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            for(k=1;k<=n;k++)
            {
                if (i==j || j==k || k==i) continue;
                if (b[j][k]==b[j][i]+b[i][k]) vis[j][k]=true;
            }
    ans=0;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if (!vis[i][j]) ans+=b[i][j];
    ans/=2;
    cout<<ans<<endl;
    Accepted
}


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

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

using namespace std;

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

	int A, B, C,res; cin >> A >> B >> C;

	res = B / A;
	res = res > C ? C : res;
	cout << res << endl;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import static java.lang.System.*;

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

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    int p[] = new int[N];
    for(int i=0; i<N; i++) p[i] = sc.nextInt();
    int tmp = -1;
    boolean check = true;
    for(int i=0; i<N; i++){
      if(p[i] != i+1){
        if(tmp == -1) tmp = p[i];
        else{
          if(tmp != i+1) check = false;
        }
      }
    }
    if(check) out.println("YES");
    else out.println("NO");
  }
}

Measured memory_bytes: 22996
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<vector>


int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==1)a+=15;
    if(b==1)b+=15;
    if(a==b)printf("Draw");
    else if(a<b)printf("Bob");
    else printf("Alice");
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long ch(long long a,long long b)
{
  	long long ab = a % b;
  	if(ab==0)
	  	return b;
  	return ch(b,ab);
}
int main()
{
 	long long a,b,c,d,C,e;
	cin >> a >> b >> c >> d;
 	a--;
 	C=b-a;
  	C+=(a/c-b/c)+(a/d-b/d);
	if(c > d)
	{	
    	e = c*d/ch(c,d);
	}
	else
	{
    	e = c*d/ch(d,c);
	}
  	C -= (a/e - b/e);
  	cout << C;
  	return 0;
}

Measured memory_bytes: 256
import sys, math
from pprint import pprint
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

S = rs()

mods = []
n = 0
e = 1
for i in reversed(range(len(S))):
	n += int(S[i]) * e
	e = (e*10) % 2019
	n = n % 2019
	mods.append(n)
mods.append(0)
import collections
cnt = collections.Counter(mods)
ans = 0
for k, c in cnt.items():
	ans += c*(c-1)//2
print(ans)


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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    string s;
    cin >> s;

    if (s.size()==3) {
        reverse(s.begin(), s.end());
    }
    cout << s << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
    solve();
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int> > a(n, vector<int>(m));
    for(int i=0; i<m; i++) cin >> b[i];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    int ans = 0;
    int sum = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            sum += b[j]*a[i][j];
        }
        if(sum+c>0) ans++;
        sum = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int C=stdIn.nextInt();
		int X=stdIn.nextInt();
		int Y=stdIn.nextInt();
		int ans=0;
		if((A+B)*Math.min(X,Y)>=C*2*Math.min(X,Y)){
			ans+=C*2*Math.min(X,Y);
			if(X<Y){
				Y-=X;X=0;
			}
			else{
				X-=Y;Y=0;
			}
		}
		if(A*X>=C*2*X){
			ans+=C*2*X;
			Y-=X;X=0;
		}
		if(Y<0)
			Y=0;
		if(B*Y>=C*2*Y){
			ans+=C*2*Y;
			X-=Y;Y=0;
		}
		if(X<0)
			X=0;
		ans+=A*X;
		ans+=B*Y;
		System.out.println(ans);
	}
}


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

int n, x2, x1, pl, pr, sl, sr;
int x[101];
float p;

int main(){
    cin >> n;
    x1 = x2 = 0;
    for (int i = 0; i < n; ++i){
        cin >> x[i];
        x2 += x[i]*x[i];
        x1 += x[i];
    }
    p = static_cast<float>(x1)/n;
    pl = static_cast<int>(p);
    pr = pl + 1;
    sl = x2 - 2*pl*x1 + n*pl*pl;
    sr = x2 - 2*pr*x1 + n*pr*pr;
    cout << min(sl, sr);
}

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

void _main() {
    string S;
    cin >> S;
    int a = stoll(S.substr(0, 2));
    int b = stoll(S.substr(2, 2));
    bool f = (a >= 1 && a <= 12);
    bool g = (b >= 1 && b <= 12);
    if (f && g) cout << "AMBIGUOUS" << endl;
    else if (f) cout << "MMYY" << endl;
    else if (g) cout << "YYMM" << endl;
    else cout << "NA" << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
ans_i = -1
ans_j = -1
ans_k = -1
for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            ans_i = i
            ans_j = j
            ans_k = k

print(str(ans_i) + " " + str(ans_j) + " " + str(ans_k))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	string s; cin>>s;
	while(true){
		if(s.empty())break;
		string a,b,c;
		a.resize(5);
		b.resize(6);
		c.resize(7);
		int n=s.size();
		if(5>n){
			cout<<"NO"<<endl;
			return 0;
		}
		rep(i,0,5){
			a[i]=s[n-1-i];
		}
		reverse(all(a));
		if(a=="dream" || a=="erase"){
			rep(i,0,5)s.pop_back();
			continue;
		}
		if(n>5){
			rep(i,0,6){
				b[i]=s[n-1-i];
			}
		}
		reverse(all(b));
		if(b=="eraser"){
			rep(i,0,6)s.pop_back();
			continue;
		}
		if(n>6){
			rep(i,0,7){
				c[i]=s[n-1-i];
			}
		}
		reverse(all(c));
		if(c=="dreamer"){
			rep(i,0,7)s.pop_back();
		}
		else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

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

	int res = 0;

	if(N == 100000) res += 90000;
	else if(N >= 10000) res = N - 10000 + 1;

	if(N >= 1000) res += 900;
	else if(N >= 100) res = N - 100 + 1;

	if(N >= 10) res += 9;
	else res = N;
	
	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 256