akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int n,a,b,s;
int main(void){
    cin>>n>>a>>b;
    s=a+b;
    for(int i=0;i<n;i++){
        char c;
        cin>>c;
        if(c=='a'){
            if(s>0){
                cout<<"Yes\n";
                s--;
            }else{
                cout<<"No\n";
            }
        }else if(c=='b'){
            if(b>0&&s>0){
                cout<<"Yes\n";
                b--;
                s--;
            }else cout<<"No\n";
        }else cout<<"No\n";
    }
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
int dp[3005];
int leng[3005];
int happy[3005];
int n,t,s;
int main()
{
  scanf("%d %d %d",&n,&t,&s);
  for(int i=0;i<n;i++)
    {
      scanf("%d %d",&happy[i],&leng[i]);
    }
  fill(dp,dp+3005,0);
  for(int i=0;i<n;i++)
    {
      for(int j=t;j>=leng[i];j--)
	{
	  if(j-leng[i]<s && j>s)
	    {
	      dp[j]=dp[j];
	    }
	  else
	    {
	      dp[j]=max(dp[j],dp[j-leng[i]]+happy[i]);
	    }
	}
    }
  printf("%d\n",*max_element(dp,dp+t+1));
  return 0;
}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	vector<pair<int, int>> x(n);
	for (int i = 0; i < n; i++) {
		x[i].first = a[i] + b[i];
		x[i].second = i;
	}
	sort(x.begin(), x.end(), greater<pair<int, int>>());
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int idx = x[i].second;
		if (i & 1) {
			ans -= b[idx];
		} else {
			ans += a[idx];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4728
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX_M = 200005;
int main(){
  int N,M; cin >> N >> M;
  int a[MAX_M], b[MAX_M];
  vector<int> cand;
  vector<int> cand2;
  bool flag1; flag1=false;
  bool flag2; flag2=false;
  for(int i=0;i<M;i++){
    cin >> a[i] >> b[i];
    if(a[i]==1){
      cand.push_back(b[i]);
      flag1 = true;
    }
    if(b[i]==N){
      cand2.push_back(a[i]);
      flag2 = true;
    }
  }
  if(flag1) sort(cand.begin(), cand.end());
  if(flag2) sort(cand2.begin(), cand2.end());
  int j=0;
  int i=0;
  int lim = cand.size();
  int lim2 = cand2.size();
  if(lim == 0 || lim2==0){cout << "IMPOSSIBLE" << endl; return 0;}
  while(i <= lim  && j <= lim2){
      //cout << cand[i] << " " << cand2[j];
      if(cand[i] == cand2[j]){
        cout << "POSSIBLE" << endl;
        return 0;
      }else if(cand[i] > cand2[j]){
        j++;
      }else{
        i++;
      }
  }
  cout << "IMPOSSIBLE" << endl;

  return 0;
}

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

int		main(void)
{
	int H, W;

	cin >> H >> W;
	for (int i = 0; i < W + 2; i++)
		cout << '#';
	cout << endl;
	for (int h = 0; h < H; h++)
	{
		string a;
		
		cin >> a;
		cout << '#' + a + '#' << endl;
	}
	for (int i = 0; i < W + 2; i++)
		cout << '#';
	cout << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
A, B, M = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
b = [int(x) for x in input().strip().split()]
ans = min(a) + min(b)
for m in range(M):
    x, y, c = [int(x) for x in input().strip().split()]
    ans = min(ans, a[x-1]+b[y-1]-c)

print(ans)

Measured memory_bytes: 18148
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

int main() {
    double a,b,x;
    double kaku,kaku2,tei;
	double pi     = 2.0 * asin(1.0);            /* πの値 */
	double unit   = pi / 180.0;                 /* 度 → ラジアン */
	double unit_r = 180.0 / pi;                 /* ラジアン → 度 */
    cin>>a>>b>>x;
    x/=a;
    if((a*b)/2>=x){
        tei=(x/b)*2;
        kaku=atan2(tei,b);
        kaku2=atan(tan(kaku))*unit_r;
        
    }else if((a*b)/2<x){
        double nokori;
        nokori=a*b-x;
        nokori*=2;
        tei=nokori/a;
        kaku=atan2(a,tei);
        kaku2=atan(tan(kaku))*unit_r;
    }
    
    cout<<setprecision(12)<<90.0-kaku2;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'

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

ll sum(int n) {
    return (ll)n*(n+1)/2;
}

int main() {
    fastio;
    ll ans=0, N;
    cin >> N;
    ans = sum(N) - sum(N/3)*3 - sum(N/5)*5 + sum(N/15)*15;
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <set>
using namespace std;

int n;
int P[110][11];
int F[110][11];
int ans = -1000000000;

void DFS(int x, string s){
    if(s.size() == 11){
        if(s == "00000000000"){
            return;
        }
        int cnt[110] = {0};
        for (int i = 1; i <= 10; i++) {
            for (int j = 1; j <= n; j++) {
                if(s[i] == '1' && F[j][i] == 1) cnt[j]++;
            }
        }
        int profit = 0;
        for (int i = 1; i <= n; i++) {
            profit += P[i][cnt[i]];
        }
        ans = max(ans, profit);
        return;
    }
    string tmp = s;
    tmp.push_back('0');
    DFS(x+1, tmp);
    tmp = s;
    tmp.push_back('1');
    DFS(x+1, tmp);
}

int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= 10; j++) {
            cin >> F[i][j];
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> P[i][j];
        }
    }

    DFS(0,"0");

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
int n,a[400010],l,r,mid,ans;
bool S(int x){return !(x<=mid);}
bool check(){
    for(int i=1;i<=n-1;i++){
        if(S(a[n+i-1])==S(a[n+i]))	return S(a[n+i]);
        if(S(a[n-i+1])==S(a[n-i]))	return S(a[n-i+1]);
    }
    return S(a[1]);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=2*n-1;i++)	scanf("%d",&a[i]);
    l=1;r=2*n-1;
    while(l<=r){
        mid=(l+r)/2;
        if(!check())	r=mid-1,ans=mid;
		else			l=mid+1;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1024
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n = inp[0]
a = inp
ans = 0
n.times do |i| 
  if i.even? and a[i].odd?
    ans += 1 
  end
end
p ans

Measured memory_bytes: 14516
#include<bits/stdc++.h>
using namespace std;
//14719021122270100109
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ldb;

#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define forn(i, n) for(register int i=0; i<n; i++)
#define Forn(i, n) for(register int i=1; i<=n; i++)
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)
#define mid l+r>>1
#define lid (id<<1|1)
#define rid ((id<<1)+2)
#define lson lid, l, mid
#define rson rid, mid, r

inline int in()
{
    char c=getchar();
    int neg=1, x=0;
    while(!isdigit(c)) (c=='-')?neg=-1, c=getchar():c=getchar();
    while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48), c=getchar();
    return neg*x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX_T=(8e5+5);
const int MAX=1e5+5;

map<ll,int> MP;
int N, ptr, a[MAX], tp[MAX];
ll K, A[MAX], dp[MAX], L[MAX], R[MAX];

inline void re()
{
    puts("-1");
    exit(0);
}

class Seg_Tree
{
    private:
    int dat[MAX_T];
    inline void pushdown(int id)
    {
        if(!dat[id]) return;
        dat[lid]=dat[rid]=dat[id];
        dat[id]=0;
    }
    public:
    inline int get(int id, int l, int r, int a, int b)
    {
        if(r<=a||b<=l) return 0;
//        cout<<l<<" "<<r<<" "<<p<<"<< "<<dat[id]<<endl;
        if(a<=l&&r<=b) return dat[id];
        pushdown(id);
        return max(get(lson, a, b), get(rson, a, b));
    }
    inline void update(int id, int l, int r, int a, int b, int v)
    {
        if(r<=a||b<=l) return;
        if(a<=l&&r<=b)
        {
//            cout<<l<<" "<<r<<" "<<v<<"EE"<<endl;
            dat[id]=v;
            return;
        }
        pushdown(id);
        update(lson, a, b, v);
        update(rson, a, b, v);
    }
}S;

inline ll query(int x, ll v)
{
    int id=S.get(0, 0, ptr, x, x+1);
//    cout<<" "<<x<<" "<<id<<endl;
    if(!id) return 0;
//    cout<<"id="<<id<<endl;
//    cout<<dp[id]<<" "<<L[id]<<" "<<v<<endl;
//    cout<<"dp"<<dp[id]<<" "<<L[id]<<" "<<L[x]<<endl;
    return (dp[id]+(L[id]-v+K)%K);
}

int main()
{
    N=in(), K=in();
    Forn(i, N)
    {
        a[i]=in(), tp[i]=in()-1;
        A[i]=A[i-1]+a[i];
        if(tp[i]) continue;
        if(a[i]*2>K) re();
    }
    Forn(i, N)
    {
        if(!tp[i])
        {
            L[i]=(-2ll*A[i-1]%K+K)%K;
            R[i]=(-2ll*A[i]%K+K)%K;
        }
        else L[i]=0, R[i]=K-1;
        MP[L[i]]=0, MP[R[i]]=0;
    }
    foreach(it, MP) it->s=ptr++;
    
    for(int i=N; i>0; i--)
    {
        int l=MP[L[i]], r=MP[R[i]];
        dp[i]=query(l, L[i]);
//    cout<<":)"<<endl;
        if(l>r) S.update(0, 0, ptr, r+1, l, i);
        else    S.update(0, 0, ptr, 0, l, i), S.update(0, 0, ptr, r+1, ptr, i);
//        cout<<i<<" "<<dp[i]<<" m "<<l<<" "<<r<<" "<<L[i]<<" "<<R[i]<<endl;
//        cout<<i<<" "<<dp[i]<<endl;
    }
    ll ret=dp[1];
    foreach(it, MP) ret=min(ret, query(it->s, it->f));
    cout<<ret+A[N]*2ll<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
int main()
{
    ll n,k;
    cin>>k>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll d=-1;
    for(ll i=0;i<n;i++)
    {
        if(i==n-1)
        {
            d=max(abs(k+a[0]-a[n-1]),d);
        }
        else
        {
            d=max(d,abs(a[i]-a[i+1]));
        }
    }
cout<<k-d;

    return 0;
}


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

#define int long long int
#define mp make_pair
using namespace std;

int32_t main() {
    int n,m;
    scanf("%lld%lld", &n,&m);
    vector<int> v;
    for (int i = 1; i*i <= m; ++i) {
        if(m%i == 0){
            v.push_back(i);
            if(m/i != i){
                v.push_back(m/i);
            }
        }
    }
    sort(v.begin(), v.end());
    int x = v.size();
    for (int i = x - 1; i >= 0; --i) {
        if(v[i]*n <= m){
            printf("%lld",v[i]);
            return 0;
        }
    }
    printf("1");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

string s, t;
int LCS[3005][3005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>s>>t;
    int n = s.length(), m = t.length();
    rep(i, 1, n){
        rep(j, 1, m){
            if(s[i - 1] == t[j - 1]) LCS[i][j] = LCS[i - 1][j - 1] + 1;
            else LCS[i][j] = max(LCS[i - 1][j], LCS[i][j - 1]);
        }
    }
   if(LCS[n][m] == 0){
       cout<<" ";
       return 0;
   }
   string ans;
   int cn = n, cm = m;
   while(cn && cm){
       if(s[cn - 1] == t[cm - 1]){
           ans += s[cn - 1];
           cn--;
           cm--;
       }
       else{
           if(LCS[cn - 1][cm] > LCS[cn][cm - 1]) cn--;
           else cm--;
       }
   }
   r(ans);
   cout<<ans;
   return 0;
}

Measured memory_bytes: 35456
#include <iostream>

using namespace std;

long W, H, x, y;

void solve();

int main() {
  cin >> W >> H >> x >> y;
  solve();
}

void solve() {
  // 任意の点と中心を通る直線で必ず2等分できるため
  double area = (double)W / 2 * H;
  // x, y が中心を通る場合は直線は一意に決まらない
  bool is_center = (x * 2 == W) && (y * 2 == H);

  cout << area << " " << (is_center ? 1 : 0) << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

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

Measured memory_bytes: 27000
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"
#include<queue>

using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)

//3

int main(void) {
	int n = 0;
	cin >> n;
	vector<pair<int,int>> sorted = vector<pair<int,int>>();
	rep(0, n) {
		int xi = 0;
		cin >> xi;
		sorted.push_back(make_pair(xi,i));
	}
	sort(sorted.begin(), sorted.end());
	int num = n / 2 - 1;
	vector<pair<int, int>> ans = vector<pair<int,int>>();
	int ansA = sorted[num + 1].first;
	int ansB = sorted[num].first;
	rep(0, n) {	
		if (i <= num) {
			ans.push_back(pair<int, int>(sorted[i].second,ansA));
		}
		else if (i > num) 
		{
			ans.push_back(pair<int, int>(sorted[i].second,ansB));
		}
	}
	sort(ans.begin(),ans.end());
	rep(0, n) {
		cout << ans[i].second << endl;
	}
}

Measured memory_bytes: 7408
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<string> vs(n);
    REP(i,n) cin >> vs[i];
    set<char> mask;
    for(string s:vs) for(char c:s) mask.insert(c);
    vector<char> ma(mask.begin(),mask.end());
    while(ma.size()<10) ma.push_back('a');
    int csum[256][10];
    REP(i,256) REP(j,10) csum[i][j]=0;
    int tmp=1;
    REP(i,vs.size()-1){
      tmp=1;
      for(int j=vs[i].size();j>=0;--j){
	csum[vs[i][j]][1]+=tmp;
	tmp*=10;
      }
    }
    tmp=1;
    for(int j=vs[n-1].size();j>=0;--j){
      csum[vs[n-1][j]][1]-=tmp;
      tmp*=10;
    }
    REP(i,256) REP(j,10) csum[i][j]=csum[i][1]*j;
    int answer=0;
    bool l0[256];
    REP(i,256) l0[i]=false;
    for(string s:vs) for(char c:s) l0[c]=false;
    REP(i,vs.size()) if(vs[i].size()>1) l0[vs[i][0]]=true;
    do{
      if(l0[ma[0]]) continue;
      int sum=0;
      REP(i,ma.size()) sum+=csum[ma[i]][i];
      if(sum==0) ++answer;
    }while(next_permutation(ma.begin(),ma.end()));
    cout << answer << endl;

  }
}

Measured memory_bytes: 3208
import java.nio.file.*;
import java.nio.charset.*;
import java.util.*;


public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        int ret=0;
        if(n == 100){
            System.out.println((int)Math.pow(100, d) * 101);
    }else{
            System.out.println((int)Math.pow(100, d) * n);
        }
    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	long long h[100000], hi;
	vector<long long> v;
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> hi;
		v.push_back(hi);
	}
	sort(v.begin(), v.end());
	long long minleng = v[n - 1];
	for (int i = 0; i + k - 1< n; i++) {
		minleng = v[i + k - 1] - v[i] < minleng ? v[i + k - 1] - v[i] : minleng;
	}
	cout << minleng << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, t;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> t;
  vector<int>  a(n);
  REP(i, n) cin >> a[i];

  int ma = a[n - 1], max_diff = -1;
  map<int, int> mp;

  RREP(i, n - 1) {
    if(a[i] < ma) mp[ma - a[i]]++, max_diff = max(max_diff, ma - a[i]);
    else ma = a[i];
  }

  cout << mp[max_diff] << endl;
}


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

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int c = a[i] + a[j];
			int ind = lower_bound(a.begin(), a.end(), c) - a.begin();
			ans += ind - j - 1;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3572
import java.util.*;

public class Main {

    private static class Point {
        int x;
        int y;

        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public boolean equals(Point p) {
            return p.x == x && p.y == y;
        }

        public String toString() {
            return "point: " + x + "," + y;
        }
    }

    private static char[][] room;
    private static LinkedList<Point> queue;
    private static int[][] directions = {{0,1}, {1,0}, {0,-1}, {-1,0}};
    private static Point[] points;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w, h, n;
        int count = 0;
        String lineOfInput;

        h = sc.nextInt();
        w = sc.nextInt();
        n = sc.nextInt();

        room = new char[h][w];
        points = new Point[n+1];

        sc.nextLine(); // for empty line
        for (int i = 0; i < h; i++) {
            lineOfInput = sc.nextLine();
            for (int j = 0; j < w; j++) {
                room[i][j] = lineOfInput.charAt(j);
                if (room[i][j] == 'S') {
                    points[0] = new Point(j, i);
                }
                if (room[i][j] != '.' && room[i][j] != 'X' && room[i][j] != 'S') {
                    points[Integer.parseInt(Character.toString(room[i][j]))] = new Point(j, i);
                }
            }
        }

//        System.out.println(Arrays.toString(points));
//        System.out.println(points[1].equals(new Point(2,2)));

        for (int i = 1; i <= n; i++) {
            count += bfs(i);
        }

        System.out.println(count);
    }

    private static int bfs(int next) {
        int count = 0;
        Point temp;
        int nx, ny;
        boolean[][] visited = new boolean[room.length][room[0].length];

        queue = new LinkedList<>();
        queue.add(points[next-1]);
        queue.add(null);
        visited[points[next-1].y][points[next-1].x] = true;
        while ((queue.peek() != null && !queue.peek().equals(points[next])) || queue.peek() == null) {
//            System.out.println(queue.peek());
            temp = queue.poll();
            if (temp == null) {
                count++;
                queue.add(null);
            }
            else {
                for (int[] direction: directions) {
                    nx = temp.x + direction[0];
                    ny = temp.y + direction[1];
                    if (nx >= 0 && ny >= 0 && nx < room[0].length && ny < room.length) {
                        if (room[ny][nx] != 'X' && !visited[ny][nx]) {
                            queue.add(new Point(nx, ny));
                            visited[ny][nx] = true;
                        }
                    }
                }
            }
        }

        return count;
    }
}

Measured memory_bytes: 71512
#include<iostream>
using namespace std;
main(){
  double h,l,d;

  cin>>h;
  cin>>d;
  if(d>h){l=h;h=d;}
  else l=d;
  while (cin >> d){
    if(d>h)h=d;
    else if(d<l)l=d;
  }
  cout << h-l << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>

using namespace std;

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

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

	if(n==1)cout << "Hello World" << endl;
	else {
		int a,b;
		cin >> a >> b;

		cout << a+b << endl; 
	}

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    bool f=true;
    for(int j=0;j<t.size();j++){
      if(s[(i+j)%s.size()]!=t[j])f=false;
    }
    if(f){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}



Measured memory_bytes: 3196
#ifdef __APPLE__
#include <cassert>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cctype>
#include <list>
#include <cmath>
#include <limits>
#include <bitset>
#include <numeric>
#include <climits>
#include <complex>
#else
#include<bits/stdc++.h>
#endif // __APPLE__
using namespace std;
typedef pair<int,int>   II;
typedef vector<II>     VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int LL;
typedef  unsigned long long int ULL;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define ALL(c) (c).begin(),(c).end()
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i,a,b) for(int i = (int)a; i < (int)b; i++)
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)	{
cerr << name << " : " << arg1 << std::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...);}
#else
#define trace(...)
#endif
//B



vector<pair<int,int> >a,b;
int n,m;

int main()
{
	//fr;fw;
	fast_io;
    cin>>n>>m;
    REP(i,0,n)
    {
        int x,y;
        cin>>x>>y;
        a.PB({x,y});
    }
    REP(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        b.PB({x,y});
    }
    REP(i,0,n)
    {
        LL ans=-1,mxx=LLONG_MAX;
        REP(j,0,m)
        {
            LL tmp=abs(a[i].F-b[j].F)+abs(a[i].S-b[j].S);
            if(tmp<mxx)
            {
                mxx=tmp;
                ans=j;
            }
        }
        cout<<ans+1<<endl;
    }


	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, R;
  cin >> N >> R;
  if (N >= 10) cout << R << endl;
  else cout << R + 100*(10-N) << endl;
  return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define M 3005
int C[M][M],a[M],p;
int main(){
	scanf("%d",&p);
	for(int i=0;i<=p;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%p;
	}
	for(int i=0,x;i<p;++i){
		scanf("%d",&x);
		if(x==1){
			a[0]++;
			for(int j=p-1,tp=1;j>=0;--j){
				a[j]=(a[j]-tp*C[p-1][j])%p;
				tp=tp*-i%p;
			}
		}
	}
	for(int i=0;i<p;++i)printf("%d ",(a[i]%p+p)%p);
}

Measured memory_bytes: 34176
#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
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a!=b && b!=c)
        cout<<b<<endl;
    else if(a!=b && a!=c)
        cout<<a<<endl;
    else
        cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
import fractions
a,b,c,d=map(int,input().split())
x=b//c
y=b//d
xy=b//(c*d//fractions.gcd(c,d))
b=b-x-y+xy

x=(a-1)//c
y=(a-1)//d
xy=(a-1)//(c*d//fractions.gcd(c,d))
a=(a-1)-x-y+xy
print(b-a)

Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    string s;
    cin>>s;
    int a = (s[0] - '0') * 10 + (s[1] - '0');
    int b = (s[2] - '0') * 10 + (s[3] - '0');
    if((a > 0 && a < 13) && (b > 0 && b < 13)){
        cout<<"AMBIGUOUS";
    }
    else if(a > 0 && a < 13){
        cout<<"MMYY";
    }
    else if(b > 0 && b < 13){
        cout<<"YYMM";
    }
    else cout<<"NA";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp=boost::multiprecision;

using namespace std;
using namespace mp;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((cpp_int)(1e9)+7)

cpp_int pmod(cpp_int n, cpp_int p){
	cpp_int m=n%mod;
	if(p==0) return 1;
	cpp_int rtn=pmod((m*m)%mod, p/2)%mod;
	if(p%2==1) rtn=rtn*m%mod;
	return rtn;
}

cpp_int gcd(cpp_int a, cpp_int b){
	if(a<b) swap(a, b);
	if(b==0) return a;
	return gcd(b, a%b);
}

int main(){
	int n;
	cin >> n;
	cpp_int a[n];
	for(int i=0; i<n; i++) cin >> a[i];

	cpp_int l=1, s=0;
	for(int i=0; i<n; i++){
		l*=a[i]/gcd(l, a[i]);
		s+=pmod(a[i], mod-2);
	}
	cout << l*s%mod << endl;
	return 0;
}

Measured memory_bytes: 640
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less_equal<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    readc(n, m, k) readarr(a, n) readarr(b, m)

    ordered_set s; 

    fori (i, 1, m)
    {
        b[i] += b[i-1]; s.insert(b[i]);
    }

    int ans = s.order_of_key(k + 1);

    fori (i, 1, n)
    {
        a[i] += a[i-1];
        if(a[i] > k) break;
        int x = s.order_of_key(k-a[i] + 1);
        ans = max(ans, i + x);
    }

    print(ans)

    return 0;
}


Measured memory_bytes: 19220
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll R, G, B, N;
	cin >> R >> G >> B >> N;
	
	ll ans = 0LL;
	for(ll r = 0; r <= N; ++ r) {
		for(ll g = 0; g <= N; ++g) {
			ll b = (N - R * r - G * g) / B;
			
			if( b >= 0 && R * r + G * g + B * b == N ) {
				ans++;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    ll N, K; cin >> N >> K;
    ll A[N]; rep(i, N) cin >> A[i];

    ll sumA = 0; rep(i, N) sumA += A[i];
    if(K == 0){
        cout << sumA << endl;
        return 0;
    }

    //a^b = (0^a)^(0^b)
    //Kの二進数表示がb_k b_(k-1) ... b_1と表されたとする
    //b_k = 1である
    //Xの二進数表示をx_k x_(k-1) ... x_1と表すと
    //x_k = 0 -> x_(k-1)以降は自由に決められる
    //x_k = 1 -> 次にビットで1が立っている場所まで確定する
    //つまり、Kの最上位ビットから次の1が立っているまでのビットまでで寄与を計算し、大きい方を採用すればいい
    //ex. K = 100101
    //b_5 = 1, b_4 = 0, b_3 = 0, b_2 = 1,...
    //x_5 = 1, x_4 = 0, x_3 = 0の寄与と x_5 = 0, x_4とx_3はAの情報から得られる最適なもの の寄与のうち大きい方を採用

    //Aの情報で必要なのは、各ビットがいくつ立っているか. 10^12は高々40bitで表されるので配列B[40]を作成
    ll B[40] = {};
    rep(i, N){
        rep(j, 40){
            B[j] += A[i] & 1;
            A[i] >>= 1;
        }
    }

    //rep(i, 40) cout << B[i] << " "; cout << endl;
    ll bitK[40];
    vector<int> stand;
    rep(i, 40){
        bitK[i] = K & 1;
        K >>= 1;
        if(bitK[i] == 1) stand.push_back(i);
    }
    ll ans = 0;
    ll pow2[40];
    pow2[0] = 1;
    rep(i, 39) pow2[i+1] = pow2[i] << 1;
    //rep(i, stand.size()) cout << stand[i] << " "; cout << endl;
    vector<ll> choice;

    ll acc = B[stand.back()]*pow2[stand.back()];
    for(int i = stand.back()-1; i >= 0; i--){
        acc += max(B[i], N-B[i])*pow2[i];
    }
    choice.push_back(acc);

    for(int bt = stand.size()-1; bt >= 0; bt--){
        //stand.back()からstand[bt]までは大きな値を取るようにする
        //stand.back()からstand[bt-1]+1まではbitKを採用
        ll acum = 0;
        if(bt != 0){
            for(int j = stand.back(); j >= stand[bt-1]+1; j--){
                if(bitK[j] == 0) acum += B[j]*pow2[j];
                else acum += (N-B[j])*pow2[j];
            }
            acum += B[stand[bt-1]]*pow2[stand[bt-1]];
            for(int j = stand[bt-1]-1; j >= 0; j--){
                acum += max(B[j], N-B[j])*pow2[j];
            }
        }
        else{
            // X = K
            for(int j = stand.back(); j >= 0; j--){
                if(bitK[j] == 0) acum += B[j]*pow2[j];
                else acum += (N-B[j])*pow2[j];
            }
        }
        choice.push_back(acum);
    }
    sort(choice.begin(), choice.end(), greater<ll>());
    ans = choice[0];
    
    for(int i = stand.back()+1; i < 40; i++){
        ans += B[i]*pow2[i];
    }
    cout << ans << endl;
    
    return 0;
}
void solve(){}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n),c;
    for(int i=0;i<n;i++){
       cin>>a.at(i);
       b.at(i)=a.at(i);
    }
    sort(b.begin(),b.end());
int l=n/2-1;
    for(int i=0;i<n;i++){
if(b.at(l)>=a.at(i))cout<<b.at(l+1)<<endl;
else cout<<b.at(l)<<endl;
 }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string L;
  cin >> L;
  int N = L.size();
  ll ans = 1;
  ll pwr = 1;
  vector<ll> A(N), B(N);
  A[N-1] = L[N-1] == '0' ? 1 : 3;
  for(int i=N-2; i>=0; i--) {
    if(L[i] == '1') {
      A[i] += 2 * A[i+1] + 1 * pwr * 3;
    } else {
      A[i] += 1 * A[i+1];
      B[i] += 1 * B[i+1];
    }
    A[i] %= mod;
    pwr *= 3;
    pwr %= mod;
  }
  // rep(i, N)
  //   cout << A[i] << ' ';
  // cout << endl;
  cout << A[0] % mod << endl;
  return 0;
}


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

int main() {
    int r;
    cin >> r;
    int D;
    cin >> D;
    int x;
    cin >> x;

    for(int i=0; i<10; i++){
        x=r*x-D;
        cout << x << endl;
    }

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 


void solve(){
   int a, b;
   cin >> a >> b;
   int ret =  (a + b) / 2 ;
   if (( a + b) % 2 == 1) cout << "IMPOSSIBLE" << endl;
   else cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
 string s;
 cin >> s;
 if(s.compare("SUN")==0)
 cout << "7";
 else if(s.compare("MON")==0)
 cout << "6";
 else if(s.compare("TUE")==0)
 cout << "5";
 else if(s.compare("WED")==0)
 cout << "4";
 else if(s.compare("THU")==0)
 cout << "3";
 else if(s.compare("FRI")==0)
 cout << "2";
 else
 cout << "1";
 return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

double cotan(double i) {
    return  1.0/ tan(acos(-1)/180.0*i);
}

int main() {
    fast();
    int n;cin>>n;
    if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)cout<<"hon";
    else  if(n%10==8||n%10==6||n%10==1||n%10==0)cout<<"pon";
    else cout<<"bon";

}

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

using namespace std;
typedef long long ll;

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

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {

    ll n;
    cin >> n;
    vector<ll> a(n);

    rep(i, n) cin >> a[i];
    vector<ll> d;

    rep(i, n) {
        auto itr = lower_bound(d.rbegin(), d.rend(), a[i]);
        if (itr == d.rbegin()) {
            d.emplace_back(a[i]);
        } else {
            itr--;
            *itr = a[i];
        }
    }
    cout << d.size() << endl;
    return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long int
#define inf 1450000090
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sdl(x) scanf("%lld",&x)
#define nax 100010
#define mp make_pair
#define sz(x) (int)(x.size())
#define pl pair <ll , ll>
#define pii pair < int , pair <int ,int > >
#define MOD 1000000007
using namespace std;
int arr[55][30];
int main(int argc, char const *argv[])
{
  //freopen("input.txt","read",stdin);
  //freopen("output.txt","write",stdout);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
  {
  	string str;
  	cin >> str;
  	int l = str.length();
  	for (int j = 0; j < l; ++j)
  	{
  		arr[i][str[j]-'a']++;
  	}
  }
  string ans = "";
  for (int i = 0; i < 26; ++i)
  {
  		int mi = 1000000;
  		for (int j = 0; j < n; ++j)
  		{
  			mi = min(mi,arr[j][i]);
  		}
  		for (int j = 0; j < mi; ++j)
  		{
  			ans+=(char)('a'+i);
  		}
  }
  cout << ans << '\n';
  return 0;
}

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

int main() {
    int x, k, q, r[100000], t, y;
    cin >> x >> k;
    for(int i = 0; i < k; i++) cin >> r[i];
    cin >> q;
    int a{0}, b{x}, c{0}, s{0}, u{0}, v{-1};
    auto f = [](int m, int z, int n) { return max(m, min(n, z)); };
    while(q--) {
        cin >> t >> y;
        for(; u < k && r[u] <= t; s = r[u++], v *= -1) {
            c = f(-b, c + (r[u] - s) * v, x - a);
            a = f(a, 0 - c, b);
            b = f(a, x - c, b);
        }
        cout << f(0, f(a, y, b) + c + (t - s) * v, x) << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

int main(void){
	int h=in(),w=in(),c[10][10],i,j,a,ans=0,k;
	rep(i,10)rep(j,10)c[i][j]=in();
	rep(k,10)rep(i,10)rep(j,10)if(c[i][j]>c[i][k]+c[k][j])c[i][j]=c[i][k]+c[k][j];
	rep(i,h)rep(j,w){
		a=in();
		if(a>=0)ans+=c[a][1];
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


int main()
{
	int k,n;
	cin >> k >> n;
	int tmp;
	vector<bool> use(101, true);
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		use[tmp] = false;
	}
	
	int value = k;
	int dis = 0;
	while (true) {
		if (use[value - dis]) {
			printf("%d", value - dis);
			break;
		}
		if (use[value + dis]) {
			printf("%d", value + dis);
			break;
		}
		dis++;
	}

	return 0;
}



Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#define FOR(i,beg,n) for(int i=beg;i<n;i++)
#define ll long long
using namespace std;
const long long mod = 1e9+7;

vector<vector<long long>> multiply(vector<vector<long long>>&a, vector<vector<long long>>&b, long long n)
{
	vector<vector<long long>>ans(n,vector<long long>(n));
	
	FOR(i,0,n)
	{
		FOR(j,0,n)
		{
			FOR(k,0,n)
			{
				ans[i][k] = (ans[i][k] + (a[i][j]*b[j][k])%mod)%mod;
			}
		}
	}		
	return ans;
}

vector<vector<long long>> mat_exp(vector<vector<long long>>a, long long pow, long long n)
{
	vector<vector<long long>>ans(n,vector<long long>(n));
	FOR(i,0,n)
		ans[i][i]=1ll;
			
	while(pow>0)
	{
		if(pow&1)
			ans = multiply(ans,a,n);
		
		a = multiply(a,a,n);
		pow=pow/2;
		
	}
	
	return ans;
}


int main()
{
	long long n,k;
	cin>>n>>k;
	
	vector<vector<long long>>adj(n,vector<long long>(n,0));
	FOR(i,0,n)
	{
		FOR(j,0,n)
		{
			cin>>adj[i][j];
		}
	}
	long long x=0ll;
	
	
	
	vector<vector<long long>>ans = mat_exp(adj,k,n);

	
	FOR(i,0,n)
	{
		FOR(j,0,n)
		{
			x = (x+ans[i][j])%mod;
// 			cout<<ans[i][j]<<" ";
		}
// 		cout<<endl;
	}
	cout<<x<<endl;
}


Measured memory_bytes: 3724
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        string s = Console.ReadLine();
        string ans = "";
        for(int i = 0;i < s.Length;i++){
            if(s[i] == 'B'){
                if(ans.Length > 0){
                    ans = ans.Substring(0,ans.Length - 1); 
                }
            }else{
                ans += s[i].ToString();
            }
        }
        Console.WriteLine(ans);
    }
}

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

int main()
{
    int n;
     cin >> n;
     int ans = 1000 - (n % 1000);
     if(ans == 1000) ans = 0;
     cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var a, b, k, res int64

	fmt.Scan(&a, &b, &k)
	switch {
	case a > k:
		res = a - k
		fmt.Printf("%d %d", res, b)
		return
	case a < k:
		res = k - a
		if b-res > 0 {
			fmt.Printf("%d %d", 0, b-res)
			return
		} else {
			fmt.Printf("%d %d", 0, 0)
			return
		}
	default:
		fmt.Printf("%d %d", 0, b)
	}
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string t; cin >> t;
    for(int i=0; t[i]; i++){
        if(t[i]=='?') t[i] = 'D';
    }

    cout << t << ln;
    return 0;
}

Measured memory_bytes: 3708
#include<stdio.h>
long long int gcd(long long int a,long long int b){
  long long int i;
  while(a!=0 && b!=0){
    i=b;
    b=a%b;
    a=i;
  }
  return a;
}

int main(){
  long long a,b,c;
  scanf("%lld%lld",&a,&b);
  c=a*b/gcd(a,b);
  printf("%lld\n",c);
  return 0;
}


Measured memory_bytes: 256