akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

void change(int *i, int *j)
{
  int tmp;
  tmp = *i;
  *i = *j;
  *j = tmp;
}
int main(int argc, char *argv[])
{
  int i, j, k, l;
  int num = 10;
  int heights[num];

  for(i = 0; i < num; i++)
    {
      scanf("%d", &k);
      heights[i] = k;
    }

  for(j = 0; j < num; j++)
    for(k = j + 1; k < num; k++)
      {
	if(heights[j] < heights[k])
	  change(heights + j, heights + k);
      }

  for(l = 0; l < 3; l++)
    printf("%d\n", heights[l]);

  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>


int main(void)
{
	int a, b, c;
	int central;
	int min;
	int max;
	int budget;

	scanf("%d %d %d", &a, &b, &c);

	max = a;
	if (b > max) max = b;
	if (c > max) max = c;

	min = a;
	if (b < min) min = b;
	if (c < min) min = c;

	central = (a + b + c) - (max + min);

	budget = max * 10 + central + min;

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


	return 0;
}



Measured memory_bytes: 128
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<"  "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll fact[1001];
ll inv[10001];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll a[n];
	ll b[n];
	ll maxi=0;
	rep(i,0,n){
		cin >> a[i];
		b[i]=a[i];
		maxi=max(maxi,a[i]);
	}
	sort(b,b+n);
	rep(i,0,n){
		if(a[i]==maxi){
			cout << b[n-2] << "\n";
		}
		else cout << maxi << "\n";
	}
	return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
int main()
{
    long N,M;
    std::cin >> N >> M;
    std::cout << N*(N-1)/2+M*(M-1)/2 << std::endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
bc = []
for _ in range(m): bc.append([int(i) for i in input().split()])
a.sort()
bc.sort(key=lambda x:x[1])
bc = bc[::-1]
idx = 0
for b, c in bc:
    for bi in range(b):
        if idx + bi == n or a[idx+bi] >= c:
            idx = "e"
            break
        else: a[idx+bi] = c
    if idx == "e": break
    else: idx += b
print(sum(a))

Measured memory_bytes: 26692
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<double,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

inline ll mergecount(vector<ll> &a) {
  ll count = 0;
  ll n = a.size();
  if (n > 1) {
    vector<ll> b(a.begin(), a.begin() + n/2);
    vector<ll> c(a.begin() + n/2, a.end());
    count += mergecount(b);
    count += mergecount(c);
    for (ll i = 0, j = 0, k = 0; i < n; ++i)
      if (k == c.size())       a[i] = b[j++];
      else if (j == b.size())  a[i] = c[k++];
      else if (b[j] <= c[k])   a[i] = b[j++];
      else                   { a[i] = c[k++]; count += n/2 - j; }
  }
  return count;
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> a(N,0);
    for(ll i=0;i<N;++i)cin>>a[i];
    if(N==1){
        prt(a[0]);
        return 0;
    }
    ll L=0,R=1000000001;
    //中央値がx以上である区間の個数
    while(R-L>1){
        ll M=(L+R)/2;
        vector<ll> b(N,0);
        for(ll i=0;i<N;++i){if(a[i]>=M)b[i]=1;else b[i]=-1;}
        vector<ll> c(N+1,0);
        for(ll i=0;i<N;++i)c[i+1]=c[i]+b[i];
        ll count=N*(N+1)/2-mergecount(c);
        if(count<N*(N+1)/4)R=M;
        else L=M;
    }
    prt(L);fl
    return 0;
}



Measured memory_bytes: 7148
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();

    int rgb = 100*r+10*g+b;
    if (rgb%4==0) {
      System.out.println("YES");
    }
    else{
      System.out.println("NO");
    }

  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;
#define out(i) cout<<(i)<<endl

vector<ll> primevector(ll N){
    vector<ll> data(1);
    data[0]=2;
    for(ll i=3;i<N;i++){
        ll cnt=0;
        for(ll j=0;j<data.size();j++){
            if(i%data[j]==0){cnt++;break;}
        }
        if(cnt==0){data.push_back(i);}
    }
    return data;
}

int main() {
  ll N;
  cin>>N;
  vector<ll> vec(N),primelist;
  rep0(i,N){cin>>vec[i];}
  sort(all(vec));
  ll cnt=0;
  primelist=primevector(10000);
  rep0(i,N){
      bool flag=true;
      rep0(j,primelist.size()){
          if(vec[i]>primelist[j]&&vec[i]%primelist[j]==0){flag=false;break;}
      }
      if(flag){cnt++;}
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3248
N=int(input())
M=int(input())
A=list(map(int,input().split()))
L=list()
S=[0]*N
for i in range(M):
  L=list(map(int,input().split()))
  for j in range(N):
    if L[j]==A[i]:
      S[j]=S[j]+1
    else:
      S[A[i]-1]=S[A[i]-1]+1
for i in range(N):
  print(S[i])


Measured memory_bytes: 5624
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> data(n);
    for (int i = 0; i < n; i++)
        cin >> data[i];
    
    int count[4] = {0};
    for (int i = 0; i < n; i++){
        if (data[i] == "AC")
            count[0]++;
        if (data[i] == "WA")
            count[1]++;
        if (data[i] == "TLE")
            count[2]++;
        if (data[i] == "RE")
            count[3]++;
    }
    cout << "AC x " << count[0] << endl;
    cout << "WA x " << count[1] << endl;
    cout << "TLE x " << count[2] << endl;
    cout << "RE x " << count[3] << endl;
        
    return 0;
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
void printvec(vi& x, int size = 0) {
    cout << x.front();
    for (int i = 1; i < (size == 0 ? x.size() : size); i++) {
        cout << " " << x[i];
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    int n;
    cin >> n;
    list<int> lst;
    for (int i = 0; i < n; i++) {
        string cmd;
        cin >> cmd;
        switch (cmd[cmd.size() - 4]) {
            case 's':
            // insert
            int k;
            cin >> k;
            lst.push_front(k);
            break;
            case 'l':
            // delete
            cin >> k;
            for (auto itr = lst.begin(); itr != lst.end(); itr++) {
                if (*itr == k) {
                    lst.erase(itr);
                    break;
                }
            }
            break;
            case 'i':
            // deleteFirst
            lst.pop_front();
            break;
            case 'L':
            // deleteLast
            lst.pop_back();
            break;
        }
    }
    vi outs;
    for (int k: lst) {
        outs.push_back(k);
    }
    printvec(outs);
}


Measured memory_bytes: 33828
import collections
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
A=[]
for i in range(m):
  a,b=map(int,input().split())
  A.append(a)
  A.append(b)
c=collections.Counter(A)
flag=1
for a in c.keys():
  if c[a]%2==1:
    flag=0
print("YES" if flag==1 else "NO")

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

int main() {
    long long n, a, b;
    cin >> n >> a >> b;

    long long q, r, ans;
    q = n / (a + b);
    r = n % (a + b);
    ans = a * q + min(a, r);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int p(int r) {
	int ans = -1;
	for (int i = 10; i <= r; i *= 10) {
		ans = max(ans, ((r - r % i) / i)*(r % i));
	}
	return ans;
}
int main() {
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int k; cin >> k;
		int cnt = 0;
		while (k >= 10) { k = p(k); cnt++; }
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3120
/*やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん

（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。

今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、

そこでしこたま酒を飲んでからやりはじめたんや。

3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。

しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。

浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、

先に兄ちゃんがわしの口に糞をドバーっと出して来た。

それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、

3人で出した糞を手で掬いながらお互いの体にぬりあったり、

糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。

しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。

浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると

けつの穴が糞と小便でずるずるして気持ちが良い。

にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。

糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。

それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、

糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。

やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。

ああ～～早く糞まみれになろうぜ。

岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や

糞まみれでやりたいやつ、至急、メールくれや。

土方姿のまま浣腸して、糞だらけでやろうや。*/
#include "bits/stdc++.h"
#include <numeric>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define llMIN numeric_limits<long long>::min()
#define intMIN numeric_limits<int>::min()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

ll gcd(ll a,ll b){//最大公約数
  if(a<b){
    swap(a,b);
  }
  if (a%b==0){
		return(b);
    }
	else{
		return(gcd(b,a%b));
    }
}
ll lcm(ll a, ll b)
{
  ll numgcd=gcd(a, b);
  ll num1=a/numgcd;
  ll num2=b/numgcd;
    return (num1*num2*numgcd);
}
int main(void){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  int cnt=0;
  rep(i,n-2){
	if(s[i]=='A' &&s[i+1]=='B' &&s[i+2]=='C'  )cnt++;
}
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
<?php
	list( $r, $c ) = explode( ' ', trim( fgets( STDIN ) ) );
	$output = array();
	$total = array_fill( 0, $c+1, 0 );
	while( $r-- ) {
		$rc = explode( ' ', trim( fgets( STDIN ) ) );
		for( $i=0; $i<$c; $i++ ) {
			$total[ $i ] += $rc[ $i ];
		}
		$sum = array_sum( $rc );
		$total[ $c ] += $sum;
		array_push( $rc, $sum );
		array_push( $output, implode( " ", $rc ) );
    }
	array_push( $output, implode( " ", $total ) );
	print implode( "\n", $output );
?>

Measured memory_bytes: 6728
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[int(input()) - 1])


Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <vector>
#include <iomanip>
using namespace std;


int main(){
    // input
    double N, D; cin >> N >> D;

    // compute
    int ans = ceil(N / (D * 2 + 1));

    // output
    cout << ans << endl;
}



Measured memory_bytes: 256
const inputText = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split(/\s/)
  .map(Number);
const left = inputText[0] + inputText[1];
const right = inputText[2] + inputText[3];

if (left < right) {
  console.log("Right");
} else if (left > right) {
  console.log("Left");
} else {
  console.log("Balanced");
}

Measured memory_bytes: 21064
#include <iostream>
using namespace std;
int main()
{
	int n, i, j;
	double x[4], y[4];

	cin >> n;

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 4; j++)
			cin >> x[j] >> y[j];

		if (((y[0]-y[1])/(x[0]-x[1])) == ((y[2]-y[3])/(x[2]-x[3])))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
// Problem : E - Logs
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define mod 998244353
#define bug cout<<"HY"<<endl
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define numize(A) A.numize(unique(A.begin(), A.end()) - A.begin())
typedef pair<int,int> P;
int power(int a,int b)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return (power((a*a)%mod,b/2))%mod;
    return (a*(power((a*a)%mod,b/2))%mod)%mod;
}
int modInv(int n)
{
    return power(n, MOD-2);
}
int nCr(int n, int r, int p=MOD)
{
   if (r==0)
      return 1;
    int Fact[n+1];
    Fact[0] = 1;
    for (int i=1 ; i<=n; i++)
    {
        Fact[i] = (Fact[i-1]*i)%p;
    }
    return (((Fact[n]* modInv(Fact[r])) % MOD) *(modInv(Fact[n-r]) % MOD)) % MOD;
}
double PI=3.14159265359;
void solve()
{
	int n,k,i;
	cin>>n>>k;
	int A[n];
	for(i=0;i<n;i++)
		cin>>A[i];	
	sort(A,A+n);
	int low=1,high=A[n-1],ans=0;
	while(low<=high)
	{
		int mid=(low+high)/2;
		int cnt=0;
		for(i=0;i<n;i++)
		{
			int num=(A[i]-1)/mid;
			cnt+=num;
		}
		if(cnt>k)
		{
			low=mid+1;
		}
		else
		{
			ans=mid;
			high=mid-1;
		}
	}
	cout<<ans<<endl;
}
int32_t main()
{
    boost;
    int  t=1;
    // cin>>t;
    while(t--)
    {
    	solve();
    }
}


Measured memory_bytes: 5064
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int mod = 1e9+7;

int32_t main(){

    int n,m;    cin >> n >> m;
    vector<pair<int,int>> s , c;

    for(int x=0;x<n;x++){
        int a, b;   cin >> a >> b;
        s.push_back({a,b});
    }

    for(int x=0;x<m;x++){
        int a,b;    cin >> a >> b;
        c.push_back({a,b});
    }

    for(int x=0;x<n;x++){
        int dist = 1e18;
        int index = 0;

        for(int t = 0;t<m;t++){
            int curr = abs(c[t].first - s[x].first) + abs(c[t].second - s[x].second);
            if(curr < dist){
                index = t+1;
                dist = curr;
            }
        }

        cout << index << endl;

    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
  int N, X; cin>>N>>X;
  int min_v = X, sum = 0, ans = N;
  for(int i = 0; i < N; i++) {
    int m; cin>>m;
    min_v = min(min_v, m);
    sum += m;
  }
  //cout << X << " " << sum << " " << min_v << endl;
  ans += (X-sum) / min_v;
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    cin>>n;
    int ans=0;
    vector<int> a(n);
    rep(i,n){
        cin>>a.at(i);
        if(i%2==0 && a.at(i)%2!=0) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
//ΔAGC032E
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
int n,m,s,p,a[N];
int main()
{
	int i,l,r,k,o,x,y;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n+n;i=i+1)
		scanf("%d",a+i);
	sort(a+1,a+n+n+1);
	s=0;
	for(i=1;i<=n;i=i+1)
		s=max(s,(a[i]+a[n+n+1-i])%m);
	l=1,r=n-1;
	while(l<=r){
		k=l+r>>1;
		o=0;
		for(i=1;i<=k;i=i+1)
			if(a[i]+a[k+k+1-i]>=m)
				o=1;
		if(o){
			r=k-1;
			continue;
		}
		for(i=1;i<=n-k;i=i+1)
			if(a[k+k+i]+a[n+n+1-i]<m)
				o=1;
		if(o){
			l=k+1;
			continue;
		}
		x=0,y=0;
		for(i=1;i<=k;i=i+1)
			x=max(x,a[i]+a[k+k+1-i]);
		for(i=1;i<=n-k;i=i+1)
			y=max(y,a[k+k+i]+a[n+n+1-i]-m);
		s=min(s,max(x,y));
		r=k-1;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
 
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long int lli;
typedef vector <lli> vlli;
typedef vector <vlli> vvlli;
typedef vector <string> vs;
typedef vector <bool> vb;
 
#define rep(i, n) for( i = 0; i < (n); ++i)
#define repA(i, a, n) for( i = a; i <= (n); ++i)
#define repD(i, a, n) for( i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sortr(x) sort(x.begin(),x.end(),greater <int> ())
#define mod 1000000007
#define ff first
#define ss second
#define fill(a,c)  memset(a, c, sizeof (a))
#define formap(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.first<<" , "<<it.second<<endl;} cerr<<endl
#define PI  3.14159265358979323846
#define pb push_back




int main() {
	cin.sync_with_stdio(0);cin.tie(0);
    cin.exceptions(cin.failbit);
    
    lli i,a,v,b,w,t,ans;
    cin>>a>>v>>b>>w>>t;
    if (v<=w)ans=0;
    else{
        v=v-w;
        a= abs(a-b);
        if (t*v>=a)ans=1;
        else ans=0;
    }
    if (ans==0)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    
    
    
    
    
    
	return 0;
	
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <queue>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int t = a + b;
    int h = a - b;
    int k = a*b;
    int x = max(t, h);
    int y = max(h, k);
    cout << max(x, y) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,dp[100009],ans;
vector<vector<ll> >v;
ll dfs(ll d)
{
    if(dp[d]!=-1)
    return dp[d];
    dp[d]=0;
    for(auto z:v[d])
    dp[d]=max(dp[d],dfs(z)+1);
    return dp[d];
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
v.resize(n+1);
while(m--){
    ll x,y;
    cin>>x>>y;
    v[x].push_back(y);
}
memset(dp,-1,sizeof dp);
for(ll i=1;i<=n;i++)
ans=max(ans,dfs(i));
cout<<ans;
return 0;
}


Measured memory_bytes: 11644
#include <cassert>
#include <cctype>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <iomanip>
#include <limits>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;
unsigned long long rdtsc(){unsigned long long ret=0;asm volatile("rdtsc" : "=A" (ret) : :);return ret;}
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define reunique(v) v.erase(unique(all(v)),v.end())
#define RET(p,x) return p<<x,0;
#define Debug(x) cerr<<#x<<" = "<<x<<endl
const int inf=1e9;
const int mod=1e9+7;
int n,nowx,nowy,nowt;
signed main()
{
	rdtsc();
	cout<<setprecision(10);
	cin>>n;
	while (n--)
	{
		int t,x,y;
		cin>>t>>x>>y;
		int p=abs(x-nowx)+abs(y-nowy),pt=t-nowt;
		if (!(p<=pt && p%2==pt%2))
		{
			RET(cout,"No");
		}
		nowx=x;
		nowy=y;
		nowt=t;
	}
	RET(cout,"Yes");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[100010];
    rep(i, N) cin >> a[i];
    rep(i, N) {
        if (a[i] % 2) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rt return
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
char s[maxn];
char t[maxn];
char w[maxn];
int n;
int main()
{
    gbtb;
    int ans=0;
    cin>>n;
    cin>>s>>w>>t;
    repd(i,0,n-1)
    {
    	char x=s[i];
    	int cnt=0;
    	if(x!=t[i])
    	{
    		cnt++;
    		if(t[i]!=w[i])
    		{
    			if(x!=w[i])
    				cnt++;
    		}
    	}else
    	{
    	    if(w[i]!=x)
            {
                cnt++;
            }
    	}
    	ans+=cnt;
    }
    cout<<ans<<endl;
    return 0;
}

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



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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

struct edge{
  int n;
  LL s;
};

struct node{
  int n;
  LL x;
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<list<struct edge>> e(n,list<struct edge>());
  int u,v;
  LL s;
  for(int i=0;i<m;i++){
    cin >> u >> v;
    u--;
    v--;
    cin >> s;
    e[u].push_back({v,s});
    e[v].push_back({u,s});
  }
  vector<LL> color(n,0);
  vector<LL> total(n);
  queue<int> bfs;
  LL sita=1,ue=1000000000;
  bfs.push(0);
  color[0]=1;
  total[0]=0;
  int now;
  LL tmp;
  bool kisuu=false;
  while(!bfs.empty()){
    now=bfs.front();
    bfs.pop();
    for(auto itr=e[now].begin();itr!=e[now].end();itr++){
      if(color[(*itr).n]){
        if(color[(*itr).n]==color[now]){
          kisuu=true;
          if(((*itr).s-total[(*itr).n]-total[now])%2){
            cout << 0 << endl;
            return 0;
          }else{
            tmp=((*itr).s-total[(*itr).n]-total[now])/2/color[now];
            if(sita<=tmp&&tmp<=ue){
              ue=sita=tmp;
            }else{
              cout << 0 << endl;
              return 0;
            }
          }
        }else{
          if(total[(*itr).n]+total[now]==(*itr).s){
            if(color[now]==1){
              ue=min(ue,(*itr).s-total[now]);
              ue=min(ue,total[(*itr).n]-1);
              sita=max(sita,1-total[now]);
              sita=max(sita,-(*itr).s+total[(*itr).n]);
            }else{
              ue=min(ue,(*itr).s-total[(*itr).n]);
              ue=min(ue,total[now]-1);
              sita=max(sita,1-total[(*itr).n]);
              sita=max(sita,-(*itr).s+total[now]);
            }
          }else{
            cout << 0 << endl;
            return 0;
          }
        }
      }else{
        bfs.push((*itr).n);
        color[(*itr).n]=-1*color[now];
        total[(*itr).n]=(*itr).s-total[now];
        if(color[(*itr).n]==1){
          sita=max(sita,1-(*itr).s+total[now]);
        }else{
          ue=min(ue,(*itr).s-total[now]-1);
        }
      }
    }
  }
  if(kisuu){
    cout << 1 << endl;
  }else{
    cout << max(ue-sita+1,0) << endl;
  }
  return 0;
}


Measured memory_bytes: 13184
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	string s;
	cin >> s;
	ll a = 0, b = 0;
	rep(i, 3){
		if(s[i] == 'A') a++;
		else b++;
	}

	if(a == 0 || b == 0) puts("No");
	else puts("Yes");

	return 0;
}


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

int main()
{
    long long A,B,C,K;
    cin>>A>>B>>C>>K;
    if(K%2==0)
        cout<<(A-B)<<endl;
    else
        cout<<(B-A)<<endl;
    return 0;
}


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

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define y1 asdgh
#define int long long
#define double long double
#define endl '\n'
mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

/*------------------------------<Debugging Stuff>---------------------------------*/

template<class L, class R> ostream& operator<<(ostream &os, pair<L , R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R , class M> ostream& operator<<(ostream &os, tuple<L , R , M> P) {
    return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")";
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "{ "; for(auto v : V) os << v << " "; return os << "}";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

/*------------------------------</Debugging Stuff>--------------------------------*/
const int maxn = (int) 1e6 + 6;
const double EPS = 1e-9;
const int INF = (int) 1e9 + 10;
const int mod = (int) 1e9 + 7;

inline int add(int x, int y){ return (x + y) % mod; }
inline int sub(int x, int y){ return (x - y + mod) % mod; }
inline int mul(int x, int y){ return (x * y) % mod;}
inline int binpow(int a, int b){
    int x = 1 % mod;
    while(b){
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a){ return binpow(a, mod - 2);}

signed main() {
    fio;
    int n , k; cin >> n >> k;
    vector<int> a(n);
    for(int &it : a) cin >> it;
    sort(a.begin() , a.end());
    int answer = 0;
    vector<int> fac(n + 1) , ifac(n + 1);
    fac[0] = 1;
    for(int i = 1; i <= n; i++) fac[i] = mul(i , fac[i - 1]);
    for(int i = 0; i <= n; i++) ifac[i] = inv(fac[i]);
    auto get = [&](int n , int r) {
        return mul(fac[n] , mul(ifac[r] , ifac[n - r]));
    };
    for(int i = 0; i < n; i++) {
        if(i >= k - 1) {
            answer = add(answer , mul(a[i] , get(i , k - 1)));
        }
        if(n - i - 1 >= k - 1) {
            answer = sub(answer , mul(a[i] , get(n - i - 1 , k - 1)));
        }
    }
    
    assert(answer >= 0 and answer < mod);
    cout << answer << endl;

    return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int o = 0;
  for(int i = 1; i <= n; i++) {
    if(i % 2 == 1) {
      ++o;
    }
  }
  double ans = (double)o / (double)n;
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cstring>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))
#define EPS (1e-10)

using namespace std;
//using namespace boost::multiprecision;

const long long MOD = 1000000007;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator+(Point p){return Point(x + p.x, y + p.y);}
    Point operator-(Point p){return Point(x - p.x, y - p.y);}
    Point operator*(double a){return Point(a * x, a * y);}
    Point operator/(double a){return Point(x / a, y / a);}

    bool operator < (const Point &p) const {
        return y != p.y ? y < p.y : x < p.x;
    }

    double norm(){return x * x + y * y;}
};
typedef Point Vector;
typedef vector<Vector> Polygon;

double cross(Vector a, Vector b){
    return a.x*b.y - a.y*b.x;
}

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS)return COUNTER_CLOCKWISE;
    if (cross(a, b) > -EPS)return CLOCKWISE;
    if (dot(a, b) < -EPS)return ONLINE_BACK;
    if (a.norm() < b.norm())return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon andrewScan(Polygon s){
    Polygon u, l;
    if (s.size() < 3) return s;
    sort(s.begin(), s.end());
    u.push_back(s[0]);
    u.push_back(s[1]);
    l.push_back(s[s.size()-1]);
    l.push_back(s[s.size()-2]);
    
    for (size_t i = 2; i < s.size(); i++){
        for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            u.pop_back();
        }
        u.push_back(s[i]);
    }

    for (int i = (int)s.size() - 3; i >= 0; i--){
        for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            l.pop_back();
        }
        l.push_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}


int main(void){
    int a[3];
    for (int i = 0; i < 3; i++){
        cin >> a[i];
    }
    int K;
    cin >> K;
    sort(a, a+3);
    a[2] = a[2] * mod_pow(2, K);
    cout << a[0] + a[1] + a[2] << endl;
    return 0;
}   



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc71
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int f = -1;
            int a = (int)'a';
            for(int i = 0; i < 26; i++)
            {
                for(int j = 0; j < S.Length; j++)
                {
                    if ((int)S[j] == i+a)
                    {
                        break;
                    }else if (j == S.Length - 1)
                    {
                        f = i;
                        break;
                    }
                }
                if (f != -1)
                {
                    break;
                }
                if (i == 25)
                {
                    f = 26;
                }
            }
            if (f == 26)
            {
                Console.WriteLine("None");
            }else
            {
                Console.WriteLine((char)(a + f));
            }
        }
    }
}


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

int main() {
    int p[3], s;
    for (int i = 0; i < 3; i++) cin >> p[i];

    for (int i = 0; i < 3; i++) {
        if (p[0] < p[1]) {
            s = p[0];
            p[0] = p[1];
            p[1] = s;
        }

        if (p[1] < p[2]) {
            s = p[1];
            p[1] = p[2];
            p[2] = s;
        }
    }

    cout << p[0] * 10 + p[1] + p[2] << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

template <typename T>
class SegTree {
  int n;
  vector<T> data;
  T default_value;
  function<T(T a, T b)> operation;
  function<T(T prev_val, T new_val)> _update;

  // [a,b)
  T query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
      return default_value;
    }

    if (a <= l && r <= b) {
      return data[k];
    } else {
      T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return operation(vl, vr);
    }
  }

 public:
  SegTree(size_t _n, T _default_value, function<T(T a, T b)> _operation,
          function<T(T prev_val, T new_val)> update_function)
    : default_value(_default_value), operation(_operation), _update(update_function) {
    n = 1;
    while (n < _n) {
      n <<= 1;
    }
    data = vector<T>(2 * n - 1, default_value);
  }

  SegTree(vector<T> initial_value, T _default_value, function<T(T a, T b)> _operation,
          function<T(T prev_val, T new_val)> update_function)
    : default_value(_default_value), operation(_operation), _update(update_function) {
    ll sz = initial_value.size();
    n = 1;
    while (n < sz) {
      n <<= 1;
    }
    data = vector<T>(2 * n - 1, default_value);
    for (int i = 0; i < sz; i++) {
      data[n - 1 + i] = initial_value[i];
    }
    for (int i = n - 2; i >= 0; i--) {
      data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // update i-th value (0-indexed)
  void update(int i, T x) {
    i += n - 1;
    data[i] = _update(data[i], x);
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // execute query of section [a, b)
  T query(int a, int b) {
    return query(a, b, 0, 0, n);
  }

  // get i-th value
  T operator[](int i) {
    return data[i + n - 1];
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;
  vll h(n);
  vll a(n);
  rep(i, n) {
    cin >> h[i];
  }
  rep(i, n) {
    cin >> a[i];
  }

  // get max
  SegTree<ll> st(
    n + 10, 0ll, [](ll a, ll b) { return max(a, b); }, [](ll prev_val, ll new_val) { return new_val; });

  rep(i, n) {
    ll mx = st.query(0, h[i]);
    st.update(h[i], mx + a[i]);
  }

  cout << st.query(0, n + 1) << endl;

  return 0;
}


Measured memory_bytes: 7552
#include<iostream>
using namespace std;
int main(void){
  int n,a,b;
  cin>>n>>a>>b;
  int sum(0);
  for(int i(1);i<=n;i++){
    int v(0),w(0),x(0),y(0),z(0);
    int t=i;
    v=t/10000;
    t%=10000;
    w=t/1000;
    t%=1000;
    x=t/100;
    t%=100;
    y=t/10;
    t%=10;
    z=t;
    int m=v+w+x+y+z;
    if(m>=a && m<=b){
      sum+=i;
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int>h(n); for (auto& e : h)cin >> e;

	int ans=0,tmp=0;
	for (int i = 0; i < n-1; ++i) {
		if (h[i] >= h[i+1])tmp++;
		if(h[i]<h[i+1]||i==n-2) {
			ans = max(ans, tmp);
			tmp = 0;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int a[100005 + 5],vis[100005 + 5];

int main(){
	int n,ans = 0,all = 0;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		if(a[i] % 4 == 0){
			ans++;
			vis[i] = 1;
		}
	}
	if(ans >= n / 2){
		cout << "Yes";
	}
	else{
		for(int i = 1;i <= n;i++){
			if(vis[i] == 0 && a[i] % 2 == 0) all++;
		}
		if(n - 2 * ans <= all) cout << "Yes";
		else cout << "No";
	}
}

Measured memory_bytes: 1024
using System;
class AOJ0510
{
    static void Main()
    {
        int[] sum = new int[2];
        for (int i = 0; i < 2; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            foreach (string scr in input)
            {
                sum[i] += int.Parse(scr);
            }
        }
        Console.WriteLine(sum[0] > sum[1] ? sum[0] : sum[1]);
    }
}

Measured memory_bytes: 19928
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

class UF(object):
    def __init__(self,n):
        self.par = [i for i in range(n)]
        self.rank = [0]*n
        self.size = [1]*n

    # x が属する集合の代表値を返す
    def find(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = y = self.find(self.par[x])
            return y

    # x と y の集合を結合する
    def union(self,x,y):
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        else:
            if self.rank[px] < self.rank[py]:
                px, py = py, px
            if self.rank[px] == self.rank[py]:
                self.rank[px] += 1
            self.par[py] = px
            self.size[px] += self.size[py]
            return

    # x と y が同じ集合に属するか判定する
    def is_same(self,x,y):
        return self.find(x) == self.find(y)

    # x が属する集合の要素数を返す
    def get_size(self,x):
        return self.size[self.find(x)]

N,M,K = LI()
A,B = LIR(M,2)
C,D = LIR(K,2)
 
b = defaultdict(set)
t = defaultdict(set)
 
uf = UF(N)
 
for i in range(M):
    uf.union(A[i]-1,B[i]-1)
    t[A[i]-1].add(B[i]-1)
    t[B[i]-1].add(A[i]-1)
    
num = [0]*N
for i in range(K):
    if uf.is_same(C[i]-1, D[i]-1):
        num[C[i]-1] -= 1
        num[D[i]-1] -= 1
        
ans = []
for i in range(N):
    ans.append(uf.get_size(i)-1-len(t[i])+num[i])
print(*ans)

Measured memory_bytes: 130524
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,M;
int k[10];
int s[10][10];
int p[10];

int sta[10];

int main(){
    cin>>N>>M;
    rep(i,M){
        cin>>k[i];
        rep(j,k[i]){
            cin>>s[i][j];
        }
    }
    rep(i,M){
        cin>>p[i];
    }

    int ans=0;
    for(int i=0;i<1<<N;i++){
        for(int j=0;j<N;j++){
            sta[j]=i>>j&1;
        }

        for(int j=0;j<M;j++){
            int sum=0;
            for(int n=0;n<k[j];n++){
                sum+=sta[s[j][n]-1];
            }
            if(sum%2!=p[j]) goto a;
        }
        ans++;
        a:;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	cout << fixed << setprecision(15);
	int N;
	cin >> N;
	vector<tuple<long double, long double, long double>> V(N);
	for (int i = 0; i < N; i++){
		int x, y;
		cin >> x >> y;
		V[i] = make_tuple(atan2(y, x), y, x);
	}
	sort(V.begin(), V.end());
	double ans = 0;
	for (int i = 0; i < N; i++){
		for (int j = i; j < N; j++){
			double y = 0;
			double x = 0;
			for (int k = i; k <= j; k++){
				y += get<1>(V[k]);
				x += get<2>(V[k]);
			}
			ans = max(ans, hypot(x, y));
		}
	}
	for (int i = 0; i < N; i++){
		for (int j = i; j < N; j++){
			double y = 0;
			double x = 0;
			for (int k = 0; k < i; k++){
				y += get<1>(V[k]);
				x += get<2>(V[k]);
			}
			for (int k = j; k < N; k++){
				y += get<1>(V[k]);
				x += get<2>(V[k]);
			}
			ans = max(ans, hypot(x, y));
		}
	}
	cout << ans << endl;
}

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

int main()
{
	// ios::sync_with_stdio(0);


	long long n, a, b;
	cin >> n >> a >> b;
 
	if(a==0)
	{
		cout << "0\n";
		return 0;
	}
 
	if(b == 0)
	{
		cout << n;
		return 0;
	}
 
	cout << ( ( n /(a+b) )* a ) + min(n%(a+b), a) <<"\n";
	
	return 0;
	
	return 0;
}


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


int main(){
  int N;
  cin >> N;
  
  if(N%10==3)
    cout << "bon" << endl;
  else if(N%10==0 || N%10==1 || N%10==6 || N%10==8)
    cout << "pon" << endl;
  else
    cout << "hon" << endl;
 
  
  
 
  
}

Measured memory_bytes: 3636