akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int (i)=int (a);i<=int (b);i++)
#define ff(i,a,b) for(int (i)=int(a);i<int (b);i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
const double eps=1e-5;
const double pi=acos(-1.0);
const int N=1e6+6,inf=1<<30;
pii p[N];
int x[N],l[N];
int n;
int main(){
	scanf("%d",&n);
	ff(i,0,n){
		scanf("%d%d",x+i,l+i);
	}
	ff(i,0,n){
		p[i]={x[i]+l[i],x[i]-l[i]};
	}
	sort(p,p+n);
	int ans=0;
	int cur=-inf;
	ff(i,0,n){
		if(cur<=p[i].se){
			ans++;
			cur=p[i].fi;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 5304
#include<iostream>
using namespace std;
int main()
{
	int n;
	int h, m;
	cin >> n;
	h = n / 3600;
	n = n % 3600;
	m = n / 60;
	n = n % 60;
	cout << h<<":"<<m<<":"<<n << endl;
	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
using namespace std;

#define INF 1e9
#define rep(i,j,n) for(int (i)=(j);(i)<(n);(i)++)
#define rep2(i,j,n) for(int (i)=(j);(i)<=(n);(i)++)
#define all(i) (i).begin(),(i).end()
#define rall(i) (i).rbegin(),(i).rend()

typedef long long i64;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<vs> vvs;

int n;
vi a,b,c;

int main(){
  cin>>n;
  a.resize(n);
  rep(i,0,n) cin>>a[i];
  sort(all(a));
  b.resize(n);
  rep(i,0,n) cin>>b[i];
  sort(all(b));
  c.resize(n);
  rep(i,0,n) cin>>c[i];
  sort(all(c));

  i64 ans=0;
  rep(i,0,n){
    i64 acou=lower_bound(all(a),b[i])-a.begin();
    i64 ccou=n-(upper_bound(all(c),b[i])-c.begin());
    ans+=max(0ll,acou*ccou);
  }
  cout<<ans<<endl;
}


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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  long long ans[2] = {}, sum[2] = {};
  for (int i = 0; i < n; i++)
    if (i % 2 == 0)
    {
      sum[0] += a[i];
      if (sum[0] < 1)
      {
        ans[0] += -sum[0] + 1;
        sum[0] = 1;
      }
      sum[1] += a[i];
      if (-1 < sum[1])
      {
        ans[1] += sum[1] + 1;
        sum[1] = -1;
      }
    }
    else
    {
      sum[0] += a[i];
      if (-1 < sum[0])
      {
        ans[0] += sum[0] + 1;
        sum[0] = -1;
      }
      sum[1] += a[i];
      if (sum[1] < 1)
      {
        ans[1] += -sum[1] + 1;
        sum[1] = 1;
      }
    }
  cout << min(ans[0], ans[1]) << endl;

  return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()




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

	int d, t, s;
	cin >> d >> t >> s;

	cout << (d <= t * s ? "Yes" : "No") << endl;


	return 0;
}


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


int main(void){
    // Your code here!
    int N;
    cin >> N;
    int b;
    int a[N];
    bool f[N];
    
    
    
    
    for(int i = 0; i < N ;i++){
        cin >> b;
        a[i] = b-1;
        f[i] = true; 
    }
    
    int cont = 0;
    for(int i = 0; i < N;i++){
        if(f[i]&& a[a[i]] == i){
            cont++;
            f[a[i]] = false; 
        }
    }
    
    cout << cont << endl;
    

}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

vector<lli> hBase[400000];
vector<lli> wBase[400000];
map<pair<lli,lli>,lli> cnt;

void func(long long H, long long W, long long M, std::vector<long long> h, std::vector<long long> w){

    lli ansH = 0;
    lli ansW = 0;
    lli nowH,nowW;
    REP(i,0,H){
        if(chmax(ansH,(lli)hBase[i].size()))nowH = i;
    }
    REP(i,0,W){
        if(chmax(ansW,(lli)wBase[i].size()))nowW = i;
    }
    set<lli> targetH,targetW;
    REP(i,0,H){
        if(hBase[i].size()==ansH)targetH.insert(i);
    }
    REP(j,0,W){
        if(wBase[j].size()==ansW)targetW.insert(j);
    }
    for(auto hi:targetH){
        for(auto wi:targetW){
//    REP(i,0,targetH.size()){
  //      REP(j,0,targetW.size()){
            if(cnt[{hi,wi}]==0){
                cout<<ansW+ansH<<endl;
                return;
            }
        }
    }
                cout<<ansH+ansW-1<<endl;
                return;
}

int main(){
    // cout << fixed << setprecision(5);
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> h(M);
    std::vector<long long> w(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&h[i]);
        scanf("%lld",&w[i]);
        h[i]--,w[i]--;
        hBase[h[i]].push_back(w[i]);
        wBase[w[i]].push_back(h[i]);
        cnt[{h[i],w[i]}]=1;
    }
    func(H, W, M, std::move(h), std::move(w));
    return 0;
}


Measured memory_bytes: 92140
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){

  string s;
  cin >> s;
  ll A_co=0;
  string prev;
  ll ans=0;
  int flag=0;
  for(auto i : s){
    //最初
    if(flag==0){
      flag=1;
      if(i == 'A'){
	A_co++;
      }
    }
    //それ以降
    else if(i == 'A' && (prev == "A" || prev == "C")){
      A_co++;
    }
    else if (i == 'A' && prev == "B"){
      A_co=1;
    }
    else if(i == 'B' && (prev == "A" || prev == "C")){

    }
    else if(i == 'C' && prev == "B"){
      ans+=A_co;
    }
    else{
      A_co=0;
    }
    if(i == 'A') prev = "A";
    if(i == 'B') prev = "B";
    if(i == 'C') prev = "C";
    
  }
    cout << ans << endl;

  return 0;

}


Measured memory_bytes: 640
#include<iostream>
#include<complex>
#include<math.h>
using namespace std;

typedef complex<double> xy_t;
double x[4], y[4];

const double EPS = 1e-11;
int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 4; j++) {
            cin >> x[j] >> y[j];
        }
        if (abs((y[1] - y[0])*(x[3] - x[2]) - (y[3] - y[2])*(x[1] - x[0])) < EPS)
            cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>
int main(void)
{
    int a,b;
    
    scanf("%d",&a);
    scanf("%d",&b);
    
    if(a < b){
        printf("a < b\n");
    }
    else if(a > b){
        printf("a > b\n");
    }
    else {
        printf("a == b\n");
    }
    return 0;
    }


Measured memory_bytes: 2068
#include <stdio.h>

int isPrime(int n){
    if(n==2)return 1;
    for(int i=2;i*i<=n;i++)if(n%i==0)return 0;
    return 1;
}

int main(void){
    const int  yamada = 1e9+7;
    int N;
    scanf("%d",&N);
   // for(int i=0;i<1145140;i++)prime[i]=1;
   // prime[1]=0;
   // prime[2]=1;
    //for(int i=3;i<1145140;i++)for(int j=2;j*j<=i;j++){if(i%j==0)prime[i]=0;}
    long long int po[2];
    po[0]=1;
    po[1]=0;
    int a[N+2];
    a[0]=1;
    a[1]=1;
    for(int i=2;i<N+2;i++){scanf("%d",&a[i]);
        long long int kari[2];
        kari[0]=po[0];
        kari[1]=po[1];
        po[0]=isPrime(a[i])*((a[i-1]<a[i])*kari[0]+(a[i-2]<a[i])*kari[1]);
        po[0]%=yamada;
        if(i>2)po[1]=kari[0];
        po[1]%=yamada;
       // printf("%lld %lld\n",po[0],po[1]);
    }
    po[0]+=po[1];
    po[0]%=yamada;
    printf("%lld\n",po[0]);
    return 0;
}



Measured memory_bytes: 2188
var lines = []; var N = 0; var result = Infinity;

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
})

rl.on('line', function (x) {
    lines.push(x);
});

rl.on("close", function () {
    N = Number(lines[0]);

    var dp = Array(Math.max(N, Math.pow(9, 5))).fill(0);

    dp[0] = 0;
    dp[1] = 1;
    dp[Math.pow(6, 1)] = 1; dp[Math.pow(6, 2)] = 1; dp[Math.pow(6, 3)] = 1; dp[Math.pow(6, 4)] = 1; dp[Math.pow(6, 5)] = 1; dp[Math.pow(6, 6)] = 1;
    dp[Math.pow(9, 1)] = 1; dp[Math.pow(9, 2)] = 1; dp[Math.pow(9, 3)] = 1; dp[Math.pow(9, 4)] = 1; dp[Math.pow(9, 5)] = 1;


    for (var index = 1; index <= N; index++) {
        var a = Infinity;
        var b = Infinity, c = Infinity, d = Infinity, e = Infinity, f = Infinity; g = Infinity;
        var h = Infinity, i = Infinity, j = Infinity, k = Infinity, l = Infinity

        if (1 <= index) a = dp[index - 1] + dp[1];

        if (Math.pow(6, 1) <= index) b = dp[index - Math.pow(6, 1)] + dp[Math.pow(6, 1)];
        if (Math.pow(6, 2) <= index) c = dp[index - Math.pow(6, 2)] + dp[Math.pow(6, 2)];
        if (Math.pow(6, 3) <= index) d = dp[index - Math.pow(6, 3)] + dp[Math.pow(6, 3)];
        if (Math.pow(6, 4) <= index) e = dp[index - Math.pow(6, 4)] + dp[Math.pow(6, 4)];
        if (Math.pow(6, 5) <= index) f = dp[index - Math.pow(6, 5)] + dp[Math.pow(6, 5)];
        if (Math.pow(6, 6) <= index) g = dp[index - Math.pow(6, 6)] + dp[Math.pow(6, 6)];

        if (Math.pow(9, 1) <= index) h = dp[index - Math.pow(9, 1)] + dp[Math.pow(9, 1)];
        if (Math.pow(9, 2) <= index) i = dp[index - Math.pow(9, 2)] + dp[Math.pow(9, 2)];
        if (Math.pow(9, 3) <= index) j = dp[index - Math.pow(9, 3)] + dp[Math.pow(9, 3)];
        if (Math.pow(9, 4) <= index) k = dp[index - Math.pow(9, 4)] + dp[Math.pow(9, 4)];
        if (Math.pow(9, 5) <= index) l = dp[index - Math.pow(9, 5)] + dp[Math.pow(9, 5)];

        dp[index] = Math.min(a, b, c, d, e, f, g, h, i, j, k, l);
    }

    console.log(dp[N]);
});


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

int main() {
  int N, A;
  cin >> N >> A;

  if (N > 500) {
    if (N % 500 > A) {
      cout << "No" << endl;
    }
    else if (N % 500 <=A) {
      cout << "Yes" << endl;
    }
  }
  else if (N <= 500) {
    if (N <= A) {
      cout << "Yes" << endl;
    }
    else if (N > A) {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    char c;
    cin >> c;
    if (c - 'a' < 0)
    {
        cout << 'A' << endl;
    }
    else
    {
        cout << 'a' << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double ans;
  double pi = acos(-1);
  if(a*a*b/2 >= x){
    ans = x*2/a/b/b;
    ans = atan(ans);
    ans = pi/2 - ans;
  }else{
    x = a*a*b-x;
    ans = x*2/a/a/a;
    ans = atan(ans);
  }
  ans = ans*180/pi;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 4100
var A,F:array[0..1000003] of longint;
     i,n,a1,b:longint; f1:text;

 BEGIN
  assign(f1,''); reset(f1);
  readln(f1,n);
  for i:=1 to n do read(f1,A[i]);
  F[1]:=0;
  F[2]:=abs(A[1]-A[2]);
  for i:=3 to n do
   BEGIN
      a1:=F[i-1]+abs(A[i-1]-A[i]);
      b:=F[i-2]+abs(A[i-2]-A[i]);
      if a1<b then F[i]:=a1 else F[i]:=b;
   END;
  write(F[n]);
  close(f1);
 END.




Measured memory_bytes: 4608
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	vl x(N);
	vl y(N);
	rep(i, N)
		cin >> x[i] >> y[i];
	ll pmax = -InfLL;
	ll pmin = InfLL;
	ll mmax = -InfLL;
	ll mmin = InfLL;
	rep(i, N) {
		pmax = max(pmax, x[i] + y[i]);
		pmin = min(pmax, x[i] + y[i]);
		mmax = max(mmax, x[i] - y[i]);
		mmin = min(mmin, x[i] - y[i]);
	}
	ll ans = 0;
	rep(i, N) {
		ll p = x[i] + y[i];
		ll m = x[i] - y[i];
		ans = max(ans, abs(p - pmax));
		ans = max(ans, abs(p - pmin));
		ans = max(ans, abs(m - mmax));
		ans = max(ans, abs(m - mmin));
	}


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

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main(){
  int n,a,b;cin>>n>>a>>b;
  int ansMIN=(a+b<n?0:a+b-n);
  cout<<((a<=b)?a:b)<<" "<<ansMIN<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>

const int64_t cc = pow( 10, 9 ) + 7;

bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.second > another.second;
}

int main()
{
    int64_t b,c,d;
    char a;
    std::cin>> a;
    a += 1;
    std::cout<< a;
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> AB(N);
    rep(i, N) {
        cin >> AB[i].first >> AB[i].second;
    }

    sort(all(AB));

    ll ans = 0;
    int iAB = 0;
    priority_queue<pair<int, int>> pq;
    for (int d = 1; d <= M; ++d) {
        while (iAB < N && AB[iAB].first <= d) {
            pq.emplace(AB[iAB].second, AB[iAB].first);
            iAB++;
        }

        if (!pq.empty()) {
            ans += pq.top().first;
            pq.pop();
        }
    }
    
    write(ans);
}

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

int a[200010],b[200010];

inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}

inline void writeln(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
     puts("");
}

signed main(){
    int n=read();
    for(int i=1;i<=n;i++)
        a[i]=read();
        
    int res=0;
    
    for(int i=1;i<=n;i++){
        res^=a[i];
    }
    
    for(int i=1;i<=n;i++){
        cout<<(res^(a[i]))<<' ';
    }
    
    puts("");
    return 0;
}

Measured memory_bytes: 4284
import java.util.*;

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

	void calc(){
		Scanner cin = new Scanner(System.in);
		while(true){
			int n = cin.nextInt();
			if(n==0) break;
			int ret = 0;
			for(int i=2;i<=n;i++){
				int min = (int)((double)n/i - 0.5 * (i-1) + 1e-6);
				if(min > 0 && min * i + i * (i-1) /2 == n){
					ret++;
				}
			}
			System.out.println(ret);
		}
	}
}

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

int main(void){
    int n,m;
    cin>>n>>m;
    string a[n],b[m];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++) cin>>b[i];
    
    for(int j=0;j+m-1<n;j++){
        for(int i=0;i+m-1<n;i++){
            for(int k=0;k<m;k++){
                if(a[i+k].substr(j,m)!=b[k]) break;
                if(k==m-1){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

void setDigits(int n,int a[])
{
	for(int i=4;i>=0;i--)
	{
		a[i] = n%10;
		n /= 10;
	}
}

int main()
{
	int A,B;
	int digits[5];
	int counter = 0;

	cin >> A >> B;

	for(int i=A;i<B+1;i++){
		setDigits(i,digits);
		if(digits[0] == digits[4] && digits[1] == digits[3])
		{
			counter++;
		}
	}

	cout << counter << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int x;
    cin >> x;
    int ans = 0;
    bool flag = true;
    for (int b = 1; ; b++) {
        for (int p = 2; p <= 10; p++) {
            int t = pow(b, p);
            if (t > x) {
                if (p == 2) {
                    flag = false;
                    break;
                }
                continue;
            }
            ans = max(ans, t);
        }
        if (!flag) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 *  author : Atul Anand   
 *  created on : Tue Mar 31 2020
 */

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

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        int X[] = new int[N];
        read(X, N);
        int min = Arrays.stream(X).min().getAsInt();
        int max = Arrays.stream(X).max().getAsInt();
        int ans = MAX;
        for(int i = min; i <= max; i++){
            int stamina = 0;
            for(int j = 0; j < N; j++){
                stamina += Math.abs(i - X[j]) * Math.abs(i - X[j]);
            }
            ans = Math.min(ans, stamina);
        }
        println(ans);
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 28500
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
        mut x:Chars,
    }
    x.reverse();
    let mut basecount = 0i64;
    for &c in x.iter() {
        if c == '1' {
            basecount += 1;
        }
    }
    let mut dp = vec![0; MX as usize];
    for i in 0..MX as usize {
        if i == 0 {
            dp[0] = 0;
        }
        if i == 1 {
            dp[1] = 1;
        } else {
            let mut tmp = i;
            let mut cnt = 0;
            while tmp > 0 {
                // dbg!(tmp, tmp.count_ones());
                tmp %= tmp.count_ones() as usize;
                cnt += 1;
            }
            dp[i] = cnt;
        }
    }
    if n == 1 {
        if x[0] == '1' {
            println!("{}", 0);
            return;
        } else {
            println!("{}", 1);
            return;
        }
    }

    // dbg!(&dp);

    let mut fbasep = 0;
    let mut fbasen = 0;
    for i in 0..n {
        if basecount == 0 {
            break;
        }
        if x[i] == '1' {
            fbasep += mod_pow(2, i as i64, basecount + 1);
            if basecount > 1 {
                fbasen += mod_pow(2, i as i64, basecount - 1);
            }
        }
        // fbase %= basecount;
    }
    // println!("{}", fbase);

    for i in (0..n).rev() {
        let mut bc = basecount;
        if basecount == 0 {
            println!("{}", 1);
            continue;
        }
        let mut pn = 1i64;
        if x[i] == '1' {
            pn = -1;
        } else {
            pn = 1;
        }
        bc += pn;
        if pn == 1 {
            let mut b = fbasep + mod_pow(2, i as i64, bc);
            b %= bc;
            println!("{}", dp[b as usize] + 1);
        } else {
            if bc == 0 {
                println!("{}", 0);
                continue;
            }
            if bc == 1 {
                println!("{}", 1);
                continue;
            }
            let mut b = fbasen + bc - mod_pow(2, i as i64, bc);
            b %= bc;
            println!("{}", dp[b as usize] + 1);
        }
    }
    // for i in 0..10 {
    //     dbg!(i, dp[i]);
    // }
}
const MX: i64 = 1000100;
const INF: i64 = 1 << 60;
/// x ^ n % m
pub fn mod_pow(x: i64, n: i64, m: i64) -> i64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}


Measured memory_bytes: 7080
eval'A=#'+`tr ' ' ,`
c=[g=0]*-~t=10**6
A.map{c[_1]+=1
g=g.gcd _1}
print g>1?:not:(2..t).any?{|i|(1..t/i).sum{c[_1*i]}>1}?:setwise: :pairwise," coprime"

Measured memory_bytes: 139164
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(), b = sc.nextLong();
        long ans;
        if(a >= 2 && b >= 2) ans = (a-2) * (b-2);
        else ans = Math.abs(Math.max(a, b) - 2);
        System.out.println(ans);
    }
}

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

int main () {
  int N, T;
  cin >> N >> T;
  int c[N], t[N];
  int answer = 10001;
  bool ok = true;
  for (int i = 0; i < N; i++) {
    cin >> c[i] >> t[i];
    if (T >= t[i]) {
      ok = false;
      if (answer >= c[i]) {
        answer = c[i];  
      }
    }
    if (i == N - 1 && ok == true) {
      cout << "TLE" << endl;
      return 0;  
    }  
  }  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,n,a,m,c1,c2,wa[105000];
bool ac[105000];
string s;
// map<long long,string> r;
int main(){
  for(cin>>n>>m;i<n;i++){
    ac[i]=false;
  }
  while(m--){
    int p;
    cin>>p>>s;
    if(ac[p])continue;
    if(s=="AC"){
      ac[p]=true;
      c1++;
      c2+=wa[p];
    }else{
      wa[p]++;
    }
  }
  cout<<c1<<" "<<c2;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define mp make_pair
#define ft first
#define sd second
#define ue printf("what?\n");
#define pb push_back
#define oo 0x3F3F3F3F	
#define OO 3000000000000000000LL
#define EPS 0
#define maxn 200000
#define pi acos(-1)
#define mod 1000000007
#define mdc __gcd
#define N 600005
#define M 20
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

main()
{
	map<int, ll> mapa;
	mapa[0]++;
	int n, m, at, aux, i;
	scanf("%d%d", &n, &m);
	at = 0;
	ll ans = 0;
	for(i=0; i<n; i++)
	{
		scanf("%d", &aux);
		at += aux, at %= m;
		ans += mapa[at];
		mapa[at]++;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 4224
from fractions import gcd

def inpl(): return list(map(int, input().split()))
N, A, B, C = inpl()

MOD = 10**9 + 7
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

size = 2*100000 + 1
g1, g2, inverse = [0]*size, [0]*size, [0]*size

g1[:2] = [1, 1] # 元テーブル
g2[:2] = [1, 1] #逆元テーブル
inverse[:2] = [0, 1] #逆元テーブル計算用テーブル
 
for i in range(2, size):
    g1[i] =  ( g1[i-1] * i ) % MOD 
    inverse[i] = (-inverse[MOD % i] * (MOD//i) ) % MOD 
    g2[i] =  (g2[i-1] * inverse[i]) % MOD

P = 0
Q = pow(100-C, 2*N, MOD)*(100-C)%MOD

for x in range(N):
    P = (P + cmb(N+x-1, x, MOD) * (N+x) * pow(100-C, N-x, MOD) * (pow(inverse[A], N-x, MOD) + pow(inverse[B], N-x, MOD)))%MOD
P = P*100*pow(A, N, MOD)*pow(B, N, MOD)%MOD

gcd_ = gcd(P, Q)
P = P//gcd_
Q = Q//gcd_

if A*B == 0:
    print(N*100*pow(100-C, MOD-2, MOD)%MOD)
else:
    print(P*pow(Q, MOD-2, MOD)%MOD)


Measured memory_bytes: 71912
def fill(i,j):
    global Map
    for di,dj in move:
        if 0 <= i+di < a and 0 <= j+dj < b and not Map[i+di][j+dj] == '#':
            Map[i+di][j+dj] += 1
            fill(i+di,j+dj)

move = [(1,0),(0,1)]
while True:
    a,b = map(int,input().split())
    if (a,b) == (0,0):
        break
    Map = [[0]*b for _ in range(a)]
    n = int(input())
    objects = []
    for _ in range(n):
        objects.append(tuple(map(int,input().split())))
    for i,j in objects:
        Map[i-1][j-1] = '#'
    fill(0,0)
    print(Map[a-1][b-1])


Measured memory_bytes: 5620
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
  int N;
  int RedSum = 0;
  int Sum = 0;
  string str;
  cin >> N;
  cin >> str;
  for(int i = 0;i < N;i++)
  {
    if(str[i] == 'R')
    {
      RedSum++;
    }
  }
  for(int j = 0; j < RedSum; j++)
      {
    if(str[j] == 'R')
    {
      Sum++;
    }
  }
  cout << RedSum-Sum << endl;
  return 0;
}

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

int main() {
    int N;
    ll M;
    cin >> N >> M;
    // int M2 = M;

    // map<int, int> mp;  // 素因数、個数
    // for (int i = 2; i * i <= 1000000000; i++) {
    //     while (M % i == 0) {
    //         mp[i]++;
    //         M /= i;
    //     }
    // }
    // if (M != 1) mp[M]++;

    // int res = 1;
    // for (auto p : mp) {
    //     int prime = p.first;
    //     int num = p.second;
    //     printf("prime, num = %d, %d\n", prime, num);
    //     // while (num >= N) {
    //     //     res *= prime;
    //     //     num -= N;
    //     // }
    //     for (int i = 0; i < num; i++) {
    //         int now = res * prime;
    //         if ((M2 / now) >= N) {
    //             res *= prime;
    //         }
    //         else {
    //             break;
    //         }
    //     }
    // }

    vector<ll> div;
    div.push_back(1);
    for (int i = 2; i * i <= M; i++) {
        if (M % i == 0) {
            div.push_back(i);
            if (i != (M/i)) {
                div.push_back(M/i);
            }
        }
    }
    div.push_back(M);

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

    ll res = 0;
    // for (int i = div.size() - 1; i >= 0; i--) {
    rep(i, div.size()) {
        if ((M / div[i]) >= N) {
            res = div[i];
            break;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3548
N = int(input())
arr = list(map(int, input().split()))

ans = 0
skip = False
for i in range(N):
    if skip:
        skip = False
        continue
    if arr[i] == i+1:
        ans += 1
        if i == N-1: break
        if arr[i+1] == i+2:
            skip = True
            continue
print(ans)


Measured memory_bytes: 13880
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
  `(let ((it ,expr))
     (if it ,then ,else)))

(defmacro awhen (expr &rest then)
  `(aif ,expr (progn ,@then) nil))

(defun comulative (function list &key base)
  (if base
      (comulative function (cons base list))
      (do ((lst (cdr list) (cdr lst))
           (acc (list (car list))))
          ((null lst) (reverse acc))
        (push (funcall function (car acc) (car lst)) acc))))

(defun binary-search (function left right
                      &optional
                        (eps 1)
                        (average-function (lambda (x y) (ash (+ x y) -1))))
  (if (<= (abs (- left right)) eps)
      right
      (let ((mid (funcall average-function left right)))
        (if (funcall function mid)
            (binary-search function left mid eps average-function)
            (binary-search function mid right eps average-function)))))

(defun arithmetic-mean (&rest body)
  (/ (apply #'+ body) (length body)))

(defvar +MOD+ (+ (expt 10 9) 7))

(defun mapa-b (fn a b &optional (step 1))
  (do ((i a (+ i step))
       (result nil))
      ((> i b) (nreverse result))
    (push (funcall fn i) result)))

(defun map0-n (fn n)
  (mapa-b fn 0 n))

(defun map1-n (fn n)
  (mapa-b fn 1 n))

(defun read-string (&optional (stream *standard-input*))
  (labels ((is-empty (x)
             (or (char= x #\space) (char= x #\newline))))
    (loop for char = (read-char stream)
          with result
          when (is-empty char)
            do (return (concatenate 'string (nreverse result)))
          do (push char result))))

(defun char-integer (x)
  (- (char-code x) (char-code #\0)))

(defun main (str)
  (max (apply #'+ (mapcar (lambda (x) (char-integer x)) (coerce str 'list)))
       (+ (char-integer (aref str 0)) (* 9 (length str)) -10)))

(princ (main (read-string)))


Measured memory_bytes: 13876
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
A = [0] + readInts() + [0]
dist = 0
for i in range(len(A)-1):
    dist+=abs(A[i] - A[i+1])

for i in range(1,len(A)-1):
    print(dist - (abs(A[i]-A[i-1]) + abs(A[i+1] - A[i])) + abs(A[i+1] - A[i-1]))


Measured memory_bytes: 22096
// include
// ----------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>

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

// memory clear
// ----------------------------------------------------------------------------
#define CLRNUM(a) memset((a), 0, sizeof(a))
#define CLRBOOL(a, flag) memset((a), flag, sizeof(a))
#define CLRCHAR(a) memset((a), '\0', sizeof(a))

// debug
// ----------------------------------------------------------------------------
#define DEBUGINT(x) printf("%d\n", x);
#define DEBUGFLOAT(x) printf("%f\n", x);
#define DEBUGCHAR(x) printf("%c\n", x);
#define DEBUGSTR(x) printf("%s\n", x);
#define DEBUGFORINT(i, a, b, x) FOR(i, a, b){ printf("%d ", x[i]); }
#define DEBUGFORFLOAT(i, a, b,x ) FOR(i, a, b){ printf("%f ", x[i]); }
#define DEBUGFORCHAR(i, a, b, x) FOR(i, a, b){ printf("%c ", x[i]); }
#define DEBUGREPINT(i, n, x) REP(i, n){ printf("%d ", x[i]); }
#define DEBUGREPFLOAT(i, n, x) REP(i, n){ printf("%f ", x[i]); }
#define DEBUGREPCHAR(i, n, x) REP(i, n){ printf("%c ", x[i]); }

// other
// ----------------------------------------------------------------------------
#define PUTNL printf("\n")

// constant
// ----------------------------------------------------------------------------
#define INF 1000000000

int main(void)
{
    int i, j, k, l;
    char map[10][10];
    char cmap[10][10];

    for (i = 0; i < 8; ++i){
        scanf("%s", map[i]);
    }

    for (i = 1; i < 4; ++i){
        
        for (j = 0; j < 8; ++j){
            strcpy(cmap[j], map[j]);
        }


        for (j = 0; j < 8; ++j){
            for (l = 0, k = 7; l < 8; ++l, --k){
                map[j][l] = cmap[k][j];
            }
        }

        printf("%d\n", i * 90);
 
        for (j = 0; j < 8; ++j){
            printf("%s\n", map[j]);

        }
    }


    return 0;

}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <string>
#include <cctype>
using namespace std;

int main(){
  string str;
  stringstream ss("");
  ss.clear();
  getline(cin, str);
  for(char c : str){
    if(islower(c)){
      ss << (char)toupper(c);
    }else if(isupper(c)){
      ss << (char)tolower(c);
    }else{
      ss << c;
    }
  }
  cout << ss.str() << endl;
  return 0;
}

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


int main() {
	ll H,W,M;cin >> H >> W >> M;
	vector<ll> row(H),col(W);
	set<P> s;
	rep(i,M){
		ll r,c;cin >> r >> c;
		--r;--c;
		row[r]++;
		col[c]++;
		s.insert({r,c});
	}
	ll mrow = 0;
	ll mcol = 0;
	rep(i,H) mrow = max(mrow,row.at(i));
	rep(i,W) mcol = max(mcol,col.at(i));

	vector<ll> is,js;
	rep(i,H) if( mrow == row.at(i) ) is.push_back(i);
	rep(i,W) if( mcol == col.at(i) ) js.push_back(i);

	ll ans = mrow + mcol;
	for(ll i : is ){
		for(ll j : js ){
			// i,jが重ならない(=ansがそのまま)のパターンを探す
			if( s.count({i,j}) ) continue;
			cout << ans <<  endl;
			return 0;
		}
	}
	cout << --ans << endl;
}

Measured memory_bytes: 34984
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int ruisekiwa[4001],num[4001];
	for(int i = 0; i <= 4000; i++)ruisekiwa[i] = 0;

	int N;
	scanf("%d",&N);

	int table[N];

	double tmp;

	for(int i = 0; i < N; i++){
		scanf("%lf",&tmp);
		tmp *= 1000;

		//printf("%.3lf %d\n",tmp,(int)(round(tmp)));

		table[i] = (int)(round(tmp));
		ruisekiwa[(int)(round(tmp))]++;
	}

	for(int i = 0; i <= 4000; i++){
		num[i] = ruisekiwa[i];
	}

	for(int i = 1; i <= 4000; i++){
		ruisekiwa[i] += ruisekiwa[i-1];
	}


	for(int i = 0; i < N; i++){
		if(table[i] == 0){
			printf("%d\n",num[0]-1);
		}else{
			printf("%d\n",3*ruisekiwa[table[i]-1]+(num[table[i]]-1));
		}
	}

	return 0;
}

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

#define ll long long
#define ld long double
#define debug(x) \
	//    (cout << #x << ": " << (x) << endl)
#define eb emplace_back
#define fi first
#define se second

using namespace std;

const int nm = 3002;
const int mod = 998244353;

int n, m, a[nm];
int g[nm][nm];

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
	}
	g[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		g[i][0] = (g[i - 1][0] * 2) % mod;
		for (int j = 1; j <= m; ++j) {
			g[i][j] = (g[i - 1][j] * 2) % mod;
			if (a[i] <= j) {
				g[i][j] = (g[i][j] + g[i - 1][j - a[i]]) % mod;
			}
		}
	}
	printf("%d\n", g[n][m]);
}


Measured memory_bytes: 38984
#include<iostream>
#include<map>
#include<set>
#include<cstring>
#include<algorithm>

using namespace std;

const int N = 200005;
int n, m;
int main()
{
	scanf("%d%d", &n, &m);
	map<int, int> mp;
	multiset<int> v;
	for(int i = 1; i <= m; ++i)
	{
		mp[i] = i;
		v.insert(0);
	}

	for(int i = 1, l, r; i <= n; ++i)
	{
		scanf("%d%d", &l, &r);
		auto it = mp.lower_bound(l);
		int newst = 0;
		while(it != mp.end() && it -> first <= r + 1)
		{
			newst = max(newst, it -> second);
			v.erase(v.find(it->first - it->second));
			it = mp.erase(it);
		}
		if(newst && r < m)
		{
			mp[r + 1] = newst;
			v.insert(r + 1 - newst);
		}
		if(v.size())
			printf("%d\n", *v.begin() + i);
		else puts("-1");
	}
	return 0;
}


Measured memory_bytes: 22488
/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define fst first
#define scd second
#define pb push_back
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///===================================================================

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    if(n%10==3){
        cout<<"bon";
        exit(0);
    }
    if(n%10==0 || n%10==1 || n%10==6 || n%10==8  ){
        cout<<"pon";
        exit(0);
    }



    cout<<"hon";
return 0;}





Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<ll,ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const ll N=55;
vint G[N];
ll w[N],v[N],m[N],p[N],n,X,D,f[N*N*N],id[N],ans;
void dfs(ll x){
	w[x]=1,v[x]=m[x];
	for(auto y:G[x])dfs(y),v[x]+=v[y],w[x]+=w[y];
}
signed main(){
	n=read(),X=read(),D=read();
	m[1]=read();for(ll i=2;i<=n;i++)m[i]=read(),p[i]=read(),G[p[i]].pb(i);
	dfs(1);ll maxn=n*n*n,L=min(D,n);memset(f,127,sizeof(f));f[0]=0;
	for(ll i=1;i<=n;i++){
		ll x=L;
		for(ll j=0;1<<j<=x;j++){
			ll W=w[i]*(1<<j),V=v[i]*(1<<j);
			for(ll k=maxn;k>=W;k--)f[k]=min(f[k],f[k-W]+V);
			x-=1<<j;
		}if(x){
			ll W=w[i]*x,V=v[i]*x;
			for(ll k=maxn;k>=W;k--)f[k]=min(f[k],f[k-W]+V);
		}
	}
	for(ll i=1;i<=n;i++)id[i]=i;
	sort(id+1,id+n+1,[](ll a,ll b){return w[a]*v[b]>w[b]*v[a];});
	while(id[n]!=1)n--;
	for(ll i=0;i<=maxn;i++){
		if(f[i]>X)continue;
		ll W=i,V=f[i];
		for(ll j=1;j<n;j++){
			ll x=id[j];
			ll re=min(D-L,(X-V)/v[x]);
			W+=re*w[x],V+=re*v[x];
		}ll re=(X-V)/v[1];
		W+=re*w[1],V+=re*v[1];
		ans=max(ans,W);
	}return cout<<ans,signed();
}
/*
3 100 1 15 10 1 20 1
3 100 10 15 10 1 20 1
5 1000000000 1000000 123 159 1 111 1 135 3 147 3
*/

Measured memory_bytes: 4916
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    vll A(4);
    cin >> A;
    ll ans = 1LL << 60;
    ans *= -1;
    REP(i,2){
        for(int j=2; j<4; j++){
            chmax(ans,A[i]*A[j]);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3624
import bisect

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

A.sort()
B.sort()
C.sort()

res = 0
for b in B:
    res += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))

print(res)


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


def solve(H: int, W: int, h: int, w: int):
    print(H*W-h*W-(H-h)*w)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    h = int(next(tokens))  # type: int
    w = int(next(tokens))  # type: int
    solve(H, W, h, w)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

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

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	LL N, K;
	cin >> N >> K;
	vector<LL> line(N);
	foreach(i, line)cin>>i;
	LL X = 0;
	PER(i, 40){
		if(X+BIT(i)>K)continue;
		int count = 0;
		foreach(j, line)if(BIT(i)&j)++count;
		if(N>count*2)X|=BIT(i);
	}
	LL ans = 0;
	foreach(i, line)ans += X ^ i;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,c,b[20]={},a[20][20]={},ans=0,cnt=0;
  cin >> n >> m >> c;
  for(int i=0; i<m; i++) {
    cin >> b[i];
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      cin >> a[i][j];
    }
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      cnt+=a[i][j]*b[j];
    }
    if(cnt>-1*c) {
      ans++;
    }
    cnt=0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
r = 0
x, y = 0, 0
readlines.each do |l|
  length, angle = l.split(",").map(&:to_i)
  x += length * Math.sin(r)
  y += length * Math.cos(r)
  r += angle * Math::PI / 180
end
puts x.truncate
puts y.truncate

Measured memory_bytes: 6160
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int n, sum, x;
	while(cin >> n, n){
		vector<int> vec;
		for(int i = 0; i < n; i++){
			cin >> x;
			vec.push_back(x);
		}
		sort(vec.begin(), vec.end());

		sum = 0;
		for(vector<int>::iterator it = vec.begin() + 1; it != vec.end() - 1; it++){
			sum += *it;
		}
		cout << sum / (vec.size() - 2) << endl;
	}
}

Measured memory_bytes: 1216