akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2") 
#pragma GCC optimization ("unroll-loops")

using namespace std;
using ll = long long;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define Ceil(x, y) ((x+y-1)/y)
#define PI acos(-1)
const int mod = (int) 1000000007;
const int N = 3e5 + 10;
vector<int> h(N), w(N), cntH(N), cntW(N);
map<int, bool> M[N];
void solve()
{
    int H, W, m;
    cin>>H>>W>>m;
    for(int i=0; i<m; i++)
    {
        cin>>h[i]>>w[i];
        cntH[h[i]]++, cntW[w[i]]++;
        M[h[i]][w[i]] = true;
    }
    int maxh = 0, maxw = 0;
    for(int i=0; i<N; i++)
    {
        maxh = max(maxh, cntH[i]);
        maxw = max(maxw, cntW[i]);
    }
    vector<int> mxH, mxW;
    for(int i=0; i<N; i++)
    {
        if(cntH[i] == maxh)
            mxH.push_back(i);
        if(cntW[i] == maxw)
            mxW.push_back(i);
    }
    int ans = 0;
    for(int i=0; i<mxH.size(); i++)
    {
        for(int j=0; j<mxW.size(); j++)
        {
            ans = max(ans, maxh+maxw - M[mxH[i]][mxW[j]]);
            if(ans == maxh+maxw)
                break;
        }
        if(ans == maxh+maxw)
            break;
    }
    cout<<ans;
}
 

int main(int argc, char *argv[])
{
    clock_t clk_start = clock();
    fast;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    int cases = 1;
    // cin>>cases;
    for(int i=1; i<=cases; i++)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr<<"Execution Time: "<<fixed<<double(clock() - clk_start)/double(CLOCKS_PER_SEC)<<setprecision(6)<<" sec\n"; 
}


Measured memory_bytes: 39208
#!/usr/bin/env python3


n = int(input())
num = [int(x) for x in input().split()]

test = []

for i in num:
    if i % 2 != 0:
        test.append(True)
    elif i % 2 == 0 and i % 3 == 0:
        test.append(True)
    elif i % 2 == 0 and i % 5 == 0:
        test.append(True)
    else:
        test.append(False)

if all(test):
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
LL n, m, cmp = 0;
vector<int> e[200005];
bool v[200005];

void dfs(int g){
	v[g] = 1; cmp++;
	for(auto u : e[g]){
		if(!v[u]) dfs(u);
	}
}

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

	cin >> n >> m;
	FOR(i, m){
		int t1, t2;
		cin >> t1 >> t2;
		e[t1].pb(t2);
		e[t2].pb(t1);
	}

	LL ans = 0;
	FOR(i, n){
		if(v[i]) continue;
		cmp = 0;
		dfs(i);
		ans = max(ans, cmp);
	}

	cout << ans << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 20932
function Main(input) {

    var tmp = input.split(' ');

    var a = parseInt(tmp[0], 10);
    var b = parseInt(tmp[1], 10);

    var sum = a * b;
    if ((sum % 2) === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
   	cout << "vowel" << endl; 
  }else
    cout << "consonant" << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>

int main(void) {
    u_int n;
    std::string event;

    std::cin >> n;
    for (u_int i = 0; i < n; ++i) {
        std::bitset<4> runner;
        u_int out = 0, score = 0;

        do {
            std::cin >> event;
            if ("HIT" == event) {
                runner <<= 1;   // 走者を1つずつ進める
                runner.set(0);  // 一塁に走者を置く
                if (runner.test(3)) { // ホームインしたかどうか
                    ++score;
                    runner.reset(3);
                }
            } else if ("HOMERUN" == event) {
                score += runner.count() + 1;
                runner.reset(); // 走者をリセット
            } else if ("OUT" == event) {
                ++out;
            }
        } while (out != 3);

        std::cout << score << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1208
n, m = map(int, input().split())
i = 0
j = n + 1

for k in range(m):
  ti, tj = map(int, input().split())
  if ti > i:
    i = ti
  if tj < j:
    j = tj

if j == 0 and i == 0:
  print(0)
else:
  print(max(j - i + 1, 0))

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

typedef multimap< int, pair<int, int> > HL;

int main() {
  int n, m, a;
  int h, p, q;

  while (cin >> n >> m >> a, n && m && a) {
    set<int> hs;
    multimap<int, pair<int, int>> hl;

    rep (i, m) {
      cin >> h >> p >> q;
      hs.insert(h);
      hl.insert(make_pair(h, make_pair(p, q)));
    }

    int ans = a;
    for (set<int>::reverse_iterator sit=hs.rbegin(); sit!=hs.rend(); sit++) {
      int hhead = *sit;

      for (multimap<int, pair<int, int>>::iterator it = hl.lower_bound(hhead); it != hl.upper_bound(hhead); it++) {
        // ????????¢????????????????????¨???????????????
        // pair<int, int> v = it.second;
        // pair<int, int> v = (*it).second;

        pair<int, int> v = it->second;
        if (v.first == ans) {
          ans = v.second;
          break;
        }
        else if (v.second == ans ) {
          ans = v.first;
          break;
        }
      }
    }

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

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

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

    int n;
    cin >> n;

    multiset<int> st;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        auto it = st.lower_bound(a);
        if (it == st.begin()) {
            st.insert(a);
        } else {
            it--;
            st.erase(it);
            st.insert(a);
        }
    }

    cout << st.size() << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,W,Z,answer=0;
  cin >> N >> Z >> W;
  int a[N], X[N], Y[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  X[N-1] = a[N-1];
  Y[N-1] = W;
  for (int i = N-2; i+1; i--) {
    X[i] = a[i];
    Y[i] = a[N-1];
    for (int j = i+1; j < N-1; j++) {
      if (abs(X[j]-Y[j]) < abs(X[i]-Y[i])) {
        X[i] = Y[j];
        Y[i] = X[j];
      }
    }
  }
  for (int i = 0; i < N; i++) {
    answer = max(answer,abs(X[i]-Y[i]));
  }
  cout << answer;
}

Measured memory_bytes: 3660
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	int n;
	cin>>n;
	int ans = 0;
	vector<ll>b(n+2);
	for(int i=1;i<n;i++)cin>>b[i];
	b[0] = b[n] = 1e9;
	for(int i=1;i<=n;i++){
		ll res = min(b[i],b[i-1]);
		ans+=res;
	}
	cout<<ans;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[222222];
vector<ii> ans;
vi adj[222222];
void addedge(int u, int v)
{
	ans.pb(mp(u,v)); adj[u].pb(v); adj[v].pb(u);
}


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s; int n = s.length();
	for(int i=0;i<n;i++) a[i+1]=s[i]-'0';
	if(a[n]){cout<<-1<<'\n'; return 0;}
	if(!a[1]){cout<<-1<<'\n'; return 0;}
	for(int i=1;i<n;i++)
	{
		if(a[i]^a[n-i])
		{
			cout<<-1<<'\n'; return 0;
		}
	}
	int mx=0;
	for(int i=n/2;i>=1;i--)
	{
		if(a[i]) {mx=i; break;}
	}
	int cnt=0;
	for(int i=0;i<n-1-mx;i++)
	{
		addedge(0,++cnt);
	}
	addedge(0,++cnt); //for the mx
	//start here
	int pre = cnt; int precnt=mx;
	for(int i=n/2;i>=2;i--)
	{
		if(i==mx) continue;
		if(a[i])
		{
			for(int j=0;j<precnt-1-i;j++) addedge(pre,++cnt);
			addedge(pre,++cnt);
			pre=cnt; precnt=i;
		}
	}
	while(cnt+1<n)
	{
		addedge(pre,++cnt);
	}
	for(ii x:ans)
	{
		cout<<x.fi+1<<' '<<x.se+1<<'\n';
	}
}


Measured memory_bytes: 12868
@ary = Array.new(14).map{Array.new(14,0)}

while n = gets
    n = n.split(",")
    @x = n[0].to_i + 2
    @y = n[1].to_i + 2
    @s = n[2].to_i
    if @s == 1
        @ary[@x][@y - 1] += 1
        
        @ary[@x - 1][@y] += 1
        @ary[@x][@y] += 1
        @ary[@x + 1][@y] += 1
        
        @ary[@x][@y + 1] += 1
    elsif @s == 2
        @ary[@x - 1][@y - 1] += 1
        @ary[@x][@y - 1] += 1
        @ary[@x + 1][@y - 1] += 1
        
        @ary[@x - 1][@y] += 1
        @ary[@x][@y] += 1
        @ary[@x + 1][@y] += 1
        
        @ary[@x - 1][@y + 1] += 1
        @ary[@x][@y + 1] += 1
        @ary[@x + 1][@y + 1] += 1
    elsif @s == 3
        @ary[@x][@y - 2] += 1
        
        @ary[@x - 1][@y - 1] += 1
        @ary[@x][@y - 1] += 1
        @ary[@x + 1][@y - 1] += 1
        
        @ary[@x - 2][@y] += 1
        @ary[@x - 1][@y] += 1
        @ary[@x][@y] += 1
        @ary[@x + 1][@y] += 1
        @ary[@x + 2][@y] += 1
        
        @ary[@x - 1][@y + 1] += 1
        @ary[@x][@y + 1] += 1
        @ary[@x + 1][@y + 1] += 1
        
        @ary[@x][@y + 2] += 1
    end
end

a = 0
b = 0
for i in 2..11 do
    for j in 2..11 do
        if b < @ary[i][j]
            b = @ary[i][j]
        end
        if @ary[i][j] == 0
            a += 1
            
        end
    end
end

puts a
puts b




Measured memory_bytes: 6884
A,B,K = list(map(int, input().split()))
 
if(A+B>=K and A<=K):
  print(0, end=" ")
  print(B-K+A)
elif(A+B>=K):
  print(A-K, end=" ")
  print(B)
else:
  print(0, end=" ")
  print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B; cin >> A >> B;
  string result = (A%2==1&&B%2==1) ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

bool exec(int64_t x, int64_t i) {
    // a^5 - b^5 = x, a - b = i
    auto r = irange(0L, 1000L);
    auto b = *partition_point(r.begin(), r.end(), [&](int64_t b) {
        auto a = b + i;
        return a * a * a * a * a - b * b * b * b * b < x;
    });
    auto a = b + i;
    if (a * a * a * a * a - b * b * b * b * b == x) {
        cout << a << " " << b << endl;
        return true;
    }

    // a^5 + b^5 = x, a + b = i
    for (auto b :
         irange(0L, min(i / 2 + 1, (int64_t)(pow((double)x, 0.2) + 1)))) {
        auto a = i - b;

        if (a * a * a * a * a + b * b * b * b * b == x) {
            cout << a << " " << -b << endl;
            return true;
        }
    }

    return false;
}

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

    for (int64_t i = 1; i * i <= x; ++i) {
        if (x % i > 0) {
            continue;
        }

        if (exec(x, i)) {
            return 0;
        }

        if (exec(x, x / i)) {
            return 0;
        }
    }
}

Measured memory_bytes: 4032
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = a * c;
	chmax(ans, a * d);
	chmax(ans, b * c);
	chmax(ans, b * d);
	if(a <= 0 && 0 <= b) chmax(ans, 0LL);
	if(c <= 0 && 0 <= d) chmax(ans, 0LL);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int a, b,c,d,e; cin>>a>>b>>c>>d>>e;

    cout << 15 - a-b-c-d-e << endl;
    return 0;
}

Measured memory_bytes: 3588
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x>=r && x+r<=W)&&(y>=r && y+r<=H)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n=int(input())
a=list(map(int,stdin.readline().split()))
c=0
for i in range(1,n+1):
    if(a[i-1]!=i):
        c+=1
if(c>2):
    print("NO")
else:
    print("YES")

Measured memory_bytes: 39828
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N, A, B, C;
int D[102];
int main() {
    cin >> N >> A >> B >> C;
    rep(i, N) cin >> D[i];
    sort(D, D + N);
    reverse(D, D + N);

    int ans = 0;
    int cost = A;
    int cal = C;

    ans = int(1.0 * cal / cost);
    rep(i, N) {
        cal += D[i];
        cost += B;
        // cout <<cal <<", " << cost << endl;
        ans = max(ans, int(1.0 * cal / cost));
    }

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

Measured memory_bytes: 3076
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		long sum = 0;
		while(s.length() > 0){
			sum += Integer.parseInt(s.substring(0, 1));
			s = s.substring(1);
		}
		
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	}
}


Measured memory_bytes: 56344
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
    string S;

    for(int i=0;i<6;i++){
        S[i] = '0';
    }
    
    for(int i=0;i<6;i++){
        cin >> S[i];
    }

    int a = 0;
    for(int i=0;i<6;i++){
        if(S[i] == '1'){
            a = a + 1;
        }
    }
    cout << a << endl;
    return 0;

}

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

int prime_number(int num){
    int sqrt_num;
    sqrt_num = sqrt(num);
    for(int i=2; i<=sqrt_num; i++){
        if(num%i == 0){
            return 0;
        }
    }
    return 1;
}

int main()
{
    int N, count, num;
    cin >> N;
    count = 0;
    for(int i=0; i<N; i++){
        cin >> num;
        if(prime_number(num)){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=300000;

double a[MX+5];

int main()
{
    FasterIO;

    int n, m, k;
    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        ll x;
        cin>>x; a[i]=((x*(x+1))/2)/(x*1.0);
    }
    double mx=0, sm=0;
    for(int i=1; i<=k; i++) sm+=a[i];
    mx=sm;
    for(int i=k+1; i<=n; i++)
    {
        sm+=a[i]; sm-=a[i-k]; mx=max(mx, sm);
    }
    cout<<setprecision(10)<<fixed<<mx<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	int A[n];
	rep(i, n) cin >> A[i];
	set<int> s;
	int cnt = 0;
	rep(i, n) {
		if (A[i] <= 399) s.insert(1);
		else if (A[i] <= 799) s.insert(2);
		else if (A[i] <= 1199) s.insert(3);
		else if (A[i] <= 1599) s.insert(4);
		else if (A[i] <= 1999) s.insert(5);
		else if (A[i] <= 2399) s.insert(6);
		else if (A[i] <= 2799) s.insert(7);
		else if (A[i] <= 3199) s.insert(8);
		else cnt++;
	}
	int mn = max(int(s.size()), 1);
	int mx = s.size();
	if (cnt!=0) mx = mx + cnt;
	cout << mn << " " << mx << endl;
}

Measured memory_bytes: 256
#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 int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#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;};

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



ll dp[110][100100];
ll weight[110],value[110];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,W;
    cin>>N>>W;
 
    REP(i,N) cin>>weight[i]>>value[i];
    
    REP(i,110) REP(j,100100) dp[i][j]=1LL<<60;
 
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int sum_v=0;sum_v<100100;sum_v++){
            if(sum_v-value[i]>=0) chmin(dp[i+1][sum_v],dp[i][sum_v-value[i]]+weight[i]);
            chmin(dp[i+1][sum_v],dp[i][sum_v]);
        }
    }
    
    ll res=0;
    REP(i,100100) if(dp[N][i]<=W) res=i;
    cout<<res<<endl;
}

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

using namespace std;

int main(){

  int n;
  scanf("%d", &n);
  int a;
  vector<int> h;
  for(int i=0;i<n;i++){
    scanf("%d", &a);
    h.push_back(a);
  }

  int opr = 0;
  int r,l;

  while(1){
    r = n;
    for(int i=0;i<n;i++){
      if(h[i]!=0) {
        r=i;
        break;
      }
    }
    if(r==n) break;

    l = r;
    for(int i=r+1;i<n;i++){
      if(h[i]==0){
        break;
      }
      l++;
    }

    for(int i=r;i<=l;i++){
      h[i]--;
    }

    opr++;

  }

  printf("%d\n", opr);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        FastScanner cin = new FastScanner();
        int n = cin.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; ++i)
            a[i] = cin.nextInt();

        int res = 2000000000;

        for (int i = -100; i <= 100; ++i) {
            int s = 0;

            for (int j = 0; j < n; ++j)
                s += (i - a[j]) * (i - a[j]);

            res = Math.min(res, s);
        }

        System.out.println(res);
    }

    static class FastScanner {
        StringTokenizer tokenizer;
        Scanner scanner;

        FastScanner() {
            tokenizer = null;
            scanner = new Scanner(System.in);
        }

        int nextInt() {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(scanner.nextLine());

            return Integer.parseInt(tokenizer.nextToken());
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(scanner.nextLine());

            return tokenizer.nextToken();
        }
    }
}



Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

class BipartiteMatching {
  int V;
  vector<vector<int>> G;
  vector<int> match;
  vector<bool> used;

  bool dfs(int v){
    used[v] = true;
    for(int i=0; i<G[v].size(); i++){
      int u = G[v][i], w = match[u];
      if(w<0||!used[w]&&dfs(w)){
        match[v] = u;
        match[u] = v;
        return true;
      }
    }
    return false;
  }
  void init_graph(){
    for(int i=0; i<V; i++){
      G[i].clear();
      match[i] = -1;
      used[i] = false;
    }
  }

public:
  BipartiteMatching(int V):V(V),G(V,vector<int>()),match(V,0),used(V,false){
    init_graph();
  }
  void add_edge(int u, int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }
  int matching(){
    int res = 0;
    rep(i,V) match[i] = -1;
    for(int v=0; v<V; v++){
      if(match[v] < 0){
        rep(i,V) used[i] = false;
        if(dfs(v)){
          res++;
        }
      }
    }
    return res;
  }
};

int main(){
  int N;
  cin >> N;
  vector<vector<int>> A, B;
  rep(i,N){
    int a, b;
    cin >> a >> b;
    A.push_back({a,b});
  }
  rep(i,N){
    int a, b;
    cin >> a >> b;
    B.push_back({a,b});
  }

  BipartiteMatching bm(2*N);
  rep(i,N){
    rep(j,N){
      if(A[i][0]<B[j][0] && A[i][1]<B[j][1]){
        bm.add_edge(i, N+j);
      }
    }
  }
  
  cout << bm.matching() << endl;
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,c,x[5]={},i,j,tmp;
	scanf("%d %d %d",&a,&b,&c);
	x[0]=a;
	x[1]=b;
	x[2]=c;
	for(j=2;j>0;j--){
		for(i=0;i<j;i++){
			if(x[i]<x[i+1]){
				tmp=x[i];
				x[i]=x[i+1];
				x[i+1]=tmp;
			}
		}
	}
	printf("%d %d\n",x[2],x[0]);
	return 0;
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int> > country(N+1);
    vector<int> P(M);
    vector<int> Y(M);
    rep(i, M){
        cin >> P[i] >> Y[i];
        country[P[i]].push_back(Y[i]);
    }

    for (int i = 1; i < N+1; i++){
        sort(country[i].begin(), country[i].end());
    }

    rep(i, M){
        int p[6];
        int pnow = P[i];
        rep(j, 6){
            int x = pnow % 10;
            p[5-j] = x;
            pnow /= 10;
        }
        rep(j, 6){
            cout << p[j];
        }

        int ynow = lower_bound(country[P[i]].begin(), country[P[i]].end(), Y[i]) - country[P[i]].begin();
        ynow++;
        rep(j, 6){
            int x = ynow % 10;
            p[5-j] = x;
            ynow /= 10;
        }
        rep(j, 6){
            cout << p[j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 9492
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m;
vvi used;
vs in;
void dfs(int a,int b,int c){
	used[a][b]=min(used[a][b],c);
	if(a==n-1&&b==m-1)return;
	rep(i,4){
		int x=a+dx[i];
		int y=b+dy[i];
		if(x<0||y<0||x>=n||y>=m||in[x][y]=='#')continue;
		if(c+1<used[x][y])dfs(x,y,c+1);
	}
}
int main(){
	cin>>n>>m;
	in=vs(n);
	rep(i,n)cin>>in[i];
	used=vvi(n,vi(m,inf));
	dfs(0,0,1);
	int co=0;
	rep(i,n)rep(j,m)if(in[i][j]=='.')co++;
	if(used[n-1][m-1]==inf)cout<<-1<<endl;
	else cout<<co-used[n-1][m-1]<<endl;
}








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

struct unionFind{
	int n;vector<int>pr;
	unionFind(){};
	unionFind(int _n){
		n=_n;
		pr.resize(n,-1);
};
	int root(int a){
		if(pr[a]==-1)return a;
		else return pr[a]=root(pr[a]);
	}
	void unify(int a,int b){
		a=root(a);b=root(b);
		if(a==b)return;
		pr[a]=b;
	}	
	int connected(){return count(begin(pr),end(pr),-1);}
};

signed main(){
	int n,m;cin>>n>>m;
	unionFind uf(n);
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;x--;y--;
		uf.unify(x,y);
	}
	cout<<uf.connected()<<endl;
}

Measured memory_bytes: 640
#include <cstdio>
const int N = 3e5;
char s[N];

int main()
{
	scanf("%s", s);
	int res = 0;
	bool flag = true;
	for (int l = 0, r = 0; true; ++r)
		if (s[r] != s[l])
		{
			int run = r - l;
			if (run % 3 == 0)
				res += run * 2 / 3;
			if (run % 3 == 1)
				res += (run * 2 + 1) / 3, flag = true;
			if (run % 3 == 2)
				res += (run * 2 - 1) / 3, res += flag ^= true;
			if (!s[l = r])
				break;
		}
	printf("%d\n", res);
}


Measured memory_bytes: 384
from math import factorial
from sys import exit, stdin
N = int(stdin.readline().rstrip())
def dfs(s):
    #print(s)
    if int(s) > N:
        #print('exit')
        return 0
    if all(s.count(c) > 0 for c in '753'):
        #print('yay!')
        ret = 1
    else:
        ret = 0
    #print('before for %d' % ret)
    for c in '753':
        #print('c in for %s' % c)
        ret += dfs(s+c)
    #print('return is %s' % ret)
    return ret

print(dfs("0"))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
  ll a,b,c,x,y; cin >> a >> b >> c >> x >> y;
  ll z = 2 * max(x,y);
  ll sum = 0;
  ll sum_min = INFINITY;
    for (ll i = 0; i <= z; i += 2) {
        ll X = max(x - i / 2, (ll)0);
        ll Y = max(y - i / 2, (ll)0);
        sum = i * c + X * a + Y * b;
        sum_min = min(sum,sum_min);
    }
    print(sum_min);
}


Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		int a_n = scan.nextInt();
		int b_n = scan.nextInt();
		String u = scan.next();
		if(a.equals(u)){
			a_n-=1;
		}else {
			b_n-=1;
		}
		System.out.println(a_n +" "+b_n);
		// your code goes here
	}
}

Measured memory_bytes: 21204
import math
import sys
from decimal import Decimal
a,b,c = map(int,input().split())
if c-a-b <= 0:
	print('No')
	sys.exit()
if Decimal((c-a-b)*(c-a-b) - 4*a*b) > 0:
	print("Yes")
else:
	print('No')


Measured memory_bytes: 9956
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
  int N;
  int V[60];
  int C[60];
  cin >> N;
  for(int i=0; i<N; i++) cin >> V[i];
  for(int i=0; i<N; i++) cin >> C[i];

  int ans = 0; 

  for(int i=0; i<N; i++){
    if(V[i]>C[i]){
      ans += V[i]-C[i];
    }  
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
prev_a = -1
for a in A:
    ans += B[a - 1] 
    if a - prev_a == 1:
        ans += C[prev_a - 1]
    prev_a = a
print(ans)


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

int main(void) {
  
  int A;
  int B;
  
  cin >> A;
  cin >> B;
  
  if ( A == 2 ) {
    
    cout << "No" << endl;
  }
  
  else if ( B == 2 ) {
    
    cout << "No" << endl;
  }
  
  else {
    
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3528
//B - Comparing Strings

#include <iostream>

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    if (a < b)
        cout << string(b, to_string(a)[0]) << endl;
    else
        cout << string(a, to_string(b)[0]) << endl;

    return 0;
}


Measured memory_bytes: 256
// doot diddly donger cuckerino Hahahahahah


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vi = vector<int>;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template <typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template <typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

class DDivGame {
public:
  
  void solve(std::istream& cin, std::ostream& cout) {
    ll val;
    cin >> val;
    map<long long, long long> mp;
    while (val % 2 == 0) {
      mp[2]++;
      val /= 2;
    }
    for (long long i = 3; i * i <= val; i += 2) {
      while (val % i == 0) {
        mp[i]++;
        val /= i;
      }
    }
    if (val > 2) {
      mp[val]++;
    }
    int ans = 0;
    for (auto[p, e]: mp) {
      ans += max(0.0, sqrt(8 * e + 1) - 1) / 2;
    }
    cout << ans << '\n';
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	DDivGame solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3680
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

n,q = map(int,input().split())
tree = [[] for _ in range(n)]
point = [0] * n

for _ in range(n-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
    
for _ in range(q):
    a,b = map(int,input().split())
    a -= 1
    point[a] += b
    
def dfs(now, prev = -1):
    for next in tree[now]:
        if next == prev:
            continue
        point[next] += point[now]
        
        dfs(next, now)
        
dfs(0)
print(*point)

Measured memory_bytes: 268432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
string s;
ll dp[2005][2005];
int rui[2005];
ll C[2005][2005];
int main(){
	rep(i,2003) rep(j,i+1) if(j==0||j==i)C[i][j]=1;else C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	cin>>s;
	int n = s.size();
	rep(i,n){
		rui[i+1] = rui[i] + s[i]-'0';
	}
	dp[0][0] = 1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=i;j++){
			if(dp[j][i-j] == 0) continue;
			int cur = i;
			int one = rui[cur+1]-j;
			int zero = 2*(cur+1)-rui[cur+1]-(i-j);
			if(one){
				dp[j+1][i-j] += dp[j][i-j];
				if(dp[j+1][i-j] >= mod) dp[j+1][i-j] -= mod;
			}
			if(zero){
				dp[j][i-j+1] += dp[j][i-j];
				if(dp[j][i-j+1] >= mod) dp[j][i-j+1] -= mod;
			}
		}
	}
	ll ans = 0;
	for(int i=0;i<=n;i++){
		if(dp[i][n-i]==0) continue;
		int one = rui[n]-i;
		ans += dp[i][n-i] * C[n][one] % mod;
	}
	cout << (ans%mod+mod)%mod << endl;
}

Measured memory_bytes: 60544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)\
{\
return (a.second < b.second);\
}
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

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

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int K,A,B,sum=0;
    
    cin >> K >> A >> B;
    
    for(int i=A; i<=B; i++){
        if(i%K==0){
           sum=1;
           break;
        }
    }
    
    if(sum==1){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
#s.append('X')
#print(s)

a = []
x = 1
for i in range(1,n):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
else:
    a.append(x)

#print(a)
y = 0

for j in a:
    y += j*(j-1)/2

print(int(y))

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N, K;
vector<int> h(100010);
vector<int> dp(100010, INT32_MAX);


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> N >> K;
    REP(i, N) cin >> h.at(i);

    dp.at(0) = 0;

    for (int i = 1; i < N; i++) {
        for(int j = i - K; j < i; j++) {
            if (j < 0) continue;
            chmin(dp.at(i), dp.at(j) + abs(h.at(j) - h.at(i)));
        }
    }

    cout << dp.at(N - 1) << endl;

    return 0;
}

Measured memory_bytes: 1152
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Main
 */
public class Main {

  public ArrayList<Integer> maxes;

  public static void main(String[] args) {
    (new Main()).go();
  }

  public void go() {
    this.maxes = new ArrayList<Integer>();
    Scanner sc = new Scanner(System.in);

    while (true) {
      int n = sc.nextInt();
      int m = sc.nextInt();
      if (n == 0 && m == 0) {
        break;
      }
      int[] points = new int[n];
      int max = 0;
      for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
          points[j] += sc.nextInt();
          if (i == m - 1 && max < points[j]) {
            max = points[j];
          }
        }
      }
      this.maxes.add(max);
    }

    for (Integer max : maxes) {
      System.out.println(max);
    }
    sc.close();
  }
}


Measured memory_bytes: 67872
#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int N, T;
	cin >> N >> T;
	vector<int> t(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> t[i];
	}
	if (N == 1)
	{
		cout << T << endl;
		return;
	}
	unsigned long long int ans = 0;
	for (int i = 0; i < N - 1; ++i)
	{
		if (t[i + 1] - t[i] <= T)
		{
			ans += t[i + 1] - t[i];
		}
		else
		{
			ans += T;
		}
	}
	ans += T;
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1024
import sys
def f(c,h=0):
 if 2 in c and sum(c)==2:return 1
 if 5 in c:return 0  # sum(c)==2
 if 4 in c:
     k=c.index(4);c[k]-=3
     if f(c,h+1):return 1
     c[k]+=3
 if 3 in c:
     k=c.index(3);c[k]-=3
     if f(c,h+1):return 1
     c[k]+=3
 for i in range(7):
  if c[i]and c[i+1]and c[i+2]:
      c[i]-=1;c[i+1]-=1;c[i+2]-=1
      if f(c,h+1):return 1
      c[i]+=1;c[i+1]+=1;c[i+2]+=1
n='123456789'
for e in sys.stdin:
 e=list(e)
 a=[i for i in n if f([(e+[i]).count(j)for j in n])]
 if a:print(*a)
 else:print(0)


Measured memory_bytes: 5576
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int s, w; cin >> s >> w;
	if( w >= s ){
		cout << "unsafe" << endl;
	} else cout << "safe" << endl;
}

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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	get(a);
	get(b);
	get(h);

	cout << (h*(b+a))/2	 <<  endl;
	

	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=1;i<=n;i++)
#define form for(int j=0;j<m;j++)
#define pb push_back
#define mp make_pair
#define sc second
#define f first
#define kek cout<<"\n"
#define all(v)        ((v).begin()), ((v).end())
#define pob pop_back()
const ll MOD=1e9+7;
const ll INF=1e8;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
      
      string a,b;
      cin>>a>>b;
      int n,k;
      cin>>n>>k;
      string f;
      cin>>f;
      if(f==a) cout<<n-1<<" "<<k;
      else cout<<n<<" "<<k-1;
      
      
      
      
      
      return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=5e5+5;
struct node{
    int l,r;
    int sum;
}tree[maxn<<2][26];
void pushup(int m,int x){
     tree[m][x].sum=(tree[m<<1][x].sum+tree[m<<1|1][x].sum);
}
void build (int m,int l,int r,int x){
     tree[m][x].l=l;
     tree[m][x].r=r;
     tree[m][x].sum=0;
     if(l==r){
        return ;
     }
     int mid=(l+r)>>1;
     build(m<<1,l,mid,x);
     build(m<<1|1,mid+1,r,x);
     pushup(m,x);
}
void update(int m,int pos,int val,int x){
    if(tree[m][x].l==tree[m][x].r&&tree[m][x].l==pos){
        tree[m][x].sum+=val;
        return ;
    }
    int mid=(tree[m][x].l+tree[m][x].r)>>1;
    if(pos<=mid){
        update(m<<1,pos,val,x);
    }
    else{
        update(m<<1|1,pos,val,x);
    }
    pushup(m,x);
}
int query(int m,int l,int r,int x){
    if(tree[m][x].l==l&&tree[m][x].r==r){
        return tree[m][x].sum;
    }
    int mid=(tree[m][x].l+tree[m][x].r)>>1;
    if(r<=mid){
        return query(m<<1,l,r,x);
    }
    else if(l>mid){
        return query(m<<1|1,l,r,x);
    }
    else{
        return query(m<<1,l,mid,x)+query(m<<1|1,mid+1,r,x);
    }
}
char str[maxn];
int main(){
    int n;
    cin>>n;
    scanf("%s",str+1);
    for(int i=0;i<26;i++){
        build(1,1,n,i);
    }
    for(int i=1;i<=n;i++){
       update(1,i,1,str[i]-'a');
    }
    int q;
    cin>>q;
    int op;
    char s[2];
    while(q--){
          scanf("%d",&op);
          int x;
          if(op==1){
             scanf("%d%s",&x,s);
             update(1,x,-1,str[x]-'a');
             update(1,x,1,s[0]-'a');
             str[x]=s[0];
          }
          else{
             int l,r;
             scanf("%d%d",&l,&r);
             int cc=0;
             for(int i=0;i<26;i++){
              //  cout<<query(1,l,r,i)<<" "<<i<<endl;
                if(query(1,l,r,i)>0){
                    cc++;
                }
             }
             printf("%d\n",cc);
          }
    }
    return 0;
}

Measured memory_bytes: 322304
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;
string sabc="ABC";
int nabc[3];
vector<char>ans;
void manipulation(int a,int b){
	nabc[a]++;
	nabc[b]--;
	ans.push_back(sabc[a]);
}

void solve()
{
	int n;
	cin>>n;
	rep(i,3){
		cin>>nabc[i];
	}
	vector<vector<int>>cnt(n,vector<int>(3));
	vector<string> t={"AB","AC","BC"};
	map<int,pair<int,int>>num;
	num[0]=make_pair(0,1);
	num[1]=make_pair(0,2);
	num[2]=make_pair(1,2);
	//int cnt[3]={0,0,0};
	bool ok=true;
	
	vector<string>vs(n);
	rep(i,n){
		string s;
		cin>>s;
		vs[i]=s;
		
	}
	rep(i,n){
		string s=vs[i];
		rep(j,3){
			if(s==t[j]){
				int a=num[j].x, b =num[j].y;
				if(nabc[a]>0&& nabc[b]>0){
					if(nabc[a]>nabc[b]){
						manipulation(b,a);
					}else if(nabc[a]<nabc[b]){
						manipulation(a,b);
					}else{
						if(i!=n-1){
							rep(k,3){
								if(vs[i+1]==t[k]){
									int c=num[k].x, d=num[k].y;
									if(c==a or d==a){
										manipulation(a,b);
									}else{
										manipulation(b,a);
									}
								}
							}
						}else{
							manipulation(a,b);
						}
					}
				}else if(nabc[a]>0){
					manipulation(b,a);
				}else if(nabc[b]>0){
					manipulation(a,b);
				}else{
					ok=false;
				}
			}
		}
	}
	if(ok){
		cout<<"Yes"<<endl;
		rep(i,n){
			cout<<ans[i]<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
}

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


Measured memory_bytes: 12168
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        int one = N%10;
        
        if(one == 3){
            System.out.println("bon");
        }else if(one == 0 || one == 1 || one == 6 || one == 8){
            System.out.println("pon");
        }else{
            System.out.println("hon");
        }
    }
}

Measured memory_bytes: 35716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var XY = ReadLine().Split().Select(int.Parse).ToArray();
        var X = XY[0];
        var Y = XY[1];


        var x = Max(X, Y);
        var y = Min(X, Y);

        var bb = false;
        var k = x;
        var s = y;
        for (int i = 0; i <= 1000100; i++)
        {
            k++;
            s--;
            if (s == 0 && k % 3 == 0)
            {
                bb = true;
                break;
            }
        }
        if (x > y * 2 || !bb)
        {
            WriteLine(0);
            return;
        }

        var mb = new ModBinom(1000010);
        var c = 0;
        while (x < y * 2)
        {
            c++;
            y--;
            x++;
        }

        WriteLine(mb.Binom(x / 2, c));
    }
}

class ModBinom
{
    long[] fac;
    long[] finv;
    int mod;

    public ModBinom(int N, int p = (int)1e9 + 7)
    {
        N++;

        fac = new long[N];
        long[] inv = new long[N];
        finv = new long[N];

        fac[0] = fac[1] = 1;
        inv[1] = 1;
        finv[0] = finv[1] = 1;

        for (int i = 2; i < fac.Length; i++)
        {
            fac[i] = fac[i - 1] * i % p;
            inv[i] = p - inv[p % i] * (p / i) % p;
            finv[i] = finv[i - 1] * inv[i] % p;
        }

        mod = p;
    }

    public long Binom(int n, int k)
    {
        return fac[n] * finv[k] % mod * finv[n - k] % mod;
    }
}

Measured memory_bytes: 36576