akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 200001;

vector<int> tr[N];
int ans[N], de[2][N];

void dfs(int node, int p, int m1, int m2)
{
	if(node > m1)
	{
		m2 = m1;
		m1 = node;
	}
	for(int it : tr[node])
	{
		if(it != p)
		{
			dfs(it, node, m1, m2);
			if(it < m2)
				de[0][node] += de[0][it] + 1;
			if(it < m1)
				de[1][node] += de[1][it] + 1;
		}
	}
}

void solve(int node, int p, int c, int m)
{
	int f = 1, nm = m;
	if(node > m)
	{
		nm = node;
		f = 0;
	}
	ans[node] = c + de[f][node];
	for(int it : tr[node])
		if(it != p)
			solve(it, node, c + de[f][node] - (it < m ? de[f][it] : -1), nm);
}


int main()
{
	fio;
	int n;
	cin >> n;
	for(int i=1; i<n; i++)
	{
		int u, v;
		cin >> u >> v;
		tr[u].pb(v);
		tr[v].pb(u);
	}
	dfs(1, 0, 0, 0);
	solve(1, 0, 0, 0);
	for(int i=2; i<=n; i++)
		cout << ans[i] << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 29824
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, count;
    count = 0;
    long long H, W;
    cin >> N >> H >> W;
    long long A[N], B[N];
    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i];
    }
    for(int i=0;i<N;i++){
        if(A[i] >= H){
            if(B[i] >= W) count++;
        }
    }
    cout << count << "\n";
    return 0;
}


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

if sum(a) < sum(b): print(-1)
else:
    d = [j - i for i, j in zip(a, b)]
    d.sort()
    p = 0
    cnt = 0
    for i in d:
        if i > 0: 
            p += i
            cnt += 1
    idx = 0
    while p > 0:
        p += d[idx]
        idx += 1
        cnt += 1
    print(cnt)

Measured memory_bytes: 18356
#include<iostream>
#include<map>
#include<algorithm>
#include<cassert>
#include<vector>
#include<cstring>
using namespace std;

int dp[1000], catsum[20010];
vector<pair< int, int > > cats;
vector<int> foods;
int N,M,lmost;

bool isable(int mid) {
    memset(dp, -1, sizeof(dp));
    dp[M-1] = 0;

    for(int i=M-2; i>=0; --i) {
        int ret = 1<<29;
        for(int j=i+1; j<M; ++j) {
            int right = catsum[foods[j]] - catsum[(foods[i]+foods[j])/2];;
            int left = catsum[(foods[i]+foods[j])/2] - catsum[foods[i]];

            if(right + dp[j] <= mid) ret = min(left, ret);
        }
        dp[i] = ret;
    }
    if(dp[0] + catsum[foods[0]] <= mid) return true;
    return false;
}

int main() {
    int x,y,c,totalcats = 0;
    while(cin>>N>>M, N|M) {

        memset(catsum, 0, sizeof(catsum));
        foods.clear();
        cats.clear();
        totalcats = 0;

        for(int i=0; i<N; ++i) {
            cin>>x>>y>>c;
            x += 10000;
            totalcats += c;
            cats.push_back(make_pair(x,c));
        }

        for(int i=0; i<M; ++i) {
            cin>>c;
            foods.push_back(c+10000);
        }

/*
        if(M == 1) {
            cout<<totalcats<<endl;
            continue;
        }
*/

        sort(cats.begin(), cats.end());
        sort(foods.begin(), foods.end());

        for(int i=0; i<N; ++i) {
            if(cats[i].first <= foods[0]) cats[i].first = foods[0];
            if(cats[i].first >= foods[M-1]) cats[i].first = foods[M-1];
            catsum[cats[i].first] += cats[i].second;
        }

        for(int i=0,ss = 0; i<20010; ++i) {
            ss += catsum[i];
            catsum[i] = ss;
        }

        int low = -1,hi = totalcats;
        while(low+1<hi) {
            int mid = (low+hi)/2;
            if(isable(mid)) hi = mid;
            else low = mid;
        }
        cout<<hi<<endl;
    }
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

int N;
cin >> N;
vi A(N);
rep(i,N) cin >> A[i];

// l[i]:= A[i]を抜いたときの左側のGCD
// l[0]は使わないから何でもいい
// for回しやすいようにl[0] = A[0]とする
vi l(N,A[0]);
for(int i = 0; i < N-1; ++i) {
    l[i+1] = gcd(l[i],A[i]);
}

// r[i]:= A[i]を抜いたときの右側のGCD
vi r(N,A[N-1]);
for(int i = N-1; i > 0; --i) {
    r[i-1] = gcd(r[i],A[i]);
}

int ans = 1;
rep(i,N) {
    if(i == 0) {
        ans = max(ans,r[0]);
        continue;
    }
    if(i == N-1) {
        ans = max(ans,l[N-1]);
        break;
    }
    ans = max(ans,gcd(l[i], r[i]));
}
cout << ans << endl;

return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>

using namespace std;

int fact(long long int n){
    int m;
    if (n == 0)
    return 1;
    m = fact(n - 1);
    return (n%1000000007)*(m%1000000007)%1000000007;
}

int main(){

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

    if(abs(a-b)>1){
        cout<<0<<endl;
        return 0;
    }
    long long int x=fact(a);
    long long int y=fact(b);

    // cout<<fact(a)*fact(b)%1000000007*2%1000000007<<endl;
    // cout<<(x*y)%1000000007<<endl;
    // cout<<x*y<<endl;
    if(a==b){
        cout<<(x*y*2)%1000000007<<endl;
        // cout<<x*y<<endl;
        // cout<<(long long)x*y%1000000007*2%1000000007<<endl;
    }else{
        // cout<<(x*y)%1000000007<<endl;
        cout<<(x%1000000007)*(y%1000000007)%1000000007<<endl;
    }
    





    
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#define PI acos(-1.0)
#define LL long long
#define MAX 0x3fffffff
using namespace std;

int h, n, k;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> h >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> k;
		sum += k;
	}
	if (sum >= h)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  vector<tuple<ll, ll, ll>> point(n);
  rep(i, n) {
    cin >> a[i] >> b[i];
  }
  rep(i, n) {
    ll t = a[i] + b[i];
    point[i] = tie(t, a[i], b[i]);
  }
  sort(point.rbegin(), point.rend());
  ll takahashi = 0, aoki = 0;
  rep(i, n) {
    int x, y, z;
    tie(x, y, z) = point[i];
    if(i % 2) aoki += z;
    else takahashi += y;
  }
  cout << takahashi - aoki << endl;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 1005;

int main() {

	FAST;

	string s;
	cin >> s;
	cout << ((s == "ARC") ? "ABC" : "ARC") << '\n';	
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> n;
  n++;
  l = 0;
  while(n > 9){
    l += 9;
    n /= 10;
  }
  print(l+n-1);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x, p1,p2 ;
    cin>>x;
    int Arr[x];
    for(int i=0; i<x; i++)
    {
        cin>>Arr[i];
    }
    bool f=false;
    int count =0;
    for(int i=0; i<(x-1); i++)
    {
        if(Arr[i]<Arr[i+1])
            continue;
        else if(Arr[i]>Arr[i+1])
        {
            if(count==0)
                p1=i;
            else
                p2=i+1;
            f=true;
            count++;
        }
    }



    if(!f)
        cout<<"YES";

    else
    {
        if(count<=2)
        {
            if(count==1)
                p2=x-1;
            swap(Arr[p1],Arr[p2]);

              if(Arr[p1]<Arr[p1+1] &&  Arr[p2]>Arr[p2-1])
                cout<<"YES";
              else
                cout<<"NO";

         }

        else
            cout<<"NO"<<endl;

    }

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

const int C = 1e5+5;
// const ll M = 1000000007;

int N, M;
int K[100010];
vector<int> L[100010];

vector<int> V[200010];

int main () {
  cin >> N >> M;
  for (auto i = 0; i < N; ++i) {
    cin >> K[i];
    for (auto j = 0; j < K[i]; ++j) {
      int l;
      cin >> l;
      L[i].push_back(l);
      V[i].push_back(l+C);
      V[l+C].push_back(i);
    }
  }
  bool visited[200010];
  fill(visited, visited+200010, false);
  stack<int> S;
  S.push(0);
  while (!S.empty()) {
    int src = S.top();
    S.pop();
    if (!visited[src]) {
      visited[src] = true;
      for (auto x : V[src]) {
        if (!visited[x]) {
          S.push(x);
        }
      }
    }
  }
  for (auto i = 0; i < N; ++i) {
    if (!visited[i]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n;
LL h[N];
LL a, b;

bool check(LL x)
{
	LL cnt = 0;
	for (int i = 1; i <= n; i ++ )
		cnt += max(0LL, (h[i] - x * b + a - b - 1) / (a - b));
	return cnt <= x;
}

int main()
{
	scanf("%d%lld%lld", &n, &a, &b);
	for (int i = 1; i <= n; i ++ ) scanf("%lld", &h[i]);
	
	LL l = 0, r = 1e9;
	while (l < r)
	{
		LL mid = l + r >> 1;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	
	printf("%lld\n", r);
	return 0;
}

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

int main(){
    string S,T;
    cin >> S >> T;
    int cnt = 0;
    for (int i=0; i < S.size(); i++){
        if (S.at(i) != T.at(i)){
            cnt += 1;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3828
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(A: int, B: int, C: int):
    ret = NO
    for i in range(1, 1001):
        if (A * i) % B == C:
            ret = YES
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


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

using namespace std;

char s[10];
int ans;

int main() {
    scanf("%s", s);
    for (int i = 0,j; i < 3; i = j + 1) {
        j = i;
        while (j < 3 && s[j] == 'R')
            j++;
        ans = max(ans, j - i);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,n,m,r,d;
    cin>>a>>b>>c;
    a=abs(a);
    if(a/c>=b)
        cout<<a-b*c<<endl;
    else{
        b-=a/c;
        if(b%2==0)cout<<a%c<<endl;
        else cout<<c-(a%c)<<endl;
    }

}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    int n;
    cin>>n;
    vll v(n),csum;
    vector<bool> b(n,false);
    rep(i,n)cin>>v[i];
    Sort(v);

    csum.push_back(0);
    rep(i,n){
        csum.push_back(csum[i]+v[i]);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        // cout<<csum[i]*2<<" "<<v[n-1]<<endl;
        if(csum[i]*2>=v[n-1]){
            b[n-1]=true;
        }
    } 
    for(int i=n-1;i>=0;i--){
        if(!b[i]){
            if(csum[i+1]*2>=v[i+1]&&b[i+1]){
                b[i]=true;
            }
        }
    }
    rep(i,n)if(b[i])ans++;
    fin(ans);
    // rep(i,csum.size()){
    //     cout<<csum[i]<<" ";
    // }
    // cout<<endl;
    // rep(i,v.size()){
    //     cout<<v[i]<<" ";
    // }
    // cout<<endl;
    // rep(i,b.size()){
    //     cout<<b[i]<<" ";
    // }
    // cout<<endl;


//////////////////////////////////////////////////////
return 0;}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    string s1=s.substr(0,2),s2=s.substr(2,2);
	int zero='0';
	int n=((int)s1[0]-zero)*10+((int)s1[1]-zero);
	int m=((int)s2[0]-zero)*10+((int)s2[1]-zero);
//cout<<n<<endl<<m<<endl;
	if((n<=12 && n>=1) && (m<=12 && m>=1))cout<<"AMBIGUOUS";
	else if((!(n<=12 && n>=1) && !(m<=12 && m>=1)))cout<<"NA";
	else if(n<=12 && n>=1)cout<<"MMYY";
	else if(m<=12 && m>=1)cout<<"YYMM";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    //処理
    //出力
    cout << min(a,b)+min(c,d) << ENT;
    return 0;
}

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


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int N;
int V[111];
int C[111];
int ans = 0;

void dfs(int idx, int val, int wei) {
  if (idx >= N) {
    chmax(ans, val - wei);
    return;
  }
  dfs(idx+1, val+V[idx], wei+C[idx]);
  dfs(idx+1, val, wei);
}

signed main() {
  cin >> N;
  rep (i, N) {
    cin >> V[i];
  }
  rep (i, N) {
    cin >> C[i];
  }

  dfs(0, 0, 0);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)


//template functions
/////////////////////////
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

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


//Answer


int main() {

string S;
cin>>S;
if(S=="SSS"){
cout<<0<<endl;
}else if(S=="RRR"){
cout<<3<<endl;
}else if(S=="RRS"||S=="SRR"){
cout<<2<<endl;
}else{
cout<<1<<endl;
} 


}







//高精度要求→しつこくlong doubleでcast　出力はprintf("20.20Lf")とかで
//printf("%a.bLf")のとき、a-b-1が整数部分の桁数。
/*配列系の書き方
long N;
cin>>N;
vector<long> p(N);
for(long i=0;i<N;i++){
cin>>p.at(i);
}

vector<int> d(102,1);

sort(A.begin(),A.end());
reverse(A.begin(),A.end());

typedef pair<long,long> P;
vector<P> p(N);

vector<vector<int>> A(N,vector<int>(M));

int a='A'+2;
cout<<a<<endl;　//a=67 文字は整数型に代入して文字コード化できる。

  char c=65;
cout<<c<<endl;  //c='A' 整数は文字型に代入してその整数が文字コードとしてあらわす整数にできる。

*/

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int n,ans;
int a[10],b[10];
void dfs(int v,bool s,bool f,bool t,bool l){
	if (v>n){
		if (s&&f&&t) ans++;
	 return;
	}
	if ((3<=a[v])||l) b[v]=3,dfs(v+1,s,f,1,((3<a[v])|l));
	if ((5<=a[v])||l) b[v]=5,dfs(v+1,s,1,t,((5<a[v])|l));
	if ((7<=a[v])||l) b[v]=7,dfs(v+1,1,f,t,((7<a[v])|l));
}
int main(){
	char x;
	while(cin>>x)
	a[++n]=x-'0';
	dfs(1,0,0,0,0);
	for (int i=1;i<=n;++i) a[i]=9;
	for (n-=1;n>=3;n--)
	dfs(1,0,0,0,0);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
A,B,K=map(int,input().split())
COUNT = 0

while True :

    if A % 2 == 1 :

        A -= 1

    A = A//2

    B += A

    COUNT += 1

    if COUNT == K :

        break
    

    if B % 2 == 1 :

        B -= 1

    B = B//2

    A += B

    COUNT += 1

    if COUNT == K :

        break

print(A,B)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    if (s == "keyence") {
        cout << "YES" << endl;
        return 0;
    }
    rep(i, len(s)) {
        reps(j, i + 1, len(s)) {
            string st = s.substr(0, i);
            string en = s.substr(j);
            string ss = st + en;
            if (ss == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

//---- Small, Large, or Equal
int main(void)
{
    int a, b;
    cin >> a >> b;
    if(a < b)
        cout << "a < b" << endl;
    else if (a > b)
        cout << "a > b" << endl;
    else
        cout << "a == b" << endl;
}

Measured memory_bytes: 3080
#include <stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int i, j, k;
  int n1 = mid -left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i=0, j=0;
  for(k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  int mid;
  if(left+1 < right) {
    mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);

  return 0;
}


Measured memory_bytes: 5636
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n, m, x = MAP()
arr = [LIST() for _ in range(n)]
c = [arr[i][0] for i in range(n)]
a = [arr[i][1:] for i in range(n)]

ans = inf
for i in range(1, n + 1):
    cmb = list(combinations(range(n), i))
    for lst in cmb:
        tmp = [0 for _ in range(m)]
        cst = 0
        for idx in lst:
            cst += c[idx]
            for j in range(m):
                tmp[j] += a[idx][j]
        flag = True
        for j in range(m):
            if tmp[j] < x:
                flag = False
        if flag:
            ans = min(ans, cst)
if ans == inf:
    print(-1)
else:
    print(ans)

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll N; cin >> N;
    vector<PLL> X(N);
    REP(i,N){
        ll A; cin >> A;
        X[i] = MP(A,i);
    }

    static ll dp[2002][2002] = {};
    REP(i,N){
        REP(j,N){
            dp[i][j] = -1;
        }
    }

    sort(ALL(X));
    reverse(ALL(X));

    dp[0][0] = 0;
    REP(l,N){
        REP(r,N){
            if (l + r >= N) continue;
            int index = l + r;
            ll A = X[index].first;
            ll d = X[index].second;
            chmax(dp[l+1][r],dp[l][r] + A * abs(l-d));
            chmax(dp[l][r+1],dp[l][r] + A * abs(d-(N - r - 1)));
        }
    }

    ll ans = -1;
    REP(k,N+1){
        //DB2(k,dp[k][N-k]);
        chmax(ans,dp[k][N-k]);
    }

    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define dbg(S) { int f=1; for(auto x:S) cerr<<(f?"[":", ")<<x, f=0; cerr<<"]\n"; }

using namespace std;
using lint=long long;

const lint INF=1LL<<61;

template<class T>
class segment_tree{
	static const int N_MAX=1e5+10;
	int n;
	T dat[4*N_MAX];

	T query(int l,int r,int a,int b,int u){
		if(l<=a && b<=r) return dat[u];

		T res=INF;
		int c=(a+b+1)/2;
		if(l<c && a<r) res=min(res,query(l,r,a,c,2*u));
		if(l<b && c<r) res=min(res,query(l,r,c,b,2*u+1));
		return res;
	}

public:
	void build(int N,T val){
		for(n=1;n<N;n*=2);
		rep(u,2*n) dat[u]=val;
	}

	void update(int u,T v){
		u+=n;
		dat[u]=min(dat[u],v);
		for(u/=2;u>=1;u/=2) dat[u]=min(dat[2*u],dat[2*u+1]);
	}

	T query(int l,int r){ return query(l,r,0,n,1); }
};

struct interval{
	int l,r;
	lint wt;
	bool operator<(const interval& I)const{ return r<I.r; }
};

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<interval> I(m);
	rep(i,m){
		scanf("%d%d%lld",&I[i].l,&I[i].r,&I[i].wt);
		I[i].l--;
	}

	sort(I.begin(),I.end());

	segment_tree<lint> S;
	S.build(n,INF);
	S.update(0,0);
	rep(i,m){
		lint d=S.query(I[i].l,I[i].r);
		S.update(I[i].r-1,d+I[i].wt);
	}

	lint ans=S.query(n-1,n);
	printf("%lld\n",ans<INF?ans:-1);

	return 0;
}


Measured memory_bytes: 4736
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] arg) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        scan.nextLine();
        List<String> list = new ArrayList<>();
        for(int i=0; i<n; i++) {
            list.add(scan.nextLine());
        }

        Map<String, Long> map = list.stream().collect(Collectors.groupingBy(n2 -> n2,Collectors.counting()));

        Map<Long, List<String>> outMap = new HashMap<>();
        map.forEach((key,value) -> {
            List<String> sList = outMap.get(value);
            if(sList == null) {
                sList = new ArrayList<>();
                outMap.put(value,sList);
            }
            sList.add(key);
        });
        Object[] mapKey = outMap.keySet().toArray();
        Arrays.sort(mapKey, Collections.reverseOrder());

        outMap.get(mapKey[0]).stream().sorted().forEach(value -> {
            System.out.println(value);
        });
    }
}


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

typedef long long LL;

using namespace std;
LL M = 1000000007;
LL pow(LL a,LL b,LL m){
    if(b==0){
        return 1;
    }
    else if (b%2 ==0 ){
        LL y = pow(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return (a*pow(a,b-1,m))%m;
    }

}


int main()
{
    LL N;
    cin>>N;
    LL arr[N], check[N], sorted[N];
    for(int i=0; i<N; i++){
        cin>>arr[i];
        sorted[i] = arr[i];
    }
    sort(sorted, sorted +N);
    for(int i=0; i<N; i++){
        LL counter = 0;
        for(int j=0; j<N; j++){
            if(j<i && arr[j] <= arr[i])
                counter++;
            if(j>i && arr[j] < arr[i])
                counter++;
        }
        check[i] = counter;
    }

    LL dp[N][N + 1];
    for(int i=0; i<N; i++){
        for(int j=0; j<N + 1; j++){
            dp[i][j] = 0;
        }
    }


    for(int i=1; i<=check[0] + 1; i++){
        dp[0][i] = (pow(2, sorted[check[0]] - sorted[i - 1], M)*2)%M;
    }
    dp[0][0] = (pow(2, sorted[check[0]], M)%M);


    for(int i=1; i<N; i++){
       if( check[i] > check[i-1]){
            for(int j=0; j <= check[i -1] + 1; j++){
                dp[i][j] += (dp[i-1][j]* pow(2, sorted[check[i]] - sorted[check[i-1]], M))%M;
                dp[i][j] += (dp[i-1][check[i-1] + 1] * pow(2, sorted[check[i]] - sorted[check[i-1]], M))%M;
                dp[i][j] = dp[i][j]%M;
            }
            for(int j = check[i-1] + 2; j <= check[i] + 1; j++){
                dp[i][j] += (dp[i-1][check[i-1] + 1] * 2 * pow(2, sorted[check[i]] - sorted[j-1], M))%M;
                dp[i][j] = dp[i][j]%M;
            }

       }
       else{
            for(int j=0; j<=check[i] + 1; j++){
                dp[i][j] += dp[i-1][j];
                dp[i][j] += dp[i-1][check[i] + 1];
                dp[i][j] = dp[i][j]%M;
            }
       }
    }
    cout<<dp[N-1][0]<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // Atcoder
    // template: cpp
    string n;
    cin >> n;
    if(n.at(0) == '7' || n.at(1) == '7' || n.at(2) == '7')
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3588
#include"iostream"
#include"stdio.h"
#include"cmath"
#include"algorithm"

#define MAXN 1000050
using namespace std;

long long A[MAXN];

int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    bool flag = false;
    if(abs(a - c) <= d) flag = true;
    if(abs(a - b) <= d && abs(b - c) <= d) flag = true;
    if(flag) cout << "Yes"<< endl;
    else cout << "No"<< endl;
    return 0;
}

Measured memory_bytes: 256
N, A = map(int, input().split())
x = list(map(int, input().split()))
maxX = max(max(x), A)
dp = [[[0 for _ in range(N * maxX + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1
for i in range(N):
    for j in range(N + 1):
        for k in range(N * A + 1):
            if dp[i][j][k] == 0: continue
            dp[i + 1][j][k] += dp[i][j][k]
            dp[i + 1][j + 1][k + x[i]] += dp[i][j][k]

ans = 0
for i in range(1, N + 1):
    ans += dp[N][i][A * i]
print(ans)

Measured memory_bytes: 127496
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int a, b;
    string _b;
    cin >> a >> _b, b = stoi(_b.substr(0, 1))*100 + stoi(_b.substr(2));
    cout << a*b / 100 << "\n";
    
    return 0;
}

Measured memory_bytes: 3644
def get_divisors(n):
    divisors = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            divisors.add(i)
            divisors.add(n // i)
        i += 1
    return divisors

n, k = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
divisor = list(get_divisors(s))
divisor.sort(reverse=True)
for d in divisor:
    r = list(map(lambda x : x % d, a))
    r.sort()
    left = r[:]
    right = [0] * n
    right[-1] = r[-1] - d
    for i in range(1, n):
        left[i] += left[i - 1]
        right[n-i-1] = right[n-i] + r[n-i-1] - d
    for i in range(n-1):
        if left[i] == -right[i+1] and left[i] <= k:
            print(d)
            quit()
print(1)



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

#define int long long
#define INF 1e18

signed main() {
    int n; cin >> n;
    double ans = 0;

    for(int i = 0; i < n; i++) {
        double x; cin >> x;
        double rate = 380000.0;
        string s; cin >> s;
        if(s == "JPY") ans += x;
        else ans += x * rate;
    }

    cout << ans << endl;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

const int N = 2000 + 10;
const lli inf = 1LL << 50;

int main(int argc, char *argv[])
{
  int n, x;
  while (cin >> n >> x) {
    lli a[n];
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }

    lli dp[n];
    for (int i = 0; i < n; ++i) {
      dp[i] = a[i];
    }

    lli mn = inf;
    for (lli ench = 0; ench <= 2 * n; ++ench) {
      for (int slime = 0; slime < n; ++slime) {
        const int i = (slime - ench + n * 10) % n;
        dp[slime] = min(dp[slime], a[i]);
      }
      mn = min(mn, accumulate(dp, dp + n, 0LL) + ench * x);
    }
    
    cout << mn << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

li = [0] * n
# print(s[0:2])
for i in range(n - 1):
  if s[i:i + 2] == "AC":
    li[i+1] += li[i] + 1
  else:
    li[i+1] = li[i]
# print(li)
for j in lr:
  print(li[j[1]-1] - li[j[0]-1])

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

int main() {
	int a, b;
	cin >> a;
	cin >> b;
	
	if(a < b) {
		cout << "a < b" << endl;
	}
	else if(a > b) {
		cout << "a > b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A - B == B - C)cout << "YES" << endl;
    else     cout << "NO" << endl; 
}

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

N = int(input())
A = list(map(int, input().split()))

sum_N = N * (N + 1) // 2
sum_A = sum(A)

if sum_A % sum_N != 0:
    print("NO")
    exit()
else:
    k = sum_A // sum_N

B = []
for i in range(N):
    if i + 1 != N:
        B.append(A[i + 1] - A[i] - k)
    else:
        B.append(A[0] - A[i] - k)

cnt = 0
for b in B:
    if b % N == 0 and b <= 0:
        k += b // N 
    else:
        print("NO")
        exit()

if k == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 56944
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
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; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
#define vecP vector<P>
// cout << setprecision(15) << std::fixed;


int main() {
	int h, w,n,cut=0;
	cin >> h >> w>>n;
	for (int i = 1;i <= min(h, w);i++) {
		cut += max(h, w);
		if (cut >= n) {
			print(i);
			exit(0);
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char s[16];
	int x,y,i,j,k,m,b[16] = {0},p[16],w[16] = {0};
	while(scanf("%s",s) != EOF){
		for(i = 0;i <= 15;i++){
			w[i] = 0;
			b[i] = 0;
		}
		for(i = 0;i <= 12;i++) b[s[i] - 48]++;
		x = 0;
		for(i = 1;i <= 9;i++){
			if(b[i] >= 4) continue;
			b[i]++;
			y = 0;
			for(j = 1;j <= 9;j++){
				if(b[j] < 2) continue;
				m = 0;
				for(k = 0;k <= 15;k++) p[k] = b[k];
				p[j]-=2;
				k = 1;
				while(k <= 9){
					if(p[k] == 0){
						k++;
						continue;
					}
					if(p[k] >= 3){
						p[k]-=3;
						m++;
						continue;
					}
					if((k <= 7) && (p[k+1] != 0) && (p[k+2] != 0)){
						p[k]--;
						p[k+1]--;
						p[k+2]--;
						m++;
						continue;
					}
					else{
						k++;
					}
				}
				if(m == 4){
					y = 1;
					break;
				}
			}
			if(y){
				w[x] = i;
				x++;
			}
			b[i]--;
		}
		if(x){
			for(i=0;i<x;i++){
				if(i == (x - 1)) printf("%d",w[i]);
				else printf("%d ",w[i]);
			}
			printf("\n");
		}
		else printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 556
l=[int(input()) for i in range(5)]
k=int(input())
f=0
for i in range(5):
  if f>0:
    break
  for j in range(i,5):
    if abs(l[i]-l[j])>k:
      f+=1
      break
if f==0:
  print("Yay!")
else:
  print(":(")

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

int main()
{
    char s[53];
    int n, a[27], b[27];
    scanf("%d",&n);
    memset(b, 0x3f, sizeof(b));
    while(n--)
    {
        scanf("%s",s);
        memset(a, 0, sizeof(a));
        for(int i=0; s[i]; ++i)
            ++a[s[i]-'a'];
        for(int i=0; i<26; ++i)
            b[i] = min(b[i], a[i]);
    }
    for(int i=0; i<26; ++i)
        for(int j=0; j<b[i]; ++j)
            printf("%c",i+'a');
    puts("");
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	double a[102];
	double sum;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum=sum+1/a[i];
	}
	cout<<1/sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>

#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    string str;
    int arr[26]={};
    
    while(getline(cin,str)){
        if(cin.eof())
            break;
        
        for(int i=0;i!=str.size();++i){
            if(str[i]>='A'&&str[i]<='Z'){
                int num=str[i]-'A';
                arr[num]+=1;
            }else if(str[i]>='a'&&str[i]<='z'){
                int num=str[i]-'a';
                arr[num]+=1;
            }
        }
    }
    
    for(char a='a';a!='z'+1;++a){
        int i=a-'a';
        cout<<a<<" : "<<arr[i]<<endl;
    }
    
    
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b});

    





}

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

int main(){
   char k[100];
   int s;
   char t[100];
   scanf("%d",&s);
   scanf("%s",k);
   if(strlen(k)<=s){
      printf("%s",k);
   }else{
      strncpy(t,k,s);
      t[s]='\0';
      printf("%s...",t);
   }
   return 0;
}


Measured memory_bytes: 1732
#include <iostream>

int main()
{
    using namespace std;

    int a[3];
    int tmp;

    cin >> a[0] >> a[1] >> a[2];

    while (1)
    {
        for (int i = 0; i < 2; i++)
        {
            if (a[i] > a[i + 1])
            {
                tmp = a[i];
                a[i] = a[i + 1];
                a[i+1] = tmp;
            }
        }
        if(a[0] <= a[1] && a[1] <= a[2]){
            break;
        }
    }

    cout << a[0] << " " << a[1] << " " << a[2] << endl;
}


Measured memory_bytes: 3064
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000

using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  vector<ll> a(N); REP(i, N) cin >> a[i];
  ll x = 0, y = 0;
  REP(i, N) y += a[i];

  ll ans = LLINF;
  REP(i, N - 1) {
    x += a[i];
    y -= a[i];
    ans = min(ans, abs(x - y));
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair

int n;
int a[100];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int sum = 0;
    for(int i = 0; i < n; i++) sum += a[i];
    if(sum % 10 != 0) cout << sum << endl;
    else{
        int mn = 10000;
        for(int i = 0; i < n; i++){
            if(a[i] % 10 != 0) mn = min(mn, a[i]);
        }
        if(mn == 10000) cout << 0 << endl;
        else cout << sum - mn << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
if len(S) != N: raise

lcost = [0] * N  # lcost[i]はS[:i]中の'W'の個数
rcost = [0] * N  # rcost[i]はS[i+1:]中の'E'の個数
for i in range(N - 1):
    lcost[i + 1] = lcost[i] + (1 if S[i] == 'W' else 0)
for i in range(N - 1, 0, -1):
    rcost[i - 1] = rcost[i] + (1 if S[i] == 'E' else 0)

print(min(p[0] + p[1] for p in zip(lcost, rcost)))

Measured memory_bytes: 27044
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] t = new int[n];
			IntStream.range(0, n).forEach(i -> t[i] = scanner.nextInt());
			int m = scanner.nextInt();
			int[] p = new int[m], x = new int[m];
			IntStream.range(0, m).forEach(i -> {
				p[i] = scanner.nextInt() - 1;
				x[i] = scanner.nextInt();
			});
			int sum = Arrays.stream(t).sum();
			IntStream.range(0, m).map(i -> sum - t[p[i]] + x[i]).forEach(System.out::println);
		}
	}
}


Measured memory_bytes: 26964
package main

import "fmt"
import "math"

func main() {
  var a, b int
  fmt.Scanf("%d %d", &a, &b)
  //x := 10
  //a = x * 0.08
  //b = x * 0.1
  xa := float64(a)*12.5 // 0.08=8/100 (a*100/8=a*25/2, (2a+1)*25/2=a*25+0.5)
  xb := float64(b)*10.0 // 0.1=1/10 (b*10)
  ya := int(math.Trunc(xa+0.5))
  yb := b*10
  if ya < yb {
    if xb >= math.Trunc(xa + 12.5) {
      fmt.Println("-1")
    } else {
      fmt.Println(yb)
    }
  } else { // ya > yb
    if ya >= yb+10 {
      fmt.Println("-1")
    } else {
      fmt.Println(ya)
    }
  }
}


Measured memory_bytes: 512